"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(93444),i(26300)),h=i(72554),d=(i(17308),i(2846),i(71418)),y=i(31420),_=i(14503),g=i(81619),u=t([l,p,h,d,y]);[l,p,h,d,y]=u.then?(await u)():u;let m,k,b,v,f,w,$=t=>t;const x="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",C="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z",H=["key","done"];class K extends a.WF{showDialog(t){this._params=t,this._step=H[0],this._open=!0,this._newEncryptionKey=(0,y.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=H.indexOf(this._step);t!==H.length-1&&(this._step=H[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)(m||(m=$` <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)(k||(k=$` <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)(b||(b=$` <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)(v||(v=$` <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,x,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,C,this.hass.localize("ui.panel.config.backup.encryption_key.download_emergency_kit_action"));case"done":return(0,a.qy)(f||(f=$` <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,g.P)(this,{message:this.hass.localize("ui.common.copied_clipboard")})}_download(){this._newEncryptionKey&&(0,y.Sx)(this.hass,this._newEncryptionKey)}async _submit(){this._newEncryptionKey&&(this._params.saveKey(this._newEncryptionKey),this._nextStep())}static get styles(){return[_.RF,_.nA,(0,a.AH)(w||(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})],K.prototype,"hass",void 0),(0,s.Cg)([(0,o.wk)()],K.prototype,"_open",void 0),(0,s.Cg)([(0,o.wk)()],K.prototype,"_step",void 0),(0,s.Cg)([(0,o.wk)()],K.prototype,"_params",void 0),(0,s.Cg)([(0,o.wk)()],K.prototype,"_newEncryptionKey",void 0),K=(0,s.Cg)([(0,o.EM)("ha-dialog-set-backup-encryption-key")],K),n()}catch(m){n(m)}})}}]);
//# sourceMappingURL=11966.7918b15a59d4a978.js.map