iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
37 lines • 26.8 kB
JavaScript
export const __rspack_esm_id=80957;export const __rspack_esm_ids=[80957];export const __webpack_modules__={30716(e,t,a){var i=a(62826),o=a(72274),r=a(34875),s=a(7731),l=a(5124),n=a(22441),d=a(1087);const h=e=>e.preventDefault();var c=a(57237);a(9503);class p extends o.h{async onChange(e){e.stopPropagation(),super.onChange(e),(0,d.r)(this,e.type)}render(){const e=this.renderText(),t=this.graphic&&"control"!==this.graphic&&!this.left?this.renderGraphic():l.s6,a=this.hasMeta&&this.left?this.renderMeta():l.s6,i=this.renderRipple();return l.qy` ${i} ${t} ${this.left?"":e} <ha-checkbox tabindex="${this.separateCheckboxClick?this.tabindex:-1}" .checked="${this.selected}" .indeterminate="${this.indeterminate}" ?disabled="${this.disabled||this.checkboxDisabled}" ="${this.onChange}" ="${this.separateCheckboxClick?c.d:h}" class="${this.left?"left":""}"> </ha-checkbox> ${this.left?e:""} ${a}`}constructor(...e){super(...e),this.checkboxDisabled=!1,this.indeterminate=!1,this.separateCheckboxClick=!1}}p.styles=[s.R,r.R,l.AH`:host{--mdc-theme-secondary:var(--primary-color)}:host([graphic=avatar]) .mdc-deprecated-list-item__graphic,:host([graphic=control]) .mdc-deprecated-list-item__graphic,:host([graphic=large]) .mdc-deprecated-list-item__graphic,:host([graphic=medium]) .mdc-deprecated-list-item__graphic{margin-inline-end:var(--mdc-list-item-graphic-margin,16px);margin-inline-start:0px;direction:var(--direction)}ha-checkbox{flex-shrink:0;direction:var(--direction);margin-inline-start:auto;margin-inline-end:0;height:100%;justify-content:center}ha-checkbox.left{margin-inline-start:0}.mdc-deprecated-list-item__graphic{margin-top:var(--check-list-item-graphic-margin-top)}:host([graphic=icon]) .mdc-deprecated-list-item__graphic{margin-inline-start:0;margin-inline-end:var(--mdc-list-item-graphic-margin,32px)}`],(0,i.Cg)([(0,n.MZ)({type:Boolean,attribute:"checkbox-disabled"})],p.prototype,"checkboxDisabled",void 0),(0,i.Cg)([(0,n.MZ)({type:Boolean})],p.prototype,"indeterminate",void 0),(0,i.Cg)([(0,n.MZ)({type:Boolean,attribute:"separate-checkbox-click"})],p.prototype,"separateCheckboxClick",void 0),p=(0,i.Cg)([(0,n.EM)("ha-check-list-item")],p)},9503(e,t,a){var i=a(62826),o=a(97577),r=a(5124),s=a(22441);class l extends o.A{get value(){return this._value??null}set value(e){this._value=e}static get styles(){return[o.A.styles,r.AH`:host{--wa-form-control-toggle-size:var(--ha-checkbox-size, 20px);--wa-form-control-border-color:var(
--ha-checkbox-border-color,
var(--ha-color-border-neutral-normal)
);--wa-form-control-background-color:var(
--ha-checkbox-background-color,
var(--wa-form-control-background-color)
);--checked-icon-color:var(
--ha-checkbox-checked-icon-color,
var(--wa-color-brand-on-loud)
);--wa-form-control-activated-color:var(
--ha-checkbox-checked-background-color,
var(--ha-color-fill-primary-loud-resting)
);-webkit-tap-highlight-color:transparent;--checked-icon-scale:var(--ha-checkbox-checked-icon-scale, 0.9);--wa-form-control-required-content:var(
--ha-checkbox-required-marker,
var(--ha-input-required-marker, "*")
);--wa-form-control-required-content-offset:var(
--ha-checkbox-required-marker-offset,
0.1rem
)}[part~=base]{align-items:center;gap:var(--ha-space-2)}[part~=control]{border-radius:var(--ha-checkbox-border-radius,var(--ha-border-radius-sm));border-width:var(--ha-checkbox-border-width,var(--ha-border-width-md));margin-inline-end:0}[part~=label]{line-height:1}#hint{font-size:var(--ha-font-size-xs);color:var(--ha-color-text-secondary)}label:has(input:not(:disabled)):hover{--wa-form-control-border-color:var(
--ha-checkbox-border-color-hover,
var(--ha-checkbox-border-color, var(--ha-color-border-neutral-loud))
)}label:has(input:not(:disabled)):hover [part~=control]{background-color:var(--ha-checkbox-background-color-hover,var(--ha-color-form-background-hover))}label:has(input:checked:not(:disabled)):hover [part~=control],label:has(input:indeterminate:not(:disabled)):hover [part~=control]{background-color:var(--ha-checkbox-checked-background-color-hover,var(--ha-color-fill-primary-loud-hover));border-color:var(--ha-checkbox-checked-background-color-hover,var(--ha-color-fill-primary-loud-hover))}`]}}l=(0,i.Cg)([(0,s.EM)("ha-checkbox")],l)},93444(e,t,a){var i=a(62826),o=a(5124),r=a(22441);class s extends o.WF{render(){return o.qy` <footer> <slot name="secondaryAction"></slot> <slot name="primaryAction"></slot> </footer> `}static get styles(){return[o.AH`footer{display:flex;gap:var(--ha-space-3);justify-content:flex-end;align-items:center;width:100%}`]}}s=(0,i.Cg)([(0,r.EM)("ha-dialog-footer")],s)},76538(e,t,a){var i=a(62826),o=a(5124),r=a(22441);class s extends o.WF{render(){const e=o.qy`<div class="header-title"> <slot name="title"></slot> </div>`,t=o.qy`<div class="header-subtitle"> <slot name="subtitle"></slot> </div>`;return o.qy` <header class="header"> <div class="header-bar"> <section class="header-navigation-icon"> <slot name="navigationIcon"></slot> </section> <section class="header-content"> ${"above"===this.subtitlePosition?o.qy`${t}${e}`:o.qy`${e}${t}`} </section> <section class="header-action-items"> <slot name="actionItems"></slot> </section> </div> <slot></slot> </header> `}static get styles(){return[o.AH`:host{display:block}:host([show-border]){border-bottom:1px solid var(--mdc-dialog-scroll-divider-color,rgba(0,0,0,.12))}.header-bar{display:flex;flex-direction:row;align-items:center;padding:0 var(--ha-space-1);box-sizing:border-box}.header-content{flex:1;padding:10px var(--ha-space-1);display:flex;flex-direction:column;justify-content:center;min-height:var(--ha-space-12);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.header-title{height:var(--ha-dialog-header-title-height,calc(var(--ha-font-size-xl) + var(--ha-space-1)));font-size:var(--ha-font-size-xl);line-height:var(--ha-line-height-condensed);font-weight:var(--ha-font-weight-medium);color:var(--ha-dialog-header-title-color,var(--primary-text-color))}.header-subtitle{font-size:var(--ha-font-size-m);line-height:var(--ha-line-height-normal);color:var(--ha-dialog-header-subtitle-color,var(--secondary-text-color))} all and (min-width:450px) and (min-height:500px){.header-bar{padding:0 var(--ha-space-2)}}.header-navigation-icon{flex:none;min-width:var(--ha-space-2);height:100%;display:flex;flex-direction:row}.header-action-items{flex:none;min-width:var(--ha-space-2);height:100%;display:flex;flex-direction:row}`]}constructor(...e){super(...e),this.subtitlePosition="below",this.showBorder=!1}}(0,i.Cg)([(0,r.MZ)({type:String,attribute:"subtitle-position"})],s.prototype,"subtitlePosition",void 0),(0,i.Cg)([(0,r.MZ)({type:Boolean,reflect:!0,attribute:"show-border"})],s.prototype,"showBorder",void 0),s=(0,i.Cg)([(0,r.EM)("ha-dialog-header")],s)},72554(e,t,a){a.a(e,async function(e,t){try{var i=a(62826),o=a(93900),r=a(35211),s=a(5124),l=a(22441),n=a(63672),d=a(1087),h=a(64481),c=a(22792),p=a(59992),g=a(14503),m=a(22348),u=(a(76538),a(26300)),v=e([o,u]);[o,u]=v.then?(await v)():v;const f="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";class b extends((0,p.V)(s.WF)){connectedCallback(){super.connectedCallback(),this.addEventListener("dialog-set-fullscreen",this._handleFullscreenChanged)}get scrollableElement(){return this.bodyContainer}updated(e){super.updated(e),e.has("open")&&(this._open=this.open)}render(){return s.qy` <wa-dialog .open="${this._open}" .lightDismiss="${!this.preventScrimClose}" without-header aria-labelledby="${(0,n.J)(this.ariaLabelledBy||(void 0!==this.headerTitle?"ha-dialog-title":void 0))}" aria-describedby="${(0,n.J)(this.ariaDescribedBy)}" ="${this._handleKeyDown}" -hide="${this._handleHide}" -show="${this._handleShow}" -after-show="${this._handleAfterShow}" -after-hide="${this._handleAfterHide}"> ${this.withoutHeader?s.s6:s.qy`<slot name="header"> <ha-dialog-header .subtitlePosition="${this.headerSubtitlePosition}" .showBorder="${this._bodyScrolled}"> <slot name="headerNavigationIcon" slot="navigationIcon"> <ha-icon-button data-dialog="close" .label="${this._i18n?.localize?.("ui.common.close")??"Close"}" .path="${f}"></ha-icon-button> </slot> ${void 0!==this.headerTitle?s.qy`<span slot="title" class="title" id="ha-dialog-title"> ${this.headerTitle} </span>`:s.qy`<slot name="headerTitle" slot="title"></slot>`} ${void 0!==this.headerSubtitle?s.qy`<span slot="subtitle">${this.headerSubtitle}</span>`:s.qy`<slot name="headerSubtitle" slot="subtitle"></slot>`} <slot name="headerActionItems" slot="actionItems"></slot> </ha-dialog-header> </slot>`} <div class="content-wrapper"> <div class="body ha-scrollbar" ="${this._handleBodyScroll}"> <slot></slot> </div> ${this.renderScrollableFades()} </div> <slot name="footer" slot="footer"></slot> </wa-dialog> `}disconnectedCallback(){this.removeEventListener("dialog-set-fullscreen",this._handleFullscreenChanged),this._setFullscreen(!1),super.disconnectedCallback(),this._open=!1}_handleFullscreenChanged(e){this._open?(0,h.J)(()=>{this._setFullscreen(e.detail)}):this._setFullscreen(e.detail)}_setFullscreen(e){this.toggleAttribute("fullscreen",e)}_handleBodyScroll(e){this._bodyScrolled=e.target.scrollTop>0}_handleKeyDown(e){"Escape"===e.key&&(this._escapePressed=!0,this.preventScrimClose&&e.preventDefault(),e.stopPropagation(),e.currentTarget.open=!1)}_handleHide(e){const t=e.detail?.source===e.target.dialog;this.preventScrimClose&&this._escapePressed&&t&&e.preventDefault(),this._escapePressed=!1}static get styles(){return[...super.styles,g.dp,s.AH`wa-dialog{--full-width:var(
--ha-dialog-width-full,
min(95vw, var(--safe-width))
);--width:min(var(--ha-dialog-width-md, 580px), var(--full-width));--spacing:var(--dialog-content-padding, var(--ha-space-6));--show-duration:var(--ha-dialog-show-duration, 200ms);--hide-duration:var(--ha-dialog-hide-duration, 200ms);--wa-color-surface-raised:var(
--ha-dialog-surface-background,
var(--card-background-color, var(--ha-color-surface-default))
);--wa-panel-border-radius:var(
--ha-dialog-border-radius,
var(--ha-border-radius-3xl)
);max-width:var(--ha-dialog-max-width,var(--safe-width))} (prefers-reduced-motion:reduce){wa-dialog{--show-duration:0ms;--hide-duration:0ms}}:host([width=small]) wa-dialog{--width:min(var(--ha-dialog-width-sm, 320px), var(--full-width))}:host([width=large]) wa-dialog{--width:min(var(--ha-dialog-width-lg, 1024px), var(--full-width))}:host([fullscreen]) wa-dialog,:host([width=full]) wa-dialog{--width:var(--full-width)}:host([fullscreen]) wa-dialog::part(dialog){min-height:var(--safe-height);max-height:var(--safe-height);margin-top:0;transform:none}:host([fullscreen]) .content-wrapper{overflow:hidden}:host([fullscreen]) .body{overflow:hidden;padding:0}wa-dialog::part(dialog){-webkit-backdrop-filter:var(--ha-dialog-surface-backdrop-filter,none);backdrop-filter:var(--ha-dialog-surface-backdrop-filter,none);box-shadow:var(--dialog-box-shadow,var(--wa-shadow-l));color:var(--primary-text-color);min-width:var(--width,var(--full-width));max-width:var(--width,var(--full-width));max-height:var(--ha-dialog-max-height,calc(var(--safe-height) - var(--ha-space-20)));min-height:var(--ha-dialog-min-height);margin-top:var(--dialog-surface-margin-top,auto);transform:translate(calc(var(--safe-area-offset-left,0px) - var(--safe-area-offset-right,0px)),calc(var(--safe-area-offset-top,0px) - var(--safe-area-offset-bottom,0px)));display:flex;flex-direction:column;overflow:hidden}wa-dialog::part(dialog)::backdrop{-webkit-backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none));backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter,none));background-color:var(--mdc-dialog-scrim-color,none)} all and (max-width:450px),all and (max-height:500px){:host([type=standard]){--ha-dialog-border-radius:0}:host([type=standard]) wa-dialog{--full-width:var(--ha-dialog-width-full, 100vw);--width:var(--full-width)}:host([type=standard]) wa-dialog::part(dialog){min-height:var(--ha-dialog-min-height,100vh);min-height:var(--ha-dialog-min-height,100dvh);max-height:var(--ha-dialog-max-height,100vh);max-height:var(--ha-dialog-max-height,100dvh);margin-top:0;margin-bottom:0;padding-top:var(--safe-area-inset-top);padding-bottom:var(--safe-area-inset-bottom);padding-left:var(--safe-area-inset-left);padding-right:var(--safe-area-inset-right);transform:none}}.header-title-container{display:flex;align-items:center}.header-title{margin:0;margin-bottom:0;color:var(--ha-dialog-header-title-color,var(--primary-text-color));font-size:var(
--ha-dialog-header-title-font-size,
var(--ha-font-size-2xl)
);line-height:var(
--ha-dialog-header-title-line-height,
var(--ha-line-height-condensed)
);font-weight:var(--ha-dialog-header-title-font-weight,var(--ha-font-weight-normal));overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-right:var(--ha-space-3)}wa-dialog::part(body){padding:0;display:flex;flex-direction:column;max-width:100%;overflow:hidden}.content-wrapper{position:relative;flex:1;display:flex;flex-direction:column;min-height:0}.body{position:var(--dialog-content-position,relative);padding:var(--dialog-content-padding,0 var(--ha-space-6) var(--ha-space-6) var(--ha-space-6));overflow:auto;flex-grow:1}:host([flexcontent]) .body{max-width:100%;flex:1;display:flex;flex-direction:column}wa-dialog::part(footer){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%}`]}constructor(...e){super(...e),this.open=!1,this.type="standard",this.width="medium",this.preventScrimClose=!1,this.headerSubtitlePosition="below",this.flexContent=!1,this.withoutHeader=!1,this._open=!1,this._bodyScrolled=!1,this._escapePressed=!1,this._handleShow=async e=>{e.eventPhase===Event.AT_TARGET&&(this._open=!0,(0,d.r)(this,"opened"),await this.updateComplete,requestAnimationFrame(()=>{if(this._hassConfig?.auth.external&&(0,m.V)(this._hassConfig.auth.external)){const e=this.querySelector("[autofocus]");return void(null!==e&&(e.id||(e.id="ha-dialog-autofocus"),this._hassConfig.auth.external.fireMessage({type:"focus_element",payload:{element_id:e.id}})))}this.querySelector("[autofocus]")?.focus()}))},this._handleAfterShow=e=>{e.eventPhase===Event.AT_TARGET&&(0,d.r)(this,"after-show")},this._handleAfterHide=e=>{e.eventPhase===Event.AT_TARGET&&(this._open=!1,this._setFullscreen(!1),(0,d.r)(this,"closed"))}}}(0,i.Cg)([(0,l.MZ)({attribute:"aria-labelledby"})],b.prototype,"ariaLabelledBy",void 0),(0,i.Cg)([(0,l.MZ)({attribute:"aria-describedby"})],b.prototype,"ariaDescribedBy",void 0),(0,i.Cg)([(0,l.MZ)({type:Boolean,reflect:!0})],b.prototype,"open",void 0),(0,i.Cg)([(0,l.MZ)({reflect:!0})],b.prototype,"type",void 0),(0,i.Cg)([(0,l.MZ)({type:String,reflect:!0,attribute:"width"})],b.prototype,"width",void 0),(0,i.Cg)([(0,l.MZ)({type:Boolean,reflect:!0,attribute:"prevent-scrim-close"})],b.prototype,"preventScrimClose",void 0),(0,i.Cg)([(0,l.MZ)({attribute:"header-title"})],b.prototype,"headerTitle",void 0),(0,i.Cg)([(0,l.MZ)({attribute:"header-subtitle"})],b.prototype,"headerSubtitle",void 0),(0,i.Cg)([(0,l.MZ)({type:String,attribute:"header-subtitle-position"})],b.prototype,"headerSubtitlePosition",void 0),(0,i.Cg)([(0,l.MZ)({type:Boolean,reflect:!0,attribute:"flexcontent"})],b.prototype,"flexContent",void 0),(0,i.Cg)([(0,l.MZ)({type:Boolean,attribute:"without-header"})],b.prototype,"withoutHeader",void 0),(0,i.Cg)([(0,l.wk)()],b.prototype,"_open",void 0),(0,i.Cg)([(0,l.P)(".body")],b.prototype,"bodyContainer",void 0),(0,i.Cg)([(0,l.wk)(),(0,r.Fg)({context:c.D5,subscribe:!0})],b.prototype,"_i18n",void 0),(0,i.Cg)([(0,l.wk)(),(0,r.Fg)({context:c.WF,subscribe:!0})],b.prototype,"_hassConfig",void 0),(0,i.Cg)([(0,l.wk)()],b.prototype,"_bodyScrolled",void 0),(0,i.Cg)([(0,l.Ls)({passive:!0})],b.prototype,"_handleBodyScroll",null),b=(0,i.Cg)([(0,l.EM)("ha-dialog")],b),t()}catch(e){t(e)}})},67505(e,t,a){var i=a(62826),o=a(5124),r=a(22441),s=a(93421);a(67094);class l extends o.WF{render(){return this._localize?o.qy` <ha-svg-icon .path="${"M12,2A7,7 0 0,1 19,9C19,11.38 17.81,13.47 16,14.74V17A1,1 0 0,1 15,18H9A1,1 0 0,1 8,17V14.74C6.19,13.47 5,11.38 5,9A7,7 0 0,1 12,2M9,21V20H15V21A1,1 0 0,1 14,22H10A1,1 0 0,1 9,21M12,4A5,5 0 0,0 7,9C7,11.05 8.23,12.81 10,13.58V16H14V13.58C15.77,12.81 17,11.05 17,9A5,5 0 0,0 12,4Z"}"></ha-svg-icon> <span class="prefix">${this._localize("ui.panel.config.tips.tip")}</span> <span class="text"><slot></slot></span> `:o.s6}}l.styles=o.AH`:host{display:block;text-align:center}.text{direction:var(--direction);margin-left:2px;margin-inline-start:2px;margin-inline-end:initial;color:var(--secondary-text-color)}.prefix{font-weight:var(--ha-font-weight-medium)}`,(0,i.Cg)([(0,r.wk)(),(0,s.IW)()],l.prototype,"_localize",void 0),l=(0,i.Cg)([(0,r.EM)("ha-tip")],l)},71084(e,t,a){a.a(e,async function(e,i){try{a.r(t);a(44114),a(18111),a(22489),a(7588),a(17642),a(58004),a(33853),a(45876),a(32475),a(15024),a(31698);var o=a(62826),r=a(7364),s=a(5124),l=a(22441),n=a(75751),d=a(36312),h=a(1087),c=a(3129),p=a(53072),g=a(17022),m=a(65063),u=a(18350),v=(a(30716),a(72554)),f=(a(93444),a(76538),a(26300)),b=(a(8630),a(65829)),_=(a(67094),a(67505),a(45098)),w=a(62176),y=e([u,v,f,b,_,w]);[u,v,f,b,_,w]=y.then?(await y)():y;const x="M19,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,3M19,5V19H5V5H19Z",k="M19,19H5V5H15V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V11H19M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z",C="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",$="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z";class A extends s.WF{showDialog(e){this._params=e,this._refreshMedia(),this._open=!0}closeDialog(){return this._open=!1,!0}_dialogClosed(){this._filesChanged&&this._params.onClose&&this._params.onClose(),this._params=void 0,this._currentItem=void 0,this._uploading=!1,this._deleting=!1,this._filesChanged=!1,(0,h.r)(this,"dialog-closed",{dialog:this.localName})}willUpdate(){this._filteredChildren=this._currentItem?.children?.filter(e=>!e.can_expand)||[],0===this._filteredChildren.length&&0!==this._selected.size&&(this._selected=new Set)}render(){if(!this._params)return s.s6;let e=0;return s.qy` <ha-dialog .open="${this._open}" ?prevent-scrim-close="${this._uploading||this._deleting}" ="${this._dialogClosed}"> <ha-dialog-header slot="header"> ${this._uploading||this._deleting?s.s6:s.qy`<slot name="headerNavigationIcon" slot="navigationIcon"> <ha-icon-button data-dialog="close" .label="${this.hass?.localize("ui.common.close")??"Close"}" .path="${C}"></ha-icon-button></slot>`} <h1 class="title" slot="title" id="dialog-box-title"> ${this.hass.localize("ui.components.media-browser.file_management.title")} </h1> ${0===this._selected.size?s.qy`<ha-media-upload-button .hass="${this.hass}" .currentItem="${this._params.currentItem}" ="${this._startUploading}" -refresh="${this._doneUploading}" slot="actionItems"></ha-media-upload-button>`:s.qy`<ha-button variant="danger" slot="actionItems" .disabled="${this._deleting}" ="${this._handleDelete}"> <ha-svg-icon .path="${$}" slot="start"></ha-svg-icon> ${this.hass.localize("ui.components.media-browser.file_management."+(this._deleting?"deleting":"delete"),{count:this._selected.size})} </ha-button>`} </ha-dialog-header> ${this._currentItem?this._filteredChildren.length?s.qy` <div class="buttons" slot="footer"> <ha-button appearance="filled" ="${this._handleDeselectAll}" .disabled="${0===this._selected.size}"> <ha-svg-icon .path="${x}" slot="start"></ha-svg-icon> ${this.hass.localize("ui.components.media-browser.file_management.deselect_all")} </ha-button> <ha-button appearance="filled" ="${this._handleSelectAll}" .disabled="${this._selected.size===this._filteredChildren.length}"> <ha-svg-icon .path="${k}" slot="start"></ha-svg-icon> ${this.hass.localize("ui.components.media-browser.file_management.select_all")} </ha-button> </div> <ha-list multi ="${this._handleSelected}"> ${(0,n.u)(this._filteredChildren,e=>e.media_content_id,t=>{const a=s.qy` <ha-svg-icon slot="graphic" .path="${p.EC["directory"===t.media_class&&t.children_media_class||t.media_class].icon}"></ha-svg-icon> `;return s.qy` <ha-check-list-item ${(0,r.i0)({id:t.media_content_id,skipInitial:!0})} graphic="icon" .disabled="${this._uploading||this._deleting}" .selected="${this._selected.has(e++)}" .item="${t}"> ${a} ${t.title} </ha-check-list-item> `})} </ha-list> `:s.qy`<div class="no-items"> <p> ${this.hass.localize("ui.components.media-browser.file_management.no_items")} </p> ${this._currentItem?.children?.length?s.qy`<span class="folders">${this.hass.localize("ui.components.media-browser.file_management.folders_not_supported")}</span>`:""} </div>`:s.qy` <div class="refresh"> <ha-spinner></ha-spinner> </div> `} ${(0,d.x)(this.hass.config,"hassio")?s.qy`<ha-tip> ${this.hass.localize("ui.components.media-browser.file_management.tip_media_storage",{storage:s.qy`<a href="/config/storage" ="${this.closeDialog}"> ${this.hass.localize("ui.components.media-browser.file_management.tip_storage_panel")}</a>`})} </ha-tip>`:s.s6} </ha-dialog> `}_handleSelected(e){this._selected=e.detail.index}_startUploading(){this._uploading=!0,this._filesChanged=!0}_doneUploading(){this._uploading=!1,this._refreshMedia()}_handleDeselectAll(){this._selected.size&&(this._selected=new Set)}_handleSelectAll(){this._selected=new Set([...Array(this._filteredChildren.length).keys()])}async _handleDelete(){if(!await(0,m.dk)(this,{text:this.hass.localize("ui.components.media-browser.file_management.confirm_delete",{count:this._selected.size}),warning:!0}))return;this._filesChanged=!0,this._deleting=!0;const e=[];let t=0;this._currentItem.children.forEach(a=>{a.can_expand||this._selected.has(t++)&&e.push(a)});try{await Promise.all(e.map(async e=>{if((0,g.Jz)(e.media_content_id))await(0,g.WI)(this.hass,e.media_content_id);else if((0,g.iY)(e.media_content_id)){const t=(0,c.pD)(e.media_content_id);t&&await(0,c.vS)(this.hass,t)}this._currentItem={...this._currentItem,children:this._currentItem.children.filter(t=>t!==e)}}))}finally{this._deleting=!1,this._selected=new Set}}async _refreshMedia(){this._selected=new Set,this._currentItem=void 0,this._currentItem=await(0,g.Fn)(this.hass,this._params.currentItem.media_content_id)}static get styles(){return[s.AH`ha-dialog{--dialog-content-padding:0}ha-dialog-header ha-button,ha-dialog-header ha-media-upload-button{--mdc-theme-primary:var(--primary-text-color);margin:6px;display:block}ha-tip{margin:16px}.refresh{display:flex;height:200px;justify-content:center;align-items:center}.buttons{display:flex;justify-content:center;width:100%}.no-items{text-align:center;padding:16px}.folders{color:var(--secondary-text-color);font-style:italic}.title{font:inherit;font-size:inherit;margin:inherit}`]}constructor(...e){super(...e),this._uploading=!1,this._deleting=!1,this._selected=new Set,this._open=!1,this._filteredChildren=[],this._filesChanged=!1}}(0,o.Cg)([(0,l.MZ)({attribute:!1})],A.prototype,"hass",void 0),(0,o.Cg)([(0,l.wk)()],A.prototype,"_currentItem",void 0),(0,o.Cg)([(0,l.wk)()],A.prototype,"_params",void 0),(0,o.Cg)([(0,l.wk)()],A.prototype,"_uploading",void 0),(0,o.Cg)([(0,l.wk)()],A.prototype,"_deleting",void 0),(0,o.Cg)([(0,l.wk)()],A.prototype,"_selected",void 0),(0,o.Cg)([(0,l.wk)()],A.prototype,"_open",void 0),(0,o.Cg)([(0,l.wk)()],A.prototype,"_filteredChildren",void 0),A=(0,o.Cg)([(0,l.EM)("dialog-media-manage")],A),i()}catch(e){i(e)}})},62176(e,t,a){a.a(e,async function(e,t){try{var i=a(62826),o=a(5124),r=a(22441),s=a(1087),l=a(17022),n=a(65063),d=a(18350),h=(a(67094),e([d]));d=(h.then?(await h)():h)[0];const c="M9,16V10H5L12,3L19,10H15V16H9M5,20V18H19V20H5Z";class p extends o.WF{render(){return this.currentItem&&(0,l.Jz)(this.currentItem.media_content_id||"")?o.qy` <ha-button .disabled="${this._uploading>0}" ="${this._startUpload}" .loading="${this._uploading>0}"> <ha-svg-icon .path="${c}" slot="start"></ha-svg-icon> ${this._uploading>0?this.hass.localize("ui.components.media-browser.file_management.uploading",{count:this._uploading}):this.hass.localize("ui.components.media-browser.file_management.add_media")} </ha-button> `:o.s6}async _startUpload(){if(this._uploading>0)return;const e=document.createElement("input");e.type="file",e.accept="audio/*,video/*,image/*",e.multiple=!0,e.addEventListener("change",async()=>{(0,s.r)(this,"uploading");const t=e.files;document.body.removeChild(e);const a=this.currentItem.media_content_id;for(let e=0;e<t.length;e++){this._uploading=t.length-e;try{await(0,l.VA)(this.hass,a,t[e])}catch(e){(0,n.showAlertDialog)(this,{text:this.hass.localize("ui.components.media-browser.file_management.upload_failed",{reason:e.message||e})});break}}this._uploading=0,(0,s.r)(this,"media-refresh")},{once:!0}),e.style.display="none",document.body.append(e),e.click()}constructor(...e){super(...e),this._uploading=0}}(0,i.Cg)([(0,r.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,i.Cg)([(0,r.MZ)({attribute:!1})],p.prototype,"currentItem",void 0),(0,i.Cg)([(0,r.wk)()],p.prototype,"_uploading",void 0),p=(0,i.Cg)([(0,r.EM)("ha-media-upload-button")],p),t()}catch(e){t(e)}})},3129(e,t,a){a.d(t,{AP:()=>o,M5:()=>d,Q0:()=>s,mF:()=>l,pD:()=>r,vS:()=>n});const i="/api/image/serve/",o="media-source://image_upload",r=e=>{let t;if(e.startsWith(i)){t=e.substring(17);const a=t.indexOf("/");a>=0&&(t=t.substring(0,a))}else e.startsWith(o)&&(t=e.substring(o.length+1));return t},s=(e,t,a=!1)=>{if(!a&&!t)throw new Error("Size must be provided if original is false");return a?`/api/image/serve/${e}/original`:`/api/image/serve/${e}/${t}x${t}`},l=async(e,t)=>{const a=new FormData;a.append("file",t);const i=await e.fetchWithAuth("/api/image/upload",{method:"POST",body:a});if(413===i.status)throw new Error(`Uploaded image is too large (${t.name})`);if(200!==i.status)throw new Error("Unknown error");return i.json()},n=(e,t)=>e.callWS({type:"image/delete",image_id:t}),d=async(e,t)=>{const a=await fetch(e.hassUrl(t));if(!a.ok)throw new Error(`Failed to fetch image: ${a.statusText?a.statusText:a.status}`);return a.blob()}}};