UNPKG

iobroker.lovelace

Version:

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

3 lines 32.2 kB
export const __rspack_esm_id=90681;export const __rspack_esm_ids=[90681];export const __webpack_modules__={21016(e,t,i){i.d(t,{Pu:()=>a,SB:()=>l,mk:()=>n,r1:()=>s});const s=e=>e.callWS({type:"counter/list"}),a=(e,t)=>e.callWS({type:"counter/create",...t}),n=(e,t,i)=>e.callWS({type:"counter/update",counter_id:t,...i}),l=(e,t)=>e.callWS({type:"counter/delete",counter_id:t})},41656(e,t,i){i.d(t,{n:()=>p});var s=i(21016),a=i(2279),n=i(42575),l=i(77738),o=i(6922),r=i(33687),h=i(12284),c=i(2247),d=i(49141);const p={input_boolean:{fetch:a.tT,update:a.iE,delete:a.e1},input_button:{fetch:n.vF,update:n.mC,delete:n.C1},input_text:{fetch:h.MG,update:h.BJ,delete:h.d_},input_number:{fetch:o.kF,update:o.Tv,delete:o.$I},input_datetime:{fetch:l.a2,update:l.fJ,delete:l.Bj},input_select:{fetch:r.HV,update:r.EJ,delete:r.O3},counter:{fetch:s.r1,update:s.mk,delete:s.SB},timer:{fetch:d.kL,update:d.r9,delete:d.pZ},schedule:{fetch:c.YA,update:c.Fs,delete:c.VD}}},2279(e,t,i){i.d(t,{e1:()=>l,iE:()=>n,nr:()=>a,tT:()=>s});const s=e=>e.callWS({type:"input_boolean/list"}),a=(e,t)=>e.callWS({type:"input_boolean/create",...t}),n=(e,t,i)=>e.callWS({type:"input_boolean/update",input_boolean_id:t,...i}),l=(e,t)=>e.callWS({type:"input_boolean/delete",input_boolean_id:t})},42575(e,t,i){i.d(t,{C1:()=>l,L6:()=>a,mC:()=>n,vF:()=>s});const s=e=>e.callWS({type:"input_button/list"}),a=(e,t)=>e.callWS({type:"input_button/create",...t}),n=(e,t,i)=>e.callWS({type:"input_button/update",input_button_id:t,...i}),l=(e,t)=>e.callWS({type:"input_button/delete",input_button_id:t})},77738(e,t,i){i.d(t,{Bj:()=>r,TB:()=>a,a2:()=>n,fJ:()=>o,ke:()=>l,rv:()=>s});const s=e=>`${e.attributes.year||"1970"}-${String(e.attributes.month||"01").padStart(2,"0")}-${String(e.attributes.day||"01").padStart(2,"0")}T${String(e.attributes.hour||"00").padStart(2,"0")}:${String(e.attributes.minute||"00").padStart(2,"0")}:${String(e.attributes.second||"00").padStart(2,"0")}`,a=(e,t,i=void 0,s=void 0)=>{const a={entity_id:t,time:i,date:s};e.callService("input_datetime","set_datetime",a)},n=e=>e.callWS({type:"input_datetime/list"}),l=(e,t)=>e.callWS({type:"input_datetime/create",...t}),o=(e,t,i)=>e.callWS({type:"input_datetime/update",input_datetime_id:t,...i}),r=(e,t)=>e.callWS({type:"input_datetime/delete",input_datetime_id:t})},6922(e,t,i){i.d(t,{$I:()=>l,Tv:()=>n,gO:()=>a,kF:()=>s});const s=e=>e.callWS({type:"input_number/list"}),a=(e,t)=>e.callWS({type:"input_number/create",...t}),n=(e,t,i)=>e.callWS({type:"input_number/update",input_number_id:t,...i}),l=(e,t)=>e.callWS({type:"input_number/delete",input_number_id:t})},33687(e,t,i){i.d(t,{BT:()=>n,EJ:()=>l,HV:()=>a,MZ:()=>s,O3:()=>o});const s=(e,t,i)=>e.callService("input_select","select_option",{option:i,entity_id:t}),a=e=>e.callWS({type:"input_select/list"}),n=(e,t)=>e.callWS({type:"input_select/create",...t}),l=(e,t,i)=>e.callWS({type:"input_select/update",input_select_id:t,...i}),o=(e,t)=>e.callWS({type:"input_select/delete",input_select_id:t})},12284(e,t,i){i.d(t,{BJ:()=>l,KY:()=>s,MG:()=>a,d_:()=>o,m4:()=>n});const s=(e,t,i)=>e.callService(t.split(".",1)[0],"set_value",{value:i,entity_id:t}),a=e=>e.callWS({type:"input_text/list"}),n=(e,t)=>e.callWS({type:"input_text/create",...t}),l=(e,t,i)=>e.callWS({type:"input_text/update",input_text_id:t,...i}),o=(e,t)=>e.callWS({type:"input_text/delete",input_text_id:t})},2247(e,t,i){i.d(t,{Fs:()=>l,VD:()=>o,YA:()=>a,mx:()=>s,sF:()=>n});const s=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],a=e=>e.callWS({type:"schedule/list"}),n=(e,t)=>e.callWS({type:"schedule/create",...t}),l=(e,t,i)=>e.callWS({type:"schedule/update",schedule_id:t,...i}),o=(e,t)=>e.callWS({type:"schedule/delete",schedule_id:t})},77555(e,t,i){i.a(e,async function(e,s){try{i.r(t),i.d(t,{HaConfigHelpers:()=>Ce});i(74423),i(44114),i(18111),i(81148),i(22489),i(20116),i(7588),i(61701),i(13579),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(14603),i(47566),i(98721);var a=i(62826),n=(i(68825),i(88696)),l=i(35211),o=i(5124),r=i(22441),h=i(22786),c=i(36312),d=i(93905),p=i(65522),_=i(69093),u=i(91926),g=i(6030),y=i(9899),f=i(87710),b=i(86171),m=i(18350),v=i(29823),w=(i(70947),i(41113)),C=i(52190),$=i(66702),k=i(72644),E=i(138),S=i(2617),x=(i(47680),i(75248)),A=i(93367),H=(i(67094),i(34127)),L=i(82e3),z=i(76570),F=i(77423),M=i(26571),W=i(22792),V=i(96204),I=i(59241),O=i(6810),q=i(14782),B=i(41656),P=i(95350),Z=i(92557),D=i(77763),j=i(70241),R=i(65063),T=i(42269),U=i(23296),G=i(72553),J=i(54706),N=i(14503),Q=i(30039),Y=i(55270),K=i(90986),X=i(29303),ee=i(25635),te=i(87599),ie=i(5317),se=i(69569),ae=i(94017),ne=i(19661),le=i(24367),oe=i(19711),re=e([b,m,v,w,C,$,k,E,S,x,A,H,U,G,ie,te,X,ae]);[b,m,v,w,C,$,k,E,S,x,A,H,U,G,ie,te,X,ae]=re.then?(await re)():re;const he="M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z",ce="M12 2C17.5 2 22 6.5 22 12S17.5 22 12 22 2 17.5 2 12 6.5 2 12 2M12 4C10.1 4 8.4 4.6 7.1 5.7L18.3 16.9C19.3 15.5 20 13.8 20 12C20 7.6 16.4 4 12 4M16.9 18.3L5.7 7.1C4.6 8.4 4 10.1 4 12C4 16.4 7.6 20 12 20C13.9 20 15.6 19.4 16.9 18.3Z",de="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z",pe="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",_e="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",ue="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z",ge="M7,10L12,15L17,10H7Z",ye="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",fe="M13 2V4C17.39 4.54 20.5 8.53 19.96 12.92C19.5 16.56 16.64 19.43 13 19.88V21.88C18.5 21.28 22.45 16.34 21.85 10.85C21.33 6.19 17.66 2.5 13 2M11 2C9.04 2.18 7.19 2.95 5.67 4.2L7.1 5.74C8.22 4.84 9.57 4.26 11 4.06V2M4.26 5.67C3 7.19 2.24 9.04 2.05 11H4.05C4.24 9.58 4.8 8.23 5.69 7.1L4.26 5.67M2.06 13C2.26 14.96 3.03 16.81 4.27 18.33L5.69 16.9C4.81 15.77 4.24 14.42 4.06 13H2.06M7.06 18.37L5.67 19.74C7.18 21 9.04 21.79 11 22V20C9.58 19.82 8.23 19.25 7.1 18.37H7.06Z",be="M5.5,7A1.5,1.5 0 0,1 4,5.5A1.5,1.5 0 0,1 5.5,4A1.5,1.5 0 0,1 7,5.5A1.5,1.5 0 0,1 5.5,7M21.41,11.58L12.41,2.58C12.05,2.22 11.55,2 11,2H4C2.89,2 2,2.89 2,4V11C2,11.55 2.22,12.05 2.59,12.41L11.58,21.41C11.95,21.77 12.45,22 13,22C13.55,22 14.05,21.77 14.41,21.41L21.41,14.41C21.78,14.05 22,13.55 22,13C22,12.44 21.77,11.94 21.41,11.58Z",me="M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M9,8H11V17H9V8M13,8H15V17H13V8Z",ve=(e,t)=>{const i={};for(const s of e)i[t(s)]=s;return i},we=(e,t,i)=>{const s=e[i]?.config_entry_id;return s?t[s]:void 0};class Ce extends((0,J.E)(o.WF)){get _availableAssistants(){return(0,ne.V)(this.cloudStatus,this.hass)}hassSubscribe(){return[(0,F.TC)(this.hass,async e=>{const t=this._configEntries?{...this._configEntries}:{};e.forEach(e=>{null===e.type||"added"===e.type?t[e.entry.entry_id]=e.entry:"removed"===e.type?delete t[e.entry.entry_id]:"updated"===e.type&&(t[e.entry.entry_id]=e.entry),this._entitySource&&this._configEntries&&"loaded"===e.entry.state&&"loaded"!==this._configEntries[e.entry.entry_id]?.state&&this._debouncedFetchEntitySources()}),this._configEntries=t},{type:["helper"]}),(0,I.Bz)(this.hass.connection,e=>{this._entityEntries=ve(e,e=>e.entity_id)}),(0,z.Ar)(this.hass.connection,"helpers",e=>{this._categories=e})]}_labelsForEntity(e){return this.hass.entities[e]?.labels||(0,I.Ox)(this._entityReg)[e]?.labels||[]}render(){if(!this.hass||void 0===this._helperEntities||void 0===this._entityEntries||void 0===this._configEntries)return o.qy`<hass-loading-screen></hass-loading-screen>`;const e=this._sizeController.value&&this._sizeController.value<700||!this._sizeController.value&&"docked"===this.hass.dockedSidebar,t=this._getItems(this.hass.localize,this._helperEntities,this._disabledEntityEntries||[],this._entityEntries,this._configEntries,this._entityReg,this._categories,this._labels,this._filteredHelperEntityIds);return o.qy` <hass-tabs-subpage-data-table .hass="${this.hass}" .narrow="${this.narrow}" .backPath="${this._searchParms.has("historyBack")?void 0:"/config"}" .route="${this.route}" .tabs="${ee.configSections.devices}" .searchLabel="${this.hass.localize("ui.panel.config.helpers.picker.search",{number:t.length})}" selectable .selected="${this._selected.length}" @selection-changed="${this._handleSelectionChanged}" has-filters .filters="${Object.values(this._filters).filter(e=>Array.isArray(e)?e.length:e&&Object.values(e).some(e=>Array.isArray(e)?e.length:e)).length}" .columns="${this._columns(this.hass.localize,t)}" .data="${t}" .initialGroupColumn="${this._activeGrouping??"category"}" .initialCollapsedGroups="${this._activeCollapsed}" .initialSorting="${this._activeSorting}" .columnOrder="${this._activeColumnOrder}" .hiddenColumns="${this._activeHiddenColumns}" @columns-changed="${this._handleColumnsChanged}" @sorting-changed="${this._handleSortingChanged}" @grouping-changed="${this._handleGroupingChanged}" @collapsed-changed="${this._handleCollapseChanged}" .activeFilters="${this._activeFilters}" @clear-filter="${this._clearFilter}" @row-click="${this._openEditDialog}" .filter="${this._filter}" @search-changed="${this._handleSearchChange}" has-fab clickable .noDataText="${this.hass.localize("ui.panel.config.helpers.picker.no_helpers")}" class="${this.narrow?"narrow":""}"> <ha-filter-floor-areas .hass="${this.hass}" .type="${"entity"}" .value="${this._filters["ha-filter-floor-areas"]}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-floor-areas"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-floor-areas> <ha-filter-devices .hass="${this.hass}" .type="${"entity"}" .value="${this._filters["ha-filter-devices"]}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-devices"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-devices> <ha-filter-labels .hass="${this.hass}" .value="${this._filters["ha-filter-labels"]}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-labels"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-labels> <ha-filter-categories .hass="${this.hass}" scope="helpers" .value="${this._filters["ha-filter-categories"]}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-categories"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-categories> <ha-filter-voice-assistants .hass="${this.hass}" .value="${this._filters["ha-filter-voice-assistants"]}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-voice-assistants"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-voice-assistants> ${this.narrow?o.s6:o.qy`<ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkCategory}"> <ha-assist-chip slot="trigger" .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.move_category")}"> <ha-svg-icon slot="trailing-icon" .path="${ge}"></ha-svg-icon> </ha-assist-chip> ${this._renderCategoryItems()} </ha-dropdown> ${e?o.s6:o.qy`<ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkLabel}"> <ha-assist-chip slot="trigger" .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.add_label")}"> <ha-svg-icon slot="trailing-icon" .path="${ge}"></ha-svg-icon> </ha-assist-chip> ${this._renderLabelItems()} </ha-dropdown>`}`} ${this.narrow||e?o.qy` <ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkAction}"> ${this.narrow?o.qy`<ha-assist-chip .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_action")}" slot="trigger"> <ha-svg-icon slot="trailing-icon" .path="${ge}"></ha-svg-icon> </ha-assist-chip>`:o.qy`<ha-icon-button .path="${_e}" .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_action")}" slot="trigger"></ha-icon-button>`} ${this.narrow?o.qy`<ha-dropdown-item> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.move_category")} ${this._renderCategoryItems("submenu")} </ha-dropdown-item>`:o.s6} ${this.narrow||"docked"===this.hass.dockedSidebar?o.qy`<ha-dropdown-item> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.add_label")} ${this._renderLabelItems("submenu")} </ha-dropdown-item>`:o.s6} </ha-dropdown>`:o.s6} <ha-integration-overflow-menu .hass="${this.hass}" slot="toolbar-icon"></ha-integration-overflow-menu> <ha-button slot="fab" size="large" @click="${this._createHelper}"> <ha-svg-icon slot="start" .path="${ye}"></ha-svg-icon> ${this.hass.localize("ui.panel.config.helpers.picker.create_helper")} </ha-button> </hass-tabs-subpage-data-table> `}_filterExpanded(e){e.detail.expanded?this._expandedFilter=e.target.localName:this._expandedFilter===e.target.localName&&(this._expandedFilter=void 0)}_filterChanged(e){const t=e.target.localName;this._filters={...this._filters,[t]:e.detail.value},this._filteredItems={...this._filteredItems,[t]:e.detail.items},this._fromUrl||(this._storageFilters=this._filters),this._applyFilters()}_applyFilters(){const e=Object.entries(this._filters);let t;Object.values(this._filteredItems).forEach(e=>{e&&(t=t?"intersection"in t?t.intersection(e):new Set([...t].filter(t=>e.has(t))):e)});for(const[i,s]of e)if("ha-filter-labels"===i&&Array.isArray(s)&&s.length){const e=new Set;if(this._helperEntities.filter(e=>(0,I.Ox)(this._entityReg)[e.entity_id]?.labels.some(e=>s.includes(e))).forEach(t=>e.add(t.entity_id)),(this._disabledEntityEntries||[]).filter(e=>e.labels.some(e=>s.includes(e))).forEach(t=>e.add(t.entity_id)),!t){t=e;continue}t="intersection"in t?t.intersection(e):new Set([...t].filter(t=>e.has(t)))}else if("ha-filter-categories"===i&&Array.isArray(s)&&s.length){const e=new Set;if(this._helperEntities.filter(e=>s[0]===(0,I.Ox)(this._entityReg)[e.entity_id]?.categories.helpers).forEach(t=>e.add(t.entity_id)),(this._disabledEntityEntries||[]).filter(e=>s[0]===e.categories.helpers).forEach(t=>e.add(t.entity_id)),!t){t=e;continue}t="intersection"in t?t.intersection(e):new Set([...t].filter(t=>e.has(t)))}else if("ha-filter-voice-assistants"===i&&Array.isArray(s)&&s.length){const e=new Set;if(this._helperEntities.filter(e=>(0,q.hB)(this._entityReg,e.entity_id).some(e=>s.includes(e))).forEach(t=>e.add(t.entity_id)),(this._disabledEntityEntries||[]).filter(e=>(0,q.hB)(this._entityReg,e.entity_id).some(e=>s.includes(e))).forEach(t=>e.add(t.entity_id)),!t){t=e;continue}t="intersection"in t?t.intersection(e):new Set([...t].filter(t=>e.has(t)))}this._filteredHelperEntityIds=t?[...t]:void 0}connectedCallback(){super.connectedCallback(),window.addEventListener("location-changed",this._locationChanged),window.addEventListener("popstate",this._popState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("location-changed",this._locationChanged),window.removeEventListener("popstate",this._popState)}_setFiltersFromUrl(){const e=this._searchParms.get("area"),t=this._searchParms.get("device"),i=this._searchParms.get("label"),s=this._searchParms.get("category"),a=this._searchParms.get("voice_assistant");(e||s||i||t||a)&&(this._fromUrl=!0,this._filter=history.state?.filter||"",this._filters={"ha-filter-floor-areas":e?{areas:[e]}:void 0,"ha-filter-devices":t?[t]:[],"ha-filter-labels":i?[i]:[],"ha-filter-categories":s?[s]:[],"ha-filter-voice-assistants":a?[a]:[]})}_clearFilter(){this._filters={},this._filteredItems={},this._fromUrl||(this._storageFilters={}),this._applyFilters()}_editCategory(e){const t=(0,I.Ox)(this._entityReg)[e.entity_id];t?(0,Y.j)(this,{scope:"helpers",entityReg:t}):(0,R.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.automation.picker.no_category_support"),text:this.hass.localize("ui.panel.config.automation.picker.no_category_entity_reg")})}async _bulkAddCategory(e){const t=[];this._selected.forEach(i=>{t.push((0,I.G_)(this.hass,i,{categories:{helpers:e}}))});const i=await Promise.allSettled(t);if((0,f.$)(i)){const e=(0,f.N)(i);(0,R.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:e.length}),text:o.qy`<pre> ${e.map(e=>e.reason.message||e.reason.code||e.reason).join("\r\n")}</pre>`})}}async _bulkLabel(e,t){const i=[];this._selected.forEach(s=>{const a=this._labelsForEntity(s);i.push((0,I.G_)(this.hass,s,{labels:"add"===t?a.concat(e):a.filter(t=>t!==e)}))});const s=await Promise.allSettled(i);if((0,f.$)(s)){const e=(0,f.N)(s);(0,R.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:e.length}),text:o.qy`<pre> ${e.map(e=>e.reason.message||e.reason.code||e.reason).join("\r\n")}</pre>`})}}_handleSelectionChanged(e){this._selected=e.detail.value}firstUpdated(e){super.firstUpdated(e),this._setFiltersFromUrl(),this._fetchEntitySources(),(0,c.x)(this.hass.config,"diagnostics")&&(0,V.Dh)(this.hass).then(e=>{const t={};for(const i of e)t[i.domain]=i.handlers.config_entry;this._diagnosticHandlers=t}),"/add"===this.route.path&&this._handleAdd()}async _fetchEntitySources(){const[e,t]=await Promise.all([(0,O.c)(this.hass),(0,P.fK)(this.hass)]),i={};for(const e of t)"helper"===e.integration_type&&(i[e.domain]=e);this._helperManifests=i;const s={},a=new Set;for(const[t,n]of Object.entries(e)){const e=n.domain;e in i&&(s[t]=e,a.add(e))}a.size&&this.hass.loadBackendTranslation("title",[...a]),this._entitySource=s}async _handleAdd(){const e=(0,g.p9)("domain");if((0,u.oo)("/config/helpers",{replace:!0}),!e)return;if((0,le.z)(e))return void(0,oe.$)(this,{domain:e});if(!(await(0,M.yu)(this.hass,["helper"])).includes(e)){return(await(0,M.yu)(this.hass,["device","hub","service"])).includes(e)?void(0,u.oo)(`/config/integrations/add?domain=${e}`,{replace:!0}):void(0,R.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.integrations.config_flow.error"),text:this.hass.localize("ui.panel.config.integrations.config_flow.no_config_flow")})}const t=await this.hass.loadBackendTranslation("title",e,!0);await(0,R.dk)(this,{title:this.hass.localize("ui.panel.config.integrations.confirm_new",{integration:(0,P.p$)(t,e)})})&&(0,D.W)(this,{startFlowHandler:e,manifest:await(0,P.QC)(this.hass,e)})}willUpdate(e){if(super.willUpdate(e),this.hasUpdated||(this._filters=this._storageFilters,this._setFiltersFromUrl()),!this._entityEntries||!this._configEntries)return;(e.has("_helperManifests")||e.has("_entityEntries")||e.has("_configEntries"))&&this._helperManifests&&(this._disabledEntityEntries=Object.values(this._entityEntries).filter(e=>e.disabled_by&&(e.platform in this._helperManifests||e.config_entry_id&&e.config_entry_id in this._configEntries)));let t=!this._helperEntities||e.has("_entityEntries")||e.has("_configEntries")||e.has("_entitySource");if(!t&&e.has("hass")){const i=e.get("hass");t=!i||i.states!==this.hass.states}if(!t)return;const i=Object.keys(this._entitySource),s=Object.values(this.hass.states).filter(e=>i.includes(e.entity_id)||(0,le.z)((0,_.t)(e)));this._helperEntities.length===s.length&&this._helperEntities.every((e,t)=>s[t]===e)||(this._helperEntities=s,Object.keys(this._filters).length>0&&this._applyFilters())}async _openEditDialog(e){const t=e.detail.id;t.includes(".")?(0,T.p)(this,{entityId:t}):(0,j.Q)(this,this._configEntries[t])}_showError(e){(0,R.showAlertDialog)(this,{title:this.hass.localize("ui.errors.config.configuration_error"),text:(0,te.J)(this.hass,e.configEntry),warning:!0})}async _deleteEntry(e){await(0,R.dk)(this,{title:this.hass.localize("ui.panel.config.integrations.config_entry.delete_confirm_title",{title:e.configEntry.title}),text:this.hass.localize("ui.panel.config.integrations.config_entry.delete_confirm_text"),confirmText:this.hass.localize("ui.common.delete"),dismissText:this.hass.localize("ui.common.cancel"),destructive:!0})&&(0,F.eM)(this.hass,e.id)}async _downloadDiagnostics(e){const t=(0,V.WV)(e.configEntry.entry_id),i=await(0,L.e0)(this.hass,t);(0,Q.R)(i.path)}_openSettings(e){e.entity?(0,T.p)(this,{entityId:e.entity_id,view:"settings"}):(0,j.Q)(this,e.configEntry)}async _deleteHelper(e){if(!e.entity_id)return;if(await(0,R.dk)(this,{title:this.hass.localize("ui.panel.config.helpers.picker.delete_confirm_title"),text:this.hass.localize("ui.panel.config.helpers.picker.delete_confirm_text",{name:e.name}),confirmText:this.hass.localize("ui.common.delete"),dismissText:this.hass.localize("ui.common.cancel"),destructive:!0}))try{if((0,le.z)(e.type)){const t=this._entityReg.find(t=>t.entity_id===e.entity_id);if(!t?.unique_id||!(0,c.x)(this.hass.config,e.type))throw new Error(this.hass.localize("ui.panel.config.helpers.picker.delete_failed"));return void await B.n[e.type].delete(this.hass,t.unique_id)}e.configEntry&&await(0,F.eM)(this.hass,e.configEntry.entry_id)}catch(e){(0,R.showAlertDialog)(this,{text:e.message||this.hass.localize("ui.panel.config.helpers.picker.delete_failed")})}}_createHelper(){(0,oe.$)(this,{})}_handleSortingChanged(e){this._activeSorting=e.detail}_handleGroupingChanged(e){this._activeGrouping=e.detail.value??""}_handleCollapseChanged(e){this._activeCollapsed=e.detail.value}_handleSearchChange(e){this._filter=e.detail.value}_handleColumnsChanged(e){this._activeColumnOrder=e.detail.columnOrder,this._activeHiddenColumns=e.detail.hiddenColumns}static get styles(){return[N.RF,o.AH`:host{display:block}hass-tabs-subpage-data-table{--data-table-row-height:60px}hass-tabs-subpage-data-table.narrow{--data-table-row-height:72px}ha-assist-chip{--ha-assist-chip-container-shape:10px}ha-dropdown::part(menu),ha-dropdown::part(submenu){--auto-size-available-width:calc(50vw - var(--ha-space-4))}ha-dropdown ha-assist-chip{--md-assist-chip-trailing-space:8px}`]}constructor(...e){super(...e),this.isWide=!1,this.narrow=!1,this._filter="",this._helperEntities=[],this._entitySource={},this._selected=[],this._searchParms=new URLSearchParams(window.location.search),this._filters={},this._storageFilters={},this._filteredItems={},this._entityReg=[],this._sizeController=new n.P(this,{callback:e=>e[0]?.contentRect.width}),this._debouncedFetchEntitySources=(0,y.s)(()=>this._fetchEntitySources(),500,!1),this._columns=(0,h.A)((e,t)=>({icon:{title:"",label:e("ui.panel.config.helpers.picker.headers.icon"),type:"icon",showNarrow:!0,moveable:!1,template:e=>e.entity?o.qy`<ha-state-icon .stateObj="${e.entity}"></ha-state-icon>`:o.qy`<ha-svg-icon .path="${e.icon}" style="color:var(--error-color)"></ha-svg-icon>`},name:{title:e("ui.panel.config.helpers.picker.headers.name"),main:!0,sortable:!0,filterable:!0,flex:2,direction:"asc",extraTemplate:e=>e.label_entries.length?o.qy` <ha-data-table-labels .labels="${e.label_entries}"></ha-data-table-labels> `:o.s6},entity_id:(0,X.DZ)(e),category:(0,X.Bl)(e),area:(0,X.A7)(e),labels:(0,X.AI)(),localized_type:{title:e("ui.panel.config.helpers.picker.headers.type"),sortable:!0,filterable:!0,groupable:!0},editable:(0,X.tH)(e,e("ui.panel.config.entities.picker.status.unmanageable")),actions:{lastFixed:!0,title:"",label:this.hass.localize("ui.panel.config.generic.headers.actions"),type:"overflow-menu",showNarrow:!0,template:e=>o.qy` <ha-icon-overflow-menu narrow .items="${[...e.configEntry&&F.m4.includes(e.configEntry.state)?[{path:he,label:this.hass.localize("ui.panel.config.helpers.picker.error_information"),warning:!0,action:()=>this._showError(e)}]:[],{path:de,label:this.hass.localize("ui.panel.config.automation.picker.show_settings"),action:()=>this._openSettings(e)},{path:be,label:this.hass.localize("ui.panel.config.automation.picker."+(e.category?"edit_category":"assign_category")),action:()=>this._editCategory(e)},...e.configEntry&&e.editable&&F.m4.includes(e.configEntry.state)&&void 0===e.entity?[{path:me,label:this.hass.localize("ui.common.delete"),warning:!0,action:()=>this._deleteEntry(e)}]:[],...this._diagnosticHandlers?.[e.type]&&e.configEntry?[{path:ue,label:this.hass.localize("ui.panel.config.integrations.config_entry.download_diagnostics"),action:()=>this._downloadDiagnostics(e)}]:[],...e.editable&&e.entity_id?[{divider:!0},{path:pe,label:this.hass.localize("ui.common.delete"),warning:!0,action:()=>this._deleteHelper(e)}]:[]]}"> </ha-icon-overflow-menu> `},assistants:(0,ae.MD)(e,this.hass,this._availableAssistants,t)})),this._getItems=(0,h.A)((e,t,i,s,a,n,l,o,r)=>{if(null===r)return[];const h={...a};return[...t.map(e=>{const t=we(s,a,e.entity_id);return t&&delete h[t.entry_id],{id:e.entity_id,name:e.attributes.friendly_name||"",entity_id:e.entity_id,editable:void 0!==t||e.attributes.editable,type:t?t.domain:this._entitySource[e.entity_id]||(0,_.t)(e),configEntry:t,entity:e}}),...Object.values(h).map(e=>{const t=Object.values(s).find(t=>t.config_entry_id===e.entry_id);return{id:e.entry_id,entity_id:"",icon:"setup_in_progress"===e.state?fe:he,name:e.title||"",editable:!0,type:e.domain,configEntry:e,entity:void 0,selectable:!1,disabled:!!t?.disabled_by}}).filter(e=>!e.disabled),...(i||[]).map(e=>({id:e.entity_id,entity_id:e.entity_id,icon:ce,name:e.name||e.original_name||e.entity_id,editable:!0,type:e.platform,configEntry:void 0,entity:void 0,selectable:!0,disabled:!0}))].filter(e=>!r||r?.includes(e.entity_id)).map(t=>{const i=(0,I.Ox)(n)[t.entity_id],s=(o&&i?.labels||[]).map(e=>o.find(t=>t.label_id===e)).filter(e=>void 0!==e),a=i?.categories.helpers,r=i?.device_id,h=i?.area_id||this.hass.devices?.[r]?.area_id,c=h&&this.hass.areas?.[h]?(0,p.A)(this.hass.areas[h]):void 0,d=(0,q.hB)(n,t.entity_id);return{...t,localized_type:(0,P.p$)(e,t.type)||e(`ui.panel.config.helpers.types.${t.type}`)||t.type,label_entries:s,labels:s.map(e=>e.name),category:a?l?.find(e=>e.category_id===a)?.name:void 0,area:c,assistants:d,assistants_sortable_key:(0,ae.HX)(d)}})}),this._fromUrl=!1,this._locationChanged=()=>{window.location.search.substring(1)!==this._searchParms.toString()&&(this._searchParms=new URLSearchParams(window.location.search),this._setFiltersFromUrl())},this._popState=()=>{window.location.search.substring(1)!==this._searchParms.toString()&&(this._searchParms=new URLSearchParams(window.location.search),this._setFiltersFromUrl())},this._handleBulkCategory=e=>{const t=e.detail.item.value;"category_create"!==t?"category_none"!==t?t?.startsWith("category_")&&this._bulkAddCategory(t.substring(9)):this._bulkAddCategory(null):this._bulkCreateCategory()},this._handleBulkLabel=e=>{e.preventDefault();const t=e.detail.item.value;if("label_create"!==t){if(t?.startsWith("label_")){const i=e.detail.item.action;this._bulkLabel(t.substring(6),i)}}else this._bulkCreateLabel()},this._bulkCreateCategory=()=>{(0,K.S)(this,{scope:"helpers",createEntry:async e=>{const t=await(0,z.s_)(this.hass,"helpers",e);return this._bulkAddCategory(t.category_id),t}})},this._bulkCreateLabel=()=>{(0,se.f)(this,{createEntry:async e=>{const t=await(0,Z._9)(this.hass,e);this._bulkLabel(t.label_id,"add")}})},this._renderCategoryItems=(e="")=>o.qy`${this._categories?.map(t=>o.qy`<ha-dropdown-item .slot="${e}" .value="${`category_${t.category_id}`}"> ${t.icon?o.qy`<ha-icon slot="icon" .icon="${t.icon}"></ha-icon>`:o.qy`<ha-svg-icon slot="icon" .path="${be}"></ha-svg-icon>`} ${t.name} </ha-dropdown-item>`)} <ha-dropdown-item .slot="${e}" value="category_none"> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.no_category")} </ha-dropdown-item> <wa-divider .slot="${e}"></wa-divider> <ha-dropdown-item .slot="${e}" value="category_create"> ${this.hass.localize("ui.panel.config.category.editor.add")} </ha-dropdown-item>`,this._renderLabelItems=(e="")=>o.qy`${this._labels?.map(t=>{const i=this._selected.every(e=>this._labelsForEntity(e).includes(t.label_id)),s=!i&&this._selected.some(e=>this._labelsForEntity(e).includes(t.label_id));return o.qy`<ha-dropdown-item .slot="${e}" .value="${`label_${t.label_id}`}" .action="${i?"remove":"add"}"> <ha-checkbox slot="icon" .checked="${i}" .indeterminate="${s}"></ha-checkbox> <ha-label .color="${t.color}" .description="${t.description}"> ${t.icon?o.qy`<ha-icon slot="icon" .icon="${t.icon}"></ha-icon>`:o.s6} ${t.name} </ha-label> </ha-dropdown-item>`})} <wa-divider .slot="${e}"></wa-divider> <ha-dropdown-item .slot="${e}" value="label_create"> ${this.hass.localize("ui.panel.config.labels.add_label")} </ha-dropdown-item>`,this._handleBulkAction=e=>{const t=e.detail.item,i=t.value;if(i)if(i.startsWith("category_"))"category_create"===i?this._bulkCreateCategory():"category_none"===i?this._bulkAddCategory(null):this._bulkAddCategory(i.substring(9));else if(i.startsWith("label_"))if("label_create"===i)this._bulkCreateLabel();else{const e=t.action;this._bulkLabel(i.substring(6),e)}}}}(0,a.Cg)([(0,r.MZ)({attribute:!1})],Ce.prototype,"hass",void 0),(0,a.Cg)([(0,r.MZ)({attribute:"is-wide",type:Boolean})],Ce.prototype,"isWide",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],Ce.prototype,"narrow",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],Ce.prototype,"route",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],Ce.prototype,"cloudStatus",void 0),(0,a.Cg)([(0,d.I)({key:"helpers-table-sort",state:!1,subscribe:!1})],Ce.prototype,"_activeSorting",void 0),(0,a.Cg)([(0,d.I)({key:"helpers-table-grouping",state:!1,subscribe:!1})],Ce.prototype,"_activeGrouping",void 0),(0,a.Cg)([(0,d.I)({key:"helpers-table-collapsed",state:!1,subscribe:!1})],Ce.prototype,"_activeCollapsed",void 0),(0,a.Cg)([(0,r.wk)(),(0,d.I)({storage:"sessionStorage",key:"helpers-table-search",state:!0,subscribe:!1})],Ce.prototype,"_filter",void 0),(0,a.Cg)([(0,d.I)({key:"helpers-table-column-order",state:!1,subscribe:!1})],Ce.prototype,"_activeColumnOrder",void 0),(0,a.Cg)([(0,d.I)({key:"helpers-table-hidden-columns",state:!1,subscribe:!1})],Ce.prototype,"_activeHiddenColumns",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_helperEntities",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_disabledEntityEntries",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_entityEntries",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_configEntries",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_entitySource",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_selected",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_activeFilters",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_helperManifests",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_diagnosticHandlers",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_searchParms",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_filters",void 0),(0,a.Cg)([(0,d.I)({storage:"sessionStorage",key:"helpers-table-filters",state:!1,subscribe:!1})],Ce.prototype,"_storageFilters",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_filteredItems",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_expandedFilter",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_categories",void 0),(0,a.Cg)([(0,l.Fg)({context:W.HD,subscribe:!0}),(0,r.wk)()],Ce.prototype,"_labels",void 0),(0,a.Cg)([(0,r.wk)(),(0,l.Fg)({context:W.ih,subscribe:!0})],Ce.prototype,"_entityReg",void 0),(0,a.Cg)([(0,r.wk)()],Ce.prototype,"_filteredHelperEntityIds",void 0),Ce=(0,a.Cg)([(0,r.EM)("ha-config-helpers")],Ce),s()}catch(e){s(e)}})},19711(e,t,i){i.d(t,{$:()=>n});var s=i(1087);const a=()=>Promise.all([i.e(80131),i.e(70183),i.e(47677)]).then(i.bind(i,79029)),n=(e,t)=>{(0,s.r)(e,"show-dialog",{dialogTag:"dialog-helper-detail",dialogImport:a,dialogParams:t})}}};