(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var n=function(t){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,"string");if("object"!=e(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(n)?n:n+""}function n(e,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,t(o.key),o)}}function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}const i=gutenverseCoreFrontend;function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}var a=function(t){function a(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),t=this,o=arguments,n=r(n=a),function(t,n){if(n&&("object"==e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,u()?Reflect.construct(n,o||[],r(t).constructor):n.apply(t,o));var t,n,o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t)}(a,t),c=a,(f=[{key:"init",value:function(){var e=this,t=this._elements,n=window.GutenverseFrontendConfig,r=n.framework_asset,o=n.framework_version;t.length>0&&(0,i.load)(r+"js/ReactPlayer.standalone.js?ver="+o,function(n){n||t.map(function(t){e._renderVideo(t)}),window.addEventListener("resize",function(){t.map(function(t){e._calculateSize(t)})},!0)})}},{key:"_getYouTubeVideoId",value:function(e){for(var t=0,n=[/(?:youtube\.com\/(?:embed|v)\/|youtu\.be\/)([\w-]{11})/,/youtube\.com\/watch\?.*v=([\w-]{11})/,/youtube-nocookie\.com\/(?:embed|v)\/([\w-]{11})/];t<n.length;t++){var r=n[t],o=e.match(r);if(o)return o[1]}return null}},{key:"_normalizeVideoUrl",value:function(e){if(!e)return e;var t=this._getYouTubeVideoId(e);return t?"https://www.youtube.com/embed/".concat(t):e}},{key:"_calculateSize",value:function(e){var t=(0,i.u)(e).find(".guten-video-bg-wrapper");if(t.length){var n=(0,i.u)(e).find(".guten-video-bg-wrapper > div"),r=(0,i.u)(t).size(),o=Math.floor(.56*r.width),u=Math.floor(r.height/.56);o>r.height?n.attr("style","width: ".concat(r.width,"px; height: ").concat(o,"px")):n.attr("style","width: ".concat(u,"px; height: ").concat(r.height,"px"))}}},{key:"_renderVideo",value:function(t){var n=this,r=(0,i.u)(t).data("property"),o=r?JSON.parse(r):null;if(o&&"object"===e(o)&&o.url){o.url=this._normalizeVideoUrl(o.url),o.config||(o.config={}),o.config.youtube||(o.config.youtube={}),o.config.youtube.playerVars||(o.config.youtube.playerVars={});var u=o.config.youtube.playerVars;0!==u.start&&"0"!==u.start||delete u.start,0!==u.end&&"0"!==u.end||delete u.end;var a=o.playing&&!o.muted;o.playing&&(u.autoplay=1,u.mute=1,u.enablejsapi=1,o.muted=!0),renderReactPlayer(t,o),setTimeout(function(){n._calculateSize(t),(0,i.u)(t).find(".guten-video-bg-wrapper").addClass("loaded")},1),a&&this._attemptUnmute(t)}}},{key:"_attemptUnmute",value:function(e){setTimeout(function(){var t=e.querySelector("video");if(t)t.muted=!1;else{var n=e.querySelector("iframe");n&&n.contentWindow&&n.contentWindow.postMessage(JSON.stringify({event:"command",func:"unMute",args:[]}),"*")}},2e3)}}])&&n(c.prototype,f),Object.defineProperty(c,"prototype",{writable:!1}),c;var c,f}(i.Default),c=(0,i.u)(".guten-video-wrapper");c&&new a(c)})();