iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
14 lines • 23.1 kB
JavaScript
/*! For license information please see 5713.0239f63755867a2a.js.LICENSE.txt */
export const __rspack_esm_id=5713;export const __rspack_esm_ids=[5713];export const __webpack_modules__={12451(t,e,i){i.d(e,{O:()=>r,i:()=>a.is});var o=i(5124),a=i(12130);class r extends o.WF{click(){if(this.mdcRoot)return this.mdcRoot.focus(),void this.mdcRoot.click();super.click()}createFoundation(){void 0!==this.mdcFoundation&&this.mdcFoundation.destroy(),this.mdcFoundationClass&&(this.mdcFoundation=new this.mdcFoundationClass(this.createAdapter()),this.mdcFoundation.init())}firstUpdated(){this.createFoundation()}}},12130(t,e,i){i.d(e,{SE:()=>d,U9:()=>c,hP:()=>o,is:()=>a});i(44114);const o=t=>t.nodeType===Node.ELEMENT_NODE;function a(t){return{addClass:e=>{t.classList.add(e)},removeClass:e=>{t.classList.remove(e)},hasClass:e=>t.classList.contains(e)}}let r=!1;const s=()=>{},n={get passive(){return r=!0,!1}};document.addEventListener("x",s,n),document.removeEventListener("x",s);const c=(t=window.document)=>{let e=t.activeElement;const i=[];if(!e)return i;for(;e&&(i.push(e),e.shadowRoot);)e=e.shadowRoot.activeElement;return i},d=t=>{const e=c();if(!e.length)return!1;const i=e[e.length-1],o=new Event("check-if-focused",{bubbles:!0,composed:!0});let a=[];const r=t=>{a=t.composedPath()};return document.body.addEventListener("check-if-focused",r),i.dispatchEvent(o),document.body.removeEventListener("check-if-focused",r),-1!==a.indexOf(t)}},28732(t,e,i){var o=i(62826),a=i(27686),r=i(7731),s=i(5124),n=i(22441);class c extends a.J{renderRipple(){return this.noninteractive?"":super.renderRipple()}static get styles(){return[r.R,s.AH`:host{padding-left:var(--mdc-list-side-padding-left,var(--mdc-list-side-padding,20px));padding-inline-start:var(--mdc-list-side-padding-left,var(--mdc-list-side-padding,20px));padding-right:var(--mdc-list-side-padding-right,var(--mdc-list-side-padding,20px));padding-inline-end:var(--mdc-list-side-padding-right,var(--mdc-list-side-padding,20px))}:host([graphic=avatar]:not([twoLine])),:host([graphic=icon]:not([twoLine])){height:48px}span.material-icons:first-of-type{margin-inline-start:0px!important;margin-inline-end:var(--mdc-list-item-graphic-margin,16px)!important;direction:var(--direction)!important}span.material-icons:last-of-type{margin-inline-start:auto!important;margin-inline-end:0px!important;direction:var(--direction)!important}.mdc-deprecated-list-item__meta{display:var(--mdc-list-item-meta-display);align-items:center;flex-shrink:0}:host([graphic=icon]:not([twoline])) .mdc-deprecated-list-item__graphic{margin-inline-end:var(--mdc-list-item-graphic-margin,20px)!important}:host([multiline-secondary]){height:auto}:host([multiline-secondary]) .mdc-deprecated-list-item__text{padding:8px 0}:host([multiline-secondary]) .mdc-deprecated-list-item__secondary-text{text-overflow:initial;white-space:normal;overflow:auto;display:inline-block;margin-top:10px}:host([multiline-secondary]) .mdc-deprecated-list-item__primary-text{margin-top:10px}:host([multiline-secondary]) .mdc-deprecated-list-item__secondary-text::before{display:none}:host([multiline-secondary]) .mdc-deprecated-list-item__primary-text::before{display:none}:host([disabled]){color:var(--disabled-text-color)}:host([noninteractive]){pointer-events:unset}`,"rtl"===document.dir?s.AH`span.material-icons:first-of-type,span.material-icons:last-of-type{direction:rtl!important;--direction:rtl}`:s.AH``]}}c=(0,o.Cg)([(0,n.EM)("ha-list-item")],c)},8630(t,e,i){var o=i(62826),a=i(68618),r=i(11081),s=i(22441);class n extends a.iY{}n.styles=r.R,n=(0,o.Cg)([(0,s.EM)("ha-list")],n)},65829(t,e,i){i.a(t,async function(t,e){try{var o=i(62826),a=i(55262),r=i(5124),s=i(22441),n=t([a]);a=(n.then?(await n)():n)[0];class c extends a.A{updated(t){if(super.updated(t),t.has("size"))switch(this.size){case"tiny":this.style.setProperty("--ha-spinner-size","16px");break;case"small":this.style.setProperty("--ha-spinner-size","28px");break;case"medium":this.style.setProperty("--ha-spinner-size","48px");break;case"large":this.style.setProperty("--ha-spinner-size","68px");break;case void 0:this.style.removeProperty("--ha-progress-ring-size")}}static get styles(){return[a.A.styles,r.AH`:host{--indicator-color:var(
--ha-spinner-indicator-color,
var(--primary-color)
);--track-color:var(--ha-spinner-divider-color, var(--divider-color));--track-width:4px;--speed:3.5s;font-size:var(--ha-spinner-size, 48px)}`]}}(0,o.Cg)([(0,s.MZ)()],c.prototype,"size",void 0),c=(0,o.Cg)([(0,s.EM)("ha-spinner")],c),e()}catch(t){e(t)}})},18885(t,e,i){i.d(e,{Td:()=>o,iP:()=>r,pz:()=>a});const o=(t,e)=>t.callWS({type:"config/core/update",...e}),a=t=>t.callWS({type:"config/core/detect"}),r=t=>t.callApi("POST","config/core/check_config")},85013(t,e,i){i.d(e,{a:()=>o});const o={BD:"BDT",BE:"EUR",BF:"XOF",BG:"BGN",BA:"BAM",BB:"BBD",WF:"XPF",BL:"EUR",BM:"BMD",BN:"BND",BO:"BOB",BH:"BHD",BI:"BIF",BJ:"XOF",BT:"BTN",JM:"JMD",BV:"NOK",BW:"BWP",WS:"WST",BQ:"USD",BR:"BRL",BS:"BSD",JE:"GBP",BY:"BYN",BZ:"BZD",RU:"RUB",RW:"RWF",RS:"RSD",TL:"USD",RE:"EUR",TM:"TMT",TJ:"TJS",RO:"RON",TK:"NZD",GW:"XOF",GU:"USD",GT:"GTQ",GS:"GBP",GR:"EUR",GQ:"XAF",GP:"EUR",JP:"JPY",GY:"GYD",GG:"GBP",GF:"EUR",GE:"GEL",GD:"XCD",GB:"GBP",GA:"XAF",SV:"USD",GN:"GNF",GM:"GMD",GL:"DKK",GI:"GIP",GH:"GHS",OM:"OMR",TN:"TND",JO:"JOD",HR:"EUR",HT:"HTG",HU:"HUF",HK:"HKD",HN:"HNL",HM:"AUD",VE:"VED",PR:"USD",PS:"ILS",PW:"USD",PT:"EUR",SJ:"NOK",PY:"PYG",IQ:"IQD",PA:"PAB",PF:"XPF",PG:"PGK",PE:"PEN",PK:"PKR",PH:"PHP",PN:"NZD",PL:"PLN",PM:"EUR",ZM:"ZMW",EH:"MAD",EE:"EUR",EG:"EGP",ZA:"ZAR",EC:"USD",IT:"EUR",VN:"VND",SB:"SBD",ET:"ETB",SO:"SOS",ZW:"ZWL",SA:"SAR",ES:"EUR",ER:"ERN",ME:"EUR",MD:"MDL",MG:"MGA",MF:"EUR",MA:"MAD",MC:"EUR",UZ:"UZS",MM:"MMK",ML:"XOF",MO:"MOP",MN:"MNT",MH:"USD",MK:"MKD",MU:"MUR",MT:"EUR",MW:"MWK",MV:"MVR",MQ:"EUR",MP:"USD",MS:"XCD",MR:"MRU",IM:"GBP",UG:"UGX",TZ:"TZS",MY:"MYR",MX:"MXN",IL:"ILS",FR:"EUR",IO:"USD",SH:"SHP",FI:"EUR",FJ:"FJD",FK:"FKP",FM:"USD",FO:"DKK",NI:"NIO",NL:"EUR",NO:"NOK",NA:"NAD",VU:"VUV",NC:"XPF",NE:"XOF",NF:"AUD",NG:"NGN",NZ:"NZD",NP:"NPR",NR:"AUD",NU:"NZD",CK:"NZD",XK:"EUR",CI:"XOF",CH:"CHF",CO:"COP",CN:"CNY",CM:"XAF",CL:"CLP",CC:"AUD",CA:"CAD",CG:"XAF",CF:"XAF",CD:"CDF",CZ:"CZK",CY:"EUR",CX:"AUD",CR:"CRC",CW:"ANG",CV:"CVE",CU:"CUP",SZ:"SZL",SY:"SYP",SX:"ANG",KG:"KGS",KE:"KES",SS:"SSP",SR:"SRD",KI:"AUD",KH:"KHR",KN:"XCD",KM:"KMF",ST:"STD",SK:"EUR",KR:"KRW",SI:"EUR",KP:"KPW",KW:"KWD",SN:"XOF",SM:"EUR",SL:"SLL",SC:"SCR",KZ:"KZT",KY:"KYD",SG:"SGD",SE:"SEK",SD:"SDG",DO:"DOP",DM:"XCD",DJ:"DJF",DK:"DKK",VG:"USD",DE:"EUR",YE:"YER",DZ:"DZD",US:"USD",UY:"UYU",YT:"EUR",UM:"USD",LB:"LBP",LC:"XCD",LA:"LAK",TV:"AUD",TW:"TWD",TT:"TTD",TR:"TRY",LK:"LKR",LI:"CHF",LV:"EUR",TO:"TOP",LT:"EUR",LU:"EUR",LR:"LRD",LS:"LSL",TH:"THB",TF:"EUR",TG:"XOF",TD:"XAF",TC:"USD",LY:"LYD",VA:"EUR",VC:"XCD",AE:"AED",AD:"EUR",AG:"XCD",AF:"AFN",AI:"XCD",VI:"USD",IS:"ISK",IR:"IRR",AM:"AMD",AL:"ALL",AO:"AOA",AQ:"",AS:"USD",AR:"ARS",AU:"AUD",AT:"EUR",AW:"AWG",IN:"INR",AX:"EUR",AZ:"AZN",IE:"EUR",ID:"IDR",UA:"UAH",QA:"QAR",MZ:"MZN"}},3523(t,e,i){i.d(e,{R:()=>a,h:()=>o});const o=(t,e,i,o)=>fetch(`https://nominatim.openstreetmap.org/search.php?q=${t}&format=jsonv2${o?`&limit=${o}`:""}${i?"&addressdetails=1":""}&accept-language=${e.locale.language}&email=abuse@home-assistant.io`,{headers:{"User-Agent":`HomeAssistant/${e.config.version}`}}).then(t=>{if(t.ok)return t.json();throw new Error(t.statusText)}),a=(t,e,i)=>fetch(`https://nominatim.openstreetmap.org/reverse.php?lat=${t[0]}&lon=${t[1]}&accept-language=${e.locale.language}&zoom=${i??18}&format=jsonv2&email=abuse@home-assistant.io`,{headers:{"User-Agent":`HomeAssistant/${e.config.version}`}}).then(t=>{if(t.ok)return t.json();throw new Error(t.statusText)})},96765(t,e,i){i.a(t,async function(t,o){try{i.r(e);i(74423);var a=i(62826),r=i(5124),s=i(22441),n=i(22786),c=i(8480),d=i(1087),l=i(38962),h=i(18350),p=i(33173),g=i(52763),u=i(65829),m=i(18885),_=i(85013),y=i(79007),v=i(17733),f=i(92946),b=t([l,h,g,u,f,p,c]);[l,h,g,u,f,p,c]=b.then?(await b)():b;class C extends r.WF{render(){return this._location?this._skipCore?r.qy`<div class="row center"> <ha-spinner></ha-spinner> </div>`:r.qy` ${this._error?r.qy`<ha-alert alert-type="error">${this._error}</ha-alert>`:r.s6} <p> ${this.onboardingLocalize("ui.panel.page-onboarding.core-config.country_intro")} </p> <ha-form .hass="${this.hass}" .data="${{country:this._country??"",time_zone:this._timeZone}}" .schema="${this._schema(!this._timeZoneDetected)}" .computeLabel="${this._computeLabel}" .disabled="${this._working}" @value-changed="${this._handleFormChanged}"></ha-form> <div class="footer"> <ha-button @click="${this._save}" .disabled="${this._working}"> ${this.onboardingLocalize("ui.panel.page-onboarding.core-config.finish")} </ha-button> </div> `:r.qy`<onboarding-location .hass="${this.hass}" .onboardingLocalize="${this.onboardingLocalize}" @value-changed="${this._locationChanged}"></onboarding-location>`}firstUpdated(t){super.firstUpdated(t),this.addEventListener("keyup",t=>{this._location&&"Enter"===t.key&&this._save(t)})}_handleFormChanged(t){const e=t.detail.value;this._country=e.country||void 0,e.time_zone&&(this._timeZone=e.time_zone)}async _locationChanged(t){if(this._location=t.detail.value.location,t.detail.value.country&&(this._country=t.detail.value.country),t.detail.value.elevation&&(this._elevation=t.detail.value.elevation),t.detail.value.currency&&(this._currency=t.detail.value.currency),t.detail.value.language&&(this._language=t.detail.value.language),t.detail.value.timezone&&(this._timeZone=t.detail.value.timezone,this._timeZoneDetected=!0),t.detail.value.unit_system&&(this._unitSystem=t.detail.value.unit_system),this._country&&this._timeZoneDetected)return this._skipCore=!0,void this._save(t);let e;if(navigator.language){const t=navigator.language.split("-").pop().toUpperCase();p.FS.includes(t)&&(e=t)}this._country=e,(0,d.r)(this,"onboarding-progress",{increase:.5}),await this.updateComplete,setTimeout(()=>this._form?.focus(),100)}async _save(t){if(this._location&&this._country&&this._timeZone){t.preventDefault(),this._working=!0;try{await(0,m.Td)(this.hass,{location_name:this.onboardingLocalize("ui.panel.page-onboarding.core-config.location_name_default"),latitude:this._location[0],longitude:this._location[1],elevation:Number(this._elevation),unit_system:this._unitSystem||["US","MM","LR"].includes(this._country)?"us_customary":"metric",time_zone:this._timeZone,currency:this._currency||_.a[this._country]||"EUR",country:this._country,language:this._language});const t=await(0,y.Xo)(this.hass);(0,d.r)(this,"onboarding-step",{type:"core_config",result:t})}catch(t){this._skipCore=!1,this._working=!1,this._error=t.message}}}constructor(...t){super(...t),this._working=!1,this._elevation="0",this._timeZone=c.n2,this._timeZoneDetected=c.fL,this._language=(0,v.wb)(),this._skipCore=!1,this._schema=(0,n.A)(t=>[{name:"country",required:!0,selector:{country:null}},...t?[{name:"time_zone",required:!0,selector:{timezone:null}}]:[]]),this._computeLabel=t=>this.hass.localize(`ui.panel.config.core.section.core.core_config.${t.name}`)}}C.styles=r.AH`.row{display:flex;flex-direction:row;margin:0 -8px;align-items:center;--ha-select-min-width:100px}.secondary{color:var(--secondary-text-color)}p{font-size:var(--ha-font-size-m);line-height:var(--ha-line-height-condensed)}.flex{flex:1}.middle-text{margin:16px 0}.row{margin-top:16px}.center{justify-content:center}.row>*{margin:0 8px}.radio-group{display:flex;flex-direction:column;flex:1}.footer{margin-top:16px;text-align:right}a{color:var(--primary-color)}`,(0,a.Cg)([(0,s.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,a.Cg)([(0,s.MZ)({attribute:!1})],C.prototype,"onboardingLocalize",void 0),(0,a.Cg)([(0,s.wk)()],C.prototype,"_working",void 0),(0,a.Cg)([(0,s.wk)()],C.prototype,"_location",void 0),(0,a.Cg)([(0,s.wk)()],C.prototype,"_timeZone",void 0),(0,a.Cg)([(0,s.wk)()],C.prototype,"_timeZoneDetected",void 0),(0,a.Cg)([(0,s.wk)()],C.prototype,"_country",void 0),(0,a.Cg)([(0,s.wk)()],C.prototype,"_error",void 0),(0,a.Cg)([(0,s.wk)()],C.prototype,"_skipCore",void 0),(0,a.Cg)([(0,s.P)("ha-form")],C.prototype,"_form",void 0),C=(0,a.Cg)([(0,s.EM)("onboarding-core-config")],C),o()}catch(t){o(t)}})},92946(t,e,i){i.a(t,async function(t,e){try{i(18111),i(20116),i(61701);var o=i(62826),a=i(5124),r=i(22441),s=i(22786),n=i(1087),c=i(38962),d=i(18350),l=(i(8630),i(28732),i(65829)),h=i(91485),p=i(99257),g=i(18885),u=i(3523),m=i(65063),_=i(54819),y=t([c,d,l,h,p]);[c,d,l,h,p]=y.then?(await y)():y;const v="M12,8A4,4 0 0,1 16,12A4,4 0 0,1 12,16A4,4 0 0,1 8,12A4,4 0 0,1 12,8M3.05,13H1V11H3.05C3.5,6.83 6.83,3.5 11,3.05V1H13V3.05C17.17,3.5 20.5,6.83 20.95,11H23V13H20.95C20.5,17.17 17.17,20.5 13,20.95V23H11V20.95C6.83,20.5 3.5,17.17 3.05,13M12,5A7,7 0 0,0 5,12A7,7 0 0,0 12,19A7,7 0 0,0 19,12A7,7 0 0,0 12,5Z",f="M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z",b="M12,11.5A2.5,2.5 0 0,1 9.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,11.5M12,2A7,7 0 0,0 5,9C5,14.25 12,22 12,22C12,22 19,14.25 19,9A7,7 0 0,0 12,2Z",C="M15.5,12C18,12 20,14 20,16.5C20,17.38 19.75,18.2 19.31,18.9L22.39,22L21,23.39L17.88,20.32C17.19,20.75 16.37,21 15.5,21C13,21 11,19 11,16.5C11,14 13,12 15.5,12M15.5,14A2.5,2.5 0 0,0 13,16.5A2.5,2.5 0 0,0 15.5,19A2.5,2.5 0 0,0 18,16.5A2.5,2.5 0 0,0 15.5,14M19.5,2A0.5,0.5 0 0,1 20,2.5V11.81C19.42,11.26 18.75,10.81 18,10.5V4.7L15,5.86V10C14.3,10.07 13.62,10.24 13,10.5V5.87L9,4.47V16.13H9V16.5C9,17.14 9.09,17.76 9.26,18.34L8,17.9L2.66,19.97L2.5,20A0.5,0.5 0 0,1 2,19.5V4.38C2,4.15 2.15,3.97 2.36,3.9L8,2L14,4.1L19.34,2.03L19.5,2M4,5.46V17.31L7,16.15V4.45L4,5.46Z",A=[52.3731339,4.8903147],M=matchMedia("(prefers-color-scheme: dark)"),k="location";class D extends a.WF{render(){const t=this.onboardingLocalize("ui.panel.page-onboarding.core-config.location_address",{openstreetmap:a.qy`<a href="https://www.openstreetmap.org/" target="_blank" rel="noopener noreferrer">OpenStreetMap</a>`,osm_privacy_policy:a.qy`<a href="https://wiki.osmfoundation.org/wiki/Privacy_Policy" target="_blank" rel="noopener noreferrer">${this.onboardingLocalize("ui.panel.page-onboarding.core-config.osm_privacy_policy")}</a>`});return a.qy` <h1> ${this.onboardingLocalize("ui.panel.page-onboarding.core-config.location_header")} </h1> ${this._error?a.qy`<ha-alert alert-type="error">${this._error}</ha-alert>`:a.s6} <p> ${this.onboardingLocalize("ui.panel.page-onboarding.core-config.intro_location")} </p> <div class="location-search"> <ha-input label="${this.onboardingLocalize("ui.panel.page-onboarding.core-config.address_label")}" .disabled="${this._working}" @keyup="${this._addressSearch}"> <ha-svg-icon slot="start" .path="${f}"></ha-svg-icon> ${this._working?a.qy`<ha-spinner slot="end" size="small"></ha-spinner>`:a.qy` <ha-icon-button @click="${this._handleButtonClick}" slot="end" .disabled="${this._working}" .label="${this.onboardingLocalize(this._search?"ui.common.search":"ui.panel.page-onboarding.core-config.button_detect")}" .path="${this._search?C:v}"></ha-icon-button> `} </ha-input> ${void 0!==this._places?a.qy` <ha-list activatable> ${this._places?.length?this._places.map(t=>{const e=[t.name||t.address[t.category],t.address.house_number,t.address.road||t.address.waterway,t.address.village||t.address.town,t.address.suburb||t.address.subdivision,t.address.city||t.address.municipality].filter(Boolean).join(", "),i=[t.address.county||t.address.state_district||t.address.region,t.address.state,t.address.country].filter(Boolean).join(", ");return a.qy`<ha-list-item @click="${this._itemClicked}" .placeId="${t.place_id}" .selected="${this._highlightedMarker===t.place_id}" .activated="${this._highlightedMarker===t.place_id}" .twoline="${e&&i}"> ${e||i} <span slot="secondary">${e?i:""}</span> </ha-list-item>`}):a.qy`<ha-list-item noninteractive>${null===this._places?"":"No results"}</ha-list-item>`} </ha-list> `:a.s6} </div> <ha-locations-editor class="flex" .hass="${this.hass}" .locations="${this._markerLocations(this._location,this._places,this._highlightedMarker)}" zoom="14" .themeMode="${M.matches?"dark":"light"}" .disabled="${this._working}" @location-updated="${this._locationChanged}" @marker-clicked="${this._markerClicked}"></ha-locations-editor> <p class="attribution">${t}</p> <div class="footer"> <ha-button @click="${this._save}" .disabled="${this._working}"> ${this.onboardingLocalize("ui.panel.page-onboarding.core-config.finish")} </ha-button> </div> `}firstUpdated(t){super.firstUpdated(t),setTimeout(()=>this._input.focus(),100),this.addEventListener("keyup",t=>{"Enter"===t.key&&this._save(t)})}updated(t){if(t.has("_highlightedMarker")&&this._highlightedMarker){const t=this._places?.find(t=>t.place_id===this._highlightedMarker);4===t?.boundingbox?.length?this.map.fitBounds([[t.boundingbox[0],t.boundingbox[2]],[t.boundingbox[1],t.boundingbox[3]]],{zoom:16,pad:0}):this.map.fitMarker(String(this._highlightedMarker),{zoom:16})}}_locationChanged(t){this._location=t.detail.location,t.detail.id!==k&&this._reverseGeocode()}_markerClicked(t){if(t.detail.id===k)return;this._highlightedMarker=Number(t.detail.id);const e=this._places.find(e=>e.place_id===Number(t.detail.id));this._location=[Number(e.lat),Number(e.lon)],this._country=e.address.country_code.toUpperCase()}_itemClicked(t){this._highlightedMarker=t.currentTarget.placeId;const e=this._places.find(e=>e.place_id===t.currentTarget.placeId);this._location=[Number(e.lat),Number(e.lon)],this._country=e.address.country_code.toUpperCase()}async _addressSearch(t){t.stopPropagation(),this._search=(t.currentTarget.value??"").length>0,"Enter"===t.key&&this._searchAddress(t.currentTarget.value??"")}async _searchAddress(t){this._working=!0,this._highlightedMarker=void 0,this._error=void 0,this._places=null,this.map.addEventListener("markers-updated",()=>{setTimeout(()=>{(this._places?.length||0)>2&&this.map.fitMap({pad:.5})},500)},{once:!0});try{this._places=await(0,u.h)(t,this.hass,!0,3),this._places?.length&&(this._highlightedMarker=this._places[0].place_id,this._location=[Number(this._places[0].lat),Number(this._places[0].lon)],this._country=this._places[0].address.country_code.toUpperCase())}catch(t){this._places=void 0,this._error=t.message}finally{this._working=!1}}async _reverseGeocode(){if(!this._location)return;this._places=null;const t=await(0,u.R)(this._location,this.hass);this._country=t.address.country_code.toUpperCase(),this._places=[t],this._highlightedMarker=t.place_id}async _handleButtonClick(t){this._search?this._searchAddress(t.target.parentElement.value):this._detectLocation()}_detectLocation(){if(window.isSecureContext&&navigator.geolocation){this._working=!0;const t={enableHighAccuracy:!0,timeout:5e3,maximumAge:0};navigator.geolocation.getCurrentPosition(async t=>{this.map.addEventListener("markers-updated",()=>{this.map.fitMarker(k)},{once:!0}),this._location=[t.coords.latitude,t.coords.longitude],t.coords.altitude&&(this._elevation=String(Math.round(t.coords.altitude)));try{await this._reverseGeocode()}finally{this._working=!1}},()=>{this._working=!1,this._whoAmI()},t)}else this._whoAmI()}async _whoAmI(){if(await(0,m.dk)(this,{title:this.onboardingLocalize("ui.panel.page-onboarding.core-config.title_location_detect"),text:this.onboardingLocalize("ui.panel.page-onboarding.core-config.intro_location_detect")})){this._working=!0;try{const t=await(0,g.pz)(this.hass);t.latitude&&t.longitude&&(this.map.addEventListener("markers-updated",()=>{this.map.fitMarker(k)},{once:!0}),this._location=[Number(t.latitude),Number(t.longitude)]),t.elevation&&(this._elevation=String(t.elevation)),t.unit_system&&(this._unitSystem=t.unit_system),t.time_zone&&(this._timeZone=t.time_zone),t.currency&&(this._currency=t.currency),t.country&&(this._country=t.country)}catch(t){this._error=`Failed to detect location information: ${t.message}`}finally{this._working=!1}}}async _save(t){this._location&&(t.preventDefault(),(0,n.r)(this,"value-changed",{value:{location:this._location,country:this._country,elevation:this._elevation,unit_system:this._unitSystem,time_zone:this._timeZone,currency:this._currency}}))}static get styles(){return[_.o,a.AH`.location-search{margin-top:32px;margin-bottom:32px}ha-locations-editor{display:block;height:300px;margin-top:8px;border-radius:var(--mdc-shape-large,16px);overflow:hidden}ha-list{width:100%;border:1px solid var(--divider-color);box-sizing:border-box;border-top-width:0;border-bottom-left-radius:var(--mdc-shape-small,4px);border-bottom-right-radius:var(--mdc-shape-small,4px);--mdc-list-vertical-padding:0}ha-list-item{height:72px}.attribution{margin:0;padding:4px 16px 12px 16px;color:var(--mdc-text-field-label-ink-color,rgba(0,0,0,.6));font-family:var(
--mdc-typography-caption-font-family,
var(--mdc-typography-font-family, var(--ha-font-family-body))
);font-size:var(
--mdc-typography-caption-font-size,
var(--ha-font-size-xs)
);font-weight:var(--mdc-typography-caption-font-weight,var(--ha-font-weight-normal));letter-spacing:var(
--mdc-typography-caption-letter-spacing,
.0333333333em
);text-decoration:var(--mdc-typography-caption-text-decoration,inherit);text-transform:var(--mdc-typography-caption-text-transform,inherit)}.attribution a{color:inherit}`]}constructor(...t){super(...t),this._working=!1,this._location=A,this._search=!1,this._markerLocations=(0,s.A)((t,e,i)=>e?e?.length?e.map(e=>({id:String(e.place_id),iconPath:e.place_id===i?void 0:b,latitude:t&&e.place_id===i?t[0]:Number(e.lat),longitude:t&&e.place_id===i?t[1]:Number(e.lon),location_editable:e.place_id===i})):[]:[{id:k,latitude:(t||A)[0],longitude:(t||A)[1],location_editable:!0}])}}(0,o.Cg)([(0,r.MZ)({attribute:!1})],D.prototype,"hass",void 0),(0,o.Cg)([(0,r.MZ)({attribute:!1})],D.prototype,"onboardingLocalize",void 0),(0,o.Cg)([(0,r.wk)()],D.prototype,"_working",void 0),(0,o.Cg)([(0,r.wk)()],D.prototype,"_location",void 0),(0,o.Cg)([(0,r.wk)()],D.prototype,"_places",void 0),(0,o.Cg)([(0,r.wk)()],D.prototype,"_error",void 0),(0,o.Cg)([(0,r.wk)()],D.prototype,"_search",void 0),(0,o.Cg)([(0,r.wk)()],D.prototype,"_highlightedMarker",void 0),(0,o.Cg)([(0,r.P)("ha-locations-editor",!0)],D.prototype,"map",void 0),(0,o.Cg)([(0,r.P)("ha-input")],D.prototype,"_input",void 0),D=(0,o.Cg)([(0,r.EM)("onboarding-location")],D),e()}catch(t){e(t)}})},77957(t,e,i){var o=i(76080),a=i(79504),r=i(47055),s=i(48981),n=i(56969),c=i(26198),d=i(2360),l=i(35370),h=Array,p=a([].push);t.exports=function(t,e,i,a){for(var g,u,m,_=s(t),y=r(_),v=o(e,i),f=d(null),b=c(y),C=0;b>C;C++)m=y[C],(u=n(v(m,C,_)))in f?p(f[u],m):f[u]=[m];if(a&&(g=a(_))!==h)for(u in f)f[u]=l(g,f[u]);return f}},46058(t,e,i){var o=i(46518),a=i(77957),r=i(6469);o({target:"Array",proto:!0},{group:function(t){return a(this,t,arguments.length>1?arguments[1]:void 0)}}),r("group")}};