"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["11966"],{50157:function(t,e,i){i.a(t,async function(t,n){try{i.r(e);i(3362),i(62953);var s=i(40445),a=i(96196),o=i(77845),c=i(1087),r=i(63130),l=i(18350),p=i(72554),h=(i(93444),i(26300)),d=(i(17308),i(2846),i(31420)),y=i(14503),_=i(81619),g=t([l,p,h,d]);[l,p,h,d]=g.then?(await g)():g;let u,m,k,b,v,f,w=t=>t;const $="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z",x="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z",C=["key","done"];class H extends a.WF{showDialog(t){this._params=t,this._step=C[0],this._open=!0,this._newEncryptionKey=(0,d.cq)()}closeDialog(){return this._open=!1,!0}_dialogClosed(){var t;null!==(t=this._params)&&void 0!==t&&t.cancel&&this._params.cancel(),this._step=void 0,this._params=void 0,this._newEncryptionKey=void 0,this._open=!1,(0,c.r)(this,"dialog-closed",{dialog:this.localName})}_done(){var t;null===(t=this._params)||void 0===t||t.submit(!0),this.closeDialog()}_nextStep(){const t=C.indexOf(this._step);t!==C.length-1&&(this._step=C[t+1])}render(){if(!this._params||!this._step)return a.s6;const t="key"===this._step?this.hass.localize("ui.panel.config.backup.dialogs.set_encryption_key.key.title"):"";return(0,a.qy)(u||(u=w` <ha-dialog .hass="${0}" .open="${0}" header-title="${0}" prevent-scrim-close @closed="${0}"> ${0} <ha-dialog-footer slot="footer"> ${0} </ha-dialog-footer> </ha-dialog> `),this.hass,this._open,t,this._dialogClosed,this._renderStepContent(),"key"===this._step?(0,a.qy)(m||(m=w` <ha-button slot="primaryAction" @click="${0}" .disabled="${0}"> ${0} </ha-button> `),this._submit,!this._newEncryptionKey,this.hass.localize("ui.panel.config.backup.dialogs.set_encryption_key.actions.set")):(0,a.qy)(k||(k=w` <ha-button slot="primaryAction" @click="${0}"> ${0} </ha-button> `),this._done,this.hass.localize("ui.panel.config.backup.dialogs.set_encryption_key.actions.done")))}_renderStepContent(){switch(this._step){case"key":return(0,a.qy)(b||(b=w` <p> ${0} </p> <div class="encryption-key"> <p>${0}</p> <ha-icon-button .path="${0}" @click="${0}"></ha-icon-button> </div> <ha-md-list> <ha-md-list-item> <span slot="headline"> ${0} </span> <span slot="supporting-text"> ${0} </span> <ha-button size="small" appearance="plain" slot="end" @click="${0}"> <ha-svg-icon .path="${0}" slot="start"></ha-svg-icon> ${0} </ha-button> </ha-md-list-item> </ha-md-list> `),this.hass.localize("ui.panel.config.backup.dialogs.set_encryption_key.new.description"),this._newEncryptionKey,$,this._copyKeyToClipboard,this.hass.localize("ui.panel.config.backup.encryption_key.download_emergency_kit"),this.hass.localize("ui.panel.config.backup.encryption_key.download_emergency_kit_description"),this._download,x,this.hass.localize("ui.panel.config.backup.encryption_key.download_emergency_kit_action"));case"done":return(0,a.qy)(v||(v=w` <div class="done"> <img src="/static/images/voice-assistant/hi.png" alt="Casita Home Assistant logo"> <h1> ${0} </h1> </div> `),this.hass.localize("ui.panel.config.backup.dialogs.set_encryption_key.done.title"))}return a.s6}async _copyKeyToClipboard(){await(0,r.l)(this._newEncryptionKey,this.renderRoot.querySelector("div")),(0,_.P)(this,{message:this.hass.localize("ui.common.copied_clipboard")})}_download(){this._newEncryptionKey&&(0,d.Sx)(this.hass,this._newEncryptionKey)}async _submit(){this._newEncryptionKey&&(this._params.saveKey(this._newEncryptionKey),this._nextStep())}static get styles(){return[y.RF,y.nA,(0,a.AH)(f||(f=w`ha-dialog{--dialog-content-padding:var(--ha-space-2) var(--ha-space-6)}ha-md-list{background:0 0;--md-list-item-leading-space:0;--md-list-item-trailing-space:0}.encryption-key{border:1px solid var(--divider-color);background-color:var(--primary-background-color);border-radius:var(--ha-border-radius-md);padding:16px;display:flex;flex-direction:row;align-items:center;gap:var(--ha-space-6)}.encryption-key p{margin:0;flex:1;font-size:var(--ha-font-size-xl);font-family:var(--ha-font-family-code);font-style:normal;font-weight:var(--ha-font-weight-normal);line-height:var(--ha-line-height-condensed);text-align:center}.encryption-key ha-icon-button{flex:none;margin:-16px}p{margin-top:0}.done{text-align:center}`))]}constructor(...t){super(...t),this._open=!1}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],H.prototype,"hass",void 0),(0,s.Cg)([(0,o.wk)()],H.prototype,"_open",void 0),(0,s.Cg)([(0,o.wk)()],H.prototype,"_step",void 0),(0,s.Cg)([(0,o.wk)()],H.prototype,"_params",void 0),(0,s.Cg)([(0,o.wk)()],H.prototype,"_newEncryptionKey",void 0),H=(0,s.Cg)([(0,o.EM)("ha-dialog-set-backup-encryption-key")],H),n()}catch(u){n(u)}})}}]);
//# sourceMappingURL=11966.0adaa11dd1b51395.js.map