import{s as N,c7 as x,c8 as D,aF as O,E as y,G as E,f as d,a4 as T,b2 as A,O as B,z as S,aX as F,Q as I,y as v,a1 as z,bl as H,X as V,ah as L}from"./index-DT8qTvyx.js";var U=function(k){N(a,k);function a(t){var e=k.call(this,t)||this;return e.mounted=!1,e.toDispose=[],e.state={columns:t.columns||[],rows:t.rows||[],loading:!1},e.toggleItem=e.toggleItem.bind(e),e.reload=e.reload.bind(e),e.initOptions=e.initOptions.bind(e),e.mounted=!0,e}return a.prototype.componentDidMount=function(){var t=this.props,e=t.formInited,n=t.addHook,r=t.formItem;r&&this.toDispose.push(e||!n?r.addInitHook(this.initOptions):n(this.initOptions,"init"))},a.prototype.componentDidUpdate=function(t){var e=this.props;if(t.columns!==e.columns||t.rows!==e.rows)this.setState({columns:e.columns||[],rows:e.rows||[]});else if(e.formInited&&(e.source!==t.source||t.data!==e.data)){var n=x(t.source,t.data,{ignoreData:!0}),r=x(e.source,e.data,{ignoreData:!0});n.url!==r.url&&D(r.url)&&this.reload()}},a.prototype.componentWillUnmount=function(){this.mounted=!1,this.toDispose.forEach(function(t){return t()}),this.toDispose=[]},a.prototype.doAction=function(t,e,n){var r,o,i=this.props,c=i.resetValue,m=i.onChange,h=i.formStore,g=i.store,s=i.name,l=t==null?void 0:t.actionType;if(l==="clear")m==null||m("");else if(l==="reset"){var p=(o=O((r=h==null?void 0:h.pristine)!==null&&r!==void 0?r:g==null?void 0:g.pristine,s))!==null&&o!==void 0?o:c;m==null||m(p??"")}},a.prototype.initOptions=function(t){return y(this,void 0,void 0,function(){var e,n,r;return E(this,function(o){switch(o.label){case 0:return[4,this.reload()];case 1:return o.sent(),e=this.props,n=e.formItem,r=e.name,n?(n.value&&H(t,r,n.value),[2]):[2]}})})},a.prototype.reload=function(){return y(this,void 0,void 0,function(){var t,e,n,r,o,i,c=this;return E(this,function(m){switch(m.label){case 0:if(t=this.props,e=t.source,n=t.data,r=t.env,o=t.onChange,i=t.translate,!V(e,n)||this.state.loading)return[2];if(!r||!r.fetcher)throw new Error("fetcher is required");return[4,new Promise(function(h,g){if(!c.mounted)return h();c.setState({loading:!0},function(){if(!c.mounted)return h();r.fetcher(e,n).then(function(s){if(!s.ok)throw new Error(s.msg||i("fetchFailed"));if(!c.mounted)return h();c.setState({loading:!1,rows:s.data.rows||[],columns:s.data.columns||[]},function(){e&&e.replaceData;var l=s.data.value;l&&(l=e.replaceData?l:X(l,c.state.columns,c.state.rows),o(l)),h()})}).catch(function(s){return c.setState({error:s,loading:!1},function(){return h()})})})})];case 1:return[2,m.sent()]}})})},a.prototype.toggleItem=function(t,e,n){return y(this,void 0,void 0,function(){var r,o,i,c,m,h,g,s,u,p,l,p,l,p,u,b,C;return E(this,function(f){switch(f.label){case 0:if(r=this.state,o=r.columns,i=r.rows,c=this.props,m=c.multiple,h=c.singleSelectMode,g=c.dispatchEvent,c.data,s=this.props.value||M(o,i),m)s[e][n]=v(v({},s[e][n]),{checked:t});else if(h==="row")for(u=0,p=o.length;u