"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["8611"],{38542:function(e,t,r){r.a(e,async function(e,s){try{r.r(t),r.d(t,{FlowPreviewGeneric:function(){return l}});r(35748),r(12977),r(5934),r(95013);var i=r(69868),o=r(84922),a=r(11991),_=r(38534),n=r(99264),h=r(51849),d=r(44017),u=(r(94124),e([n]));n=(u.then?(await u)():u)[0];let p,c,w=e=>e;class l extends o.WF{disconnectedCallback(){super.disconnectedCallback(),this._unsub&&(this._unsub.then(e=>e()),this._unsub=void 0)}willUpdate(e){e.has("stepData")&&this._debouncedSubscribePreview()}render(){return this._error?(0,o.qy)(p||(p=w`<ha-alert alert-type="error">${0}</ha-alert>`),this._error):(0,o.qy)(c||(c=w`<entity-preview-row .hass="${0}" .stateObj="${0}"></entity-preview-row>`),this.hass,this._preview)}async _subscribePreview(){if(this._unsub&&((await this._unsub)(),this._unsub=void 0),"config_flow"===this.flowType||"options_flow"===this.flowType||"config_subentries_flow"===this.flowType){this._error=void 0;try{this._unsub=(0,_.Q)(this.hass,this.domain,this.flowId,this.flowType,this.stepData,this._setPreview),await this._unsub,(0,d.r)(this,"set-flow-errors",{errors:{}})}catch(e){"string"==typeof e.message?this._error=e.message:(this._error=void 0,(0,d.r)(this,"set-flow-errors",e.message)),this._unsub=void 0,this._preview=void 0}}}constructor(...e){super(...e),this._setPreview=e=>{if(e.error)return this._error=e.error,void(this._preview=void 0);const t=(new Date).toISOString();this._preview=Object.assign({entity_id:`${this.stepId}.___flow_preview___`,last_changed:t,last_updated:t,context:{id:"",parent_id:null,user_id:null}},e)},this._debouncedSubscribePreview=(0,h.s)(()=>{this._subscribePreview()},250)}}(0,i.__decorate)([(0,a.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,i.__decorate)([(0,a.MZ)({attribute:!1})],l.prototype,"flowType",void 0),(0,i.__decorate)([(0,a.MZ)()],l.prototype,"domain",void 0),(0,i.__decorate)([(0,a.MZ)({attribute:!1})],l.prototype,"stepId",void 0),(0,i.__decorate)([(0,a.MZ)({attribute:!1})],l.prototype,"flowId",void 0),(0,i.__decorate)([(0,a.MZ)({attribute:!1})],l.prototype,"stepData",void 0),(0,i.__decorate)([(0,a.wk)()],l.prototype,"_preview",void 0),(0,i.__decorate)([(0,a.wk)()],l.prototype,"_error",void 0),l=(0,i.__decorate)([(0,a.EM)("flow-preview-generic")],l),s()}catch(p){s(p)}})}}]);
//# sourceMappingURL=8611.656413cf22c3a018.js.map