UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

4 lines 75.3 kB
export const __rspack_esm_id=8735;export const __rspack_esm_ids=[8735];export const __webpack_modules__={75248(t,e,i){i.a(t,async function(t,s){try{i.r(e),i.d(e,{HaIconOverflowMenu:()=>_});i(18111),i(61701);var a=i(62826),o=(i(68825),i(5124)),r=i(22441),l=i(93421),n=i(57237),h=i(14503),c=i(29823),d=(i(70947),i(26300)),p=(i(67094),i(34127)),u=t([c,d,p]);[c,d,p]=u.then?(await u)():u;const g="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z";class _ extends o.WF{render(){return 0===this.items.length?o.s6:o.qy` ${this.narrow?o.qy` <ha-dropdown @wa-show="${this._handleIconOverflowMenuOpened}" @click="${n.d}"> <ha-icon-button .label="${this._localize("ui.common.overflow_menu")}" .path="${g}" slot="trigger"></ha-icon-button> ${this.items.map(t=>t.divider?o.qy`<wa-divider></wa-divider>`:o.qy`<ha-dropdown-item ?disabled="${t.disabled}" @click="${t.action}" variant="${t.warning?"danger":"default"}"> <ha-svg-icon slot="icon" .path="${t.path}"></ha-svg-icon> ${t.label} </ha-dropdown-item>`)} </ha-dropdown>`:o.qy` ${this.items.map(t=>t.narrowOnly?o.s6:t.divider?o.qy`<div role="separator"></div>`:o.qy`<ha-tooltip .disabled="${!t.tooltip}" .for="icon-button-${t.label}">${t.tooltip??""} </ha-tooltip><ha-icon-button .id="icon-button-${t.label}" @click="${t.action}" .label="${t.label}" .path="${t.path}" ?disabled="${t.disabled}"></ha-icon-button> `)} `} `}_handleIconOverflowMenuOpened(t){t.stopPropagation()}static get styles(){return[h.RF,o.AH`:host{display:flex;justify-content:flex-end;cursor:initial}div[role=separator]{border-right:1px solid var(--divider-color);width:1px}`]}constructor(...t){super(...t),this.items=[],this.narrow=!1}}(0,a.Cg)([(0,r.wk)(),(0,l.IW)()],_.prototype,"_localize",void 0),(0,a.Cg)([(0,r.MZ)({type:Array})],_.prototype,"items",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],_.prototype,"narrow",void 0),_=(0,a.Cg)([(0,r.EM)("ha-icon-overflow-menu")],_),s()}catch(t){s(t)}})},98677(t,e,i){i.a(t,async function(t,e){try{var s=i(62826),a=i(5124),o=i(22441),r=i(1087),l=i(18350),n=(i(3587),i(35891)),h=i(57116),c=i(38119),d=t([l,c]);[l,c]=d.then?(await d)():d;const p="M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z";class u extends c.D{get _config(){return this.config}render(){return a.qy` ${this.config.description?a.qy`<ha-markdown class="description" breaks .content="${this.config.description}"></ha-markdown>`:a.s6} ${this.renderCard()} <ha-button slot="fab" size="large" class="${this.dirty?"dirty":""}" .disabled="${this.saving}" @click="${this._saveScript}"> <ha-svg-icon slot="start" .path="${p}"></ha-svg-icon> ${this.hass.localize("ui.common.save")} </ha-button> `}_saveScript(){(0,r.r)(this,"save-script")}async _getBlueprints(){this._blueprints=await(0,n.Xg)(this.hass,"script")}static get styles(){return[c.D.styles,h.T_,a.AH`:host{position:relative;height:100%;min-height:calc(100vh - 85px);min-height:calc(100dvh - 85px)}ha-button[slot=fab]{position:fixed;--ha-button-box-shadow:var(--ha-box-shadow-l)}`]}constructor(...t){super(...t),this.saving=!1,this.dirty=!1}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],u.prototype,"config",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],u.prototype,"saving",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],u.prototype,"dirty",void 0),u=(0,s.Cg)([(0,o.EM)("blueprint-script-editor")],u),e()}catch(t){e(t)}})},90370(t,e,i){i.a(t,async function(t,s){try{i.r(e);i(18111),i(81148),i(22489);var a=i(62826),o=i(22441),r=i(22786),l=i(69093),n=i(9899),h=i(324),c=i(21475),d=i(42180),p=t([c,d]);[c,d]=p.then?(await p)():p;const u=(t,e)=>t.length===e.length&&t.every((t,i)=>t===e[i]);class g extends h.a{firstUpdated(t){super.firstUpdated(t),this.hass.loadBackendTranslation("device_automation")}updatePageEl(t,e){if(t.hass=this.hass,t.narrow=this.narrow,t.isWide=this.isWide,t.route=this.routeTail,t.cloudStatus=this.cloudStatus,this.hass&&(t.scripts&&e?e.has("hass")&&this._debouncedUpdateScripts(t):t.scripts=this._getScripts(this.hass.states)),(!e||e.has("route"))&&"show"===this._currentPage){t.creatingNew=void 0;const e=this.routeTail.path.slice(1);return void(t.entityId="new"===e?null:e)}if((!e||e.has("route"))&&"dashboard"!==this._currentPage){t.creatingNew=void 0;const e=this.routeTail.path.slice(1);t.scriptId="new"===e?null:e}}constructor(...t){super(...t),this.narrow=!1,this.isWide=!1,this.scripts=[],this.routerOptions={defaultPage:"dashboard",routes:{dashboard:{tag:"ha-script-picker",cache:!0},edit:{tag:"ha-script-editor"},show:{tag:"ha-script-editor"},trace:{tag:"ha-script-trace",load:()=>Promise.all([i.e(66432),i.e(87857),i.e(82333),i.e(775),i.e(52422)]).then(i.bind(i,74706))}}},this._debouncedUpdateScripts=(0,n.s)(t=>{const e=this._getScripts(this.hass.states);u(e,t.scripts)||(t.scripts=e)},10),this._getScripts=(0,r.A)(t=>Object.values(t).filter(t=>"script"===(0,l.t)(t)&&!t.attributes.restored))}}(0,a.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"hass",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean})],g.prototype,"narrow",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"is-wide",type:Boolean})],g.prototype,"isWide",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"cloudStatus",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"scripts",void 0),g=(0,a.Cg)([(0,o.EM)("ha-config-script")],g),s()}catch(t){s(t)}})},21475(t,e,i){i.a(t,async function(t,e){try{i(18111),i(20116),i(61701),i(13579);var s=i(62826),a=(i(68825),i(5124)),o=i(22441),r=i(6412),l=i(17079),n=i(1087),h=i(91926),c=i(80880),d=i(7553),p=i(18350),u=i(29823),g=(i(70947),i(26300)),_=(i(67094),i(10763)),f=i(35891),y=i(12596),m=i(22675),b=i(59241),v=i(84025),$=i(65063),w=i(42269),C=i(81310),A=i(79172),H=i(39359),k=i(54706),V=i(14503),M=i(41570),x=i(49053),z=i(37325),L=i(64265),q=i(60109),S=i(55270),R=i(98677),I=i(70043),E=i(84042),Z=t([p,u,g,_,C,R,E,I]);[p,u,g,_,C,R,E,I]=Z.then?(await Z)():Z;const F="M6,2A4,4 0 0,1 10,6V8H14V6A4,4 0 0,1 18,2A4,4 0 0,1 22,6A4,4 0 0,1 18,10H16V14H18A4,4 0 0,1 22,18A4,4 0 0,1 18,22A4,4 0 0,1 14,18V16H10V18A4,4 0 0,1 6,22A4,4 0 0,1 2,18A4,4 0 0,1 6,14H8V10H6A4,4 0 0,1 2,6A4,4 0 0,1 6,2M16,18A2,2 0 0,0 18,20A2,2 0 0,0 20,18A2,2 0 0,0 18,16H16V18M14,10H10V14H14V10M6,16A2,2 0 0,0 4,18A2,2 0 0,0 6,20A2,2 0 0,0 8,18V16H6M8,6A2,2 0 0,0 6,4A2,2 0 0,0 4,6A2,2 0 0,0 6,8H8V6M18,8A2,2 0 0,0 20,6A2,2 0 0,0 18,4A2,2 0 0,0 16,6V8H18Z",P="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z",O="M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z",U="M12,14A2,2 0 0,1 14,16A2,2 0 0,1 12,18A2,2 0 0,1 10,16A2,2 0 0,1 12,14M23.46,8.86L21.87,15.75L15,14.16L18.8,11.78C17.39,9.5 14.87,8 12,8C8.05,8 4.77,10.86 4.12,14.63L2.15,14.28C2.96,9.58 7.06,6 12,6C15.58,6 18.73,7.89 20.5,10.72L23.46,8.86Z",B="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",D="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",T="M6 2C4.9 2 4 2.9 4 4V20C4 21.1 4.9 22 6 22H10V20.1L20 10.1V8L14 2H6M13 3.5L18.5 9H13V3.5M20.1 13C20 13 19.8 13.1 19.7 13.2L18.7 14.2L20.8 16.3L21.8 15.3C22 15.1 22 14.7 21.8 14.5L20.5 13.2C20.4 13.1 20.3 13 20.1 13M18.1 14.8L12 20.9V23H14.1L20.2 16.9L18.1 14.8Z",j="M17,7H22V17H17V19A1,1 0 0,0 18,20H20V22H17.5C16.95,22 16,21.55 16,21C16,21.55 15.05,22 14.5,22H12V20H14A1,1 0 0,0 15,19V5A1,1 0 0,0 14,4H12V2H14.5C15.05,2 16,2.45 16,3C16,2.45 16.95,2 17.5,2H20V4H18A1,1 0 0,0 17,5V7M2,7H13V9H4V15H13V17H2V7M20,15V9H17V15H20Z",W="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z",N="M8,5.14V19.14L19,12.14L8,5.14Z",Y="M3 6V8H14V6H3M3 10V12H14V10H3M20 10.1C19.9 10.1 19.7 10.2 19.6 10.3L18.6 11.3L20.7 13.4L21.7 12.4C21.9 12.2 21.9 11.8 21.7 11.6L20.4 10.3C20.3 10.2 20.2 10.1 20 10.1M18.1 11.9L12 17.9V20H14.1L20.2 13.9L18.1 11.9M3 14V16H10V14H3Z",G="M16,8H14V11H11V13H14V16H16V13H19V11H16M2,12C2,9.21 3.64,6.8 6,5.68V3.5C2.5,4.76 0,8.09 0,12C0,15.91 2.5,19.24 6,20.5V18.32C3.64,17.2 2,14.79 2,12M15,3C10.04,3 6,7.04 6,12C6,16.96 10.04,21 15,21C19.96,21 24,16.96 24,12C24,7.04 19.96,3 15,3M15,19C11.14,19 8,15.86 8,12C8,8.14 11.14,5 15,5C18.86,5 22,8.14 22,12C22,15.86 18.86,19 15,19Z",K="M18.4,10.6C16.55,9 14.15,8 11.5,8C6.85,8 2.92,11.03 1.54,15.22L3.9,16C4.95,12.81 7.95,10.5 11.5,10.5C13.45,10.5 15.23,11.22 16.62,12.38L13,16H22V7L18.4,10.6Z",X="M18,17H10.5L12.5,15H18M6,17V14.5L13.88,6.65C14.07,6.45 14.39,6.45 14.59,6.65L16.35,8.41C16.55,8.61 16.55,8.92 16.35,9.12L8.47,17M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z",J="M20 4H18V3H20.5C20.78 3 21 3.22 21 3.5V5.5C21 5.78 20.78 6 20.5 6H20V7H19V5H20V4M19 9H20V8H19V9M17 3H16V7H17V3M23 15V18C23 18.55 22.55 19 22 19H21V20C21 21.11 20.11 22 19 22H5C3.9 22 3 21.11 3 20V19H2C1.45 19 1 18.55 1 18V15C1 14.45 1.45 14 2 14H3C3 10.13 6.13 7 10 7H11V5.73C10.4 5.39 10 4.74 10 4C10 2.9 10.9 2 12 2S14 2.9 14 4C14 4.74 13.6 5.39 13 5.73V7H14C14.34 7 14.67 7.03 15 7.08V10H19.74C20.53 11.13 21 12.5 21 14H22C22.55 14 23 14.45 23 15M10 15.5C10 14.12 8.88 13 7.5 13S5 14.12 5 15.5 6.12 18 7.5 18 10 16.88 10 15.5M19 15.5C19 14.12 17.88 13 16.5 13S14 14.12 14 15.5 15.12 18 16.5 18 19 16.88 19 15.5M17 8H16V9H17V8Z",Q="M5.5,7A1.5,1.5 0 0,1 4,5.5A1.5,1.5 0 0,1 5.5,4A1.5,1.5 0 0,1 7,5.5A1.5,1.5 0 0,1 5.5,7M21.41,11.58L12.41,2.58C12.05,2.22 11.55,2 11,2H4C2.89,2 2,2.89 2,4V11C2,11.55 2.22,12.05 2.59,12.41L11.58,21.41C11.95,21.77 12.45,22 13,22C13.55,22 14.05,21.77 14.41,21.41L21.41,14.41C21.78,14.05 22,13.55 22,13C22,12.44 21.77,11.94 21.41,11.58Z",tt="M15,12C15,10.7 14.16,9.6 13,9.18V6.82C14.16,6.4 15,5.3 15,4A3,3 0 0,0 12,1A3,3 0 0,0 9,4C9,5.3 9.84,6.4 11,6.82V9.19C9.84,9.6 9,10.7 9,12C9,13.3 9.84,14.4 11,14.82V17.18C9.84,17.6 9,18.7 9,20A3,3 0 0,0 12,23A3,3 0 0,0 15,20C15,18.7 14.16,17.6 13,17.18V14.82C14.16,14.4 15,13.3 15,12M12,3A1,1 0 0,1 13,4A1,1 0 0,1 12,5A1,1 0 0,1 11,4A1,1 0 0,1 12,3M12,21A1,1 0 0,1 11,20A1,1 0 0,1 12,19A1,1 0 0,1 13,20A1,1 0 0,1 12,21Z",et="M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z";class it extends((0,k.E)((0,I.j)((0,H._)((0,A.b)(a.WF))))){willUpdate(t){if(super.willUpdate(t),this.entityRegCreated&&this._newScriptId&&t.has("entityRegistry")){const t=this.entityRegistry?.find(t=>"script"===t.platform&&t.unique_id===this._newScriptId);t&&(this.entityRegCreated(t),this.entityRegCreated=void 0)}}render(){if(!this.config)return this.renderLoading();const t=this.currentEntityId?this.hass.states[this.currentEntityId]:void 0,e="use_blueprint"in this.config,i=M.c?a.qy`<ha-svg-icon .path="${F}"></ha-svg-icon>`:this.hass.localize("ui.panel.config.automation.editor.ctrl");return a.qy` <hass-subpage .hass="${this.hass}" .narrow="${this.narrow}" .route="${this.route}" .backCallback="${this.backTapped}" .header="${this.config.alias||this.hass.localize("ui.panel.config.script.editor.default_name")}"> ${"gui"!==this.mode||this.narrow?a.s6:a.qy`<ha-icon-button slot="toolbar-icon" .label="${this.hass.localize("ui.common.undo")}" .path="${et}" @click="${this._undo}" .disabled="${!this._undoRedoController.canUndo}" id="button-undo"> </ha-icon-button> <ha-tooltip placement="bottom" for="button-undo"> ${this.hass.localize("ui.common.undo")} <span class="shortcut"> (<span>${i}</span> <span>+</span> <span>Z</span>) </span> </ha-tooltip> <ha-icon-button slot="toolbar-icon" .label="${this.hass.localize("ui.common.redo")}" .path="${K}" @click="${this._redo}" .disabled="${!this._undoRedoController.canRedo}" id="button-redo"> </ha-icon-button> <ha-tooltip placement="bottom" for="button-redo"> ${this.hass.localize("ui.common.redo")} <span class="shortcut">( ${M.c?a.qy`<span>${i}</span> <span>+</span> <span>Shift</span> <span>+</span> <span>Z</span>`:a.qy`<span>${i}</span> <span>+</span> <span>Y</span>`}) </span> </ha-tooltip>`} ${this.scriptId&&!this.narrow?a.qy` <ha-button appearance="plain" @click="${this._showTrace}" slot="toolbar-icon"> ${this.hass.localize("ui.panel.config.script.editor.show_trace")} </ha-button> `:""} <ha-dropdown slot="toolbar-icon" @wa-select="${this._handleDropdownSelect}"> <ha-icon-button slot="trigger" .label="${this.hass.localize("ui.common.menu")}" .path="${D}"></ha-icon-button> ${"gui"===this.mode&&this.narrow?a.qy`<ha-dropdown-item value="undo" .disabled="${!this._undoRedoController.canUndo}"> ${this.hass.localize("ui.common.undo")} <ha-svg-icon slot="icon" .path="${et}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item value="redo" .disabled="${!this._undoRedoController.canRedo}"> ${this.hass.localize("ui.common.redo")} <ha-svg-icon slot="icon" .path="${K}"></ha-svg-icon> </ha-dropdown-item>`:a.s6} <ha-dropdown-item .disabled="${!this.scriptId}" value="info"> ${this.hass.localize("ui.panel.config.script.editor.show_info")} <ha-svg-icon slot="icon" .path="${W}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${!t}" value="settings"> ${this.hass.localize("ui.panel.config.automation.picker.show_settings")} <ha-svg-icon slot="icon" .path="${P}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${!t}" value="category"> ${this.hass.localize("ui.panel.config.scene.picker."+(this.registryEntry?.categories?.script?"edit_category":"assign_category"))} <ha-svg-icon slot="icon" .path="${Q}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${!this.scriptId}" value="run"> ${this.hass.localize("ui.panel.config.script.picker.run_script")} <ha-svg-icon slot="icon" .path="${N}"></ha-svg-icon> </ha-dropdown-item> ${this.scriptId&&this.narrow?a.qy`<ha-dropdown-item value="trace"> ${this.hass.localize("ui.panel.config.automation.editor.show_trace")} <ha-svg-icon slot="icon" .path="${tt}"></ha-svg-icon> </ha-dropdown-item>`:a.s6} ${e||"fields"in this.config?a.s6:a.qy` <ha-dropdown-item .disabled="${this.readOnly||"yaml"===this.mode}" value="add_fields"> ${this.hass.localize("ui.panel.config.script.editor.field.add_fields")} <ha-svg-icon slot="icon" .path="${j}"></ha-svg-icon> </ha-dropdown-item> `} <ha-dropdown-item value="rename" .disabled="${!this.scriptId||this.readOnly||"yaml"===this.mode}"> ${this.hass.localize("ui.panel.config.script.editor.rename")} <ha-svg-icon slot="icon" .path="${X}"></ha-svg-icon> </ha-dropdown-item> ${e?a.s6:a.qy` <ha-dropdown-item value="change_mode" .disabled="${this.readOnly||"yaml"===this.mode}"> ${this.hass.localize("ui.panel.config.script.editor.change_mode")} <ha-svg-icon slot="icon" .path="${U}"></ha-svg-icon> </ha-dropdown-item> `} <ha-dropdown-item .disabled="${!!this.blueprintConfig||!this.readOnly&&!this.scriptId}" value="duplicate"> ${this.hass.localize(this.readOnly?"ui.panel.config.script.editor.migrate":"ui.panel.config.script.editor.duplicate")} <ha-svg-icon slot="icon" .path="${G}"></ha-svg-icon> </ha-dropdown-item> ${e?a.qy` <ha-dropdown-item value="take_control" .disabled="${this.readOnly}"> ${this.hass.localize("ui.panel.config.script.editor.take_control")} <ha-svg-icon slot="icon" .path="${T}"></ha-svg-icon> </ha-dropdown-item> `:a.s6} <ha-dropdown-item value="toggle_yaml_mode"> ${this.hass.localize("ui.panel.config.automation.editor.edit_"+("gui"===this.mode?"yaml":"ui"))} <ha-svg-icon slot="icon" .path="${Y}"></ha-svg-icon> </ha-dropdown-item> <wa-divider></wa-divider> <ha-dropdown-item .disabled="${this.readOnly||!this.scriptId}" value="delete" .variant="${this.scriptId?"danger":"default"}"> ${this.hass.localize("ui.panel.config.script.picker.delete")} <ha-svg-icon class="${(0,r.H)({warning:Boolean(this.scriptId)})}" slot="icon" .path="${B}"> </ha-svg-icon> </ha-dropdown-item> </ha-dropdown> <div class="${"yaml"===this.mode?"yaml-mode":""}"> ${"gui"===this.mode?a.qy` <div> ${e?a.qy` <blueprint-script-editor .hass="${this.hass}" .narrow="${this.narrow}" .isWide="${this.isWide}" .config="${this.config}" .disabled="${this.readOnly}" .saving="${this.saving}" .dirty="${this.dirty}" @value-changed="${this._valueChanged}" @save-script="${this._handleSaveScript}"></blueprint-script-editor> `:a.qy` <manual-script-editor .hass="${this.hass}" .narrow="${this.narrow}" .isWide="${this.isWide}" .config="${this.config}" .disabled="${this.readOnly}" .dirty="${this.dirty}" .saving="${this.saving}" @value-changed="${this._valueChanged}" @editor-save="${this._handleSaveScript}" @save-script="${this._handleSaveScript}"> <div class="alert-wrapper" slot="alerts"> ${this.errors||t?.state===m.Hh?a.qy`<ha-alert alert-type="error" .title="${t?.state===m.Hh?this.hass.localize("ui.panel.config.script.editor.unavailable"):void 0}"> ${this.errors||this.validationErrors} ${t?.state===m.Hh?a.qy`<ha-svg-icon slot="icon" .path="${J}"></ha-svg-icon>`:a.s6} </ha-alert>`:a.s6} ${this.blueprintConfig?a.qy`<ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.script.editor.confirm_take_control")} <div slot="action" style="display:flex"> <ha-button appearance="plain" @click="${this.takeControlSave}">${this.hass.localize("ui.common.yes")}</ha-button> <ha-button appearance="plain" @click="${this.revertBlueprint}">${this.hass.localize("ui.common.no")}</ha-button> </div> </ha-alert>`:this.readOnly?a.qy`<ha-alert alert-type="warning" dismissable>${this.hass.localize("ui.panel.config.script.editor.read_only")} <ha-button appearance="plain" slot="action" @click="${this._duplicate}"> ${this.hass.localize("ui.panel.config.script.editor.migrate")} </ha-button> </ha-alert>`:a.s6} </div> </manual-script-editor> `} </div> `:"yaml"===this.mode?a.qy`<ha-yaml-editor .defaultValue="${this._preprocessYaml()}" .readOnly="${this.readOnly}" disable-fullscreen @value-changed="${this._yamlChanged}" @editor-save="${this._handleSaveScript}"></ha-yaml-editor> <ha-button slot="fab" size="large" class="${!this.readOnly&&this.dirty?"dirty":""}" .disabled="${this.saving}" @click="${this._handleSaveScript}"> <ha-svg-icon slot="start" .path="${O}"></ha-svg-icon> ${this.hass.localize("ui.common.save")} </ha-button>`:a.s6} </div> </hass-subpage> `}_setEntityId(){if(!this.entityRegistry)return;const t=this.entityRegistry.find(t=>"script"===t.platform&&t.unique_id===this.scriptId);this.currentEntityId=t?.entity_id}updated(t){super.updated(t);const e=t.get("scriptId");if(!t.has("scriptId")||!this.scriptId||this.entityId||!this.hass||e&&e===this.scriptId||(this._setEntityId(),this.loadConfig(this.scriptId)),(t.has("scriptId")||t.has("entityRegistry"))&&this.scriptId&&this.entityRegistry&&this._setEntityId(),t.has("scriptId")&&!this.scriptId&&this.hass){const t=(0,v.NX)();this.dirty=!!t;const e={};t&&"use_blueprint"in t||(e.sequence=[]),this.config={...e,...t},this.readOnly=!1}if(t.has("entityId")&&this.entityId){(0,v.R$)(this.hass,this.entityId).then(t=>{this.config=(0,v.nB)(t.config),this._checkValidation()});const t=this.entityRegistry?.find(t=>t.entity_id===this.entityId);t?.unique_id&&(this.scriptId=t.unique_id),this.currentEntityId=this.entityId,this.dirty=!1,this.readOnly=!0}}async _checkValidation(){if(this.validationErrors=void 0,!this.currentEntityId||!this.config)return;const t=this.hass.states[this.currentEntityId];if(t?.state!==m.Hh)return;const e=await(0,y.$)(this.hass,{actions:this.config.sequence});this.validationErrors=Object.entries(e).map(([t,e])=>e.valid?"":a.qy`${this.hass.localize(`ui.panel.config.automation.editor.${t}.name`)}: ${e.error}<br>`)}_valueChanged(t){this.config&&this._undoRedoController.commit(this.config),this.config=t.detail.value,this.errors=void 0,this.dirty=!0}async _runScript(){(0,v.TP)(this.hass,this.currentEntityId)?(0,w.p)(this,{entityId:this.currentEntityId}):(await(0,v.kR)(this.hass,this.scriptId),(0,x.c)(this,{message:this.hass.localize("ui.notification_toast.triggered",{name:this.config.alias})}))}_editCategory(){this.registryEntry?(0,S.j)(this,{scope:"script",entityReg:this.registryEntry}):(0,$.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.scene.picker.no_category_support"),text:this.hass.localize("ui.panel.config.scene.picker.no_category_entity_reg")})}_computeEntityIdFromAlias(t){const e=(0,c.Y)(t);let i=e,s=2;for(;this._idIsUsed(i);)i=`${e}_${s}`,s++;return i}_idIsUsed(t){return`script.${t}`in this.hass.states||(this.entityRegistry?.some(e=>e.unique_id===t)??!1)}async _showInfo(){if(!this.scriptId)return;const t=this.entityRegistry?.find(t=>t.unique_id===this.scriptId);t&&(0,n.r)(this,"hass-more-info",{entityId:t.entity_id})}async _showTrace(){if(this.scriptId){await this.confirmUnsavedChanged()&&(0,h.oo)(`/config/script/trace/${this.scriptId}`)}}_addFields(){"fields"in this.config||(this.config&&this._undoRedoController.commit(this.config),this._manualEditor?.addFields(),this.dirty=!0)}_preprocessYaml(){return this.config}_yamlChanged(t){t.stopPropagation(),this.dirty=!0,t.detail.isValid?(this.yamlErrors=void 0,this.config=t.detail.value,this.errors=void 0):this.yamlErrors=t.detail.errorMsg}async confirmUnsavedChanged(){return!this.dirty||new Promise(t=>{(0,L._)(this,{config:this.config,domain:"script",updateConfig:async(e,i)=>{this.config=e,this.entityRegistryUpdate=i,this.dirty=!0,this.requestUpdate();const s=this.scriptId||String(Date.now());try{await this._saveScript(s)}catch(e){return this.requestUpdate(),void t(!1)}t(!0)},onClose:()=>t(!1),onDiscard:()=>t(!0),entityRegistryUpdate:this.entityRegistryUpdate,entityRegistryEntry:this.registryEntry,title:this.hass.localize(this.scriptId?"ui.panel.config.script.editor.leave.unsaved_confirm_title":"ui.panel.config.script.editor.leave.unsaved_new_title"),description:this.hass.localize(this.scriptId?"ui.panel.config.script.editor.leave.unsaved_confirm_text":"ui.panel.config.script.editor.leave.unsaved_new_text"),hideInputs:null!==this.scriptId})})}async _takeControl(){const t=this.config;try{const e=await(0,f.oz)(this.hass,"script",t.use_blueprint.path,t.use_blueprint.input||{}),i={...(0,v.nB)(e.substituted_config),alias:t.alias,description:t.description};this.blueprintConfig=t,this.config=i,"yaml"===this.mode&&this._yamlEditor?.setValue(this.config),this.readOnly=!0,this.errors=void 0}catch(t){this.errors=t.message}}async _duplicate(){(this.readOnly?await(0,$.dk)(this,{title:this.hass.localize("ui.panel.config.script.picker.migrate_script"),text:this.hass.localize("ui.panel.config.script.picker.migrate_script_description")}):await this.confirmUnsavedChanged())&&(this.currentEntityId=void 0,(0,v.AM)({...this.config,alias:this.readOnly?this.config?.alias:`${this.config?.alias} (${this.hass.localize("ui.panel.config.script.picker.duplicate")})`}))}async _deleteConfirm(){(0,$.dk)(this,{title:this.hass.localize("ui.panel.config.script.editor.delete_confirm_title"),text:this.hass.localize("ui.panel.config.script.editor.delete_confirm_text",{name:this.config?.alias}),confirmText:this.hass.localize("ui.common.delete"),destructive:!0,dismissText:this.hass.localize("ui.common.cancel"),confirm:()=>this._delete()})}async _delete(){await(0,v.Ht)(this.hass,this.scriptId),(0,h.OE)("/config")}async _promptScriptAlias(){return new Promise(t=>{(0,L._)(this,{config:this.config,domain:"script",updateConfig:async(e,i)=>{this.config=e,this.entityRegistryUpdate=i,this.dirty=!0,this.requestUpdate(),t(!0)},onClose:()=>t(!1),entityRegistryUpdate:this.entityRegistryUpdate,entityRegistryEntry:this.entityRegistry?.find(t=>t.unique_id===this.scriptId)})})}async _promptScriptMode(){return new Promise(t=>{(0,z.e)(this,{config:this.config,updateConfig:e=>{this.config=e,this.dirty=!0,this.requestUpdate(),t()},onClose:()=>t()})})}async _handleSaveScript(){if(this.yamlErrors)return void(0,x.c)(this,{message:this.yamlErrors});if(this._manualEditor?.resetPastedConfig(),!this.scriptId){if(!await this._promptScriptAlias())return;this.currentEntityId=this._computeEntityIdFromAlias(this.config.alias)}const t=this.scriptId||this.currentEntityId||Date.now();await this._saveScript(t),this.scriptId||(0,h.oo)(`/config/script/edit/${t}`,{replace:!0})}async _saveScript(t){let e;this.saving=!0,void 0===this.entityRegistryUpdate||this.scriptId||(this._newScriptId=t.toString(),e=new Promise(t=>{this.entityRegCreated=t}));try{if(await this.hass.callApi("POST","config/script/config/"+t,this.config),void 0!==this.entityRegistryUpdate){let t=this.currentEntityId;if(e)try{t=(await(0,d.h)(5e3,e)).entity_id}catch(i){if(t=void 0,!(i instanceof Error&&"TimeoutError"===i.name))throw i;await(0,q.j)(this,{savedPromise:e,type:"script"});try{t=(await(0,d.h)(0,e)).entity_id}catch(t){if(!(t instanceof Error&&"TimeoutError"===t.name))throw t}}t&&await(0,b.G_)(this.hass,t,{categories:{script:this.entityRegistryUpdate.category||null},labels:this.entityRegistryUpdate.labels||[],area_id:this.entityRegistryUpdate.area||null})}this.dirty=!1}catch(t){throw this.errors=t.body?.message||t.error||t.body,(0,x.c)(this,{message:t.body?.message||t.error||t.body}),t}finally{this.saving=!1}}supportedShortcuts(){return{s:()=>this._handleSaveScript(),c:()=>this._copySelectedRow(),x:()=>this._cutSelectedRow(),Delete:()=>this._deleteSelectedRow(),Backspace:()=>this._deleteSelectedRow(),z:()=>this._undo(),Z:()=>this._redo(),y:()=>this._redo()}}_collapseAll(){this._manualEditor?.collapseAll()}_expandAll(){this._manualEditor?.expandAll()}_copySelectedRow(){this._manualEditor?.copySelectedRow()}_cutSelectedRow(){this._manualEditor?.cutSelectedRow()}_deleteSelectedRow(){this._manualEditor?.deleteSelectedRow()}_applyUndoRedo(t){this._manualEditor?.triggerCloseSidebar(),this.config=t,this.dirty=!0}_undo(){this._undoRedoController.undo()}_redo(){this._undoRedoController.redo()}_handleDropdownSelect(t){const e=t.detail?.item?.value;if(e)switch(e){case"undo":this._undo();break;case"redo":this._redo();break;case"info":this._showInfo();break;case"settings":this.showSettings();break;case"category":this._editCategory();break;case"run":this._runScript();break;case"add_fields":this._addFields();break;case"rename":this._promptScriptAlias();break;case"change_mode":this._promptScriptMode();break;case"duplicate":this._duplicate();break;case"take_control":this._takeControl();break;case"toggle_yaml_mode":if("gui"===this.mode){this.switchYamlMode();break}this.switchUiMode();break;case"delete":this._deleteConfirm();break;case"trace":this._showTrace()}}static get styles(){return[V.RF,I.m,a.AH`blueprint-script-editor,manual-script-editor{margin:0 auto;max-width:1040px;padding:28px 20px 0;display:block}:not(.yaml-mode)>.error-wrapper{position:absolute;top:4px;z-index:3;width:100%;display:flex;flex-direction:column;align-items:center}:not(.yaml-mode)>.error-wrapper ha-alert{background-color:var(--card-background-color);box-shadow:0 2px 4px rgba(0,0,0,.2);border-radius:var(--ha-border-radius-sm)}.alert-wrapper{position:sticky;top:0;margin-top:0;margin-bottom:8px;z-index:1;width:100%;display:flex;flex-direction:column;align-items:center;gap:var(--ha-space-2);pointer-events:none}.alert-wrapper ha-alert{background-color:var(--card-background-color);box-shadow:0 2px 4px rgba(0,0,0,.2);border-radius:var(--ha-border-radius-sm);margin-bottom:0;pointer-events:auto}manual-script-editor{max-width:var(--ha-automation-editor-max-width);padding:0 12px}span[slot=introduction] a{color:var(--primary-color)}.header{display:flex;margin:16px 0;align-items:center}.header .name{font-size:var(--ha-font-size-xl);font-weight:var(--ha-font-weight-normal);flex:1}.header a{color:var(--secondary-text-color)}`]}constructor(...t){super(...t),this.scriptId=null,this.domainHooks={domain:"script",fetchFileConfig:v.Kq,normalizeConfig:v.nB,checkValidation:()=>this._checkValidation()},this._undoRedoController=new l.X(this,{apply:t=>this._applyUndoRedo(t),currentConfig:()=>this.config})}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],it.prototype,"scriptId",void 0),(0,s.Cg)([(0,o.P)("manual-script-editor")],it.prototype,"_manualEditor",void 0),(0,s.Cg)([(0,o.P)("ha-yaml-editor")],it.prototype,"_yamlEditor",void 0),it=(0,s.Cg)([(0,o.EM)("ha-script-editor")],it),e()}catch(t){e(t)}})},17625(t,e,i){i.a(t,async function(t,e){try{i(74423);var s=i(62826),a=i(5124),o=i(22441),r=i(6412),l=i(1087),n=i(99124),h=i(57237),c=i(53516),d=i(56214),p=(i(76776),i(29823)),u=(i(70947),i(84383)),g=i(65063),_=i(41570),f=i(49053),y=i(57116),m=i(50940),b=t([d,p,m]);[d,p,m]=b.then?(await b)():b;const v="M6,2A4,4 0 0,1 10,6V8H14V6A4,4 0 0,1 18,2A4,4 0 0,1 22,6A4,4 0 0,1 18,10H16V14H18A4,4 0 0,1 22,18A4,4 0 0,1 18,22A4,4 0 0,1 14,18V16H10V18A4,4 0 0,1 6,22A4,4 0 0,1 2,18A4,4 0 0,1 6,14H8V10H6A4,4 0 0,1 2,6A4,4 0 0,1 6,2M16,18A2,2 0 0,0 18,20A2,2 0 0,0 20,18A2,2 0 0,0 18,16H16V18M14,10H10V14H14V10M6,16A2,2 0 0,0 4,18A2,2 0 0,0 6,20A2,2 0 0,0 8,18V16H6M8,6A2,2 0 0,0 6,4A2,2 0 0,0 4,6A2,2 0 0,0 6,8H8V6M18,8A2,2 0 0,0 20,6A2,2 0 0,0 18,4A2,2 0 0,0 16,6V8H18Z",$="M9 22C8.45 22 8 21.55 8 21V18H4C2.9 18 2 17.11 2 16V4C2 2.89 2.9 2 4 2H20C21.11 2 22 2.9 22 4V16C22 17.11 21.11 18 20 18H13.9L10.2 21.71C10 21.9 9.75 22 9.5 22H9M10 16V19.08L13.08 16H20V4H4V16H10M15.84 8.2L14.83 9.21L12.76 7.18L13.77 6.16C13.97 5.95 14.31 5.94 14.55 6.16L15.84 7.41C16.05 7.62 16.06 7.96 15.84 8.2M8 11.91L12.17 7.72L14.24 9.8L10.08 14H8V11.91Z",w="M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9M10,16V19.08L13.08,16H20V4H4V16H10M6,7H18V9H6V7M6,11H15V13H6V11Z",C="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",A="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",H="M3 6V8H14V6H3M3 10V12H14V10H3M20 10.1C19.9 10.1 19.7 10.2 19.6 10.3L18.6 11.3L20.7 13.4L21.7 12.4C21.9 12.2 21.9 11.8 21.7 11.6L20.4 10.3C20.3 10.2 20.2 10.1 20 10.1M18.1 11.9L12 17.9V20H14.1L20.2 13.9L18.1 11.9M3 14V16H10V14H3Z";class k extends a.WF{render(){const t=this.field.selector&&"object"==typeof this.field.selector,e=(0,c.C)(this.field.description?.trim()||"",250);return a.qy` <ha-card outlined> <ha-automation-row .disabled="${this.disabled}" @click="${this._toggleSidebar}" .selected="${this._selected}" .leftChevron="${t}" @toggle-collapsed="${this._toggleCollapse}" .collapsed="${this._collapsed}" .highlight="${this.highlight}" @delete-row="${this._onDelete}"> <ha-dropdown slot="icons" @click="${n.C}" @keydown="${h.d}" @wa-select="${this._handleDropdownSelect}" placement="bottom-end"> <ha-icon-button slot="trigger" .label="${this.hass.localize("ui.common.menu")}" .path="${A}"></ha-icon-button> <ha-dropdown-item value="edit_note"> <ha-svg-icon slot="icon" .path="${$}"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.editor.note."+(this.field.description?"edit":"add"))} </ha-dropdown-item> <ha-dropdown-item value="toggle_yaml_mode"> <ha-svg-icon slot="icon" .path="${H}"></ha-svg-icon> <div class="overflow-label"> ${this.hass.localize("ui.panel.config.automation.editor.edit_"+(this._yamlMode?"ui":"yaml"))} <span class="shortcut-placeholder ${_.c?"mac":""}"></span> </div> </ha-dropdown-item> <ha-dropdown-item value="delete" .disabled="${this.disabled}" variant="danger"> <ha-svg-icon slot="icon" .path="${C}"></ha-svg-icon> <div class="overflow-label"> ${this.hass.localize("ui.panel.config.automation.editor.actions.delete")} ${this.narrow?a.s6:a.qy`<span class="shortcut"> <span>${_.c?a.qy`<ha-svg-icon .path="${v}"></ha-svg-icon>`:this.hass.localize("ui.panel.config.automation.editor.ctrl")}</span> <span>+</span> <span>${this.hass.localize("ui.panel.config.automation.editor.del")}</span> </span>`} </div> </ha-dropdown-item> </ha-dropdown> <h3 slot="header"> ${this.field.name??this.key} ${this.field.description?.trim()?a.qy` <ha-svg-icon id="note-icon" tabindex="0" .path="${w}" .label="${this.hass.localize("ui.panel.config.automation.editor.note.label")}" class="note-indicator"></ha-svg-icon> <ha-tooltip for="note-icon"><p>${e}</p></ha-tooltip> `:a.s6} </h3> <slot name="icons" slot="icons"></slot> </ha-automation-row> </ha-card> ${t?a.qy` <div class="${(0,r.H)({"selector-row":!0,"parent-selected":this._selected,hidden:this._collapsed})}"> <ha-card> <ha-automation-row .selected="${this._selectorRowSelected}" @click="${this._toggleSelectorSidebar}" .collapsed="${this._selectorRowCollapsed}" @toggle-collapsed="${this._toggleSelectorRowCollapse}" .leftChevron="${u.W.includes(Object.keys(this.field.selector)[0])}" .highlight="${this.highlight}"> <h3 slot="header"> ${this.hass.localize(`ui.components.selectors.selector.types.${Object.keys(this.field.selector)[0]}`)} ${this.hass.localize("ui.panel.config.script.editor.field.selector")} </h3> <ha-dropdown slot="icons" @click="${n.C}" @keydown="${h.d}" @wa-select="${this._handleDropdownSelect}" placement="bottom-end"> <ha-icon-button slot="trigger" .label="${this.hass.localize("ui.common.menu")}" .path="${A}"></ha-icon-button> <ha-dropdown-item value="toggle_yaml_mode" selector-row> <ha-svg-icon slot="icon" .path="${H}"></ha-svg-icon> <div class="overflow-label"> ${this.hass.localize("ui.panel.config.automation.editor.edit_"+(this._yamlMode?"ui":"yaml"))} <span class="shortcut-placeholder ${_.c?"mac":""}"></span> </div> </ha-dropdown-item> <ha-dropdown-item value="delete" .disabled="${this.disabled}" variant="danger"> <ha-svg-icon slot="icon" .path="${C}"></ha-svg-icon> <div class="overflow-label"> ${this.hass.localize("ui.panel.config.automation.editor.actions.delete")} ${this.narrow?a.s6:a.qy`<span class="shortcut"> <span>${_.c?a.qy`<ha-svg-icon .path="${v}"></ha-svg-icon>`:this.hass.localize("ui.panel.config.automation.editor.ctrl")}</span> <span>+</span> <span>${this.hass.localize("ui.panel.config.automation.editor.del")}</span> </span>`} </div> </ha-dropdown-item> </ha-dropdown> </ha-automation-row> </ha-card> ${"object"==typeof this.field.selector&&u.W.includes(Object.keys(this.field.selector)[0])?a.qy` <ha-script-field-selector-editor class="${this._selectorRowCollapsed?"hidden":""}" .selected="${this._selectorRowSelected}" .hass="${this.hass}" .field="${this.field}" .disabled="${this.disabled}" indent @value-changed="${this._selectorValueChanged}" .narrow="${this.narrow}"></ha-script-field-selector-editor> `:a.s6} </div> `:a.s6} `}_toggleCollapse(){this._collapsed=!this._collapsed}expand(){this._collapsed=!1}collapse(){this._collapsed=!0}expandSelectorRow(){this._selectorRowCollapsed=!1}collapseSelectorRow(){this._selectorRowCollapsed=!0}_toggleSelectorRowCollapse(){this._selectorRowCollapsed=!this._selectorRowCollapsed}expandAll(){this.expand(),this.expandSelectorRow(),this._selectorEditor?.expandAll()}collapseAll(){this.collapse(),this.collapseSelectorRow(),this._selectorEditor?.collapseAll()}_toggleSidebar(t){t?.stopPropagation(),this._selected?(0,l.r)(this,"request-close-sidebar"):(this._selected=!0,this._collapsed=!1,this.openSidebar())}_toggleSelectorSidebar(t){t?.stopPropagation(),this._selectorRowSelected?(0,l.r)(this,"request-close-sidebar"):(this._selectorRowSelected=!0,this._selectorRowCollapsed=!1,this.openSidebar(!0))}_selectorValueChanged(t){t.stopPropagation(),(0,l.r)(this,"value-changed",{value:{...this.field,key:this.key,...t.detail.value}})}openSidebar(t=!1,e){t||(this._selected=!0);const i=e??this.field;(0,l.r)(this,"open-sidebar",{save:t=>{(0,l.r)(this,"value-changed",{value:t})},close:e=>{t?(this._selectorRowSelected=!1,e&&this.focusSelector()):(this._selected=!1,e&&this.focus()),(0,l.r)(this,"close-sidebar")},toggleYamlMode:()=>{this._toggleYamlMode(),this.openSidebar()},delete:this._onDelete,config:{field:i,selector:t,key:this.key,excludeKeys:this.excludeKeys},yamlMode:this._yamlMode,editNote:this._editNote}),this.narrow&&window.setTimeout(()=>{this.scrollIntoView({block:"start",behavior:"smooth"})},180)}focus(){this._fieldRowElement?.focus()}focusSelector(){this._selectorRowElement?.focus()}_handleDropdownSelect(t){const e=t.detail?.item?.value;if(e)switch(e){case"toggle_yaml_mode":this._toggleYamlMode(t.target);break;case"delete":this._onDelete();break;case"edit_note":this._editNote()}}static get styles(){return[y.bH,y.aM,y.Lt,a.AH`.selector-row{padding-top:12px;padding-bottom:16px;padding-inline-start:16px;padding-inline-end:0px}`]}constructor(...t){super(...t),this.excludeKeys=[],this.disabled=!1,this.narrow=!1,this._yamlMode=!1,this._selected=!1,this._collapsed=!1,this._selectorRowSelected=!1,this._selectorRowCollapsed=!1,this._editNote=async()=>{const t=await(0,g.an)(this,{title:this.hass.localize("ui.panel.config.automation.editor.note."+(this.field.description?"edit":"add")),inputLabel:this.hass.localize("ui.panel.config.automation.editor.note.label"),inputType:"string",defaultValue:this.field.description,confirmText:this.hass.localize("ui.common.submit"),multiline:!0});if(null!==t){const e={...this.field};""===t?delete e.description:e.description=t,(0,l.r)(this,"value-changed",{value:e}),this._selected&&this.openSidebar(!1,e)}},this._toggleYamlMode=t=>{this._yamlMode=!this._yamlMode,t&&this.openSidebar(t.hasAttribute("selector-row"))},this._onDelete=()=>{(0,l.r)(this,"value-changed",{value:null}),(this._selected||this._selectorRowSelected)&&(0,l.r)(this,"close-sidebar"),(0,f.c)(this,{message:this.hass.localize("ui.common.successfully_deleted"),duration:4e3,action:{text:this.hass.localize("ui.common.undo"),action:()=>{(0,l.r)(window,"undo-change")}}})}}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],k.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)()],k.prototype,"key",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],k.prototype,"excludeKeys",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],k.prototype,"field",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],k.prototype,"disabled",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],k.prototype,"narrow",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],k.prototype,"highlight",void 0),(0,s.Cg)([(0,o.wk)()],k.prototype,"_yamlMode",void 0),(0,s.Cg)([(0,o.wk)()],k.prototype,"_selected",void 0),(0,s.Cg)([(0,o.wk)()],k.prototype,"_collapsed",void 0),(0,s.Cg)([(0,o.wk)()],k.prototype,"_selectorRowSelected",void 0),(0,s.Cg)([(0,o.wk)()],k.prototype,"_selectorRowCollapsed",void 0),(0,s.Cg)([(0,o.P)("ha-script-field-selector-editor")],k.prototype,"_selectorEditor",void 0),(0,s.Cg)([(0,o.P)("ha-automation-row:first-of-type")],k.prototype,"_fieldRowElement",void 0),(0,s.Cg)([(0,o.P)(".selector-row ha-automation-row")],k.prototype,"_selectorRowElement",void 0),k=(0,s.Cg)([(0,o.EM)("ha-script-field-row")],k),e()}catch(t){e(t)}})},95415(t,e,i){i.a(t,async function(t,e){try{i(18111),i(22489),i(7588),i(61701);var s=i(62826),a=i(5124),o=i(22441),r=i(1087),l=i(18350),n=(i(67094),i(17625)),h=t([l,n]);[l,n]=h.then?(await h)():h;const c="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z";class d extends a.WF{render(){return a.qy` ${this.fields?a.qy`<div class="fields"> ${Object.entries(this.fields).map(([t,e])=>a.qy` <ha-script-field-row .key="${t}" .excludeKeys="${Object.keys(this.fields).filter(e=>e!==t)}" .field="${e}" .disabled="${this.disabled}" @value-changed="${this._fieldChanged}" .hass="${this.hass}" .highlight="${void 0!==this.highlightedFields?.[t]}" .narrow="${this.narrow}"> </ha-script-field-row> `)} </div> `:a.s6} <ha-button @click="${this._addField}" .disabled="${this.disabled}"> <ha-svg-icon .path="${c}" slot="start"></ha-svg-icon> ${this.hass.localize("ui.panel.config.script.editor.field.add_field")} </ha-button> `}updated(t){super.updated(t),t.has("fields")&&this._focusLastActionOnChange&&(this._focusLastActionOnChange=!1,this.focusLastField())}focusLastField(){const t=this.shadowRoot.querySelector("ha-script-field-row:last-of-type");t.updateComplete.then(()=>{t.openSidebar(),t.focus(),this.narrow&&window.setTimeout(()=>{t.scrollIntoView({block:"start",behavior:"smooth"})},180)})}_addField(){const t=this._getUniqueKey(this.hass.localize("ui.panel.config.script.editor.field.field")||"field",this.fields||{}),e={...this.fields||{},[t]:{selector:{text:null}}};this._focusLastActionOnChange=!0,(0,r.r)(this,"value-changed",{value:e})}_fieldChanged(t){t.stopPropagation();const e=t.target.key;let i={};if(null===t.detail.value)i={...this.fields},delete i[e];else{const s={...t.detail.value},a=s.key;delete s.key;e!==a?Object.entries(this.fields).forEach(([t,o])=>{t===e?i[a]=s:i[t]=o}):(i={...this.fields},i[e]=s)}(0,r.r)(this,"value-changed",{value:i})}_getUniqueKey(t,e){let i=t;if(t in e){let s=2;do{i=`${t}_${s}`,s++}while(i in e)}return i}expandAll(){this._fieldRowElements?.forEach(t=>{t.expandAll()})}collapseAll(){this._fieldRowElements?.forEach(t=>{t.collapseAll()})}constructor(...t){super(...t),this.disabled=!1,this.narrow=!1,this._focusLastActionOnChange=!1}}d.styles=a.AH`ha-script-field-row{display:block;margin-bottom:16px;scroll-margin-top:48px}ha-svg-icon{height:20px}`,(0,s.Cg)([(0,o.MZ)({attribute:!1})],d.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],d.prototype,"disabled",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],d.prototype,"fields",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],d.prototype,"highlightedFields",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],d.prototype,"narrow",void 0),(0,s.Cg)([(0,o.YG)("ha-script-field-row")],d.prototype,"_fieldRowElements",void 0),d=(0,s.Cg)([(0,o.EM)("ha-script-fields")],d),e()}catch(t){e(t)}})},42180(t,e,i){i.a(t,async function(t,e){try{i(74423),i(44114),i(18111),i(81148),i(22489),i(20116),i(7588),i(61701),i(13579),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(14603),i(47566),i(98721);var s=i(62826),a=(i(68825),i(88696)),o=i(35211),r=i(5124),l=i(22441),n=i(89784),h=i(22786),c=i(36312),d=i(93905),p=i(1087),u=i(28978),g=i(91926),_=i(87710),f=i(86171),y=i(18350),m=i(29823),b=(i(70947),i(645)),v=i(41113),$=i(52190),w=i(66702),C=i(72644),A=i(138),H=i(2617),k=i(26300),V=i(75248),M=(i(82988),i(67094),i(34127)),x=i(2514),z=i(76570),L=i(22792),q=i(77001),S=i(22675),R=i(59241),I=i(14782),E=i(92557),Z=i(84025),F=i(71606),P=i(65063),O=i(42269),U=i(72553),B=i(54706),D=i(14503),T=i(36918),j=i(81619),W=i(34023),N=i(14839),Y=i(55270),G=i(90986),K=i(29303),X=i(25635),J=i(69569),Q=i(94017),tt=i(19661),et=t([f,y,m,b,v,$,w,C,A,H,k,V,M,U,K,Q]);[f,y,m,b,v,$,w,C,A,H,k,V,M,U,K,Q]=et.then?(await et)():et;const it="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z",st="M11,17H4A2,2 0 0,1 2,15V3A2,2 0 0,1 4,1H16V3H4V15H11V13L15,16L11,19V17M19,21V7H8V13H6V7A2,2 0 0,1 8,5H19A2,2 0 0,1 21,7V21A2,2 0 0,1 19,23H8A2,2 0 0,1 6,21V19H8V21H19Z",at="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",ot="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",rt="M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z",lt="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z",nt="M7,10L12,15L17,10H7Z",ht="M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z",ct="M8,5.14V19.14L19,12.14L8,5.14Z",dt="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",pt="M17.8,20C17.4,21.2 16.3,22 15,22H5C3.3,22 2,20.7 2,19V18H5L14.2,18C14.6,19.2 15.7,20 17,20H17.8M19,2C20.7,2 22,3.3 22,5V6H20V5C20,4.4 19.6,4 19,4C18.4,4 18,4.4 18,5V18H17C16.4,18 16,17.6 16,17V16H5V5C5,3.3 6.3,2 8,2H19M8,6V8H15V6H8M8,10V12H14V10H8Z",ut="M5.5,7A1.5,1.5 0 0,1 4,5.5A1.5,1.5 0 0,1 5.5,4A1.5,1.5 0 0,1 7,5.5A1.5,1.5 0 0,1 5.5,7M21.41,11.58L12.41,2.58C12.05,2.22 11.55,2 11,2H4C2.89,2 2,2.89 2,4V11C2,11.55 2.22,12.05 2.59,12.41L11.58,21.41C11.95,21.77 12.45,22 13,22C13.55,22 14.05,21.77 14.41,21.41L21.41,14.41C21.78,14.05 22,13.55 22,13C22,12.44 21.77,11.94 21.41,11.58Z",gt="M20 2H4C2.9 2 2 2.9 2 4V20C2 21.11 2.9 22 4 22H20C21.11 22 22 21.11 22 20V4C22 2.9 21.11 2 20 2M4 6L6 4H10.9L4 10.9V6M4 13.7L13.7 4H18.6L4 18.6V13.7M20 18L18 20H13.1L20 13.1V18M20 10.3L10.3 20H5.4L20 5.4V10.3Z",_t="M15,12C15,10.7 14.16,9.6 13,9.18V6.82C14.16,6.4 15,5.3 15,4A3,3 0 0,0 12,1A3,3 0 0,0 9,4C9,5.3 9.84,6.4 11,6.82V9.19C9.84,9.6 9,10.7 9,12C9,13.3 9.84,14.4 11,14.82V17.18C9.84,17.6 9,18.7 9,20A3,3 0 0,0 12,23A3,3 0 0,0 15,20C15,18.7 14.16,17.6 13,17.18V14.82C14.16,14.4 15,13.3 15,12M12,3A1,1 0 0,1 13,4A1,1 0 0,1 12,5A1,1 0 0,1 11,4A1,1 0 0,1 12,3M12,21A1,1 0 0,1 11,20A1,1 0 0,1 12,19A1,1 0 0,1 13,20A1,1 0 0,1 12,21Z";class ft extends((0,B.E)(r.WF)){get _availableAssistants(){return(0,tt.V)(this.cloudStatus,this.hass)}hassSubscribe(){return[(0,z.Ar)(this.hass.connection,"script",t=>{this._categories=t})]}render(){const t=this._sizeController.value&&this._sizeController.value<900||!this._sizeController.value&&"docked"===this.hass.dockedSidebar,e=t&&(!this._sizeController.value||this._sizeController.value<700),i=this._scripts(this.scripts,this._entityReg,this.hass.areas,this._categories,this._labels,this._filteredEntityIds);return r.qy` <hass-tabs-subpage-data-table .hass="${this.hass}" .narrow="${this.narrow}" .backPath="${this._searchParms.has("historyBack")?void 0:"/config"}" .route="${this.route}" .tabs="${X.configSections.automations}" .searchLabel="${this.hass.localize("ui.panel.config.script.picker.search",{number:i.length})}" has-filters .initialGroupColumn="${this._activeGrouping??"category"}" .initialCollapsedGroups="${this._activeCollapsed}" .initialSorting="${this._activeSorting}" .columnOrder="${this._activeColumnOrder}" .hiddenColumns="${this._activeHiddenColumns}" @columns-changed="${this._handleColumnsChanged}" @sorting-changed="${this._handleSortingChanged}" @grouping-changed="${this._handleGroupingChanged}" @collapsed-changed="${this._handleCollapseChanged}" selectable .selected="${this._selected.length}" @selection-changed="${this._handleSelectionChanged}" .filters="${Object.values(this._filters).filter(t=>Array.isArray(t.value)?t.value.length:t.value&&Object.values(t.value).some(t=>Array.isArray(t)?t.length:t)).length}" .columns="${this._columns(this.hass.localize,i)}" .data="${i}" .empty="${!this.scripts.length}" .activeFilters="${this._activeFilters}" id="entity_id" .noDataText="${this.hass.localize("ui.panel.config.script.picker.no_scripts")}" @clear-filter="${this._clearFilter}" .filter="${this._filter}" @search-changed="${this._handleSearchChange}" has-fab clickable class="${this.narrow?"narrow":""}" @row-click="${this._handleRowClicked}"> <ha-icon-button slot="toolbar-icon" .label="${this.hass.localize("ui.common.help")}" .path="${rt}" @click="${this._showHelp}"></ha-icon-button> <ha-filter-floor-areas .hass="${this.hass}" .type="${"script"}" .value="${this._filters["ha-filter-floor-areas"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-floor-areas"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-floor-areas> <ha-filter-devices .hass="${this.hass}" .type="${"script"}" .value="${this._filters["ha-filter-devices"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-devices"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-devices> <ha-filter-entities .hass="${this.hass}" .type="${"script"}" .value="${this._filters["ha-filter-entities"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-entities"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-entities> <ha-filter-labels .hass="${this.hass}" .value="${this._filters["ha-filter-labels"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-labels"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-labels> <ha-filter-categories .hass="${this.hass}" scope="script" .value="${this._filters["ha-filter-categories"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-categories"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-categories> <ha-filter-voice-assistants .hass="${this.hass}" .value="${this._filters["ha-filter-voice-assistants"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-voice-assistants"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-voice-assistants> <ha-filter-blueprints .hass="${this.hass}" .type="${"script"}" .value="${this._filters["ha-filter-blueprints"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-blueprints"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-blueprints> ${this.narrow?r.s6:r.qy`<ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkCategory}"> <ha-assist-chip slot="trigger" .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.move_category")}"> <ha-svg-icon slot="trailing-icon" .path="${nt}"></ha-svg-icon> </ha-assist-chip> ${this._renderCategoryItems()} </ha-dropdown> ${e?r.s6:r.qy`<ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkLabel}"> <ha-assist-chip slot="trigger" .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.add_label")}"> <ha-svg-icon slot="trailing-icon" .path="${nt}"></ha-svg-icon> </ha-assist-chip> ${this._renderLabelItems()} </ha-dropdown>`} ${t?r.s6:r.qy`<ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkArea}"> <ha-assist-chip slot="trigger" .label="${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.move_area")}"> <ha-svg-icon slot="trailing-icon" .path="${nt}"></ha-svg-icon> </ha-assist-chip> ${this._renderAreaItems()} </ha-dropdown>`}`} ${this.narrow||t?r.qy` <ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkAction}"> ${this.narrow?r.qy`<ha-assist-chip .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_action")}" slot="trigger"> <ha-svg-icon slot="trailing-icon" .path="${nt}"></ha-svg-icon> </ha-assist-chip>`:r.qy`<ha-icon-button .path="${ot}" .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_action")}" slot="trigger"></ha-icon-button>`} ${this.narrow?r.qy`<ha-dropdown-item> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.move_category")} ${this._renderCategoryItems("submenu")} </ha-dropdown-item>`:r.s6} ${this.narrow||e?r.qy`<ha-dropdown-item> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.add_label")} ${this._renderLabelItems("submenu")} </ha-dropdown-item>`:r.s6} ${this.narrow||t?r.qy`<ha-dropdown-item> ${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.move_area")} ${this._renderAreaItems("submenu")} </ha-dropdown-item>`:r.s6} </ha-dropdown>`:r.s6} ${this.scripts.length?r.s6:r.qy` <div class="empty" slot="empty"> <ha-svg-icon .path="${pt}"></ha-svg-icon> <h1> ${this.hass.localize("ui.panel.config.script.picker.empty_header")} </h1> <p> ${this.hass.localize("ui.panel.config.script.picker.empty_text")} </p> <ha-button appearance="plain" href="${(0,T.o)(this.hass,"/docs/script/editor/")}" target="_blank" rel="noreferrer" size="small"> ${this.hass.localize("ui.panel.config.common.learn_more")} <ha-svg-icon slot="end" .path="${ht}"></ha-svg-icon> </ha-button> </div>`} <ha-button slot="fab" size="large" @click="${this._createNew}"> <ha-svg-icon slot="start" .path="${dt}"></ha-svg-icon> ${this.hass.localize("ui.panel.config.script.picker.add_script")} </ha-button> </hass-tabs-subpage-data-table> `}_handleSearchChange(t){this._filter=t.detail.value}_filterExpanded(t){t.detail.expanded?this._expandedFilter=t.target.localName:this._expandedFilter===t.target.localName&&(this._expandedFilter=void 0)}_filterChanged(t){const e=t.target.localName;this._filters={...this._filters,[e]:t.detail},this._fromUrl||(this._storageFilters=this._filters),this._applyFilters()}_clearFilter(){this._filters={},this._fromUrl||(this._storageFilters={}),this._applyFilters()}_applyFilters(){const t=Object.entries(this._filters);let e=this.scripts.map(t=>t.entity_id);for(const[i,s]of t)(0,q.fq)(i,s,["ha-filter-floor-areas","ha-filter-devices","ha-filter-entities","ha-filter-blueprints"])?e=e.filter(t=>s.items.has(t)):(0,q._H)(i,s,"ha-filter-categories")?e=e.filter(t=>s.value[0]===this._entityReg.find(e=>e.entity_id===t)?.categories.script):(0,q._H)(i,s,"ha-filter-labels")?e=e.filter(t=>this._entityReg.find(e=>e.entity_id===t)?.labels.some(t=>s.value.includes(t))):(0,q._H)(i,s,"ha-filter-voice-assistants")&&(e=e.filter(t=>(0,I.hB)(this._entityReg,t).some(t=>s.value.includes(t))));this._filteredEntityIds=e}willUpdate(t){if(super.willUpdate(t),!this.hasUpdated){this._searchParms.has("area")||this._searchParms.has("blueprint")||this._searchParms.has("device")||this._searchParms.has("label")||(this._filters=this._storageFilters),this._searchParms.has("area")&&this._filterArea(),this._searchParms.has("device")&&this._filterDevice(),this._searchParms.has("blueprint")&&this._filterBlueprint(),this._searchParms.has("label")&&this._filterLabel()}}updated(t){super.updated(t),t.has("_entityReg")&&this._applyFilters()}_filterArea(){const t=this._searchParms.get("area");t&&(this._fromUrl=!0,this._filters={...this._filters,"ha-filter-floor-areas":{value:{areas:[t]},items:void 0}},this._applyFilters())}_filterDevice(){const t=this._searchParms.get("device");t&&(this._fromUrl=!0,this._filters={...this._filters,"ha-filter-devices":{value:[t],items:void 0}},this._applyFilters())}_filterLabel(){const t=this._searchParms.get("label");t&&(this._fromUrl=!0,this._filters={...this._filters,"ha-filter-labels":{value:[t],items:void 0}},this._applyFilters())}async _filterBlueprint(){const t=this._searchParms.get("blueprint");if(!t)return;this._fromUrl=!0;const e=await(0,F.f)(this.hass,"script_blueprint",t);this._filters={...this._filters,"ha-filter-blueprints":{value:[t],items:new Set(e.automation||[])}},this._applyFilters()}_editCategory(t){const e=this._entityReg.find(e=>e.entity_id===t.entity_id);e?(0,Y.j)(this,{scope:"script",entityReg:e}):(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.script.picker.no_category_support"),text:this.hass.localize("ui.panel.config.script.picker.no_category_entity_reg")})}_handleSelectionChanged(t){this._selected=t.detail.value}async _bulkAddCategory(t){const e=[];this._selected.forEach(i=>{e.push((0,R.G_)(this.hass,i,{categories:{script:t}}))});const i=await Promise.allSettled(e);if((0,_.$)(i)){const t=(0,_.N)(i);(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:r.qy`<pre>
${t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n")}</pre>`})}}async _bulkLabel(t,e){const i=[];this._selected.forEach(s=>{i.push((0,R.G_)(this.hass,s,{labels:"add"===e?this.hass.entities[s].labels.concat(t):this.hass.entities[s].labels.filter(e=>e!==t)}))});const s=await Promise.allSettled(i);if((0,_.$)(s)){const t=(0,_.N)(s);(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:r.qy`<pre>
${t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n")}</pre>`})}}_handleRowClicked(t){const e=this._entityReg.find(e=>e.entity_id===t.detail.id);e?(0,g.oo)(`/config/script/edit/${e.unique_id}`):(0,g.oo)(`/config/script/show/${t.detail.id}`)}_createNew(){(0,c.x)(this.hass.config,"blueprint")?(0,N.l)(this,{mode:"script"}):(0,g.oo)("/config/script/edit/new")}_showInfo(t){(0,p.r)(this,"hass-more-info",{entityId:t.entity_id})}_openSettings(t){(0,O.p)(this,{entityId:t.entity_id,view:"settings"})}_showTrace(t){const e=this._entityReg.find(e=>e.entity_id===t.entity_id);e&&(0,g.oo)(`/config/script/trace/${e.unique_id}`)}_showHelp(){(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.script.caption"),text:r.qy` ${this.hass.localize("ui.panel.config.script.picker.introduction")} <p> <a href="${(0,T.o)(this.hass,"/docs/scripts/")}" target="_blank" rel="noreferrer"> ${this.hass.localize("ui.panel.config.script.picker.learn_more")} </a> </p> `})}async _duplicate(t){try{const e=this._entityReg.find(e=>e.entity_id===t.entity_id);if(!e)return;const i=await(0,Z.Kq)(this.hass,e.unique_id);(0,Z.AM)({...i,alias:`${i?.alias} (${this.hass.localize("ui.panel.config.script.picker.duplicate")})`})}catch(e){if(404===e.status_code){const e=await(0,Z.R$)(this.hass,t.entity_id);return void(0,Z.AM)(e.config)}await(0,P.showAlertDialog)(this,{text:this.hass.localize("ui.panel.config.script.editor.load_error_unknown",{err_no:e.status_code})})}}async _deleteConfirm(t){(0,P.dk)(this,{title:this.hass.localize("ui.panel.config.script.editor.delete_confirm_title"),text:this.hass.localize("ui.panel.config.script.editor.delete_confirm_text",{name:t.name}),confirmText:this.hass.localize("ui.common.delete"),dismissText:this.hass.localize("ui.common.cancel"),confirm:()=>this._delete(t),destructive:!0})}async _delete(t){try{const e=this._entityReg.find(e=>e.entity_id===t.entity_id);e&&(await(0,Z.Ht)(this.hass,e.unique_id),this._selected=this._selected.filter(e=>e!==t.entity_id))}catch(t){await(0,P.showAlertDialog)(this,{text:400===t.status_code?this.hass.localize("ui.panel.config.script.editor.load_error_not_deletable"):this.hass.localize("ui.panel.config.script.editor.load_error_unknown",{err_no:t.status_code})})}}async _bulkAddArea(t){const e=[];this._selected.forEach(i=>{e.push((0,R.G_)(this.hass,i,{area_id:t}))});const i=await Promise.allSettled(e);if((0,_.$)(i)){const t=(0,_.N)(i);(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:r.qy`<pre>
${t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n")}</pre>`})}}_handleSortingChanged(t){this._activeSorting=t.detail}_handleGroupingChanged(t){this._activeGrouping=t.detail.value??""}_handleCollapseChanged(t){this._activeCollapsed=t.detail.value}_handleColumnsChanged(t){this._activeColumnOrder=t.detail.columnOrder,this._activeHiddenColumns=t.detail.hiddenColumns}static get styles(){return[D.RF,r.AH`:host{display:block;height:100%}hass-tabs-subpage-data-table{--data-table-row-height:60px}hass-tabs-subpage-data-table.narrow{--data-table-row-height:72px}a{text-decoration:none}.empty{--mdc-icon-size:80px;max-width:500px}.empty ha-button{--mdc-icon-size:24px}.empty h1{font-size:var(--ha-font-size-3xl)}ha-assist-chip{--ha-assist-chip-container-shape:10px}ha-dropdown::part(menu),ha-dropdown::part(submenu){--auto-size-available-width:calc(50vw - var(--ha-space-4))}ha-dropdown ha-assist-chip{--md-assist-chip-trailing-space:8px}`]}constructor(...t){super(...t),this.isWide=!1,this.narrow=!1,this._searchParms=new URLSearchParams(window.location.search),this._selected=[],this._filter="",this._filters={},this._storageFilters={},this._fromUrl=!1,this._entityReg=[],this._sizeController=new a.P(this,{callback:t=>t[0]?.contentRect.width}),this._scripts=(0,h.A)((t,e,i,s,a,o)=>null===o?[]:(o?t.filter(t=>o.includes(t.entity_id)):t).map(t=>{const o=e.find(e=>e.entity_id===t.entity_id),r=o?.categories.script,l=(a&&o?.labels||[]).map(t=>a.find(e=>e.label_id===t)).filter(t=>void 0!==t),n=(0,I.hB)(e,t.entity_id);return{...t,name:(0,u.u)(t),area:o?.area_id?i[o?.area_id]?.name:void 0,last_triggered:t.attributes.last_triggered||void 0,category:r?s?.find(t=>t.category_id===r)?.name:void 0,label_entries:l,labels:l.map(t=>t.name),assistants:n,assistants_sortable_key:(0,Q.HX)(n),selectable:void 0!==o}})),this._columns=(0,h.A)((t,e)=>({icon:{title:"",showNarrow:!0,moveable:!1,label:t("ui.panel.config.script.picker.headers.icon"),type:"icon",template:t=>r.qy`<ha-state-icon .stateObj="${t}" style="${(0,n.W)({color:t.state===S.Hh?"var(--error-color)":"unset"})}"></ha-state-icon>`},entity_id:(0,K.t)(),name:{title:t("ui.panel.config.script.picker.headers.name"),main:!0,sortable:!0,filterable:!0,direction:"asc",flex:2,extraTemplate:t=>t.label_entries.length?r.qy`<ha-data-table-labels @label-clicked="${this._labelClicked}" .labels="${t.label_entries}"></ha-data-table-labels>`:r.s6},area:(0,K.A7)(t),category:(0,K.Bl)(t),labels:(0,K.AI)(),last_triggered:(0,K.N4)(t,this.hass),actions:{lastFixed:!0,title:"",label:this.hass.localize("ui.panel.config.generic.headers.actions"),type:"overflow-menu",showNarrow:!0,template:t=>r.qy` <ha-icon-overflow-menu narrow .items="${[{path:lt,label:this.hass.localize("ui.panel.config.script.picker.show_info"),action:()=>this._showInfo(t)},{path:it,label:this.hass.localize("ui.panel.config.automation.picker.show_settings"),action:()=>this._openSettings(t)},{path:ut,label:this.hass.localize("ui.panel.config.script.picker."+(t.category?"edit_category":"assign_category")),action:()=>this._editCategory(t)},{path:ct,label:this.hass.localize("ui.panel.config.script.picker.run"),action:()=>this._runScript(t)},{path:_t,label:this.hass.localize("ui.panel.config.script.picker.show_trace"),action:()=>this._showTrace(t)},{divider:!0},{path:st,label:this.hass.localize("ui.panel.config.script.picker.duplicate"),action:()=>this._duplicate(t)},{label:this.hass.localize("ui.panel.config.script.picker.delete"),path:at,action:()=>this._deleteConfirm(t),warning:!0}]}"> </ha-icon-overflow-menu> `},assistants:(0,Q.MD)(t,this.hass,this._availableAssistants,e)})),this._labelClicked=t=>{const e=t.detail.label;this._filters={...this._filters,"ha-filter-labels":{value:[e.label_id],items:void 0}},this._fromUrl||(this._storageFilters=this._filters),this._applyFilters()},this._handleBulkCategory=t=>{const e=t.detail.item.value;"category_create"!==e?"category_none"!==e?e?.startsWith("category_")&&this._bulkAddCategory(e.substring(9)):this._bulkAddCategory(null):this._bulkCreateCategory()},this._handleBulkLabel=t=>{t.preventDefault();const e=t.detail.item.value;if("label_create"!==e){if(e?.startsWith("label_")){const i=t.detail.item.action;this._bulkLabel(e.substring(6),i)}}else this._bulkCreateLabel()},this._runScript=async t=>{const e=this._entityReg.find(e=>e.entity_id===t.entity_id);e&&((0,Z.TP)(this.hass,e.unique_id)?this._showInfo(t):(await(0,Z.kR)(this.hass,e.unique_id),(0,j.P)(this,{message:this.hass.localize("ui.notification_toast.triggered",{name:(0,u.u)(t)})})))},this._bulkCreateCategory=()=>{(0,G.S)(this,{scope:"script",createEntry:async t=>{const e=await(0,z.s_)(this.hass,"script",t);return this._bulkAddCategory(e.category_id),e}})},this._bulkCreateLabel=()=>{(0,J.f)(this,{createEntry:async t=>{const e=await(0,E._9)(this.hass,t);this._bulkLabel(e.label_id,"add")}})},this._handleBulkArea=t=>{const e=t.detail.item.value;"area_create"!==e?"area_none"!==e?e?.startsWith("area_")&&this._bulkAddArea(e.substring(5)):this._bulkAddArea(null):this._bulkCreateArea()},this._bulkCreateArea=()=>{(0,W.J)(this,{createEntry:async t=>{const e=await(0,x.L3)(this.hass,t);return this._bulkAddArea(e.area_id),e}})},this._renderCategoryItems=(t="")=>r.qy`${this._categories?.map(e=>r.qy`<ha-dropdown-item .slot="${t}" .value="${`category_${e.category_id}`}"> ${e.icon?r.qy`<ha-icon slot="icon" .icon="${e.icon}"></ha-icon>`:r.qy`<ha-svg-icon slot="icon" .path="${ut}"></ha-svg-icon>`} ${e.name} </ha-dropdown-item>`)} <ha-dropdown-item .slot="${t}" value="category_none"> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.no_category")} </ha-dropdown-item> <wa-divider .slot="${t}"></wa-divider> <ha-dropdown-item .slot="${t}" value="category_create"> ${this.hass.localize("ui.panel.config.category.editor.add")} </ha-dropdown-item>`,this._renderLabelItems=(t="")=>r.qy`${this._labels?.map(e=>{const i=this._selected.every(t=>this.hass.entities[t]?.labels.includes(e.label_id)),s=!i&&this._selected.some(t=>this.hass.entities[t]?.labels.includes(e.label_id));return r.qy`<ha-dropdown-item .slot="${t}" .value="${`label_${e.label_id}`}" .action="${i?"remove":"add"}"> <ha-checkbox slot="icon" .checked="${i}" .indeterminate="${s}"></ha-checkbox> <ha-label .color="${e.color}" .description="${e.description}"> ${e.icon?r.qy`<ha-icon slot="icon" .icon="${e.icon}"></ha-icon>`:r.s6} ${e.name} </ha-label> </ha-dropdown-item>`})} <wa-divider .slot="${t}"></wa-divider> <ha-dropdown-item .slot="${t}" value="label_create"> ${this.hass.localize("ui.panel.config.labels.add_label")} </ha-dropdown-item>`,this._renderAreaItems=(t="")=>r.qy`${Object.values(this.hass.areas).map(e=>r.qy`<ha-dropdown-item .slot="${t}" .value="${`area_${e.area_id}`}"> ${e.icon?r.qy`<ha-icon slot="icon" .icon="${e.icon}"></ha-icon>`:r.qy`<ha-svg-icon slot="icon" .path="${gt}"></ha-svg-icon>`} ${e.name} </ha-dropdown-item>`)} <ha-dropdown-item .slot="${t}" value="area_none"> ${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.no_area")} </ha-dropdown-item> <wa-divider .slot="${t}"></wa-divider> <ha-dropdown-item .slot="${t}" value="area_create"> ${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.add_area")} </ha-dropdown-item>`,this._handleBulkAction=t=>{const e=t.detail.item,i=e.value;if(i)if(i.startsWith("category_"))"category_create"===i?this._bulkCreateCategory():"category_none"===i?this._bulkAddCategory(null):this._bulkAddCategory(i.substring(9));else if(i.startsWith("label_"))if("label_create"===i)this._bulkCreateLabel();else{const t=e.action;this._bulkLabel(i.substring(6),t)}else i.startsWith("area_")&&("area_create"===i?this._bulkCreateArea():"area_none"===i?this._bulkAddArea(null):this._bulkAddArea(i.substring(5)))}}}(0,s.Cg)([(0,l.MZ)({attribute:!1})],ft.prototype,"hass",void 0),(0,s.Cg)([(0,l.MZ)({attribute:!1})],ft.prototype,"scripts",void 0),(0,s.Cg)([(0,l.MZ)({attribute:"is-wide",type:Boolean})],ft.prototype,"isWide",void 0),(0,s.Cg)([(0,l.MZ)({type:Boolean})],ft.prototype,"narrow",void 0),(0,s.Cg)([(0,l.MZ)({attribute:!1})],ft.prototype,"route",void 0),(0,s.Cg)([(0,l.MZ)({attribute:!1})],ft.prototype,"cloudStatus",void 0),(0,s.Cg)([(0,l.wk)()],ft.prototype,"_searchParms",void 0),(0,s.Cg)([(0,l.wk)()],ft.prototype,"_selected",void 0),(0,s.Cg)([(0,l.wk)()],ft.prototype,"_activeFilters",void 0),(0,s.Cg)([(0,l.wk)()],ft.prototype,"_filteredEntityIds",void 0),(0,s.Cg)([(0,l.wk)(),(0,d.I)({storage:"sessionStorage",key:"script-table-search",state:!0,subscribe:!1})],ft.prototype,"_filter",void 0),(0,s.Cg)([(0,l.wk)()],ft.prototype,"_filters",void 0),(0,s.Cg)([(0,d.I)({storage:"sessionStorage",key:"script-table-filters-full",state:!1,subscribe:!1,serializer:q.iS,deserializer:q.Dc})],ft.prototype,"_storageFilters",void 0),(0,s.Cg)([(0,l.wk)()],ft.prototype,"_expandedFilter",void 0),(0,s.Cg)([(0,l.wk)()],ft.prototype,"_categories",void 0),(0,s.Cg)([(0,o.Fg)({context:L.HD,subscribe:!0}),(0,l.wk)()],ft.prototype,"_labels",void 0),(0,s.Cg)([(0,l.wk)(),(0,o.Fg)({context:L.ih,subscribe:!0})],ft.prototype,"_entityReg",void 0),(0,s.Cg)([(0,d.I)({key:"script-table-sort",state:!1,subscribe:!1})],ft.prototype,"_activeSorting",void 0),(0,s.Cg)([(0,d.I)({key:"script-table-grouping",state:!1,subscribe:!1})],ft.prototype,"_activeGrouping",void 0),(0,s.Cg)([(0,d.I)({key:"script-table-collapsed",state:!1,subscribe:!1})],ft.prototype,"_activeCollapsed",void 0),(0,s.Cg)([(0,d.I)({key:"script-table-column-order",state:!1,subscribe:!1})],ft.prototype,"_activeColumnOrder",void 0),(0,s.Cg)([(0,d.I)({key:"script-table-hidden-columns",state:!1,subscribe:!1})],ft.prototype,"_activeHiddenColumns",void 0),ft=(0,s.Cg)([(0,l.EM)("ha-script-picker")],ft),e()}catch(t){e(t)}})},84042(t,e,i){i.a(t,async function(t,e){try{i(74423),i(18111),i(22489);var s=i(62826),a=i(53289),o=i(5124),r=i(22441),l=i(63533),n=i(44537),h=i(68348),c=i(1087),d=i(26300),p=(i(3587),i(84025)),u=i(36918),g=i(49053),_=i(68469),f=i(136),y=i(84047),m=i(57116),b=i(95415),v=t([d,_,b,f]);[d,_,b,f]=v.then?(await v)():v;const $="M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z",w=(0,l.Ik)({alias:(0,l.lq)((0,l.Yj)()),description:(0,l.lq)((0,l.Yj)()),sequence:(0,l.lq)((0,l.YO)((0,l.bz)())),icon:(0,l.lq)((0,l.Yj)()),mode:(0,l.lq)((0,l.vP)([typeof p.FN])),max:(0,l.lq)((0,l.ai)()),fields:(0,l.lq)((0,l.Ik)())});class C extends((0,f.N)(o.WF)){addFields(){this._openFields=!0,(0,c.r)(this,"value-changed",{value:{...this.config,fields:{[this.hass.localize("ui.panel.config.script.editor.field.field")||"field"]:{selector:{text:null}}}}})}updated(t){super.updated(t),this._openFields&&t.has("config")&&(this._openFields=!1,this._scriptFields?.updateComplete.then(()=>this._scriptFields?.focusLastField()))}renderContent(){return o.qy` ${this.config.description?o.qy`<ha-markdown class="description" breaks .content="${this.config.description}"></ha-markdown>`:o.s6} ${this.config.fields?o.qy`<div class="header"> <h2 id="fields-heading" class="name"> ${this.hass.localize("ui.panel.config.script.editor.field.fields")} </h2> <ha-icon-button .path="${$}" .label="${this.hass.localize("ui.panel.config.script.editor.field.link_help_fields")}" href="${(0,u.o)(this.hass,"/integrations/script/#fields")}" target="_blank" rel="noreferrer"></ha-icon-button> </div> <ha-script-fields role="region" aria-labelledby="fields-heading" .fields="${this.config.fields}" .highlightedFields="${this.pastedConfig?.fields}" @value-changed="${this._fieldsChanged}" .hass="${this.hass}" .disabled="${this.disabled}" .narrow="${this.narrow}" @open-sidebar="${this.openSidebar}" @request-close-sidebar="${this.triggerCloseSidebar}" @close-sidebar="${this.handleCloseSidebar}"></ha-script-fields>`:o.s6} <div class="header"> <h2 id="sequence-heading" class="name"> ${this.hass.localize("ui.panel.config.script.editor.sequence")} </h2> </div> <ha-automation-action role="region" aria-labelledby="sequence-heading" .actions="${this.config.sequence||[]}" .highlightedActions="${this.pastedConfig?.sequence}" @value-changed="${this._sequenceChanged}" @open-sidebar="${this.openSidebar}" @request-close-sidebar="${this.triggerCloseSidebar}" @close-sidebar="${this.handleCloseSidebar}" .hass="${this.hass}" .editorDirty="${this.dirty}" .narrow="${this.narrow}" .disabled="${this.disabled||this.saving}" root sidebar></ha-automation-action> `}saveConfig(){(0,c.r)(this,"save-script")}_fieldsChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,c.r)(this,"value-changed",{value:{...this.config,fields:t.detail.value}})}_sequenceChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,c.r)(this,"value-changed",{value:{...this.config,sequence:t.detail.value}})}_appendToExistingConfig(t){this.pastedConfig=t;const e={...this.config};e&&("fields"in t&&(e.fields={...e.fields,...t.fields}),"sequence"in t&&(e.sequence=(0,n.e)(e.sequence||[]).concat((0,n.e)(t.sequence))),this.showPastedToastWithUndo(),(0,c.r)(this,"value-changed",{value:{...e}}))}showPastedToastWithUndo(){(0,g.c)(this,{message:this.hass.localize("ui.panel.config.script.editor.paste_toast_message"),duration:4e3,action:{text:this.hass.localize("ui.common.undo"),action:()=>{(0,c.r)(this,"undo-change"),this.pastedConfig=void 0}}})}static get styles(){return[m.T_,m.qK,o.AH`.header{display:flex;align-items:center}.header:first-child{margin-top:-16px}.header .name{font-size:var(--ha-font-size-xl);font-weight:var(--ha-font-weight-normal);flex:1}.description{margin-top:16px}ha-icon-button{color:var(--secondary-text-color)}`]}constructor(...t){super(...t),this._openFields=!1,this.handlePaste=async t=>{if(!(0,h.u)(t.composedPath()))return;const e=t.clipboardData?.getData("text");if(!e)return;let i;try{i=(0,a.Hh)(e)}catch(t){return void(0,g.c)(this,{message:this.hass.localize("ui.panel.config.script.editor.paste_invalid_config"),duration:4e3,dismissable:!0})}if(!i||"object"!=typeof i)return;let s=i;"script"in s&&(s=s.script,Object.keys(s).length&&(s=s[Object.keys(s)[0]])),Array.isArray(s)&&(s=1===s.length?s[0]:{sequence:s});const o=(0,p.pq)(s);let r;(!["sequence","unknown"].includes(o)||"sequence"===o&&"metadata"in s)&&(s={sequence:[s]});try{r=(0,p.nB)(s)}catch(t){return}try{(0,l.vA)(r,w)}catch(t){return void(0,g.c)(this,{message:this.hass.localize("ui.panel.config.script.editor.paste_invalid_config"),duration:4e3,dismissable:!0})}if(r){t.preventDefault();const e=Object.keys(r).filter(t=>(0,n.e)(r[t]).length);if(1===e.length&&["sequence"].includes(e[0])&&this.tryInsertAfterSelected(r[e[0]]))return void this.showPastedToastWithUndo();if(this.dirty||(0,n.e)(this.config.sequence)?.length||Object.keys(this.config.fields||{}).length){if(!await new Promise(t=>{(0,y.Z)(this,{domain:"script",pastedConfig:r,onClose:()=>t(!1),onAppend:()=>{this._appendToExistingConfig(r),t(!1)},onReplace:()=>t(!0)})}))return}this.replaceExistingConfig(r)}}}}(0,s.Cg)([(0,r.P)("ha-script-fields")],C.prototype,"_scriptFields",void 0),(0,s.Cg)([(0,r.YG)("ha-automation-action, ha-script-fields")],C.prototype,"collapsableElements",void 0),C=(0,s.Cg)([(0,r.EM)("manual-script-editor")],C),e()}catch(t){e(t)}})}};