UNPKG

iobroker.lovelace

Version:

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

8 lines 26.1 kB
/*! For license information please see 69304.1a1f3b3e670db75d.js.LICENSE.txt */ export const __rspack_esm_id=69304;export const __rspack_esm_ids=[69304];export const __webpack_modules__={93421(e,t,a){a.d(t,{IW:()=>c,dH:()=>h,fI:()=>l});a(44114);var o=a(35211),r=a(22792),i=a(32172);const s=(e,t)=>{let a=e;for(const e of t){if(null==a)return;a=a[e]}return a},n=(e,t,a)=>{const r=(0,i.p)({transformer:function(e){return a.call(this,e)},watch:t?[t]:[]}),s=(0,o.Fg)({context:e,subscribe:!0});return(e,t)=>{r(e,t),s(e,t)}},l=e=>n(r.iN,e.entityIdPath[0],function(t){const a=s(this,e.entityIdPath);return"string"==typeof a?t?.[a]:void 0}),h=e=>n(r.X1,e.entityIdPath[0],function(t){const a=s(this,e.entityIdPath);return"string"==typeof a?t?.[a]:void 0}),c=()=>n(r.D5,void 0,({localize:e})=>e)},32172(e,t,a){a.d(t,{p:()=>o});a(18111),a(7588),a(45367),a(92731),a(17642),a(58004),a(33853),a(45876),a(32475),a(15024),a(31698);function o(e){return(t,a)=>{if("object"==typeof a)throw new Error("This decorator does not support this compilation type.");const o=String(a),r=t;if(r._transformers){if(!r.hasOwnProperty("_transformers")){const e=r._transformers;r._transformers=new Map,e.forEach((e,t)=>r._transformers.set(t,e))}}else{r._transformers=new Map,r._watching=new Map;const e=r.willUpdate;r.willUpdate=function(t){e.call(this,t);const a=new Set;t.forEach((e,t)=>{const o=this._watching.get(t);void 0!==o&&o.forEach(e=>a.add(e))}),a.forEach(e=>{this[e]=this[`__original_${String(e)}`]})}}r._transformers.set(a,e.transformer),e.watch&&e.watch.forEach(e=>{let t=r._watching.get(e);t||(t=new Set,r._watching.set(e,t)),t.add(a)});const i=Object.getOwnPropertyDescriptor(t,a);let s;if(void 0===i)s={get(){return this[`__transform_${o}`]},set(e){const t=this[`__transform_${o}`],a=this._transformers.get(o);this[`__transform_${o}`]=a?a.call(this,e):e,this[`__original_${o}`]=e,this.requestUpdate(o,t)},configurable:!0,enumerable:!0};else{const e=i.set;s={...i,set(t){const a=this[`__transform_${o}`],r=this._transformers.get(o);this[`__transform_${o}`]=r?r.call(this,t):t,this[`__original_${o}`]=t,this.requestUpdate(o,a),e?.call(this,t)}}}Object.defineProperty(t,a,s)}}},38962(e,t,a){a.a(e,async function(e,o){try{a.r(t);var r=a(62826),i=a(5124),s=a(22441),n=a(6412),l=a(93421),h=a(1087),c=a(26300),d=(a(67094),e([c]));c=(d.then?(await d)():d)[0];const p="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",u={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"};class m extends i.WF{render(){return i.qy` <div class="issue-type ${(0,n.H)({[this.alertType]:!0})}" role="alert"> <div class="icon ${this.title?"":"no-title"}"> <slot name="icon"> <ha-svg-icon .path="${u[this.alertType]}"></ha-svg-icon> </slot> </div> <div class="${(0,n.H)({content:!0,narrow:this.narrow})}"> <div class="main-content"> ${this.title?i.qy`<div class="title">${this.title}</div>`:i.s6} <slot></slot> </div> <div class="action"> <slot name="action"> ${this.dismissable?i.qy`<ha-icon-button @click="${this._dismissClicked}" .label="${this._localize?.("ui.common.dismiss_alert")}" .path="${p}"></ha-icon-button>`:i.s6} </slot> </div> </div> </div> `}_dismissClicked(){(0,h.r)(this,"alert-dismissed-clicked")}constructor(...e){super(...e),this.title="",this.alertType="info",this.dismissable=!1,this.narrow=!1}}m.styles=i.AH`.issue-type{position:relative;padding:8px;display:flex}.icon{height:var(--ha-alert-icon-size,24px);width:var(--ha-alert-icon-size,24px)}.issue-type::after{position:absolute;top:0;right:0;bottom:0;left:0;opacity:.12;pointer-events:none;content:"";border-radius:var(--ha-border-radius-sm)}.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;line-height:normal;margin-left:8px;margin-right:0;margin-inline-start:8px;margin-inline-end:8px}.title{margin-top:2px;font-weight:var(--ha-font-weight-bold)}.action ha-icon-button{--mdc-theme-primary:var(--primary-text-color);--ha-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}`,(0,r.Cg)([(0,s.MZ)()],m.prototype,"title",void 0),(0,r.Cg)([(0,s.MZ)({attribute:"alert-type"})],m.prototype,"alertType",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean})],m.prototype,"dismissable",void 0),(0,r.Cg)([(0,s.wk)(),(0,l.IW)()],m.prototype,"_localize",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean})],m.prototype,"narrow",void 0),m=(0,r.Cg)([(0,s.EM)("ha-alert")],m),o()}catch(e){o(e)}})},59646(e,t,a){a.a(e,async function(e,t){try{var o=a(62826),r=a(29344),i=a(5124),s=a(22441),n=a(88360),l=e([r]);r=(l.then?(await l)():l)[0];class h extends r.A{updated(e){super.updated(e),e.has("haptic")&&(this.haptic?this.addEventListener("change",this._forwardHaptic):this.removeEventListener("change",this._forwardHaptic))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",this._forwardHaptic)}static get styles(){return[r.A.styles,i.AH`:host{--wa-form-control-toggle-size:var(--ha-switch-size, 24px);--wa-form-control-required-content:var( --ha-switch-required-marker, var(--ha-input-required-marker, "*") );--wa-form-control-required-content-offset:var( --ha-switch-required-marker-offset, 0.1rem );--thumb-size:var(--ha-switch-thumb-size, 18px);--width:var(--ha-switch-width, 48px)}label{position:relative;height:max(var(--thumb-size),var(--wa-form-control-toggle-size))}label::before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:100%;height:100%;min-width:var(--ha-switch-min-touch-size,40px);min-height:var(--ha-switch-min-touch-size,40px)}label.disabled::before{pointer-events:none}.switch{background-color:var(--ha-switch-background-color,var(--ha-color-fill-disabled-quiet-resting));border-color:var(--ha-switch-border-color,var(--ha-color-border-neutral-normal))}label:not(.disabled) .input:focus-visible~.switch,label:not(.disabled):hover .switch{background-color:var(--ha-switch-background-color-hover,var(--ha-switch-background-color,var(--ha-color-fill-disabled-quiet-hover)))}.checked .switch{background-color:var(--ha-switch-checked-background-color,var(--ha-color-fill-primary-normal-resting));border-color:var(--ha-switch-checked-border-color,var(--ha-color-border-primary-loud))}label:not(.disabled).checked .input:focus-visible~.switch,label:not(.disabled).checked:hover .switch{background-color:var(--ha-switch-checked-background-color-hover,var(--ha-switch-checked-background-color,var(--ha-color-fill-primary-normal-hover)));border-color:var(--ha-switch-checked-border-color-hover,var(--ha-switch-checked-border-color,var(--ha-color-border-primary-loud)))}.switch .thumb{background-color:var(--ha-switch-thumb-background-color,var(--ha-color-on-neutral-normal));border-color:var(--ha-switch-thumb-border-color,var(--ha-color-on-neutral-normal));border-style:var(--wa-form-control-border-style);border-width:var(--wa-form-control-border-width);box-shadow:var(--ha-switch-thumb-box-shadow,var(--ha-box-shadow-s))}label:not(.disabled) .input:focus-visible~.switch .thumb,label:not(.disabled):hover .switch .thumb{background-color:var(--ha-switch-thumb-background-color-hover,var(--ha-switch-thumb-background-color,var(--ha-color-on-neutral-normal)));border-color:var(--ha-switch-thumb-border-color-hover,var(--ha-switch-thumb-border-color,var(--ha-color-on-neutral-normal)))}.checked .switch .thumb{background-color:var(--ha-switch-checked-thumb-background-color,var(--ha-color-on-primary-normal));border-color:var(--ha-switch-checked-thumb-border-color,var(--ha-color-on-primary-normal))}label:not(.disabled).checked .input:focus-visible~.switch .thumb,label:not(.disabled).checked:hover .switch .thumb{background-color:var(--ha-switch-checked-thumb-background-color-hover,var(--ha-switch-checked-thumb-background-color,var(--ha-color-on-primary-normal)));border-color:var(--ha-switch-checked-thumb-border-color-hover,var(--ha-switch-checked-thumb-border-color,var(--ha-color-on-primary-normal)))}label.disabled{opacity:var(--ha-switch-disabled-opacity, .3);cursor:not-allowed}label:not(.disabled) .input:focus-visible~.switch .thumb{outline:0;outline-offset:none}label:not(.disabled) .input:focus-visible~.switch{outline:var(--wa-focus-ring);outline-offset:var(--wa-focus-ring-offset)}:host(:empty) slot.label{display:none}`]}constructor(...e){super(...e),this.haptic=!1,this._forwardHaptic=()=>{(0,n.j)(this,"light")}}}(0,o.Cg)([(0,s.MZ)({type:Boolean})],h.prototype,"haptic",void 0),h=(0,o.Cg)([(0,s.EM)("ha-switch")],h),t()}catch(e){t(e)}})},83892(e,t,a){a.d(t,{x:()=>n});a(18111),a(13579);var o=a(62826),r=a(92070),i=a(5124),s=a(22441);class n extends i.WF{_onSlotChange(e){return t=>{const a=t.target.assignedNodes({flatten:!0}).some(e=>e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE&&""!==e.textContent?.trim());"start"===e?this._hasStart=a:this._hasEnd=a}}render(){return this._renderBase(this._renderInner())}_renderBase(e){return i.qy`<div part="base" class="base" id="item">${e}</div>`}_renderInner(){const e=this._slotController.test("content");return i.qy` <div part="start" class="start" ?hidden="${!this._hasStart}"> <slot name="start" @slotchange="${this._onSlotChange("start")}"></slot> </div> <div part="content" class="content"> ${e?i.qy`<slot name="content"></slot>`:this._renderDefaultContent()} </div> <div part="end" class="end" ?hidden="${!this._hasEnd}"> <slot name="end" @slotchange="${this._onSlotChange("end")}"></slot> </div> `}_renderDefaultContent(){const e=this._slotController.test("headline"),t=this._slotController.test("supporting-text"),a=e||void 0!==this.headline,o=t||void 0!==this.supportingText;return i.qy` ${a?i.qy`<div part="headline" class="headline"> <slot name="headline">${this.headline??i.s6}</slot> </div>`:i.s6} ${o?i.qy`<div part="supporting-text" class="supporting"> <slot name="supporting-text">${this.supportingText??i.s6}</slot> </div>`:i.s6} `}constructor(...e){super(...e),this.disabled=!1,this._slotController=new r.X(this,"headline","supporting-text","content"),this._hasStart=!1,this._hasEnd=!1}}n.styles=i.AH`:host{display:block;color:var(--primary-text-color);font-size:var(--ha-font-size-m);line-height:var(--ha-line-height-normal)}:host([disabled]){color:var(--disabled-text-color);pointer-events:none}.base{position:relative;display:flex;flex-direction:row;align-items:center;gap:var(--ha-row-item-gap,var(--ha-space-4));padding-block:var(--ha-row-item-padding-block,var(--ha-space-3));padding-inline:var(--ha-row-item-padding-inline,var(--ha-space-4));min-height:var(--ha-row-item-min-height,48px);box-sizing:border-box}.content{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;justify-content:center}.end,.start{display:flex;align-items:center;flex:0 0 auto}.end[hidden],.start[hidden]{display:none}.headline{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.supporting{color:var(--secondary-text-color);font-size:var(--ha-font-size-s);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}`,(0,o.Cg)([(0,s.MZ)({type:String})],n.prototype,"headline",void 0),(0,o.Cg)([(0,s.MZ)({type:String,attribute:"supporting-text"})],n.prototype,"supportingText",void 0),(0,o.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],n.prototype,"disabled",void 0),(0,o.Cg)([(0,s.wk)()],n.prototype,"_hasStart",void 0),(0,o.Cg)([(0,s.wk)()],n.prototype,"_hasEnd",void 0),n=(0,o.Cg)([(0,s.EM)("ha-row-item")],n)},82e3(e,t,a){a.d(t,{D5:()=>o,Fy:()=>s,Gk:()=>h,Hg:()=>r,Y_:()=>c,ds:()=>l,e0:()=>i,ec:()=>n});a(74423),a(18111),a(61701),a(33110);const o=14881==a.j?`${location.protocol}//${location.host}`:null,r=e=>e.map(e=>{if("string"!==e.type)return e;switch(e.name){case"username":return{...e,autocomplete:"username",autofocus:!0};case"password":return{...e,autocomplete:"current-password"};case"code":return{...e,autocomplete:"one-time-code",autofocus:!0};default:return e}}),i=(e,t)=>e.callWS({type:"auth/sign_path",path:t}),s=async(e,t,a,o)=>e.callWS({type:"config/auth_provider/homeassistant/create",user_id:t,username:a,password:o}),n=(e,t,a)=>e.callWS({type:"config/auth_provider/homeassistant/change_password",current_password:t,new_password:a}),l=(e,t,a)=>e.callWS({type:"config/auth_provider/homeassistant/admin_change_password",user_id:t,password:a}),h=(e,t,a)=>e.callWS({type:"config/auth_provider/homeassistant/admin_change_username",user_id:t,username:a}),c=(e,t,a)=>e.callWS({type:"auth/delete_all_refresh_tokens",token_type:t,delete_current_token:a})},81131(e,t,a){a.a(e,async function(e,o){try{a.r(t),a.d(t,{DialogAddUser:()=>b});var r=a(62826),i=a(5124),s=a(22441),n=a(1087),l=a(38962),h=a(18350),c=a(72554),d=(a(93444),a(26300)),p=a(59646),u=a(91485),m=(a(83892),a(82e3)),g=a(28669),v=a(14503),w=e([l,h,c,d,p,u]);[l,h,c,d,p,u]=w.then?(await w)():w;class b extends i.WF{showDialog(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,this._open=!0}firstUpdated(e){super.firstUpdated(e),this.addEventListener("keypress",e=>{"Enter"===e.key&&this._createUser(e)})}render(){return this._params?i.qy` <ha-dialog .open="${this._open}" prevent-scrim-close header-title="${this.hass.localize("ui.panel.config.users.add_user.caption")}" @closed="${this._dialogClosed}"> <div> ${this._error?i.qy` <div class="error">${this._error}</div> `:""} ${this._allowChangeName?i.qy`<ha-input class="name" name="name" .label="${this.hass.localize("ui.panel.config.users.editor.name")}" .value="${this._name}" required .validationMessage="${this.hass.localize("ui.common.error_required")}" @input="${this._handleValueChanged}" @blur="${this._maybePopulateUsername}" autofocus></ha-input>`:""} <ha-input class="username" name="username" .label="${this.hass.localize("ui.panel.config.users.editor.username")}" .value="${this._username}" required @input="${this._handleValueChanged}" .validationMessage="${this.hass.localize("ui.common.error_required")}" ?autofocus="${!this._allowChangeName}"></ha-input> <ha-input type="password" password-toggle .label="${this.hass.localize("ui.panel.config.users.add_user.password")}" name="password" .value="${this._password}" required @input="${this._handleValueChanged}" .validationMessage="${this.hass.localize("ui.common.error_required")}"></ha-input> <ha-input type="password" password-toggle .label="${this.hass.localize("ui.panel.config.users.add_user.password_confirm")}" name="passwordConfirm" .value="${this._passwordConfirm}" @input="${this._handleValueChanged}" required .invalid="${""!==this._password&&""!==this._passwordConfirm&&this._passwordConfirm!==this._password}" .errorMessage="${this.hass.localize("ui.panel.config.users.add_user.password_not_match")}"></ha-input> <ha-row-item> <span slot="headline">${this.hass.localize("ui.panel.config.users.editor.local_access_only")}</span> <span slot="supporting-text">${this.hass.localize("ui.panel.config.users.editor.local_access_only_description")}</span> <ha-switch slot="end" .checked="${this._localOnly}" @change="${this._localOnlyChanged}"></ha-switch> </ha-row-item> <ha-row-item> <span slot="headline">${this.hass.localize("ui.panel.config.users.editor.admin")}</span> <span slot="supporting-text">${this.hass.localize("ui.panel.config.users.editor.admin_description")}</span> <ha-switch slot="end" .checked="${this._isAdmin}" @change="${this._adminChanged}"></ha-switch> </ha-row-item> ${this._isAdmin?i.s6:i.qy` <ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.users.users_privileges_note")} </ha-alert> `} </div> <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" appearance="plain" @click="${this._close}"> ${this.hass.localize("ui.common.cancel")} </ha-button> <ha-button slot="primaryAction" .disabled="${!this._name||!this._username||!this._password||this._password!==this._passwordConfirm}" @click="${this._createUser}" .loading="${this._loading}"> ${this.hass.localize("ui.panel.config.users.add_user.create")} </ha-button> </ha-dialog-footer> </ha-dialog> `:i.s6}_close(){this._open=!1}_dialogClosed(){this._params=void 0,(0,n.r)(this,"dialog-closed",{dialog:this.localName})}_maybePopulateUsername(){if(this._username||!this._name)return;const e=this._name.split(" ");e.length&&(this._username=e[0].toLowerCase())}_handleValueChanged(e){this._error=void 0;const t=e.target;this[`_${t.name}`]=t.value}async _adminChanged(e){const t=e.target;this._isAdmin=t.checked}_localOnlyChanged(e){const t=e.target;this._localOnly=t.checked}async _createUser(e){if(e.preventDefault(),!this._name||!this._username||!this._password)return;let t;this._loading=!0,this._error="";try{t=(await(0,g.kg)(this.hass,this._name,[this._isAdmin?g.wj:g.eR],this._localOnly)).user}catch(e){return this._loading=!1,void(this._error=e.message)}try{await(0,m.Fy)(this.hass,t.id,this._username,this._password)}catch(e){return await(0,g.hG)(this.hass,t.id),this._loading=!1,void(this._error=e.message)}t.username=this._username,t.credentials=[{type:"homeassistant"}],this._params.userAddedCallback(t),this._close()}static get styles(){return[v.nA,i.AH`ha-dialog{--dialog-z-index:10}.row{display:flex;padding:8px 0}ha-row-item{--ha-row-item-padding-inline:0}`]}constructor(...e){super(...e),this._loading=!1,this._open=!1,this._allowChangeName=!0}}(0,r.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_loading",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_error",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_params",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_open",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_name",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_username",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_password",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_passwordConfirm",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_isAdmin",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_localOnly",void 0),(0,r.Cg)([(0,s.wk)()],b.prototype,"_allowChangeName",void 0),b=(0,r.Cg)([(0,s.EM)("dialog-add-user")],b),o()}catch(e){o(e)}})},29344(e,t,a){a.a(e,async function(e,o){try{a.d(t,{A:()=>k});var r=a(5124),i=a(22441),s=a(6412),n=a(63672),l=a(34514),h=a(40991),c=a(92070),d=a(41268),p=a(9395),u=a(62676),m=a(15477),g=a(31896),v=a(17060),w=a(19978),b=e([v]);v=(b.then?(await b)():b)[0];var _=Object.defineProperty,f=Object.getOwnPropertyDescriptor,y=(e,t,a,o)=>{for(var r,i=o>1?void 0:o?f(t,a):t,s=e.length-1;s>=0;s--)(r=e[s])&&(i=(o?r(t,a,i):r(i))||i);return o&&i&&_(t,a,i),i};let k=class extends u.q{static get validators(){return[...super.validators,(0,d.i)()]}get value(){return this._value??"on"}set value(e){this._value=e}handleSizeChange(){(0,h.b)(this.localName,this.size)}get checked(){return this.valueHasChanged?Boolean(this._checked):this._checked??this.defaultChecked}set checked(e){this._checked=Boolean(e),this.valueHasChanged=!0}handleClick(){this.hasInteracted=!0,this.checked=!this.checked,this.updateComplete.then(()=>{this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))})}handleKeyDown(e){const t="rtl"===this.localize.dir();"ArrowLeft"===e.key&&(e.preventDefault(),this.checked=t,this.updateComplete.then(()=>{this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0}))})),"ArrowRight"===e.key&&(e.preventDefault(),this.checked=!t,this.updateComplete.then(()=>{this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0}))}))}willUpdate(e){super.willUpdate(e),(e.has("value")||e.has("checked")||e.has("defaultChecked"))&&this.handleValueOrCheckedChange()}handleValueOrCheckedChange(){this.setValue(this.checked?this.value:null,this._value),this.updateValidity()}handleStateChange(){this.hasUpdated&&(this.input.checked=this.checked),this.customStates.set("checked",this.checked),this.updateValidity()}handleDisabledChange(){this.updateValidity()}click(){this.input.click()}focus(e){this.input.focus(e)}blur(){this.input.blur()}setValue(e,t){this.checked?this.internals.setFormValue(e??"on",t):this.internals.setFormValue(null,null)}formResetCallback(){this._checked=null,super.formResetCallback(),this.handleValueOrCheckedChange()}render(){const e=this.hasUpdated?this.hasSlotController.test("hint"):this.withHint,t=!!this.hint||!!e;return r.qy` <label part="base" class="${(0,s.H)({checked:this.checked,disabled:this.disabled})}"> <input class="input" type="checkbox" title="${this.title}" name="${(0,n.J)(this.name)}" value="${(0,n.J)(this.value)}" .checked="${(0,l.V)(this.checked)}" .disabled="${this.disabled}" .required="${this.required}" role="switch" aria-checked="${this.checked?"true":"false"}" aria-describedby="hint" @click="${this.handleClick}" @keydown="${this.handleKeyDown}"> <span part="control" class="switch"> <span part="thumb" class="thumb"></span> </span> <slot part="label" class="label"></slot> </label> <slot id="hint" name="hint" part="hint" class="${(0,s.H)({"has-slotted":t})}" aria-hidden="${t?"false":"true"}">${this.hint}</slot> `}constructor(){super(...arguments),this.hasSlotController=new c.X(this,"hint"),this.localize=new v.c(this),this.title="",this.name=null,this._value=this.getAttribute("value")??null,this.size="m",this.disabled=!1,this._checked=null,this.defaultChecked=this.hasAttribute("checked"),this.required=!1,this.hint="",this.withHint=!1}};k.shadowRootOptions={...u.q.shadowRootOptions,delegatesFocus:!0},k.css=[m.A,g.A,w.A],y([(0,i.P)('input[type="checkbox"]')],k.prototype,"input",2),y([(0,i.MZ)()],k.prototype,"title",2),y([(0,i.MZ)({reflect:!0})],k.prototype,"name",2),y([(0,i.MZ)({reflect:!0})],k.prototype,"value",1),y([(0,i.MZ)({reflect:!0})],k.prototype,"size",2),y([(0,p.w)("size")],k.prototype,"handleSizeChange",1),y([(0,i.MZ)({type:Boolean})],k.prototype,"disabled",2),y([(0,i.MZ)({type:Boolean,attribute:!1})],k.prototype,"checked",1),y([(0,i.MZ)({type:Boolean,attribute:"checked",reflect:!0})],k.prototype,"defaultChecked",2),y([(0,i.MZ)({type:Boolean,reflect:!0})],k.prototype,"required",2),y([(0,i.MZ)({attribute:"hint"})],k.prototype,"hint",2),y([(0,i.MZ)({attribute:"with-hint",type:Boolean})],k.prototype,"withHint",2),y([(0,p.w)(["checked","defaultChecked"])],k.prototype,"handleStateChange",1),y([(0,p.w)("disabled",{waitUntilFirstUpdate:!0})],k.prototype,"handleDisabledChange",1),k=y([(0,i.EM)("wa-switch")],k),k.disableWarning?.("change-in-update"),o()}catch(e){o(e)}})},19978(e,t,a){a.d(t,{A:()=>o});var o=a(5124).AH`:host{--height:var(--wa-form-control-toggle-size);--width:calc(var(--height) * 1.75);--thumb-size:0.75em;display:inline-flex;line-height:var(--wa-form-control-value-line-height)}label{position:relative;display:flex;align-items:center;font:inherit;color:var(--wa-form-control-value-color);vertical-align:middle;cursor:pointer}.switch{flex:0 0 auto;position:relative;display:flex;align-items:center;justify-content:center;width:var(--width);height:var(--height);background-color:var(--wa-form-control-background-color);border-color:var(--wa-form-control-border-color);border-radius:var(--height);border-style:var(--wa-form-control-border-style);border-width:var(--wa-form-control-border-width);transition-property:translate,background,border-color,box-shadow;transition-duration:var(--wa-transition-normal);transition-timing-function:var(--wa-transition-easing)}.switch .thumb{aspect-ratio:1/1;width:var(--thumb-size);height:var(--thumb-size);background-color:var(--wa-form-control-border-color);border-radius:50%;translate:calc((var(--width) - var(--height))/ -2);transition:inherit}.switch .thumb:dir(rtl){translate:calc((var(--width) - var(--height))/ 2)}.input{position:absolute;opacity:0;padding:0;margin:0;pointer-events:none}label:not(.disabled) .input:focus-visible~.switch .thumb{outline:var(--wa-focus-ring);outline-offset:var(--wa-focus-ring-offset)}.checked .switch{background-color:var(--wa-form-control-activated-color);border-color:var(--wa-form-control-activated-color)}.checked .switch .thumb{background-color:var(--wa-color-surface-default);translate:calc((var(--width) - var(--height))/ 2)}.checked .switch .thumb:dir(rtl){translate:calc((var(--width) - var(--height))/ -2)}label:has(> :disabled){opacity:.5;cursor:not-allowed}[part~=label]{display:inline-block;line-height:var(--height);margin-inline-start:.5em;user-select:none;-webkit-user-select:none}:host([required]) [part~=label]::after{content:var(--wa-form-control-required-content);color:var(--wa-form-control-required-content-color);margin-inline-start:var(--wa-form-control-required-content-offset)}@media (forced-colors:active){:checked+.switch .thumb,:checked:enabled+.switch:hover .thumb{background-color:ButtonText}}`}};