"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["81493"],{44244:function(a,o,t){t.a(a,async function(a,i){try{t.r(o);t(3362),t(62953);var s=t(40445),e=t(96196),n=t(77845),r=t(1087),l=t(38962),c=t(18350),d=t(72554),p=(t(93444),t(91485)),h=t(31420),_=t(14503),u=t(63993),g=a([l,c,d,p,h,u]);[l,c,d,p,h,u]=g.then?(await g)():g;let y,k,b,w,m=a=>a;class f extends e.WF{showDialog(a){this._open=!0,this._params=a}closeDialog(){return this._open=!1,!0}_dialogClosed(){this._open&&(0,r.r)(this,"dialog-closed",{dialog:this.localName}),this._open=!1,this._params=void 0,this._encryptionKey="",this._error=""}render(){return this._params?(0,e.qy)(y||(y=m` <ha-dialog .hass="${0}" .open="${0}" header-title="${0}" prevent-scrim-close @closed="${0}"> <p> ${0} </p> <p> ${0} </p> <ha-input type="password" password-toggle .label="${0}" @input="${0}"></ha-input> ${0} <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" appearance="plain" @click="${0}"> ${0} </ha-button> <ha-button slot="primaryAction" @click="${0}"> ${0} </ha-button> </ha-dialog-footer> </ha-dialog> `),this.hass,this._open,this.hass.localize("ui.panel.config.backup.dialogs.download.title"),this._dialogClosed,this.hass.localize("ui.panel.config.backup.dialogs.download.description"),this.hass.localize("ui.panel.config.backup.dialogs.download.download_backup_encrypted",{download_it_encrypted:(0,e.qy)(k||(k=m`<button class="link" @click="${0}"> ${0} </button>`),this._downloadEncrypted,this.hass.localize("ui.panel.config.backup.dialogs.download.download_it_encrypted"))}),this.hass.localize("ui.panel.config.backup.dialogs.download.encryption_key"),this._keyChanged,this._error?(0,e.qy)(b||(b=m`<ha-alert alert-type="error">${0}</ha-alert>`),this._error):e.s6,this._cancel,this.hass.localize("ui.common.cancel"),this._submit,this.hass.localize("ui.panel.config.backup.dialogs.download.download")):e.s6}_cancel(){this.closeDialog()}async _submit(){if(""!==this._encryptionKey)try{await(0,h.Zm)(this.hass,this._params.backup.backup_id,this._agentId,this._encryptionKey),(0,u.s)(this.hass,this._params.backup.backup_id,this._agentId,this._encryptionKey),this.closeDialog()}catch(a){"password_incorrect"===(null==a?void 0:a.code)?this._error=this.hass.localize("ui.panel.config.backup.dialogs.download.incorrect_encryption_key"):"decrypt_not_supported"===(null==a?void 0:a.code)?this._error=this.hass.localize("ui.panel.config.backup.dialogs.download.decryption_not_supported"):alert(a.message)}}_keyChanged(a){this._encryptionKey=a.currentTarget.value,this._error=""}get _agentId(){var a;return null!==(a=this._params)&&void 0!==a&&a.agentId?this._params.agentId:(0,h.EB)(Object.keys(this._params.backup.agents))}async _downloadEncrypted(){(0,u.s)(this.hass,this._params.backup.backup_id,this._agentId),this.closeDialog()}static get styles(){return[_.RF,_.nA,(0,e.AH)(w||(w=m`ha-dialog{--dialog-content-padding:var(--ha-space-2) var(--ha-space-6)}button.link{background:0 0;border:none;padding:0;font-size:var(--ha-font-size-m);color:var(--primary-color);text-decoration:underline;cursor:pointer}`))]}constructor(...a){super(...a),this._open=!1,this._encryptionKey="",this._error=""}}(0,s.Cg)([(0,n.MZ)({attribute:!1})],f.prototype,"hass",void 0),(0,s.Cg)([(0,n.wk)()],f.prototype,"_open",void 0),(0,s.Cg)([(0,n.wk)()],f.prototype,"_params",void 0),(0,s.Cg)([(0,n.wk)()],f.prototype,"_encryptionKey",void 0),(0,s.Cg)([(0,n.wk)()],f.prototype,"_error",void 0),f=(0,s.Cg)([(0,n.EM)("ha-dialog-download-decrypted-backup")],f),i()}catch(y){i(y)}})}}]);
//# sourceMappingURL=81493.b3d908d1636956bb.js.map