(function ($) {
	"use strict";
	var WidgetQRCode = function ($scope, $) {
		if ( $scope.find( '.ec-qr-code-wrapper' ).length ) {
			var content = $scope[0].querySelectorAll( '.ec-qr-code-wrapper' );
			if (content.length > 0) {
				content.forEach(
					function (item) {
						var qrdatas = JSON.parse( item.getAttribute( 'data-qrdatas' ) );
						var itemId  = item.id;
						var qrcode  = new QRCode(
							itemId,
							{
								width: parseInt( qrdatas.qrwidth ),
								height: parseInt( qrdatas.qrheight ),
								text: qrdatas.qrcontent,
								colorDark: qrdatas.colordark,
								colorLight: qrdatas.colorLight,
								correctLevel: QRCode.CorrectLevel.H
							}
						);
					}
				);
			}

		}
	};
	$( window ).on(
		'elementor/frontend/init',
		function () {
			elementorFrontend.hooks.addAction( 'frontend/element_ready/ecafe-qr-code.default', WidgetQRCode );
		}
	);
})( jQuery );