iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
8 lines • 37.6 kB
JavaScript
/*! For license information please see 15175.dea93d179a477bb8.js.LICENSE.txt */
export const __rspack_esm_id=15175;export const __rspack_esm_ids=[15175];export const __webpack_modules__={60353(t,e,i){i.d(e,{u:()=>a});class a{start(t){const e=Date.now();this._startY=t,this._startTime=e,this._lastY=t,this._lastTime=e,this._delta=0}move(t){const e=Date.now();return this._delta=this._startY-t,this._lastY=t,this._lastTime=e,this._delta}end(){const t=this.getVelocity(),e=Math.abs(t)>this._velocityThreshold;return{velocity:t,delta:this._delta,isSwipe:e,isDownwardSwipe:t>0}}getDelta(){return this._delta}getVelocity(){if(Date.now()-this._lastTime>=this._movementTimeThreshold)return 0;const t=this._lastTime-this._startTime;return t>0?(this._lastY-this._startY)/t:0}reset(){this._startY=0,this._delta=0,this._startTime=0,this._lastY=0,this._lastTime=0}constructor(t={}){this._startY=0,this._delta=0,this._startTime=0,this._lastY=0,this._lastTime=0,this._velocityThreshold=t.velocitySwipeThreshold??.5,this._movementTimeThreshold=t.movementTimeThreshold??100}}},14693(t,e,i){i.a(t,async function(t,a){try{i.d(e,{r:()=>_});var o=i(62826),s=i(35211),r=i(5124),n=i(22441),d=i(71769),l=i(22792),h=i(99611),c=(i(76538),i(26300)),p=i(72554),u=t([h,c,p]);[h,c,p]=u.then?(await u)():u;const m="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",g="(max-width: 870px), (max-height: 500px)";class _ extends r.WF{connectedCallback(){super.connectedCallback(),this._unsubMediaQuery=(0,d.m)(g,t=>{this._modeSet&&!this.allowModeChange||(this.mode=t?"bottom-sheet":"dialog",this._modeSet=!0)})}get _defaultAriaLabelledBy(){return this.ariaLabelledBy||(void 0!==this.headerTitle?"ha-dialog-title":void 0)}_renderCloseButton(t){return this.hideCloseButton?r.qy`<span slot="${t}"></span>`:r.qy` <slot name="headerNavigationIcon" slot="${t}"> <ha-icon-button data-dialog="close" .label="${this._i18n?.localize?.("ui.common.close")??"Close"}" .path="${m}"></ha-icon-button> </slot> `}_renderHeaderContent(){return r.qy` <ha-dialog-header .subtitlePosition="${this.headerSubtitlePosition}"> ${this._renderCloseButton("navigationIcon")} ${void 0!==this.headerTitle?r.qy`<span slot="title" class="title" id="ha-dialog-title"> ${this.headerTitle} </span>`:r.qy`<slot name="headerTitle" slot="title"></slot>`} ${void 0!==this.headerSubtitle?r.qy`<span slot="subtitle">${this.headerSubtitle}</span>`:r.qy`<slot name="headerSubtitle" slot="subtitle"></slot>`} <slot name="headerActionItems" slot="actionItems"></slot> </ha-dialog-header> `}disconnectedCallback(){super.disconnectedCallback(),this._unsubMediaQuery?.(),this._unsubMediaQuery=void 0,this._modeSet=!1}render(){return"bottom-sheet"===this.mode?r.qy` <ha-bottom-sheet .ariaLabelledBy="${this._defaultAriaLabelledBy}" .ariaDescribedBy="${this.ariaDescribedBy}" .flexContent="${this.flexContent}" .open="${this.open}" .preventScrimClose="${this.preventScrimClose}"> ${this.withoutHeader?r.s6:r.qy` <slot name="header" slot="header">${this._renderHeaderContent()}</slot> `} <slot></slot> <slot name="footer" slot="footer"></slot> </ha-bottom-sheet> `:r.qy` <ha-dialog .open="${this.open}" .type="${this.type}" .width="${this.width}" .preventScrimClose="${this.preventScrimClose}" .ariaLabelledBy="${this.ariaLabelledBy}" .ariaDescribedBy="${this.ariaDescribedBy}" .headerTitle="${this.headerTitle}" .headerSubtitle="${this.headerSubtitle}" .headerSubtitlePosition="${this.headerSubtitlePosition}" .flexContent="${this.flexContent}" .withoutHeader="${this.withoutHeader}"> ${this._renderCloseButton("headerNavigationIcon")} <slot name="headerTitle" slot="headerTitle"></slot> <slot name="headerSubtitle" slot="headerSubtitle"></slot> <slot name="headerActionItems" slot="headerActionItems"></slot> <slot></slot> <slot name="footer" slot="footer"></slot> </ha-dialog> `}static get styles(){return[r.AH`ha-bottom-sheet{--ha-bottom-sheet-border-radius:var(--ha-border-radius-2xl);--ha-bottom-sheet-surface-background:var(
--ha-dialog-surface-background,
var(--card-background-color, var(--ha-color-surface-default))
);--ha-bottom-sheet-padding:0 var(--safe-area-inset-right) var(--safe-area-inset-bottom) var(--safe-area-inset-left);--ha-bottom-sheet-content-padding:var(
--dialog-content-padding,
0 var(--ha-space-6) var(--ha-space-6) var(--ha-space-6)
)}`]}constructor(...t){super(...t),this.open=!1,this.type="standard",this.width="medium",this.preventScrimClose=!1,this.headerSubtitlePosition="below",this.allowModeChange=!1,this.withoutHeader=!1,this.hideCloseButton=!1,this.flexContent=!1,this.mode="dialog",this._modeSet=!1}}(0,o.Cg)([(0,n.MZ)({attribute:"aria-labelledby"})],_.prototype,"ariaLabelledBy",void 0),(0,o.Cg)([(0,n.MZ)({attribute:"aria-describedby"})],_.prototype,"ariaDescribedBy",void 0),(0,o.Cg)([(0,n.MZ)({type:Boolean,reflect:!0})],_.prototype,"open",void 0),(0,o.Cg)([(0,n.MZ)({reflect:!0})],_.prototype,"type",void 0),(0,o.Cg)([(0,n.MZ)({type:String,reflect:!0,attribute:"width"})],_.prototype,"width",void 0),(0,o.Cg)([(0,n.MZ)({type:Boolean,reflect:!0,attribute:"prevent-scrim-close"})],_.prototype,"preventScrimClose",void 0),(0,o.Cg)([(0,n.MZ)({attribute:"header-title"})],_.prototype,"headerTitle",void 0),(0,o.Cg)([(0,n.MZ)({attribute:"header-subtitle"})],_.prototype,"headerSubtitle",void 0),(0,o.Cg)([(0,n.MZ)({type:String,attribute:"header-subtitle-position"})],_.prototype,"headerSubtitlePosition",void 0),(0,o.Cg)([(0,n.MZ)({type:Boolean,attribute:"allow-mode-change"})],_.prototype,"allowModeChange",void 0),(0,o.Cg)([(0,n.MZ)({type:Boolean,attribute:"without-header"})],_.prototype,"withoutHeader",void 0),(0,o.Cg)([(0,n.MZ)({type:Boolean,attribute:"hide-close-button"})],_.prototype,"hideCloseButton",void 0),(0,o.Cg)([(0,n.MZ)({type:Boolean,reflect:!0,attribute:"flexcontent"})],_.prototype,"flexContent",void 0),(0,o.Cg)([(0,n.wk)()],_.prototype,"mode",void 0),(0,o.Cg)([(0,n.wk)(),(0,s.Fg)({context:l.D5,subscribe:!0})],_.prototype,"_i18n",void 0),_=(0,o.Cg)([(0,n.EM)("ha-adaptive-dialog")],_),a()}catch(t){a(t)}})},99611(t,e,i){i.a(t,async function(t,e){try{i(18111),i(13579),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);var a=i(62826),o=i(1126),s=i(35211),r=i(5124),n=i(22441),d=i(1087),l=i(60353),h=i(22792),c=i(59992),p=i(14503),u=i(22348),m=t([o]);o=(m.then?(await m)():m)[0];const g=300,_=new Set(["ha-control-slider","ha-slider","ha-control-switch","ha-control-circular-slider","ha-hs-color-picker","ha-map","ha-more-info-control-select-container","ha-filter-chip"]),v=new Set(["volume-slider-container","forecast"]);class y extends((0,c.V)(r.WF)){get scrollableElement(){return this._bodyElement}connectedCallback(){super.connectedCallback(),this.addEventListener("slider-interaction-start",this._handleSliderInteractionStart,{capture:!0}),this.addEventListener("slider-interaction-stop",this._handleSliderInteractionStop,{capture:!0})}updated(t){super.updated(t),t.has("open")&&(this._drawerOpen=this.open)}render(){return r.qy` <wa-drawer id="drawer" placement="bottom" .open="${this._drawerOpen}" .lightDismiss="${!this.preventScrimClose}" .ariaLabelledby="${this.ariaLabelledBy}" .ariaDescribedby="${this.ariaDescribedBy}" ="${this._handleKeyDown}" -show="${this._handleShow}" -after-show="${this._handleAfterShow}" -hide="${this._handleHide}" -after-hide="${this._handleAfterHide}" ="${this._handleCloseAction}" without-header ="${this._handleTouchStart}"> <div class="handle-wrapper" aria-hidden="true"> <div class="handle"></div> </div> <slot name="header"></slot> <div class="content-wrapper"> <div id="body" class="body ha-scrollbar"> <slot></slot> </div> ${this.renderScrollableFades()} </div> <slot name="footer"></slot> </wa-drawer> `}_startResizing(t){document.addEventListener("touchmove",this._handleTouchMove,{passive:!1}),document.addEventListener("touchend",this._handleTouchEnd),document.addEventListener("touchcancel",this._handleTouchEnd),this._gestureRecognizer.start(t)}_animateSnapBack(){this.style.setProperty("--dialog-transition",`transform ${g}ms ease-out`),this.style.removeProperty("--dialog-transform"),setTimeout(()=>{this.style.removeProperty("--dialog-transition")},g)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("slider-interaction-start",this._handleSliderInteractionStart,{capture:!0}),this.removeEventListener("slider-interaction-stop",this._handleSliderInteractionStop,{capture:!0}),this._unregisterResizeHandlers(),this._isDragging=!1}static get styles(){return[...super.styles,p.dp,r.AH`wa-drawer{--wa-color-surface-raised:transparent;--spacing:0;--size:var(--ha-bottom-sheet-height, auto);--show-duration:${g}ms;--hide-duration:${g}ms}wa-drawer::part(dialog){max-height:min(var(--ha-bottom-sheet-max-height,90vh),calc(100vh - max(var(--safe-area-inset-top),48px)));max-height:min(var(--ha-bottom-sheet-max-height,90dvh),calc(100dvh - max(var(--safe-area-inset-top),48px)));align-items:center;transform:var(--dialog-transform);transition:var(--dialog-transition)} (prefers-reduced-motion:reduce){wa-drawer{--wa-color-surface-raised:transparent;--spacing:0;--size:var(--ha-bottom-sheet-height, auto);--show-duration:1ms;--hide-duration:1ms}wa-drawer::part(dialog){transition:1ms}}wa-drawer::part(dialog)::backdrop{-webkit-backdrop-filter:var(--ha-bottom-sheet-scrim-backdrop-filter,var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none)));backdrop-filter:var(--ha-bottom-sheet-scrim-backdrop-filter,var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none)));background-color:var(--ha-bottom-sheet-scrim-color,var(--mdc-dialog-scrim-color,none))}wa-drawer::part(body){max-width:var(--ha-bottom-sheet-max-width);width:100%;position:relative;border-top-left-radius:var(--ha-bottom-sheet-border-radius,var(--ha-dialog-border-radius,var(--ha-border-radius-2xl)));border-top-right-radius:var(--ha-bottom-sheet-border-radius,var(--ha-dialog-border-radius,var(--ha-border-radius-2xl)));background-color:var(--ha-bottom-sheet-surface-background,var(--ha-dialog-surface-background,var(--card-background-color,var(--ha-color-surface-default))));-webkit-backdrop-filter:var(--ha-bottom-sheet-surface-backdrop-filter,var(--ha-dialog-surface-backdrop-filter,none));backdrop-filter:var(--ha-bottom-sheet-surface-backdrop-filter,var(--ha-dialog-surface-backdrop-filter,none));padding:var(--ha-bottom-sheet-padding,0 var(--safe-area-inset-right) var(--safe-area-inset-bottom) var(--safe-area-inset-left))}:host([flexcontent]) wa-drawer::part(body){display:flex;flex-direction:column}:host([prevent-scrim-close]) .handle-wrapper{display:none}.handle-wrapper{position:absolute;top:0;inset-inline-start:0;width:100%;padding-bottom:2px;display:flex;justify-content:center;align-items:center;pointer-events:none;z-index:1}.handle-wrapper .handle{height:16px;width:200px;display:flex;justify-content:center;align-items:center}.handle-wrapper .handle::after{content:"";border-radius:var(--ha-border-radius-md);height:4px;background:var(--ha-bottom-sheet-handle-color,var(--divider-color));width:40px}.content-wrapper{position:relative;flex:1;display:flex;flex-direction:column;min-height:0}.body{padding:var(--ha-bottom-sheet-content-padding,0);box-sizing:border-box}:host([flexcontent]) .body{flex:1;max-width:100%;display:flex;flex-direction:column;padding:var(--ha-bottom-sheet-content-padding,var(--ha-bottom-sheet-padding,0 var(--safe-area-inset-right) var(--safe-area-inset-bottom) var(--safe-area-inset-left)));box-sizing:border-box}slot[name=footer]{display:block;padding:0}::slotted([slot=footer]){display:flex;padding:var(--ha-space-3) var(--ha-space-4) var(--ha-space-4) var(--ha-space-4);gap:var(--ha-space-3);justify-content:flex-end;align-items:center;width:100%;box-sizing:border-box}:host([flexcontent]) slot[name=footer]{flex-shrink:0}`]}constructor(...t){super(...t),this.open=!1,this.flexContent=!1,this.preventScrimClose=!1,this._drawerOpen=!1,this._sliderInteractionActive=!1,this._gestureRecognizer=new l.u,this._isDragging=!1,this._escapePressed=!1,this._handleShow=async()=>{this._drawerOpen=!0,this.open=!0,(0,d.r)(this,"opened"),await this.updateComplete,requestAnimationFrame(()=>{const t=this._autofocusElement;this._hassConfig?.auth.external&&(0,u.V)(this._hassConfig.auth.external)?t&&(t.id||(t.id="ha-bottom-sheet-autofocus"),this._hassConfig.auth.external.fireMessage({type:"focus_element",payload:{element_id:t.id}})):t?.focus()})},this._handleAfterShow=()=>{(0,d.r)(this,"after-show")},this._handleSliderInteractionStart=()=>{this._sliderInteractionActive=!0},this._handleSliderInteractionStop=()=>{this._sliderInteractionActive=!1},this._handleAfterHide=t=>{if(this._sliderInteractionActive)return this._drawerOpen=!0,void(this.open=!0);t.eventPhase===Event.AT_TARGET&&(this.open=!1,this._drawerOpen=!1,(0,d.r)(this,"closed"))},this._handleHide=t=>{if(t.eventPhase!==Event.AT_TARGET)return;const e=t.detail.source===t.target.drawer;if(this._sliderInteractionActive)return t.preventDefault(),this._drawerOpen=!0,this.open=!0,void(this._escapePressed=!1);this.preventScrimClose&&this._escapePressed&&e&&t.preventDefault(),this._escapePressed=!1},this._handleKeyDown=t=>{"Escape"===t.key&&(this._escapePressed=!0,this.preventScrimClose&&t.preventDefault(),t.stopPropagation(),t.currentTarget.open=!1)},this._handleCloseAction=t=>{t.composedPath().some(t=>t instanceof HTMLElement&&("close"===t.getAttribute("data-dialog")||"close"===t.getAttribute("data-drawer")))&&(this._drawerOpen=!1)},this._handleTouchStart=t=>{if(this.preventScrimClose)return;const e=t.composedPath();for(const t of e){if(t===this._drawer)break;if(t instanceof HTMLElement&&(t.scrollTop>0||_.has(t.localName)||Array.from(t.classList).some(t=>v.has(t))))return}t.stopPropagation(),this._startResizing(t.touches[0].clientY)},this._handleTouchMove=t=>{const e=t.touches[0].clientY,i=this._gestureRecognizer.move(e);i<0&&(t.preventDefault(),this._isDragging=!0,requestAnimationFrame(()=>{this._isDragging&&this.style.setProperty("--dialog-transform",`translateY(${-1*i}px)`)}))},this._handleTouchEnd=()=>{this._unregisterResizeHandlers(),this._isDragging=!1;const t=this._gestureRecognizer.end();if(t.isSwipe)return void(t.isDownwardSwipe?this._drawerOpen=!1:this._animateSnapBack());const e=this._drawer.shadowRoot?.querySelector('[part="body"]'),i=e?.offsetHeight||0;i>0&&t.delta<0&&Math.abs(t.delta)>.5*i?this._drawerOpen=!1:this._animateSnapBack()},this._unregisterResizeHandlers=()=>{document.removeEventListener("touchmove",this._handleTouchMove),document.removeEventListener("touchend",this._handleTouchEnd),document.removeEventListener("touchcancel",this._handleTouchEnd)}}}(0,a.Cg)([(0,n.MZ)({attribute:"aria-labelledby"})],y.prototype,"ariaLabelledBy",void 0),(0,a.Cg)([(0,n.MZ)({attribute:"aria-describedby"})],y.prototype,"ariaDescribedBy",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean})],y.prototype,"open",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean,reflect:!0,attribute:"flexcontent"})],y.prototype,"flexContent",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean,reflect:!0,attribute:"prevent-scrim-close"})],y.prototype,"preventScrimClose",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_drawerOpen",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_sliderInteractionActive",void 0),(0,a.Cg)([(0,n.wk)(),(0,s.Fg)({context:h.WF,subscribe:!0})],y.prototype,"_hassConfig",void 0),(0,a.Cg)([(0,n.P)("#drawer")],y.prototype,"_drawer",void 0),(0,a.Cg)([(0,n.P)("#body")],y.prototype,"_bodyElement",void 0),(0,a.Cg)([(0,n.P)("[autofocus]")],y.prototype,"_autofocusElement",void 0),y=(0,a.Cg)([(0,n.EM)("ha-bottom-sheet")],y),e()}catch(t){e(t)}})},10139(t,e,i){i.d(e,{I$:()=>h,I3:()=>v,PV:()=>_,Po:()=>u,RK:()=>w,TB:()=>c,TH:()=>f,T_:()=>b,am:()=>r,jR:()=>l,ng:()=>n,nx:()=>y,o9:()=>d});i(74423);var a=i(28978),o=i(88249),s=i(59241);const r=(t,e)=>t({type:"device_automation/action/list",device_id:e}),n=(t,e)=>t({type:"device_automation/condition/list",device_id:e}),d=(t,e)=>t({type:"device_automation/trigger/list",device_id:e}).then(t=>(0,o.vO)(t)),l=(t,e)=>t({type:"device_automation/action/capabilities",action:e}),h=(t,e)=>t({type:"device_automation/condition/capabilities",condition:e}),c=(t,e)=>t({type:"device_automation/trigger/capabilities",trigger:e}),p=["device_id","domain","entity_id","type","subtype","event","condition","trigger"],u=(t,e,i)=>{if(typeof e!=typeof i)return!1;for(const a in e)if(p.includes(a))if("entity_id"!==a||e[a]?.includes(".")===i[a]?.includes(".")){if(!Object.is(e[a],i[a]))return!1}else if(!m(t,e[a],i[a]))return!1;for(const a in i)if(p.includes(a))if("entity_id"!==a||e[a]?.includes(".")===i[a]?.includes(".")){if(!Object.is(e[a],i[a]))return!1}else if(!m(t,e[a],i[a]))return!1;return!0},m=(t,e,i)=>{if(!e||!i)return!1;if(e.includes(".")){const i=(0,s.Ox)(t)[e];if(!i)return!1;e=i.id}if(i.includes(".")){const e=(0,s.Ox)(t)[i];if(!e)return!1;i=e.id}return e===i},g=(t,e,i,o)=>{if(!o)return`<${t("ui.panel.config.automation.editor.unknown_entity")}>`;if(o.includes(".")){const t=e[o];return t?(0,a.u)(t):o}const r=(0,s.P9)(i)[o];if(r){if(r.name)return r.name;const t=e[r.entity_id];return t?(0,a.u)(t):r.original_name??o}return`<${t("ui.panel.config.automation.editor.unknown_entity")}>`},_=(t,e,i,a)=>t(`component.${a.domain}.device_automation.action_type.${a.type}`,{entity_name:g(t,e,i,a.entity_id),subtype:a.subtype?t(`component.${a.domain}.device_automation.action_subtype.${a.subtype}`)||a.subtype:""})||(a.subtype?`"${a.subtype}" ${a.type}`:a.type),v=(t,e,i,a)=>t(`component.${a.domain}.device_automation.condition_type.${a.type}`,{entity_name:g(t,e,i,a.entity_id),subtype:a.subtype?t(`component.${a.domain}.device_automation.condition_subtype.${a.subtype}`)||a.subtype:""})||(a.subtype?`"${a.subtype}" ${a.type}`:a.type),y=(t,e,i,a)=>t(`component.${a.domain}.device_automation.trigger_type.${a.type}`,{entity_name:g(t,e,i,a.entity_id),subtype:a.subtype?t(`component.${a.domain}.device_automation.trigger_subtype.${a.subtype}`)||a.subtype:""})||(a.subtype?`"${a.subtype}" ${a.type}`:a.type),b=(t,e)=>i=>t(`component.${e.domain}.device_automation.extra_fields.${i.name}`)||i.name,f=(t,e)=>i=>t(`component.${e.domain}.device_automation.extra_fields_descriptions.${i.name}`),w=(t,e)=>t.metadata?.secondary&&!e.metadata?.secondary?1:!t.metadata?.secondary&&e.metadata?.secondary?-1:0},28180(t,e,i){i(18111),i(61701);var a=i(62826),o=i(5124),s=i(22441),r=i(1087),n=(i(47680),i(67094),i(1671),i(50723),i(93421));class d extends o.WF{render(){return this.sections.length?o.qy`${this.sections.map((t,e)=>this._renderSection(t,e))}`:o.s6}_renderSection(t,e){return t.actions.length||t.empty||t.emptyKey?o.qy` <h3 class="section-header"> ${this._localizeValue(t.title,t.titleKey)} </h3> ${t.actions.length?o.qy`<ha-list-base> ${t.actions.map((t,i)=>this._renderActionItem(t,e,i))} </ha-list-base>`:o.qy`<h4 class="empty"> ${this._localizeValue(t.empty,t.emptyKey)} </h4>`} `:o.s6}_renderActionItem(t,e,i){return o.qy` <ha-list-item-button .disabled="${!1===t.enabled}" data-section-index="${e}" data-action-index="${i}" .headline="${this._localizeValue(t.name,t.nameKey)}" .supportingText="${this._localizeValue(t.description,t.descriptionKey)}" ="${this._actionSelected}"> ${t.icon?o.qy`<ha-icon class="start-icon" slot="start" .icon="${t.icon}"></ha-icon>`:t.iconPath?o.qy`<ha-svg-icon class="start-icon" slot="start" .path="${t.iconPath}"></ha-svg-icon>`:o.s6} <ha-svg-icon class="plus" slot="end" .path="${"M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"}"></ha-svg-icon> </ha-list-item-button> `}_localizeValue(t,e){return t||(e?this._localize(e):void 0)}_actionSelected(t){const e=this.sections[Number(t.currentTarget.dataset.sectionIndex)]?.actions[Number(t.currentTarget.dataset.actionIndex)];e&&!1!==e.enabled&&(0,r.r)(this,"add-to-list-action-selected",{action:e})}constructor(...t){super(...t),this.sections=[]}}d.styles=o.AH`:host{display:block}.section-header{padding:var(--ha-space-2) var(--ha-space-6) var(--ha-space-1);margin:0;font-size:var(--ha-font-size-m);font-weight:var(--ha-font-weight-medium);color:var(--secondary-text-color)}.empty{padding:var(--ha-space-2) var(--ha-space-6) var(--ha-space-1);margin:0;font-size:var(--ha-font-size-m);font-weight:var(--ha-font-weight-normal);color:var(--secondary-text-color)}ha-list-item-button{--ha-row-item-padding-inline:var(--ha-space-5)}ha-icon,ha-svg-icon{display:flex;align-items:center}.start-icon{color:var(--ha-color-text-secondary)}.plus{color:var(--primary-color)}ha-list-item-button[disabled] .plus,ha-list-item-button[disabled] .start-icon{color:var(--disabled-text-color)}`,(0,a.Cg)([(0,s.wk)(),(0,n.IW)()],d.prototype,"_localize",void 0),(0,a.Cg)([(0,s.MZ)({attribute:!1})],d.prototype,"sections",void 0),d=(0,a.Cg)([(0,s.EM)("ha-add-to-action-list")],d)},71706(t,e,i){i.a(t,async function(t,a){try{i.r(e),i.d(e,{DialogDeviceAddTo:()=>$});i(44114);var o=i(62826),s=i(5124),r=i(35211),n=i(22441),d=i(37981),l=i(1087),h=i(14693),c=i(65829),p=i(88249),u=i(22792),m=i(10139),g=i(84025),_=i(34884),v=(i(28180),i(41250)),y=i(14503),b=t([h,c]);[h,c]=b.then?(await b)():b;const f="M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z",w="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",C="M14 10H3V12H14V10M14 6H3V8H14V6M3 16H10V14H3V16M21.5 11.5L23 13L16 20L11.5 15.5L13 14L16 17L21.5 11.5Z",k="M17.5 15.5C17.5 16.61 16.61 17.5 15.5 17.5S13.5 16.61 13.5 15.5 14.4 13.5 15.5 13.5 17.5 14.4 17.5 15.5M8.5 13.5C7.4 13.5 6.5 14.4 6.5 15.5S7.4 17.5 8.5 17.5 10.5 16.61 10.5 15.5 9.61 13.5 8.5 13.5M23 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.73V7H14C17.87 7 21 10.13 21 14H22C22.55 14 23 14.45 23 15M21 16H19V14C19 11.24 16.76 9 14 9H10C7.24 9 5 11.24 5 14V16H3V17H5V20H19V17H21V16Z",x="M15,20A1,1 0 0,0 16,19V4H8A1,1 0 0,0 7,5V16H5V5A3,3 0 0,1 8,2H19A3,3 0 0,1 22,5V6H20V5A1,1 0 0,0 19,4A1,1 0 0,0 18,5V9L18,19A3,3 0 0,1 15,22H5A3,3 0 0,1 2,19V18H13A2,2 0 0,0 15,20M9,6H14V8H9V6M9,10H14V12H9V10M9,14H14V16H9V14Z";class $ extends s.WF{showDialog(t){this._params=t,this._open=!0,!t.newTriggersConditions&&this._api&&this._fetchDeviceAutomations(t)}closeDialog(){this._open=!1}willUpdate(t){super.willUpdate(t),t.has("_api")&&this._api&&this._params&&!this._params.newTriggersConditions&&!this._triggers&&this._fetchDeviceAutomations(this._params)}firstUpdated(t){super.firstUpdated(t),this._i18n.loadBackendTranslation("device_automation")}async _fetchDeviceAutomations(t){const e=t.device.id,[i,a,o]=await Promise.all([(0,m.o9)(this._api.callWS,e),(0,m.ng)(this._api.callWS,e),(0,m.am)(this._api.callWS,e)]);this._triggers=i.sort(m.RK),this._conditions=a.sort(m.RK),this._actions=o.sort(m.RK)}_dialogClosed(){this._params=void 0,this._triggers=void 0,this._conditions=void 0,this._actions=void 0,(0,l.r)(this,"dialog-closed",{dialog:this.localName})}render(){if(!this._params)return s.s6;const t=(0,d.T)(this._params.device,this._i18n.localize,this._states);return s.qy` <ha-adaptive-dialog .open="${this._open}" header-title="${this._i18n.localize("ui.dialogs.more_info_control.add_to.title",{target:t})}" ="${this._dialogClosed}"> ${this._params.newTriggersConditions?this._renderNewOptions():this._renderLegacyOptions()} </ha-adaptive-dialog> `}_renderNewOptions(){if(!this._params)return s.s6;const t=[{title:this._i18n.localize("ui.panel.config.devices.automation.automations_heading"),actions:[{kind:"add-to",key:"automation_trigger",iconPath:k,name:this._i18n.localize("ui.dialogs.more_info_control.add_to.action_options.automation_trigger")},{kind:"add-to",key:"automation_condition",iconPath:C,name:this._i18n.localize("ui.dialogs.more_info_control.add_to.action_options.automation_condition")},{kind:"add-to",key:"automation_action",iconPath:w,name:this._i18n.localize("ui.dialogs.more_info_control.add_to.action_options.automation_action")}]},{title:this._i18n.localize("ui.panel.config.devices.script.scripts_heading"),actions:[{kind:"add-to",key:"script_action",iconPath:x,name:this._i18n.localize("ui.dialogs.more_info_control.add_to.action_options.script_action")}]}];return this._addSceneSection(t),s.qy` <ha-add-to-action-list .sections="${t}" -to-list-action-selected="${this._handleActionSelected}"></ha-add-to-action-list> `}_renderLegacyOptions(){if(!this._triggers&&!this._conditions&&!this._actions)return s.qy` <div class="loading"> <ha-spinner></ha-spinner> </div> `;if(!this._params)return s.s6;const t=Boolean(this._triggers?.length),e=Boolean(this._conditions?.length),i=Boolean(this._actions?.length),a=Boolean(this._params.entityIds.length);if(!(t||e||i||a))return s.qy` <div class="empty"> ${this._i18n.localize("ui.panel.config.devices.automation.no_device_automations")} </div> `;const o=[];t&&o.push({kind:"legacy",legacyType:"trigger",iconPath:k,name:this._i18n.localize("ui.dialogs.more_info_control.add_to.action_options.automation_trigger")}),e&&o.push({kind:"legacy",legacyType:"condition",iconPath:C,name:this._i18n.localize("ui.dialogs.more_info_control.add_to.action_options.automation_condition")}),i&&o.push({kind:"legacy",legacyType:"automation_action",iconPath:w,name:this._i18n.localize("ui.dialogs.more_info_control.add_to.action_options.automation_action")});const r=i?[{kind:"legacy",legacyType:"script_action",iconPath:x,name:this._i18n.localize("ui.dialogs.more_info_control.add_to.action_options.script_action")}]:[],n=[{title:this._i18n.localize("ui.panel.config.devices.automation.automations_heading"),actions:o,empty:o.length?void 0:this._i18n.localize("ui.panel.config.devices.automation.no_automations")},{title:this._i18n.localize("ui.panel.config.devices.script.scripts_heading"),actions:r,empty:r.length?void 0:this._i18n.localize("ui.panel.config.devices.script.no_scripts")}];return this._addSceneSection(n),s.qy` <ha-add-to-action-list .sections="${n}" -to-list-action-selected="${this._handleActionSelected}"></ha-add-to-action-list> `}_addSceneSection(t){this._params?.canCreateScene&&this._params.entityIds.length&&t.push({title:this._i18n.localize("ui.panel.config.devices.scene.scenes_heading"),actions:[{kind:"scene",iconPath:f,name:this._i18n.localize("ui.dialogs.more_info_control.add_to.action_options.scene")}]})}_handleActionSelected(t){if(!this._params)return;const{action:e}=t.detail;"scene"!==e.kind?"add-to"!==e.kind?this._handleLegacyAction(e.legacyType):this._handleAddToAction(e.key):this._handleCreateScene()}_handleAddToAction(t){this._params&&(this.closeDialog(),(0,v.B8)(t,{device_id:this._params.device.id}))}_handleLegacyAction(t){if(this.closeDialog(),"script_action"===t){const t={};return this._actions?.length&&(t.sequence=[this._actions[0]]),void(0,g.AM)(t,!0)}const e={};"trigger"===t&&this._triggers?.length?e.triggers=[this._triggers[0]]:"condition"===t&&this._conditions?.length?e.conditions=[this._conditions[0]]:"automation_action"===t&&this._actions?.length&&(e.actions=[this._actions[0]]),(0,p.mX)(e,!0)}_handleCreateScene(){this._params&&(this.closeDialog(),(0,_.Tx)({entities:(0,v.S6)(this._params.entityIds)}))}static get styles(){return[y.RF,y.nA,s.AH`ha-adaptive-dialog{--dialog-content-padding:0}.empty,.loading{padding:var(--ha-space-4);text-align:center}`]}constructor(...t){super(...t),this._open=!1}}(0,o.Cg)([(0,n.wk)(),(0,r.Fg)({context:u.D5,subscribe:!0})],$.prototype,"_i18n",void 0),(0,o.Cg)([(0,n.wk)(),(0,r.Fg)({context:u.iN,subscribe:!0})],$.prototype,"_states",void 0),(0,o.Cg)([(0,n.wk)(),(0,r.Fg)({context:u.Ie,subscribe:!0})],$.prototype,"_api",void 0),(0,o.Cg)([(0,n.wk)()],$.prototype,"_params",void 0),(0,o.Cg)([(0,n.wk)()],$.prototype,"_open",void 0),(0,o.Cg)([(0,n.wk)()],$.prototype,"_triggers",void 0),(0,o.Cg)([(0,n.wk)()],$.prototype,"_conditions",void 0),(0,o.Cg)([(0,n.wk)()],$.prototype,"_actions",void 0),$=(0,o.Cg)([(0,n.EM)("dialog-device-add-to")],$),a()}catch(t){a(t)}})},1126(t,e,i){i.a(t,async function(t,e){try{var a=i(5124),o=i(22441),s=i(6412),r=i(63672),n=i(17051),d=i(42462),l=i(28438),h=i(98779),c=i(27259),p=i(25877),u=i(31247),m=i(4444),g=i(92070),_=i(9395),v=i(717),y=i(17060),b=i(88496),f=i(57024),w=t([b,y]);[b,y]=w.then?(await w)():w;var C=Object.defineProperty,k=Object.getOwnPropertyDescriptor,x=(t,e,i,a)=>{for(var o,s=a>1?void 0:a?k(e,i):e,r=t.length-1;r>=0;r--)(o=t[r])&&(s=(a?o(e,i,s):o(s))||s);return a&&s&&C(e,i,s),s};let $=class extends v.A{firstUpdated(){a.S$||this.open&&(this.addOpenListeners(),this.drawer.showModal(),(0,m.JG)(this))}disconnectedCallback(){super.disconnectedCallback(),(0,m.I7)(this),this.removeOpenListeners()}async requestClose(t){const e=new l.L({source:t});if(this.dispatchEvent(e),e.defaultPrevented)return this.open=!0,void(0,c.Ud)(this.drawer,"pulse");this.removeOpenListeners(),await(0,c.Ud)(this.drawer,"hide"),this.open=!1,this.drawer.close(),(0,m.I7)(this);const i=this.originalTrigger;"function"==typeof i?.focus&&setTimeout(()=>i.focus()),this.dispatchEvent(new n.Z)}addOpenListeners(){document.addEventListener("keydown",this.handleDocumentKeyDown),(0,p.AZ)(this)}removeOpenListeners(){document.removeEventListener("keydown",this.handleDocumentKeyDown),(0,p.Fw)(this)}handleDialogCancel(t){t.preventDefault(),!this.drawer.classList.contains("hide")&&t.target===this.drawer&&(0,p.a0)(this)&&this.requestClose(this.drawer)}handleDialogClick(t){const e=t.target.closest('[data-drawer="close"]');e&&(t.stopPropagation(),this.requestClose(e))}async handleDialogPointerDown(t){t.target===this.drawer&&(this.lightDismiss?this.requestClose(this.drawer):await(0,c.Ud)(this.drawer,"pulse"))}handleOpenChange(){this.open&&!this.drawer.open?this.show():this.drawer.open&&(this.open=!0,this.requestClose(this.drawer))}async show(){const t=new h.k;this.dispatchEvent(t),t.defaultPrevented?this.open=!1:(this.addOpenListeners(),this.originalTrigger=document.activeElement,this.open=!0,this.drawer.showModal(),(0,m.JG)(this),requestAnimationFrame(()=>{const t=this.querySelector("[autofocus]");t&&"function"==typeof t.focus?t.focus():this.drawer.focus()}),await(0,c.Ud)(this.drawer,"show"),this.dispatchEvent(new d.q))}render(){const t=!this.withoutHeader,e=this.hasUpdated?this.hasSlotController.test("footer"):this.withFooter;return a.qy` <dialog aria-labelledby="${this.ariaLabelledby??"title"}" aria-describedby="${(0,r.J)(this.ariaDescribedby)}" part="dialog" class="${(0,s.H)({drawer:!0,open:this.open,top:"top"===this.placement,end:"end"===this.placement,bottom:"bottom"===this.placement,start:"start"===this.placement})}" ="${this.handleDialogCancel}" ="${this.handleDialogClick}" ="${this.handleDialogPointerDown}"> ${t?a.qy` <header part="header" class="header"> <h2 part="title" class="title" id="title"> <slot name="label"> ${this.label.length>0?this.label:String.fromCharCode(8203)} </slot> </h2> <div part="header-actions" class="header-actions"> <slot name="header-actions"></slot> <wa-button part="close-button" exportparts="base:close-button__base" class="close" appearance="plain" ="${t=>this.requestClose(t.target)}"> <wa-icon name="xmark" label="${this.localize.term("close")}" library="system" variant="solid"></wa-icon> </wa-button> </div> </header> `:""} <div part="body" class="body"><slot></slot></div> ${e?a.qy` <footer part="footer" class="footer"> <slot name="footer"></slot> </footer> `:""} </dialog> `}constructor(){super(...arguments),this.localize=new y.c(this),this.hasSlotController=new g.X(this,"footer","header-actions","label"),this.open=!1,this.label="",this.placement="end",this.withoutHeader=!1,this.lightDismiss=!0,this.withFooter=!1,this.handleDocumentKeyDown=t=>{"Escape"===t.key&&this.open&&(0,p.a0)(this)&&(t.preventDefault(),t.stopPropagation(),this.requestClose(this.drawer))}}};$.css=f.A,x([(0,o.P)(".drawer")],$.prototype,"drawer",2),x([(0,o.MZ)({type:Boolean,reflect:!0})],$.prototype,"open",2),x([(0,o.MZ)({reflect:!0})],$.prototype,"label",2),x([(0,o.MZ)({reflect:!0})],$.prototype,"placement",2),x([(0,o.MZ)({attribute:"without-header",type:Boolean,reflect:!0})],$.prototype,"withoutHeader",2),x([(0,o.MZ)({attribute:"light-dismiss",type:Boolean})],$.prototype,"lightDismiss",2),x([(0,o.MZ)({attribute:"aria-labelledby"})],$.prototype,"ariaLabelledby",2),x([(0,o.MZ)({attribute:"aria-describedby"})],$.prototype,"ariaDescribedby",2),x([(0,o.MZ)({attribute:"with-footer",type:Boolean})],$.prototype,"withFooter",2),x([(0,_.w)("open",{waitUntilFirstUpdate:!0})],$.prototype,"handleOpenChange",1),$=x([(0,o.EM)("wa-drawer")],$),a.S$||(document.addEventListener("click",t=>{const e=t.target.closest("[data-drawer]");if(e instanceof Element){const[t,i]=(0,u.v)(e.getAttribute("data-drawer")||"");if("open"===t&&i?.length){const t=e.getRootNode().getElementById(i);"wa-drawer"===t?.localName?t.open=!0:console.warn(`A drawer with an ID of "${i}" could not be found in this document.`)}}}),document.addEventListener("pointerdown",()=>{})),e()}catch(t){e(t)}})},57024(t,e,i){i.d(e,{A:()=>a});var a=i(5124).AH`:host{--size:25rem;--spacing:var(--wa-space-l);--backdrop-filter:none;--show-duration:200ms;--hide-duration:200ms;display:none}:host([open]){display:block}.drawer{display:flex;flex-direction:column;top:0;inset-inline-start:0;width:100%;height:100%;max-width:100%;max-height:100%;overflow:hidden;color:inherit;background-color:var(--wa-color-surface-raised);border:none;box-shadow:var(--wa-shadow-l);overflow:auto;padding:0;margin:0;animation-duration:var(--show-duration);animation-timing-function:ease}.drawer.show::backdrop{animation:show-backdrop var(--show-duration,200ms) ease}.drawer.hide::backdrop{animation:show-backdrop var(--hide-duration,200ms) ease reverse}.drawer.show.top{animation:show-drawer-from-top var(--show-duration) ease}.drawer.hide.top{animation:show-drawer-from-top var(--hide-duration) ease reverse}.drawer.show.end{animation:show-drawer-from-end var(--show-duration) ease}.drawer.show.end:dir(rtl){animation-name:show-drawer-from-start}.drawer.hide.end{animation:show-drawer-from-end var(--hide-duration) ease reverse}.drawer.hide.end:dir(rtl){animation-name:show-drawer-from-start}.drawer.show.bottom{animation:show-drawer-from-bottom var(--show-duration) ease}.drawer.hide.bottom{animation:show-drawer-from-bottom var(--hide-duration) ease reverse}.drawer.show.start{animation:show-drawer-from-start var(--show-duration) ease}.drawer.show.start:dir(rtl){animation-name:show-drawer-from-end}.drawer.hide.start{animation:show-drawer-from-start var(--hide-duration) ease reverse}.drawer.hide.start:dir(rtl){animation-name:show-drawer-from-end}.drawer.pulse{animation:pulse 250ms ease}.drawer:focus{outline:0}.top{top:0;inset-inline-end:auto;bottom:auto;inset-inline-start:0;width:100%;height:var(--size)}.end{top:0;inset-inline-end:0;bottom:auto;inset-inline-start:auto;width:var(--size);height:100%}.bottom{top:auto;inset-inline-end:auto;bottom:0;inset-inline-start:0;width:100%;height:var(--size)}.start{top:0;inset-inline-end:auto;bottom:auto;inset-inline-start:0;width:var(--size);height:100%}.header{display:flex;flex-wrap:nowrap;padding-inline-start:var(--spacing);padding-block-end:0;padding-inline-end:calc(var(--spacing) - var(--wa-form-control-padding-block));padding-block-start:calc(var(--spacing) - var(--wa-form-control-padding-block))}.title{align-self:center;flex:1 1 auto;font:inherit;font-size:var(--wa-font-size-l);font-weight:var(--wa-font-weight-heading);line-height:var(--wa-line-height-condensed);margin:0}.header-actions{align-self:start;display:flex;flex-shrink:0;flex-wrap:wrap;justify-content:end;gap:var(--wa-space-2xs);padding-inline-start:var(--spacing)}.header-actions ::slotted(wa-button),.header-actions wa-button{flex:0 0 auto;display:flex;align-items:center}.body{flex:1 1 auto;display:block;padding:var(--spacing);overflow:auto;-webkit-overflow-scrolling:touch}.body:focus{outline:0}.body:focus-visible{outline:var(--wa-focus-ring);outline-offset:var(--wa-focus-ring-offset)}.footer{display:flex;flex-wrap:wrap;gap:var(--wa-space-xs);justify-content:end;padding:var(--spacing);padding-block-start:0}.footer ::slotted(wa-button:not(:last-of-type)){margin-inline-end:var(--wa-spacing-xs)}.drawer::backdrop{background-color:var(--wa-color-overlay-modal,rgb(0 0 0 / .25));-webkit-backdrop-filter:var(--backdrop-filter);backdrop-filter:var(--backdrop-filter)} pulse{0%{scale:1}50%{scale:1.01}100%{scale:1}} show-drawer{from{opacity:0;scale:0.8}to{opacity:1;scale:1}} show-drawer-from-top{from{opacity:0;translate:0 -100%}to{opacity:1;translate:0 0}} show-drawer-from-end{from{opacity:0;translate:100%}to{opacity:1;translate:0 0}} show-drawer-from-bottom{from{opacity:0;translate:0 100%}to{opacity:1;translate:0 0}} show-drawer-from-start{from{opacity:0;translate:-100% 0}to{opacity:1;translate:0 0}} show-backdrop{from{opacity:0}to{opacity:1}} (forced-colors:active){.drawer{border:solid 1px #fff}}`}};