import{s as G,X as T,di as j,bJ as M,dj as J,a3 as N,am as Q,V as $,E as D,G as E,y as w,av as I,f as x,dk as H,aG as K,aH as X,O as Y,z as O,P as k,Q as c,aM as Z,T as q,D as ee,d0 as te,cn as ae,K as V,a5 as B,dl as z}from"./index-DT8qTvyx.js";var ne=function(A){G(r,A);function r(){var t=A!==null&&A.apply(this,arguments)||this;return t.initalValues={},t.state={currentStep:-1,completeStep:-1,rawSteps:[]},t}return r.prototype.componentDidMount=function(){var t=this,e=this.props,a=e.initApi,n=e.initFetch,s=e.initAsyncApi,o=e.initFinishedField,p=e.store,h=e.messages,l=h.fetchSuccess,u=h.fetchFailed;e.onInit,T(a,p.data,n)?p.fetchInitData(a,p.data,{successMessage:l,errorMessage:u,onSuccess:function(){if(!(!T(s,p.data)||p.data[o||"finished"]))return j(function(){return p.checkRemote(s,p.data)},function(i){return i&&i[o||"finished"]},function(i){return t.asyncCancel=i})}}).then(function(i){t.handleFetchInitEvent(i);var m={currentStep:typeof t.props.startStep=="string"?M(J(t.props.startStep,N(t.props.data,(i==null?void 0:i.data)||{})),1):1};return i&&i.data&&(typeof i.data.step=="number"||typeof i.data.step=="string"&&/^\d+$/.test(i.data.step))&&(m.currentStep=M(i.data.step,1)),t.setState(m,function(){i&&i.data&&(i.data.submiting||i.data.submited)&&t.checkSubmit()}),i}):this.setState({currentStep:typeof this.props.startStep=="string"?M(J(this.props.startStep,this.props.data),1):1}),this.normalizeSteps(p.data)},r.prototype.componentDidUpdate=function(t){var e=this.props,a=e.store,n=e.fetchSuccess,s=e.fetchFailed;(!Q(t.steps,e.steps)||!Q(t.data,e.data))&&this.normalizeSteps(e.data),$(t.initApi,e.initApi,t.data,e.data)&&a.fetchData(e.initApi,a.data,{successMessage:n,errorMessage:s})},r.prototype.componentWillUnmount=function(){this.asyncCancel&&this.asyncCancel()},r.prototype.dispatchEvent=function(t,e){var a;return D(this,void 0,void 0,function(){var n,s,o,p;return E(this,function(h){switch(h.label){case 0:return n=this.props,s=n.dispatchEvent,o=n.data,[4,s(t,e?N(o,e):o)];case 1:return p=h.sent(),[2,(a=p==null?void 0:p.prevented)!==null&&a!==void 0?a:!1]}})})},r.prototype.handleFetchInitEvent=function(t){var e;return D(this,void 0,void 0,function(){var a,n,s;return E(this,function(o){switch(o.label){case 0:return a=this.props,n=a.onInit,s=a.store,[4,this.dispatchEvent("inited",w(w({},s.data),{responseData:t.ok?(e=s.data)!==null&&e!==void 0?e:{}:t,responseStatus:(t==null?void 0:t.status)===void 0?s.error?1:0:t==null?void 0:t.status,responseMsg:s.msg}))];case 1:return o.sent()&&n&&n(s.data),[2]}})})},r.prototype.normalizeSteps=function(t){return D(this,void 0,void 0,function(){var e,a,n,s,o,p,h;return E(this,function(l){switch(l.label){case 0:e=this.props,a=e.steps,n=e.translate,s=[],o=a.length,p=0,l.label=1;case 1:return p=0&&this.gotoStep(a.step)}else e.actionType==="submit"?this.finalSubmit():h&&h(t,e,a,n,s||this.context)}},r.prototype.handleQuery=function(t){if(this.props.initApi){if(t!=null&&t.hasOwnProperty("orderBy")&&!$(this.props.initApi,this.props.initApi,this.props.store.data,N(this.props.store.data,t)))return!1;this.receive(t);return}return this.props.onQuery?this.props.onQuery(t):!1},r.prototype.openFeedback=function(t,e){var a=this;return new Promise(function(n){var s=a.props.store;s.setCurrentAction({type:"button",actionType:"dialog",dialog:t},a.props.resolveDefinitions),s.openDialog(e,void 0,function(o){n(o)},a.context)})},r.prototype.handleChange=function(t){return D(this,void 0,void 0,function(){var e,a,n;return E(this,function(s){switch(s.label){case 0:return e=this.props.store,a=e.data,n=w(w({},a),t),[4,this.dispatchEvent("change",n)];case 1:return s.sent()?[2]:(e.updateData(t),[2])}})})},r.prototype.handleInit=function(t){var e=this.state.currentStep;this.initalValues[e]=this.initalValues[e]||t;var a=this.props.store;a.updateData(t)},r.prototype.handleReset=function(t){var e=this.props.store,a=this.initalValues[this.state.currentStep],n={};Object.keys(t).forEach(function(s){n[s]=a.hasOwnProperty(s)?a[s]:void 0}),e.updateData(n)},r.prototype.finalSubmit=function(t,e){return t===void 0&&(t={}),e===void 0&&(e={type:"submit"}),D(this,void 0,void 0,function(){var a,n,s,o,p,h,l,u,i,m,f,d,v,g,C,F,b=this;return E(this,function(_){switch(_.label){case 0:return a=this.props,n=a.store,s=a.api,o=a.asyncApi,p=a.finishedField,h=a.target,l=a.redirect,u=a.reload,i=a.env,m=a.onFinished,f=this.state.rawSteps,[4,this.dispatchEvent("finished",n.data)];case 1:if(_.sent())return[2];if(d=f[this.state.currentStep-1],n.updateData(t),h)this.submitToTarget(I(h,n.data),n.data),this.setState({completeStep:f.length});else if(e.api||d.api||s)v=e.asyncApi||d.asyncApi||o,T(v,n.data)&&n.updateData((F={},F[p||"finished"]=!1,F)),g=this.form?this.form.props.store:n,n.markSaving(!0),g.saveRemote(e.api||d.api||s,n.data,{onSuccess:function(y){return D(b,void 0,void 0,function(){var S,R,P=this;return E(this,function(W){switch(W.label){case 0:return[4,this.dispatchEvent("submitSucc",N(this.props.data,{result:y}))];case 1:return S=W.sent(),!T(v,n.data)||n.data[p||"finished"]?[2,{cbResult:null,dispatcher:S}]:(R=j(function(){return n.checkRemote(v,n.data)},function(L){return L&&L[p||"finished"]},function(L){return P.asyncCancel=L}),[2,{cbResult:R,dispatcher:S}])}})})},onFailed:function(y){return D(b,void 0,void 0,function(){var S;return E(this,function(R){switch(R.label){case 0:return n.markSaving(!1),[4,this.dispatchEvent("submitFail",N(this.props.data,{error:y}))];case 1:return S=R.sent(),[2,{dispatcher:S}]}})})}}).then(function(y){return D(b,void 0,void 0,function(){var S,R,P;return E(this,function(W){switch(W.label){case 0:return S=e.feedback,S&&B(S,y)?[4,this.openFeedback(S,y)]:[3,2];case 1:if(R=W.sent(),S.skipRestOnCancel&&!R)throw new z;if(S.skipRestOnConfirm&&R)throw new z;W.label=2;case 2:if(this.setState({completeStep:f.length}),n.updateData(w(w({},n.data),y)),n.markSaving(!1),y&&typeof y.step=="number")this.gotoStep(y.step);else if(m&&m(y,e)===!1)return[2,y];return P=(e.redirect||d.redirect||l)&&V(e.redirect||d.redirect||l,n.data),P?i.jumpTo(P,e,n.data):(e.reload||d.reload||u)&&this.reloadTarget(I(e.reload||d.reload||u,n.data),n.data),[2,y]}})})}).catch(function(y){});else{if(this.setState({completeStep:f.length}),m&&m(n.data,e)===!1)return[2];C=(e.redirect||d.redirect||l)&&V(e.redirect||d.redirect||l,n.data),C?i.jumpTo(C,e,n.data):(e.reload||d.reload||u)&&this.reloadTarget(I(e.reload||d.reload||u,n.data),n.data)}return[2]}})})},r.prototype.handleSubmit=function(t,e){var a,n=this,s=this.props,o=s.store,p=s.finishedField,h=this.state.rawSteps;if(this.state.currentStep0?C:Array.isArray(a)?K([],X(a),!1).map(function(y){return delete y.hiddenOn,y}):null,_=Array.isArray(b)?b[F-1]:null;return x.createElement("div",{ref:this.domRef,className:h(v?"".concat(p,"Panel ").concat(p,"Panel--default"):"","".concat(p,"Wizard ").concat(p,"Wizard--").concat(u),e),style:n},x.createElement("div",{className:h("".concat(p,"Wizard-step"),f)},this.renderSteps(),x.createElement("div",{role:"wizard-body",className:h("".concat(p,"Wizard-stepContent clearfix"),d)},_?s("body",w(w({},_),{type:"form",wrapWithPanel:!1,api:null}),{key:this.state.currentStep,ref:this.formRef,onInit:this.handleInit,onReset:this.handleReset,onSubmit:this.handleSubmit,onAction:this.handleAction,onQuery:this.handleQuery,disabled:o.loading,popOverContainer:l||this.getPopOverContainer,onChange:this.handleChange,formStore:void 0}):F===-1?i("loading"):x.createElement("p",{className:"text-danger"},i("Wizard.configError"))),this.renderFooter()),s("dialog",w(w({},o.action&&o.action.dialog),{type:"dialog"}),{key:"dialog",data:o.dialogData,onConfirm:this.handleDialogConfirm,onClose:this.handleDialogClose,show:o.dialogOpen}),x.createElement(Y,{loadingConfig:m,size:"lg",overlay:!0,key:"info",show:o.loading}))},r.prototype.render=function(){return this.renderWizard()},r.defaultProps={mode:"horizontal",readOnly:!1,messages:{},actionClassName:"",actionPrevLabel:"Wizard.prev",actionNextLabel:"Wizard.next",actionNextSaveLabel:"Wizard.saveAndNext",actionFinishLabel:"Wizard.finish",startStep:"1",wrapWithPanel:!0},r.propsList=["steps","mode","messages","actionClassName","actionPrevLabel","actionNextLabel","actionNextSaveLabel","actionFinishLabel","onFinished","affixFooter","startStep"],O([k,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",void 0)],r.prototype,"formRef",null),O([k,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",void 0)],r.prototype,"domRef",null),O([k,c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",void 0)],r.prototype,"getPopOverContainer",null),O([k,c("design:type",Function),c("design:paramtypes",[Object,Object,Object,Boolean,Object]),c("design:returntype",void 0)],r.prototype,"handleAction",null),O([k,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",void 0)],r.prototype,"handleQuery",null),O([k,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",Promise)],r.prototype,"handleChange",null),O([k,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",void 0)],r.prototype,"handleInit",null),O([k,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",void 0)],r.prototype,"handleReset",null),O([k,c("design:type",Function),c("design:paramtypes",[Object,Object]),c("design:returntype",void 0)],r.prototype,"handleSubmit",null),O([k,c("design:type",Function),c("design:paramtypes",[Array,Object,Array]),c("design:returntype",void 0)],r.prototype,"handleDialogConfirm",null),O([k,c("design:type",Function),c("design:paramtypes",[Object]),c("design:returntype",void 0)],r.prototype,"handleDialogClose",null),O([k,c("design:type",Function),c("design:paramtypes",[Number,Object]),c("design:returntype",void 0)],r.prototype,"handleJumpStep",null),r}(x.Component);function U(A,r,t,e){var a=!1;return A&&A.hasOwnProperty("jumpable")?a=A.jumpable:A&&A.jumpableOn?a=Z(A.jumpableOn,N(e,{currentStep:t})):a=r+1