UNPKG

iobroker.lovelace

Version:

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

8 lines 25.4 kB
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["36265"],{99426:function(e,t,i){i.r(t);var a=i(61701),s=(i(71695),i(47021),i(57243)),r=i(50778),n=i(35359),o=i(36522);i(23334),i(37583);let d,l,c,h,u=e=>e;const p={info:"M11,9H13V7H11M12,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,2M11,17H13V11H11V17Z",warning:"M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16",error:"M11,15H13V17H11V15M11,7H13V13H11V7M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20Z",success:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2,4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"};(0,a.Z)([(0,r.Mo)("ha-alert")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,r.Cb)()],key:"title",value(){return""}},{kind:"field",decorators:[(0,r.Cb)({attribute:"alert-type"})],key:"alertType",value(){return"info"}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"dismissable",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"narrow",value(){return!1}},{kind:"method",key:"render",value:function(){return(0,s.dy)(d||(d=u` <div class="issue-type ${0}" role="alert"> <div class="icon ${0}"> <slot name="icon"> <ha-svg-icon .path="${0}"></ha-svg-icon> </slot> </div> <div class="${0}"> <div class="main-content"> ${0} <slot></slot> </div> <div class="action"> <slot name="action"> ${0} </slot> </div> </div> </div> `),(0,n.$)({[this.alertType]:!0}),this.title?"":"no-title",p[this.alertType],(0,n.$)({content:!0,narrow:this.narrow}),this.title?(0,s.dy)(l||(l=u`<div class="title">${0}</div>`),this.title):s.Ld,this.dismissable?(0,s.dy)(c||(c=u`<ha-icon-button @click="${0}" label="Dismiss alert" .path="${0}"></ha-icon-button>`),this._dismissClicked,"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"):s.Ld)}},{kind:"method",key:"_dismissClicked",value:function(){(0,o.B)(this,"alert-dismissed-clicked")}},{kind:"field",static:!0,key:"styles",value(){return(0,s.iv)(h||(h=u`.issue-type{position:relative;padding:8px;display:flex}.issue-type::after{position:absolute;top:0;right:0;bottom:0;left:0;opacity:.12;pointer-events:none;content:"";border-radius:4px}.icon{z-index:1}.icon.no-title{align-self:center}.content{display:flex;justify-content:space-between;align-items:center;width:100%;text-align:var(--float-start)}.content.narrow{flex-direction:column;align-items:flex-end}.action{z-index:1;width:min-content;--mdc-theme-primary:var(--primary-text-color)}.main-content{overflow-wrap:anywhere;word-break:break-word;margin-left:8px;margin-right:0;margin-inline-start:8px;margin-inline-end:0}.title{margin-top:2px;font-weight:700}.action ha-icon-button,.action mwc-button{--mdc-theme-primary:var(--primary-text-color);--mdc-icon-button-size:36px}.issue-type.info>.icon{color:var(--info-color)}.issue-type.info::after{background-color:var(--info-color)}.issue-type.warning>.icon{color:var(--warning-color)}.issue-type.warning::after{background-color:var(--warning-color)}.issue-type.error>.icon{color:var(--error-color)}.issue-type.error::after{background-color:var(--error-color)}.issue-type.success>.icon{color:var(--success-color)}.issue-type.success::after{background-color:var(--success-color)}:host ::slotted(ul){margin:0;padding-inline-start:20px}`))}}]}}),s.oi)},59826:function(e,t,i){var a=i(61701),s=(i(71695),i(47021),i(31622)),r=i(57243),n=i(50778),o=i(22344);let d,l=e=>e;(0,a.Z)([(0,n.Mo)("ha-button")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",static:!0,key:"styles",value(){return[o.W,(0,r.iv)(d||(d=l`::slotted([slot=icon]){margin-inline-start:0px;margin-inline-end:8px;direction:var(--direction);display:block}.mdc-button{height:var(--button-height,36px)}.trailing-icon{display:flex}.slot-container{overflow:var(--button-slot-container-overflow,visible)}:host([destructive]){--mdc-theme-primary:var(--error-color)}`))]}}]}}),s.Button)},55486:function(e,t,i){var a=i(61701),s=(i(71695),i(47021),i(4918)),r=i(6394),n=i(57243),o=i(50778),d=i(35359),l=i(36522);let c,h,u=e=>e;(0,a.Z)([(0,o.Mo)("ha-formfield")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,o.Cb)({type:Boolean,reflect:!0})],key:"disabled",value(){return!1}},{kind:"method",key:"render",value:function(){const e={"mdc-form-field--align-end":this.alignEnd,"mdc-form-field--space-between":this.spaceBetween,"mdc-form-field--nowrap":this.nowrap};return(0,n.dy)(c||(c=u` <div class="mdc-form-field ${0}"> <slot></slot> <label class="mdc-label" @click="${0}"> <slot name="label">${0}</slot> </label> </div>`),(0,d.$)(e),this._labelClick,this.label)}},{kind:"method",key:"_labelClick",value:function(){const e=this.input;if(e&&(e.focus(),!e.disabled))switch(e.tagName){case"HA-CHECKBOX":e.checked=!e.checked,(0,l.B)(e,"change");break;case"HA-RADIO":e.checked=!0,(0,l.B)(e,"change");break;default:e.click()}}},{kind:"field",static:!0,key:"styles",value(){return[r.W,(0,n.iv)(h||(h=u`:host(:not([alignEnd])) ::slotted(ha-switch){margin-right:10px;margin-inline-end:10px;margin-inline-start:inline}.mdc-form-field{align-items:var(--ha-formfield-align-items,center);gap:4px}.mdc-form-field>label{direction:var(--direction);margin-inline-start:0;margin-inline-end:auto;padding:0}:host([disabled]) label{color:var(--disabled-text-color)}`))]}}]}}),s.a)},34326:function(e,t,i){var a=i(61701),s=(i(71695),i(47021),i(57243)),r=i(50778);i(23334),i(83166);let n,o,d,l=e=>e;(0,a.Z)([(0,r.Mo)("ha-password-field")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"invalid",value:void 0},{kind:"field",decorators:[(0,r.Cb)({attribute:"error-message"})],key:"errorMessage",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"icon",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"iconTrailing",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)()],key:"autocomplete",value:void 0},{kind:"field",decorators:[(0,r.Cb)()],key:"autocorrect",value:void 0},{kind:"field",decorators:[(0,r.Cb)({attribute:"input-spellcheck"})],key:"inputSpellcheck",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:String})],key:"value",value(){return""}},{kind:"field",decorators:[(0,r.Cb)({type:String})],key:"placeholder",value(){return""}},{kind:"field",decorators:[(0,r.Cb)({type:String})],key:"label",value(){return""}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean,reflect:!0})],key:"disabled",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"required",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Number})],key:"minLength",value(){return-1}},{kind:"field",decorators:[(0,r.Cb)({type:Number})],key:"maxLength",value(){return-1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean,reflect:!0})],key:"outlined",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:String})],key:"helper",value(){return""}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"validateOnInitialRender",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:String})],key:"validationMessage",value(){return""}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"autoValidate",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:String})],key:"pattern",value(){return""}},{kind:"field",decorators:[(0,r.Cb)({type:Number})],key:"size",value(){return null}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"helperPersistent",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"charCounter",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"endAligned",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:String})],key:"prefix",value(){return""}},{kind:"field",decorators:[(0,r.Cb)({type:String})],key:"suffix",value(){return""}},{kind:"field",decorators:[(0,r.Cb)({type:String})],key:"name",value(){return""}},{kind:"field",decorators:[(0,r.Cb)({type:String,attribute:"input-mode"})],key:"inputMode",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"readOnly",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({attribute:!1,type:String})],key:"autocapitalize",value(){return""}},{kind:"field",decorators:[(0,r.SB)()],key:"_unmaskedPassword",value(){return!1}},{kind:"field",decorators:[(0,r.IO)("ha-textfield")],key:"_textField",value:void 0},{kind:"method",key:"render",value:function(){var e;return(0,s.dy)(n||(n=l`<ha-textfield .invalid="${0}" .errorMessage="${0}" .icon="${0}" .iconTrailing="${0}" .autocomplete="${0}" .autocorrect="${0}" .inputSpellcheck="${0}" .value="${0}" .placeholder="${0}" .label="${0}" .disabled="${0}" .required="${0}" .minLength="${0}" .maxLength="${0}" .outlined="${0}" .helper="${0}" .validateOnInitialRender="${0}" .validationMessage="${0}" .autoValidate="${0}" .pattern="${0}" .size="${0}" .helperPersistent="${0}" .charCounter="${0}" .endAligned="${0}" .prefix="${0}" .name="${0}" .inputMode="${0}" .readOnly="${0}" .autocapitalize="${0}" .type="${0}" .suffix="${0}" @input="${0}" @change="${0}"></ha-textfield> <ha-icon-button .label="${0}" @click="${0}" .path="${0}"></ha-icon-button>`),this.invalid,this.errorMessage,this.icon,this.iconTrailing,this.autocomplete,this.autocorrect,this.inputSpellcheck,this.value,this.placeholder,this.label,this.disabled,this.required,this.minLength,this.maxLength,this.outlined,this.helper,this.validateOnInitialRender,this.validationMessage,this.autoValidate,this.pattern,this.size,this.helperPersistent,this.charCounter,this.endAligned,this.prefix,this.name,this.inputMode,this.readOnly,this.autocapitalize,this._unmaskedPassword?"text":"password",(0,s.dy)(o||(o=l`<div style="width:24px"></div>`)),this._handleInputEvent,this._handleChangeEvent,(null===(e=this.hass)||void 0===e?void 0:e.localize(this._unmaskedPassword?"ui.components.selectors.text.hide_password":"ui.components.selectors.text.show_password"))||(this._unmaskedPassword?"Hide password":"Show password"),this._toggleUnmaskedPassword,this._unmaskedPassword?"M11.83,9L15,12.16C15,12.11 15,12.05 15,12A3,3 0 0,0 12,9C11.94,9 11.89,9 11.83,9M7.53,9.8L9.08,11.35C9.03,11.56 9,11.77 9,12A3,3 0 0,0 12,15C12.22,15 12.44,14.97 12.65,14.92L14.2,16.47C13.53,16.8 12.79,17 12,17A5,5 0 0,1 7,12C7,11.21 7.2,10.47 7.53,9.8M2,4.27L4.28,6.55L4.73,7C3.08,8.3 1.78,10 1,12C2.73,16.39 7,19.5 12,19.5C13.55,19.5 15.03,19.2 16.38,18.66L16.81,19.08L19.73,22L21,20.73L3.27,3M12,7A5,5 0 0,1 17,12C17,12.64 16.87,13.26 16.64,13.82L19.57,16.75C21.07,15.5 22.27,13.86 23,12C21.27,7.61 17,4.5 12,4.5C10.6,4.5 9.26,4.75 8,5.2L10.17,7.35C10.74,7.13 11.35,7 12,7Z":"M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z")}},{kind:"method",key:"focus",value:function(){this._textField.focus()}},{kind:"method",key:"checkValidity",value:function(){return this._textField.checkValidity()}},{kind:"method",key:"reportValidity",value:function(){return this._textField.reportValidity()}},{kind:"method",key:"setCustomValidity",value:function(e){return this._textField.setCustomValidity(e)}},{kind:"method",key:"layout",value:function(){return this._textField.layout()}},{kind:"method",key:"_toggleUnmaskedPassword",value:function(){this._unmaskedPassword=!this._unmaskedPassword}},{kind:"method",decorators:[(0,r.hO)({passive:!0})],key:"_handleInputEvent",value:function(e){this.value=e.target.value}},{kind:"method",decorators:[(0,r.hO)({passive:!0})],key:"_handleChangeEvent",value:function(e){this.value=e.target.value,this._reDispatchEvent(e)}},{kind:"method",key:"_reDispatchEvent",value:function(e){const t=new Event(e.type,e);this.dispatchEvent(t)}},{kind:"field",static:!0,key:"styles",value(){return(0,s.iv)(d||(d=l`:host{display:block;position:relative}ha-textfield{width:100%}ha-icon-button{position:absolute;top:8px;right:8px;inset-inline-start:initial;inset-inline-end:8px;--mdc-icon-button-size:40px;--mdc-icon-size:20px;color:var(--secondary-text-color);direction:var(--direction)}`))}}]}}),s.oi)},30509:function(e,t,i){var a=i(61701),s=(i(71695),i(47021),i(57243)),r=i(50778);let n,o,d=e=>e;(0,a.Z)([(0,r.Mo)("ha-settings-row")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,r.Cb)({type:Boolean,reflect:!0})],key:"narrow",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean,reflect:!0})],key:"slim",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean,attribute:"three-line"})],key:"threeLine",value(){return!1}},{kind:"field",decorators:[(0,r.Cb)({type:Boolean,attribute:"wrap-heading",reflect:!0})],key:"wrapHeading",value(){return!1}},{kind:"method",key:"render",value:function(){return(0,s.dy)(n||(n=d` <div class="prefix-wrap"> <slot name="prefix"></slot> <div class="body" ?two-line="${0}" ?three-line="${0}"> <slot name="heading"></slot> <div class="secondary"><slot name="description"></slot></div> </div> </div> <div class="content"><slot></slot></div> `),!this.threeLine,this.threeLine)}},{kind:"field",static:!0,key:"styles",value(){return(0,s.iv)(o||(o=d`:host{display:flex;padding:0 16px;align-content:normal;align-self:auto;align-items:center}.body{padding-top:8px;padding-bottom:8px;padding-left:0;padding-inline-start:0;padding-right:16px;padding-inline-end:16px;overflow:hidden;display:var(--layout-vertical_-_display,flex);flex-direction:var(--layout-vertical_-_flex-direction,column);justify-content:var(--layout-center-justified_-_justify-content,center);flex:var(--layout-flex_-_flex,1);flex-basis:var(--layout-flex_-_flex-basis,0.000000001px)}.body[three-line]{min-height:var(--paper-item-body-three-line-min-height,88px)}:host(:not([wrap-heading])) body>*{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.body>.secondary{display:block;padding-top:4px;font-family:var( --mdc-typography-body2-font-family, var(--mdc-typography-font-family, Roboto, sans-serif) );-webkit-font-smoothing:antialiased;font-size:var(--mdc-typography-body2-font-size, .875rem);font-weight:var(--mdc-typography-body2-font-weight,400);line-height:normal;color:var(--secondary-text-color)}.body[two-line]{min-height:calc(var(--paper-item-body-two-line-min-height,72px) - 16px);flex:1}.content{display:contents}:host(:not([narrow])) .content{display:var(--settings-row-content-display,flex);justify-content:flex-end;flex:1;padding:16px 0}.content ::slotted(*){width:var(--settings-row-content-width)}:host([narrow]){align-items:normal;flex-direction:column;border-top:1px solid var(--divider-color);padding-bottom:8px}::slotted(ha-switch){padding:16px 0}.secondary{white-space:normal}.prefix-wrap{display:var(--settings-row-prefix-display)}:host([narrow]) .prefix-wrap{display:flex;align-items:center}:host([slim]),:host([slim]) .content,:host([slim]) ::slotted(ha-switch){padding:0}:host([slim]) .body{min-height:0}`))}}]}}),s.oi)},17170:function(e,t,i){i.a(e,(async function(e,a){try{i.r(t),i.d(t,{HaSpinner:()=>p});var s=i(61701),r=i(72621),n=(i(71695),i(47021),i(97677)),o=i(43580),d=i(57243),l=i(50778),c=e([n]);n=(c.then?(await c)():c)[0];let h,u=e=>e,p=(0,s.Z)([(0,l.Mo)("ha-spinner")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,l.Cb)()],key:"size",value:void 0},{kind:"method",key:"updated",value:function(e){if((0,r.Z)(i,"updated",this,3)([e]),e.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")}}},{kind:"field",static:!0,key:"styles",value(){return[o.Z,(0,d.iv)(h||(h=u`: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)}`))]}}]}}),n.Z);a()}catch(h){a(h)}}))},1888:function(e,t,i){var a=i(61701),s=i(72621),r=(i(71695),i(47021),i(62523)),n=i(83835),o=i(57243),d=i(50778),l=i(13560);let c,h=e=>e;(0,a.Z)([(0,d.Mo)("ha-switch")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,d.Cb)({type:Boolean})],key:"haptic",value(){return!1}},{kind:"method",key:"firstUpdated",value:function(){(0,s.Z)(i,"firstUpdated",this,3)([]),this.addEventListener("change",(()=>{this.haptic&&(0,l.j)("light")}))}},{kind:"field",static:!0,key:"styles",value(){return[n.W,(0,o.iv)(c||(c=h`:host{--mdc-theme-secondary:var(--switch-checked-color)}.mdc-switch.mdc-switch--checked .mdc-switch__thumb{background-color:var(--switch-checked-button-color);border-color:var(--switch-checked-button-color)}.mdc-switch.mdc-switch--checked .mdc-switch__track{background-color:var(--switch-checked-track-color);border-color:var(--switch-checked-track-color)}.mdc-switch:not(.mdc-switch--checked) .mdc-switch__thumb{background-color:var(--switch-unchecked-button-color);border-color:var(--switch-unchecked-button-color)}.mdc-switch:not(.mdc-switch--checked) .mdc-switch__track{background-color:var(--switch-unchecked-track-color);border-color:var(--switch-unchecked-track-color)}`))]}}]}}),r.H)},43546:function(e,t,i){i.d(t,{Cp:()=>n,TZ:()=>o,W2:()=>r,YY:()=>l,iI:()=>s,j2:()=>d,oT:()=>a});i(19083),i(9359),i(70104),i(77439),i(19423),i(40251),i(97499),i(61006);const a=e=>e.map((e=>{if("string"!==e.type)return e;switch(e.name){case"username":return Object.assign(Object.assign({},e),{},{autocomplete:"username",autofocus:!0});case"password":return Object.assign(Object.assign({},e),{},{autocomplete:"current-password"});case"code":return Object.assign(Object.assign({},e),{},{autocomplete:"one-time-code",autofocus:!0});default:return e}})),s=(e,t)=>e.callWS({type:"auth/sign_path",path:t}),r=async(e,t,i,a)=>e.callWS({type:"config/auth_provider/homeassistant/create",user_id:t,username:i,password:a}),n=(e,t,i)=>e.callWS({type:"config/auth_provider/homeassistant/change_password",current_password:t,new_password:i}),o=(e,t,i)=>e.callWS({type:"config/auth_provider/homeassistant/admin_change_password",user_id:t,password:i}),d=(e,t,i)=>e.callWS({type:"config/auth_provider/homeassistant/admin_change_username",user_id:t,username:i}),l=(e,t,i)=>e.callWS({type:"auth/delete_all_refresh_tokens",token_type:t,delete_current_token:i})},78845:function(e,t,i){i.a(e,(async function(e,a){try{i.r(t),i.d(t,{DialogAddUser:()=>w});var s=i(61701),r=i(72621),n=(i(71695),i(40251),i(47021),i(57243)),o=i(50778),d=(i(99426),i(59826),i(17170)),l=i(73729),c=(i(55486),i(23334),i(30509),i(1888),i(83166),i(43546)),h=i(4242),u=i(28008),p=(i(34326),e([d]));d=(p.then?(await p)():p)[0];let y,m,v,f,k,g,_,b=e=>e,w=(0,s.Z)([(0,o.Mo)("dialog-add-user")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_loading",value(){return!1}},{kind:"field",decorators:[(0,o.SB)()],key:"_error",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_params",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_name",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_username",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_password",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_passwordConfirm",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_isAdmin",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_localOnly",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_allowChangeName",value(){return!0}},{kind:"method",key:"showDialog",value:function(e){this._params=e,this._name=this._params.name||"",this._username="",this._password="",this._passwordConfirm="",this._isAdmin=!1,this._localOnly=!1,this._error=void 0,this._loading=!1,this._params.name?(this._allowChangeName=!1,this._maybePopulateUsername()):this._allowChangeName=!0}},{kind:"method",key:"firstUpdated",value:function(e){(0,r.Z)(i,"firstUpdated",this,3)([e]),this.addEventListener("keypress",(e=>{"Enter"===e.key&&this._createUser(e)}))}},{kind:"method",key:"render",value:function(){return this._params?(0,n.dy)(y||(y=b` <ha-dialog open @closed="${0}" scrimClickAction escapeKeyAction .heading="${0}"> <div> ${0} ${0} <ha-textfield class="username" name="username" .label="${0}" .value="${0}" required @input="${0}" .validationMessage="${0}" dialogInitialFocus></ha-textfield> <ha-password-field .label="${0}" name="password" .value="${0}" required @input="${0}" .validationMessage="${0}"></ha-password-field> <ha-password-field .label="${0}" name="passwordConfirm" .value="${0}" @input="${0}" required .invalid="${0}" .errorMessage="${0}"></ha-password-field> <ha-settings-row> <span slot="heading"> ${0} </span> <span slot="description"> ${0} </span> <ha-switch .checked="${0}" @change="${0}"> </ha-switch> </ha-settings-row> <ha-settings-row> <span slot="heading"> ${0} </span> <span slot="description"> ${0} </span> <ha-switch .checked="${0}" @change="${0}"> </ha-switch> </ha-settings-row> ${0} </div> ${0} </ha-dialog> `),this._close,(0,l.i)(this.hass,this.hass.localize("ui.panel.config.users.add_user.caption")),this._error?(0,n.dy)(m||(m=b` <div class="error">${0}</div> `),this._error):"",this._allowChangeName?(0,n.dy)(v||(v=b`<ha-textfield class="name" name="name" .label="${0}" .value="${0}" required .validationMessage="${0}" @input="${0}" @blur="${0}" dialogInitialFocus></ha-textfield>`),this.hass.localize("ui.panel.config.users.editor.name"),this._name,this.hass.localize("ui.common.error_required"),this._handleValueChanged,this._maybePopulateUsername):"",this.hass.localize("ui.panel.config.users.editor.username"),this._username,this._handleValueChanged,this.hass.localize("ui.common.error_required"),this.hass.localize("ui.panel.config.users.add_user.password"),this._password,this._handleValueChanged,this.hass.localize("ui.common.error_required"),this.hass.localize("ui.panel.config.users.add_user.password_confirm"),this._passwordConfirm,this._handleValueChanged,""!==this._password&&""!==this._passwordConfirm&&this._passwordConfirm!==this._password,this.hass.localize("ui.panel.config.users.add_user.password_not_match"),this.hass.localize("ui.panel.config.users.editor.local_access_only"),this.hass.localize("ui.panel.config.users.editor.local_access_only_description"),this._localOnly,this._localOnlyChanged,this.hass.localize("ui.panel.config.users.editor.admin"),this.hass.localize("ui.panel.config.users.editor.admin_description"),this._isAdmin,this._adminChanged,this._isAdmin?n.Ld:(0,n.dy)(f||(f=b` <ha-alert alert-type="info"> ${0} </ha-alert> `),this.hass.localize("ui.panel.config.users.users_privileges_note")),this._loading?(0,n.dy)(k||(k=b` <div slot="primaryAction" class="submit-spinner"> <ha-spinner></ha-spinner> </div> `)):(0,n.dy)(g||(g=b` <ha-button slot="primaryAction" .disabled="${0}" @click="${0}"> ${0} </ha-button> `),!this._name||!this._username||!this._password||this._password!==this._passwordConfirm,this._createUser,this.hass.localize("ui.panel.config.users.add_user.create"))):n.Ld}},{kind:"method",key:"_close",value:function(){this._params=void 0}},{kind:"method",key:"_maybePopulateUsername",value:function(){if(this._username||!this._name)return;const e=this._name.split(" ");e.length&&(this._username=e[0].toLowerCase())}},{kind:"method",key:"_handleValueChanged",value:function(e){this._error=void 0;const t=e.target;this[`_${t.name}`]=t.value}},{kind:"method",key:"_adminChanged",value:async function(e){const t=e.target;this._isAdmin=t.checked}},{kind:"method",key:"_localOnlyChanged",value:function(e){const t=e.target;this._localOnly=t.checked}},{kind:"method",key:"_createUser",value:async function(e){if(e.preventDefault(),!this._name||!this._username||!this._password)return;let t;this._loading=!0,this._error="";try{t=(await(0,h.r4)(this.hass,this._name,[this._isAdmin?h.Pb:h.CE],this._localOnly)).user}catch(i){return this._loading=!1,void(this._error=i.message)}try{await(0,c.W2)(this.hass,t.id,this._username,this._password)}catch(i){return await(0,h.h8)(this.hass,t.id),this._loading=!1,void(this._error=i.message)}t.username=this._username,t.credentials=[{type:"homeassistant"}],this._params.userAddedCallback(t),this._close()}},{kind:"get",static:!0,key:"styles",value:function(){return[u.yu,(0,n.iv)(_||(_=b`ha-dialog{--mdc-dialog-max-width:500px;--dialog-z-index:10}.row{display:flex;padding:8px 0}ha-password-field,ha-textfield{display:block;margin-bottom:8px}ha-settings-row{padding:0}`))]}}]}}),n.oi);a()}catch(y){a(y)}}))}}]); //# sourceMappingURL=36265.a53ca762da30b01f.js.map