"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["33495"],{25995:function(e,t,n){n.d(t,{Vw:function(){return a},kG:function(){return o},y6:function(){return s}});n(3362);const r=(e,t,n)=>new Promise((r,s)=>{const o=document.createElement(e);let a="src",i="body";switch(o.onload=()=>r(t),o.onerror=()=>s(t),e){case"script":o.async=!0,n&&(o.type=n);break;case"link":o.type="text/css",o.rel="stylesheet",a="href",i="head"}o[a]=t,document[i].appendChild(o)}),s=e=>r("link",e),o=e=>r("script",e),a=e=>r("script",e,"module")},6378:function(e,t,n){n.r(t),n.d(t,{HaPanelCustom:function(){return p}});n(74423),n(62953);var r=n(40445),s=n(96196),o=n(77845),a=n(91926),i=n(19459);n(3362);var l=n(25995);const c={},u=e=>e.html_url?{type:"html",url:e.html_url}:e.module_url&&e.js_url?{type:"js",url:e.js_url}:e.module_url?{type:"module",url:e.module_url}:{type:"js",url:e.js_url};n(18111),n(7588);const h=(e,t)=>{"setProperties"in e?e.setProperties(t):Object.keys(t).forEach(n=>{e[n]=t[n]})};class p extends s.mN{createRenderRoot(){return this}registerIframe(e,t){var n;e(this.panel,{hass:this.hass,narrow:this.narrow,route:this.route}),this._setProperties=t,null===(n=this.querySelector("iframe"))||void 0===n||n.classList.add("loaded")}disconnectedCallback(){super.disconnectedCallback(),this._cleanupPanel()}update(e){if(super.update(e),e.has("panel")){const t=e.get("panel");if(!(0,i.b)(t,this.panel))return t&&this._cleanupPanel(),void this._createPanel(this.panel)}if(!this._setProperties)return;const t={};for(const n of e.keys())t[n]=this[n];this._setProperties(t)}_cleanupPanel(){for(delete window.customPanel,this._setProperties=void 0;this.lastChild;)this.removeChild(this.lastChild)}_createPanel(e){this.style.backgroundColor="var(--primary-background-color)";const t=e.config._panel_custom,n=u(t),r=document.createElement("a");if(r.href=n.url,!t.trust_external&&!["localhost","127.0.0.1",location.hostname].includes(r.hostname)&&!confirm(`${this.hass.localize("ui.panel.custom.external_panel.question_trust",{name:t.name,link:r.href})}\n\n           ${this.hass.localize("ui.panel.custom.external_panel.complete_access")}\n\n           (${this.hass.localize("ui.panel.custom.external_panel.hide_message")})`))return;if(!t.embed_iframe)return void(e=>{const t=u(e);return"js"===t.type?(t.url in c||(c[t.url]=(0,l.kG)(t.url)),c[t.url]):"module"===t.type?(0,l.Vw)(t.url):Promise.reject("No valid url found in panel config.")})(t).then(()=>{const n=(e=>{const t="html_url"in e?`ha-panel-${e.name}`:e.name;return document.createElement(t)})(t);this._setProperties=e=>h(n,e),h(n,{panel:e,hass:this.hass,narrow:this.narrow,route:this.route}),this.appendChild(n)},()=>{alert(`Unable to load custom panel from ${r.href}`)});window.customPanel=this;const s=this.panel.title?`title="${this.panel.title}"`:"";this.innerHTML=`\n      <style>\n        iframe {\n          border: none;\n          width: 100%;\n          height: 100vh;\n          height: 100dvh;\n          display: block;\n          background-color: var(--primary-background-color);\n          opacity: 0;\n          transition: opacity var(--ha-animation-duration-normal) ease;\n        }\n        iframe.loaded {\n          opacity: 1;\n        }\n      </style>\n      <iframe ${s}></iframe>`.trim();const o=this.querySelector("iframe").contentWindow.document;o.open(),o.write(`<!doctype html><script src='${window.customPanelJS}'><\/script>`),o.close()}constructor(...e){super(...e),this.narrow=!1,this.navigate=(e,t)=>(0,a.o)(e,t)}}(0,r.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,r.Cg)([(0,o.MZ)({type:Boolean})],p.prototype,"narrow",void 0),(0,r.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"route",void 0),(0,r.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"panel",void 0),p=(0,r.Cg)([(0,o.EM)("ha-panel-custom")],p)}}]);
//# sourceMappingURL=33495.a101ed3289586aca.js.map