define("discourse/plugins/discourse-lazy-videos/discourse/components/lazy-iframe",["exports","@ember/component","@glimmer/component","@ember/template-factory"],(function(e,t,i,o){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const r=(0,o.createTemplateFactory)({id:"aRGjz/CC",block:'[[[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]],["@providerName","@title"],false,["if"]]',moduleName:"discourse/plugins/discourse-lazy-videos/discourse/components/lazy-iframe.hbs",isStrictMode:!1})
class a extends i.default{get iframeSrc(){switch(this.args.providerName){case"youtube":let e=`https://www.youtube.com/embed/${this.args.videoId}?autoplay=1&rel=0`
return this.args.startTime&&(e+=`&start=${this.convertToSeconds(this.args.startTime)}`),e
case"vimeo":return`https://player.vimeo.com/video/${this.args.videoId}${this.args.videoId.includes("?")?"&":"?"}autoplay=1`
case"tiktok":return`https://www.tiktok.com/embed/v2/${this.args.videoId}`}}convertToSeconds(e){const t=e.toString().match(/(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?/),[i,o,r]=t.slice(1)
if(i||o||r){return 3600*(parseInt(i,10)||0)+60*(parseInt(o,10)||0)+(parseInt(r,10)||0)}return e}}e.default=a,(0,t.setComponentTemplate)(r,a)})),define("discourse/plugins/discourse-lazy-videos/discourse/components/lazy-video",["exports","@ember/component","@glimmer/component","@glimmer/tracking","@ember/object","@ember/template","@ember/template-factory"],(function(e,t,i,o,r,a,s){"use strict"
var l,n
function d(e,t,i,o,r){var a={}
return Object.keys(o).forEach((function(e){a[e]=o[e]})),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=i.slice().reverse().reduce((function(i,o){return o(e,t,i)||i}),a),r&&void 0!==a.initializer&&(a.value=a.initializer?a.initializer.call(r):void 0,a.initializer=void 0),void 0===a.initializer&&(Object.defineProperty(e,t,a),a=null),a}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const c=(0,s.createTemplateFactory)({id:"5+HCJd+d",block:'[[[10,0],[15,0,[28,[37,0],["lazy-video-container",[28,[37,1],[[30,1,["providerName"]],"-onebox"],null],[52,[30,0,["isLoaded"]],"video-loaded"]],null]],[15,"data-video-id",[30,1,["id"]]],[15,"data-video-title",[30,1,["title"]]],[15,"data-video-start-time",[30,1,["startTime"]]],[15,"data-provider-name",[30,1,["providerName"]]],[12],[1,"\\n"],[41,[30,0,["isLoaded"]],[[[1,"    "],[8,[39,3],null,[["@providerName","@title","@videoId","@startTime"],[[30,1,["providerName"]],[30,1,["title"]],[30,1,["id"]],[30,1,["startTime"]]]],null],[1,"\\n"]],[]],[[[1,"    "],[11,0],[16,0,[28,[37,0],["video-thumbnail",[30,1,["providerName"]]],null]],[24,"tabindex","0"],[16,5,[30,0,["thumbnailStyle"]]],[4,[38,4],["click",[30,0,["loadEmbed"]]],null],[4,[38,4],["keypress",[30,0,["loadEmbed"]]],null],[12],[1,"\\n      "],[10,"img"],[15,0,[28,[37,1],[[30,1,["providerName"]],"-thumbnail"],null]],[15,"src",[30,1,["thumbnail"]]],[15,"title",[30,1,["title"]]],[14,"loading","lazy"],[12],[13],[1,"\\n      "],[10,0],[15,0,[28,[37,0],["icon",[28,[37,1],[[30,1,["providerName"]],"-icon"],null]],null]],[12],[13],[1,"\\n    "],[13],[1,"\\n    "],[10,0],[14,0,"title-container"],[12],[1,"\\n      "],[10,0],[14,0,"title-wrapper"],[12],[1,"\\n        "],[10,3],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[14,0,"title-link"],[15,6,[30,1,["url"]]],[15,"title",[30,1,["title"]]],[12],[1,"\\n          "],[1,[30,1,["title"]]],[1,"\\n        "],[13],[1,"\\n      "],[13],[1,"\\n    "],[13],[1,"\\n"]],[]]],[13]],["@videoAttributes"],false,["concat-class","concat","if","lazy-iframe","on"]]',moduleName:"discourse/plugins/discourse-lazy-videos/discourse/components/lazy-video.hbs",isStrictMode:!1})
let u=e.default=(l=class extends i.default{constructor(){var e,t,i,o
super(...arguments),e=this,t="isLoaded",o=this,(i=n)&&Object.defineProperty(e,t,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(o):void 0})}loadEmbed(){this.isLoaded||(this.isLoaded=!0,this.args.onLoadedVideo?.())}onKeyPress(e){"Enter"===e.key&&(e.preventDefault(),this.loadEmbed())}get thumbnailStyle(){const e=this.args.videoAttributes.dominantColor
if(e?.match(/^[0-9A-Fa-f]+$/))return(0,a.htmlSafe)(`background-color: #${e};`)}},n=d(l.prototype,"isLoaded",[o.tracked],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),d(l.prototype,"loadEmbed",[r.action],Object.getOwnPropertyDescriptor(l.prototype,"loadEmbed"),l.prototype),d(l.prototype,"onKeyPress",[r.action],Object.getOwnPropertyDescriptor(l.prototype,"onKeyPress"),l.prototype),l);(0,t.setComponentTemplate)(c,u)})),define("discourse/plugins/discourse-lazy-videos/initializers/lazy-videos",["exports","discourse/lib/plugin-api","discourse/plugins/discourse-lazy-videos/lib/lazy-video-attributes","@ember/template-factory"],(function(e,t,i,o){"use strict"
function r(e){e.decorateCookedElement(((t,r)=>{if(t.classList.contains("d-editor-preview"))return
t.querySelectorAll(".lazy-video-container").forEach((a=>{const s=e.container.lookup("service:site-settings"),l=(0,i.default)(a)
if(s[`lazy_${l.providerName}_enabled`]){const i=()=>{const i=t.closest("article")?.dataset?.postId
i&&e.preventCloak(parseInt(i,10))},s=r.renderGlimmer("p.lazy-video-wrapper",(0,o.createTemplateFactory)({id:"BIb4XPBx",block:'[[[8,[39,0],null,[["@videoAttributes","@onLoadedVideo"],[[30,1,["param"]],[30,1,["onLoadedVideo"]]]],null]],["@data"],false,["lazy-video"]]',moduleName:"/var/www/discourse/app/assets/javascripts/discourse/discourse/plugins/discourse-lazy-videos/initializers/lazy-videos.js",isStrictMode:!1}),{param:l,onLoadedVideo:i})
a.replaceWith(s)}}))}),{onlyStream:!0})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={name:"discourse-lazy-videos",initialize(){(0,t.withPluginApi)("1.6.0",r)}}})),define("discourse/plugins/discourse-lazy-videos/lib/lazy-video-attributes",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(e){if(!e.classList.contains("lazy-video-container"))return{}
const t=e.querySelector("a")?.getAttribute("href"),i=e.querySelector("img"),o=i?.getAttribute("src"),r=i?.dataset?.dominantColor,a=e.dataset.videoTitle,s=e.dataset.videoStartTime,l=e.dataset.providerName,n=e.dataset.videoId
return{url:t,thumbnail:o,title:a,providerName:l,id:n,dominantColor:r,startTime:s}}}))

//# sourceMappingURL=discourse-lazy-videos-6832d6205141068be6c94993f8a6948a13bcf4d05bbb293f5fc2af59cc0cc172.map
//!

;
