iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 70.2 kB
JavaScript
export const __rspack_esm_id=283;export const __rspack_esm_ids=[283];export const __webpack_modules__={20543(t,i,e){e.a(t,async function(t,i){try{var o=e(62826),n=e(5124),s=e(22441),a=e(9899),d=e(88249),c=e(34127),r=(e(78486),t([c]));c=(r.then?(await r)():r)[0];class l extends n.WF{connectedCallback(){super.connectedCallback(),this._subscribeCondition()}updated(t){super.updated(t),t.has("condition")&&void 0!==t.get("condition")&&(this._resetSubscription(),this._debounceSubscribeCondition())}disconnectedCallback(){super.disconnectedCallback(),this._debounceSubscribeCondition.cancel(),this._resetSubscription()}render(){return n.qy` <div id="indicator"> <slot></slot> <ha-automation-row-live-test .state="${this._liveTestResult.state}" .label="${this.hass.localize(`ui.panel.config.automation.editor.conditions.live_test_state.${this._liveTestResult.state}`)}"></ha-automation-row-live-test> </div> ${this._liveTestResult.message?n.qy`<ha-tooltip for="indicator">${this._liveTestResult.message}</ha-tooltip>`:n.s6} `}_resetSubscription(){this._liveTestResult={state:"unknown",message:this.hass.localize("ui.panel.config.automation.editor.conditions.live_test_state.unknown")},this._conditionUnsub&&(this._conditionUnsub.then(t=>t()),this._conditionUnsub=void 0)}async _subscribeCondition(){if(this._resetSubscription(),!this.condition)return;const t=(0,d.sF)(this.hass.connection,t=>{t.error?this._handleLiveTestError(t.error):this._liveTestResult={state:t.result?"pass":"fail",message:this.hass.localize("ui.panel.config.automation.editor.conditions.testing_"+(t.result?"pass":"error"))}},this.condition);t.catch(i=>{this._handleLiveTestError(i),this._conditionUnsub===t&&(this._conditionUnsub=void 0)}),this._conditionUnsub=t}_handleLiveTestError(t){const i="string"!=typeof t&&"invalid_format"===t.code;this._liveTestResult={state:i?"invalid":"unknown",message:this.hass.localize("ui.panel.config.automation.editor.conditions."+(i?"invalid_condition":"live_test_state.unknown"))}}constructor(...t){super(...t),this._liveTestResult={state:"unknown"},this._debounceSubscribeCondition=(0,a.s)(()=>this._subscribeCondition(),500)}}l.styles=n.AH`:host{display:inline-flex;position:relative}#indicator{display:inline-flex;position:relative}`,(0,o.Cg)([(0,s.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],l.prototype,"condition",void 0),(0,o.Cg)([(0,s.wk)()],l.prototype,"_liveTestResult",void 0),l=(0,o.Cg)([(0,s.EM)("ha-automation-condition-live-test")],l),i()}catch(t){i(t)}})},78486(t,i,e){var o=e(62826),n=e(5124),s=e(22441);class a extends n.WF{render(){return n.qy` <div id="indicator" role="status" tabindex="0" aria-label="${this.label}"></div> `}constructor(...t){super(...t),this.state="unknown",this.label=""}}a.styles=n.AH`:host{position:absolute;top:-5px;inset-inline-end:-6px;display:inline-block}#indicator{width:10px;height:10px;border-radius:var(--ha-border-radius-circle);border:var(--ha-border-width-md) solid;box-sizing:border-box;background-color:var(--card-background-color);box-shadow:0 0 0 2px var(--card-background-color);transition:all var(--ha-animation-duration-normal) ease-in-out}:host([state=pass]) #indicator{background-color:var(--ha-color-green-60);border-color:var(--ha-color-green-60)}:host([state=fail]) #indicator{border-color:var(--ha-color-orange-60)}:host([state=invalid]) #indicator{border-color:var(--ha-color-red-60)}:host([state=unknown]) #indicator{border-color:var(--ha-color-neutral-60)}`,(0,o.Cg)([(0,s.MZ)({reflect:!0})],a.prototype,"state",void 0),(0,o.Cg)([(0,s.MZ)()],a.prototype,"label",void 0),a=(0,o.Cg)([(0,s.EM)("ha-automation-row-live-test")],a)},87682(t,i,e){e.a(t,async function(t,i){try{var o=e(62826),n=e(22441),s=e(10139),a=e(17062),d=t([a]);a=(d.then?(await d)():d)[0];class c extends a.V{get NO_AUTOMATION_TEXT(){return this.hass.localize("ui.panel.config.devices.automation.conditions.no_conditions")}get UNKNOWN_AUTOMATION_TEXT(){return this.hass.localize("ui.panel.config.devices.automation.conditions.unknown_condition")}constructor(){super(s.I3,s.ng,t=>({device_id:t||"",condition:"device",domain:"",entity_id:""}))}}c=(0,o.Cg)([(0,n.EM)("ha-device-condition-picker")],c),i()}catch(t){i(t)}})},76623(t,i,e){e.a(t,async function(t,o){try{e.d(i,{D:()=>h});var n=e(62826),s=e(5124),a=e(22441),d=e(91450),c=e(71727),r=e(85694),l=(e(47680),e(67094),t([r]));r=(l.then?(await l)():l)[0];const h={device:"M3 6H21V4H3C1.9 4 1 4.9 1 6V18C1 19.1 1.9 20 3 20H7V18H3V6M13 12H9V13.78C8.39 14.33 8 15.11 8 16C8 16.89 8.39 17.67 9 18.22V20H13V18.22C13.61 17.67 14 16.88 14 16S13.61 14.33 13 13.78V12M11 17.5C10.17 17.5 9.5 16.83 9.5 16S10.17 14.5 11 14.5 12.5 15.17 12.5 16 11.83 17.5 11 17.5M22 8H16C15.5 8 15 8.5 15 9V19C15 19.5 15.5 20 16 20H22C22.5 20 23 19.5 23 19V9C23 8.5 22.5 8 22 8M21 18H17V10H21V18Z",and:"M4.4,16.5C4.4,15.6 4.7,14.7 5.2,13.9C5.7,13.1 6.7,12.2 8.2,11.2C7.3,10.1 6.8,9.3 6.5,8.7C6.1,8 6,7.4 6,6.7C6,5.2 6.4,4.1 7.3,3.2C8.2,2.3 9.4,2 10.9,2C12.2,2 13.3,2.4 14.2,3.2C15.1,4 15.5,5 15.5,6.1C15.5,6.9 15.3,7.6 14.9,8.3C14.5,9 13.8,9.7 12.8,10.4L11.4,11.5L15.7,16.7C16.3,15.5 16.6,14.3 16.6,12.8H18.8C18.8,15.1 18.3,17 17.2,18.5L20,21.8H17L15.7,20.3C15,20.9 14.3,21.3 13.4,21.6C12.5,21.9 11.6,22.1 10.7,22.1C8.8,22.1 7.3,21.6 6.1,20.6C5,19.5 4.4,18.2 4.4,16.5M10.7,20C12,20 13.2,19.5 14.3,18.5L9.6,12.8L9.2,13.1C7.7,14.2 7,15.3 7,16.5C7,17.6 7.3,18.4 8,19C8.7,19.6 9.5,20 10.7,20M8.5,6.7C8.5,7.6 9,8.6 10.1,9.9L11.7,8.8C12.3,8.4 12.7,8 12.9,7.6C13.1,7.2 13.2,6.7 13.2,6.2C13.2,5.6 13,5.1 12.5,4.7C12.1,4.3 11.5,4.1 10.8,4.1C10.1,4.1 9.5,4.3 9.1,4.8C8.7,5.3 8.5,5.9 8.5,6.7Z",or:"M2,4C5,10 5,14 2,20H8C13,20 19,16 22,12C19,8 13,4 8,4H2M5,6H8C11.5,6 16.3,9 19.3,12C16.3,15 11.5,18 8,18H5C6.4,13.9 6.4,10.1 5,6Z",not:"M14.08,4.61L15.92,5.4L14.8,8H19V10H13.95L12.23,14H19V16H11.38L9.92,19.4L8.08,18.61L9.2,16H5V14H10.06L11.77,10H5V8H12.63L14.08,4.61Z",state:"M6.27 17.05C6.72 17.58 7 18.25 7 19C7 20.66 5.66 22 4 22S1 20.66 1 19 2.34 16 4 16C4.18 16 4.36 16 4.53 16.05L7.6 10.69L5.86 9.7L9.95 8.58L11.07 12.67L9.33 11.68L6.27 17.05M20 16C18.7 16 17.6 16.84 17.18 18H11V16L8 19L11 22V20H17.18C17.6 21.16 18.7 22 20 22C21.66 22 23 20.66 23 19S21.66 16 20 16M12 8C12.18 8 12.36 8 12.53 7.95L15.6 13.31L13.86 14.3L17.95 15.42L19.07 11.33L17.33 12.32L14.27 6.95C14.72 6.42 15 5.75 15 5C15 3.34 13.66 2 12 2S9 3.34 9 5 10.34 8 12 8Z",numeric_state:"M4,17V9H2V7H6V17H4M22,15C22,16.11 21.1,17 20,17H16V15H20V13H18V11H20V9H16V7H20A2,2 0 0,1 22,9V10.5A1.5,1.5 0 0,1 20.5,12A1.5,1.5 0 0,1 22,13.5V15M14,15V17H8V13C8,11.89 8.9,11 10,11H12V9H8V7H12A2,2 0 0,1 14,9V11C14,12.11 13.1,13 12,13H10V15H14Z",sun:"M12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,2L14.39,5.42C13.65,5.15 12.84,5 12,5C11.16,5 10.35,5.15 9.61,5.42L12,2M3.34,7L7.5,6.65C6.9,7.16 6.36,7.78 5.94,8.5C5.5,9.24 5.25,10 5.11,10.79L3.34,7M3.36,17L5.12,13.23C5.26,14 5.53,14.78 5.95,15.5C6.37,16.24 6.91,16.86 7.5,17.37L3.36,17M20.65,7L18.88,10.79C18.74,10 18.47,9.23 18.05,8.5C17.63,7.78 17.1,7.15 16.5,6.64L20.65,7M20.64,17L16.5,17.36C17.09,16.85 17.62,16.22 18.04,15.5C18.46,14.77 18.73,14 18.87,13.21L20.64,17M12,22L9.59,18.56C10.33,18.83 11.14,19 12,19C12.82,19 13.63,18.83 14.37,18.56L12,22Z",template:"M8,3A2,2 0 0,0 6,5V9A2,2 0 0,1 4,11H3V13H4A2,2 0 0,1 6,15V19A2,2 0 0,0 8,21H10V19H8V14A2,2 0 0,0 6,12A2,2 0 0,0 8,10V5H10V3M16,3A2,2 0 0,1 18,5V9A2,2 0 0,0 20,11H21V13H20A2,2 0 0,0 18,15V19A2,2 0 0,1 16,21H14V19H16V14A2,2 0 0,1 18,12A2,2 0 0,1 16,10V5H14V3H16Z",time:"M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z",trigger:"M10 7V9H9V15H10V17H6V15H7V9H6V7H10M16 7C17.11 7 18 7.9 18 9V15C18 16.11 17.11 17 16 17H12V7M16 9H14V15H16V9Z",zone:"M12,2C15.31,2 18,4.66 18,7.95C18,12.41 12,19 12,19C12,19 6,12.41 6,7.95C6,4.66 8.69,2 12,2M12,6A2,2 0 0,0 10,8A2,2 0 0,0 12,10A2,2 0 0,0 14,8A2,2 0 0,0 12,6M20,19C20,21.21 16.42,23 12,23C7.58,23 4,21.21 4,19C4,17.71 5.22,16.56 7.11,15.83L7.75,16.74C6.67,17.19 6,17.81 6,18.5C6,19.88 8.69,21 12,21C15.31,21 18,19.88 18,18.5C18,17.81 17.33,17.19 16.25,16.74L16.89,15.83C18.78,16.56 20,17.71 20,19Z"};class p extends s.WF{render(){if(this.icon)return s.qy`<ha-icon .icon="${this.icon}"></ha-icon>`;if(!this.condition)return s.s6;if(!this.hass)return this._renderFallback();const t=(0,r.r)(this.hass.connection,this.hass.config,this.condition).then(t=>t?s.qy`<ha-icon .icon="${t}"></ha-icon>`:this._renderFallback());return s.qy`${(0,d.T)(t)}`}_renderFallback(){const t=(0,c.m)(this.condition);return s.qy` <ha-svg-icon .path="${h[this.condition]||r.l[t]}"></ha-svg-icon> `}}(0,n.Cg)([(0,a.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,n.Cg)([(0,a.MZ)()],p.prototype,"condition",void 0),(0,n.Cg)([(0,a.MZ)()],p.prototype,"icon",void 0),p=(0,n.Cg)([(0,a.EM)("ha-condition-icon")],p),o()}catch(t){o(t)}})},49313(t,i,e){e.a(t,async function(t,i){try{var o=e(62826),n=e(5124),s=e(22441),a=e(6412),d=e(22786),c=e(69558),r=e(1087),l=e(10763),h=e(88249),p=e(87225),u=e(15702),g=e(57116),m=(e(35913),t([l,u]));[l,u]=m.then?(await m)():m;class b extends n.WF{render(){const t=this._processedCondition(this.condition),i=this.yamlMode||!this.uiSupported;return n.qy` <div class="${(0,a.H)({"card-content":!0,disabled:!this.indent&&(this.disabled||!1===this.condition.enabled&&!this.yamlMode),yaml:i,indent:this.indent,card:!this.inSidebar})}"> ${i?n.qy` ${this.uiSupported?n.s6:n.qy` <ha-automation-editor-warning .alertTitle="${this.hass.localize("ui.panel.config.automation.editor.conditions.unsupported_condition",{condition:t.condition})}" .localize="${this.hass.localize}"></ha-automation-editor-warning> `} <ha-yaml-editor .defaultValue="${this.condition}" @value-changed="${this._onYamlChange}" .readOnly="${this.disabled}"></ha-yaml-editor> `:n.qy` <div @value-changed="${this._onUiChanged}"> ${this.description?n.qy`<ha-automation-condition-platform .hass="${this.hass}" .condition="${this.condition}" .description="${this.description}" .disabled="${this.disabled}"></ha-automation-condition-platform>`:(0,c._)(`ha-automation-condition-${t.condition}`,{hass:this.hass,condition:t,disabled:this.disabled,optionsInSidebar:this.indent,narrow:this.narrow})} </div> `} </div> `}_onYamlChange(t){t.stopPropagation(),t.detail.isValid&&(0,r.r)(this,this.inSidebar?"yaml-changed":"value-changed",{value:t.detail.value})}_onUiChanged(t){t.stopPropagation();const i={...this.condition.alias?{alias:this.condition.alias}:{},...this.condition.note?{note:this.condition.note}:{},...t.detail.value};(0,r.r)(this,"value-changed",{value:i})}expandAll(){this._collapsibleElement?.expandAll?.()}collapseAll(){this._collapsibleElement?.collapseAll?.()}constructor(...t){super(...t),this.disabled=!1,this.yamlMode=!1,this.indent=!1,this.narrow=!1,this.inSidebar=!1,this.selected=!1,this.uiSupported=!1,this._processedCondition=(0,d.A)(t=>(0,h.XF)(t))}}b.styles=[g.yj,g.aM,n.AH`:host([action]) .card-content{padding:0}:host([action]) .card-content.indent{margin-left:0;margin-right:0;padding:0;border-left:none;border-bottom:none}`],(0,o.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"condition",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],b.prototype,"disabled",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"yamlMode",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],b.prototype,"indent",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],b.prototype,"narrow",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean,attribute:"sidebar"})],b.prototype,"inSidebar",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],b.prototype,"selected",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean,attribute:"supported"})],b.prototype,"uiSupported",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"description",void 0),(0,o.Cg)([(0,s.P)("ha-yaml-editor")],b.prototype,"yamlEditor",void 0),(0,o.Cg)([(0,s.P)(p.fg.join(", "))],b.prototype,"_collapsibleElement",void 0),b=(0,o.Cg)([(0,s.EM)("ha-automation-condition-editor")],b),i()}catch(t){i(t)}})},53354(t,i,e){e.a(t,async function(t,i){try{e(74423),e(18111),e(13579);var o=e(62826),n=(e(68825),e(35211)),s=e(34271),a=e(53289),d=e(5124),c=e(22441),r=e(6412),l=e(22786),h=e(44537),p=e(93905),u=e(1087),g=e(99124),m=e(57237),b=e(52943),_=e(53516),v=e(78978),y=e(63130),C=e(56214),f=e(20543),$=e(7822),w=e(38962),M=(e(76776),e(76623)),A=e(29823),k=(e(70947),e(11382),e(26300)),V=e(34127),H=e(88249),L=e(79800),x=e(87225),z=e(12596),S=e(22792),Z=e(65063),q=e(41570),I=e(49053),E=e(15702),T=e(57116),D=e(62711),B=e(49313),F=e(80081),O=e(30356),R=e(4601),P=e(97681),U=e(4519),N=e(93977),W=e(40998),j=e(60092),Y=e(1103),K=e(52128),Q=e(56860),G=t([C,f,$,w,M,A,k,V,E,D,B,F,O,R,P,U,N,W,j,Y,K,Q,L]);[C,f,$,w,M,A,k,V,E,D,B,F,O,R,P,U,N,W,j,Y,K,Q,L]=G.then?(await G)():G;const X="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",J="M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z",tt="M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z",it="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",et="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",ot="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z",nt="M19,3L13,9L15,11L22,4V3M12,12.5A0.5,0.5 0 0,1 11.5,12A0.5,0.5 0 0,1 12,11.5A0.5,0.5 0 0,1 12.5,12A0.5,0.5 0 0,1 12,12.5M6,20A2,2 0 0,1 4,18C4,16.89 4.9,16 6,16A2,2 0 0,1 8,18C8,19.11 7.1,20 6,20M6,8A2,2 0 0,1 4,6C4,4.89 4.9,4 6,4A2,2 0 0,1 8,6C8,7.11 7.1,8 6,8M9.64,7.64C9.87,7.14 10,6.59 10,6A4,4 0 0,0 6,2A4,4 0 0,0 2,6A4,4 0 0,0 6,10C6.59,10 7.14,9.87 7.64,9.64L10,12L7.64,14.36C7.14,14.13 6.59,14 6,14A4,4 0 0,0 2,18A4,4 0 0,0 6,22A4,4 0 0,0 10,18C10,17.41 9.87,16.86 9.64,16.36L12,14L19,21H22V20L9.64,7.64Z",st="M19,20H5V4H7V7H17V4H19M12,2A1,1 0 0,1 13,3A1,1 0 0,1 12,4A1,1 0 0,1 11,3A1,1 0 0,1 12,2M19,2H14.82C14.4,0.84 13.3,0 12,0C10.7,0 9.6,0.84 9.18,2H5A2,2 0 0,0 3,4V20A2,2 0 0,0 5,22H19A2,2 0 0,0 21,20V4A2,2 0 0,0 19,2Z",at="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",dt="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",ct="M6,22A3,3 0 0,1 3,19C3,18.4 3.18,17.84 3.5,17.37L9,7.81V6A1,1 0 0,1 8,5V4A2,2 0 0,1 10,2H14A2,2 0 0,1 16,4V5A1,1 0 0,1 15,6V7.81L20.5,17.37C20.82,17.84 21,18.4 21,19A3,3 0 0,1 18,22H6M5,19A1,1 0 0,0 6,20H18A1,1 0 0,0 19,19C19,18.79 18.93,18.59 18.82,18.43L16.53,14.47L14,17L8.93,11.93L5.18,18.43C5.07,18.59 5,18.79 5,19M13,10A1,1 0 0,0 12,11A1,1 0 0,0 13,12A1,1 0 0,0 14,11A1,1 0 0,0 13,10Z",rt="M12,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,2M10,16.5L16,12L10,7.5V16.5Z",lt="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",ht="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",pt="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",ut="M12,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,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4M9,9V15H15V9";class gt extends d.WF{get selected(){return this._selected}_renderOverflowLabel(t,i){return d.qy` <div class="overflow-label"> ${t} ${this.optionsInSidebar&&!this.narrow?i||d.qy`<span class="shortcut-placeholder ${q.c?"mac":""}"></span>`:d.s6} </div> `}_renderRow(){const t="target"in(this.conditionDescriptions[this.condition.condition]||{}),i=t?this.condition.target:"device_id"in this.condition&&this.condition.device_id?{device_id:[this.condition.device_id]}:void 0,e=this.conditionDescriptions[this.condition.condition]?.target,o=(0,_.C)(this.condition.note?.trim()||"",250);return d.qy` ${this.optionsInSidebar&&"trigger"!==this.condition.condition?d.qy`<ha-automation-condition-live-test id="condition-icon" slot="leading-icon" .hass="${this.hass}" .condition="${this.condition}"> <ha-condition-icon .hass="${this.hass}" .condition="${this.condition.condition}"></ha-condition-icon> </ha-automation-condition-live-test>`:d.qy`<div id="condition-icon" class="icon-badge-wrapper" slot="leading-icon"> <ha-condition-icon .hass="${this.hass}" .condition="${this.condition.condition}"></ha-condition-icon> </div>`} <h3 slot="header"> ${(0,b.Z)((0,L.p)(this.condition,this.hass,this._entityReg))} ${void 0!==i||t&&!this._isNew?this._renderTargets(i,t&&!this._isNew,e,"device"!==this.condition.condition):d.s6} ${this.condition.note?.trim()?d.qy` <ha-svg-icon id="note-icon" tabindex="0" .path="${et}" .label="${this.hass.localize("ui.panel.config.automation.editor.note.label")}" class="note-indicator"></ha-svg-icon> <ha-tooltip for="note-icon"><p>${o}</p></ha-tooltip> `:d.s6} </h3> <ha-automation-row-event-chip .show="${this._testing}" .variant="${this._testingResult?"success":"warning"}" slot="event" class="event-chip" aria-live="polite"> ${this.hass.localize("ui.panel.config.automation.editor.conditions.testing_"+(this._testingResult?"pass":"error"))} </ha-automation-row-event-chip> <slot name="icons" slot="icons"></slot> <ha-dropdown slot="icons" @click="${g.C}" @keydown="${m.d}" @wa-select="${this._handleDropdownSelect}" placement="bottom-end"> <ha-icon-button slot="trigger" .label="${this.hass.localize("ui.common.menu")}" .path="${dt}"> </ha-icon-button> <ha-dropdown-item value="test"> <ha-svg-icon slot="icon" .path="${ct}"></ha-svg-icon> ${this._renderOverflowLabel(this.hass.localize("ui.panel.config.automation.editor.conditions.test"))} </ha-dropdown-item> <ha-dropdown-item value="rename" .disabled="${this.disabled}"> <ha-svg-icon slot="icon" .path="${pt}"></ha-svg-icon> ${this._renderOverflowLabel(this.hass.localize("ui.panel.config.automation.editor.conditions.rename"))} </ha-dropdown-item> <ha-dropdown-item value="edit_note"> <ha-svg-icon slot="icon" .path="${it}"></ha-svg-icon> ${this._renderOverflowLabel(this.hass.localize("ui.panel.config.automation.editor.note."+(this.condition.note?"edit":"add")))} </ha-dropdown-item> <wa-divider></wa-divider> <ha-dropdown-item value="duplicate" .disabled="${this.disabled}"> <ha-svg-icon slot="icon" .path="${ht}"></ha-svg-icon> ${this._renderOverflowLabel(this.hass.localize("ui.panel.config.automation.editor.actions.duplicate"))} </ha-dropdown-item> <ha-dropdown-item value="copy" .disabled="${this.disabled}"> <ha-svg-icon slot="icon" .path="${ot}"></ha-svg-icon>${this._renderOverflowLabel(this.hass.localize("ui.panel.config.automation.editor.triggers.copy"),d.qy`<span class="shortcut"> <span>${q.c?d.qy`<ha-svg-icon .path="${X}"></ha-svg-icon>`:this.hass.localize("ui.panel.config.automation.editor.ctrl")}</span> <span>+</span> <span>C</span> </span>`)} </ha-dropdown-item> <ha-dropdown-item value="cut" .disabled="${this.disabled}"> <ha-svg-icon slot="icon" .path="${nt}"></ha-svg-icon>${this._renderOverflowLabel(this.hass.localize("ui.panel.config.automation.editor.triggers.cut"),d.qy`<span class="shortcut"> <span>${q.c?d.qy`<ha-svg-icon .path="${X}"></ha-svg-icon>`:this.hass.localize("ui.panel.config.automation.editor.ctrl")}</span> <span>+</span> <span>X</span> </span>`)} </ha-dropdown-item> ${this._pasteAvailable()?d.qy` <ha-dropdown-item value="paste"> <ha-svg-icon slot="icon" .path="${st}"></ha-svg-icon> ${this._renderOverflowLabel(this.hass.localize("ui.panel.config.automation.editor.actions.paste"),d.qy`<span class="shortcut"> <span>${q.c?d.qy`<ha-svg-icon .path="${X}"></ha-svg-icon>`:this.hass.localize("ui.panel.config.automation.editor.ctrl")}</span> <span>+</span> <span>V</span> </span>`)} </ha-dropdown-item> `:d.s6} ${this.optionsInSidebar?d.s6:d.qy` <ha-dropdown-item value="move_up" .disabled="${this.disabled||!!this.first}"> ${this.hass.localize("ui.panel.config.automation.editor.move_up")} <ha-svg-icon slot="icon" .path="${tt}"></ha-svg-icon></ha-dropdown-item> <ha-dropdown-item value="move_down" .disabled="${this.disabled||!!this.last}"> ${this.hass.localize("ui.panel.config.automation.editor.move_down")} <ha-svg-icon slot="icon" .path="${J}"></ha-svg-icon></ha-dropdown-item> `} <ha-dropdown-item value="toggle_yaml_mode"> <ha-svg-icon slot="icon" .path="${lt}"></ha-svg-icon> ${this._renderOverflowLabel(this.hass.localize("ui.panel.config.automation.editor.edit_"+(this._yamlMode?"ui":"yaml")))} </ha-dropdown-item> <wa-divider></wa-divider> <ha-dropdown-item value="disable" .disabled="${this.disabled}"> <ha-svg-icon slot="icon" .path="${!1===this.condition.enabled?rt:ut}"></ha-svg-icon> ${this._renderOverflowLabel(this.hass.localize("ui.panel.config.automation.editor.actions."+(!1===this.condition.enabled?"enable":"disable")))} </ha-dropdown-item> <ha-dropdown-item variant="danger" value="delete" .disabled="${this.disabled}"> <ha-svg-icon class="warning" slot="icon" .path="${at}"></ha-svg-icon> ${this._renderOverflowLabel(this.hass.localize("ui.panel.config.automation.editor.actions.delete"),d.qy`<span class="shortcut"> <span>${q.c?d.qy`<ha-svg-icon .path="${X}"></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>`)} </ha-dropdown-item> </ha-dropdown> ${this.optionsInSidebar?d.s6:d.qy`${this._warnings?d.qy`<ha-automation-editor-warning .localize="${this.hass.localize}" .warnings="${this._warnings}"> </ha-automation-editor-warning>`:d.s6} <ha-automation-condition-editor .hass="${this.hass}" .condition="${this.condition}" .description="${this.conditionDescriptions[this.condition.condition]}" .disabled="${this.disabled}" .yamlMode="${this._yamlMode}" .uiSupported="${this._uiSupported(this._getType(this.condition,this.conditionDescriptions))}" .narrow="${this.narrow}" @ui-mode-not-available="${this._handleUiModeNotAvailable}"></ha-automation-condition-editor>`} `}render(){return this.condition?d.qy` <ha-card outlined class="${(0,r.H)({selected:this._selected,"building-block":this.optionsInSidebar&&x.I8.includes(this.condition.condition)&&!this._collapsed})}"> ${!1===this.condition.enabled?d.qy` <div class="disabled-bar"> ${this.hass.localize("ui.panel.config.automation.editor.actions.disabled")} </div> `:d.s6} ${this.optionsInSidebar?d.qy`<ha-automation-row .disabled="${!1===this.condition.enabled}" .leftChevron="${x.I8.includes(this.condition.condition)}" .collapsed="${this._collapsed}" .selected="${this._selected}" .highlight="${this.highlight}" .buildingBlock="${x.I8.includes(this.condition.condition)}" .sortSelected="${this.sortSelected}" .dim="${this._testing}" @click="${this._toggleSidebar}" @toggle-collapsed="${this._toggleCollapse}">${this._renderRow()} </ha-automation-row>`:d.qy` <ha-expansion-panel left-chevron @expanded-changed="${this._expansionPanelChanged}"> ${this._renderRow()} </ha-expansion-panel> `} </ha-card> ${this.optionsInSidebar&&x.I8.includes(this.condition.condition)?d.qy`<ha-automation-condition-editor class="${this._collapsed?"hidden":""}" .hass="${this.hass}" .condition="${this.condition}" .disabled="${this.disabled}" .uiSupported="${this._uiSupported(this._getType(this.condition,this.conditionDescriptions))}" indent .selected="${this._selected}" .narrow="${this.narrow}" @value-changed="${this._onValueChange}"></ha-automation-condition-editor>`:d.s6} `:d.s6}firstUpdated(t){super.firstUpdated(t),this.root&&(this._collapsed=!1)}willUpdate(t){t.has("yamlMode")&&(this._warnings=void 0)}disconnectedCallback(){super.disconnectedCallback(),void 0!==this._testingTimeout&&clearTimeout(this._testingTimeout)}_onValueChange(t){this._selected&&this.optionsInSidebar&&this.openSidebar(t.detail.value)}_setClipboard(){this._clipboard={...this._clipboard,condition:(0,s.A)(this.condition)},(0,y.l)((0,a.dump)(this.condition))}_switchUiMode(){this._yamlMode=!1}_switchYamlMode(){this._yamlMode=!0}expand(){this.optionsInSidebar?this._collapsed=!1:this.updateComplete.then(()=>{this.shadowRoot.querySelector("ha-expansion-panel").expanded=!0})}collapse(){this._collapsed=!0}expandAll(){this.expand(),this.conditionEditor?.expandAll()}collapseAll(){this.collapse(),this.conditionEditor?.collapseAll()}_handleUiModeNotAvailable(t){this._warnings=(0,v._)(this.hass,t.detail).warnings,this._yamlMode||(this._yamlMode=!0)}_toggleSidebar(t){t?.stopPropagation(),this._selected?(0,u.r)(this,"request-close-sidebar"):this.openSidebar()}markAsNew(){this._isNew=!0}_expansionPanelChanged(t){t.detail.expanded||(this._isNew=!1)}openSidebar(t){const i=t||this.condition;(0,u.r)(this,"open-sidebar",{save:t=>{(0,u.r)(this,"value-changed",{value:t})},close:t=>{this._selected=!1,this._isNew=!1,(0,u.r)(this,"close-sidebar"),t&&this.focus()},rename:()=>{this._renameCondition()},editNote:this._editNoteCondition,toggleYamlMode:()=>{this._toggleYamlMode(),this.openSidebar()},disable:this._onDisable,delete:this._onDelete,duplicate:this._duplicateCondition,insertAfter:this._insertAfter,copy:this._copyCondition,cut:this._cutCondition,paste:this._pasteCondition,pasteAvailable:this._pasteAvailable,test:this._testCondition,config:i,uiSupported:this._uiSupported(this._getType(i,this.conditionDescriptions)),description:this.conditionDescriptions[i.condition],yamlMode:this._yamlMode}),this._selected=!0,this._collapsed=!1,this.narrow&&window.setTimeout(()=>{this.scrollIntoView({block:"start",behavior:"smooth"})},180)}_toggleCollapse(){this._collapsed=!this._collapsed}focus(){this._automationRowElement?.focus()}_handleDropdownSelect(t){t.stopPropagation();const i=t.detail?.item?.value;if(i)switch(i){case"test":this._testCondition();break;case"rename":this._renameCondition();break;case"edit_note":this._editNoteCondition();break;case"duplicate":this._duplicateCondition();break;case"copy":this._copyCondition();break;case"cut":this._cutCondition();break;case"paste":this._pasteCondition();break;case"move_up":this._moveUp();break;case"move_down":this._moveDown();break;case"toggle_yaml_mode":this._toggleYamlMode(t.target);break;case"disable":this._onDisable();break;case"delete":this._onDelete()}}static get styles(){return[T.bH,T.Lt]}constructor(...t){super(...t),this.disabled=!1,this.root=!1,this.narrow=!1,this.sortSelected=!1,this._collapsed=!0,this._isNew=!1,this.conditionDescriptions={},this.optionsInSidebar=!1,this._yamlMode=!1,this._testing=!1,this._selected=!1,this._entityReg=[],this._renderTargets=(0,l.A)((t,i=!1,e,o=!1)=>d.qy`<ha-automation-row-targets .target="${t}" .targetRequired="${i}" .selector="${e?{target:e}:void 0}" .interactive="${o}"></ha-automation-row-targets>`),this._onDisable=()=>{const t=!(this.condition.enabled??1),i={...this.condition,enabled:t};(0,u.r)(this,"value-changed",{value:i}),this._selected&&this.optionsInSidebar&&this.openSidebar(i),this._yamlMode&&!this.optionsInSidebar&&this.conditionEditor?.yamlEditor?.setValue(i)},this._onDelete=()=>{(0,u.r)(this,"value-changed",{value:null}),this._selected&&(0,u.r)(this,"close-sidebar"),(0,I.c)(this,{message:this.hass.localize("ui.common.successfully_deleted"),duration:4e3,action:{text:this.hass.localize("ui.common.undo"),action:()=>{(0,u.r)(window,"undo-change")}}})},this._testCondition=async()=>{if(this._testing&&void 0===this._testingTimeout)return;void 0!==this._testingTimeout&&clearTimeout(this._testingTimeout);const t=this.condition;let i,e;requestAnimationFrame(()=>{this.scrollIntoViewIfNeeded?this.scrollIntoViewIfNeeded():this.scrollIntoView()});try{i=await(0,z.$)(this.hass,{conditions:t})}catch(t){return(0,Z.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.automation.editor.conditions.validation_failed")}),void console.error("Error validating condition",t)}if(this.condition===t)if(i.conditions.valid){try{e=await(0,H.S9)(this.hass,t)}catch(i){if(this.condition!==t)return;return void(0,Z.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.automation.editor.conditions.test_failed"),text:i.message})}this._testingResult=e.result,this._testing=!0,this._testingTimeout=window.setTimeout(()=>{this._testing=!1},2500)}else(0,Z.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.automation.editor.conditions.invalid_condition"),text:i.conditions.error})},this._renameCondition=async()=>{const t=await(0,Z.an)(this,{title:this.hass.localize("ui.panel.config.automation.editor.conditions.change_alias"),inputLabel:this.hass.localize("ui.panel.config.automation.editor.conditions.alias"),inputType:"string",placeholder:(0,b.Z)((0,L.p)(this.condition,this.hass,this._entityReg,!0)),defaultValue:this.condition.alias,confirmText:this.hass.localize("ui.common.submit")});if(null!==t){const i={...this.condition};""===t?delete i.alias:i.alias=t,(0,u.r)(this,"value-changed",{value:i}),this._selected&&this.optionsInSidebar?this.openSidebar(i):this._yamlMode&&this.conditionEditor?.yamlEditor?.setValue(i)}},this._editNoteCondition=async()=>{const t=await(0,Z.an)(this,{title:this.hass.localize("ui.panel.config.automation.editor.note."+(this.condition.note?"edit":"add")),inputLabel:this.hass.localize("ui.panel.config.automation.editor.note.label"),inputType:"string",defaultValue:this.condition.note,confirmText:this.hass.localize("ui.common.submit"),multiline:!0});if(null!==t){const i={...this.condition};""===t?delete i.note:i.note=t,(0,u.r)(this,"value-changed",{value:i}),this._selected&&this.optionsInSidebar?this.openSidebar(i):this._yamlMode&&this.conditionEditor?.yamlEditor?.setValue(i)}},this._duplicateCondition=()=>{(0,u.r)(this,"duplicate")},this._insertAfter=t=>!(0,h.e)(t).some(t=>!(0,H.G3)(t))&&((0,u.r)(this,"insert-after",{value:t}),!0),this._copyCondition=()=>{this._setClipboard(),this._selected&&this.optionsInSidebar&&this.openSidebar(),(0,I.c)(this,{message:this.hass.localize("ui.panel.config.automation.editor.conditions.copied_to_clipboard"),duration:2e3})},this._cutCondition=()=>{this._setClipboard(),(0,u.r)(this,"value-changed",{value:null}),this._selected&&(0,u.r)(this,"close-sidebar"),(0,I.c)(this,{message:this.hass.localize("ui.panel.config.automation.editor.conditions.cut_to_clipboard"),duration:2e3})},this._pasteCondition=()=>{const t=this._clipboard?.condition;t&&(0,u.r)(this,"paste",{item:t})},this._pasteAvailable=()=>!!this._clipboard?.condition,this._moveUp=()=>{(0,u.r)(this,"move-up")},this._moveDown=()=>{(0,u.r)(this,"move-down")},this._toggleYamlMode=t=>{this._yamlMode?this._switchUiMode():this._switchYamlMode(),this.optionsInSidebar?t&&this.openSidebar():this.expand()},this._getType=(0,l.A)((t,i)=>t.condition in i?"platform":t.condition),this._uiSupported=(0,l.A)(t=>void 0!==customElements.get(`ha-automation-condition-${t}`))}}(0,o.Cg)([(0,c.MZ)({attribute:!1})],gt.prototype,"hass",void 0),(0,o.Cg)([(0,c.MZ)({attribute:!1})],gt.prototype,"condition",void 0),(0,o.Cg)([(0,c.MZ)({type:Boolean})],gt.prototype,"disabled",void 0),(0,o.Cg)([(0,c.MZ)({type:Boolean})],gt.prototype,"root",void 0),(0,o.Cg)([(0,c.MZ)({type:Boolean})],gt.prototype,"first",void 0),(0,o.Cg)([(0,c.MZ)({type:Boolean})],gt.prototype,"last",void 0),(0,o.Cg)([(0,c.MZ)({type:Boolean})],gt.prototype,"narrow",void 0),(0,o.Cg)([(0,c.MZ)({type:Boolean})],gt.prototype,"highlight",void 0),(0,o.Cg)([(0,c.MZ)({type:Boolean,attribute:"sort-selected"})],gt.prototype,"sortSelected",void 0),(0,o.Cg)([(0,c.wk)()],gt.prototype,"_collapsed",void 0),(0,o.Cg)([(0,c.wk)()],gt.prototype,"_isNew",void 0),(0,o.Cg)([(0,c.wk)()],gt.prototype,"_warnings",void 0),(0,o.Cg)([(0,c.MZ)({attribute:!1})],gt.prototype,"conditionDescriptions",void 0),(0,o.Cg)([(0,c.MZ)({type:Boolean,attribute:"sidebar"})],gt.prototype,"optionsInSidebar",void 0),(0,o.Cg)([(0,p.I)({key:"automationClipboard",state:!1,subscribe:!0,storage:"sessionStorage"})],gt.prototype,"_clipboard",void 0),(0,o.Cg)([(0,c.wk)()],gt.prototype,"_yamlMode",void 0),(0,o.Cg)([(0,c.wk)()],gt.prototype,"_testing",void 0),(0,o.Cg)([(0,c.wk)()],gt.prototype,"_testingResult",void 0),(0,o.Cg)([(0,c.wk)()],gt.prototype,"_selected",void 0),(0,o.Cg)([(0,c.wk)(),(0,n.Fg)({context:S.ih,subscribe:!0})],gt.prototype,"_entityReg",void 0),(0,o.Cg)([(0,c.P)("ha-automation-condition-editor")],gt.prototype,"conditionEditor",void 0),(0,o.Cg)([(0,c.P)("ha-automation-row")],gt.prototype,"_automationRowElement",void 0),gt=(0,o.Cg)([(0,c.EM)("ha-automation-condition-row")],gt),i()}catch(t){i(t)}})},40219(t,i,e){e.a(t,async function(t,i){try{e(74423),e(18111),e(22489),e(7588);var o=e(62826),n=e(34271),s=e(5124),a=e(22441),d=e(75751),c=e(1087),r=e(57237),l=e(18350),h=(e(85938),e(67094),e(88249)),p=e(87225),u=e(93758),g=e(54706),m=(e(49053),e(82405)),b=e(41175),_=e(57116),v=e(53354),y=t([l,v]);[l,v]=y.then?(await y)():y;const C="M21 11H3V9H21V11M21 13H3V15H21V13Z",f="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z";class $ extends((0,b.j)((0,g.E)(s.WF))){get items(){return this.conditions}set items(t){this.conditions=t}setHighlightedItems(t){this.highlightedConditions=t}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribe()}hassSubscribe(){return[(0,u.CO)(this.hass.connection,"automation","new_triggers_conditions",t=>{this._newTriggersAndConditions=t.enabled})]}_subscribeDescriptions(){this._unsubscribe(),this._conditionDescriptions={},this._unsub=(0,p.bn)(this.hass,t=>{this._conditionDescriptions={...this._conditionDescriptions,...t}})}_unsubscribe(){this._unsub&&(this._unsub.then(t=>t()),this._unsub=void 0)}willUpdate(t){super.willUpdate(t),t.has("_newTriggersAndConditions")&&this._subscribeDescriptions()}firstUpdated(t){super.firstUpdated(t),this.hass.loadBackendTranslation("conditions")}updated(t){if(!this.hass)return;const i=(0,m.II)(this.hass.states,this.hass.devices,this.hass.areas,"condition");if(t.has("conditions")&&i&&(this._openedAddDialogFromQuery=!1),!this._openedAddDialogFromQuery&&this.root&&!this.disabled&&0===this.conditions.length&&i?(this._openedAddDialogFromQuery=!0,queueMicrotask(()=>this._addConditionDialog())):this._openedAddDialogFromQuery&&!i&&(this._openedAddDialogFromQuery=!1),!t.has("conditions"))return;let e;if(Array.isArray(this.conditions)||(e=[this.conditions]),(e||this.conditions).forEach((t,i)=>{"string"==typeof t&&(e=e||[...this.conditions],e[i]={condition:"template",value_template:t})}),e)(0,c.r)(this,"value-changed",{value:e});else if(this.focusLastItemOnChange||void 0!==this.focusItemIndexOnChange){const t=this.focusLastItemOnChange?"new":"moved",i=this.shadowRoot.querySelector("ha-automation-condition-row:"+("new"===t?"last-of-type":`nth-of-type(${this.focusItemIndexOnChange+1})`));this.focusLastItemOnChange=!1,this.focusItemIndexOnChange=void 0,i.updateComplete.then(()=>{!this.optionsInSidebar||p.I8.includes(i.condition.condition)&&"moved"!==t||(i.openSidebar(),this.narrow&&i.scrollIntoView({block:"start",behavior:"smooth"})),"new"===t&&(i.expand(),i.markAsNew()),this.optionsInSidebar||i.focus()})}}expandAll(){this._conditionRowElements?.forEach(t=>{t.expandAll()})}collapseAll(){this._conditionRowElements?.forEach(t=>{t.collapseAll()})}render(){return Array.isArray(this.conditions)?s.qy` <ha-sortable handle-selector=".handle" draggable-selector="ha-automation-condition-row" .disabled="${this.disabled}" group="conditions" invert-swap @item-moved="${this.itemMoved}" @item-added="${this.itemAdded}" @item-removed="${this.itemRemoved}"> <div class="rows ${this.optionsInSidebar?"":"no-sidebar"}"> ${(0,d.u)(this.conditions.filter(t=>"object"==typeof t),t=>this.getKey(t),(t,i)=>s.qy` <ha-automation-condition-row .root="${this.root}" .sortableData="${t}" .index="${i}" .first="${0===i}" .last="${i===this.conditions.length-1}" .totalConditions="${this.conditions.length}" .condition="${t}" .conditionDescriptions="${this._conditionDescriptions}" .disabled="${this.disabled}" .narrow="${this.narrow}" @duplicate="${this.duplicateItem}" @paste="${this.pasteItem}" @insert-after="${this.insertAfter}" @move-down="${this.moveDown}" @move-up="${this.moveUp}" @value-changed="${this.itemChanged}" .hass="${this.hass}" .highlight="${this.highlightedConditions?.includes(t)}" .optionsInSidebar="${this.optionsInSidebar}" .sortSelected="${this.rowSortSelected===i}" @stop-sort-selection="${this.stopSortSelection}"> ${this.disabled?s.s6:s.qy` <div tabindex="0" class="handle ${this.rowSortSelected===i?"active":""}" slot="icons" @keydown="${this.handleDragKeydown}" @click="${r.d}" .index="${i}"> <ha-svg-icon .path="${C}"></ha-svg-icon> </div> `} </ha-automation-condition-row> `)} <div class="buttons"> <ha-button .disabled="${this.disabled}" @click="${this._addConditionDialog}" .appearance="${this.root?"accent":"filled"}" .size="${this.root?"medium":"small"}"> <ha-svg-icon .path="${f}" slot="start"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.editor.conditions.add")} </ha-button> </div> </div> </ha-sortable> `:s.s6}_addConditionDialog(){this.narrow&&(0,c.r)(this,"request-close-sidebar"),(0,m.gZ)(this,{type:"condition",add:this._addCondition,clipboardItem:this._clipboard?.condition?.condition,clipboardPasteToastBottomOffset:this.editorDirty?60:void 0})}constructor(...t){super(...t),this.root=!1,this.editorDirty=!1,this._conditionDescriptions={},this._newTriggersAndConditions=!1,this._openedAddDialogFromQuery=!1,this._addCondition=(t,i)=>{let e;if(t===m.uV)e=this.conditions.concat((0,n.A)(this._clipboard.condition));else if((0,h.Q)(t))e=this.conditions.concat({condition:(0,h.Dt)(t),target:i});else{const o=t,n=customElements.get(`ha-automation-condition-${o}`);e=this.conditions.concat({...n.defaultConfig,...i?.entity_id?{entity_id:i.entity_id}:{}})}this.focusLastItemOnChange=!0,(0,c.r)(this,"value-changed",{value:e})}}}$.styles=_.Ju,(0,o.Cg)([(0,a.MZ)({attribute:!1})],$.prototype,"conditions",void 0),(0,o.Cg)([(0,a.MZ)({attribute:!1})],$.prototype,"highlightedConditions",void 0),(0,o.Cg)([(0,a.MZ)({type:Boolean})],$.prototype,"root",void 0),(0,o.Cg)([(0,a.MZ)({type:Boolean,attribute:!1})],$.prototype,"editorDirty",void 0),(0,o.Cg)([(0,a.wk)()],$.prototype,"_conditionDescriptions",void 0),(0,o.Cg)([(0,a.YG)("ha-automation-condition-row")],$.prototype,"_conditionRowElements",void 0),(0,o.Cg)([(0,a.wk)()],$.prototype,"_newTriggersAndConditions",void 0),$=(0,o.Cg)([(0,a.EM)("ha-automation-condition")],$),i()}catch(t){i(t)}})},80081(t,i,e){e.a(t,async function(t,i){try{var o=e(62826),n=e(22441),s=e(56847),a=t([s]);s=(a.then?(await a)():a)[0];class d extends s.m{static get defaultConfig(){return{condition:"and",conditions:[]}}}d=(0,o.Cg)([(0,n.EM)("ha-automation-condition-and")],d),i()}catch(t){i(t)}})},30356(t,i,e){e.a(t,async function(t,i){try{e(18111),e(7588);var o=e(62826),n=e(35211),s=e(5124),a=e(22441),d=e(22786),c=e(1087),r=e(87682),l=e(1798),h=e(52763),p=e(22792),u=e(10139),g=t([r,l,h]);[r,l,h]=g.then?(await g)():g;class m extends s.WF{static get defaultConfig(){return{condition:"device",device_id:"",domain:"",entity_id:""}}shouldUpdate(t){return!t.has("condition")||(!this.condition.device_id||this.condition.device_id in this.hass.devices||((0,c.r)(this,"ui-mode-not-available",Error(this.hass.localize("ui.panel.config.automation.editor.edit_unknown_device"))),!1))}render(){const t=this._deviceId||this.condition.device_id;return s.qy` <ha-device-picker .value="${t}" @value-changed="${this._devicePicked}" .hass="${this.hass}" .disabled="${this.disabled}" .label="${this.hass.localize("ui.panel.config.automation.editor.conditions.type.device.label")}"></ha-device-picker> <ha-device-condition-picker .value="${this.condition}" .deviceId="${t}" @value-changed="${this._deviceConditionPicked}" .hass="${this.hass}" .disabled="${this.disabled}" .label="${this.hass.localize("ui.panel.config.automation.editor.conditions.type.device.condition")}"></ha-device-condition-picker> ${this._capabilities?.extra_fields?s.qy` <ha-form .hass="${this.hass}" .data="${this._extraFieldsData(this.condition,this._capabilities)}" .schema="${this._capabilities.extra_fields}" .disabled="${this.disabled}" .computeLabel="${(0,u.T_)(this.hass.localize,this.condition)}" .computeHelper="${(0,u.TH)(this.hass.localize,this.condition)}" @value-changed="${this._extraFieldsChanged}"></ha-form> `:""} `}firstUpdated(){this.hass.loadBackendTranslation("device_automation"),this._capabilities||this._getCapabilities(),this.condition&&(this._origCondition=this.condition)}updated(t){const i=t.get("condition");i&&!(0,u.Po)(this._entityReg,i,this.condition)&&this._getCapabilities()}async _getCapabilities(){const t=this.condition;this._capabilities=t.domain?await(0,u.I$)(this.hass.callWS,t):void 0}_devicePicked(t){t.stopPropagation(),this._deviceId=t.target.value,void 0===this._deviceId&&(0,c.r)(this,"value-changed",{value:{...m.defaultConfig,condition:"device"}})}_deviceConditionPicked(t){t.stopPropagation();let i=t.detail.value;this._origCondition&&(0,u.Po)(this._entityReg,this._origCondition,i)&&(i=this._origCondition),(0,c.r)(this,"value-changed",{value:i})}_extraFieldsChanged(t){t.stopPropagation(),(0,c.r)(this,"value-changed",{value:{...this.condition,...t.detail.value}})}constructor(...t){super(...t),this.disabled=!1,this._entityReg=[],this._extraFieldsData=(0,d.A)((t,i)=>{const e={};return i.extra_fields.forEach(i=>{void 0!==t[i.name]&&(e[i.name]=t[i.name])}),e})}}m.styles=s.AH`:host{display:block;margin-bottom:var(--ha-space-3)}ha-device-picker{display:block;margin-bottom:24px}ha-form{display:block;margin-top:24px}`,(0,o.Cg)([(0,a.MZ)({attribute:!1})],m.prototype,"hass",void 0),(0,o.Cg)([(0,a.MZ)({type:Object})],m.prototype,"condition",void 0),(0,o.Cg)([(0,a.MZ)({type:Boolean})],m.prototype,"disabled",void 0),(0,o.Cg)([(0,a.wk)()],m.prototype,"_deviceId",void 0),(0,o.Cg)([(0,a.wk)()],m.prototype,"_capabilities",void 0),(0,o.Cg)([(0,a.wk)(),(0,n.Fg)({context:p.ih,subscribe:!0})],m.prototype,"_entityReg",void 0),m=(0,o.Cg)([(0,a.EM)("ha-automation-condition-device")],m),i()}catch(t){i(t)}})},56847(t,i,e){e.a(t,async function(t,o){try{e.d(i,{m:()=>l});var n=e(62826),s=e(5124),a=e(22441),d=e(1087),c=e(40219),r=t([c]);c=(r.then?(await r)():r)[0];class l extends s.WF{render(){return s.qy` <ha-automation-condition .conditions="${this.condition.conditions||[]}" @value-changed="${this._valueChanged}" .hass="${this.hass}" .disabled="${this.disabled}" .optionsInSidebar="${this.optionsInSidebar}" .narrow="${this.narrow}"></ha-automation-condition> `}expandAll(){this._conditionElement?.expandAll?.()}collapseAll(){this._conditionElement?.collapseAll?.()}_valueChanged(t){t.stopPropagation(),(0,d.r)(this,"value-changed",{value:{...this.condition,conditions:t.detail.value}})}constructor(...t){super(...t),this.disabled=!1,this.narrow=!1,this.optionsInSidebar=!1}}(0,n.Cg)([(0,a.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,n.Cg)([(0,a.MZ)({attribute:!1})],l.prototype,"condition",void 0),(0,n.Cg)([(0,a.MZ)({type:Boolean})],l.prototype,"disabled",void 0),(0,n.Cg)([(0,a.MZ)({type:Boolean})],l.prototype,"narrow",void 0),(0,n.Cg)([(0,a.MZ)({type:Boolean,attribute:"sidebar"})],l.prototype,"optionsInSidebar",void 0),(0,n.Cg)([(0,a.P)("ha-automation-condition")],l.prototype,"_conditionElement",void 0),l=(0,n.Cg)([(0,a.EM)("ha-automation-condition-logical")],l),o()}catch(t){o(t)}})},4601(t,i,e){e.a(t,async function(t,i){try{var o=e(62826),n=e(22441),s=e(56847),a=t([s]);s=(a.then?(await a)():a)[0];class d extends s.m{static get defaultConfig(){return{condition:"not",conditions:[]}}}d=(0,o.Cg)([(0,n.EM)("ha-automation-condition-not")],d),i()}catch(t){i(t)}})},97681(t,i,e){e.a(t,async function(t,i){try{var o=e(62826),n=e(5124),s=e(22441),a=e(22786),d=e(63533),c=e(1087),r=e(52763),l=e(88827),h=t([r,l]);[r,l]=h.then?(await h)():h;const p=(0,d.Ik)({alias:(0,d.lq)((0,d.Yj)()),note:(0,d.lq)((0,d.Yj)()),condition:(0,d.eu)("numeric_state"),entity_id:(0,d.lq)((0,d.Yj)()),attribute:(0,d.lq)((0,d.Yj)()),above:(0,d.lq)((0,d.KC)([(0,d.ai)(),(0,d.Yj)()])),below:(0,d.lq)((0,d.KC)([(0,d.ai)(),(0,d.Yj)()])),value_template:(0,d.lq)((0,d.Yj)()),enabled:(0,d.lq)((0,d.zM)())});class u extends n.WF{static get defaultConfig(){return{condition:"numeric_state",entity_id:""}}shouldUpdate(t){if(t.has("condition"))try{(0,d.vA)(this.condition,p)}catch(t){return(0,c.r)(this,"ui-mode-not-available",t),!1}return!0}willUpdate(){this._inputAboveIsEntity=this._inputAboveIsEntity??("string"==typeof this.condition.above&&(this.condition.above.startsWith("input_number.")||this.condition.above.startsWith("number.")||this.condition.above.startsWith("sensor."))),this._inputBelowIsEntity=this._inputBelowIsEntity??("string"==typeof this.condition.below&&(this.condition.below.startsWith("input_number.")||this.condition.below.startsWith("number.")||this.condition.below.startsWith("sensor.")))}render(){const t=this._schema(this.hass.localize,this._inputAboveIsEntity,this._inputBelowIsEntity),i=this._data(this._inputAboveIsEntity,this._inputBelowIsEntity,this.condition);return n.qy` <ha-form .hass="${this.hass}" .data="${i}" .schema="${t}" .disabled="${this.disabled}" @value-changed="${this._valueChanged}" .computeLabel="${this._computeLabelCallback}"></ha-form> `}_valueChanged(t){t.stopPropagation();const i={...t.detail.value};this._inputAboveIsEntity="input"===i.lower_limit,this._inputBelowIsEntity="input"===i.upper_limit,delete i.lower_limit,delete i.upper_limit,""===i.value_template&&delete i.value_template,(0,c.r)(this,"value-changed",{value:i})}constructor(...t){super(...t),this.disabled=!1,this._data=(0,a.A)((t,i,e)=>({lower_limit:t?"input":"value",upper_limit:i?"input":"value",...e})),this._schema=(0,a.A)((t,i,e)=>[{name:"entity_id",required:!0,selector:{entity:{}}},{name:"attribute",selector:{attribute:{hide_attributes:l.We}},context:{filter_entity:"entity_id"}},{name:"lower_limit",type:"select",required:!0,options:[["value",t("ui.panel.config.automation.editor.conditions.type.numeric_state.type_value")],["input",t("ui.panel.config.automation.editor.conditions.type.numeric_state.type_input")]]},...i?[{name:"above",selector:{entity:{domain:["input_number","number","sensor"]}}}]:[{name:"above",selector:{number:{mode:"box",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,step:.1}}}],{name:"upper_limit",type:"select",required:!0,options:[["value",t("ui.panel.config.automation.editor.conditions.type.numeric_state.type_value")],["input",t("ui.panel.config.automation.editor.conditions.type.numeric_state.type_input")]]},...e?[{name:"below",selector:{entity:{domain:["input_number","number","sensor"]}}}]:[{name:"below",selector:{number:{mode:"box",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,step:.1}}}],{name:"value_template",selector:{template:{}}}]),this._computeLabelCallback=t=>{switch(t.name){case"entity_id":return this.hass.localize("ui.components.entity.entity-picker.entity");case"attribute":return this.hass.localize("ui.components.entity.entity-attribute-picker.attribute");default:return this.hass.localize(`ui.panel.config.automation.editor.triggers.type.numeric_state.${t.name}`)}}}}u.styles=n.AH`:host{display:block;margin-bottom:var(--ha-space-3)}`,(0,o.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"condition",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],u.prototype,"disabled",void 0),(0,o.Cg)([(0,s.wk)()],u.prototype,"_inputAboveIsEntity",void 0),(0,o.Cg)([(0,s.wk)()],u.prototype,"_inputBelowIsEntity",void 0),u=(0,o.Cg)([(0,s.EM)("ha-automation-condition-numeric_state")],u),i()}catch(t){i(t)}})},4519(t,i,e){e.a(t,async function(t,i){try{var o=e(62826),n=e(22441),s=e(56847),a=t([s]);s=(a.then?(await a)():a)[0];class d extends s.m{static get defaultConfig(){return{condition:"or",conditions:[]}}}d=(0,o.Cg)([(0,n.EM)("ha-automation-condition-or")],d),i()}catch(t){i(t)}})},35913(t,i,e){e(18111),e(20116),e(7588),e(61701),e(13579),e(17642),e(58004),e(33853),e(45876),e(32475),e(15024),e(31698);var o=e(62826),n=e(5124),s=e(22441),a=e(22786),d=e(1087),c=(e(9503),e(11399),e(8034),e(87225)),r=e(95350),l=e(88555),h=e(36918);const p=t=>t.selector&&!t.required&&!("boolean"in t.selector&&t.default);class u extends n.WF{static get defaultConfig(){return{condition:""}}willUpdate(t){if(super.willUpdate(t),this.hasUpdated||(this.hass.loadBackendTranslation("conditions"),this.hass.loadBackendTranslation("selector")),!t.has("condition"))return;const i=t.get("condition");if(this.condition?.condition){const t=(0,c.ob)(this.condition.condition);t!==(0,c.ob)(i?.condition||"")&&this._fetchManifest(t)}else this._manifest=void 0;if(this.condition&&i?.condition!==this.condition.condition&&this.description?.fields){const t="options"in this.condition,i=this.condition.options?{...this.condition.options}:{},e=!t;let o=!1;Object.entries(this.description.fields).forEach(([t,n])=>{n.selector&&n.required&&void 0===n.default&&"boolean"in n.selector&&void 0===i[t]?(o=!0,i[t]=!1):!e||!n.selector||void 0===n.default||void 0!==i[t]||n.selector&&"automation_behavior"in n.selector&&this.description?.target&&!this.condition?.target||(o=!0,i[t]=n.default)}),t&&!o||(0,d.r)(this,"value-changed",{value:{...this.condition,options:i}})}i?.target!==this.condition?.target&&this._updateResolvedTargetEntityCount(this.condition?.target)}render(){const t=(0,c.ob)(this.condition.condition),i=(0,c.YQ)(this.condition.condition),e=this.hass.localize(`component.${t}.conditions.${i}.description`),o=this.description,s=!o?.fields,a=Boolean(o?.fields&&Object.values(o.fields).some(t=>p(t)));return n.qy` <div class="description"> ${e?n.qy`<p>${e}</p>`:n.s6} ${this._manifest?n.qy`<a href="${this._manifest.is_built_in?(0,h.o)(this.hass,`/integrations/${this._manifest.domain}`):this._manifest.documentation}" title="${this.hass.localize("ui.components.service-control.integration_doc")}" target="_blank" rel="noreferrer"> <ha-icon-button .path="${"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"}" class="help-icon"></ha-icon-button> </a>`:n.s6} </div> ${o&&"target"in o?n.qy`<ha-settings-row narrow> <span slot="heading">${this.hass.localize("ui.components.service-control.target")}</span> <ha-selector .hass="${this.hass}" .selector="${this._targetSelector(o.target)}" .disabled="${this.disabled}" @value-changed="${this._targetChanged}" .value="${this.condition?.target}"></ha-selector></ha-settings-row>`:n.s6} ${s?n.qy`<ha-yaml-editor .label="${this.hass.localize("ui.components.service-control.action_data")}" .name="${"data"}" .readOnly="${this.disabled}" .defaultValue="${this.condition?.options}" @value-changed="${this._dataChanged}"></ha-yaml-editor>`:Object.entries(o.fields).map(([e,o])=>this._renderField(e,o,a,t,i))} `}_generateContext(t){if(!t.context)return;const i={};for(const[e,o]of Object.entries(t.context))"target"===o&&this.description?.target&&(i.target_selector=this._targetSelector(this.description.target)),i[e]="target"===o?this.condition.target:this.condition.options?.[o];return i}_dataChanged(t){if(t.stopPropagation(),!1===t.detail.isValid)return;const i=t.currentTarget.key,e=t.detail.value;if(!(this.condition?.options?.[i]!==e&&(this.condition?.options&&i in this.condition.options||""!==e&&void 0!==e)))return;const o={...this.condition?.options,[i]:e};(""===e||void 0===e||"object"==typeof e&&!Object.keys(e).length)&&delete o[i],(0,d.r)(this,"value-changed",{value:{...this.condition,options:o}})}_targetChanged(t){t.stopPropagation(),(0,d.r)(this,"value-changed",{value:{...this.condition,target:t.detail.value}})}_toggleCheckbox(t){const i=t.currentTarget?.parentElement?.querySelector("ha-checkbox");i?.click()}_checkboxChanged(t){const i=t.currentTarget.checked,e=t.currentTarget.key;let o;if(i){this._checkedKeys.add(e);const t=this.description&&Object.entries(this.description).find(([t,i])=>t===e)?.[1];let i=t?.default;null==i&&t?.selector&&"constant"in t.selector&&(i=t.selector.constant?.value),null==i&&t?.selector&&"boolean"in t.selector&&(i=!1),null!=i&&(o={...this.condition?.options,[e]:i})}else this._checkedKeys.delete(e),o={...this.condition?.options},delete o[e];o&&(0,d.r)(this,"value-changed",{value:{...this.condition,options:o}}),this.requestUpdate("_checkedKeys")}async _fetchManifest(t){this._manifest=void 0;try{this._manifest=await(0,r.QC)(this.hass,t)}catch(i){console.log(`Unable to fetch integration manifest for ${t}`)}}_updateResolvedTargetEntityCount(t){this._resolvedTargetEntityCount=(0,l.aW)(t);const i=Object.entries(this.description?.fields??{}).find(([,t])=>t.selector&&"automation_behavior"in t.selector);if(!i)return;const[e,o]=i;if(t&&this._resolvedTargetEntityCount>1&&void 0===this.condition.options?.[e]){const t=o.default;void 0!==t&&(0,d.r)(this,"value-changed",{value:{...this.condition,options:{...this.condition.options,[e]:t}}})}}constructor(...t){super(...t),this.disabled=!1,this._checkedKeys=new Set,this._targetSelector=(0,a.A)(t=>t?{target:{...t}}:{target:{}}),this._renderField=(t,i,e,o,s)=>{const a=i?.selector??{text:null},d=p(i);if(!i.selector)return n.s6;if("automation_behavior"in a&&this.description?.target&&(!this.condition?.target||void 0!==this._resolvedTargetEntityCount&&this._resolvedTargetEntityCount<=1))return n.s6;const c=this.hass.localize(`component.${o}.conditions.${s}.fields.${t}.description`);return n.qy`<ha-settings-row narrow> ${d?n.qy`<ha-checkbox .key="${t}" .checked="${this._checkedKeys.has(t)||!!this.condition?.options&&void 0!==this.condition.options[t]}" .disabled="${this.disabled}" @change="${this._checkboxChanged}" slot="prefix"></ha-checkbox>`:e?n.qy`<div slot="prefix" class="checkbox-spacer"></div>`:n.s6} <span slot="heading" class="${d?"clickable":""}" @click="${d?this._toggleCheckbox:void 0}">${this.hass.localize(`component.${o}.conditions.${s}.fields.${t}.name`)||t}</span> ${c?n.qy`<span class="${d?"clickable":""}" @click="${d?this._toggleCheckbox:void 0}" slot="description">${c}</span>`:n.s6} <ha-selector .disabled="${this.disabled||d&&!this._checkedKeys.has(t)&&(!this.condition?.options||void 0===this.condition.options[t])}" .hass="${this.hass}" .selector="${a}" .context="${this._generateContext(i)}" .key="${t}" @value-changed="${this._dataChanged}" .value="${this.condition?.options?this.condition.options[t]:void 0}" .placeholder="${i.default}" .localizeValue="${this._localizeValueCallback}" .required="${i.required}"></ha-selector> </ha-settings-row>`},this._localizeValueCallback=t=>this.condition?.condition?this.hass.localize(`component.${(0,c.ob)(this.condition.condition)}.selector.${t}`):""}}u.styles=n.AH`:host{display:block;margin:0px calc(-1 * var(--ha-space-4))}ha-settings-row{padding:0 var(--ha-space-4)}ha-settings-row[narrow]{padding-bottom:var(--ha-space-2)}ha-settings-row{--settings-row-content-width:100%;--settings-row-prefix-display:contents;border-top:var(--service-control-items-border-top,1px solid var(--divider-color))}ha-entity-picker,ha-service-picker,ha-yaml-editor{display:block;margin:0 var(--ha-space-4)}ha-yaml-editor{padding:var(--ha-space-4) 0}p{margin:0 var(--ha-space-4);padding:var(--ha-space-4) 0}:host([hide-picker]) p{padding-top:0}.checkbox-spacer{width:32px}.help-icon{color:var(--secondary-text-color)}.description{justify-content:space-between;display:flex;align-items:center;padding-right:2px;padding-inline-end:2px;padding-inline-start:initial}.description p{direction:ltr}.clickable{cursor:pointer}`,(0,o.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"condition",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"description",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],u.prototype,"disabled",void 0),(0,o.Cg)([(0,s.wk)()],u.prototype,"_checkedKeys",void 0),(0,o.Cg)([(0,s.wk)()],u.prototype,"_manifest",void 0),(0,o.Cg)([(0,s.wk)()],u.prototype,"_resolvedTargetEntityCount",void 0),u=(0,o.Cg)([(0,s.EM)("ha-automation-condition-platform")],u)},93977(t,i,e){e.a(t,async function(t,i){try{e(18111),e(7588);var o=e(62826),n=e(5124),s=e(22441),a=e(63533),d=e(44537),c=e(57673),r=e(1087),l=e(52763),h=e(88827),p=e(67442),u=t([l,h]);[l,h]=u.then?(await u)():u;const g=(0,a.Ik)({alias:(0,a.lq)((0,a.Yj)()),note:(0,a.lq)((0,a.Yj)()),condition:(0,a.eu)("state"),entity_id:(0,a.lq)((0,a.Yj)()),attribute:(0,a.lq)((0,a.Yj)()),state:(0,a.lq)((0,a.KC)([(0,a.Yj)(),(0,a.YO)((0,a.Yj)())])),for:(0,a.lq)((0,a.KC)([(0,a.ai)(),(0,a.Yj)(),p.b])),enabled:(0,a.lq)((0,a.zM)())}),m=[{name:"entity_id",required:!0,selector:{entity:{}}},{name:"attribute",selector:{attribute:{hide_attributes:h.B9}},context:{filter_entity:"entity_id"}},{name:"state",required:!0,selector:{state:{multiple:!0}},context:{filter_entity:"entity_id",filter_attribute:"attribute"}},{name:"for",selector:{duration:{}}}];class b extends n.WF{static get defaultConfig(){return{condition:"state",entity_id:"",state:[]}}shouldUpdate(t){if(t.has("condition"))try{(0,a.vA)(this.condition,g)}catch(t){return(0,r.r)(this,"ui-mode-not-available",t),!1}return!0}render(){const t=(0,c.z)(this.condition.for),i={...this.condition,state:(0,d.e)(this.condition.state)||[],for:t};return n.qy` <ha-form .hass="${this.hass}" .data="${i}" .schema="${m}" .disabled="${this.disabled}" @value-changed="${this._valueChanged}" .computeLabel="${this._computeLabelCallback}"></ha-form> `}_valueChanged(t){t.stopPropagation();const i=t.detail.value;Object.keys(i).forEach(t=>void 0===i[t]||""===i[t]?delete i[t]:{}),void 0!==i.state&&""!==i.state||(i.state=[]),(0,r.r)(this,"value-changed",{value:i})}constructor(...t){super(...t),this.disabled=!1,this._computeLabelCallback=t=>{switch(t.name){case"entity_id":return this.hass.localize("ui.components.entity.entity-picker.entity");case"attribute":return this.hass.localize("ui.components.entity.entity-attribute-picker.attribute");case"for":return this.hass.localize("ui.panel.config.automation.editor.triggers.type.state.for");default:return this.hass.localize(`ui.panel.config.automation.editor.conditions.type.state.${t.name}`)}}}}b.styles=n.AH`:host{display:block;margin-bottom:var(--ha-space-3)}`,(0,o.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"condition",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],b.prototype,"disabled",void 0),b=(0,o.Cg)([(0,s.EM)("ha-automation-condition-state")],b),i()}catch(t){i(t)}})},40998(t,i,e){e.a(t,async function(t,i){try{e(74423);var o=e(62826),n=e(5124),s=e(22441),a=e(22786),d=e(1087),c=e(52763),r=t([c]);c=(r.then?(await r)():r)[0];const l="sunrise",h="sunset";class p extends n.WF{connectedCallback(){super.connectedCallback(),this.condition.before&&this.condition.after?this._formType="between":this.condition.after&&(this._formType="after")}static get defaultConfig(){return{condition:"sun",before:l}}render(){const t=this._schema(this.hass.localize,this._formType);return n.qy` <ha-select .label="${this.hass.localize("ui.panel.config.automation.editor.conditions.type_select")}" .value="${this._formType}" @selected="${this._typeSelected}" .options="${[{value:"before",label:this.hass.localize("ui.panel.config.automation.editor.conditions.type.sun.before")},{value:"after",label:this.hass.localize("ui.panel.config.automation.editor.conditions.type.sun.after")},{value:"between",label:this.hass.localize("ui.panel.config.automation.editor.conditions.type.sun.between")}]}"> </ha-select> <ha-form .schema="${t}" .data="${this.condition}" .hass="${this.hass}" .disabled="${this.disabled}" .computeLabel="${this._computeLabelCallback}" @value-changed="${this._valueChanged}"></ha-form> `}_valueChanged(t){t.stopPropagation(),(0,d.r)(this,"value-changed",{value:t.detail.value})}_typeSelected(t){const i=t.detail.value;this._formType=i,"after"===i?(delete this.condition.before,delete this.condition.before_offset):this.condition.before||(this.condition.before=l),"before"===i?(delete this.condition.after,delete this.condition.after_offset):this.condition.after||(this.condition.after=h),(0,d.r)(this,"value-changed",{value:{...this.condition}})}constructor(...t){super(...t),this.disabled=!1,this._formType="before",this._schema=(0,a.A)((t,i)=>[...["between","after"].includes(i)?[{name:"after",type:"select",default:h,options:[["sunrise",t("ui.panel.config.automation.editor.conditions.type.sun.sunrise")],["sunset",t("ui.panel.config.automation.editor.conditions.type.sun.sunset")]]},{name:"after_offset",selector:{duration:{allow_negative:!0}}}]:[],...["between","before"].includes(i)?[{name:"before",type:"select",default:l,options:[["sunrise",t("ui.panel.config.automation.editor.conditions.type.sun.sunrise")],["sunset",t("ui.panel.config.automation.editor.conditions.type.sun.sunset")]]},{name:"before_offset",selector:{duration:{allow_negative:!0}}}]:[]]),this._computeLabelCallback=t=>this.hass.localize(`ui.panel.config.automation.editor.conditions.type.sun.${t.name}`)}}p.styles=n.AH`ha-select{display:block;margin-bottom:var(--ha-space-4)}`,(0,o.Cg)([(0,s.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],p.prototype,"condition",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],p.prototype,"disabled",void 0),(0,o.Cg)([(0,s.wk)()],p.prototype,"_formType",void 0),p=(0,o.Cg)([(0,s.EM)("ha-automation-condition-sun")],p),i()}catch(t){i(t)}})},60092(t,i,e){e.a(t,async function(t,i){try{var o=e(62826),n=e(5124),s=e(22441),a=e(52763),d=e(1087),c=t([a]);a=(c.then?(await c)():c)[0];const r=[{name:"value_template",required:!0,selector:{template:{}}}];class l extends n.WF{static get defaultConfig(){return{condition:"template",value_template:""}}render(){return n.qy` <ha-form .hass="${this.hass}" .data="${this.condition}" .schema="${r}" @value-changed="${this._valueChanged}" .computeLabel="${this._computeLabelCallback}" .disabled="${this.disabled}"></ha-form> `}_valueChanged(t){t.stopPropagation();const i=t.detail.value;(0,d.r)(this,"value-changed",{value:i})}constructor(...t){super(...t),this.disabled=!1,this._computeLabelCallback=t=>this.hass.localize(`ui.panel.config.automation.editor.conditions.type.template.${t.name}`)}}(0,o.Cg)([(0,s.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],l.prototype,"condition",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],l.prototype,"disabled",void 0),l=(0,o.Cg)([(0,s.EM)("ha-automation-condition-template")],l),i()}catch(t){i(t)}})},1103(t,i,e){e.a(t,async function(t,i){try{e(18111),e(7588),e(61701);var o=e(62826),n=e(5124),s=e(22441),a=e(22786),d=e(380),c=e(1087),r=e(52763),l=t([r]);r=(l.then?(await l)():l)[0];const h=["sun","mon","tue","wed","thu","fri","sat"];class p extends n.WF{static get defaultConfig(){return{condition:"time"}}render(){const t=this._inputModeBefore??(this.condition.before?.startsWith("input_datetime.")||this.condition.before?.startsWith("time.")||this.condition.before?.startsWith("sensor.")),i=this._inputModeAfter??(this.condition.after?.startsWith("input_datetime.")||this.condition.after?.startsWith("time.")||this.condition.after?.startsWith("sensor.")),e=this._schema(this.hass.localize,this.hass.locale,i,t),o={mode_before:t?"input":"value",mode_after:i?"input":"value",...this.condition};return n.qy` <ha-form .hass="${this.hass}" .data="${o}" .schema="${e}" .disabled="${this.disabled}" @value-changed="${this._valueChanged}" .computeLabel="${this._computeLabelCallback}"></ha-form> `}_valueChanged(t){t.stopPropagation();const i=t.detail.value;this._inputModeAfter="input"===i.mode_after,this._inputModeBefore="input"===i.mode_before,delete i.mode_after,delete i.mode_before,Object.keys(i).forEach(t=>void 0===i[t]||""===i[t]||Array.isArray(i[t])&&0===i[t].length?delete i[t]:{}),(0,c.r)(this,"value-changed",{value:i})}constructor(...t){super(...t),this.disabled=!1,this._schema=(0,a.A)((t,i,e,o)=>{const n=(0,d.P)(i),s=h.slice(n,h.length).concat(h.slice(0,n));return[{name:"mode_after",type:"select",required:!0,options:[["value",t("ui.panel.config.automation.editor.conditions.type.time.type_value")],["input",t("ui.panel.config.automation.editor.conditions.type.time.type_input")]]},{name:"after",selector:e?{entity:{filter:[{domain:"input_datetime"},{domain:"time"},{domain:"sensor",device_class:"timestamp"}]}}:{time:{}}},{name:"mode_before",type:"select",required:!0,options:[["value",t("ui.panel.config.automation.editor.conditions.type.time.type_value")],["input",t("ui.panel.config.automation.editor.conditions.type.time.type_input")]]},{name:"before",selector:o?{entity:{filter:[{domain:"input_datetime"},{domain:"time"},{domain:"sensor",device_class:"timestamp"}]}}:{time:{}}},{type:"multi_select",name:"weekday",options:s.map(i=>[i,t(`ui.panel.config.automation.editor.conditions.type.time.weekdays.${i}`)])}]}),this._computeLabelCallback=t=>this.hass.localize(`ui.panel.config.automation.editor.conditions.type.time.${t.name}`)}}(0,o.Cg)([(0,s.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],p.prototype,"condition",void 0),(0,o.Cg)([(0,s.wk)()],p.prototype,"_inputModeBefore",void 0),(0,o.Cg)([(0,s.wk)()],p.prototype,"_inputModeAfter",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],p.prototype,"disabled",void 0),p=(0,o.Cg)([(0,s.EM)("ha-automation-condition-time")],p),i()}catch(t){i(t)}})},52128(t,i,e){e.a(t,async function(t,i){try{e(18111),e(22489),e(61701),e(13579),e(17642),e(58004),e(33853),e(45876),e(32475),e(15024),e(31698);var o=e(62826),n=e(5124),s=e(22441),a=e(22786),d=e(44537),c=e(1087),r=e(52763),l=e(606),h=e(88249),p=t([r,l]);[r,l]=p.then?(await p)():p;const u=t=>{const i=(0,h.aI)(t).map(t=>"id"in t?t.id:void 0).filter(Boolean);return Array.from(new Set(i))};class g extends n.WF{static get defaultConfig(){return{condition:"trigger",id:""}}connectedCallback(){super.connectedCallback();const t={callback:t=>this._automationUpdated(t)};(0,c.r)(this,"subscribe-automation-config",t),this._unsub=t.unsub}disconnectedCallback(){super.disconnectedCallback(),this._unsub&&this._unsub()}render(){if(!this._triggerIds.length)return this.hass.localize("ui.panel.config.automation.editor.conditions.type.trigger.no_triggers");const t=this._schema(this._triggerIds);return n.qy` <ha-form .schema="${t}" .data="${this.condition}" .hass="${this.hass}" .disabled="${this.disabled}" .computeLabel="${this._computeLabelCallback}" @value-changed="${this._valueChanged}"></ha-form> `}_automationUpdated(t){this._triggerIds=t?.triggers?u((0,d.e)(t.triggers)):[]}_valueChanged(t){t.stopPropagation();const i=t.detail.value;"string"==typeof i.id?this._triggerIds.some(t=>t===i.id)||(i.id=""):Array.isArray(i.id)&&(i.id=i.id.filter(t=>this._triggerIds.some(i=>i===t)),i.id.length||(i.id="")),(0,c.r)(this,"value-changed",{value:i})}constructor(...t){super(...t),this.disabled=!1,this._triggerIds=[],this._schema=(0,a.A)(t=>[{name:"id",selector:{select:{multiple:!0,options:t}},required:!0}]),this._computeLabelCallback=t=>this.hass.localize(`ui.panel.config.automation.editor.conditions.type.trigger.${t.name}`)}}(0,o.Cg)([(0,s.MZ)({attribute:!1})],g.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],g.prototype,"condition",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],g.prototype,"disabled",void 0),(0,o.Cg)([(0,s.wk)()],g.prototype,"_triggerIds",void 0),g=(0,o.Cg)([(0,s.EM)("ha-automation-condition-trigger")],g),i()}catch(t){i(t)}})},56860(t,i,e){e.a(t,async function(t,i){try{var o=e(62826),n=e(5124),s=e(22441),a=e(1087),d=e(69093),c=e(3471),r=e(82474),l=t([r]);function h(t){return(0,c.e)(t)&&"zone"!==(0,d.t)(t)}r=(l.then?(await l)():l)[0];const p=["zone"];class u extends n.WF{static get defaultConfig(){return{condition:"zone",entity_id:"",zone:""}}render(){const{entity_id:t,zone:i}=this.condition;return n.qy` <ha-entity-picker .label="${this.hass.localize("ui.panel.config.automation.editor.conditions.type.zone.entity")}" .value="${t}" @value-changed="${this._entityPicked}" .hass="${this.hass}" .disabled="${this.disabled}" .entityFilter="${h}"></ha-entity-picker> <ha-entity-picker .label="${this.hass.localize("ui.panel.config.automation.editor.conditions.type.zone.zone")}" .value="${i}" @value-changed="${this._zonePicked}" .hass="${this.hass}" .disabled="${this.disabled}" .includeDomains="${p}"></ha-entity-picker> `}_entityPicked(t){t.stopPropagation(),(0,a.r)(this,"value-changed",{value:{...this.condition,entity_id:t.detail.value}})}_zonePicked(t){t.stopPropagation(),(0,a.r)(this,"value-changed",{value:{...this.condition,zone:t.detail.value}})}constructor(...t){super(...t),this.disabled=!1}}u.styles=n.AH`ha-entity-picker:first-child{display:block;margin-bottom:24px}`,(0,o.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],u.prototype,"condition",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean})],u.prototype,"disabled",void 0),u=(0,o.Cg)([(0,s.EM)("ha-automation-condition-zone")],u),i()}catch(g){i(g)}})}};