import{s as _,d4 as L,E as k,G as M,V as B,X as P,an as U,a3 as Q,aH as x,aI as O,y as h,aN as V,f as u,ad as D,O as j,x as H,b2 as J,aR as X,ae as K,z as E,P as T,Q as C,T as $,D as G,d5 as Y,aK as Z,K as q,aw as ee,a5 as te}from"./index-BPRWoLf4.js";var ae=function(y){_(o,y);function o(e){var t=y.call(this,e)||this;return L(t,["handleAction","handleChange","handleBulkChange","handleQuery","handleDialogConfirm","handleDialogClose","handleDrawerConfirm","handleDrawerClose","handleClick","reload","silentReload","initInterval"]),t.style=document.createElement("style"),t.style.setAttribute("data-page",""),document.getElementsByTagName("head")[0].appendChild(t.style),t.updateStyle(),t.varStyle=document.createElement("style"),t.varStyle.setAttribute("data-vars",""),document.getElementsByTagName("head")[0].appendChild(t.varStyle),t.updateVarStyle(),t}return o.prototype.updateStyle=function(){this.props.css||this.props.mobileCSS?this.style.innerHTML=`
      `.concat(this.buildCSS(this.props.css),`

      @media (max-width: 768px) {
        `).concat(this.buildCSS(this.props.mobileCSS),`
      }
      `):this.style.innerHTML=""},o.prototype.buildCSS=function(e){if(!e)return"";var t="";for(var a in e){var n=e[a],s="";for(var r in n){var l="",d=n[r];if(typeof d=="string")s+="  ".concat(r,": ").concat(d,`;
`);else{for(var i in d)l+=" ".concat(i,":").concat(d[i],";");s+="  ".concat(r," {").concat(l,`}
`)}}t+=`
      `.concat(a,` {
        `).concat(s,`
      }
      `)}return t},o.prototype.updateVarStyle=function(){var e=this.props.cssVars,t="";if(e){for(var a in e)if(a.startsWith("--")){if(a.indexOf(":")!==-1)continue;var n=e[a];if(typeof n=="string"&&(n.indexOf("expression(")!==-1||n.indexOf(";")!==-1))continue;t+="".concat(a,": ").concat(n,`; 
`)}this.varStyle.innerHTML=`
      :root {
        `.concat(t,`
      }
      `)}},o.prototype.componentDidMount=function(){return k(this,void 0,void 0,function(){var e,t,a,n,s,r,l,d,i,p;return M(this,function(f){switch(f.label){case 0:return e=this.props,t=e.initApi,a=e.initFetch,n=e.initFetchOn,s=e.store,r=e.messages,l=e.data,d=e.dispatchEvent,i=e.env,this.mounted=!0,[4,d("init",l,this)];case 1:return p=f.sent(),i!=null&&i.tracker&&i.tracker({eventType:"pageLoaded"},this.props),p!=null&&p.prevented||!Z(s)?[2]:(P(t,s.data,a,n)&&s.fetchInitData(t,s.data,{successMessage:r&&r.fetchSuccess,errorMessage:r&&r.fetchFailed}).then(this.initInterval),[2])}})})},o.prototype.componentDidUpdate=function(e){var t=this.props,a=t.store,n=t.initApi;if(t.initFetchOn&&t.initFetch&&!e.initFetch||t.initFetch!==!1&&B(e.initApi,n,e.data,t.data)){var s=t.messages;P(n,a.data)&&a.fetchData(n,a.data,{successMessage:s&&s.fetchSuccess,errorMessage:s&&s.fetchFailed}).then(this.initInterval)}(JSON.stringify(t.css)!==JSON.stringify(e.css)||JSON.stringify(t.mobileCSS)!==JSON.stringify(e.mobileCSS))&&this.updateStyle(),JSON.stringify(t.cssVars)!==JSON.stringify(e.cssVars)&&this.updateVarStyle(),U(e.defaultData,t.defaultData)&&a.reInitData(t.defaultData)},o.prototype.componentWillUnmount=function(){var e,t;this.mounted=!1,clearTimeout(this.timer),this.style&&((e=this.style.parentNode)===null||e===void 0||e.removeChild(this.style)),this.varStyle&&((t=this.varStyle.parentNode)===null||t===void 0||t.removeChild(this.varStyle))},o.prototype.reloadTarget=function(e,t){},o.prototype.handleAction=function(e,t,a,n,s){var r=this;n===void 0&&(n=!1);var l=this.props,d=l.env,i=l.store,p=l.messages,f=l.onAction;return t.actionType==="dialog"?(i.setCurrentAction(t,this.props.resolveDefinitions),new Promise(function(c){i.openDialog(a,void 0,function(m,v){var g;(g=t.callback)===null||g===void 0||g.call(t,m,v),c({confirmed:m,value:v})},s||r.context)})):t.actionType==="drawer"?(i.setCurrentAction(t,this.props.resolveDefinitions),new Promise(function(c){i.openDrawer(a,void 0,function(m,v){var g;(g=t.callback)===null||g===void 0||g.call(t,m,v),c({confirmed:m,value:v})},s)})):t.actionType==="ajax"?(i.setCurrentAction(t,this.props.resolveDefinitions),P(t.api,a)?i.saveRemote(t.api,a,{successMessage:t.messages&&t.messages.success||p&&p.saveSuccess,errorMessage:t.messages&&t.messages.failed||p&&p.saveSuccess}).then(function(){return k(r,void 0,void 0,function(){var c;return M(this,function(m){switch(m.label){case 0:return t.feedback&&te(t.feedback,i.data)?[4,this.openFeedback(t.feedback,i.data)]:[3,2];case 1:m.sent(),m.label=2;case 2:return c=t.redirect&&q(t.redirect,i.data),c&&d.jumpTo(c,t,i.data),t.reload&&this.reloadTarget(ee(t.reload,i.data),i.data),[2]}})})}).catch(function(c){if(n||t.countDown)throw c}):void 0):f(e,t,a,n,s||this.context)},o.prototype.handleQuery=function(e){if(this.props.initApi){if(e!=null&&e.hasOwnProperty("orderBy")&&!B(this.props.initApi,this.props.initApi,this.props.store.data,Q(this.props.store.data,e)))return!1;this.receive(e);return}return this.props.onQuery?this.props.onQuery(e):!1},o.prototype.handleDialogConfirm=function(e,t){for(var a=[],n=2;n<arguments.length;n++)a[n-2]=arguments[n];var s=this.props.store;t.mergeData&&e.length===1&&e[0]&&s.updateData(e[0]);var r=s.action.dialog;r&&r.onConfirm&&r.onConfirm.apply(r,x([e,t],O(a),!1))===!1||s.closeDialog(!0,e)},o.prototype.handleDialogClose=function(e){e===void 0&&(e=!1);var t=this.props.store;t.closeDialog(e)},o.prototype.handleDrawerConfirm=function(e,t){for(var a=[],n=2;n<arguments.length;n++)a[n-2]=arguments[n];var s=this.props.store;t.mergeData&&e.length===1&&e[0]&&s.updateData(e[0]);var r=s.action.dialog;r&&r.onConfirm&&r.onConfirm.apply(r,x([e,t],O(a),!1))===!1||s.closeDrawer(!0,e)},o.prototype.handleDrawerClose=function(){var e=this.props.store;e.closeDrawer(!1)},o.prototype.handleClick=function(e){var t,a=e.target,n=this.props.env,s=a.tagName==="A"&&a.hasAttribute("data-link")?a.getAttribute("data-link"):(t=a.closest("a[data-link]"))===null||t===void 0?void 0:t.getAttribute("data-link");n&&s&&(n.jumpTo(s,void 0,this.props.data),e.preventDefault())},o.prototype.handleResizeMouseDown=function(e){var t=e.nativeEvent.which==3;t||(this.codeWrap=e.currentTarget.parentElement,document.addEventListener("mousemove",this.handleResizeMouseMove),document.addEventListener("mouseup",this.handleResizeMouseUp),this.startX=e.clientX,this.startWidth=this.codeWrap.offsetWidth)},o.prototype.handleResizeMouseMove=function(e){var t=this.props,a=t.asideMinWidth,n=a===void 0?160:a,s=t.asideMaxWidth,r=s===void 0?350:s,l=t.asidePosition,d=e.clientX-this.startX,i=l==="right"?this.startWidth-d:this.startWidth+d,p=Math.min(Math.max(i,n),r);this.codeWrap.style.cssText+="width: ".concat(p,"px")},o.prototype.handleResizeMouseUp=function(){document.removeEventListener("mousemove",this.handleResizeMouseMove),document.removeEventListener("mouseup",this.handleResizeMouseUp)},o.prototype.openFeedback=function(e,t){var a=this;return new Promise(function(n){var s=a.props.store;s.setCurrentAction({type:"button",actionType:"dialog",dialog:e},a.props.resolveDefinitions),s.openDialog(t,void 0,function(r){n(r)},a.context)})},o.prototype.reload=function(e,t,a,n,s){return k(this,void 0,void 0,function(){var r,l,d,i;return M(this,function(p){switch(p.label){case 0:return t?[2,this.receive(t,void 0,s)]:(r=this.props,l=r.store,d=r.initApi,clearTimeout(this.timer),P(d,l.data)?[4,l.fetchData(d,l.data,{silent:n})]:[3,2]);case 1:i=p.sent(),this.initInterval(i),p.label=2;case 2:return[2,l.data]}})})},o.prototype.receive=function(e,t,a){var n=this.props.store;n.updateData(e,void 0,a),this.reload()},o.prototype.silentReload=function(e,t){this.reload(t,void 0,void 0,!0)},o.prototype.initInterval=function(e){var t,a=this.props,n=a.interval,s=a.silentPolling,r=a.stopAutoRefreshWhen,l=a.data,d=a.dispatchEvent,i=a.store;return d("inited",Q(l,h(h({},e==null?void 0:e.data),{responseData:e!=null&&e.ok?(t=e==null?void 0:e.data)!==null&&t!==void 0?t:{}:e,responseStatus:(e==null?void 0:e.status)===void 0?i!=null&&i.error?1:0:e==null?void 0:e.status,responseMsg:(e==null?void 0:e.msg)||(i==null?void 0:i.msg)}))),e!=null&&e.ok&&n&&this.mounted&&(!r||!V(r,l))&&(this.timer=setTimeout(s?this.silentReload:this.reload,Math.max(n,1e3))),e},o.prototype.handleRefresh=function(){return k(this,void 0,void 0,function(){var e,t,a,n;return M(this,function(s){switch(s.label){case 0:return e=this.props,t=e.dispatchEvent,a=e.data,[4,t("pullRefresh",a)];case 1:return n=s.sent(),n!=null&&n.prevented?[2]:(this.reload(),[2])}})})},o.prototype.handleChange=function(e,t,a,n){var s=this.props,r=s.store,l=s.onChange;typeof t=="string"&&t&&r.changeValue(t,e,n),l==null||l.apply(null,arguments)},o.prototype.handleBulkChange=function(e){var t,a;(a=(t=this.props.store)===null||t===void 0?void 0:t.updateData)===null||a===void 0||a.call(t,e)},o.prototype.renderHeader=function(){var e=this.props,t=e.title,a=e.subTitle,n=e.remark,s=e.remarkPlacement,r=e.headerClassName,l=e.toolbarClassName,d=e.toolbar,i=e.render,p=e.store,f=e.initApi,c=e.popOverContainer,m=e.env,v=e.classnames,g=e.regions;e.translate;var w=e.id,b=e.themeCss,N={onAction:this.handleAction,onQuery:f?this.handleQuery:void 0,onChange:this.handleChange,onBulkChange:this.handleBulkChange,pageLoading:p.loading},S,A;return(Array.isArray(g)?~g.indexOf("header"):t||a)&&(S=u.createElement("div",{className:v("Page-header",r,D(h(h({},this.props),{name:"headerControlClassName",id:w,themeCss:b})))},t?u.createElement("h2",{className:v("Page-title",D(h(h({},this.props),{name:"titleControlClassName",id:w,themeCss:b})))},i("title",t,N),n?i("remark",{type:"remark",tooltip:n,placement:s||"bottom",container:c||m.getModalContainer}):null):null,a&&u.createElement("small",{className:v("Page-subTitle")},i("subTitle",a,N)))),(Array.isArray(g)?~g.indexOf("toolbar"):d)&&(A=u.createElement("div",{className:v("Page-toolbar",l,D(h(h({},this.props),{name:"toolbarControlClassName",id:w,themeCss:b})))},i("toolbar",d||"",N))),S&&A?u.createElement("div",{className:v("Page-headerRow")},S,A):S||A},o.prototype.renderContent=function(e){var t=this.props,a=t.store,n=t.body,s=t.bodyClassName,r=t.render,l=t.classnames,d=t.showErrorMsg,i=t.regions;t.translate;var p=t.loadingConfig;t.initApi;var f=t.id,c=t.env,m=t.themeCss;return u.createElement("div",{className:l("Page-content")},u.createElement("div",{className:l("Page-main")},this.renderHeader(),u.createElement("div",{className:l("Page-body",s,D(h(h({},this.props),{name:"bodyControlClassName",id:f,themeCss:m}))),role:"page-body"},u.createElement(j,{size:"lg",overlay:!0,key:"info",show:a.loading,loadingConfig:p}),!c.forceSilenceInsideError&&a.error&&d!==!1?u.createElement(H,{level:"danger",showCloseButton:!0,onClose:a.clearMessage},a.msg):null,(Array.isArray(i)?~i.indexOf("body"):n)?r("body",n||"",e):null)))},o.prototype.render=function(){var e=this.props,t=e.className,a=e.store;e.body,e.bodyClassName;var n=e.render,s=e.aside,r=e.asideClassName,l=e.classnames;e.showErrorMsg;var d=e.initApi,i=e.regions,p=e.style,f=e.data,c=e.asideResizor,m=e.asideSticky,v=e.pullRefresh,g=e.mobileUI,w=e.translate;e.loadingConfig;var b=e.id,N=e.wrapperCustomStyle,S=e.env,A=e.themeCss,F=e.asidePosition,W={onAction:this.handleAction,onQuery:d?this.handleQuery:void 0,onChange:this.handleChange,onBulkChange:this.handleBulkChange,pageLoading:a.loading},R=Array.isArray(i)?~i.indexOf("aside"):s&&(!Array.isArray(s)||s.length),I=J(p,f),z=this.renderContent(W);return u.createElement("div",{className:l("Page",R?"Page--withSidebar":"",R&&m?"Page--asideSticky":"",R&&F?"Page--".concat(F,"Aside"):"",t,D(h({name:"baseControlClassName",id:b,themeCss:A},this.props)),D(h({name:"wrapperCustomStyle",id:b,themeCss:N},this.props))),onClick:this.handleClick,style:I},R?u.createElement("div",{className:l("Page-aside",c?"relative":"Page-aside--withWidth",r,D(h(h({},this.props),{name:"asideControlClassName",id:b,themeCss:A})))},n("aside",s||"",h(h({},W),typeof s=="string"?{inline:!1,className:"Page-asideTplWrapper"}:null)),c?u.createElement("div",{onMouseDown:this.handleResizeMouseDown,className:l("Page-asideResizor")}):null):null,g&&v&&!v.disabled?u.createElement(X,h({},v,{translate:w,onRefresh:this.handleRefresh}),z):z,n("dialog",h(h({},a.action&&a.action.dialog),{type:"dialog"}),{key:"dialog",data:a.dialogData,onConfirm:this.handleDialogConfirm,onClose:this.handleDialogClose,show:a.dialogOpen,onAction:this.handleAction,onQuery:d?this.handleQuery:void 0}),n("drawer",h(h({},a.action&&a.action.drawer),{type:"drawer"}),{key:"drawer",data:a.drawerData,onConfirm:this.handleDrawerConfirm,onClose:this.handleDrawerClose,show:a.drawerOpen,onAction:this.handleAction,onQuery:d?this.handleQuery:void 0}),u.createElement(K,h({},this.props,{config:{wrapperCustomStyle:N,id:b,themeCss:A,classNames:[{key:"baseControlClassName",weights:{default:{important:!0},hover:{important:!0},active:{important:!0}}},{key:"bodyControlClassName"},{key:"headerControlClassName"},{key:"titleControlClassName"},{key:"toolbarControlClassName"},{key:"asideControlClassName"}]},env:S})))},o.defaultProps={asideClassName:"",bodyClassName:"",headerClassName:"",initFetch:!0,toolbarClassName:"",messages:{},asideSticky:!0,asidePosition:"left",pullRefresh:{disabled:!0}},o.propsList=["title","subTitle","initApi","initFetchOn","initFetch","headerClassName","bodyClassName","asideClassName","toolbarClassName","toolbar","body","aside","messages","style","showErrorMsg"],E([T,C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",void 0)],o.prototype,"handleResizeMouseDown",null),E([T,C("design:type",Function),C("design:paramtypes",[MouseEvent]),C("design:returntype",void 0)],o.prototype,"handleResizeMouseMove",null),E([T,C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",void 0)],o.prototype,"handleResizeMouseUp",null),E([T,C("design:type",Function),C("design:paramtypes",[]),C("design:returntype",Promise)],o.prototype,"handleRefresh",null),o}(u.Component),ne=function(y){_(o,y);function o(e,t){var a=y.call(this,e)||this,n=t;return n.registerComponent(a),a}return o.prototype.componentWillUnmount=function(){var e=this.context;e.unRegisterComponent(this),y.prototype.componentWillUnmount.call(this)},o.prototype.reloadTarget=function(e,t){var a=this.context;a.reload(e,t)},o.prototype.handleAction=function(e,t,a,n,s){return n===void 0&&(n=!1),k(this,void 0,void 0,function(){var r,l;return M(this,function(d){switch(d.label){case 0:return r=s||this.context,t.actionType!=="reload"?[3,1]:(t.target&&r.reload(t.target,a),[3,4]);case 1:return t.target?(t.target.split(",").forEach(function(i){var p=r.getComponentByName(i);p&&p.doAction&&p.doAction(h(h({},t),{target:void 0}),a)}),[3,4]):[3,2];case 2:return[4,y.prototype.handleAction.call(this,e,t,a,n,s)];case 3:return l=d.sent(),t.reload&&~["url","link","jump"].indexOf(t.actionType)&&r.reload(t.reload,a),[2,l];case 4:return[2]}})})},o.prototype.handleDialogConfirm=function(e,t){for(var a,n,s=[],r=2;r<arguments.length;r++)s[r-2]=arguments[r];var l=this.props.store,d=l.action,i=(a=t.reload)!==null&&a!==void 0?a:d.reload,p=l.getDialogScoped()||this.context;y.prototype.handleDialogConfirm.apply(this,x([e,t],O(s),!1)),i?p.reload(i,l.data):(p==null?void 0:p.component)!==this&&(!((n=p.component)===null||n===void 0)&&n.reload)?p.component.reload():this.context.getComponents().filter(function(f){return f.props.type==="crud"}).forEach(function(f){return f.reload&&f.reload()})},o.prototype.handleDrawerConfirm=function(e,t){var a=this,n,s=this.props.store,r=s.action,l=(n=t.reload)!==null&&n!==void 0?n:r.reload,d=s.getDrawerScoped()||this.context;y.prototype.handleDrawerConfirm.call(this,e,t),setTimeout(function(){var i;l?d.reload(l,s.data):d.component!==a&&(!((i=d==null?void 0:d.component)===null||i===void 0)&&i.reload)?d.component.reload():a.context.getComponents().filter(function(p){return p.props.type==="crud"}).forEach(function(p){return p.reload&&p.reload()})},300)},o.prototype.setData=function(e,t){return this.props.store.updateData(e,void 0,t)},o.prototype.getData=function(){var e=this.props.store;return e.data},o.contextType=$,o}(ae),re=function(y){_(o,y);function o(){return y!==null&&y.apply(this,arguments)||this}return o=E([G({type:"page",storeType:Y.name,isolateScope:!0})],o),o}(ne);export{re as PageRenderer,ne as PageRendererBase,ae as default};
