{"version":3,"file":"discourse-lazy-videos.js","names":["define","_exports","_component","_component2","_templateFactory","Object","defineProperty","value","default","LazyIframe","iframeSrc","this","args","providerName","url","videoId","startTime","time","match","toString","hours","minutes","seconds","slice","parseInt","convertToSeconds","includes","static","setComponentTemplate","createTemplateFactory","id","block","moduleName","isStrictMode","_tracking","_helper","_modifier","_object","_template","_concatClass","_lazyIframe","LazyVideo","dt7948","g","prototype","tracked","isLoaded","i","thumbnailStyle","color","videoAttributes","dominantColor","htmlSafe","loadEmbed","onLoadedVideo","n","action","onKeyPress","event","key","preventDefault","scope","concat","on","_pluginApi","_lazyVideo","_lazyVideoAttributes","_templateOnly","initLazyEmbed","api","decorateCookedElement","cooked","helper","classList","contains","querySelectorAll","forEach","container","siteSettings","lookup","postId","closest","dataset","preventCloak","lazyVideo","document","createElement","add","renderGlimmer","undefined","param","replaceWith","onlyStream","name","initialize","withPluginApi","querySelector","getAttribute","img","thumbnail","title","videoTitle","videoStartTime"],"sources":["discourse/plugins/discourse-lazy-videos/discourse/components/lazy-iframe.js","discourse/plugins/discourse-lazy-videos/discourse/components/lazy-video.js","discourse/plugins/discourse-lazy-videos/initializers/lazy-videos.js","discourse/plugins/discourse-lazy-videos/lib/lazy-video-attributes.js"],"sourcesContent":["define(\"discourse/plugins/discourse-lazy-videos/discourse/components/lazy-iframe\", [\"exports\", \"@glimmer/component\", \"@ember/component\", \"@ember/template-factory\"], function (_exports, _component, _component2, _templateFactory) {\n \"use strict\";\n\n Object.defineProperty(_exports, \"__esModule\", {\n value: true\n });\n _exports.default = void 0;\n function convertToSeconds(time) {\n const match = time.toString().match(/(?:(\\d+)h)?(?:(\\d+)m)?(?:(\\d+)s)?/);\n const [hours, minutes, seconds] = match.slice(1);\n if (hours || minutes || seconds) {\n const h = parseInt(hours, 10) || 0;\n const m = parseInt(minutes, 10) || 0;\n const s = parseInt(seconds, 10) || 0;\n return h * 3600 + m * 60 + s;\n }\n return time;\n }\n class LazyIframe extends _component.default {\n get iframeSrc() {\n switch (this.args.providerName) {\n case \"youtube\":\n let url = `https://www.youtube.com/embed/${this.args.videoId}?autoplay=1&rel=0`;\n if (this.args.startTime) {\n url += `&start=${convertToSeconds(this.args.startTime)}`;\n }\n return url;\n case \"vimeo\":\n return `https://player.vimeo.com/video/${this.args.videoId}${this.args.videoId.includes(\"?\") ? \"&\" : \"?\"}autoplay=1`;\n case \"tiktok\":\n return `https://www.tiktok.com/embed/v2/${this.args.videoId}`;\n }\n }\n static #_ = (() => (0, _component2.setComponentTemplate)((0, _templateFactory.createTemplateFactory)(\n /*\n \n {{#if @providerName}}\n \n {{/if}}\n \n */\n {\n \"id\": \"GBbnVjZj\",\n \"block\": \"[[[1,\\\"\\\\n\\\"],[41,[30,1],[[[1,\\\" \\\"],[10,\\\"iframe\\\"],[15,\\\"src\\\",[30,0,[\\\"iframeSrc\\\"]]],[15,\\\"title\\\",[30,2]],[14,\\\"allowFullScreen\\\",\\\"\\\"],[14,\\\"scrolling\\\",\\\"no\\\"],[14,\\\"frameborder\\\",\\\"0\\\"],[14,\\\"seamless\\\",\\\"seamless\\\"],[14,\\\"allow\\\",\\\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\\\"],[12],[13],[1,\\\"\\\\n\\\"]],[]],null],[1,\\\" \\\"]],[\\\"@providerName\\\",\\\"@title\\\"],false,[\\\"if\\\"]]\",\n \"moduleName\": \"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-lazy-videos/discourse/components/lazy-iframe.js\",\n \"isStrictMode\": true\n }), this))();\n }\n _exports.default = LazyIframe;\n});","define(\"discourse/plugins/discourse-lazy-videos/discourse/components/lazy-video\", [\"exports\", \"@glimmer/component\", \"@glimmer/tracking\", \"@ember/helper\", \"@ember/modifier\", \"@ember/object\", \"@ember/template\", \"discourse/helpers/concat-class\", \"discourse/plugins/discourse-lazy-videos/discourse/components/lazy-iframe\", \"@ember/component\", \"@ember/template-factory\"], function (_exports, _component, _tracking, _helper, _modifier, _object, _template, _concatClass, _lazyIframe, _component2, _templateFactory) {\n \"use strict\";\n\n Object.defineProperty(_exports, \"__esModule\", {\n value: true\n });\n _exports.default = void 0;\n class LazyVideo extends _component.default {\n static #_ = (() => dt7948.g(this.prototype, \"isLoaded\", [_tracking.tracked], function () {\n return false;\n }))();\n #isLoaded = (() => (dt7948.i(this, \"isLoaded\"), void 0))();\n get thumbnailStyle() {\n const color = this.args.videoAttributes.dominantColor;\n if (color?.match(/^[0-9A-Fa-f]+$/)) {\n return (0, _template.htmlSafe)(`background-color: #${color};`);\n }\n }\n loadEmbed() {\n if (!this.isLoaded) {\n this.isLoaded = true;\n this.args.onLoadedVideo?.();\n }\n }\n static #_2 = (() => dt7948.n(this.prototype, \"loadEmbed\", [_object.action]))();\n onKeyPress(event) {\n if (event.key === \"Enter\") {\n event.preventDefault();\n this.loadEmbed();\n }\n }\n static #_3 = (() => dt7948.n(this.prototype, \"onKeyPress\", [_object.action]))();\n static #_4 = (() => (0, _component2.setComponentTemplate)((0, _templateFactory.createTemplateFactory)(\n /*\n \n