(()=>{"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 o=function(t){if("object"!=e(t)||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var n=o.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(o)?o:o+""}function o(e,o){for(var n=0;n<o.length;n++){var r=o[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,t(r.key),r)}}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(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,r=arguments,o=n(o=a),function(t,o){if(o&&("object"==e(o)||"function"==typeof o))return o;if(void 0!==o)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(o,r||[],n(t).constructor):o.apply(t,r));var t,o,r}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&&r(e,t)}(a,t),c=a,(f=[{key:"init",value:function(){var e=this,t=this._elements,o=window.GutenverseFrontendConfig,n=o.framework_asset,r=o.framework_version;t.length>0&&(0,i.load)(n+"js/ReactPlayer.standalone.js?ver="+r,function(o){o||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,o=[/(?:youtube\.com\/(?:embed|v)\/|youtu\.be\/)([\w-]{11})/,/youtube\.com\/watch\?.*v=([\w-]{11})/,/youtube-nocookie\.com\/(?:embed|v)\/([\w-]{11})/];t<o.length;t++){var n=o[t],r=e.match(n);if(r)return r[1]}return null}},{key:"_normalizeVideoUrl",value:function(e){if(!e)return e;var t="www.youtube.com";e.includes("www.youtube-nocookie.com")&&(t="www.youtube-nocookie.com");var o=this._getYouTubeVideoId(e);return o?"https://".concat(t,"/embed/").concat(o):e}},{key:"_calculateSize",value:function(e){var t=(0,i.u)(e).find(".guten-video-bg-wrapper");if(t.length){var o=(0,i.u)(e).find(".guten-video-bg-wrapper > div"),n=(0,i.u)(t).size(),r=Math.floor(.56*n.width),u=Math.floor(n.height/.56);r>n.height?o.attr("style","width: ".concat(n.width,"px; height: ").concat(r,"px")):o.attr("style","width: ".concat(u,"px; height: ").concat(n.height,"px"))}}},{key:"_renderVideo",value:function(t){var o=this,n=(0,i.u)(t).data("property"),r=n?JSON.parse(n):null;if(r&&"object"===e(r)&&r.url){r.url=this._normalizeVideoUrl(r.url),r.config||(r.config={}),r.config.youtube||(r.config.youtube={}),r.config.youtube.playerVars||(r.config.youtube.playerVars={});var u=r.config.youtube.playerVars;0!==u.start&&"0"!==u.start||delete u.start,0!==u.end&&"0"!==u.end||delete u.end;var a=r.playing&&!r.muted;r.playing&&(u.autoplay=1,u.mute=1,u.enablejsapi=1,r.muted=!0),renderReactPlayer(t,r),setTimeout(function(){o._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 o=e.querySelector("iframe");o&&o.contentWindow&&o.contentWindow.postMessage(JSON.stringify({event:"command",func:"unMute",args:[]}),"*")}},2e3)}}])&&o(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)})();