@nocobase/client 2.0.0-alpha.60 → 2.0.0-alpha.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
width: 100%;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`,items:s},i))})},JM=()=>{const{isInMenu:e}=YM();return{attribute:m.useMemo(()=>e?{}:{role:"menuitem"},[e])}},{Paragraph:XM,Text:QM}=I.Typography,ZM=e=>{const[t,o]=m.useState(!1),n=a.jsx(XM,{style:{display:"flex",marginBottom:0},copyable:{text:e.error.message},children:a.jsxs(QM,{type:"danger",style:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",display:"inline-block",maxWidth:"200px"},children:["Error: ",e.error.message]})});return a.jsxs(a.Fragment,{children:[a.jsx("div",{onMouseOver:()=>o(!0),children:e.children||n}),a.jsx(I.Modal,{zIndex:1e4,open:t,footer:null,onCancel:()=>o(!1),width:"60%",children:a.jsx(bo,f({},e))})]})},{Paragraph:eA,Text:tA,Link:oA}=I.Typography,Qd=(e,t={})=>{const o=Ed(),[n,l]=m.useState(!1),i=Te();return{loading:n,download:()=>O(void 0,null,function*(){l(!0);try{const r=yield i.request({url:"logger:collect",method:"post",responseType:"blob",data:f({error:{message:e.message,stack:e.stack},location:o},t)}),s=window.URL.createObjectURL(new Blob([r.data],{type:"application/gzip"})),c=document.createElement("a");c.setAttribute("href",s),c.setAttribute("download","logs.tar.gz"),c.click(),c.remove()}catch(r){console.log(r)}l(!1)})}},bo=({error:e})=>{const t=y.useFieldSchema(),{t:o}=K.useTranslation(),{loading:n,download:l}=Qd(e,{schema:t}),i=a.jsxs(K.Trans,{children:["This is likely a NocoBase internals bug. Please open an issue at ",a.jsx(oA,{href:"https://github.com/nocobase/nocobase/issues",target:"_blank",children:"here"})]});return a.jsx("div",{style:{backgroundColor:"white"},children:a.jsx(I.Result,{style:{maxWidth:"60vw",margin:"auto"},status:"error",title:o("Render Failed"),subTitle:i,extra:[a.jsx(I.Button,{type:"primary",href:"https://github.com/nocobase/nocobase/issues",target:"_blank",children:o("Feedback")},"feedback"),a.jsx(I.Button,{loading:n,onClick:l,children:o("Download logs")},"log")],children:a.jsx(eA,{copyable:{text:e.stack},children:a.jsx(tA,{type:"danger",style:{whiteSpace:"pre-line",textAlign:"center"},children:e.stack})})})})};bo.Modal=ZM;const Sr=()=>{const e=De.useNavigate(),{t}=K.useTranslation();return a.jsx(I.Result,{status:"404",title:"404",subTitle:t("Sorry, the page you visited does not exist."),extra:a.jsx(I.Button,{onClick:()=>e("/",{replace:!0}),type:"primary",children:"Back Home"})})};class co{constructor(t,o){this.options=t,this.app=o,this.options=t,this.app=o}get pluginManager(){return this.app.pluginManager}get context(){return this.app.context}get flowEngine(){return this.app.flowEngine}get engine(){return this.app.flowEngine}get pm(){return this.app.pm}get router(){return this.app.router}get pluginSettingsManager(){return this.app.pluginSettingsManager}get pluginSettingsRouter(){return this.app.pluginSettingsManager}get schemaInitializerManager(){return this.app.schemaInitializerManager}get schemaSettingsManager(){return this.app.schemaSettingsManager}get dataSourceManager(){return this.app.dataSourceManager}afterAdd(){return O(this,null,function*(){})}beforeLoad(){return O(this,null,function*(){})}load(){return O(this,null,function*(){})}t(t,o={}){var n;return this.app.i18n.t(t,f({ns:(n=this.options)==null?void 0:n.packageName},o))}}const nA={display:"flex",alignItems:"center",gap:4},Zd=e=>t=>{const{tooltip:o}=t;return o?a.jsxs("div",{style:nA,children:[a.jsx(e,f({},t)),a.jsx(I.Tooltip,{title:o,children:a.jsx(te.QuestionCircleOutlined,{style:{zIndex:1}})})]}):a.jsx(e,f({},t))},{evaluate:lA}=kd.evaluators.get("formula.js"),Qh=e=>{const t=st(),o=gt(),[n,l]=m.useState();return m.useEffect(()=>{O(void 0,null,function*(){if(e==null||e===""){l(void 0);return}const{exp:i,scope:r}=yield Yd(e,{variables:t,localVariables:o});try{const s=lA(i,f({now:()=>new Date().toString()},r));l(s)}catch(s){console.error(s)}})},[t.parseVariable,e,o]),n};class kn{constructor(t){A(this,"options"),A(this,"name"),this.options=Object.assign({items:[]},t),this.name=t.name}get items(){return this.options.items}add(t,o){const n=t.split("."),l=n[n.length-1],i=T(f({},o),{name:l}),r=(d,u)=>{const p=this.items.findIndex(h=>h.name===d);p===-1?this.items.push(u):this.items[p]=u};if(n.length===1){r(l,i);return}const s=n.slice(0,-1).join("."),c=this.get(s);if(c){c.children||(c.children=[]);const d=t.replace(`${c.name}.`,""),u=c.children.findIndex(p=>p.name===d);u===-1?c.children.push(i):c.children[u]=i}else r(l,i)}get(t){var o;if(!t)return;const n=t.split(".");let l={children:this.items};for(let i=0;i<n.length;i++){const r=n[i],s=(o=l.children)==null?void 0:o.find(c=>c.name===r);if(s&&(l=s),i===n.length-1)return s}}remove(t){const o=t.split(".");if(o.length===1){const l=this.items.findIndex(i=>i.name===o[0]);l!==-1&&this.items.splice(l,1);return}const n=this.get(o.slice(0,-1).join("."));if(n&&n.children){const l=o[o.length-1],i=n.children.findIndex(r=>r.name===l);i!==-1&&n.children.splice(i,1)}}}var Ze=(e=>(e.group="group",e.page="page",e.flowRoute="flowRoute",e.link="link",e.tabs="tabs",e.flowPage="flowPage",e))(Ze||{});const Ai=Nt("nb-menu-item",e=>{const{componentCls:t}=e;return{[t]:{paddingLeft:`${e.padding}px !important`,paddingRight:`${e.padding}px !important`}}}),iA=()=>{const e=Te();return m.useCallback(t=>O(void 0,null,function*(){yield e.request({method:"POST",url:"/uiSchemas:insert",data:t})}),[e])},rA=()=>{const{t:e}=K.useTranslation(),t=m.useContext(y.SchemaOptionsContext),{theme:o}=Go(),{componentCls:n,hashId:l}=Ai(),i=Xi(),{createRoute:r}=qt(),s=iA(),c=m.useCallback(()=>O(void 0,null,function*(){const d=yield Yo(e("Add page"),()=>a.jsx(ht,{scope:t.scope,components:f({},t.components),children:a.jsx(ue.FormLayout,{layout:"vertical",children:a.jsx(To.Provider,{value:bl,children:a.jsx(He,{schema:{properties:{title:{title:e("Menu item title"),required:!0,"x-component":"Input","x-decorator":"FormItem"},icon:{title:e("Icon"),"x-component":"IconPicker","x-decorator":"FormItem"}}}})})})}),o).open({initialValues:{}}),u=ee.uid(),p=ee.uid(),h=ee.uid(),g=ee.uid();yield r({type:Ze.flowPage,title:d.title,icon:d.icon,parentId:i==null?void 0:i.id,schemaUid:p,menuSchemaUid:u,enableTabs:!1,children:[{type:Ze.tabs,schemaUid:h,tabSchemaName:g,hidden:!0}]}),s(V0({pageSchemaUid:p}))}),[r,s,t==null?void 0:t.components,t==null?void 0:t.scope,i==null?void 0:i.id,e,o]);return a.jsx(Mt,{title:e("Modern page (v2)"),onClick:c,className:`${n} ${l}`})};function V0({pageSchemaUid:e}){return{type:"void","x-component":"FlowRoute","x-uid":e}}const z0=()=>{const{t:e}=K.useTranslation(),t=m.useContext(y.SchemaOptionsContext),{theme:o}=Go(),{componentCls:n,hashId:l}=Ai(),i=Xi(),{createRoute:r}=qt(),s=m.useCallback(()=>O(void 0,null,function*(){const c=yield Yo(e("Add group"),()=>a.jsx(ht,{scope:t.scope,components:f({},t.components),children:a.jsx(ue.FormLayout,{layout:"vertical",children:a.jsx(To.Provider,{value:bl,children:a.jsx(He,{schema:{properties:{title:{title:e("Menu item title"),"x-component":"Input","x-decorator":"FormItem",required:!0},icon:{title:e("Icon"),"x-component":"IconPicker","x-decorator":"FormItem"}}}})})})}),o).open({initialValues:{}}),{title:d,icon:u}=c,p=ee.uid();yield r({type:Ze.group,title:d,icon:u,parentId:i==null?void 0:i.id,schemaUid:p})}),[t.components,t.scope,e,o]);return a.jsx(Mt,{title:e("Group"),onClick:s,className:`${n} ${l}`})},Ri=e=>{const t=m.useRef(null);return m.useEffect(()=>(t.current&&e!==t.current&&t.current.onUnmount(),t.current=e,e.onMount(),()=>{e.onUnmount()}),[e]),e},ri={},ab=e=>/{{.*?}}/g.test(e),se=({noCache:e}={noCache:!1})=>{const t=m.useContext(y.SchemaOptionsContext),o=m.useContext(y.SchemaExpressionScopeContext);return(n,l)=>{let i=!1,r;if(typeof n=="string"&&n.startsWith("{{")&&(i=!0,r=n),n&&typeof n=="object"&&!m.isValidElement(n)){try{r=JSON.stringify(n)}catch(s){return console.warn("Failed to stringify:",s),n}if(ri[r])return ri[r];i=ab(r)}if(Array.isArray(n)){try{r=JSON.stringify(n)}catch(s){return console.warn("Failed to stringify:",s),n}if(ri[r])return ri[r];i=ab(r)}if(i){const s=f(f(f({},t==null?void 0:t.scope),o),l);if(!r)return y.Schema.compile(n,s);try{return e?y.Schema.compile(n,s):(ri[r]=ri[r]||y.Schema.compile(n,s),ri[r])}catch(c){return console.log("useCompile error",n,c),y.Schema.compile(n,s)}}return n}},jo=(e,t)=>{const{components:o}=m.useContext(y.SchemaOptionsContext);return e?typeof e!="string"?e:L.get(o,e)||t:t},Lm=Symbol("LAZY_COMPONENT_KEY");function _r(e,...t){if(t.length===0){const o=m.lazy(()=>e().then(l=>{const i=l.default;return n[Lm]=i,{default:i}})),n=l=>a.jsx(m.Suspense,{fallback:a.jsx(I.Spin,{}),children:a.jsx(o,f({},l))});return n}return t.reduce((o,n)=>{const l=m.lazy(()=>e().then(i=>{const r=L.get(i,n);return o[n][Lm]=r,{default:r}}));return o[n]=i=>a.jsx(m.Suspense,{fallback:a.jsx(I.Spin,{}),children:a.jsx(l,f({},i))}),o},{})}function _0(e,t){if(e)return e["x-app-version"]||(e["x-app-version"]=t),Object.keys(e.properties||{}).forEach(o=>{var n;_0((n=e.properties)==null?void 0:n[o],t)}),e}const aA="@nocobase/client",sA="2.0.0-alpha.60",cA="AGPL-3.0",dA="lib/index.js",uA="es/index.mjs",pA="es/index.d.ts",mA={"@ahooksjs/use-url-state":"3.5.1","@ant-design/cssinjs":"^1.11.1","@ant-design/icons":"^5.6.1","@ant-design/pro-layout":"^7.22.1","@antv/g2plot":"^2.4.18","@budibase/handlebars-helpers":"0.14.0","@codemirror/lang-html":"^6.4.10","@codemirror/theme-one-dark":"^6.1.3","@ctrl/tinycolor":"^3.6.0","@dnd-kit/core":"^6.0.0","@dnd-kit/sortable":"^7.0.0","@emotion/css":"^11.7.1","@formily/antd-v5":"1.2.3","@formily/core":"^2.2.27","@formily/grid":"^2.2.27","@formily/json-schema":"^2.2.27","@formily/path":"^2.2.27","@formily/react":"^2.2.27","@formily/reactive":"^2.2.27","@formily/reactive-react":"^2.2.27","@formily/shared":"^2.2.27","@formily/validator":"^2.2.27","@nocobase/evaluators":"2.0.0-alpha.60","@nocobase/flow-engine":"2.0.0-alpha.60","@nocobase/sdk":"2.0.0-alpha.60","@nocobase/utils":"2.0.0-alpha.60","@tanstack/react-table":"^8.21.3","@types/tabulator-tables":"^6.2.6","acorn-jsx":"^5.3.2",ahooks:"^3.7.2",antd:"5.24.2","antd-mobile":"^5.41.1","antd-mobile-icons":"^0.3.0","antd-style":"3.7.1",axios:"^1.7.0","bignumber.js":"^9.1.2",classnames:"^2.3.1",codemirror:"^6.0.2",cronstrue:"^2.11.0","file-saver":"^2.0.5",filesize:"9.0.11",flat:"^5.0.2","html5-qrcode":"^2.3.8",i18next:"^22.4.9","i18next-http-backend":"^2.1.1",ignore:"^5.2.0",json5:"^2.2.3",liquidjs:"^10.0.0",lodash:"4.17.21","lru-cache":"6.0.0","markdown-it":"14.1.0","markdown-it-highlightjs":"3.3.1",mathjs:"^10.6.0",mermaid:"9.4.3",mime:"^4.0.4","mime-match":"^1.0.2","react-beautiful-dnd":"^13.1.0","react-device-detect":"2.2.3","react-drag-listview":"^0.1.9","react-error-boundary":"^4.0.10","react-helmet":"^6.1.0","react-hotkeys-hook":"^3.4.7","react-i18next":"^11.15.1","react-iframe":"~1.8.5","react-image-lightbox":"^5.1.4","react-intersection-observer":"9.14.0","react-js-cron":"^3.1.0","react-quill":"^2.0.0","react-router-dom":"^6.30.1","react-to-print":"^2.14.7","sanitize-html":"2.13.0","tabulator-tables":"^6.3.1","use-deep-compare-effect":"^1.8.1",vditor:"^3.10.3"},hA={react:">=18.0.0","react-dom":">=18.0.0","react-is":">=18.0.0"},gA={"@testing-library/react":"^14.0.0","@types/markdown-it":"14.1.1","@types/markdown-it-highlightjs":"3.3.1","@types/react-big-calendar":"^1.6.4","axios-mock-adapter":"^1.20.0",dumi:"2.2.14","dumi-theme-nocobase":"^0.2.32"},vA={name:aA,version:sA,license:cA,main:dA,module:uA,types:pA,dependencies:mA,peerDependencies:hA,devDependencies:gA};function en(e){return new Zh(e)}const K0=e=>{e&&(e["x-uid"]||(e["x-uid"]=ee.uid()),Object.keys(e.properties||{}).forEach(t=>{K0(e.properties[t])}))},Mc=e=>e,xA=(e,t)=>{if(!(!e||!t)){for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==(e==null?void 0:e[o]))return!1;return!0}},hr=(e,t)=>{if(e["x-uid"]&&e["x-uid"]===t["x-uid"])return[null,e.toJSON()];const o=e.toJSON(),n=T(f({},o),{properties:{}});let l=null;const i=(r,s)=>{Object.keys(r||{}).forEach(c=>{const d=r[c];if(d["x-uid"]===t["x-uid"]){l=r[c];return}else s.properties[c]=T(f({},d),{properties:{}}),i(d==null?void 0:d.properties,s.properties[c])})};return i(o.properties,n),[n,l]},fA=e=>e;class Zh{constructor(t){A(this,"current"),A(this,"options"),A(this,"appVersion"),A(this,"events",{}),this.options=t,this.current=t.current,this.appVersion=t.appVersion}get model(){return this.options.model}get query(){return this.options.query}loadAPIClientEvents(){const{api:t,t:o=fA}=this.options;if(!t)return;const n=l=>{if(!l)return[];const i=Object.values(l.properties).length,r=[];return l.mapProperties(s=>{s["x-component-props"]=s["x-component-props"]||{},s["x-component-props"].width=100/i,s["x-uid"]&&r.push({"x-uid":s["x-uid"],"x-component-props":s["x-component-props"]})}),l["x-uid"]&&r.length?r:[]};this.on("insertAdjacent",l=>O(this,[l],function*({onSuccess:i,current:r,position:s,schema:c,wrap:d,wrapped:u,removed:p}){var h;let g=[];if((u==null?void 0:u["x-component"])==="Grid.Col"&&(g=g.concat(n(u.parent))),(p==null?void 0:p["x-component"])==="Grid.Col"&&(g=g.concat(n(p.parent))),this.refresh(),!r["x-uid"])return;const v=yield t.request({url:`/uiSchemas:insertAdjacent/${r["x-uid"]}?position=${s}`,method:"post",data:{schema:_0(c,this.appVersion),wrap:d}});g.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:g})),p!=null&&p["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${p["x-uid"]}`,method:"post"})),i==null||i((h=v==null?void 0:v.data)==null?void 0:h.data),I.message.success(o("Saved successfully"),.2)})),this.on("patch",l=>O(this,[l],function*({schema:i}){this.refresh(),i!=null&&i["x-uid"]&&(yield t.request({url:"/uiSchemas:patch",method:"post",data:f({},i)}),I.message.success(o("Saved successfully"),.2))})),this.on("initializeActionContext",l=>O(this,[l],function*({schema:i}){i!=null&&i["x-uid"]&&(yield t.request({url:"/uiSchemas:initializeActionContext",method:"post",data:f({},i)}))})),this.on("batchPatch",l=>O(this,[l],function*({schemas:i}){this.refresh(),yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:i}),I.message.success(o("Saved successfully"),.2)})),this.on("remove",l=>O(this,[l],function*({removed:i}){let r=[];(i==null?void 0:i["x-component"])==="Grid.Col"&&(r=n(i.parent)),this.refresh(),i!=null&&i["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${i["x-uid"]}`,method:"post"}),r.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:r})),I.message.success(o("Saved successfully"),.2))}))}prepareProperty(t){t.type||(t.type="void"),t.name||(t.name=ee.uid()),this.current["x-uid"]&&K0(t)}on(t,o){this.events[t]||(this.events[t]=[]),this.events[t].push(o)}emit(t,...o){return O(this,null,function*(){if(!this.events[t])return;const[n,...l]=o;return Promise.all(this.events[t].map(i=>i.bind(this)(f({current:this.current},n),...l)))})}parentsIn(t){if(!t||!y.Schema.isSchemaInstance(t))return!1;let o=this.current;for(;o!=null&&o.parent;){if(o.parent===t)return!0;o=o.parent}return!1}refresh(t){const{refresh:o}=this.options;return o==null?void 0:o(t)}deepMerge(t){const o={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly"},n={"x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(t).forEach(l=>{o[l]?(this.current[l]=t[l],this.updateModel(o[l],t[l])):n[l]?Object.keys(t[l]).forEach(i=>{Im(this.current,[l,i],t[l][i]),this.updateModel([n[l],i],t[l][i])}):this.current[l]=t[l]}),this.emit("patch",{schema:t})}getSchemaAttribute(t,o){return gi(this.current,t,o)}shallowMerge(t){const o={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly","x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(t).forEach(n=>{this.current[n]=t[n],o[n]&&this.updateModel(o[n],t[n])}),this.emit("patch",{schema:t})}updateModel(t,o){const n=l=>{Im(l,t,o)};this.model&&n(this.model),this.query&&this.query.take(n)}insertAdjacent(t,o,n={}){switch(t){case"beforeBegin":return this.insertBeforeBegin(o,n);case"afterBegin":return this.insertAfterBegin(o,n);case"beforeEnd":return this.insertBeforeEnd(o,n);case"afterEnd":return this.insertAfterEnd(o,n)}}recursiveRemoveIfNoChildren(t,o){if(!t)return;let n=t,l;const i=o==null?void 0:o.breakRemoveOn;for(;n;){if(typeof i=="function"){if(i(n))break}else if(xA(n,i))break;if(Object.keys(n.properties||{}).length>0)break;n.parent&&(l=n.parent.removeProperty(n.name)),n=n.parent}return l}remove(t,o={}){const{breakRemoveOn:n,removeParentsIfNoChildren:l}=o,i=t||this.current;let r=i.parent.removeProperty(i.name);if(l){const s=this.recursiveRemoveIfNoChildren(i.parent,{breakRemoveOn:n});s&&(r=s)}return this.emit("remove",{removed:r})}removeWithoutEmit(t,o={}){const{breakRemoveOn:n,removeParentsIfNoChildren:l}=o,i=t||this.current;let r=i.parent.removeProperty(i.name);if(l){const s=this.recursiveRemoveIfNoChildren(i.parent,{breakRemoveOn:n});s&&(r=s)}return r}insertBeforeBeginOrAfterEnd(t,o={}){if(!y.Schema.isSchemaInstance(this.current)||!y.Schema.isSchemaInstance(t)||this.current.parent!==t.parent)return;let n=0,l=0;return this.current.parent.mapProperties((i,r,s)=>{this.current.name===r&&(l=s),t.name===r&&(n=s)}),n>l?this.insertBeforeBegin(t,o):this.insertAfterEnd(t,o)}insertBeforeBegin(t,o={}){if(!y.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o.onSuccess},{wrap:l=Mc,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(y.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Xo(t));const s={};let c=!1,d=0,u=0;this.current.parent.mapProperties((x,b)=>{b===this.current.name&&(u=d,c=!0,++d),x["x-index"]=d,++d,c&&(s[b]=x,this.current.parent.removeProperty(b))}),this.prepareProperty(t);const p=l(t),h=this.current.parent.addProperty(p.name||ee.uid(),p);h["x-index"]=u,h.parent=this.current.parent,this.current.parent.setProperties(s);const[g,v]=hr(h,t);this.emit("insertAdjacent",f({position:"beforeBegin",schema:v,wrapped:p,wrap:g},n))}insertAfterBegin(t,o={}){if(!y.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o.onSuccess},{wrap:l=Mc,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(y.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Xo(t));const s={};let c=1;this.current.mapProperties((g,v)=>{g["x-index"]=c,++c,s[v]=g}),this.current.properties={},this.prepareProperty(t);const d=l(t),u=this.current.addProperty(d.name||ee.uid(),d);u["x-index"]=0,u.parent=this.current,this.current.setProperties(s);const[p,h]=hr(u,t);this.emit("insertAdjacent",f({position:"afterBegin",schema:h,wrap:p,wrapped:d},n))}insertBeforeEnd(t,o={}){if(!y.Schema.isSchemaInstance(this.current))return;delete t["x-index"];const n={onSuccess:o.onSuccess},{wrap:l=Mc,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(y.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Xo(t));this.prepareProperty(t);const s=l(t),c=this.current.addProperty(s.name||ee.uid(),s);c.parent=this.current;const[d,u]=hr(c,t);return this.emit("insertAdjacent",f({position:"beforeEnd",schema:u,wrap:d,wrapped:s},n))}insertAfterEnd(t,o={}){if(!y.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o==null?void 0:o.onSuccess},{wrap:l=Mc,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;let s=0,c=0,d=!1;const u={};if(this.current.parent.mapProperties((x,b)=>{x["x-index"]=s,b===this.current.name&&(++s,c=s,d=!0),++s,d&&b!==this.current.name&&(u[b]=x,this.current.parent.removeProperty(b))}),y.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i})),t.parent=null}else t&&(t=Xo(t));this.prepareProperty(t);const p=l(t),h=this.current.parent.addProperty(p.name||ee.uid(),p);h.parent=this.current.parent,h["x-index"]=c,this.current.parent.setProperties(u);const[g,v]=hr(h,t);this.emit("insertAdjacent",f({position:"afterEnd",schema:v,wrap:g,wrapped:p},n))}}function eu(){const e=m.useContext(y.SchemaOptionsContext),t=m.useMemo(()=>(e==null?void 0:e.components)||{},[e]);return o=>{if(!o)return null;if(typeof o!="string")return o;const n=gi(t,o);return n||console.error(`[nocobase]: Component "${o}" not found`),n}}function X(){const{designable:e,setDesignable:t,refresh:o,reset:n}=m.useContext(Pt),l=m.useContext(y.SchemaOptionsContext),i=m.useMemo(()=>(l==null?void 0:l.components)||{},[l]),r=m.useMemo(()=>()=>a.jsx(a.Fragment,{}),[]),s=Ct.useUpdate(),c=Ji(),d=Vs(),u=m.useCallback(S=>{o==null||o(),s(),c==null||c(S),d==null||d()},[o,s,c,d]),p=y.useField(),h=y.useFieldSchema(),g=Te(),{t:v}=K.useTranslation(),x=m.useMemo(()=>en({t:v,api:g,refresh:u,current:h,model:p,appVersion:vA.version}),[v,g,u,h,p]);m.useEffect(()=>{x.loadAPIClientEvents()},[x]);const{isMobileLayout:b}=to();return{dn:x,designable:b?!1:e,reset:n,refresh:u,setDesignable:t,DesignableBar:r,findComponent:m.useCallback(S=>{var C;if(!S)return null;if(typeof S!="string")return S;const k=gi(i,S);return(C=k==null?void 0:k[Lm])!=null?C:k},[gi]),on:x.on.bind(x),patch:m.useCallback((S,C)=>{const k=F=>{Object.keys(F).forEach(j=>{const P=F[j];j==="title"&&(p.title=P,h.title=P),j==="x-decorator-props"&&(p.decoratorProps||(p.decoratorProps={}),h["x-decorator-props"]||(h["x-decorator-props"]={}),Object.keys(P).forEach(M=>{p.decoratorProps[M]=P[M],h["x-decorator-props"][M]=P[M]})),j==="x-component-props"&&(p.componentProps||(p.componentProps={}),h["x-component-props"]||(h["x-component-props"]={}),Object.keys(P).forEach(M=>{p.componentProps[M]=P[M],h["x-component-props"][M]=P[M]}))})};if(typeof S=="string"){const F={};return Im(F,S,C),k(F)}k(S),u()},[x]),shallowMerge:m.useCallback(S=>{x.shallowMerge(S)},[x]),deepMerge:m.useCallback(S=>{x.deepMerge(S)},[x]),remove:m.useCallback((S,C)=>{x.remove(S,C)},[x]),insertAdjacent:m.useCallback((S,C,k)=>{x.insertAdjacent(S,C,k)},[x]),insertBeforeBegin:m.useCallback(S=>{x.insertBeforeBegin(S)},[x]),insertAfterBegin:m.useCallback(S=>{x.insertAfterBegin(S)},[x]),insertBeforeEnd:m.useCallback(S=>{x.insertBeforeEnd(S)},[x]),insertAfterEnd:m.useCallback(S=>{x.insertAfterEnd(S)},[x])}}const Vm=()=>null;Vm.isNullComponent=!0;const Wo=()=>{const{designable:e}=X(),t=y.useFieldSchema(),o=m.useMemo(()=>t["x-designer"]||t["x-toolbar"]?t["x-designer"]||t["x-toolbar"]:t["x-settings"]?dn:Vm,[t]),n=jo(o);return e&&n||Vm},U0=e=>{const t=m.useContext(y.SchemaOptionsContext),o=m.useContext(y.SchemaExpressionScopeContext),n=m.useRef();return n.current=o,e.toFieldProps(T(f({},t),{get scope(){return f(f({},t.scope),n.current)}}))};function Ni(){return m.useContext(Pt)}const eg=()=>{var e;const{getCollectionJoinField:t,getCollection:o}=ie(),n=y.useFieldSchema(),{getField:l}=re(),i=l(n.name)||t(n["x-collection-field"]),{t:r}=K.useTranslation(),{label:s}=((e=n["x-component-props"])==null?void 0:e.fieldNames)||{};return m.useMemo(()=>{if(!i||!(i!=null&&i.interface)||!["o2o","oho","obo","o2m","linkTo","m2o","m2m"].includes(i.interface))return;const c=o(i.target);if((c==null?void 0:c.template)==="file")return[{label:r("Record picker"),value:"CollectionField"},{label:r("Select"),value:"AssociationSelect"}];switch(i.interface){case"o2m":return[{label:r("Record picker"),value:"CollectionField"},{label:r("Subtable"),value:"TableField"},{label:r("Select"),value:"AssociationSelect"}];case"m2o":case"m2m":case"linkTo":return[{label:r("Record picker"),value:"CollectionField"},{label:r("Select"),value:"AssociationSelect"}];default:return[{label:r("Record picker"),value:"CollectionField"},{label:r("Subform"),value:"FormField"},{label:r("Select"),value:"AssociationSelect"}]}},[r,i==null?void 0:i.interface,s])},tu=()=>{var e;const t=y.useField(),o=y.useFieldSchema(),n=ve(),l=Ye(),i=(n==null?void 0:n.getField(o.name))||(l==null?void 0:l.getCollectionField(o["x-collection-field"])),r=se();m.useEffect(()=>{var s;t!=null&&t.title||(t.title=r((s=i==null?void 0:i.uiSchema)==null?void 0:s.title))},[(e=i==null?void 0:i.uiSchema)==null?void 0:e.title])},sb=()=>({}),Yt=(e={})=>{const t=e,{useProps:o=sb}=t,n=ne(t,["useProps"]);let l=o;typeof o!="function"&&(l=sb);const i=l();return f(f({},n),i)};function zl({filterOption:e,onFilterChange:t}){const{parseFilter:o,findVariable:n}=z$(),[l,i]=m.useState({}),[r,s]=m.useState(!!e);return m.useEffect(()=>{if(!e)return;const c=()=>O(this,null,function*(){s(!0);const u=yield o(e);s(!1),i(u),t==null||t(u)});c();const d=L.debounce(c,M0);ut.reaction(()=>de.flatten(e,{breakOn({key:u}){return u.startsWith("$")&&u!=="$and"&&u!=="$or"},transformValue(u){if(!dt(u))return u;const p=Gd(u),h=n(p);let g=null;const v=Hd(u).split(".");return v.forEach((x,b)=>{const S=v.slice(0,b+1).join("."),C=de.getValuesByPath({[p]:(h==null?void 0:h.ctx)||{}},S);L.isEmpty(C)||(g=C)}),g}}),d,{equals:L.isEqual})},[JSON.stringify(e),o,n]),{filter:l,parseVariableLoading:r}}const as=e=>{const t=Dt();if(e)return t},bA=e=>{var t;const{params:o,parseVariableLoading:n}=H0(e),l=as(e.association),i=(t=wt().getDataSource(e.dataSource))==null?void 0:t.collectionManager.getCollection(e.collection);return{params:o,parentRecord:l,parseVariableLoading:n,rowKey:(i==null?void 0:i.filterTargetKey)||"id"}};function H0(e){var t;const o=y.useFieldSchema(),{filter:n,parseVariableLoading:l}=zl({filterOption:(t=e.params)==null?void 0:t.filter});return{params:m.useMemo(()=>{const i=e.params||{},{dragSortBy:r}=(o==null?void 0:o["x-decorator-props"])||{};return e.dragSort&&r&&(i.sort=r),T(f({},i),{filter:n})},[o,n,e.dragSort,e.params]),parseVariableLoading:l}}const G0="__isNewRecord__",tg=e=>ut.untracked(()=>!!(e!=null&&e[G0])),ol=e=>{if(!L.isObject(e))throw new Error("markRecordAsNew: record must be an object");return e[G0]=!0,e},yA=()=>{var e;return!!((e=Un())!=null&&e.loading)},ss=(e,t)=>{const{useLoading:o=yA,displayName:n,SkeletonComponent:l=I.Skeleton}=t||{},i=m.memo(r=>{const s=o(),c=m.useRef(!1),d=m.useDeferredValue(s);return!c.current&&d?a.jsx(l,{}):(c.current=!0,a.jsx(e,f({},r)))});return i.displayName=n||`${e.displayName}(withSkeletonComponent)`||`${e.name}(withSkeletonComponent)`,i},SA=(e,t)=>{const o=n=>(n==null?void 0:n.mode)==="constant"?n.value:null;switch(!0){case[he.Color,he.BackgroundColor,he.TextAlign,he.FontSize,he.FontWeight,he.FontStyle].includes(e):return o(t);default:return null}},CA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield Promise.all(o.filter(r=>!r.disabled).map(r=>O(void 0,null,function*(){return(yield Co({ruleGroup:r.condition,variables:n,localVariables:l,conditionType:r.conditionType},i))?r:null})))).filter(Boolean).map(r=>r.actions).flat()}),FA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield CA({rules:o,variables:n,localVariables:l},i)).map(r=>T(f({},r),{value:SA(r.operator,r.value)}))}),kA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield FA({rules:o,variables:n,localVariables:l},i)).reduce((r,s)=>T(f({},r),{[s.operator]:s.value}),{})});function og({formValues:e,category:t="default",rules:o,schema:n,form:l}){const[i,r]=m.useState({}),s=y.useFieldSchema(),c=st(),d=gt({currentForm:{values:e}}),u=n??s,p=o??(u[td[t]]||(u==null?void 0:u.parent[td[t]])),h=ot(),g=m.useCallback(()=>{p&&e&&kA({rules:p,variables:c,localVariables:d},h.jsonLogic).then(v=>{L.isEmpty(v)?r({}):r(v)}).catch(v=>{throw new Error(v.message)})},[c,d,p,e]);return m.useEffect(()=>{if(g(),l){const v=ee.uid();return l.addEffects(v,()=>{Oe.onFormValuesChange(()=>{g()})}),()=>{l.removeEffects(v)}}},[l,g,e]),{valueMap:i}}const W0=m.memo(({record:e,schema:t,onStyleChange:o})=>{const{valueMap:n}=og({formValues:e,category:"style",schema:t});return m.useEffect(()=>{o(n)},[o,n]),null});W0.displayName="GetStyleRules";const wA={opacity:.5},PA={position:"relative"},jA={display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",left:0,right:0,height:"100%",maxHeight:400,zIndex:1e3},IA={display:"none"},ng=m.memo(e=>a.jsxs("div",{style:PA,children:[a.jsx(I.Spin,T(f({},L.omit(e,"children")),{style:e.spinning?jA:IA})),a.jsx("div",{style:e.spinning?wA:null,children:e.children})]}));ng.displayName="HighPerformanceSpin";var Kr=(e=>(e[e.FORM=0]="FORM",e[e.TABLE=1]="TABLE",e[e.TREE=2]="TREE",e[e.COLLAPSE=3]="COLLAPSE",e))(Kr||{});const Zt=(e,t="$and")=>{const o=e.filter(n=>{if(n&&typeof n=="object"&&!Array.isArray(n))return Object.values(n).filter(l=>l!==void 0).length});return o.length===0?{}:o.length===1?o[0]:{[t]:o}},Y0=(e,t)=>{var o;return(o=t.associatedFields)==null?void 0:o.filter(n=>e==null?void 0:e.some(l=>l===n.target))},J0=(e,t)=>{var o;return(o=t.foreignKeyFields)==null?void 0:o.filter(n=>e.fields.some(l=>l.type!=="belongsTo"&&l.foreignKey===n.name&&l.target===n.collectionName))},TA=e=>{const{getDataBlocks:t}=Jl(),o=y.useFieldSchema(),n=ve(),{getAllCollectionsInheritChain:l}=e0();if(e===0||e===3)return t().filter(i=>zm(i.collection,n));if(e===1||e===2)return t().filter(i=>{var r,s;return o["x-uid"]!==i.uid&&(zm(i.collection,n)||((r=Y0(l(n.name,n.dataSource),i))==null?void 0:r.length)||((s=J0(n,i))==null?void 0:s.length))})},MA=(e,t,o,n)=>(e=de.flatten(e,{breakOn({value:l,path:i}){if(["$match","$notMatch","$anyOf","$noneOf","$childIn","$childNotIn","$dateBetween","$in","$notIn"].includes(t[i]))return!0;const r=o(`${n}.${i}`);if(["datetime","datetimeNoTz","date","unixTimestamp","createdAt","updatedAt"].includes(r==null?void 0:r.interface))return!0;if(r!=null&&r.target){if(Array.isArray(l))return!0;const s=r.targetKey||"id";if(l&&l[s]!=null)return!0}return!1}}),{$and:Object.keys(e).map(l=>{let i=L.get(e,l);const r=o(`${n}.${l}`);return r!=null&&r.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(r.type)&&(i=de.getValuesByPath(i,r.targetKey||"id"),l=`${l}.${r.targetKey||"id"}`,(r==null?void 0:r.interface)==="chinaRegion"&&(i=L.last(i))),!i&&i!==0&&i!==!1?null:{[l]:{[t[l]||"$eq"]:i}}}).filter(Boolean)}),lg=()=>{var e;return((e=ve())==null?void 0:e.fields.filter(t=>X0(t)))||[]},X0=e=>["o2o","oho","obo","m2o","createdBy","updatedBy","o2m","m2m","linkTo","chinaRegion","mbm"].includes(e==null?void 0:e.interface),zm=(e,t)=>e.name===t.name&&e.dataSource===t.dataSource,Cr=e=>{for(;e;){if(e["x-filter-targets"])return e["x-decorator"]==="FilterFormBlockProvider";e=e.parent}return!1},ou=m.createContext({});ou.displayName="AssociationFieldContext";const rl=e=>{const t=y.useFieldSchema(),{insertAfterBegin:o}=X(),{isMobileLayout:n}=to();return m.useCallback(l=>{n||t.reduceProperties((i,r)=>r["x-component"]==="AssociationField."+e?r:i,null)||o(Xo(l))},[e,t,o,n])};function Tt(){return m.useContext(ou)}function ig(e){var t,o,n,l,i,r,s,c,d,u;const{action:p="list",service:h,useOriginalFilter:g}=e,v=y.useFieldSchema(),x=y.useField(),{getField:b}=re(),{getCollectionJoinField:S}=ie(),C=$e(),{isNew:k}=fo()||{},F=(L.isString((n=(o=(t=v==null?void 0:v["x-component-props"])==null?void 0:t.service)==null?void 0:o.params)==null?void 0:n.filter)?(r=(i=(l=x.componentProps)==null?void 0:l.service)==null?void 0:i.params)==null?void 0:r.filter:(d=(c=(s=v==null?void 0:v["x-component-props"])==null?void 0:s.service)==null?void 0:c.params)==null?void 0:d.filter)||((u=h==null?void 0:h.params)==null?void 0:u.filter),{filter:j}=zl({filterOption:F,onFilterChange:()=>{k&&x.reset()}}),P=m.useMemo(()=>b(v.name)||S(v==null?void 0:v["x-collection-field"]),[v]),M=C==null?void 0:C[P==null?void 0:P.sourceKey],R=m.useMemo(()=>{const N=["oho","o2m"].includes(P==null?void 0:P.interface);return Zt([Zt([N&&!Cr(v)&&P!=null&&P.foreignKey&&!g?{[P.foreignKey]:{$is:null}}:null,j]),N&&M!==void 0&&M!==null&&!Cr(v)&&P!=null&&P.foreignKey&&!g?{[P.foreignKey]:{$eq:M}}:null],"$or")},[P==null?void 0:P.interface,P==null?void 0:P.foreignKey,v,j,M,g]);return m.useMemo(()=>T(f({resource:P==null?void 0:P.target,action:p},h),{params:T(f({},h==null?void 0:h.params),{filter:R})}),[P==null?void 0:P.target,p,R,h])}const Ur=(e={})=>{var t,o,n,l,i;const r=y.useFieldSchema(),s=((l=(n=(o=(t=r["x-component-props"])==null?void 0:t.field)==null?void 0:o.uiSchema)==null?void 0:n["x-component-props"])==null?void 0:l.fieldNames)||((i=r["x-component-props"])==null?void 0:i.fieldNames)||e.fieldNames;return f({label:"label",value:"value"},s)},nd=m.createContext(null);nd.displayName="SubFormContext";const Di=e=>{const t=m.useContext(nd),{value:o,collection:n,fieldSchema:l,parent:i,skip:r}=e.value,s=m.useMemo(()=>L.omitBy({value:o,collection:n,fieldSchema:l,skip:r,parent:i||(t!=null&&t.skip?t.parent:t)},L.isUndefined),[o,n,l,r,i,t]);return a.jsx(nd.Provider,{value:s,children:e.children})},Hr=()=>{const{value:e,collection:t,fieldSchema:o,parent:n}=m.useContext(nd)||{};return{formValue:e,collection:t,fieldSchema:o,parent:n}},cs=e=>{const{t}=K.useTranslation(),o=`nocobase_table_column_settings_${e}`,n=m.useCallback(()=>{try{const r=localStorage.getItem(o);return r?JSON.parse(r):null}catch(r){return console.warn("Failed to parse table column settings from localStorage:",r),null}},[o]),l=m.useCallback(r=>{try{const s=JSON.stringify(r);localStorage.setItem(o,s);const c=new CustomEvent("nocobase-table-settings-changed",{detail:{key:o,tableId:e,settings:r}});window.dispatchEvent(c)}catch(s){console.warn("Failed to save table column settings to localStorage:",s),I.message.error(t("Failed to save table settings"))}},[o,e,t]),i=m.useCallback(()=>{try{localStorage.removeItem(o);const r=new CustomEvent("nocobase-table-settings-changed",{detail:{key:o,tableId:e,settings:null}});window.dispatchEvent(r)}catch(r){console.warn("Failed to clear table column settings from localStorage:",r),I.message.error(t("Failed to clear table settings"))}},[o,e,t]);return{getSettings:n,saveSettings:l,clearSettings:i}},nu=(e,t=!0)=>{const o=y.useFieldSchema(),n=(o==null?void 0:o["x-uid"])||"default",{getSettings:l}=cs(n),[i,r]=m.useState(0);m.useEffect(()=>{const c=d=>{const{key:u,tableId:p}=d.detail;(u.includes(n)||p===n)&&r(h=>h+1)};return window.addEventListener("nocobase-table-settings-changed",c),()=>{window.removeEventListener("nocobase-table-settings-changed",c)}},[n]);const s=m.useMemo(()=>l(),[l,i]);return{columns:m.useMemo(()=>{if(!t||!s||s.length===0)return e;const c=new Map;s.forEach(g=>{c.set(g.key,g)});const d=e.map(g=>{const v=c.get(g.key);if(v){const x=g.columnHidden||!v.visible,b=v.width||g.width,S=v.fixed||g.fixed;return T(f({},g),{columnHidden:x,fixed:S,width:b,_orderIndex:v.order})}return g}),u=[],p=[];d.forEach(g=>{g._orderIndex!==void 0?u.push(g):p.push(g)}),u.sort((g,v)=>(g._orderIndex||0)-(v._orderIndex||0));const h=[...u,...p];return h.forEach(g=>{delete g._orderIndex}),h},[e,s])}},AA=({rows:e=5,columns:t=6})=>{const{token:o}=mt(),n=o.controlHeight*2.06,l=o.controlHeight*1.75,i=m.useMemo(()=>Z.css`
|
|
64
|
+
`,items:s},i))})},JM=()=>{const{isInMenu:e}=YM();return{attribute:m.useMemo(()=>e?{}:{role:"menuitem"},[e])}},{Paragraph:XM,Text:QM}=I.Typography,ZM=e=>{const[t,o]=m.useState(!1),n=a.jsx(XM,{style:{display:"flex",marginBottom:0},copyable:{text:e.error.message},children:a.jsxs(QM,{type:"danger",style:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",display:"inline-block",maxWidth:"200px"},children:["Error: ",e.error.message]})});return a.jsxs(a.Fragment,{children:[a.jsx("div",{onMouseOver:()=>o(!0),children:e.children||n}),a.jsx(I.Modal,{zIndex:1e4,open:t,footer:null,onCancel:()=>o(!1),width:"60%",children:a.jsx(bo,f({},e))})]})},{Paragraph:eA,Text:tA,Link:oA}=I.Typography,Qd=(e,t={})=>{const o=Ed(),[n,l]=m.useState(!1),i=Te();return{loading:n,download:()=>O(void 0,null,function*(){l(!0);try{const r=yield i.request({url:"logger:collect",method:"post",responseType:"blob",data:f({error:{message:e.message,stack:e.stack},location:o},t)}),s=window.URL.createObjectURL(new Blob([r.data],{type:"application/gzip"})),c=document.createElement("a");c.setAttribute("href",s),c.setAttribute("download","logs.tar.gz"),c.click(),c.remove()}catch(r){console.log(r)}l(!1)})}},bo=({error:e})=>{const t=y.useFieldSchema(),{t:o}=K.useTranslation(),{loading:n,download:l}=Qd(e,{schema:t}),i=a.jsxs(K.Trans,{children:["This is likely a NocoBase internals bug. Please open an issue at ",a.jsx(oA,{href:"https://github.com/nocobase/nocobase/issues",target:"_blank",children:"here"})]});return a.jsx("div",{style:{backgroundColor:"white"},children:a.jsx(I.Result,{style:{maxWidth:"60vw",margin:"auto"},status:"error",title:o("Render Failed"),subTitle:i,extra:[a.jsx(I.Button,{type:"primary",href:"https://github.com/nocobase/nocobase/issues",target:"_blank",children:o("Feedback")},"feedback"),a.jsx(I.Button,{loading:n,onClick:l,children:o("Download logs")},"log")],children:a.jsx(eA,{copyable:{text:e.stack},children:a.jsx(tA,{type:"danger",style:{whiteSpace:"pre-line",textAlign:"center"},children:e.stack})})})})};bo.Modal=ZM;const Sr=()=>{const e=De.useNavigate(),{t}=K.useTranslation();return a.jsx(I.Result,{status:"404",title:"404",subTitle:t("Sorry, the page you visited does not exist."),extra:a.jsx(I.Button,{onClick:()=>e("/",{replace:!0}),type:"primary",children:"Back Home"})})};class co{constructor(t,o){this.options=t,this.app=o,this.options=t,this.app=o}get pluginManager(){return this.app.pluginManager}get context(){return this.app.context}get flowEngine(){return this.app.flowEngine}get engine(){return this.app.flowEngine}get pm(){return this.app.pm}get router(){return this.app.router}get pluginSettingsManager(){return this.app.pluginSettingsManager}get pluginSettingsRouter(){return this.app.pluginSettingsManager}get schemaInitializerManager(){return this.app.schemaInitializerManager}get schemaSettingsManager(){return this.app.schemaSettingsManager}get dataSourceManager(){return this.app.dataSourceManager}afterAdd(){return O(this,null,function*(){})}beforeLoad(){return O(this,null,function*(){})}load(){return O(this,null,function*(){})}t(t,o={}){var n;return this.app.i18n.t(t,f({ns:(n=this.options)==null?void 0:n.packageName},o))}}const nA={display:"flex",alignItems:"center",gap:4},Zd=e=>t=>{const{tooltip:o}=t;return o?a.jsxs("div",{style:nA,children:[a.jsx(e,f({},t)),a.jsx(I.Tooltip,{title:o,children:a.jsx(te.QuestionCircleOutlined,{style:{zIndex:1}})})]}):a.jsx(e,f({},t))},{evaluate:lA}=kd.evaluators.get("formula.js"),Qh=e=>{const t=st(),o=gt(),[n,l]=m.useState();return m.useEffect(()=>{O(void 0,null,function*(){if(e==null||e===""){l(void 0);return}const{exp:i,scope:r}=yield Yd(e,{variables:t,localVariables:o});try{const s=lA(i,f({now:()=>new Date().toString()},r));l(s)}catch(s){console.error(s)}})},[t.parseVariable,e,o]),n};class kn{constructor(t){A(this,"options"),A(this,"name"),this.options=Object.assign({items:[]},t),this.name=t.name}get items(){return this.options.items}add(t,o){const n=t.split("."),l=n[n.length-1],i=T(f({},o),{name:l}),r=(d,u)=>{const p=this.items.findIndex(h=>h.name===d);p===-1?this.items.push(u):this.items[p]=u};if(n.length===1){r(l,i);return}const s=n.slice(0,-1).join("."),c=this.get(s);if(c){c.children||(c.children=[]);const d=t.replace(`${c.name}.`,""),u=c.children.findIndex(p=>p.name===d);u===-1?c.children.push(i):c.children[u]=i}else r(l,i)}get(t){var o;if(!t)return;const n=t.split(".");let l={children:this.items};for(let i=0;i<n.length;i++){const r=n[i],s=(o=l.children)==null?void 0:o.find(c=>c.name===r);if(s&&(l=s),i===n.length-1)return s}}remove(t){const o=t.split(".");if(o.length===1){const l=this.items.findIndex(i=>i.name===o[0]);l!==-1&&this.items.splice(l,1);return}const n=this.get(o.slice(0,-1).join("."));if(n&&n.children){const l=o[o.length-1],i=n.children.findIndex(r=>r.name===l);i!==-1&&n.children.splice(i,1)}}}var Ze=(e=>(e.group="group",e.page="page",e.flowRoute="flowRoute",e.link="link",e.tabs="tabs",e.flowPage="flowPage",e))(Ze||{});const Ai=Nt("nb-menu-item",e=>{const{componentCls:t}=e;return{[t]:{paddingLeft:`${e.padding}px !important`,paddingRight:`${e.padding}px !important`}}}),iA=()=>{const e=Te();return m.useCallback(t=>O(void 0,null,function*(){yield e.request({method:"POST",url:"/uiSchemas:insert",data:t})}),[e])},rA=()=>{const{t:e}=K.useTranslation(),t=m.useContext(y.SchemaOptionsContext),{theme:o}=Go(),{componentCls:n,hashId:l}=Ai(),i=Xi(),{createRoute:r}=qt(),s=iA(),c=m.useCallback(()=>O(void 0,null,function*(){const d=yield Yo(e("Add page"),()=>a.jsx(ht,{scope:t.scope,components:f({},t.components),children:a.jsx(ue.FormLayout,{layout:"vertical",children:a.jsx(To.Provider,{value:bl,children:a.jsx(He,{schema:{properties:{title:{title:e("Menu item title"),required:!0,"x-component":"Input","x-decorator":"FormItem"},icon:{title:e("Icon"),"x-component":"IconPicker","x-decorator":"FormItem"}}}})})})}),o).open({initialValues:{}}),u=ee.uid(),p=ee.uid(),h=ee.uid(),g=ee.uid();yield r({type:Ze.flowPage,title:d.title,icon:d.icon,parentId:i==null?void 0:i.id,schemaUid:p,menuSchemaUid:u,enableTabs:!1,children:[{type:Ze.tabs,schemaUid:h,tabSchemaName:g,hidden:!0}]}),s(V0({pageSchemaUid:p}))}),[r,s,t==null?void 0:t.components,t==null?void 0:t.scope,i==null?void 0:i.id,e,o]);return a.jsx(Mt,{title:e("Modern page (v2)"),onClick:c,className:`${n} ${l}`})};function V0({pageSchemaUid:e}){return{type:"void","x-component":"FlowRoute","x-uid":e}}const z0=()=>{const{t:e}=K.useTranslation(),t=m.useContext(y.SchemaOptionsContext),{theme:o}=Go(),{componentCls:n,hashId:l}=Ai(),i=Xi(),{createRoute:r}=qt(),s=m.useCallback(()=>O(void 0,null,function*(){const c=yield Yo(e("Add group"),()=>a.jsx(ht,{scope:t.scope,components:f({},t.components),children:a.jsx(ue.FormLayout,{layout:"vertical",children:a.jsx(To.Provider,{value:bl,children:a.jsx(He,{schema:{properties:{title:{title:e("Menu item title"),"x-component":"Input","x-decorator":"FormItem",required:!0},icon:{title:e("Icon"),"x-component":"IconPicker","x-decorator":"FormItem"}}}})})})}),o).open({initialValues:{}}),{title:d,icon:u}=c,p=ee.uid();yield r({type:Ze.group,title:d,icon:u,parentId:i==null?void 0:i.id,schemaUid:p})}),[t.components,t.scope,e,o]);return a.jsx(Mt,{title:e("Group"),onClick:s,className:`${n} ${l}`})},Ri=e=>{const t=m.useRef(null);return m.useEffect(()=>(t.current&&e!==t.current&&t.current.onUnmount(),t.current=e,e.onMount(),()=>{e.onUnmount()}),[e]),e},ri={},ab=e=>/{{.*?}}/g.test(e),se=({noCache:e}={noCache:!1})=>{const t=m.useContext(y.SchemaOptionsContext),o=m.useContext(y.SchemaExpressionScopeContext);return(n,l)=>{let i=!1,r;if(typeof n=="string"&&n.startsWith("{{")&&(i=!0,r=n),n&&typeof n=="object"&&!m.isValidElement(n)){try{r=JSON.stringify(n)}catch(s){return console.warn("Failed to stringify:",s),n}if(ri[r])return ri[r];i=ab(r)}if(Array.isArray(n)){try{r=JSON.stringify(n)}catch(s){return console.warn("Failed to stringify:",s),n}if(ri[r])return ri[r];i=ab(r)}if(i){const s=f(f(f({},t==null?void 0:t.scope),o),l);if(!r)return y.Schema.compile(n,s);try{return e?y.Schema.compile(n,s):(ri[r]=ri[r]||y.Schema.compile(n,s),ri[r])}catch(c){return console.log("useCompile error",n,c),y.Schema.compile(n,s)}}return n}},jo=(e,t)=>{const{components:o}=m.useContext(y.SchemaOptionsContext);return e?typeof e!="string"?e:L.get(o,e)||t:t},Lm=Symbol("LAZY_COMPONENT_KEY");function _r(e,...t){if(t.length===0){const o=m.lazy(()=>e().then(l=>{const i=l.default;return n[Lm]=i,{default:i}})),n=l=>a.jsx(m.Suspense,{fallback:a.jsx(I.Spin,{}),children:a.jsx(o,f({},l))});return n}return t.reduce((o,n)=>{const l=m.lazy(()=>e().then(i=>{const r=L.get(i,n);return o[n][Lm]=r,{default:r}}));return o[n]=i=>a.jsx(m.Suspense,{fallback:a.jsx(I.Spin,{}),children:a.jsx(l,f({},i))}),o},{})}function _0(e,t){if(e)return e["x-app-version"]||(e["x-app-version"]=t),Object.keys(e.properties||{}).forEach(o=>{var n;_0((n=e.properties)==null?void 0:n[o],t)}),e}const aA="@nocobase/client",sA="2.0.0-alpha.61",cA="AGPL-3.0",dA="lib/index.js",uA="es/index.mjs",pA="es/index.d.ts",mA={"@ahooksjs/use-url-state":"3.5.1","@ant-design/cssinjs":"^1.11.1","@ant-design/icons":"^5.6.1","@ant-design/pro-layout":"^7.22.1","@antv/g2plot":"^2.4.18","@budibase/handlebars-helpers":"0.14.0","@codemirror/lang-html":"^6.4.10","@codemirror/theme-one-dark":"^6.1.3","@ctrl/tinycolor":"^3.6.0","@dnd-kit/core":"^6.0.0","@dnd-kit/sortable":"^7.0.0","@emotion/css":"^11.7.1","@formily/antd-v5":"1.2.3","@formily/core":"^2.2.27","@formily/grid":"^2.2.27","@formily/json-schema":"^2.2.27","@formily/path":"^2.2.27","@formily/react":"^2.2.27","@formily/reactive":"^2.2.27","@formily/reactive-react":"^2.2.27","@formily/shared":"^2.2.27","@formily/validator":"^2.2.27","@nocobase/evaluators":"2.0.0-alpha.61","@nocobase/flow-engine":"2.0.0-alpha.61","@nocobase/sdk":"2.0.0-alpha.61","@nocobase/utils":"2.0.0-alpha.61","@tanstack/react-table":"^8.21.3","@types/tabulator-tables":"^6.2.6","acorn-jsx":"^5.3.2",ahooks:"^3.7.2",antd:"5.24.2","antd-mobile":"^5.41.1","antd-mobile-icons":"^0.3.0","antd-style":"3.7.1",axios:"^1.7.0","bignumber.js":"^9.1.2",classnames:"^2.3.1",codemirror:"^6.0.2",cronstrue:"^2.11.0","file-saver":"^2.0.5",filesize:"9.0.11",flat:"^5.0.2","html5-qrcode":"^2.3.8",i18next:"^22.4.9","i18next-http-backend":"^2.1.1",ignore:"^5.2.0",json5:"^2.2.3",liquidjs:"^10.0.0",lodash:"4.17.21","lru-cache":"6.0.0","markdown-it":"14.1.0","markdown-it-highlightjs":"3.3.1",mathjs:"^10.6.0",mermaid:"9.4.3",mime:"^4.0.4","mime-match":"^1.0.2","react-beautiful-dnd":"^13.1.0","react-device-detect":"2.2.3","react-drag-listview":"^0.1.9","react-error-boundary":"^4.0.10","react-helmet":"^6.1.0","react-hotkeys-hook":"^3.4.7","react-i18next":"^11.15.1","react-iframe":"~1.8.5","react-image-lightbox":"^5.1.4","react-intersection-observer":"9.14.0","react-js-cron":"^3.1.0","react-quill":"^2.0.0","react-router-dom":"^6.30.1","react-to-print":"^2.14.7","sanitize-html":"2.13.0","tabulator-tables":"^6.3.1","use-deep-compare-effect":"^1.8.1",vditor:"^3.10.3"},hA={react:">=18.0.0","react-dom":">=18.0.0","react-is":">=18.0.0"},gA={"@testing-library/react":"^14.0.0","@types/markdown-it":"14.1.1","@types/markdown-it-highlightjs":"3.3.1","@types/react-big-calendar":"^1.6.4","axios-mock-adapter":"^1.20.0",dumi:"2.2.14","dumi-theme-nocobase":"^0.2.32"},vA={name:aA,version:sA,license:cA,main:dA,module:uA,types:pA,dependencies:mA,peerDependencies:hA,devDependencies:gA};function en(e){return new Zh(e)}const K0=e=>{e&&(e["x-uid"]||(e["x-uid"]=ee.uid()),Object.keys(e.properties||{}).forEach(t=>{K0(e.properties[t])}))},Mc=e=>e,xA=(e,t)=>{if(!(!e||!t)){for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==(e==null?void 0:e[o]))return!1;return!0}},hr=(e,t)=>{if(e["x-uid"]&&e["x-uid"]===t["x-uid"])return[null,e.toJSON()];const o=e.toJSON(),n=T(f({},o),{properties:{}});let l=null;const i=(r,s)=>{Object.keys(r||{}).forEach(c=>{const d=r[c];if(d["x-uid"]===t["x-uid"]){l=r[c];return}else s.properties[c]=T(f({},d),{properties:{}}),i(d==null?void 0:d.properties,s.properties[c])})};return i(o.properties,n),[n,l]},fA=e=>e;class Zh{constructor(t){A(this,"current"),A(this,"options"),A(this,"appVersion"),A(this,"events",{}),this.options=t,this.current=t.current,this.appVersion=t.appVersion}get model(){return this.options.model}get query(){return this.options.query}loadAPIClientEvents(){const{api:t,t:o=fA}=this.options;if(!t)return;const n=l=>{if(!l)return[];const i=Object.values(l.properties).length,r=[];return l.mapProperties(s=>{s["x-component-props"]=s["x-component-props"]||{},s["x-component-props"].width=100/i,s["x-uid"]&&r.push({"x-uid":s["x-uid"],"x-component-props":s["x-component-props"]})}),l["x-uid"]&&r.length?r:[]};this.on("insertAdjacent",l=>O(this,[l],function*({onSuccess:i,current:r,position:s,schema:c,wrap:d,wrapped:u,removed:p}){var h;let g=[];if((u==null?void 0:u["x-component"])==="Grid.Col"&&(g=g.concat(n(u.parent))),(p==null?void 0:p["x-component"])==="Grid.Col"&&(g=g.concat(n(p.parent))),this.refresh(),!r["x-uid"])return;const v=yield t.request({url:`/uiSchemas:insertAdjacent/${r["x-uid"]}?position=${s}`,method:"post",data:{schema:_0(c,this.appVersion),wrap:d}});g.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:g})),p!=null&&p["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${p["x-uid"]}`,method:"post"})),i==null||i((h=v==null?void 0:v.data)==null?void 0:h.data),I.message.success(o("Saved successfully"),.2)})),this.on("patch",l=>O(this,[l],function*({schema:i}){this.refresh(),i!=null&&i["x-uid"]&&(yield t.request({url:"/uiSchemas:patch",method:"post",data:f({},i)}),I.message.success(o("Saved successfully"),.2))})),this.on("initializeActionContext",l=>O(this,[l],function*({schema:i}){i!=null&&i["x-uid"]&&(yield t.request({url:"/uiSchemas:initializeActionContext",method:"post",data:f({},i)}))})),this.on("batchPatch",l=>O(this,[l],function*({schemas:i}){this.refresh(),yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:i}),I.message.success(o("Saved successfully"),.2)})),this.on("remove",l=>O(this,[l],function*({removed:i}){let r=[];(i==null?void 0:i["x-component"])==="Grid.Col"&&(r=n(i.parent)),this.refresh(),i!=null&&i["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${i["x-uid"]}`,method:"post"}),r.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:r})),I.message.success(o("Saved successfully"),.2))}))}prepareProperty(t){t.type||(t.type="void"),t.name||(t.name=ee.uid()),this.current["x-uid"]&&K0(t)}on(t,o){this.events[t]||(this.events[t]=[]),this.events[t].push(o)}emit(t,...o){return O(this,null,function*(){if(!this.events[t])return;const[n,...l]=o;return Promise.all(this.events[t].map(i=>i.bind(this)(f({current:this.current},n),...l)))})}parentsIn(t){if(!t||!y.Schema.isSchemaInstance(t))return!1;let o=this.current;for(;o!=null&&o.parent;){if(o.parent===t)return!0;o=o.parent}return!1}refresh(t){const{refresh:o}=this.options;return o==null?void 0:o(t)}deepMerge(t){const o={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly"},n={"x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(t).forEach(l=>{o[l]?(this.current[l]=t[l],this.updateModel(o[l],t[l])):n[l]?Object.keys(t[l]).forEach(i=>{Im(this.current,[l,i],t[l][i]),this.updateModel([n[l],i],t[l][i])}):this.current[l]=t[l]}),this.emit("patch",{schema:t})}getSchemaAttribute(t,o){return gi(this.current,t,o)}shallowMerge(t){const o={title:"title",description:"description",default:"initialValue",readOnly:"readOnly",writeOnly:"editable",enum:"dataSource","x-pattern":"pattern","x-display":"display","x-validator":"validator","x-decorator":"decorator","x-component":"component","x-reactions":"reactions","x-content":"content","x-visible":"visible","x-hidden":"hidden","x-disabled":"disabled","x-editable":"editable","x-read-only":"readOnly","x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(t).forEach(n=>{this.current[n]=t[n],o[n]&&this.updateModel(o[n],t[n])}),this.emit("patch",{schema:t})}updateModel(t,o){const n=l=>{Im(l,t,o)};this.model&&n(this.model),this.query&&this.query.take(n)}insertAdjacent(t,o,n={}){switch(t){case"beforeBegin":return this.insertBeforeBegin(o,n);case"afterBegin":return this.insertAfterBegin(o,n);case"beforeEnd":return this.insertBeforeEnd(o,n);case"afterEnd":return this.insertAfterEnd(o,n)}}recursiveRemoveIfNoChildren(t,o){if(!t)return;let n=t,l;const i=o==null?void 0:o.breakRemoveOn;for(;n;){if(typeof i=="function"){if(i(n))break}else if(xA(n,i))break;if(Object.keys(n.properties||{}).length>0)break;n.parent&&(l=n.parent.removeProperty(n.name)),n=n.parent}return l}remove(t,o={}){const{breakRemoveOn:n,removeParentsIfNoChildren:l}=o,i=t||this.current;let r=i.parent.removeProperty(i.name);if(l){const s=this.recursiveRemoveIfNoChildren(i.parent,{breakRemoveOn:n});s&&(r=s)}return this.emit("remove",{removed:r})}removeWithoutEmit(t,o={}){const{breakRemoveOn:n,removeParentsIfNoChildren:l}=o,i=t||this.current;let r=i.parent.removeProperty(i.name);if(l){const s=this.recursiveRemoveIfNoChildren(i.parent,{breakRemoveOn:n});s&&(r=s)}return r}insertBeforeBeginOrAfterEnd(t,o={}){if(!y.Schema.isSchemaInstance(this.current)||!y.Schema.isSchemaInstance(t)||this.current.parent!==t.parent)return;let n=0,l=0;return this.current.parent.mapProperties((i,r,s)=>{this.current.name===r&&(l=s),t.name===r&&(n=s)}),n>l?this.insertBeforeBegin(t,o):this.insertAfterEnd(t,o)}insertBeforeBegin(t,o={}){if(!y.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o.onSuccess},{wrap:l=Mc,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(y.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Xo(t));const s={};let c=!1,d=0,u=0;this.current.parent.mapProperties((x,b)=>{b===this.current.name&&(u=d,c=!0,++d),x["x-index"]=d,++d,c&&(s[b]=x,this.current.parent.removeProperty(b))}),this.prepareProperty(t);const p=l(t),h=this.current.parent.addProperty(p.name||ee.uid(),p);h["x-index"]=u,h.parent=this.current.parent,this.current.parent.setProperties(s);const[g,v]=hr(h,t);this.emit("insertAdjacent",f({position:"beforeBegin",schema:v,wrapped:p,wrap:g},n))}insertAfterBegin(t,o={}){if(!y.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o.onSuccess},{wrap:l=Mc,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(y.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Xo(t));const s={};let c=1;this.current.mapProperties((g,v)=>{g["x-index"]=c,++c,s[v]=g}),this.current.properties={},this.prepareProperty(t);const d=l(t),u=this.current.addProperty(d.name||ee.uid(),d);u["x-index"]=0,u.parent=this.current,this.current.setProperties(s);const[p,h]=hr(u,t);this.emit("insertAdjacent",f({position:"afterBegin",schema:h,wrap:p,wrapped:d},n))}insertBeforeEnd(t,o={}){if(!y.Schema.isSchemaInstance(this.current))return;delete t["x-index"];const n={onSuccess:o.onSuccess},{wrap:l=Mc,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;if(y.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i}))}else t&&(t=Xo(t));this.prepareProperty(t);const s=l(t),c=this.current.addProperty(s.name||ee.uid(),s);c.parent=this.current;const[d,u]=hr(c,t);return this.emit("insertAdjacent",f({position:"beforeEnd",schema:u,wrap:d,wrapped:s},n))}insertAfterEnd(t,o={}){if(!y.Schema.isSchemaInstance(this.current))return;const n={onSuccess:o==null?void 0:o.onSuccess},{wrap:l=Mc,breakRemoveOn:i,removeParentsIfNoChildren:r}=o;let s=0,c=0,d=!1;const u={};if(this.current.parent.mapProperties((x,b)=>{x["x-index"]=s,b===this.current.name&&(++s,c=s,d=!0),++s,d&&b!==this.current.name&&(u[b]=x,this.current.parent.removeProperty(b))}),y.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),r&&(n.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:i})),t.parent=null}else t&&(t=Xo(t));this.prepareProperty(t);const p=l(t),h=this.current.parent.addProperty(p.name||ee.uid(),p);h.parent=this.current.parent,h["x-index"]=c,this.current.parent.setProperties(u);const[g,v]=hr(h,t);this.emit("insertAdjacent",f({position:"afterEnd",schema:v,wrap:g,wrapped:p},n))}}function eu(){const e=m.useContext(y.SchemaOptionsContext),t=m.useMemo(()=>(e==null?void 0:e.components)||{},[e]);return o=>{if(!o)return null;if(typeof o!="string")return o;const n=gi(t,o);return n||console.error(`[nocobase]: Component "${o}" not found`),n}}function X(){const{designable:e,setDesignable:t,refresh:o,reset:n}=m.useContext(Pt),l=m.useContext(y.SchemaOptionsContext),i=m.useMemo(()=>(l==null?void 0:l.components)||{},[l]),r=m.useMemo(()=>()=>a.jsx(a.Fragment,{}),[]),s=Ct.useUpdate(),c=Ji(),d=Vs(),u=m.useCallback(S=>{o==null||o(),s(),c==null||c(S),d==null||d()},[o,s,c,d]),p=y.useField(),h=y.useFieldSchema(),g=Te(),{t:v}=K.useTranslation(),x=m.useMemo(()=>en({t:v,api:g,refresh:u,current:h,model:p,appVersion:vA.version}),[v,g,u,h,p]);m.useEffect(()=>{x.loadAPIClientEvents()},[x]);const{isMobileLayout:b}=to();return{dn:x,designable:b?!1:e,reset:n,refresh:u,setDesignable:t,DesignableBar:r,findComponent:m.useCallback(S=>{var C;if(!S)return null;if(typeof S!="string")return S;const k=gi(i,S);return(C=k==null?void 0:k[Lm])!=null?C:k},[gi]),on:x.on.bind(x),patch:m.useCallback((S,C)=>{const k=F=>{Object.keys(F).forEach(j=>{const P=F[j];j==="title"&&(p.title=P,h.title=P),j==="x-decorator-props"&&(p.decoratorProps||(p.decoratorProps={}),h["x-decorator-props"]||(h["x-decorator-props"]={}),Object.keys(P).forEach(M=>{p.decoratorProps[M]=P[M],h["x-decorator-props"][M]=P[M]})),j==="x-component-props"&&(p.componentProps||(p.componentProps={}),h["x-component-props"]||(h["x-component-props"]={}),Object.keys(P).forEach(M=>{p.componentProps[M]=P[M],h["x-component-props"][M]=P[M]}))})};if(typeof S=="string"){const F={};return Im(F,S,C),k(F)}k(S),u()},[x]),shallowMerge:m.useCallback(S=>{x.shallowMerge(S)},[x]),deepMerge:m.useCallback(S=>{x.deepMerge(S)},[x]),remove:m.useCallback((S,C)=>{x.remove(S,C)},[x]),insertAdjacent:m.useCallback((S,C,k)=>{x.insertAdjacent(S,C,k)},[x]),insertBeforeBegin:m.useCallback(S=>{x.insertBeforeBegin(S)},[x]),insertAfterBegin:m.useCallback(S=>{x.insertAfterBegin(S)},[x]),insertBeforeEnd:m.useCallback(S=>{x.insertBeforeEnd(S)},[x]),insertAfterEnd:m.useCallback(S=>{x.insertAfterEnd(S)},[x])}}const Vm=()=>null;Vm.isNullComponent=!0;const Wo=()=>{const{designable:e}=X(),t=y.useFieldSchema(),o=m.useMemo(()=>t["x-designer"]||t["x-toolbar"]?t["x-designer"]||t["x-toolbar"]:t["x-settings"]?dn:Vm,[t]),n=jo(o);return e&&n||Vm},U0=e=>{const t=m.useContext(y.SchemaOptionsContext),o=m.useContext(y.SchemaExpressionScopeContext),n=m.useRef();return n.current=o,e.toFieldProps(T(f({},t),{get scope(){return f(f({},t.scope),n.current)}}))};function Ni(){return m.useContext(Pt)}const eg=()=>{var e;const{getCollectionJoinField:t,getCollection:o}=ie(),n=y.useFieldSchema(),{getField:l}=re(),i=l(n.name)||t(n["x-collection-field"]),{t:r}=K.useTranslation(),{label:s}=((e=n["x-component-props"])==null?void 0:e.fieldNames)||{};return m.useMemo(()=>{if(!i||!(i!=null&&i.interface)||!["o2o","oho","obo","o2m","linkTo","m2o","m2m"].includes(i.interface))return;const c=o(i.target);if((c==null?void 0:c.template)==="file")return[{label:r("Record picker"),value:"CollectionField"},{label:r("Select"),value:"AssociationSelect"}];switch(i.interface){case"o2m":return[{label:r("Record picker"),value:"CollectionField"},{label:r("Subtable"),value:"TableField"},{label:r("Select"),value:"AssociationSelect"}];case"m2o":case"m2m":case"linkTo":return[{label:r("Record picker"),value:"CollectionField"},{label:r("Select"),value:"AssociationSelect"}];default:return[{label:r("Record picker"),value:"CollectionField"},{label:r("Subform"),value:"FormField"},{label:r("Select"),value:"AssociationSelect"}]}},[r,i==null?void 0:i.interface,s])},tu=()=>{var e;const t=y.useField(),o=y.useFieldSchema(),n=ve(),l=Ye(),i=(n==null?void 0:n.getField(o.name))||(l==null?void 0:l.getCollectionField(o["x-collection-field"])),r=se();m.useEffect(()=>{var s;t!=null&&t.title||(t.title=r((s=i==null?void 0:i.uiSchema)==null?void 0:s.title))},[(e=i==null?void 0:i.uiSchema)==null?void 0:e.title])},sb=()=>({}),Yt=(e={})=>{const t=e,{useProps:o=sb}=t,n=ne(t,["useProps"]);let l=o;typeof o!="function"&&(l=sb);const i=l();return f(f({},n),i)};function zl({filterOption:e,onFilterChange:t}){const{parseFilter:o,findVariable:n}=z$(),[l,i]=m.useState({}),[r,s]=m.useState(!!e);return m.useEffect(()=>{if(!e)return;const c=()=>O(this,null,function*(){s(!0);const u=yield o(e);s(!1),i(u),t==null||t(u)});c();const d=L.debounce(c,M0);ut.reaction(()=>de.flatten(e,{breakOn({key:u}){return u.startsWith("$")&&u!=="$and"&&u!=="$or"},transformValue(u){if(!dt(u))return u;const p=Gd(u),h=n(p);let g=null;const v=Hd(u).split(".");return v.forEach((x,b)=>{const S=v.slice(0,b+1).join("."),C=de.getValuesByPath({[p]:(h==null?void 0:h.ctx)||{}},S);L.isEmpty(C)||(g=C)}),g}}),d,{equals:L.isEqual})},[JSON.stringify(e),o,n]),{filter:l,parseVariableLoading:r}}const as=e=>{const t=Dt();if(e)return t},bA=e=>{var t;const{params:o,parseVariableLoading:n}=H0(e),l=as(e.association),i=(t=wt().getDataSource(e.dataSource))==null?void 0:t.collectionManager.getCollection(e.collection);return{params:o,parentRecord:l,parseVariableLoading:n,rowKey:(i==null?void 0:i.filterTargetKey)||"id"}};function H0(e){var t;const o=y.useFieldSchema(),{filter:n,parseVariableLoading:l}=zl({filterOption:(t=e.params)==null?void 0:t.filter});return{params:m.useMemo(()=>{const i=e.params||{},{dragSortBy:r}=(o==null?void 0:o["x-decorator-props"])||{};return e.dragSort&&r&&(i.sort=r),T(f({},i),{filter:n})},[o,n,e.dragSort,e.params]),parseVariableLoading:l}}const G0="__isNewRecord__",tg=e=>ut.untracked(()=>!!(e!=null&&e[G0])),ol=e=>{if(!L.isObject(e))throw new Error("markRecordAsNew: record must be an object");return e[G0]=!0,e},yA=()=>{var e;return!!((e=Un())!=null&&e.loading)},ss=(e,t)=>{const{useLoading:o=yA,displayName:n,SkeletonComponent:l=I.Skeleton}=t||{},i=m.memo(r=>{const s=o(),c=m.useRef(!1),d=m.useDeferredValue(s);return!c.current&&d?a.jsx(l,{}):(c.current=!0,a.jsx(e,f({},r)))});return i.displayName=n||`${e.displayName}(withSkeletonComponent)`||`${e.name}(withSkeletonComponent)`,i},SA=(e,t)=>{const o=n=>(n==null?void 0:n.mode)==="constant"?n.value:null;switch(!0){case[he.Color,he.BackgroundColor,he.TextAlign,he.FontSize,he.FontWeight,he.FontStyle].includes(e):return o(t);default:return null}},CA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield Promise.all(o.filter(r=>!r.disabled).map(r=>O(void 0,null,function*(){return(yield Co({ruleGroup:r.condition,variables:n,localVariables:l,conditionType:r.conditionType},i))?r:null})))).filter(Boolean).map(r=>r.actions).flat()}),FA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield CA({rules:o,variables:n,localVariables:l},i)).map(r=>T(f({},r),{value:SA(r.operator,r.value)}))}),kA=(e,t)=>O(void 0,[e,t],function*({rules:o,variables:n,localVariables:l},i){return(yield FA({rules:o,variables:n,localVariables:l},i)).reduce((r,s)=>T(f({},r),{[s.operator]:s.value}),{})});function og({formValues:e,category:t="default",rules:o,schema:n,form:l}){const[i,r]=m.useState({}),s=y.useFieldSchema(),c=st(),d=gt({currentForm:{values:e}}),u=n??s,p=o??(u[td[t]]||(u==null?void 0:u.parent[td[t]])),h=ot(),g=m.useCallback(()=>{p&&e&&kA({rules:p,variables:c,localVariables:d},h.jsonLogic).then(v=>{L.isEmpty(v)?r({}):r(v)}).catch(v=>{throw new Error(v.message)})},[c,d,p,e]);return m.useEffect(()=>{if(g(),l){const v=ee.uid();return l.addEffects(v,()=>{Oe.onFormValuesChange(()=>{g()})}),()=>{l.removeEffects(v)}}},[l,g,e]),{valueMap:i}}const W0=m.memo(({record:e,schema:t,onStyleChange:o})=>{const{valueMap:n}=og({formValues:e,category:"style",schema:t});return m.useEffect(()=>{o(n)},[o,n]),null});W0.displayName="GetStyleRules";const wA={opacity:.5},PA={position:"relative"},jA={display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",left:0,right:0,height:"100%",maxHeight:400,zIndex:1e3},IA={display:"none"},ng=m.memo(e=>a.jsxs("div",{style:PA,children:[a.jsx(I.Spin,T(f({},L.omit(e,"children")),{style:e.spinning?jA:IA})),a.jsx("div",{style:e.spinning?wA:null,children:e.children})]}));ng.displayName="HighPerformanceSpin";var Kr=(e=>(e[e.FORM=0]="FORM",e[e.TABLE=1]="TABLE",e[e.TREE=2]="TREE",e[e.COLLAPSE=3]="COLLAPSE",e))(Kr||{});const Zt=(e,t="$and")=>{const o=e.filter(n=>{if(n&&typeof n=="object"&&!Array.isArray(n))return Object.values(n).filter(l=>l!==void 0).length});return o.length===0?{}:o.length===1?o[0]:{[t]:o}},Y0=(e,t)=>{var o;return(o=t.associatedFields)==null?void 0:o.filter(n=>e==null?void 0:e.some(l=>l===n.target))},J0=(e,t)=>{var o;return(o=t.foreignKeyFields)==null?void 0:o.filter(n=>e.fields.some(l=>l.type!=="belongsTo"&&l.foreignKey===n.name&&l.target===n.collectionName))},TA=e=>{const{getDataBlocks:t}=Jl(),o=y.useFieldSchema(),n=ve(),{getAllCollectionsInheritChain:l}=e0();if(e===0||e===3)return t().filter(i=>zm(i.collection,n));if(e===1||e===2)return t().filter(i=>{var r,s;return o["x-uid"]!==i.uid&&(zm(i.collection,n)||((r=Y0(l(n.name,n.dataSource),i))==null?void 0:r.length)||((s=J0(n,i))==null?void 0:s.length))})},MA=(e,t,o,n)=>(e=de.flatten(e,{breakOn({value:l,path:i}){if(["$match","$notMatch","$anyOf","$noneOf","$childIn","$childNotIn","$dateBetween","$in","$notIn"].includes(t[i]))return!0;const r=o(`${n}.${i}`);if(["datetime","datetimeNoTz","date","unixTimestamp","createdAt","updatedAt"].includes(r==null?void 0:r.interface))return!0;if(r!=null&&r.target){if(Array.isArray(l))return!0;const s=r.targetKey||"id";if(l&&l[s]!=null)return!0}return!1}}),{$and:Object.keys(e).map(l=>{let i=L.get(e,l);const r=o(`${n}.${l}`);return r!=null&&r.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(r.type)&&(i=de.getValuesByPath(i,r.targetKey||"id"),l=`${l}.${r.targetKey||"id"}`,(r==null?void 0:r.interface)==="chinaRegion"&&(i=L.last(i))),!i&&i!==0&&i!==!1?null:{[l]:{[t[l]||"$eq"]:i}}}).filter(Boolean)}),lg=()=>{var e;return((e=ve())==null?void 0:e.fields.filter(t=>X0(t)))||[]},X0=e=>["o2o","oho","obo","m2o","createdBy","updatedBy","o2m","m2m","linkTo","chinaRegion","mbm"].includes(e==null?void 0:e.interface),zm=(e,t)=>e.name===t.name&&e.dataSource===t.dataSource,Cr=e=>{for(;e;){if(e["x-filter-targets"])return e["x-decorator"]==="FilterFormBlockProvider";e=e.parent}return!1},ou=m.createContext({});ou.displayName="AssociationFieldContext";const rl=e=>{const t=y.useFieldSchema(),{insertAfterBegin:o}=X(),{isMobileLayout:n}=to();return m.useCallback(l=>{n||t.reduceProperties((i,r)=>r["x-component"]==="AssociationField."+e?r:i,null)||o(Xo(l))},[e,t,o,n])};function Tt(){return m.useContext(ou)}function ig(e){var t,o,n,l,i,r,s,c,d,u;const{action:p="list",service:h,useOriginalFilter:g}=e,v=y.useFieldSchema(),x=y.useField(),{getField:b}=re(),{getCollectionJoinField:S}=ie(),C=$e(),{isNew:k}=fo()||{},F=(L.isString((n=(o=(t=v==null?void 0:v["x-component-props"])==null?void 0:t.service)==null?void 0:o.params)==null?void 0:n.filter)?(r=(i=(l=x.componentProps)==null?void 0:l.service)==null?void 0:i.params)==null?void 0:r.filter:(d=(c=(s=v==null?void 0:v["x-component-props"])==null?void 0:s.service)==null?void 0:c.params)==null?void 0:d.filter)||((u=h==null?void 0:h.params)==null?void 0:u.filter),{filter:j}=zl({filterOption:F,onFilterChange:()=>{k&&x.reset()}}),P=m.useMemo(()=>b(v.name)||S(v==null?void 0:v["x-collection-field"]),[v]),M=C==null?void 0:C[P==null?void 0:P.sourceKey],R=m.useMemo(()=>{const N=["oho","o2m"].includes(P==null?void 0:P.interface);return Zt([Zt([N&&!Cr(v)&&P!=null&&P.foreignKey&&!g?{[P.foreignKey]:{$is:null}}:null,j]),N&&M!==void 0&&M!==null&&!Cr(v)&&P!=null&&P.foreignKey&&!g?{[P.foreignKey]:{$eq:M}}:null],"$or")},[P==null?void 0:P.interface,P==null?void 0:P.foreignKey,v,j,M,g]);return m.useMemo(()=>T(f({resource:P==null?void 0:P.target,action:p},h),{params:T(f({},h==null?void 0:h.params),{filter:R})}),[P==null?void 0:P.target,p,R,h])}const Ur=(e={})=>{var t,o,n,l,i;const r=y.useFieldSchema(),s=((l=(n=(o=(t=r["x-component-props"])==null?void 0:t.field)==null?void 0:o.uiSchema)==null?void 0:n["x-component-props"])==null?void 0:l.fieldNames)||((i=r["x-component-props"])==null?void 0:i.fieldNames)||e.fieldNames;return f({label:"label",value:"value"},s)},nd=m.createContext(null);nd.displayName="SubFormContext";const Di=e=>{const t=m.useContext(nd),{value:o,collection:n,fieldSchema:l,parent:i,skip:r}=e.value,s=m.useMemo(()=>L.omitBy({value:o,collection:n,fieldSchema:l,skip:r,parent:i||(t!=null&&t.skip?t.parent:t)},L.isUndefined),[o,n,l,r,i,t]);return a.jsx(nd.Provider,{value:s,children:e.children})},Hr=()=>{const{value:e,collection:t,fieldSchema:o,parent:n}=m.useContext(nd)||{};return{formValue:e,collection:t,fieldSchema:o,parent:n}},cs=e=>{const{t}=K.useTranslation(),o=`nocobase_table_column_settings_${e}`,n=m.useCallback(()=>{try{const r=localStorage.getItem(o);return r?JSON.parse(r):null}catch(r){return console.warn("Failed to parse table column settings from localStorage:",r),null}},[o]),l=m.useCallback(r=>{try{const s=JSON.stringify(r);localStorage.setItem(o,s);const c=new CustomEvent("nocobase-table-settings-changed",{detail:{key:o,tableId:e,settings:r}});window.dispatchEvent(c)}catch(s){console.warn("Failed to save table column settings to localStorage:",s),I.message.error(t("Failed to save table settings"))}},[o,e,t]),i=m.useCallback(()=>{try{localStorage.removeItem(o);const r=new CustomEvent("nocobase-table-settings-changed",{detail:{key:o,tableId:e,settings:null}});window.dispatchEvent(r)}catch(r){console.warn("Failed to clear table column settings from localStorage:",r),I.message.error(t("Failed to clear table settings"))}},[o,e,t]);return{getSettings:n,saveSettings:l,clearSettings:i}},nu=(e,t=!0)=>{const o=y.useFieldSchema(),n=(o==null?void 0:o["x-uid"])||"default",{getSettings:l}=cs(n),[i,r]=m.useState(0);m.useEffect(()=>{const c=d=>{const{key:u,tableId:p}=d.detail;(u.includes(n)||p===n)&&r(h=>h+1)};return window.addEventListener("nocobase-table-settings-changed",c),()=>{window.removeEventListener("nocobase-table-settings-changed",c)}},[n]);const s=m.useMemo(()=>l(),[l,i]);return{columns:m.useMemo(()=>{if(!t||!s||s.length===0)return e;const c=new Map;s.forEach(g=>{c.set(g.key,g)});const d=e.map(g=>{const v=c.get(g.key);if(v){const x=g.columnHidden||!v.visible,b=v.width||g.width,S=v.fixed||g.fixed;return T(f({},g),{columnHidden:x,fixed:S,width:b,_orderIndex:v.order})}return g}),u=[],p=[];d.forEach(g=>{g._orderIndex!==void 0?u.push(g):p.push(g)}),u.sort((g,v)=>(g._orderIndex||0)-(v._orderIndex||0));const h=[...u,...p];return h.forEach(g=>{delete g._orderIndex}),h},[e,s])}},AA=({rows:e=5,columns:t=6})=>{const{token:o}=mt(),n=o.controlHeight*2.06,l=o.controlHeight*1.75,i=m.useMemo(()=>Z.css`
|
|
65
65
|
&.skeleton-wrapper {
|
|
66
66
|
width: 100%;
|
|
67
67
|
background: ${o.colorBgContainer};
|
|
@@ -622,7 +622,7 @@ ${JSON.stringify(H,null,2)}`)},[d,c,s,l,n,M,t,r,i,v,o,x,k,R,F,j,g]),D=m.useCallb
|
|
|
622
622
|
display: ${k?"block":"none"};
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
-
`),footer:k?a.jsx(Ve,{basePath:g.address,schema:h,onlyRenderProperties:!0,filterProperties:P=>P["x-component"]===o}):!1,children:j?a.jsx(sB,{footerNodeName:o,field:g,schema:h}):a.jsx(I.Skeleton,{active:!0,paragraph:{rows:6}})}))}))})})},{displayName:"ActionModal"}),uv=e=>a.jsx(Uo.ErrorBoundary,{FallbackComponent:rB,onError:console.log,children:a.jsx(dB,f({},e))});uv.Footer=y.observer(()=>{const e=y.useField(),t=y.useFieldSchema();return a.jsx(Ve,{basePath:e.address,schema:t,onlyRenderProperties:!0})},{displayName:"ActionModal.Footer"});uv.FootBar=y.observer(()=>{const e=y.useField(),t=y.useFieldSchema();return a.jsx("div",{className:"ant-modal-footer",children:a.jsx(Ve,{basePath:e.address,schema:t,onlyRenderProperties:!0})})},{displayName:"ActionModal.FootBar"});const yu=()=>{const{setVisible:e}=ke();return{goBack:m.useCallback(()=>{e==null||e(!1)},[e])}},Su=()=>{const{token:e}=It(),{goBack:t}=yu(),o=32,n=m.useMemo(()=>({width:"auto",height:"auto",lineHeight:1,padding:e.paddingXS,marginRight:o-e.paddingXS}),[e.paddingXS]);return a.jsx(I.Button,{"aria-label":"back-button",type:"text",icon:a.jsx(te.ArrowLeftOutlined,{}),style:n,onClick:t})},uB=Nt("nb-action-page",e=>{const{componentCls:t}=e;return{[t]:{position:"absolute !important",top:0,left:0,right:0,bottom:0,backgroundColor:e.colorBgLayout,overflowX:"hidden",overflowY:"auto",".ant-tabs-nav":{background:e.colorBgContainer,padding:`0 ${e.paddingPageVertical}px`,marginBottom:0},".ant-tabs-content-holder":{padding:`${e.paddingPageVertical}px`,paddingBottom:"0px"}}}}),pB=()=>{const e=m.useMemo(()=>document.querySelector(".nb-subpages-slot-without-header-and-side"),[]);return{getContainerDOM:m.useCallback(()=>e,[e])}},mB=m.memo(({schema:e})=>{const[t,o]=m.useState(!1);return m.useEffect(()=>{m.startTransition(()=>{o(!0)})},[]),t?a.jsx(Ve,{schema:e,onlyRenderProperties:!0}):null});function IF({level:e}){const t=y.useFieldSchema(),o=ke(),{getContainerDOM:n}=pB(),{componentCls:l,hashId:i}=uB(),r=Gi(),s=_n(),c=m.useMemo(()=>({zIndex:fl("page",s,e||0)}),[s,e]);if(!o.visible)return null;const d=a.jsx("div",{className:`${l} ${i}`,style:c,children:a.jsx($i,{children:a.jsx(Sl,T(f({},r),{tabBarExtraContent:a.jsx(Su,{}),children:a.jsx(To.Provider,{value:c.zIndex,children:a.jsx(mB,{schema:t})})}))})}),u=n();return nn.createPortal(d,u||document.body)}IF.Footer=y.observer(()=>null,{displayName:"ActionPage.Footer"});const hB=m.createContext(null),Lt=()=>m.useContext(hB),Mt=m.memo(m.forwardRef((e,t)=>{const{style:o,closeInitializerMenuWhenClick:n=!0,name:l=ee.uid(),applyMenuStyle:i=!0,className:r,disabled:s,items:c,icon:d,title:u,onClick:p,children:h}=e,g=se(),v=SB(c,l,p),{componentCls:x,hashId:b}=Yh(),{attribute:S}=JM(),{setVisible:C}=nt(),k=m.useMemo(()=>{if(c&&c.length>0)return[{key:l,style:o,className:r,label:h||g(u),onClick:F=>{s||F.key!==l||(n&&(C==null||C(!1)),p==null||p(T(f({},F),{item:e})))},icon:typeof d=="string"?a.jsx(ct,{type:d}):d,children:v}]},[l,s,o,r,h,u,p,d,v]);return c&&c.length>0?a.jsx(L0,{disabled:s,items:k}):a.jsx("div",{ref:t,onClick:F=>{F.stopPropagation(),n&&(C==null||C(!1)),p==null||p({event:F,item:e})},children:a.jsx("div",T(f({},S),{className:fe({[`${x}-menu-item`]:i,[`${x}-menu-item-disabled`]:s},r),style:o,children:h||a.jsxs(a.Fragment,{children:[typeof d=="string"?a.jsx(ct,{type:d}):d,a.jsx("span",{className:fe({[`${b} ${x}-item-content`]:!!d}),children:g(u)})]})}))})}));Mt.displayName="SchemaInitializerItem";const gB={marginLeft:20},vB={display:"flex",alignItems:"center",justifyContent:"space-between"},TF=e=>{const t=e,{title:o,checked:n}=t,l=ne(t,["title","checked"]),i=se();return a.jsx(Mt,T(f({},l),{closeInitializerMenuWhenClick:!1,children:a.jsxs("div",{style:vB,children:[i(o),a.jsx(I.Switch,{disabled:e.disabled,style:gB,size:"small",checked:n})]})}))},Kn=e=>{const{children:t}=e;return t?a.jsx(a.Fragment,{children:t.sort((o,n)=>(o.sort||0)-(n.sort||0)).map((o,n)=>a.jsx(pv,f({},o),o.name||o.key||n))}):null},Vb={item:"SchemaInitializerItemInternal",itemGroup:"SchemaInitializerItemGroupInternal",divider:"SchemaInitializerDivider",switch:"SchemaInitializerSwitchInternal",subMenu:"SchemaInitializerSubMenuInternal",actionModal:"SchemaInitializerActionModalInternal"},xB=()=>{},fB=()=>!0,bB=()=>{},pv=m.memo(e=>{const t=e,{type:o,Component:n,component:l,children:i,useVisible:r=fB,useChildren:s=xB,useComponentProps:c=bB,hideIfNoChildren:d,componentProps:u,sort:p}=t,h=ne(t,["type","Component","component","children","useVisible","useChildren","useComponentProps","hideIfNoChildren","componentProps","sort"]),g=s(),v=c(),x=eu(),b=n||l,S=!b&&o&&Vb[o],C=m.useMemo(()=>{const j=[...g||[],...i||[]];return j.length===0?void 0:j},[g,i]),k=m.useMemo(()=>T(f(f(f({},h),S?v:{}),S?u:{}),{children:C}),[h,S,v,u,C]);if(!r()||!o&&!b)return null;const F=x(S?Vb[o]:b);return!F||d&&!C?null:a.jsx(Xh.Provider,{value:k,children:a.jsx(F,T(f(f({},u),v),{children:C}))})});pv.displayName="SchemaInitializerChild";const yB=e=>{const{items:t}=e;return t.length===0?null:a.jsx(Kn,{children:t})};m.forwardRef((e,t)=>{const o=e,{onClick:n}=o,l=ne(o,["onClick"]);return a.jsx(Mt,T(f({ref:t},l),{onClick:i=>n==null?void 0:n(i.event,!1)}))});const mv=()=>{const e=y.useFieldSchema(),{name:t}=ve()||{};return{getAriaLabel:m.useCallback(o=>{if(!e)return"";const n=e["x-component"],l=typeof n=="string"?n:(n==null?void 0:n.displayName)||n.name,i=e["x-initializer"]?`-${e["x-initializer"]}`:"",r=t?`-${t}`:"";return o=o?`-${o}`:"",`schema-initializer-${l}${i}${r}${o}`},[e,t])}},MF=m.memo(e=>{const t=e,{style:o,options:n}=t,l=ne(t,["style","options"]),i=se(),{getAriaLabel:r}=mv();return a.jsx(I.Button,T(f({"data-testid":n["data-testid"],"aria-label":r(),"aria-disabled":"false",type:"dashed",style:f({borderColor:"var(--colorSettings)",color:"var(--colorSettings)",flex:"none"},o),icon:typeof n.icon=="string"?a.jsx(ct,{type:n.icon}):n.icon},l),{children:n.title&&a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"inline-block",width:n.icon?"calc(100% - 14px)":"100%",verticalAlign:"bottom"},children:i(n.title)})}))});MF.displayName="SchemaInitializerButton(memo)";const AF=e=>{const t=e.Component||MF,o=e.ItemsComponent||yB,n=T(f({},e.itemsComponentProps),{options:e,items:e.items,style:e.itemsComponentStyle}),l=m.useMemo(()=>GM(t),[t]);return m.createElement(l,e,m.createElement(o,n))};AF.displayName="InitializerComponent";function pn(e,t){const o=ot(),{isMobile:n}=Lt()||{};e==="popup:common:addBlock"&&o.schemaInitializerManager.has("mobile:popup:common:addBlock")&&n&&(e="mobile:popup:common:addBlock");const l=m.useMemo(()=>typeof e=="object"?e:o.schemaInitializerManager.get(e),[o.schemaInitializerManager,e]);return m.useMemo(()=>e?l?{exists:!0,render:i=>m.createElement(AF,f(f(f({},l.options),t),i))}:(console.error(`[nocobase]: SchemaInitializer "${e}" not found`),{exists:!1,render:()=>null}):{exists:!1,render:()=>null},[l,e,t])}function SB(e,t,o){const n=RF(o);return m.useMemo(()=>n(e,t),[n,e,t])}function RF(e){const t=se(),o=m.useCallback((n,l)=>n!=null&&n.length?n.map((i,r)=>{var s,c;const d=i.component||i.Component;let u;const p=i.title||i.label?t(i.title||i.label):void 0;if(d&&(u=m.createElement(pv,T(f({},i),{title:p}))),i.type==="divider")return{type:"divider",key:i.key||`divider-${r}`};if(i.type==="item"&&d)return i.key||(i.key=`${p}-${r}`),i.associationField?{key:i.key,label:u,associationField:i.associationField}:{key:i.key,label:u};if(i.type==="itemGroup"){const x=typeof p=="string"?p:i.title,b=i.key||`${l}-item-group-${r}`;return{type:"group",key:b,label:x,children:(s=i==null?void 0:i.children)!=null&&s.length?o(i.children,b):[]}}if(i.type==="subMenu"){const x=p,b=i.key||i.name||`${l}-sub-menu-${r}`;return{key:b,label:x,children:(c=i==null?void 0:i.children)!=null&&c.length?o(i.children,b):[]}}if(i.isMenuType)return ne(i,["isMenuType"]);const h=u||p,g=i.key||`${l}-${p}-${r}`,v=x=>{x.domEvent.stopPropagation(),x.key===g&&(i.onClick?i.onClick(T(f({},x),{item:i})):e==null||e(T(f({},x),{item:i})))};return i.associationField?{key:g,label:h,associationField:i.associationField,onClick:v}:{style:i.style,key:g,label:h,onClick:v}}):[],[t,e]);return o}class Le extends kn{constructor(t,o){super(t),A(this,"otherInstance",null),o&&(this.otherInstance=o,o.otherInstance=this)}add(t,o){super.get(t)||(super.add(t,o),this.otherInstance&&this.otherInstance.add(t,o))}remove(t){super.get(t)&&(super.remove(t),this.otherInstance&&this.otherInstance.remove(t))}}const CB={BlockInitializers:"page:addBlock",MBlockInitializers:"mobilePage:addBlock",CreateFormBlockInitializers:"popup:addNew:addBlock",CusomeizeCreateFormBlockInitializers:"popup:addRecord:addBlock",RecordBlockInitializers:"popup:common:addBlock",BulkEditBlockInitializers:"popup:bulkEdit:addBlock",TableColumnInitializers:"table:configureColumns",TableActionColumnInitializers:"table:configureItemActions",TableActionInitializers:"table:configureActions",SubTableActionInitializers:"subTable:configureActions",FormItemInitializers:"form:configureFields",CreateFormActionInitializers:"createForm:configureActions",UpdateFormActionInitializers:"editForm:configureActions",ReadPrettyFormItemInitializers:"details:configureFields",DetailsActionInitializers:"detailsWithPaging:configureActions",ReadPrettyFormActionInitializers:"details:configureActions",KanbanCardInitializers:"kanban:configureItemFields",KanbanActionInitializers:"kanban:configureActions",GridCardActionInitializers:"gridCard:configureActions",GridCardItemActionInitializers:"gridCard:configureItemActions",ListActionInitializers:"list:configureActions",ListItemActionInitializers:"list:configureItemActions",CalendarActionInitializers:"calendar:configureActions",GanttActionInitializers:"gantt:configureActions",MapActionInitializers:"map:configureActions",TableSelectorInitializers:"popup:tableSelector:addBlock",ChartInitializers:"charts:addBlock",ChartFilterItemInitializers:"chartFilterForm:configureFields",ChartFilterActionInitializers:"chartFilterForm:configureActions",AssociationFilterInitializers:"filterCollapse:configureFields",FilterFormItemInitializers:"filterForm:configureFields",FilterFormActionInitializers:"filterForm:configureActions",CustomFormItemInitializers:"assignFieldValuesForm:configureFields",BulkEditFormItemInitializers:"bulkEditForm:configureFields",BulkEditFormActionInitializers:"bulkEditForm:configureActions",AuditLogsTableColumnInitializers:"auditLogsTable:configureColumns",AuditLogsTableActionColumnInitializers:"auditLogsTable:configureItemActions",AuditLogsTableActionInitializers:"auditLogsTable:configureActions",SnapshotBlockInitializers:"popup:snapshot:addBlock",AddBlockButton:"workflowManual:popup:configureUserInterface:addBlock",AddCustomFormField:"workflowManual:customForm:configureFields",AddActionButton:"workflowManual:form:configureActions"};function NF(e,t){return e===t||CB[e]===t}const Dc=(e,t,o)=>{ut.untracked(()=>{e[t]===void 0&&(e[t]=o)})},FB=(e,t,o)=>{typeof t.required>"u"&&(e.required=!!o.required)},kB=e=>{var t;const o=se(),n=y.useField(),l=y.useFieldSchema(),{uiSchema:i,defaultValue:r}=_t(),{isAllowToSetDefaultValue:s}=Qr(),c=jo(((t=l["x-component-props"])==null?void 0:t.component)||(i==null?void 0:i["x-component"])||"Input"),d=je(),u=qd(i==null?void 0:i["x-use-component-props"],e);return m.useEffect(()=>{if(!i)return;const p=o(i);if(Dc(n,"content",p["x-content"]),Dc(n,"title",p.title),Dc(n,"description",p.description),d!=null&&d.form){const g=s()?l.default||r:void 0;g!=null&&Dc(n,"initialValue",g)}if(!n.validator&&(p["x-validator"]||l["x-validator"])){const g=L.concat([],p["x-validator"]||[],l["x-validator"]||[]);n.validator=g}l["x-disabled"]===!0&&(n.disabled=!0),l["x-read-pretty"]===!0&&(n.readPretty=!0),FB(n,l,p),n.dataSource=p.enum,n.data=n.data||{},n.data.dataSource=p==null?void 0:p.enum;const h=o(p["x-component-props"])||{};n.componentProps=ee.merge(h,n.componentProps||{},u||{})},[i]),i?a.jsx(c,f(f({},e),u)):null},wB=e=>{var t;const o=y.useField(),n=y.useFieldSchema(),{uiSchema:l}=yk(),i=jo(((t=n["x-component-props"])==null?void 0:t.component)||(l==null?void 0:l["x-component"])||"Input"),r=qd(l==null?void 0:l["x-use-component-props"],e);if(m.useEffect(()=>{n["x-read-pretty"]===!0&&!o.readPretty&&(o.readPretty=!0),n["x-disabled"]===!0&&(o.disabled=!0),o.data=o.data||{},o.data.dataSource=l==null?void 0:l.enum},[o,n]),!l)return null;const s=f(f({},e),r);return dt(s.value)&&s.value===n.default&&(s.value=void 0),a.jsx(i,f({},s))},DF=y.connect(e=>{const t=y.useFieldSchema(),o=cV();return a.jsx(ac,{name:t.name,children:o?a.jsx(wB,f({},e)):a.jsx(kB,f({},e))})});DF.displayName="CollectionField";function PB(e){const{fieldSchema:t,schemaKey:o,parentSchemaKey:n,value:l,valueKeys:i}=e;if(o)L.set(t,o,l);else if(n){if(l==null)return t;typeof l=="object"?Object.keys(l).forEach(r=>{i&&!i.includes(r)||L.set(t,`${n}.${r}`,l[r])}):console.error("value must be object")}return t}const jB=e=>e,IB=(e="common")=>{const t=y.useFieldSchema(),{fieldSchema:o}=Fe()||{};return e==="field"&&o||t};function TB(e){const{name:t,useVisible:o,schemaKey:n,title:l,type:i="common",defaultValue:r,useDefaultValue:s=jB,useComponentProps:c}=e;return{name:t,useVisible:o,type:"switch",useComponentProps(){const d=IB(i),{dn:u}=X(),p=s(r),h=se(),{t:g}=K.useTranslation(),{fieldSchema:v}=Fe()||{},x=c==null?void 0:c();return{title:typeof l=="function"?l(g):h(l),checked:(x==null?void 0:x.checked)===void 0?!!L.get(d,n,p):x==null?void 0:x.checked,onChange(b){var S;(S=x==null?void 0:x.onChange)==null||S.call(x,b);const C=PB({fieldSchema:d,schemaKey:n,value:b});v?(u.emit("patch",{schema:C}),u.refresh()):u.deepMerge(C)}}}}}const MB=(e,t)=>O(void 0,[e,t],function*({operator:o,condition:n,variables:l,localVariables:i,conditionType:r,displayResult:s},c){switch(o){case"visible":return(yield Co({ruleGroup:n,variables:l,localVariables:i,conditionType:r},c))&&s.push("visible"),s;case"hidden":return(yield Co({ruleGroup:n,variables:l,localVariables:i,conditionType:r},c))&&s.push("hidden"),s;default:return null}}),AB=(e,t,o,n)=>{const l=ot().jsonLogic,[i,r]=m.useState(null),s=fo();return m.useEffect(()=>{O(void 0,null,function*(){const c=[];for(const d of e.filter(u=>!u.disabled))for(const u of d.actions||[])yield MB({operator:u.operator,condition:d.condition,variables:t,localVariables:o,conditionType:d.conditionType,displayResult:c},l);r(c)})},[e,n,s]),i};function Cu(e,t){e.forEach(o=>{var n;(n=o.actions)==null||n.forEach(l=>{t(l,o)})})}const RB=e=>{if(!e)return[];let t=(e==null?void 0:e["x-block-linkage-rules"])||[];return e.mapProperties(o=>{o["x-block-linkage-rules"]&&(t=o["x-block-linkage-rules"])}),t==null?void 0:t.filter(o=>!o.disabled)},hv=e=>{const t=y.useFieldSchema(),o=st(),n=gt(),{designable:l}=X(),i=y.useForm(),r=m.useMemo(()=>RB(t),[t]),[s,c]=m.useState(null),d=AB(r,o,n,s),u=(t==null?void 0:t["x-decorator"])==="FormItem"&&!i.readPretty&&r.length;return m.useEffect(()=>{if(u){const p=ee.uid();return setTimeout(()=>{i.addEffects(p,()=>{Cu(r,(h,g)=>ut.reaction(()=>{const v=Wd({linkageRules:r,localVariables:n}),x=j0({action:h,localVariables:n});return[v,x].map(b=>JSON.stringify(b)).join(",")},()=>{c(ee.uid())},{fireImmediately:!0,equals:L.isEqual}))})}),()=>{i.removeEffects(p)}}},[r,u]),r.length?d===null?null:L.last(d)==="hidden"?l?a.jsx("div",{style:{opacity:.3},children:e.children}):null:e.children:e.children},gv=m.createContext({});gv.displayName="DataBlockContext";const EF=m.createContext(null),NB=({children:e})=>{const[t,o]=m.useState(!1),n=m.useMemo(()=>({rerenderDataBlock:()=>{o(!0),setTimeout(()=>{o(!1)})}}),[]);return t?null:a.jsx(EF.Provider,{value:n,children:e})},qF=e=>{const{collection:t,association:o,allowNull:n=!1}=e,l=m.useMemo(()=>o?{Component:fR,name:o}:{Component:aU,name:t},[t,o]);return a.jsx(l.Component,{name:l.name,allowNull:n,children:e.children})},vv=ze(m.memo(e=>{const t=e,{collection:o,association:n,dataSource:l,children:i,hidden:r}=t,s=ne(t,["collection","association","dataSource","children","hidden"]),{dn:c}=X(),d=y.useFieldSchema();return r?null:a.jsx(Ki,{scopeId:d==null?void 0:d["x-uid"],type:"dataBlock",children:a.jsx(gv.Provider,{value:{dn:c,props:T(f({},s),{collection:o,association:n,dataSource:l})},children:a.jsx(es,{dataSource:l,children:a.jsx(qF,{collection:o,association:n,children:a.jsx(Ep,{children:a.jsx(hv,{children:a.jsx($M,{children:a.jsx($F,{children:a.jsx($B,{params:e.params,children:a.jsx(NB,{children:i})})})})})})})})})})}),{displayName:"DataBlockProvider"}),DB=()=>{const e=m.useContext(gv);if(!e)throw new Error("useDataBlock() must be used within a DataBlockProvider");return e},jt=()=>DB().props,EB=()=>{const e=m.useContext(EF);if(!e)throw new Error("useRerenderDataBlock() must be used within a DataBlockProvider");return e},Fu=m.createContext(null);Fu.displayName="BlockRequestRefContext";const ku=m.createContext(!1);ku.displayName="BlockRequestLoadingContext";const wu=m.createContext(null);wu.displayName="BlockRequestDataContext";function qB(e){const t=Jd(),o=Kh(),{action:n,params:l={},record:i,requestService:r,requestOptions:s,sourceId:c,association:d,parentRecord:u}=e,p=Te(),h=jt(),g=Or(h.dataSource),v=I0(d),[x,b]=m.useMemo(()=>[JSON.stringify(l),JSON.stringify(i)],[l,i]),{isBlockTemplate:S,templateFinished:C}=Bd(),k=P=>{var M;if(i)return Promise.resolve({data:i});if(!n)throw new Error("[nocobase]: The 'action' parameter is missing in the 'DataBlockRequestProvider' component");if(n==="get"&&L.isNil(l.filterByTk))return console.warn('[nocobase]: The "filterByTk" parameter is missing in the "DataBlockRequestProvider" component');const R=l.filterByTk===void 0?L.omit(l,"filterByTk"):l,N=f(f({},R),P);return(M=o[n])==null?void 0:M.call(o,N).then(D=>D.data)},F=(...P)=>S!=null&&S()&&!C?null:(r||k)(...P),j=Ue((...P)=>O(this,null,function*(){const[M,R]=yield Promise.all([F(...P),BB({sourceId:c,association:d,parentRecord:u,api:p,headers:g,sourceKey:v})]);return M&&(M.parentRecord=R==null?void 0:R.data),M}),T(f({},s),{manual:t==="manual",ready:!!n,refreshDeps:[n,x,b,o,d,u,c,C]}));return j._defaultParams=l,j}function BB(e){return O(this,arguments,function*({sourceId:t,association:o,parentRecord:n,api:l,headers:i,sourceKey:r}){if(n)return Promise.resolve({data:n});if(!o||!r||!t)return Promise.resolve({data:void 0});const s=`${o.split(".")[0]}:get?filter[${r}]=${t}`;return(yield l.request({url:s,headers:i})).data})}const BF=e=>{var t,o,n,l,i,r;const s=m.useRef(e.recordRequest),c=m.useRef((t=e.recordRequest)==null?void 0:t.data),{active:d}=Mi(),u=m.useRef(d),p=m.useDeferredValue(d),h=jt();return p&&!u.current&&(L.isNil(h.dataLoadingMode)||h.dataLoadingMode==="auto")&&((o=e.recordRequest)==null||o.refresh()),p&&u.current&&!((n=e.recordRequest)!=null&&n.loading)&&!L.isEqual(c.current,(l=e.recordRequest)==null?void 0:l.data)&&(c.current=(i=e.recordRequest)==null?void 0:i.data),p!==u.current&&(u.current=p),s.current=e.recordRequest,a.jsx(Fu.Provider,{value:s,children:a.jsx(ku.Provider,{value:(r=e.recordRequest)==null?void 0:r.loading,children:a.jsx(wu.Provider,{value:c.current,children:e.children})})})},$F=m.memo(({children:e})=>{var t,o;const n=jt(),{action:l,filterByTk:i,sourceId:r,params:s=A0,association:c,collection:d,record:u,parentRecord:p,requestOptions:h,requestService:g}=n,v=m.useMemo(()=>T(f({},s),{filterByTk:i||s.filterByTk}),[i,s]),x=qB({action:l,sourceId:r,record:u,association:c,collection:d,requestOptions:h,requestService:g,params:v,parentRecord:p}),b=(t=x.data)==null?void 0:t.parentRecord,S=m.useMemo(()=>b&&new fn({isNew:!1,data:b instanceof fn?b.data:b}),[b]);return a.jsx(BF,{recordRequest:x,children:l!=="list"?a.jsx(Bl,{isNew:l==null,record:((o=x.data)==null?void 0:o.data)||u,parentRecord:S||p,children:e}):a.jsx(Bl,{isNew:!1,record:null,parentRecord:S||p,children:e})})});$F.displayName="DataBlockRequestProvider";const Un=()=>{const e=m.useContext(Fu),t=m.useContext(ku),o=m.useContext(wu);return m.useMemo(()=>e?T(f({},e.current),{loading:t,data:o}):null,[e,o,t])},ua=()=>{const e=m.useContext(Fu);return m.useMemo(()=>({getDataBlockRequest:()=>e?e.current:null}),[e])},As=()=>m.useContext(wu),xv=m.createContext(null);xv.displayName="FilterContext";const OF=m.memo(({children:e})=>{const t=m.useRef([]),o=m.useCallback(i=>{typeof i=="function"?t.current=i(t.current):t.current=i},[]),n=m.useCallback(()=>t.current,[]),l=m.useMemo(()=>({getDataBlocks:n,setDataBlocks:o}),[n,o]);return a.jsx(xv.Provider,{value:l,children:e})});OF.displayName="FilterBlockProvider";const $B=({children:e,params:t})=>{const o=ve(),{recordDataBlocks:n}=Jl(),{getDataBlockRequest:l}=ua(),i=y.useField(),r=y.useFieldSchema(),s=lg(),c=m.useRef(null),d=Jd(),u=i&&i.decoratorType!=="FilterFormBlockProvider"&&i.decoratorType!=="FormBlockProvider"&&i.decoratorProps.blockType!=="filter",p=m.useCallback(()=>{const h=l();n({uid:r["x-uid"],title:i.componentProps.title,doFilter:h.runAsync,collection:o,associatedFields:s,foreignKeyFields:o==null?void 0:o.getFields("isForeignKey"),defaultFilter:(t==null?void 0:t.filter)||{},service:h,dom:c.current,dataLoadingMode:d,clearFilter(g){var v,x,b;const S=((v=this.service.params)==null?void 0:v[0])||{},C=((b=(x=this.service.params)==null?void 0:x[1])==null?void 0:b.filters)||{};delete C[g];const k=Zt([...Object.values(C).map(F=>yt(F)),(t==null?void 0:t.filter)||{}]);this.service.run(T(f({},S),{page:1,filter:k}),{filters:C})},clearData(){this.service.mutate(void 0)},clearSelection(){var g,v;i&&((v=(g=i.data)==null?void 0:g.clearSelectedRowKeys)==null||v.call(g))},highlightBlock(){var g;const v=c.current;if(!v)return;const x=v.querySelector(".ant-nb-schema-toolbar");x&&x.classList.remove("hidden"),v.style.boxShadow="0 3px 12px rgba(0, 0, 0, 0.15)",v.style.transition="box-shadow 0.3s ease, transform 0.2s ease",(g=v.scrollIntoView)==null||g.call(v,{behavior:"smooth",block:"start"})},unhighlightBlock(){const g=c.current;if(!g)return;const v=g.querySelector(".ant-nb-schema-toolbar");v&&v.classList.add("hidden"),g.style.boxShadow="none",g.style.transition="box-shadow 0.3s ease, transform 0.2s ease"}})},[s,o,d,r,t==null?void 0:t.filter,n,l,i]);return m.useEffect(()=>{u&&p()},[p,u]),a.jsx("div",{ref:c,children:e})},Jl=()=>{const e=m.useContext(xv),t=Wr(),o=m.useCallback(()=>(e==null?void 0:e.getDataBlocks())||[],[e]),n=m.useCallback(i=>{t.recordDataBlocks(i);const r=e==null?void 0:e.getDataBlocks().find(s=>s.uid===i.uid);if(r){Object.assign(r,i);return}e==null||e.setDataBlocks(s=>[...s,i])},[e]),l=m.useCallback(i=>{t.removeDataBlock(i),!(e!=null&&e.getDataBlocks().every(r=>r.uid!==i))&&(e==null||e.setDataBlocks(r=>r.filter(s=>s.uid!==i)))},[e]);return e?{recordDataBlocks:n,getDataBlocks:o,removeDataBlock:l,inProvider:!0}:{inProvider:!1,recordDataBlocks:L.noop,getDataBlocks:o,removeDataBlock:L.noop}},OB=()=>{const e=y.useField(),{t}=K.useTranslation();return a.jsxs(bt,{children:[a.jsx(so,{title:t("Edit markdown"),onClick:()=>{e.editable=!0}}),a.jsx(tk,{}),a.jsx(qo,{}),a.jsx(Bt,{}),a.jsx(Ot,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};class LB extends HTMLElement{constructor(){super(),A(this,"root"),this.attachShadow({mode:"open"}),this.root=null}getProps(t,o={}){return[...t].filter(n=>n.name!=="style").map(n=>this.convert(o,n.name,n.value)).reduce((n,l)=>T(f({},n),{[l.name]:l.value}),{})}convert(t,o,n){const l=Object.keys(t).find(r=>r.toLowerCase()==o);let i=n;return n==="true"||n==="false"?i=n=="true":!isNaN(n)&&n!==""?i=+n:/^{.*}/.exec(n)&&(i=JSON.parse(n)),{name:l||o,value:i}}connectedCallback(){const t=f({},this.getProps(this.attributes));this.root=yh.createRoot(this.shadowRoot),this.root.render(a.jsx(I.QRCode,f({},t)))}disconnectedCallback(){this.root.unmount()}}function VB(){customElements.get("qr-code")||customElements.define("qr-code",LB)}const LF=Nt("nb-markdown",(e,{isDarkTheme:t})=>{const{componentCls:o}=e,n=new pl.TinyColor(e.colorFillAlter).onBackground(e.colorBgContainer).toHexShortString(),l={lineHeight:"inherit","&.nb-markdown-default":{"pre code.hljs":{display:"block",overflowX:"auto",padding:"1em"},"code.hljs":{padding:"3px 5px"},":not(pre) code":{padding:"2px 5px",color:"#d56161",background:e.colorFillQuaternary,border:`1px solid ${e.colorBorder}`,borderRadius:e.borderRadiusSM},blockquote:{borderLeft:"4px solid #ccc",paddingLeft:"20px",marginLeft:"0",color:"#666",fontStyle:"italic"},img:{maxWidth:"100%"},".hljs":{background:"#f8f8f8",color:"#444"},".hljs-comment":{color:"#697070"},".hljs-punctuation,.hljs-tag":{color:"#444a"},".hljs-tag .hljs-attr,.hljs-tag .hljs-name":{color:"#444"},".hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag":{fontWeight:700},".hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type":{color:"#800"},".hljs-section,.hljs-title":{color:"#800",fontWeight:700},".hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable":{color:"#ab5656"},".hljs-literal":{color:"#695"},".hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code":{color:"#397300"},".hljs-meta":{color:"#1f7199"},".hljs-meta .hljs-string":{color:"#38a"},".hljs-emphasis":{fontStyle:"italic"},".hljs-strong":{fontWeight:700}},"&.nb-markdown-table":{table:{borderCollapse:"collapse",width:"100%",fontFamily:"Arial, sans-serif",marginBottom:"1.5rem"},"th, td":{borderBottom:`1px solid ${e.colorBorderSecondary}`,padding:`${e.paddingContentVertical}px ${e.paddingContentHorizontal}px`,textAlign:"left"},th:{backgroundColor:n,fontWeight:"bold",color:e.colorText},"tr:hover":{backgroundColor:e.colorFillTertiary},"tr:last-child td":{borderBottom:"none"},"tr:first-child th":{borderTop:"none"}}},i={"&.nb-markdown-default":{"pre code.hljs":{display:"block",overflowX:"auto",padding:"1em"},"code.hljs":{padding:"3px 5px"},":not(pre) code":{padding:"2px 5px",color:"#d56161",background:e.colorFillQuaternary,border:`1px solid ${e.colorBorder}`,borderRadius:e.borderRadiusSM},".hljs":{color:"#adbac7",background:"#22272e"},".hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_":{color:"#f47067"},".hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_":{color:"#dcbdfb"},".hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable":{color:"#6cb6ff"},".hljs-meta .hljs-string,.hljs-regexp,.hljs-string":{color:"#96d0ff"},".hljs-built_in,.hljs-symbol":{color:"#f69d50"},".hljs-code,.hljs-comment,.hljs-formula":{color:"#768390"},".hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag":{color:"#8ddb8c"},".hljs-subst":{color:"#adbac7"},".hljs-section":{color:"#316dca",fontWeight:700},".hljs-bullet":{color:"#eac55f"},".hljs-emphasis":{color:"#adbac7",fontStyle:"italic"},".hljs-strong":{color:"#adbac7",fontWeight:700},".hljs-addition":{color:"#b4f1b4",backgroundColor:"#1b4721"},".hljs-deletion":{color:"#ffd8d3",backgroundColor:"#78191b"}},"&.nb-markdown-table":{table:{borderCollapse:"collapse",width:"100%",fontFamily:"Arial, sans-serif",marginBottom:"1.5rem"},"th, td":{borderBottom:`1px solid ${e.colorBorderSecondary}`,padding:`${e.paddingContentVertical}px ${e.paddingContentHorizontal}px`,textAlign:"left"},th:{backgroundColor:n,fontWeight:"bold",color:e.colorText},"tr:hover":{backgroundColor:e.colorFillTertiary},"tr:last-child td":{borderBottom:"none"},"tr:first-child th":{borderTop:"none"}}};return{[o]:f({lineHeight:e.lineHeight,"& > *:last-child":{marginBottom:"0"},".ant-description-textarea, .ant-description-input":{lineHeight:e.lineHeight},".field-interface-datetime":{minWidth:"100px"}},t?i:l)}}),VF=L.memoize(e=>O(void 0,null,function*(){return e&&(yield Promise.resolve().then(()=>require("./md-oH2RssNY-IQIU5F3r.js"))).default.render(e)}));function zB(e){const[t,o]=m.useState(""),[n,l]=m.useState(!0);return m.useEffect(()=>{l(!0),VF(e).then(i=>{o(i),l(!1)}).catch(i=>console.log(i))},[e]),{html:t,loading:n}}function _B(e){const t=e;let o=document.createElement("div");o.innerHTML=t;const n=o.innerText;return o=null,(n==null?void 0:n.replace(/[\n\r]/g,""))||""}const KB=e=>{const{scope:t}=e,{t:o,i18n:n}=K.useTranslation(),[l,i]=m.useState(e.defaultValue),r=m.useRef(null),[s,c]=m.useState([]),[d,u]=m.useState(null);m.useEffect(()=>{c(t)},[t]),m.useEffect(()=>{var h,g;const v=(g=(h=r==null?void 0:r.current)==null?void 0:h.resizableTextArea)==null?void 0:g.textArea;d&&v&&v.setSelectionRange(d,d)},[d]);const p=m.useCallback(function(h){var g;const v=h.filter(j=>!!j.trim()),{current:x}=r,b=(g=x==null?void 0:x.resizableTextArea)==null?void 0:g.textArea;if(!b||!v)return;x.focus();const S=`{{${h.join(".")}}}`,C=b.selectionStart||0,k=l.substring(0,C)+S+l.substring(C,l.length),F=C+S.length;i(k),u(F)},[l]);return a.jsxs("div",{className:"mb-markdown",style:{position:"relative",paddingTop:"20px"},children:[a.jsx(I.Input.TextArea,T(f({ref:r,autoSize:{minRows:3}},e),{value:l,onChange:h=>{i(h.target.value)},style:{paddingBottom:"40px"}})),a.jsxs(a.Fragment,{children:[a.jsxs("span",{style:{marginLeft:".25em"},className:"ant-formily-item-extra",children:[o("Syntax references"),":"]}),a.jsx("a",{href:`https://${n.language==="zh-CN"?"docs-cn":"docs"}.nocobase.com/handbook/template-handlebars`,target:"_blank",rel:"noreferrer",children:"Handlebars.js"})]}),a.jsx("div",{style:{position:"absolute",top:21,right:1},children:a.jsx(ca,{options:s,setOptions:c,onInsert:p})}),a.jsxs(I.Space,{style:{position:"absolute",bottom:30,right:5},children:[a.jsx(I.Button,{onClick:h=>{var g;(g=e.onCancel)==null||g.call(e,h)},children:o("Cancel")}),a.jsx(I.Button,{type:"primary",onClick:()=>{var h;(h=e.onSubmit)==null||h.call(e,l)},children:o("Save")})]})]})},UB=()=>{const{token:e}=I.theme.useToken(),t=Ug();if(t)return t-2*e.paddingLG};function HB(e){const t=/\{\{\$nForm\.([\w.]+)\}\}/g;return[...e.matchAll(t)].map(o=>o[1])}function GB(e,t){const o={};for(const n of t){const l=n.split(".");let i=e;for(const r of l)if(i&&typeof i=="object"&&r in i)i=i[r];else{i=void 0;break}o[n]=i}return o}const WB=ze(y.observer(e=>{const{isDarkTheme:t}=Go(),{componentCls:o,hashId:n}=LF({isDarkTheme:t}),{content:l,className:i}=e,r=y.useField(),s=y.useFieldSchema(),{dn:c}=X(),{onSave:d,onCancel:u,form:p}=e,h=fo(),[g,v]=m.useState(""),x=st(),b=gt(),{engine:S}=(s==null?void 0:s["x-decorator-props"])||{},[C,k]=m.useState(!1),{t:F,i18n:j}=K.useTranslation(),P=y.useForm(),M=HB(l),[R,N]=m.useState(null);m.useEffect(()=>{if(M.length>0){const $=ee.uid();return setTimeout(()=>{P.addEffects($,()=>ut.reaction(()=>{const q=GB(P.values,M);return JSON.stringify(q)},()=>{N(ee.uid())},{fireImmediately:!0,equals:L.isEqual}))}),()=>{P.removeEffects($)}}},[]),m.useEffect(()=>{k(!0),O(void 0,null,function*(){setTimeout(()=>O(void 0,null,function*(){const $=yield Ud(S,l,x,b,VF,F);v($)})),k(!1)})},[l,x,b,S,R]);const D=UB(),B=ms({collectionField:{uiSchema:s},form:p,record:h,uiSchema:s,noDisabled:!0});return m.useEffect(()=>{VB()},[]),C?a.jsx(I.Spin,{}):r!=null&&r.editable?a.jsx(KB,T(f({scope:B},e),{className:!0,defaultValue:l,onCancel:()=>{r.editable=!1,u==null||u()},onSubmit:$=>O(void 0,null,function*(){r.editable=!1,s["x-component-props"]!=null||(s["x-component-props"]={}),s["x-component-props"].content=$,r.componentProps.content=$,d==null||d(s),c.emit("patch",{schema:{"x-uid":s["x-uid"],"x-component-props":{content:$}}})})})):a.jsx("div",{className:fe([o,n,"nb-markdown nb-markdown-default nb-markdown-table",i]),style:T(f({},e.style),{height:D||"100%",overflowY:D?"auto":"null"}),dangerouslySetInnerHTML:{__html:g}})}),{displayName:"MarkdownVoid"}),zF=e=>{const t=at(),o=y.useFieldSchema();return a.jsx(Ki,{scopeId:o==null?void 0:o["x-uid"],type:"markdownBlock",children:a.jsx(Wt,T(f({},t),{collectionField:!0,children:a.jsx(WB,f({},e))}))})};zF.Designer=OB;const Pu=y.connect(I.Input.TextArea,y.mapProps((e,t)=>T(f({autoSize:{maxRows:10,minRows:3}},e),{suffix:a.jsx("span",{children:t!=null&&t.loading||t!=null&&t.validating?a.jsx(te.LoadingOutlined,{}):e.suffix})})),y.mapReadPretty(e=>a.jsx(Rs,f({},e)))),Rs=e=>{const{isDarkTheme:t}=Go(),{wrapSSR:o,hashId:n,componentCls:l}=LF({isDarkTheme:t}),{html:i="",loading:r}=zB(e.value),s=m.useMemo(()=>_B(i),[i]);if(r)return o(a.jsx(I.Spin,{}));const c=a.jsx("div",{className:`${n} ${l} nb-markdown nb-markdown-default nb-markdown-table`,dangerouslySetInnerHTML:{__html:i}});return o(a.jsx(tt.TextArea,T(f({},e),{autop:!1,text:s,value:c})))};Pu.Void=zF;const Ns=m.createContext({}),Xl=m.forwardRef((e,t)=>{var o=e,{children:n}=o,l=ne(o,["children"]);const{token:i}=It(),r=l,{title:s,description:c}=r,d=ne(r,["title","description"]),u=m.useMemo(()=>({marginBottom:i.marginBlock,height:"100%"}),[i.marginBlock]),[p,h]=m.useState(0),g=m.useRef(null),{t:v}=K.useTranslation(),x=y.useFieldSchema(),b=x==null?void 0:x["x-block-linkage-rules"];m.useEffect(()=>{const k=setTimeout(()=>{if(g.current){const F=c?g.current.parentElement.parentElement.parentElement.offsetHeight:i.fontSizeLG*i.lineHeightLG+i.padding*2-1;h(F)}else p&&h(0)},500);return()=>clearTimeout(k)},[s,c]);const S=(s||c)&&a.jsxs("div",{ref:g,style:{padding:"8px 0px 8px"},children:[a.jsxs("span",{children:[" ",v(s,{ns:Qt})]}),c&&a.jsx(Rs,{value:v(c,{ns:Qt}),style:{overflowWrap:"break-word",whiteSpace:"normal",fontWeight:400,color:i.colorTextDescription,borderRadius:"4px"}})]}),C=a.jsx(Ns.Provider,{value:{titleHeight:p},children:a.jsx(I.Card,T(f({ref:t,variant:"borderless",style:u},d),{title:S,children:n}))});return b?a.jsx(hv,{children:C}):C});Xl.displayName="BlockItemCard";const sl=()=>{var e,t,o;const n=y.useFieldSchema(),l=cl(n),i=(e=ft())==null?void 0:e.fieldSchema,r=m.useMemo(()=>ju(i||n),[]),{disablePageHeader:s,enablePageTabs:c,hidePageTitle:d}=(r==null?void 0:r["x-component-props"])||{},{titleHeight:u}=m.useContext(Ns)||{},{allAccessRoutes:p}=un(),h=is(),g=m.useMemo(()=>Is(h,p),[h,p]);return{heightProps:T(f({},l==null?void 0:l["x-component-props"]),{title:((t=l==null?void 0:l["x-component-props"])==null?void 0:t.title)||((o=l==null?void 0:l["x-component-props"])==null?void 0:o.description),disablePageHeader:s,enablePageTabs:(g==null?void 0:g.enableTabs)||c,hidePageTitle:d,titleHeight:u})}},ju=e=>e?e["x-component"]==="Page"?e:ju(e.parent):null,cl=e=>e?["BlockItem","CardItem"].includes(e["x-component"])?e:cl(e.parent):null,fv=({association:e})=>{var t;const o=Dt(),n=ln(),l=Ye(),i=ve();if(!e)return;const r=l.getCollection(e.split(".")[0]);return i.name===r.name||(t=i.getParentCollectionsName)!=null&&t.call(i).includes(r.name)?o:n},YB=()=>{const e=y.useForm();return{onClick(){console.log("usePickActionProps",e.values)}}};function JB(e,t){const o=/\{\{\s*((\w+\.?)+)\s*\}\}/g;return e.replace(o,function(n,l){return gi(t,l)||""})}function XB(e){const t=L.cloneDeep(e.values),o=[];return e.query("*").forEach(n=>{n&&o.push(n)}),L.uniq(o.filter(n=>{var l,i;const r=((l=n.path)==null?void 0:l.segments)||[],s=r.length<=1?r.join("."):r.slice(0,-1).join(".");return((i=n==null?void 0:n.componentProps)==null?void 0:i.readOnlySubmit)&&!gi(t,s)[n==null?void 0:n.componentProps.filterTargetKey]}).map(n=>{var l;const i=((l=n.path)==null?void 0:l.segments)||[];return i.length<=1?i.join("."):i.slice(0,-1).join(".")})).forEach((n,l)=>{(l!==0||n.includes("."))&&!t[n]&&L.unset(t,n)}),t}function Ds({filterByTk:e,field:t,form:o,fieldNames:n,getField:l,resource:i,actionFields:r}){if(e&&r){const s=Object.keys(o.values).filter(c=>{const d=l(c);return!r.includes(c)&&["hasOne","hasMany","belongsTo","belongsToMany"].includes(d==null?void 0:d.type)});return By(f({},o.values),s)}return XB(o)}function _F(e){const t=y.useForm(),o=e??t,n=Pn(),{field:l,resource:i}=pt(),{fields:r,getField:s,getTreeParentField:c,name:d}=re(),u=r.map(S=>S.name),{fieldSchema:p}=ke(),{getActiveFieldsName:h}=Vn()||{},g=st(),v=gt({currentForm:o}),x=y.useFieldSchema(),b=Eh();return m.useCallback(()=>O(this,null,function*(){var S,C,k,F;const{assignedValues:j={},overwriteValues:P}=(S=x==null?void 0:x["x-action-settings"])!=null?S:{},M=Ds({filterByTk:n,field:l,form:o,fieldNames:u,getField:s,resource:i,actionFields:(h==null?void 0:h("form"))||[]}),R={},N=Object.keys(j).map(D=>O(this,null,function*(){const B=j[D],$=s(D);if(dt(B)){const{value:q}=(yield g==null?void 0:g.parseVariable(B,v))||{};R[D]=il(q,{targetCollectionField:$})}else B!==""&&(R[D]=B)}));if(yield Promise.all(N),(C=p==null?void 0:p["x-component-props"])==null?void 0:C.addChild){const D=c();M[(k=D==null?void 0:D.name)!=null?k:"parent"]=b,M[(F=D==null?void 0:D.foreignKey)!=null?F:"parentId"]=b==null?void 0:b.id}return f(f(f({},M),P),R)}),[x,l,u,p,n,o,h,s,c,v,d,i,b,g])}const bv=()=>{var e;const t=Pn(),o=fo(),n=y.useForm(),{field:l,resource:i}=pt(),{setVisible:r,setSubmitted:s,setFormValueChanged:c}=ke(),d=Eo(),u=y.useFieldSchema(),p=y.useField(),h=se(),{modal:g}=I.App.useApp(),{t:v}=K.useTranslation(),{updateAssociationValues:x}=je(),b=_F(),S=o.isNew?p.componentProps.saveMode||"create":"update",C=((e=p.componentProps.filterKeys)==null?void 0:e.checked)||[],k=gt(),F=st();return{onClick(){return O(this,null,function*(){var j,P;const{onSuccess:M,skipValidator:R,triggerWorkflows:N}=(j=u==null?void 0:u["x-action-settings"])!=null?j:{},{manualClose:D,redirecting:B,redirectTo:$,successMessage:q,actionAfterSuccess:E}=M||{};R||(yield n.submit());const U=yield b();p.data=l.data||{},p.data.loading=!0;try{const V=yield i[S]({values:U,filterKeys:C,filterByTk:t,triggerWorkflows:N!=null&&N.length?N.map(_=>[_.workflowKey,_.context].filter(Boolean).join("!")).join(","):void 0,updateAssociationValues:x});let z=$;if($&&(z=yield Ka($,{variables:F,localVariables:[...k,{name:"$record",ctx:new Proxy((P=V==null?void 0:V.data)==null?void 0:P.data,{})}]})),(E==="previous"||!E&&B!==!0)&&(r==null||r(!1)),s==null||s(!0),c==null||c(!1),p.data.loading=!1,p.data.data=V,!q){I.message.success(v("Saved successfully")),yield Wc(n),(B&&!E||E==="redirect")&&z&&(de.isURL(z)?window.location.href=z:d(z));return}D?g.success({title:h(q),onOk:()=>O(this,null,function*(){yield Wc(n),(B&&!E||E==="redirect")&&z&&(de.isURL(z)?window.location.href=z:d(z))})}):(I.message.success(h(q)),yield Wc(n),(B&&!E||E==="redirect")&&z&&(de.isURL(z)?window.location.href=z:d(z)))}catch{p.data.loading=!1}})}}},KF=()=>{var e;const t=y.useForm(),{field:o,resource:n,__parent:l}=pt(),{setVisible:i,fieldSchema:r,setSubmitted:s}=ke(),c=y.useFieldSchema(),d=y.useField(),{fields:u,getField:p,getTreeParentField:h,name:g}=re(),v=se(),x=Pn(),b=$e(),S=st(),C=gt({currentForm:t}),{getActiveFieldsName:k}=Vn()||{},F=d.componentProps.saveMode||"create",j=((e=d.componentProps.filterKeys)==null?void 0:e.checked)||[];return{onClick(){return O(this,null,function*(){var P,M,R,N,D,B;const $=u.map(Y=>Y.name),{assignedValues:q={},onSuccess:E,overwriteValues:U,skipValidator:V,triggerWorkflows:z}=(P=c==null?void 0:c["x-action-settings"])!=null?P:{},_=(M=r==null?void 0:r["x-component-props"])==null?void 0:M.addChild,{successMessage:H}=E||{},G={},W=Object.keys(q).map(Y=>O(this,null,function*(){const J=q[Y],ae=p(Y);if(dt(J)){const{value:le}=(yield S==null?void 0:S.parseVariable(J,C))||{};G[Y]=il(le,{targetCollectionField:ae})}else J!==""&&(G[Y]=J)}));yield Promise.all(W),V||(yield t.submit());const Q=Ds({filterByTk:x,field:o,form:t,fieldNames:$,getField:p,resource:n,actionFields:(k==null?void 0:k("form"))||[]});if(_){const Y=h();Q[(R=Y==null?void 0:Y.name)!=null?R:"parent"]=b,Q[(N=Y==null?void 0:Y.foreignKey)!=null?N:"parentId"]=b.id}d.data=o.data||{},d.data.loading=!0;try{const Y=yield n[F]({values:f(f(f({},Q),U),G),filterKeys:j,triggerWorkflows:z!=null&&z.length?z.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):void 0});if(d.data.loading=!1,d.data.data=Y,(B=(D=l==null?void 0:l.service)==null?void 0:D.refresh)==null||B.call(D),i==null||i(!1),s==null||s(!0),!H)return;I.message.success(v(H))}catch{d.data.data=null,d.data.loading=!1}})}}},pa=e=>{for(;e;){if(e["x-filter-targets"])return{targets:e["x-filter-targets"],uid:e["x-uid"]};e=e.parent}return{}},nh=(e,t)=>{for(;e;){if(e["x-filter-targets"]){e["x-filter-targets"]=t;return}e=e.parent}},UF=()=>{const e=y.useForm(),{getDataBlocks:t}=Jl(),o=Ye(),{getOperators:n}=Ei(),l=y.useFieldSchema(),{name:i}=ve(),{targets:r=[],uid:s}=m.useMemo(()=>pa(l),[l]),c=m.useCallback(()=>yt(MA(e.values,n(),o.getCollectionField.bind(o),i)),[e.values,o,n,i]),d=m.useCallback((...u)=>O(void 0,[...u],function*({doNothingWhenFilterIsEmpty:p=!1}={}){try{yield Promise.all(t().map(h=>O(void 0,null,function*(){var g,v,x,b;if(!r.find(F=>F.uid===h.uid))return;const S=((g=h.service.params)==null?void 0:g[0])||{},C=((x=(v=h.service.params)==null?void 0:v[1])==null?void 0:x.filters)||{};C[s]=c();const k=Zt([...Object.values(C).map(F=>yt(F)),h.defaultFilter]);if(L.isEmpty(C[s])&&((b=h.clearSelection)==null||b.call(h)),!(p&&L.isEmpty(C[s])))return h.dataLoadingMode==="manual"&&L.isEmpty(C[s])?h.clearData():(L.set(h.service.params,"1.filters",C),h.doFilter(T(f({},S),{page:1,filter:k}),{filters:C}))})))}catch(h){console.error(h)}}),[t,c,r,s]);return m.useEffect(()=>{setTimeout(()=>{d({doNothingWhenFilterIsEmpty:!0})},500)},[d]),{doFilter:d,getFilterFromCurrentForm:c}},QB=()=>{const{doFilter:e}=UF(),t=y.useField();return t.data=t.data||{},{onClick(){return O(this,null,function*(){t.data.loading=!0,yield e(),t.data.loading=!1})}}},ZB=()=>{const e=y.useForm(),t=y.useFieldSchema(),{getDataBlocks:o}=Jl(),{targets:n,uid:l}=pa(t),{doFilter:i,getFilterFromCurrentForm:r}=UF();return{doReset:()=>O(void 0,null,function*(){var s;if(yield e.reset(void 0,{forceClear:!!((s=t==null?void 0:t["x-component-props"])!=null&&s.clearDefaultValue)}),L.isEmpty(r()))return u$({getDataBlocks:o,targets:n,uid:l});yield i()})}},e$=()=>{const e=y.useField(),{doReset:t}=ZB();return e.data=e.data||{},{onClick(){return O(this,null,function*(){e.data.loading=!0,yield t(),e.data.loading=!1})}}},t$=()=>{const{resource:e,__parent:t,field:o,service:n}=pt(),l=Pn(),i=y.useFieldSchema(),r=y.useField(),s=Eo(),c=se(),d=y.useForm(),{modal:u}=I.App.useApp(),p=st(),h=gt({currentForm:d}),{name:g,getField:v}=re(),{setVisible:x}=ke();return{onClick(b,S){return O(this,null,function*(){var C,k,F,j;const{assignedValues:P={},onSuccess:M,skipValidator:R,triggerWorkflows:N}=(C=i==null?void 0:i["x-action-settings"])!=null?C:{},{manualClose:D,redirecting:B,redirectTo:$,successMessage:q,actionAfterSuccess:E}=M||{},U={},V=Object.keys(P).map(z=>O(this,null,function*(){const _=P[z],H=v(z);if(dt(_)){const{value:G}=(yield p==null?void 0:p.parseVariable(_,h))||{};U[z]=il(G,{targetCollectionField:H})}else _!==""&&(U[z]=_)}));if(yield Promise.all(V),R===!1&&(yield d.submit()),r.data=r.data||{},!r.data.loading){r.data.loading=!0;try{const z=yield e.update({filterByTk:l,values:f({},U),triggerWorkflows:N!=null&&N.length?N.map(H=>[H.workflowKey,H.context].filter(Boolean).join("!")).join(","):void 0});let _=$;if($&&(_=yield Ka($,{variables:p,localVariables:[...h,{name:"$record",ctx:new Proxy((k=z==null?void 0:z.data)==null?void 0:k.data,{})}]})),(E==="previous"||!E&&B!==!0)&&(x==null||x(!1)),S&&(S==null||S()),e instanceof mu||(j=(F=t==null?void 0:t.service)==null?void 0:F.refresh)==null||j.call(F),!q)return;D?u.success({title:c(q),onOk:()=>O(this,null,function*(){(B&&!E||E==="redirect")&&_&&(de.isURL(_)?window.location.href=_:s(_))})}):(I.message.success(c(q)),(B&&!E||E==="redirect")&&_&&(de.isURL(_)?window.location.href=_:s(_)))}catch(z){console.error(z)}finally{r.data.loading=!1}}})}}},o$=()=>{var e,t,o,n;const{field:l,resource:i,__parent:r,service:s}=pt(),c=m.useContext(y.SchemaExpressionScopeContext),d=y.useFieldSchema(),u=Fo(),{rowKey:p}=u,h=(n=(o=(t=(e=u.field)==null?void 0:e.data)==null?void 0:t.selectedRowKeys)!=null?o:c==null?void 0:c.selectedRecordKeys)!=null?n:{},g=Eo(),v=se(),{t:x}=K.useTranslation(),b=y.useField(),{modal:S}=I.App.useApp(),C=st();$e();const{name:k,getField:F}=re(),j=gt(),{setVisible:P}=ke();return{onClick(){return O(this,null,function*(){var M;const{assignedValues:R={},onSuccess:N,updateMode:D}=(M=d==null?void 0:d["x-action-settings"])!=null?M:{},{manualClose:B,redirecting:$,redirectTo:q,successMessage:E,actionAfterSuccess:U}=N||{};b.data=l.data||{},b.data.loading=!0;const V={},z=Object.keys(R).map(_=>O(this,null,function*(){const H=R[_],G=F(_);if(dt(H)){const{value:W}=(yield C==null?void 0:C.parseVariable(H,j))||{};V[_]=il(W,{targetCollectionField:G})}else H!==""&&(V[_]=H)}));yield Promise.all(z),(U==="previous"||!U&&$!==!0)&&(P==null||P(!1)),S.confirm({title:x("Bulk update"),content:x(D==="selected"?"Update selected data?":"Update all data?"),onOk(){return O(this,null,function*(){var _,H,G,W;const{filter:Q}=(H=(_=s.params)==null?void 0:_[0])!=null?H:{},Y={values:f({},V),filter:Q,forceUpdate:!1};if(D==="selected"){if(!(h!=null&&h.length)){I.message.error(x("Please select the records to be updated")),b.data.loading=!1;return}Y.filter={$and:[{[p||"id"]:{$in:h}}]}}Y.filter||(Y.forceUpdate=!0);try{yield i.update(Y)}catch{}finally{b.data.loading=!1}i instanceof mu||(W=(G=r==null?void 0:r.service)==null?void 0:G.refresh)==null||W.call(G),E&&(B?S.success({title:v(E),onOk:()=>O(this,null,function*(){($&&!U||U==="redirect")&&q&&(de.isURL(q)?window.location.href=q:g(q))})}):(I.message.success(v(E)),($&&!U||U==="redirect")&&q&&(de.isURL(q)?window.location.href=q:g(q))))})},onCancel(){return O(this,null,function*(){b.data.loading=!1})}})})}}},n$=()=>{var e;const t=Te(),o=Eo(),n=Pn(),l=y.useFieldSchema(),i=se(),r=y.useForm(),{fields:s,getField:c}=re(),{field:d,resource:u,__parent:p,service:h}=pt(),g=$e(),v=fg(),x=(e=v==null?void 0:v.data)==null?void 0:e.data,b=y.useField(),{t:S}=K.useTranslation(),{setVisible:C}=ke(),{modal:k}=I.App.useApp(),{getActiveFieldsName:F}=Vn()||{};return{onClick(){return O(this,null,function*(){var j,P,M,R;const{skipValidator:N,onSuccess:D,requestSettings:B}=(j=l==null?void 0:l["x-action-settings"])!=null?j:{},{manualClose:$,redirecting:q,redirectTo:E,successMessage:U,actionAfterSuccess:V}=D||{},z=l==null?void 0:l["x-action"];if(!B.url)return;N!==!0&&z==="customize:form:request"&&(yield r.submit());const _=B.headers?JSON.parse(B.headers):{},H=B.params?JSON.parse(B.params):{},G=B.data?JSON.parse(B.data):{};if(z==="customize:form:request"&&["POST","PUT","PATCH"].includes(B.method)){const Q=s.map(J=>J.name),Y=Ds({filterByTk:n,field:d,form:r,fieldNames:Q,getField:c,resource:u,actionFields:(F==null?void 0:F("form"))||[]});Object.assign(G,Y)}const W={url:JB(B.url,{currentRecord:g,currentUser:x}),method:B.method,headers:de.parse(_)({currentRecord:g,currentUser:x}),params:de.parse(H)({currentRecord:g,currentUser:x}),data:de.parse(G)({currentRecord:g,currentUser:x})};b.data=d.data||{},b.data.loading=!0;try{yield t.request(f({},W)),b.data.loading=!1,u instanceof mu||(M=(P=p==null?void 0:p.service)==null?void 0:P.refresh)==null||M.call(P),(R=h==null?void 0:h.refresh)==null||R.call(h),z==="customize:form:request"&&(V==="previous"||!V&&q!==!0)&&(C==null||C(!1)),U||(I.message.success(S("Saved successfully")),yield Wc(r),(q&&!V||V==="redirect")&&E&&(de.isURL(E)?window.location.href=E:o(E))),$?k.success({title:i(U),onOk:()=>O(this,null,function*(){(q&&!V||V==="redirect")&&E&&(de.isURL(E)?window.location.href=E:o(E))})}):I.message.success(i(U))}finally{b.data.loading=!1}})}}},HF=()=>{const e=y.useForm(),t=Pn(),{field:o,resource:n,__parent:l}=pt(),{setVisible:i,setFormValueChanged:r}=ke(),s=y.useFieldSchema(),c=Eo(),{fields:d,getField:u,name:p}=re(),h=se(),g=y.useField(),{updateAssociationValues:v}=je(),{modal:x}=I.App.useApp(),b=sc(),S=st(),C=gt({currentForm:e}),{getActiveFieldsName:k}=Vn()||{};return{onClick(F,j){return O(this,null,function*(){var P,M;const{assignedValues:R={},onSuccess:N,overwriteValues:D,skipValidator:B,triggerWorkflows:$}=(P=s==null?void 0:s["x-action-settings"])!=null?P:{},{manualClose:q,redirecting:E,redirectTo:U,successMessage:V,actionAfterSuccess:z}=N||{},_={},H=Object.keys(R).map(Q=>O(this,null,function*(){const Y=R[Q],J=u(Q);if(dt(Y)){const{value:ae}=(yield S==null?void 0:S.parseVariable(Y,C))||{};_[Q]=il(ae,{targetCollectionField:J})}else Y!==""&&(_[Q]=Y)}));yield Promise.all(H),B||(yield e.submit());const G=d.map(Q=>Q.name),W=Ds({filterByTk:t,field:o,form:e,fieldNames:G,getField:u,resource:n,actionFields:(k==null?void 0:k("form"))||[]});g.data=o.data||{},g.data.loading=!0;try{const Q=yield n.update(T(f({filterByTk:t,values:f(f(f({},W),D),_)},b),{updateAssociationValues:v,triggerWorkflows:$!=null&&$.length?$.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):void 0}));g.data.loading=!1,j&&(j==null||j());let Y=U;if(U&&(Y=yield Ka(U,{variables:S,localVariables:[...C,{name:"$record",ctx:new Proxy((M=Q==null?void 0:Q.data)==null?void 0:M.data,{})}]})),(z==="previous"||!z&&E!==!0)&&(i==null||i(!1)),r==null||r(!1),!V)return;q?x.success({title:h(V),onOk:()=>O(this,null,function*(){yield e.reset(),(E&&!z||z==="redirect")&&Y&&(de.isURL(Y)?window.location.href=Y:c(Y))})}):(I.message.success(h(V)),(E&&!z||z==="redirect"||z==="redirect")&&Y&&(de.isURL(Y)?window.location.href=Y:c(Y)))}catch{g.data.loading=!1}})}}},GF=()=>{const e=Pn(),{resource:t,service:o,block:n,field:l,__parent:i}=pt(),{setVisible:r,setSubmitted:s}=ke(),c=sc(),d=y.useFieldSchema(),u=y.useField();return{onClick(p,h){return O(this,null,function*(){var g,v,x,b,S,C,k;const{triggerWorkflows:F}=(g=d==null?void 0:d["x-action-settings"])!=null?g:{};u.data=l.data||{},u.data.loading=!0;try{yield t.destroy(f({filterByTk:e,triggerWorkflows:F!=null&&F.length?F.map(R=>[R.workflowKey,R.context].filter(Boolean).join("!")).join(","):void 0},c));const{count:j=0,page:P=0,pageSize:M=0}=((v=o==null?void 0:o.data)==null?void 0:v.meta)||{};if(j%M===1&&P!==1){const R=(x=o.params[0])==null?void 0:x.page,N=(S=(b=o.data)==null?void 0:b.meta)==null?void 0:S.totalPage;R===N&&o.params[0]&&R!==1&&(o.params[0].page=R-1)}h&&(h==null||h()),s==null||s(!0),n&&n!=="TableField"&&((k=(C=i==null?void 0:i.service)==null?void 0:C.refresh)==null||k.call(C),r==null||r(!1),s==null||s(!0))}catch(j){console.error(j),u.data.loading=!0}})}}},l$=e=>{const t=Pn(),o=Te().resource(e,t);return{onClick(n){return O(this,null,function*(){yield o.remove({values:[n.id]})})}}},i$=()=>{const e=Pn(),{resource:t,service:o,block:n,__parent:l}=pt(),{setVisible:i,setSubmitted:r,setFormValueChanged:s}=ke();return{onClick(c,d){return O(this,null,function*(){var u,p,h,g;yield t.remove({values:[e]});const{count:v=0,page:x=0,pageSize:b=0}=((u=o==null?void 0:o.data)==null?void 0:u.meta)||{};v%b===1&&x!==1?o.run(T(f({},(p=o==null?void 0:o.params)==null?void 0:p[0]),{page:x-1})):d&&(d==null||d()),r==null||r(!0),n&&n!=="TableField"&&((g=(h=l==null?void 0:l.service)==null?void 0:h.refresh)==null||g.call(h),i==null||i(!1),s==null||s(!1))})}}},WF=()=>{const{field:e}=pt(),{resource:t,service:o}=pt(),{setSubmitted:n}=ke(),l=re(),{filterTargetKey:i}=l;return{onClick(r,s){return O(this,null,function*(){var c,d,u,p,h,g,v;let x=(c=e.data)==null?void 0:c.selectedRowKeys;if(Array.isArray(i)&&(x=e.data.selectedRowData.map(C=>{const k={};return i.map(F=>{k[F]=C[F]}),k})),!((u=(d=e==null?void 0:e.data)==null?void 0:d.selectedRowKeys)!=null&&u.length))return;yield t.destroy({filterByTk:x}),e.data.selectedRowKeys=[];const b=(p=o.params[0])==null?void 0:p.page,S=(g=(h=o.data)==null?void 0:h.meta)==null?void 0:g.totalPage;b===S&&o.params[0]&&b!==1&&(o.params[0].page=b-1),s&&(s==null||s()),n==null||n(!0),(v=o==null?void 0:o.refresh)==null||v.call(o)})}}},r$=()=>{const{service:e}=pt();return{onClick(){return O(this,null,function*(){var t;(t=e==null?void 0:e.refresh)==null||t.call(e)})}}},YF=()=>{const e=y.useFieldSchema(),t=se(),{t:o}=K.useTranslation(),n=ve();return m.useMemo(()=>{const l=[],i=c=>{let d=c;for(;d&&!((d==null?void 0:d["x-component"])==="ActionBar"||!d.parent);)d=d.parent;const u=d.parent;if(u){const p=u==null?void 0:u.reduceProperties((h,g)=>(g==null?void 0:g["x-component"])==="TableV2"?h.concat([g]):h,[]);return p==null?void 0:p[0]}return null},r=(c,d=0)=>{var u,p,h,g,v,x,b,S,C;if(!(!c||d>1)){if((p=(u=c==null?void 0:c["x-component"])==null?void 0:u.includes)!=null&&p.call(u,"Table.Column")||(g=(h=c==null?void 0:c["x-decorator"])==null?void 0:h.includes)!=null&&g.call(h,"Table.Column")||(c==null?void 0:c["x-component"])==="TableV2.Column"){const k=c.reduceProperties?c.reduceProperties((R,N)=>(N==null?void 0:N["x-component"])==="CollectionField"?R.concat([N]):R,[]):[],F=(k==null?void 0:k.length)>0?k[0].name:c.name,j=(v=n==null?void 0:n.getField)==null?void 0:v.call(n,F);let P=o(c==null?void 0:c.title,{ns:Qt})||c.title;!P&&c.name==="actions"&&(P=o("Actions")),!P&&j&&(P=o((x=j.uiSchema)==null?void 0:x.title,{ns:Qt})||((b=j.uiSchema)==null?void 0:b.title)||j.name),P||(P=c.name||`Column ${l.length+1}`),P=t(P)||P;const M={key:c["x-uid"]||c.name||`column-${l.length}`,title:P,dataIndex:F||`column-${l.length}`,visible:c["x-display"]!=="hidden",fixed:((S=c["x-component-props"])==null?void 0:S.fixed)||!1,width:(C=c["x-component-props"])==null?void 0:C.width,order:c["x-index"]||l.length};l.push(M)}c.properties&&Object.keys(c.properties).forEach(k=>{r(c.properties[k],d+1)}),c.items&&r(c.items,d+1)}},s=i(e);return r(s),l.sort((c,d)=>(c.order||0)-(d.order||0))},[e,t,o,n])},a$=()=>{const e=y.useField(),t=y.useFieldSchema(),o=YF(),n=m.useCallback(()=>{let v=t;for(;v;){const x=S=>{if(!(S!=null&&S.properties))return null;for(const C in S.properties){const k=S.properties[C];if(k["x-component"]==="TableV2")return k;const F=x(k);if(F)return F}return null},b=x(v);if(b)return b;if(!v.parent)break;v=v.parent}return v},[t]),l=m.useMemo(()=>n(),[n]),i=m.useMemo(()=>(l==null?void 0:l["x-uid"])||"default",[l]),{getSettings:r,saveSettings:s,clearSettings:c}=cs(i),[d,u]=m.useState(r()),p=m.useMemo(()=>{if(o.length===0)return[];if(!d||d.length===0)return o;const v=new Map;return d.forEach(x=>{v.set(x.key,x)}),o.map(x=>{const b=v.get(x.key);return b?T(f({},x),{visible:b.visible,order:b.order,width:b.width||x.width,fixed:b.fixed||x.fixed}):x}).sort((x,b)=>(x.order||0)-(b.order||0))},[o,d]);m.useEffect(()=>{p.length>0&&(e.dataSource=p)},[p,e]);const h=m.useCallback(v=>{if(!(v!=null&&v.columns)||!Array.isArray(v.columns))return;const x=v.columns.map((b,S)=>({key:b.key,title:b.title,dataIndex:b.dataIndex,visible:b.visible,fixed:b.fixed,width:b.width,order:S}));s(x)},[s]),g=m.useCallback(()=>{c(),u(r())},[c]);return{columns:p,onSubmit:h,onReset:g}},s$=()=>{var e,t,o,n,l,i,r,s,c,d,u,p,h,g,v,x,b;const S=kr(),C=((o=(t=(e=S.service)==null?void 0:e.data)==null?void 0:t.meta)==null?void 0:o.count)||0,k=(i=(l=(n=S.service)==null?void 0:n.data)==null?void 0:l.meta)==null?void 0:i.page,{hasNext:F}=((s=(r=S.service)==null?void 0:r.data)==null?void 0:s.meta)||{};return!C&&k?{simple:!0,current:((u=(d=(c=S.service)==null?void 0:c.data)==null?void 0:d.meta)==null?void 0:u.page)||1,pageSize:1,showSizeChanger:!1,align:"center",onChange(j){return O(this,null,function*(){var P,M;const R=(M=(P=S.service)==null?void 0:P.params)==null?void 0:M[0];S.service.run(T(f({},R),{page:j}))})},style:{marginTop:24,textAlign:"center"},showTotal:!1,showTitle:!1,total:((g=(h=(p=S.service)==null?void 0:p.data)==null?void 0:h.data)==null?void 0:g.length)<1||!F?1*k:1*k+1,className:Z.css`
|
|
625
|
+
`),footer:k?a.jsx(Ve,{basePath:g.address,schema:h,onlyRenderProperties:!0,filterProperties:P=>P["x-component"]===o}):!1,children:j?a.jsx(sB,{footerNodeName:o,field:g,schema:h}):a.jsx(I.Skeleton,{active:!0,paragraph:{rows:6}})}))}))})})},{displayName:"ActionModal"}),uv=e=>a.jsx(Uo.ErrorBoundary,{FallbackComponent:rB,onError:console.log,children:a.jsx(dB,f({},e))});uv.Footer=y.observer(()=>{const e=y.useField(),t=y.useFieldSchema();return a.jsx(Ve,{basePath:e.address,schema:t,onlyRenderProperties:!0})},{displayName:"ActionModal.Footer"});uv.FootBar=y.observer(()=>{const e=y.useField(),t=y.useFieldSchema();return a.jsx("div",{className:"ant-modal-footer",children:a.jsx(Ve,{basePath:e.address,schema:t,onlyRenderProperties:!0})})},{displayName:"ActionModal.FootBar"});const yu=()=>{const{setVisible:e}=ke();return{goBack:m.useCallback(()=>{e==null||e(!1)},[e])}},Su=()=>{const{token:e}=It(),{goBack:t}=yu(),o=32,n=m.useMemo(()=>({width:"auto",height:"auto",lineHeight:1,padding:e.paddingXS,marginRight:o-e.paddingXS}),[e.paddingXS]);return a.jsx(I.Button,{"aria-label":"back-button",type:"text",icon:a.jsx(te.ArrowLeftOutlined,{}),style:n,onClick:t})},uB=Nt("nb-action-page",e=>{const{componentCls:t}=e;return{[t]:{position:"absolute !important",top:0,left:0,right:0,bottom:0,backgroundColor:e.colorBgLayout,overflowX:"hidden",overflowY:"auto",".ant-tabs-nav":{background:e.colorBgContainer,padding:`0 ${e.paddingPageVertical}px`,marginBottom:0},".ant-tabs-content-holder":{padding:`${e.paddingPageVertical}px`,paddingBottom:"0px"}}}}),pB=()=>{const e=m.useMemo(()=>document.querySelector(".nb-subpages-slot-without-header-and-side"),[]);return{getContainerDOM:m.useCallback(()=>e,[e])}},mB=m.memo(({schema:e})=>{const[t,o]=m.useState(!1);return m.useEffect(()=>{m.startTransition(()=>{o(!0)})},[]),t?a.jsx(Ve,{schema:e,onlyRenderProperties:!0}):null});function IF({level:e}){const t=y.useFieldSchema(),o=ke(),{getContainerDOM:n}=pB(),{componentCls:l,hashId:i}=uB(),r=Gi(),s=_n(),c=m.useMemo(()=>({zIndex:fl("page",s,e||0)}),[s,e]);if(!o.visible)return null;const d=a.jsx("div",{className:`${l} ${i}`,style:c,children:a.jsx($i,{children:a.jsx(Sl,T(f({},r),{tabBarExtraContent:a.jsx(Su,{}),children:a.jsx(To.Provider,{value:c.zIndex,children:a.jsx(mB,{schema:t})})}))})}),u=n();return nn.createPortal(d,u||document.body)}IF.Footer=y.observer(()=>null,{displayName:"ActionPage.Footer"});const hB=m.createContext(null),Lt=()=>m.useContext(hB),Mt=m.memo(m.forwardRef((e,t)=>{const{style:o,closeInitializerMenuWhenClick:n=!0,name:l=ee.uid(),applyMenuStyle:i=!0,className:r,disabled:s,items:c,icon:d,title:u,onClick:p,children:h}=e,g=se(),v=SB(c,l,p),{componentCls:x,hashId:b}=Yh(),{attribute:S}=JM(),{setVisible:C}=nt(),k=m.useMemo(()=>{if(c&&c.length>0)return[{key:l,style:o,className:r,label:h||g(u),onClick:F=>{s||F.key!==l||(n&&(C==null||C(!1)),p==null||p(T(f({},F),{item:e})))},icon:typeof d=="string"?a.jsx(ct,{type:d}):d,children:v}]},[l,s,o,r,h,u,p,d,v]);return c&&c.length>0?a.jsx(L0,{disabled:s,items:k}):a.jsx("div",{ref:t,onClick:F=>{F.stopPropagation(),n&&(C==null||C(!1)),p==null||p({event:F,item:e})},children:a.jsx("div",T(f({},S),{className:fe({[`${x}-menu-item`]:i,[`${x}-menu-item-disabled`]:s},r),style:o,children:h||a.jsxs(a.Fragment,{children:[typeof d=="string"?a.jsx(ct,{type:d}):d,a.jsx("span",{className:fe({[`${b} ${x}-item-content`]:!!d}),children:g(u)})]})}))})}));Mt.displayName="SchemaInitializerItem";const gB={marginLeft:20},vB={display:"flex",alignItems:"center",justifyContent:"space-between"},TF=e=>{const t=e,{title:o,checked:n}=t,l=ne(t,["title","checked"]),i=se();return a.jsx(Mt,T(f({},l),{closeInitializerMenuWhenClick:!1,children:a.jsxs("div",{style:vB,children:[i(o),a.jsx(I.Switch,{disabled:e.disabled,style:gB,size:"small",checked:n})]})}))},Kn=e=>{const{children:t}=e;return t?a.jsx(a.Fragment,{children:t.sort((o,n)=>(o.sort||0)-(n.sort||0)).map((o,n)=>a.jsx(pv,f({},o),o.name||o.key||n))}):null},Vb={item:"SchemaInitializerItemInternal",itemGroup:"SchemaInitializerItemGroupInternal",divider:"SchemaInitializerDivider",switch:"SchemaInitializerSwitchInternal",subMenu:"SchemaInitializerSubMenuInternal",actionModal:"SchemaInitializerActionModalInternal"},xB=()=>{},fB=()=>!0,bB=()=>{},pv=m.memo(e=>{const t=e,{type:o,Component:n,component:l,children:i,useVisible:r=fB,useChildren:s=xB,useComponentProps:c=bB,hideIfNoChildren:d,componentProps:u,sort:p}=t,h=ne(t,["type","Component","component","children","useVisible","useChildren","useComponentProps","hideIfNoChildren","componentProps","sort"]),g=s(),v=c(),x=eu(),b=n||l,S=!b&&o&&Vb[o],C=m.useMemo(()=>{const j=[...g||[],...i||[]];return j.length===0?void 0:j},[g,i]),k=m.useMemo(()=>T(f(f(f({},h),S?v:{}),S?u:{}),{children:C}),[h,S,v,u,C]);if(!r()||!o&&!b)return null;const F=x(S?Vb[o]:b);return!F||d&&!C?null:a.jsx(Xh.Provider,{value:k,children:a.jsx(F,T(f(f({},u),v),{children:C}))})});pv.displayName="SchemaInitializerChild";const yB=e=>{const{items:t}=e;return t.length===0?null:a.jsx(Kn,{children:t})};m.forwardRef((e,t)=>{const o=e,{onClick:n}=o,l=ne(o,["onClick"]);return a.jsx(Mt,T(f({ref:t},l),{onClick:i=>n==null?void 0:n(i.event,!1)}))});const mv=()=>{const e=y.useFieldSchema(),{name:t}=ve()||{};return{getAriaLabel:m.useCallback(o=>{if(!e)return"";const n=e["x-component"],l=typeof n=="string"?n:(n==null?void 0:n.displayName)||n.name,i=e["x-initializer"]?`-${e["x-initializer"]}`:"",r=t?`-${t}`:"";return o=o?`-${o}`:"",`schema-initializer-${l}${i}${r}${o}`},[e,t])}},MF=m.memo(e=>{const t=e,{style:o,options:n}=t,l=ne(t,["style","options"]),i=se(),{getAriaLabel:r}=mv();return a.jsx(I.Button,T(f({"data-testid":n["data-testid"],"aria-label":r(),"aria-disabled":"false",type:"dashed",style:f({borderColor:"var(--colorSettings)",color:"var(--colorSettings)",flex:"none"},o),icon:typeof n.icon=="string"?a.jsx(ct,{type:n.icon}):n.icon},l),{children:n.title&&a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"inline-block",width:n.icon?"calc(100% - 14px)":"100%",verticalAlign:"bottom"},children:i(n.title)})}))});MF.displayName="SchemaInitializerButton(memo)";const AF=e=>{const t=e.Component||MF,o=e.ItemsComponent||yB,n=T(f({},e.itemsComponentProps),{options:e,items:e.items,style:e.itemsComponentStyle}),l=m.useMemo(()=>GM(t),[t]);return m.createElement(l,e,m.createElement(o,n))};AF.displayName="InitializerComponent";function pn(e,t){const o=ot(),{isMobile:n}=Lt()||{};e==="popup:common:addBlock"&&o.schemaInitializerManager.has("mobile:popup:common:addBlock")&&n&&(e="mobile:popup:common:addBlock");const l=m.useMemo(()=>typeof e=="object"?e:o.schemaInitializerManager.get(e),[o.schemaInitializerManager,e]);return m.useMemo(()=>e?l?{exists:!0,render:i=>m.createElement(AF,f(f(f({},l.options),t),i))}:(console.error(`[nocobase]: SchemaInitializer "${e}" not found`),{exists:!1,render:()=>null}):{exists:!1,render:()=>null},[l,e,t])}function SB(e,t,o){const n=RF(o);return m.useMemo(()=>n(e,t),[n,e,t])}function RF(e){const t=se(),o=m.useCallback((n,l)=>n!=null&&n.length?n.map((i,r)=>{var s,c;const d=i.component||i.Component;let u;const p=i.title||i.label?t(i.title||i.label):void 0;if(d&&(u=m.createElement(pv,T(f({},i),{title:p}))),i.type==="divider")return{type:"divider",key:i.key||`divider-${r}`};if(i.type==="item"&&d)return i.key||(i.key=`${p}-${r}`),i.associationField?{key:i.key,label:u,associationField:i.associationField}:{key:i.key,label:u};if(i.type==="itemGroup"){const x=typeof p=="string"?p:i.title,b=i.key||`${l}-item-group-${r}`;return{type:"group",key:b,label:x,children:(s=i==null?void 0:i.children)!=null&&s.length?o(i.children,b):[]}}if(i.type==="subMenu"){const x=p,b=i.key||i.name||`${l}-sub-menu-${r}`;return{key:b,label:x,children:(c=i==null?void 0:i.children)!=null&&c.length?o(i.children,b):[]}}if(i.isMenuType)return ne(i,["isMenuType"]);const h=u||p,g=i.key||`${l}-${p}-${r}`,v=x=>{x.domEvent.stopPropagation(),x.key===g&&(i.onClick?i.onClick(T(f({},x),{item:i})):e==null||e(T(f({},x),{item:i})))};return i.associationField?{key:g,label:h,associationField:i.associationField,onClick:v}:{style:i.style,key:g,label:h,onClick:v}}):[],[t,e]);return o}class Le extends kn{constructor(t,o){super(t),A(this,"otherInstance",null),o&&(this.otherInstance=o,o.otherInstance=this)}add(t,o){super.get(t)||(super.add(t,o),this.otherInstance&&this.otherInstance.add(t,o))}remove(t){super.get(t)&&(super.remove(t),this.otherInstance&&this.otherInstance.remove(t))}}const CB={BlockInitializers:"page:addBlock",MBlockInitializers:"mobilePage:addBlock",CreateFormBlockInitializers:"popup:addNew:addBlock",CusomeizeCreateFormBlockInitializers:"popup:addRecord:addBlock",RecordBlockInitializers:"popup:common:addBlock",BulkEditBlockInitializers:"popup:bulkEdit:addBlock",TableColumnInitializers:"table:configureColumns",TableActionColumnInitializers:"table:configureItemActions",TableActionInitializers:"table:configureActions",SubTableActionInitializers:"subTable:configureActions",FormItemInitializers:"form:configureFields",CreateFormActionInitializers:"createForm:configureActions",UpdateFormActionInitializers:"editForm:configureActions",ReadPrettyFormItemInitializers:"details:configureFields",DetailsActionInitializers:"detailsWithPaging:configureActions",ReadPrettyFormActionInitializers:"details:configureActions",KanbanCardInitializers:"kanban:configureItemFields",KanbanActionInitializers:"kanban:configureActions",GridCardActionInitializers:"gridCard:configureActions",GridCardItemActionInitializers:"gridCard:configureItemActions",ListActionInitializers:"list:configureActions",ListItemActionInitializers:"list:configureItemActions",CalendarActionInitializers:"calendar:configureActions",GanttActionInitializers:"gantt:configureActions",MapActionInitializers:"map:configureActions",TableSelectorInitializers:"popup:tableSelector:addBlock",ChartInitializers:"charts:addBlock",ChartFilterItemInitializers:"chartFilterForm:configureFields",ChartFilterActionInitializers:"chartFilterForm:configureActions",AssociationFilterInitializers:"filterCollapse:configureFields",FilterFormItemInitializers:"filterForm:configureFields",FilterFormActionInitializers:"filterForm:configureActions",CustomFormItemInitializers:"assignFieldValuesForm:configureFields",BulkEditFormItemInitializers:"bulkEditForm:configureFields",BulkEditFormActionInitializers:"bulkEditForm:configureActions",AuditLogsTableColumnInitializers:"auditLogsTable:configureColumns",AuditLogsTableActionColumnInitializers:"auditLogsTable:configureItemActions",AuditLogsTableActionInitializers:"auditLogsTable:configureActions",SnapshotBlockInitializers:"popup:snapshot:addBlock",AddBlockButton:"workflowManual:popup:configureUserInterface:addBlock",AddCustomFormField:"workflowManual:customForm:configureFields",AddActionButton:"workflowManual:form:configureActions"};function NF(e,t){return e===t||CB[e]===t}const Dc=(e,t,o)=>{ut.untracked(()=>{e[t]===void 0&&(e[t]=o)})},FB=(e,t,o)=>{typeof t.required>"u"&&(e.required=!!o.required)},kB=e=>{var t;const o=se(),n=y.useField(),l=y.useFieldSchema(),{uiSchema:i,defaultValue:r}=_t(),{isAllowToSetDefaultValue:s}=Qr(),c=jo(((t=l["x-component-props"])==null?void 0:t.component)||(i==null?void 0:i["x-component"])||"Input"),d=je(),u=qd(i==null?void 0:i["x-use-component-props"],e);return m.useEffect(()=>{if(!i)return;const p=o(i);if(Dc(n,"content",p["x-content"]),Dc(n,"title",p.title),Dc(n,"description",p.description),d!=null&&d.form){const g=s()?l.default||r:void 0;g!=null&&Dc(n,"initialValue",g)}if(!n.validator&&(p["x-validator"]||l["x-validator"])){const g=L.concat([],p["x-validator"]||[],l["x-validator"]||[]);n.validator=g}l["x-disabled"]===!0&&(n.disabled=!0),l["x-read-pretty"]===!0&&(n.readPretty=!0),FB(n,l,p),n.dataSource=p.enum,n.data=n.data||{},n.data.dataSource=p==null?void 0:p.enum;const h=o(p["x-component-props"])||{};n.componentProps=ee.merge(h,n.componentProps||{},u||{})},[i]),i?a.jsx(c,f(f({},e),u)):null},wB=e=>{var t;const o=y.useField(),n=y.useFieldSchema(),{uiSchema:l}=yk(),i=jo(((t=n["x-component-props"])==null?void 0:t.component)||(l==null?void 0:l["x-component"])||"Input"),r=qd(l==null?void 0:l["x-use-component-props"],e);if(m.useEffect(()=>{n["x-read-pretty"]===!0&&!o.readPretty&&(o.readPretty=!0),n["x-disabled"]===!0&&(o.disabled=!0),o.data=o.data||{},o.data.dataSource=l==null?void 0:l.enum},[o,n]),!l)return null;const s=f(f({},e),r);return dt(s.value)&&s.value===n.default&&(s.value=void 0),a.jsx(i,f({},s))},DF=y.connect(e=>{const t=y.useFieldSchema(),o=cV();return a.jsx(ac,{name:t.name,children:o?a.jsx(wB,f({},e)):a.jsx(kB,f({},e))})});DF.displayName="CollectionField";function PB(e){const{fieldSchema:t,schemaKey:o,parentSchemaKey:n,value:l,valueKeys:i}=e;if(o)L.set(t,o,l);else if(n){if(l==null)return t;typeof l=="object"?Object.keys(l).forEach(r=>{i&&!i.includes(r)||L.set(t,`${n}.${r}`,l[r])}):console.error("value must be object")}return t}const jB=e=>e,IB=(e="common")=>{const t=y.useFieldSchema(),{fieldSchema:o}=Fe()||{};return e==="field"&&o||t};function TB(e){const{name:t,useVisible:o,schemaKey:n,title:l,type:i="common",defaultValue:r,useDefaultValue:s=jB,useComponentProps:c}=e;return{name:t,useVisible:o,type:"switch",useComponentProps(){const d=IB(i),{dn:u}=X(),p=s(r),h=se(),{t:g}=K.useTranslation(),{fieldSchema:v}=Fe()||{},x=c==null?void 0:c();return{title:typeof l=="function"?l(g):h(l),checked:(x==null?void 0:x.checked)===void 0?!!L.get(d,n,p):x==null?void 0:x.checked,onChange(b){var S;(S=x==null?void 0:x.onChange)==null||S.call(x,b);const C=PB({fieldSchema:d,schemaKey:n,value:b});v?(u.emit("patch",{schema:C}),u.refresh()):u.deepMerge(C)}}}}}const MB=(e,t)=>O(void 0,[e,t],function*({operator:o,condition:n,variables:l,localVariables:i,conditionType:r,displayResult:s},c){switch(o){case"visible":return(yield Co({ruleGroup:n,variables:l,localVariables:i,conditionType:r},c))&&s.push("visible"),s;case"hidden":return(yield Co({ruleGroup:n,variables:l,localVariables:i,conditionType:r},c))&&s.push("hidden"),s;default:return null}}),AB=(e,t,o,n)=>{const l=ot().jsonLogic,[i,r]=m.useState(null),s=fo();return m.useEffect(()=>{O(void 0,null,function*(){const c=[];for(const d of e.filter(u=>!u.disabled))for(const u of d.actions||[])yield MB({operator:u.operator,condition:d.condition,variables:t,localVariables:o,conditionType:d.conditionType,displayResult:c},l);r(c)})},[e,n,s]),i};function Cu(e,t){e.forEach(o=>{var n;(n=o.actions)==null||n.forEach(l=>{t(l,o)})})}const RB=e=>{if(!e)return[];let t=(e==null?void 0:e["x-block-linkage-rules"])||[];return e.mapProperties(o=>{o["x-block-linkage-rules"]&&(t=o["x-block-linkage-rules"])}),t==null?void 0:t.filter(o=>!o.disabled)},hv=e=>{const t=y.useFieldSchema(),o=st(),n=gt(),{designable:l}=X(),i=y.useForm(),r=m.useMemo(()=>RB(t),[t]),[s,c]=m.useState(null),d=AB(r,o,n,s),u=(t==null?void 0:t["x-decorator"])==="FormItem"&&!i.readPretty&&r.length;return m.useEffect(()=>{if(u){const p=ee.uid();return setTimeout(()=>{i.addEffects(p,()=>{Cu(r,(h,g)=>ut.reaction(()=>{const v=Wd({linkageRules:r,localVariables:n}),x=j0({action:h,localVariables:n});return[v,x].map(b=>JSON.stringify(b)).join(",")},()=>{c(ee.uid())},{fireImmediately:!0,equals:L.isEqual}))})}),()=>{i.removeEffects(p)}}},[r,u]),r.length?d===null?null:L.last(d)==="hidden"?l?a.jsx("div",{style:{opacity:.3},children:e.children}):null:e.children:e.children},gv=m.createContext({});gv.displayName="DataBlockContext";const EF=m.createContext(null),NB=({children:e})=>{const[t,o]=m.useState(!1),n=m.useMemo(()=>({rerenderDataBlock:()=>{o(!0),setTimeout(()=>{o(!1)})}}),[]);return t?null:a.jsx(EF.Provider,{value:n,children:e})},qF=e=>{const{collection:t,association:o,allowNull:n=!1}=e,l=m.useMemo(()=>o?{Component:fR,name:o}:{Component:aU,name:t},[t,o]);return a.jsx(l.Component,{name:l.name,allowNull:n,children:e.children})},vv=ze(m.memo(e=>{const t=e,{collection:o,association:n,dataSource:l,children:i,hidden:r}=t,s=ne(t,["collection","association","dataSource","children","hidden"]),{dn:c}=X(),d=y.useFieldSchema();return r?null:a.jsx(Ki,{scopeId:d==null?void 0:d["x-uid"],type:"dataBlock",children:a.jsx(gv.Provider,{value:{dn:c,props:T(f({},s),{collection:o,association:n,dataSource:l})},children:a.jsx(es,{dataSource:l,children:a.jsx(qF,{collection:o,association:n,children:a.jsx(Ep,{children:a.jsx(hv,{children:a.jsx($M,{children:a.jsx($F,{children:a.jsx($B,{params:e.params,children:a.jsx(NB,{children:i})})})})})})})})})})}),{displayName:"DataBlockProvider"}),DB=()=>{const e=m.useContext(gv);if(!e)throw new Error("useDataBlock() must be used within a DataBlockProvider");return e},jt=()=>DB().props,EB=()=>{const e=m.useContext(EF);if(!e)throw new Error("useRerenderDataBlock() must be used within a DataBlockProvider");return e},Fu=m.createContext(null);Fu.displayName="BlockRequestRefContext";const ku=m.createContext(!1);ku.displayName="BlockRequestLoadingContext";const wu=m.createContext(null);wu.displayName="BlockRequestDataContext";function qB(e){const t=Jd(),o=Kh(),{action:n,params:l={},record:i,requestService:r,requestOptions:s,sourceId:c,association:d,parentRecord:u}=e,p=Te(),h=jt(),g=Or(h.dataSource),v=I0(d),[x,b]=m.useMemo(()=>[JSON.stringify(l),JSON.stringify(i)],[l,i]),{isBlockTemplate:S,templateFinished:C}=Bd(),k=P=>{var M;if(i)return Promise.resolve({data:i});if(!n)throw new Error("[nocobase]: The 'action' parameter is missing in the 'DataBlockRequestProvider' component");if(n==="get"&&L.isNil(l.filterByTk))return console.warn('[nocobase]: The "filterByTk" parameter is missing in the "DataBlockRequestProvider" component');const R=l.filterByTk===void 0?L.omit(l,"filterByTk"):l,N=f(f({},R),P);return(M=o[n])==null?void 0:M.call(o,N).then(D=>D.data)},F=(...P)=>S!=null&&S()&&!C?null:(r||k)(...P),j=Ue((...P)=>O(this,null,function*(){const[M,R]=yield Promise.all([F(...P),BB({sourceId:c,association:d,parentRecord:u,api:p,headers:g,sourceKey:v})]);return M&&(M.parentRecord=R==null?void 0:R.data),M}),T(f({},s),{manual:t==="manual",ready:!!n,refreshDeps:[n,x,b,o,d,u,c,C]}));return j._defaultParams=l,j}function BB(e){return O(this,arguments,function*({sourceId:t,association:o,parentRecord:n,api:l,headers:i,sourceKey:r}){if(n)return Promise.resolve({data:n});if(!o||!r||!t)return Promise.resolve({data:void 0});const s=`${o.split(".")[0]}:get?filter[${r}]=${t}`;return(yield l.request({url:s,headers:i})).data})}const BF=e=>{var t,o,n,l,i,r;const s=m.useRef(e.recordRequest),c=m.useRef((t=e.recordRequest)==null?void 0:t.data),{active:d}=Mi(),u=m.useRef(d),p=m.useDeferredValue(d),h=jt();return p&&!u.current&&(L.isNil(h.dataLoadingMode)||h.dataLoadingMode==="auto")&&((o=e.recordRequest)==null||o.refresh()),p&&u.current&&!((n=e.recordRequest)!=null&&n.loading)&&!L.isEqual(c.current,(l=e.recordRequest)==null?void 0:l.data)&&(c.current=(i=e.recordRequest)==null?void 0:i.data),p!==u.current&&(u.current=p),s.current=e.recordRequest,a.jsx(Fu.Provider,{value:s,children:a.jsx(ku.Provider,{value:(r=e.recordRequest)==null?void 0:r.loading,children:a.jsx(wu.Provider,{value:c.current,children:e.children})})})},$F=m.memo(({children:e})=>{var t,o;const n=jt(),{action:l,filterByTk:i,sourceId:r,params:s=A0,association:c,collection:d,record:u,parentRecord:p,requestOptions:h,requestService:g}=n,v=m.useMemo(()=>T(f({},s),{filterByTk:i||s.filterByTk}),[i,s]),x=qB({action:l,sourceId:r,record:u,association:c,collection:d,requestOptions:h,requestService:g,params:v,parentRecord:p}),b=(t=x.data)==null?void 0:t.parentRecord,S=m.useMemo(()=>b&&new fn({isNew:!1,data:b instanceof fn?b.data:b}),[b]);return a.jsx(BF,{recordRequest:x,children:l!=="list"?a.jsx(Bl,{isNew:l==null,record:((o=x.data)==null?void 0:o.data)||u,parentRecord:S||p,children:e}):a.jsx(Bl,{isNew:!1,record:null,parentRecord:S||p,children:e})})});$F.displayName="DataBlockRequestProvider";const Un=()=>{const e=m.useContext(Fu),t=m.useContext(ku),o=m.useContext(wu);return m.useMemo(()=>e?T(f({},e.current),{loading:t,data:o}):null,[e,o,t])},ua=()=>{const e=m.useContext(Fu);return m.useMemo(()=>({getDataBlockRequest:()=>e?e.current:null}),[e])},As=()=>m.useContext(wu),xv=m.createContext(null);xv.displayName="FilterContext";const OF=m.memo(({children:e})=>{const t=m.useRef([]),o=m.useCallback(i=>{typeof i=="function"?t.current=i(t.current):t.current=i},[]),n=m.useCallback(()=>t.current,[]),l=m.useMemo(()=>({getDataBlocks:n,setDataBlocks:o}),[n,o]);return a.jsx(xv.Provider,{value:l,children:e})});OF.displayName="FilterBlockProvider";const $B=({children:e,params:t})=>{const o=ve(),{recordDataBlocks:n}=Jl(),{getDataBlockRequest:l}=ua(),i=y.useField(),r=y.useFieldSchema(),s=lg(),c=m.useRef(null),d=Jd(),u=i&&i.decoratorType!=="FilterFormBlockProvider"&&i.decoratorType!=="FormBlockProvider"&&i.decoratorProps.blockType!=="filter",p=m.useCallback(()=>{const h=l();n({uid:r["x-uid"],title:i.componentProps.title,doFilter:h.runAsync,collection:o,associatedFields:s,foreignKeyFields:o==null?void 0:o.getFields("isForeignKey"),defaultFilter:(t==null?void 0:t.filter)||{},service:h,dom:c.current,dataLoadingMode:d,clearFilter(g){var v,x,b;const S=((v=this.service.params)==null?void 0:v[0])||{},C=((b=(x=this.service.params)==null?void 0:x[1])==null?void 0:b.filters)||{};delete C[g];const k=Zt([...Object.values(C).map(F=>yt(F)),(t==null?void 0:t.filter)||{}]);this.service.run(T(f({},S),{page:1,filter:k}),{filters:C})},clearData(){this.service.mutate(void 0)},clearSelection(){var g,v;i&&((v=(g=i.data)==null?void 0:g.clearSelectedRowKeys)==null||v.call(g))},highlightBlock(){var g;const v=c.current;if(!v)return;const x=v.querySelector(".ant-nb-schema-toolbar");x&&x.classList.remove("hidden"),v.style.boxShadow="0 3px 12px rgba(0, 0, 0, 0.15)",v.style.transition="box-shadow 0.3s ease, transform 0.2s ease",(g=v.scrollIntoView)==null||g.call(v,{behavior:"smooth",block:"start"})},unhighlightBlock(){const g=c.current;if(!g)return;const v=g.querySelector(".ant-nb-schema-toolbar");v&&v.classList.add("hidden"),g.style.boxShadow="none",g.style.transition="box-shadow 0.3s ease, transform 0.2s ease"}})},[s,o,d,r,t==null?void 0:t.filter,n,l,i]);return m.useEffect(()=>{u&&p()},[p,u]),a.jsx("div",{ref:c,children:e})},Jl=()=>{const e=m.useContext(xv),t=Wr(),o=m.useCallback(()=>(e==null?void 0:e.getDataBlocks())||[],[e]),n=m.useCallback(i=>{t.recordDataBlocks(i);const r=e==null?void 0:e.getDataBlocks().find(s=>s.uid===i.uid);if(r){Object.assign(r,i);return}e==null||e.setDataBlocks(s=>[...s,i])},[e]),l=m.useCallback(i=>{t.removeDataBlock(i),!(e!=null&&e.getDataBlocks().every(r=>r.uid!==i))&&(e==null||e.setDataBlocks(r=>r.filter(s=>s.uid!==i)))},[e]);return e?{recordDataBlocks:n,getDataBlocks:o,removeDataBlock:l,inProvider:!0}:{inProvider:!1,recordDataBlocks:L.noop,getDataBlocks:o,removeDataBlock:L.noop}},OB=()=>{const e=y.useField(),{t}=K.useTranslation();return a.jsxs(bt,{children:[a.jsx(so,{title:t("Edit markdown"),onClick:()=>{e.editable=!0}}),a.jsx(tk,{}),a.jsx(qo,{}),a.jsx(Bt,{}),a.jsx(Ot,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};class LB extends HTMLElement{constructor(){super(),A(this,"root"),this.attachShadow({mode:"open"}),this.root=null}getProps(t,o={}){return[...t].filter(n=>n.name!=="style").map(n=>this.convert(o,n.name,n.value)).reduce((n,l)=>T(f({},n),{[l.name]:l.value}),{})}convert(t,o,n){const l=Object.keys(t).find(r=>r.toLowerCase()==o);let i=n;return n==="true"||n==="false"?i=n=="true":!isNaN(n)&&n!==""?i=+n:/^{.*}/.exec(n)&&(i=JSON.parse(n)),{name:l||o,value:i}}connectedCallback(){const t=f({},this.getProps(this.attributes));this.root=yh.createRoot(this.shadowRoot),this.root.render(a.jsx(I.QRCode,f({},t)))}disconnectedCallback(){this.root.unmount()}}function VB(){customElements.get("qr-code")||customElements.define("qr-code",LB)}const LF=Nt("nb-markdown",(e,{isDarkTheme:t})=>{const{componentCls:o}=e,n=new pl.TinyColor(e.colorFillAlter).onBackground(e.colorBgContainer).toHexShortString(),l={lineHeight:"inherit","&.nb-markdown-default":{"pre code.hljs":{display:"block",overflowX:"auto",padding:"1em"},"code.hljs":{padding:"3px 5px"},":not(pre) code":{padding:"2px 5px",color:"#d56161",background:e.colorFillQuaternary,border:`1px solid ${e.colorBorder}`,borderRadius:e.borderRadiusSM},blockquote:{borderLeft:"4px solid #ccc",paddingLeft:"20px",marginLeft:"0",color:"#666",fontStyle:"italic"},img:{maxWidth:"100%"},".hljs":{background:"#f8f8f8",color:"#444"},".hljs-comment":{color:"#697070"},".hljs-punctuation,.hljs-tag":{color:"#444a"},".hljs-tag .hljs-attr,.hljs-tag .hljs-name":{color:"#444"},".hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag":{fontWeight:700},".hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type":{color:"#800"},".hljs-section,.hljs-title":{color:"#800",fontWeight:700},".hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable":{color:"#ab5656"},".hljs-literal":{color:"#695"},".hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code":{color:"#397300"},".hljs-meta":{color:"#1f7199"},".hljs-meta .hljs-string":{color:"#38a"},".hljs-emphasis":{fontStyle:"italic"},".hljs-strong":{fontWeight:700}},"&.nb-markdown-table":{table:{borderCollapse:"collapse",width:"100%",fontFamily:"Arial, sans-serif",marginBottom:"1.5rem"},"th, td":{borderBottom:`1px solid ${e.colorBorderSecondary}`,padding:`${e.paddingContentVertical}px ${e.paddingContentHorizontal}px`,textAlign:"left"},th:{backgroundColor:n,fontWeight:"bold",color:e.colorText},"tr:hover":{backgroundColor:e.colorFillTertiary},"tr:last-child td":{borderBottom:"none"},"tr:first-child th":{borderTop:"none"}}},i={"&.nb-markdown-default":{"pre code.hljs":{display:"block",overflowX:"auto",padding:"1em"},"code.hljs":{padding:"3px 5px"},":not(pre) code":{padding:"2px 5px",color:"#d56161",background:e.colorFillQuaternary,border:`1px solid ${e.colorBorder}`,borderRadius:e.borderRadiusSM},".hljs":{color:"#adbac7",background:"#22272e"},".hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_":{color:"#f47067"},".hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_":{color:"#dcbdfb"},".hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable":{color:"#6cb6ff"},".hljs-meta .hljs-string,.hljs-regexp,.hljs-string":{color:"#96d0ff"},".hljs-built_in,.hljs-symbol":{color:"#f69d50"},".hljs-code,.hljs-comment,.hljs-formula":{color:"#768390"},".hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag":{color:"#8ddb8c"},".hljs-subst":{color:"#adbac7"},".hljs-section":{color:"#316dca",fontWeight:700},".hljs-bullet":{color:"#eac55f"},".hljs-emphasis":{color:"#adbac7",fontStyle:"italic"},".hljs-strong":{color:"#adbac7",fontWeight:700},".hljs-addition":{color:"#b4f1b4",backgroundColor:"#1b4721"},".hljs-deletion":{color:"#ffd8d3",backgroundColor:"#78191b"}},"&.nb-markdown-table":{table:{borderCollapse:"collapse",width:"100%",fontFamily:"Arial, sans-serif",marginBottom:"1.5rem"},"th, td":{borderBottom:`1px solid ${e.colorBorderSecondary}`,padding:`${e.paddingContentVertical}px ${e.paddingContentHorizontal}px`,textAlign:"left"},th:{backgroundColor:n,fontWeight:"bold",color:e.colorText},"tr:hover":{backgroundColor:e.colorFillTertiary},"tr:last-child td":{borderBottom:"none"},"tr:first-child th":{borderTop:"none"}}};return{[o]:f({lineHeight:e.lineHeight,"& > *:last-child":{marginBottom:"0"},".ant-description-textarea, .ant-description-input":{lineHeight:e.lineHeight},".field-interface-datetime":{minWidth:"100px"}},t?i:l)}}),VF=L.memoize(e=>O(void 0,null,function*(){return e&&(yield Promise.resolve().then(()=>require("./md-BbvRKckr-IQIU5F3r.js"))).default.render(e)}));function zB(e){const[t,o]=m.useState(""),[n,l]=m.useState(!0);return m.useEffect(()=>{l(!0),VF(e).then(i=>{o(i),l(!1)}).catch(i=>console.log(i))},[e]),{html:t,loading:n}}function _B(e){const t=e;let o=document.createElement("div");o.innerHTML=t;const n=o.innerText;return o=null,(n==null?void 0:n.replace(/[\n\r]/g,""))||""}const KB=e=>{const{scope:t}=e,{t:o,i18n:n}=K.useTranslation(),[l,i]=m.useState(e.defaultValue),r=m.useRef(null),[s,c]=m.useState([]),[d,u]=m.useState(null);m.useEffect(()=>{c(t)},[t]),m.useEffect(()=>{var h,g;const v=(g=(h=r==null?void 0:r.current)==null?void 0:h.resizableTextArea)==null?void 0:g.textArea;d&&v&&v.setSelectionRange(d,d)},[d]);const p=m.useCallback(function(h){var g;const v=h.filter(j=>!!j.trim()),{current:x}=r,b=(g=x==null?void 0:x.resizableTextArea)==null?void 0:g.textArea;if(!b||!v)return;x.focus();const S=`{{${h.join(".")}}}`,C=b.selectionStart||0,k=l.substring(0,C)+S+l.substring(C,l.length),F=C+S.length;i(k),u(F)},[l]);return a.jsxs("div",{className:"mb-markdown",style:{position:"relative",paddingTop:"20px"},children:[a.jsx(I.Input.TextArea,T(f({ref:r,autoSize:{minRows:3}},e),{value:l,onChange:h=>{i(h.target.value)},style:{paddingBottom:"40px"}})),a.jsxs(a.Fragment,{children:[a.jsxs("span",{style:{marginLeft:".25em"},className:"ant-formily-item-extra",children:[o("Syntax references"),":"]}),a.jsx("a",{href:`https://${n.language==="zh-CN"?"docs-cn":"docs"}.nocobase.com/handbook/template-handlebars`,target:"_blank",rel:"noreferrer",children:"Handlebars.js"})]}),a.jsx("div",{style:{position:"absolute",top:21,right:1},children:a.jsx(ca,{options:s,setOptions:c,onInsert:p})}),a.jsxs(I.Space,{style:{position:"absolute",bottom:30,right:5},children:[a.jsx(I.Button,{onClick:h=>{var g;(g=e.onCancel)==null||g.call(e,h)},children:o("Cancel")}),a.jsx(I.Button,{type:"primary",onClick:()=>{var h;(h=e.onSubmit)==null||h.call(e,l)},children:o("Save")})]})]})},UB=()=>{const{token:e}=I.theme.useToken(),t=Ug();if(t)return t-2*e.paddingLG};function HB(e){const t=/\{\{\$nForm\.([\w.]+)\}\}/g;return[...e.matchAll(t)].map(o=>o[1])}function GB(e,t){const o={};for(const n of t){const l=n.split(".");let i=e;for(const r of l)if(i&&typeof i=="object"&&r in i)i=i[r];else{i=void 0;break}o[n]=i}return o}const WB=ze(y.observer(e=>{const{isDarkTheme:t}=Go(),{componentCls:o,hashId:n}=LF({isDarkTheme:t}),{content:l,className:i}=e,r=y.useField(),s=y.useFieldSchema(),{dn:c}=X(),{onSave:d,onCancel:u,form:p}=e,h=fo(),[g,v]=m.useState(""),x=st(),b=gt(),{engine:S}=(s==null?void 0:s["x-decorator-props"])||{},[C,k]=m.useState(!1),{t:F,i18n:j}=K.useTranslation(),P=y.useForm(),M=HB(l),[R,N]=m.useState(null);m.useEffect(()=>{if(M.length>0){const $=ee.uid();return setTimeout(()=>{P.addEffects($,()=>ut.reaction(()=>{const q=GB(P.values,M);return JSON.stringify(q)},()=>{N(ee.uid())},{fireImmediately:!0,equals:L.isEqual}))}),()=>{P.removeEffects($)}}},[]),m.useEffect(()=>{k(!0),O(void 0,null,function*(){setTimeout(()=>O(void 0,null,function*(){const $=yield Ud(S,l,x,b,VF,F);v($)})),k(!1)})},[l,x,b,S,R]);const D=UB(),B=ms({collectionField:{uiSchema:s},form:p,record:h,uiSchema:s,noDisabled:!0});return m.useEffect(()=>{VB()},[]),C?a.jsx(I.Spin,{}):r!=null&&r.editable?a.jsx(KB,T(f({scope:B},e),{className:!0,defaultValue:l,onCancel:()=>{r.editable=!1,u==null||u()},onSubmit:$=>O(void 0,null,function*(){r.editable=!1,s["x-component-props"]!=null||(s["x-component-props"]={}),s["x-component-props"].content=$,r.componentProps.content=$,d==null||d(s),c.emit("patch",{schema:{"x-uid":s["x-uid"],"x-component-props":{content:$}}})})})):a.jsx("div",{className:fe([o,n,"nb-markdown nb-markdown-default nb-markdown-table",i]),style:T(f({},e.style),{height:D||"100%",overflowY:D?"auto":"null"}),dangerouslySetInnerHTML:{__html:g}})}),{displayName:"MarkdownVoid"}),zF=e=>{const t=at(),o=y.useFieldSchema();return a.jsx(Ki,{scopeId:o==null?void 0:o["x-uid"],type:"markdownBlock",children:a.jsx(Wt,T(f({},t),{collectionField:!0,children:a.jsx(WB,f({},e))}))})};zF.Designer=OB;const Pu=y.connect(I.Input.TextArea,y.mapProps((e,t)=>T(f({autoSize:{maxRows:10,minRows:3}},e),{suffix:a.jsx("span",{children:t!=null&&t.loading||t!=null&&t.validating?a.jsx(te.LoadingOutlined,{}):e.suffix})})),y.mapReadPretty(e=>a.jsx(Rs,f({},e)))),Rs=e=>{const{isDarkTheme:t}=Go(),{wrapSSR:o,hashId:n,componentCls:l}=LF({isDarkTheme:t}),{html:i="",loading:r}=zB(e.value),s=m.useMemo(()=>_B(i),[i]);if(r)return o(a.jsx(I.Spin,{}));const c=a.jsx("div",{className:`${n} ${l} nb-markdown nb-markdown-default nb-markdown-table`,dangerouslySetInnerHTML:{__html:i}});return o(a.jsx(tt.TextArea,T(f({},e),{autop:!1,text:s,value:c})))};Pu.Void=zF;const Ns=m.createContext({}),Xl=m.forwardRef((e,t)=>{var o=e,{children:n}=o,l=ne(o,["children"]);const{token:i}=It(),r=l,{title:s,description:c}=r,d=ne(r,["title","description"]),u=m.useMemo(()=>({marginBottom:i.marginBlock,height:"100%"}),[i.marginBlock]),[p,h]=m.useState(0),g=m.useRef(null),{t:v}=K.useTranslation(),x=y.useFieldSchema(),b=x==null?void 0:x["x-block-linkage-rules"];m.useEffect(()=>{const k=setTimeout(()=>{if(g.current){const F=c?g.current.parentElement.parentElement.parentElement.offsetHeight:i.fontSizeLG*i.lineHeightLG+i.padding*2-1;h(F)}else p&&h(0)},500);return()=>clearTimeout(k)},[s,c]);const S=(s||c)&&a.jsxs("div",{ref:g,style:{padding:"8px 0px 8px"},children:[a.jsxs("span",{children:[" ",v(s,{ns:Qt})]}),c&&a.jsx(Rs,{value:v(c,{ns:Qt}),style:{overflowWrap:"break-word",whiteSpace:"normal",fontWeight:400,color:i.colorTextDescription,borderRadius:"4px"}})]}),C=a.jsx(Ns.Provider,{value:{titleHeight:p},children:a.jsx(I.Card,T(f({ref:t,variant:"borderless",style:u},d),{title:S,children:n}))});return b?a.jsx(hv,{children:C}):C});Xl.displayName="BlockItemCard";const sl=()=>{var e,t,o;const n=y.useFieldSchema(),l=cl(n),i=(e=ft())==null?void 0:e.fieldSchema,r=m.useMemo(()=>ju(i||n),[]),{disablePageHeader:s,enablePageTabs:c,hidePageTitle:d}=(r==null?void 0:r["x-component-props"])||{},{titleHeight:u}=m.useContext(Ns)||{},{allAccessRoutes:p}=un(),h=is(),g=m.useMemo(()=>Is(h,p),[h,p]);return{heightProps:T(f({},l==null?void 0:l["x-component-props"]),{title:((t=l==null?void 0:l["x-component-props"])==null?void 0:t.title)||((o=l==null?void 0:l["x-component-props"])==null?void 0:o.description),disablePageHeader:s,enablePageTabs:(g==null?void 0:g.enableTabs)||c,hidePageTitle:d,titleHeight:u})}},ju=e=>e?e["x-component"]==="Page"?e:ju(e.parent):null,cl=e=>e?["BlockItem","CardItem"].includes(e["x-component"])?e:cl(e.parent):null,fv=({association:e})=>{var t;const o=Dt(),n=ln(),l=Ye(),i=ve();if(!e)return;const r=l.getCollection(e.split(".")[0]);return i.name===r.name||(t=i.getParentCollectionsName)!=null&&t.call(i).includes(r.name)?o:n},YB=()=>{const e=y.useForm();return{onClick(){console.log("usePickActionProps",e.values)}}};function JB(e,t){const o=/\{\{\s*((\w+\.?)+)\s*\}\}/g;return e.replace(o,function(n,l){return gi(t,l)||""})}function XB(e){const t=L.cloneDeep(e.values),o=[];return e.query("*").forEach(n=>{n&&o.push(n)}),L.uniq(o.filter(n=>{var l,i;const r=((l=n.path)==null?void 0:l.segments)||[],s=r.length<=1?r.join("."):r.slice(0,-1).join(".");return((i=n==null?void 0:n.componentProps)==null?void 0:i.readOnlySubmit)&&!gi(t,s)[n==null?void 0:n.componentProps.filterTargetKey]}).map(n=>{var l;const i=((l=n.path)==null?void 0:l.segments)||[];return i.length<=1?i.join("."):i.slice(0,-1).join(".")})).forEach((n,l)=>{(l!==0||n.includes("."))&&!t[n]&&L.unset(t,n)}),t}function Ds({filterByTk:e,field:t,form:o,fieldNames:n,getField:l,resource:i,actionFields:r}){if(e&&r){const s=Object.keys(o.values).filter(c=>{const d=l(c);return!r.includes(c)&&["hasOne","hasMany","belongsTo","belongsToMany"].includes(d==null?void 0:d.type)});return By(f({},o.values),s)}return XB(o)}function _F(e){const t=y.useForm(),o=e??t,n=Pn(),{field:l,resource:i}=pt(),{fields:r,getField:s,getTreeParentField:c,name:d}=re(),u=r.map(S=>S.name),{fieldSchema:p}=ke(),{getActiveFieldsName:h}=Vn()||{},g=st(),v=gt({currentForm:o}),x=y.useFieldSchema(),b=Eh();return m.useCallback(()=>O(this,null,function*(){var S,C,k,F;const{assignedValues:j={},overwriteValues:P}=(S=x==null?void 0:x["x-action-settings"])!=null?S:{},M=Ds({filterByTk:n,field:l,form:o,fieldNames:u,getField:s,resource:i,actionFields:(h==null?void 0:h("form"))||[]}),R={},N=Object.keys(j).map(D=>O(this,null,function*(){const B=j[D],$=s(D);if(dt(B)){const{value:q}=(yield g==null?void 0:g.parseVariable(B,v))||{};R[D]=il(q,{targetCollectionField:$})}else B!==""&&(R[D]=B)}));if(yield Promise.all(N),(C=p==null?void 0:p["x-component-props"])==null?void 0:C.addChild){const D=c();M[(k=D==null?void 0:D.name)!=null?k:"parent"]=b,M[(F=D==null?void 0:D.foreignKey)!=null?F:"parentId"]=b==null?void 0:b.id}return f(f(f({},M),P),R)}),[x,l,u,p,n,o,h,s,c,v,d,i,b,g])}const bv=()=>{var e;const t=Pn(),o=fo(),n=y.useForm(),{field:l,resource:i}=pt(),{setVisible:r,setSubmitted:s,setFormValueChanged:c}=ke(),d=Eo(),u=y.useFieldSchema(),p=y.useField(),h=se(),{modal:g}=I.App.useApp(),{t:v}=K.useTranslation(),{updateAssociationValues:x}=je(),b=_F(),S=o.isNew?p.componentProps.saveMode||"create":"update",C=((e=p.componentProps.filterKeys)==null?void 0:e.checked)||[],k=gt(),F=st();return{onClick(){return O(this,null,function*(){var j,P;const{onSuccess:M,skipValidator:R,triggerWorkflows:N}=(j=u==null?void 0:u["x-action-settings"])!=null?j:{},{manualClose:D,redirecting:B,redirectTo:$,successMessage:q,actionAfterSuccess:E}=M||{};R||(yield n.submit());const U=yield b();p.data=l.data||{},p.data.loading=!0;try{const V=yield i[S]({values:U,filterKeys:C,filterByTk:t,triggerWorkflows:N!=null&&N.length?N.map(_=>[_.workflowKey,_.context].filter(Boolean).join("!")).join(","):void 0,updateAssociationValues:x});let z=$;if($&&(z=yield Ka($,{variables:F,localVariables:[...k,{name:"$record",ctx:new Proxy((P=V==null?void 0:V.data)==null?void 0:P.data,{})}]})),(E==="previous"||!E&&B!==!0)&&(r==null||r(!1)),s==null||s(!0),c==null||c(!1),p.data.loading=!1,p.data.data=V,!q){I.message.success(v("Saved successfully")),yield Wc(n),(B&&!E||E==="redirect")&&z&&(de.isURL(z)?window.location.href=z:d(z));return}D?g.success({title:h(q),onOk:()=>O(this,null,function*(){yield Wc(n),(B&&!E||E==="redirect")&&z&&(de.isURL(z)?window.location.href=z:d(z))})}):(I.message.success(h(q)),yield Wc(n),(B&&!E||E==="redirect")&&z&&(de.isURL(z)?window.location.href=z:d(z)))}catch{p.data.loading=!1}})}}},KF=()=>{var e;const t=y.useForm(),{field:o,resource:n,__parent:l}=pt(),{setVisible:i,fieldSchema:r,setSubmitted:s}=ke(),c=y.useFieldSchema(),d=y.useField(),{fields:u,getField:p,getTreeParentField:h,name:g}=re(),v=se(),x=Pn(),b=$e(),S=st(),C=gt({currentForm:t}),{getActiveFieldsName:k}=Vn()||{},F=d.componentProps.saveMode||"create",j=((e=d.componentProps.filterKeys)==null?void 0:e.checked)||[];return{onClick(){return O(this,null,function*(){var P,M,R,N,D,B;const $=u.map(Y=>Y.name),{assignedValues:q={},onSuccess:E,overwriteValues:U,skipValidator:V,triggerWorkflows:z}=(P=c==null?void 0:c["x-action-settings"])!=null?P:{},_=(M=r==null?void 0:r["x-component-props"])==null?void 0:M.addChild,{successMessage:H}=E||{},G={},W=Object.keys(q).map(Y=>O(this,null,function*(){const J=q[Y],ae=p(Y);if(dt(J)){const{value:le}=(yield S==null?void 0:S.parseVariable(J,C))||{};G[Y]=il(le,{targetCollectionField:ae})}else J!==""&&(G[Y]=J)}));yield Promise.all(W),V||(yield t.submit());const Q=Ds({filterByTk:x,field:o,form:t,fieldNames:$,getField:p,resource:n,actionFields:(k==null?void 0:k("form"))||[]});if(_){const Y=h();Q[(R=Y==null?void 0:Y.name)!=null?R:"parent"]=b,Q[(N=Y==null?void 0:Y.foreignKey)!=null?N:"parentId"]=b.id}d.data=o.data||{},d.data.loading=!0;try{const Y=yield n[F]({values:f(f(f({},Q),U),G),filterKeys:j,triggerWorkflows:z!=null&&z.length?z.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):void 0});if(d.data.loading=!1,d.data.data=Y,(B=(D=l==null?void 0:l.service)==null?void 0:D.refresh)==null||B.call(D),i==null||i(!1),s==null||s(!0),!H)return;I.message.success(v(H))}catch{d.data.data=null,d.data.loading=!1}})}}},pa=e=>{for(;e;){if(e["x-filter-targets"])return{targets:e["x-filter-targets"],uid:e["x-uid"]};e=e.parent}return{}},nh=(e,t)=>{for(;e;){if(e["x-filter-targets"]){e["x-filter-targets"]=t;return}e=e.parent}},UF=()=>{const e=y.useForm(),{getDataBlocks:t}=Jl(),o=Ye(),{getOperators:n}=Ei(),l=y.useFieldSchema(),{name:i}=ve(),{targets:r=[],uid:s}=m.useMemo(()=>pa(l),[l]),c=m.useCallback(()=>yt(MA(e.values,n(),o.getCollectionField.bind(o),i)),[e.values,o,n,i]),d=m.useCallback((...u)=>O(void 0,[...u],function*({doNothingWhenFilterIsEmpty:p=!1}={}){try{yield Promise.all(t().map(h=>O(void 0,null,function*(){var g,v,x,b;if(!r.find(F=>F.uid===h.uid))return;const S=((g=h.service.params)==null?void 0:g[0])||{},C=((x=(v=h.service.params)==null?void 0:v[1])==null?void 0:x.filters)||{};C[s]=c();const k=Zt([...Object.values(C).map(F=>yt(F)),h.defaultFilter]);if(L.isEmpty(C[s])&&((b=h.clearSelection)==null||b.call(h)),!(p&&L.isEmpty(C[s])))return h.dataLoadingMode==="manual"&&L.isEmpty(C[s])?h.clearData():(L.set(h.service.params,"1.filters",C),h.doFilter(T(f({},S),{page:1,filter:k}),{filters:C}))})))}catch(h){console.error(h)}}),[t,c,r,s]);return m.useEffect(()=>{setTimeout(()=>{d({doNothingWhenFilterIsEmpty:!0})},500)},[d]),{doFilter:d,getFilterFromCurrentForm:c}},QB=()=>{const{doFilter:e}=UF(),t=y.useField();return t.data=t.data||{},{onClick(){return O(this,null,function*(){t.data.loading=!0,yield e(),t.data.loading=!1})}}},ZB=()=>{const e=y.useForm(),t=y.useFieldSchema(),{getDataBlocks:o}=Jl(),{targets:n,uid:l}=pa(t),{doFilter:i,getFilterFromCurrentForm:r}=UF();return{doReset:()=>O(void 0,null,function*(){var s;if(yield e.reset(void 0,{forceClear:!!((s=t==null?void 0:t["x-component-props"])!=null&&s.clearDefaultValue)}),L.isEmpty(r()))return u$({getDataBlocks:o,targets:n,uid:l});yield i()})}},e$=()=>{const e=y.useField(),{doReset:t}=ZB();return e.data=e.data||{},{onClick(){return O(this,null,function*(){e.data.loading=!0,yield t(),e.data.loading=!1})}}},t$=()=>{const{resource:e,__parent:t,field:o,service:n}=pt(),l=Pn(),i=y.useFieldSchema(),r=y.useField(),s=Eo(),c=se(),d=y.useForm(),{modal:u}=I.App.useApp(),p=st(),h=gt({currentForm:d}),{name:g,getField:v}=re(),{setVisible:x}=ke();return{onClick(b,S){return O(this,null,function*(){var C,k,F,j;const{assignedValues:P={},onSuccess:M,skipValidator:R,triggerWorkflows:N}=(C=i==null?void 0:i["x-action-settings"])!=null?C:{},{manualClose:D,redirecting:B,redirectTo:$,successMessage:q,actionAfterSuccess:E}=M||{},U={},V=Object.keys(P).map(z=>O(this,null,function*(){const _=P[z],H=v(z);if(dt(_)){const{value:G}=(yield p==null?void 0:p.parseVariable(_,h))||{};U[z]=il(G,{targetCollectionField:H})}else _!==""&&(U[z]=_)}));if(yield Promise.all(V),R===!1&&(yield d.submit()),r.data=r.data||{},!r.data.loading){r.data.loading=!0;try{const z=yield e.update({filterByTk:l,values:f({},U),triggerWorkflows:N!=null&&N.length?N.map(H=>[H.workflowKey,H.context].filter(Boolean).join("!")).join(","):void 0});let _=$;if($&&(_=yield Ka($,{variables:p,localVariables:[...h,{name:"$record",ctx:new Proxy((k=z==null?void 0:z.data)==null?void 0:k.data,{})}]})),(E==="previous"||!E&&B!==!0)&&(x==null||x(!1)),S&&(S==null||S()),e instanceof mu||(j=(F=t==null?void 0:t.service)==null?void 0:F.refresh)==null||j.call(F),!q)return;D?u.success({title:c(q),onOk:()=>O(this,null,function*(){(B&&!E||E==="redirect")&&_&&(de.isURL(_)?window.location.href=_:s(_))})}):(I.message.success(c(q)),(B&&!E||E==="redirect")&&_&&(de.isURL(_)?window.location.href=_:s(_)))}catch(z){console.error(z)}finally{r.data.loading=!1}}})}}},o$=()=>{var e,t,o,n;const{field:l,resource:i,__parent:r,service:s}=pt(),c=m.useContext(y.SchemaExpressionScopeContext),d=y.useFieldSchema(),u=Fo(),{rowKey:p}=u,h=(n=(o=(t=(e=u.field)==null?void 0:e.data)==null?void 0:t.selectedRowKeys)!=null?o:c==null?void 0:c.selectedRecordKeys)!=null?n:{},g=Eo(),v=se(),{t:x}=K.useTranslation(),b=y.useField(),{modal:S}=I.App.useApp(),C=st();$e();const{name:k,getField:F}=re(),j=gt(),{setVisible:P}=ke();return{onClick(){return O(this,null,function*(){var M;const{assignedValues:R={},onSuccess:N,updateMode:D}=(M=d==null?void 0:d["x-action-settings"])!=null?M:{},{manualClose:B,redirecting:$,redirectTo:q,successMessage:E,actionAfterSuccess:U}=N||{};b.data=l.data||{},b.data.loading=!0;const V={},z=Object.keys(R).map(_=>O(this,null,function*(){const H=R[_],G=F(_);if(dt(H)){const{value:W}=(yield C==null?void 0:C.parseVariable(H,j))||{};V[_]=il(W,{targetCollectionField:G})}else H!==""&&(V[_]=H)}));yield Promise.all(z),(U==="previous"||!U&&$!==!0)&&(P==null||P(!1)),S.confirm({title:x("Bulk update"),content:x(D==="selected"?"Update selected data?":"Update all data?"),onOk(){return O(this,null,function*(){var _,H,G,W;const{filter:Q}=(H=(_=s.params)==null?void 0:_[0])!=null?H:{},Y={values:f({},V),filter:Q,forceUpdate:!1};if(D==="selected"){if(!(h!=null&&h.length)){I.message.error(x("Please select the records to be updated")),b.data.loading=!1;return}Y.filter={$and:[{[p||"id"]:{$in:h}}]}}Y.filter||(Y.forceUpdate=!0);try{yield i.update(Y)}catch{}finally{b.data.loading=!1}i instanceof mu||(W=(G=r==null?void 0:r.service)==null?void 0:G.refresh)==null||W.call(G),E&&(B?S.success({title:v(E),onOk:()=>O(this,null,function*(){($&&!U||U==="redirect")&&q&&(de.isURL(q)?window.location.href=q:g(q))})}):(I.message.success(v(E)),($&&!U||U==="redirect")&&q&&(de.isURL(q)?window.location.href=q:g(q))))})},onCancel(){return O(this,null,function*(){b.data.loading=!1})}})})}}},n$=()=>{var e;const t=Te(),o=Eo(),n=Pn(),l=y.useFieldSchema(),i=se(),r=y.useForm(),{fields:s,getField:c}=re(),{field:d,resource:u,__parent:p,service:h}=pt(),g=$e(),v=fg(),x=(e=v==null?void 0:v.data)==null?void 0:e.data,b=y.useField(),{t:S}=K.useTranslation(),{setVisible:C}=ke(),{modal:k}=I.App.useApp(),{getActiveFieldsName:F}=Vn()||{};return{onClick(){return O(this,null,function*(){var j,P,M,R;const{skipValidator:N,onSuccess:D,requestSettings:B}=(j=l==null?void 0:l["x-action-settings"])!=null?j:{},{manualClose:$,redirecting:q,redirectTo:E,successMessage:U,actionAfterSuccess:V}=D||{},z=l==null?void 0:l["x-action"];if(!B.url)return;N!==!0&&z==="customize:form:request"&&(yield r.submit());const _=B.headers?JSON.parse(B.headers):{},H=B.params?JSON.parse(B.params):{},G=B.data?JSON.parse(B.data):{};if(z==="customize:form:request"&&["POST","PUT","PATCH"].includes(B.method)){const Q=s.map(J=>J.name),Y=Ds({filterByTk:n,field:d,form:r,fieldNames:Q,getField:c,resource:u,actionFields:(F==null?void 0:F("form"))||[]});Object.assign(G,Y)}const W={url:JB(B.url,{currentRecord:g,currentUser:x}),method:B.method,headers:de.parse(_)({currentRecord:g,currentUser:x}),params:de.parse(H)({currentRecord:g,currentUser:x}),data:de.parse(G)({currentRecord:g,currentUser:x})};b.data=d.data||{},b.data.loading=!0;try{yield t.request(f({},W)),b.data.loading=!1,u instanceof mu||(M=(P=p==null?void 0:p.service)==null?void 0:P.refresh)==null||M.call(P),(R=h==null?void 0:h.refresh)==null||R.call(h),z==="customize:form:request"&&(V==="previous"||!V&&q!==!0)&&(C==null||C(!1)),U||(I.message.success(S("Saved successfully")),yield Wc(r),(q&&!V||V==="redirect")&&E&&(de.isURL(E)?window.location.href=E:o(E))),$?k.success({title:i(U),onOk:()=>O(this,null,function*(){(q&&!V||V==="redirect")&&E&&(de.isURL(E)?window.location.href=E:o(E))})}):I.message.success(i(U))}finally{b.data.loading=!1}})}}},HF=()=>{const e=y.useForm(),t=Pn(),{field:o,resource:n,__parent:l}=pt(),{setVisible:i,setFormValueChanged:r}=ke(),s=y.useFieldSchema(),c=Eo(),{fields:d,getField:u,name:p}=re(),h=se(),g=y.useField(),{updateAssociationValues:v}=je(),{modal:x}=I.App.useApp(),b=sc(),S=st(),C=gt({currentForm:e}),{getActiveFieldsName:k}=Vn()||{};return{onClick(F,j){return O(this,null,function*(){var P,M;const{assignedValues:R={},onSuccess:N,overwriteValues:D,skipValidator:B,triggerWorkflows:$}=(P=s==null?void 0:s["x-action-settings"])!=null?P:{},{manualClose:q,redirecting:E,redirectTo:U,successMessage:V,actionAfterSuccess:z}=N||{},_={},H=Object.keys(R).map(Q=>O(this,null,function*(){const Y=R[Q],J=u(Q);if(dt(Y)){const{value:ae}=(yield S==null?void 0:S.parseVariable(Y,C))||{};_[Q]=il(ae,{targetCollectionField:J})}else Y!==""&&(_[Q]=Y)}));yield Promise.all(H),B||(yield e.submit());const G=d.map(Q=>Q.name),W=Ds({filterByTk:t,field:o,form:e,fieldNames:G,getField:u,resource:n,actionFields:(k==null?void 0:k("form"))||[]});g.data=o.data||{},g.data.loading=!0;try{const Q=yield n.update(T(f({filterByTk:t,values:f(f(f({},W),D),_)},b),{updateAssociationValues:v,triggerWorkflows:$!=null&&$.length?$.map(J=>[J.workflowKey,J.context].filter(Boolean).join("!")).join(","):void 0}));g.data.loading=!1,j&&(j==null||j());let Y=U;if(U&&(Y=yield Ka(U,{variables:S,localVariables:[...C,{name:"$record",ctx:new Proxy((M=Q==null?void 0:Q.data)==null?void 0:M.data,{})}]})),(z==="previous"||!z&&E!==!0)&&(i==null||i(!1)),r==null||r(!1),!V)return;q?x.success({title:h(V),onOk:()=>O(this,null,function*(){yield e.reset(),(E&&!z||z==="redirect")&&Y&&(de.isURL(Y)?window.location.href=Y:c(Y))})}):(I.message.success(h(V)),(E&&!z||z==="redirect"||z==="redirect")&&Y&&(de.isURL(Y)?window.location.href=Y:c(Y)))}catch{g.data.loading=!1}})}}},GF=()=>{const e=Pn(),{resource:t,service:o,block:n,field:l,__parent:i}=pt(),{setVisible:r,setSubmitted:s}=ke(),c=sc(),d=y.useFieldSchema(),u=y.useField();return{onClick(p,h){return O(this,null,function*(){var g,v,x,b,S,C,k;const{triggerWorkflows:F}=(g=d==null?void 0:d["x-action-settings"])!=null?g:{};u.data=l.data||{},u.data.loading=!0;try{yield t.destroy(f({filterByTk:e,triggerWorkflows:F!=null&&F.length?F.map(R=>[R.workflowKey,R.context].filter(Boolean).join("!")).join(","):void 0},c));const{count:j=0,page:P=0,pageSize:M=0}=((v=o==null?void 0:o.data)==null?void 0:v.meta)||{};if(j%M===1&&P!==1){const R=(x=o.params[0])==null?void 0:x.page,N=(S=(b=o.data)==null?void 0:b.meta)==null?void 0:S.totalPage;R===N&&o.params[0]&&R!==1&&(o.params[0].page=R-1)}h&&(h==null||h()),s==null||s(!0),n&&n!=="TableField"&&((k=(C=i==null?void 0:i.service)==null?void 0:C.refresh)==null||k.call(C),r==null||r(!1),s==null||s(!0))}catch(j){console.error(j),u.data.loading=!0}})}}},l$=e=>{const t=Pn(),o=Te().resource(e,t);return{onClick(n){return O(this,null,function*(){yield o.remove({values:[n.id]})})}}},i$=()=>{const e=Pn(),{resource:t,service:o,block:n,__parent:l}=pt(),{setVisible:i,setSubmitted:r,setFormValueChanged:s}=ke();return{onClick(c,d){return O(this,null,function*(){var u,p,h,g;yield t.remove({values:[e]});const{count:v=0,page:x=0,pageSize:b=0}=((u=o==null?void 0:o.data)==null?void 0:u.meta)||{};v%b===1&&x!==1?o.run(T(f({},(p=o==null?void 0:o.params)==null?void 0:p[0]),{page:x-1})):d&&(d==null||d()),r==null||r(!0),n&&n!=="TableField"&&((g=(h=l==null?void 0:l.service)==null?void 0:h.refresh)==null||g.call(h),i==null||i(!1),s==null||s(!1))})}}},WF=()=>{const{field:e}=pt(),{resource:t,service:o}=pt(),{setSubmitted:n}=ke(),l=re(),{filterTargetKey:i}=l;return{onClick(r,s){return O(this,null,function*(){var c,d,u,p,h,g,v;let x=(c=e.data)==null?void 0:c.selectedRowKeys;if(Array.isArray(i)&&(x=e.data.selectedRowData.map(C=>{const k={};return i.map(F=>{k[F]=C[F]}),k})),!((u=(d=e==null?void 0:e.data)==null?void 0:d.selectedRowKeys)!=null&&u.length))return;yield t.destroy({filterByTk:x}),e.data.selectedRowKeys=[];const b=(p=o.params[0])==null?void 0:p.page,S=(g=(h=o.data)==null?void 0:h.meta)==null?void 0:g.totalPage;b===S&&o.params[0]&&b!==1&&(o.params[0].page=b-1),s&&(s==null||s()),n==null||n(!0),(v=o==null?void 0:o.refresh)==null||v.call(o)})}}},r$=()=>{const{service:e}=pt();return{onClick(){return O(this,null,function*(){var t;(t=e==null?void 0:e.refresh)==null||t.call(e)})}}},YF=()=>{const e=y.useFieldSchema(),t=se(),{t:o}=K.useTranslation(),n=ve();return m.useMemo(()=>{const l=[],i=c=>{let d=c;for(;d&&!((d==null?void 0:d["x-component"])==="ActionBar"||!d.parent);)d=d.parent;const u=d.parent;if(u){const p=u==null?void 0:u.reduceProperties((h,g)=>(g==null?void 0:g["x-component"])==="TableV2"?h.concat([g]):h,[]);return p==null?void 0:p[0]}return null},r=(c,d=0)=>{var u,p,h,g,v,x,b,S,C;if(!(!c||d>1)){if((p=(u=c==null?void 0:c["x-component"])==null?void 0:u.includes)!=null&&p.call(u,"Table.Column")||(g=(h=c==null?void 0:c["x-decorator"])==null?void 0:h.includes)!=null&&g.call(h,"Table.Column")||(c==null?void 0:c["x-component"])==="TableV2.Column"){const k=c.reduceProperties?c.reduceProperties((R,N)=>(N==null?void 0:N["x-component"])==="CollectionField"?R.concat([N]):R,[]):[],F=(k==null?void 0:k.length)>0?k[0].name:c.name,j=(v=n==null?void 0:n.getField)==null?void 0:v.call(n,F);let P=o(c==null?void 0:c.title,{ns:Qt})||c.title;!P&&c.name==="actions"&&(P=o("Actions")),!P&&j&&(P=o((x=j.uiSchema)==null?void 0:x.title,{ns:Qt})||((b=j.uiSchema)==null?void 0:b.title)||j.name),P||(P=c.name||`Column ${l.length+1}`),P=t(P)||P;const M={key:c["x-uid"]||c.name||`column-${l.length}`,title:P,dataIndex:F||`column-${l.length}`,visible:c["x-display"]!=="hidden",fixed:((S=c["x-component-props"])==null?void 0:S.fixed)||!1,width:(C=c["x-component-props"])==null?void 0:C.width,order:c["x-index"]||l.length};l.push(M)}c.properties&&Object.keys(c.properties).forEach(k=>{r(c.properties[k],d+1)}),c.items&&r(c.items,d+1)}},s=i(e);return r(s),l.sort((c,d)=>(c.order||0)-(d.order||0))},[e,t,o,n])},a$=()=>{const e=y.useField(),t=y.useFieldSchema(),o=YF(),n=m.useCallback(()=>{let v=t;for(;v;){const x=S=>{if(!(S!=null&&S.properties))return null;for(const C in S.properties){const k=S.properties[C];if(k["x-component"]==="TableV2")return k;const F=x(k);if(F)return F}return null},b=x(v);if(b)return b;if(!v.parent)break;v=v.parent}return v},[t]),l=m.useMemo(()=>n(),[n]),i=m.useMemo(()=>(l==null?void 0:l["x-uid"])||"default",[l]),{getSettings:r,saveSettings:s,clearSettings:c}=cs(i),[d,u]=m.useState(r()),p=m.useMemo(()=>{if(o.length===0)return[];if(!d||d.length===0)return o;const v=new Map;return d.forEach(x=>{v.set(x.key,x)}),o.map(x=>{const b=v.get(x.key);return b?T(f({},x),{visible:b.visible,order:b.order,width:b.width||x.width,fixed:b.fixed||x.fixed}):x}).sort((x,b)=>(x.order||0)-(b.order||0))},[o,d]);m.useEffect(()=>{p.length>0&&(e.dataSource=p)},[p,e]);const h=m.useCallback(v=>{if(!(v!=null&&v.columns)||!Array.isArray(v.columns))return;const x=v.columns.map((b,S)=>({key:b.key,title:b.title,dataIndex:b.dataIndex,visible:b.visible,fixed:b.fixed,width:b.width,order:S}));s(x)},[s]),g=m.useCallback(()=>{c(),u(r())},[c]);return{columns:p,onSubmit:h,onReset:g}},s$=()=>{var e,t,o,n,l,i,r,s,c,d,u,p,h,g,v,x,b;const S=kr(),C=((o=(t=(e=S.service)==null?void 0:e.data)==null?void 0:t.meta)==null?void 0:o.count)||0,k=(i=(l=(n=S.service)==null?void 0:n.data)==null?void 0:l.meta)==null?void 0:i.page,{hasNext:F}=((s=(r=S.service)==null?void 0:r.data)==null?void 0:s.meta)||{};return!C&&k?{simple:!0,current:((u=(d=(c=S.service)==null?void 0:c.data)==null?void 0:d.meta)==null?void 0:u.page)||1,pageSize:1,showSizeChanger:!1,align:"center",onChange(j){return O(this,null,function*(){var P,M;const R=(M=(P=S.service)==null?void 0:P.params)==null?void 0:M[0];S.service.run(T(f({},R),{page:j}))})},style:{marginTop:24,textAlign:"center"},showTotal:!1,showTitle:!1,total:((g=(h=(p=S.service)==null?void 0:p.data)==null?void 0:h.data)==null?void 0:g.length)<1||!F?1*k:1*k+1,className:Z.css`
|
|
626
626
|
.ant-pagination-simple-pager {
|
|
627
627
|
display: none !important;
|
|
628
628
|
}
|
|
@@ -1699,7 +1699,7 @@ ${JSON.stringify(H,null,2)}`)},[d,c,s,l,n,M,t,r,i,v,o,x,k,R,F,j,g]),D=m.useCallb
|
|
|
1699
1699
|
border-top-color: transparent;
|
|
1700
1700
|
background-color: transparent;
|
|
1701
1701
|
}
|
|
1702
|
-
`,children:"x"})})})]})},BG=w.defineAction({name:"confirm",title:w.tExpr("Confirmation"),uiSchema:{enable:{type:"boolean",title:w.tExpr("Enable secondary confirmation"),"x-decorator":"FormItem","x-component":"Switch"},title:{type:"string",title:w.tExpr("Title"),"x-decorator":"FormItem","x-component":Rr,"x-component-props":{rows:2}},content:{type:"string",title:w.tExpr("Content"),"x-decorator":"FormItem","x-component":Rr,"x-component-props":{rows:3}}},defaultParams:{enable:!1,title:w.tExpr("Please Confirm"),content:w.tExpr("Are you sure you want to perform the action?")},handler(e,t){return O(this,null,function*(){t.enable&&((yield e.modal.confirm({title:e.t(t.title),content:e.t(t.content),okText:e.t("Confirm"),cancelText:e.t("Cancel")}))||e.exit())})}}),uy=new WeakMap;let py=0;const Lc=e=>{let t=uy.get(e);return t||(py+=1,t=`filter-item-${py}`,uy.set(e,t)),t},tr=w.observer(e=>{const{token:t}=I.theme.useToken(),{value:o={logic:"$and",items:[]},FilterItem:n,showBorder:l=!1,onRemove:i,onChange:r,closeIcon:s=a.jsx(te.CloseCircleOutlined,{style:{color:t.colorIcon}})}=e,{t:c}=K.useTranslation();o.logic||(o.logic="$and"),Array.isArray(o.items)||(o.items=[]);const{logic:d,items:u}=o,p=l?{position:"relative",border:`1px dashed ${t.colorBorder}`,padding:t.paddingSM,marginBottom:t.marginXS,borderRadius:t.borderRadius}:{position:"relative",marginBottom:t.marginXS},h=C=>{o.logic=C,r==null||r(o)},g=()=>{u.push({path:"",operator:"",value:""}),r==null||r(o)},v=()=>{u.push({logic:"$and",items:[]}),r==null||r(o)},x=C=>{u.splice(C,1),r==null||r(o)},b=C=>"path"in C||"operator"in C||"value"in C,S=C=>"logic"in C&&"items"in C;return a.jsxs("div",{style:p,children:[l&&i&&a.jsx("button",{type:"button","aria-label":"icon-close",style:{position:"absolute",right:10,top:10,cursor:"pointer",background:"transparent",border:0,padding:0},onClick:i,children:s}),a.jsx("div",{style:{marginBottom:8,color:t.colorText},children:a.jsxs("span",{children:[c("Meet")," ",a.jsxs(I.Select,{"data-testid":"filter-select-all-or-any",style:{width:"auto"},value:d,onChange:h,children:[a.jsx(I.Select.Option,{value:"$and",children:c("All")}),a.jsx(I.Select.Option,{value:"$or",children:c("Any")})]})," ",c("conditions in the group")]})}),a.jsx("div",{children:u.map((C,k)=>S(C)?a.jsx(tr,{value:C,FilterItem:n,showBorder:!0,onRemove:()=>x(k),onChange:F=>{u[k]=F,r==null||r(o)}},Lc(C)):b(C)?n?a.jsx("div",{style:{marginBottom:8,display:"flex",alignItems:"flex-end"},children:a.jsxs(I.Space,{style:{flex:1,minWidth:0},children:[a.jsx(n,{value:C}),a.jsx("button",{type:"button","aria-label":"icon-close",style:{marginLeft:8,marginRight:8,flex:"0 0 auto",cursor:"pointer",background:"transparent",border:0,padding:0},onClick:()=>x(k),children:s})]})},Lc(C)):a.jsx("div",{style:{marginBottom:8,display:"flex",alignItems:"flex-end"},children:a.jsxs(I.Space,{style:{flex:1,minWidth:0},children:[a.jsxs("span",{children:[C.path," ",C.operator," ",String(C.value)]}),a.jsx("button",{type:"button","aria-label":"icon-close",style:{marginLeft:8,marginRight:8,flex:"0 0 auto",cursor:"pointer",background:"transparent",border:0,padding:0},onClick:()=>x(k),children:s})]})},Lc(C)):a.jsx("div",{style:{marginBottom:8,display:"flex",alignItems:"flex-end"},children:a.jsxs(I.Space,{style:{flex:1,minWidth:0},children:[a.jsx("span",{style:{color:t.colorTextTertiary},children:"Invalid filter item"}),a.jsx("button",{type:"button","aria-label":"icon-close",style:{marginLeft:8,marginRight:8,flex:"0 0 auto",cursor:"pointer",background:"transparent",border:0,padding:0},onClick:()=>x(k),children:s})]})},Lc(C)))}),a.jsxs(I.Space,{size:16,style:{marginTop:8,marginBottom:8},children:[a.jsx(I.Button,{style:{padding:0},type:"link",size:"small",icon:a.jsx(te.PlusOutlined,{}),onClick:g,children:c("Add condition")}),a.jsx(I.Button,{style:{padding:0},type:"link",size:"small",icon:a.jsx(te.PlusOutlined,{}),onClick:v,children:c("Add condition group")})]})]})},{displayName:"FilterGroup"}),my=w.observer(e=>{var t;const{value:o,FilterItem:n,ctx:l}=e;o.logic||(o.logic="$and"),Array.isArray(o.items)||(o.items=[]);const i=()=>{var c;(c=l==null?void 0:l.model)!=null&&c.dispatchEvent&&l.model.dispatchEvent("reset")},r=()=>{var c;(c=l==null?void 0:l.model)!=null&&c.dispatchEvent&&l.model.dispatchEvent("submit")},s=((t=l==null?void 0:l.model)==null?void 0:t.translate)||(c=>c);return a.jsxs("form",{onSubmit:c=>{c.preventDefault(),r()},children:[a.jsx(tr,{value:o,FilterItem:n}),a.jsxs(I.Space,{style:{width:"100%",display:"flex",justifyContent:"flex-end"},children:[a.jsx(I.Button,{htmlType:"button",onClick:i,children:s("Reset")}),a.jsx(I.Button,{type:"primary",htmlType:"submit",children:s("Submit")})]})]})},{displayName:"FilterContent"}),Qw=(e,t,o,n)=>e.map(l=>$G(l,t,o,n)).filter(Boolean),$G=(e,t,o,n)=>{var l;if(o.length&&t===1&&o.includes(e.name)||!e.interface||e.filterable===!1)return;const i=e.getInterfaceOptions();if(!(i!=null&&i.filterable))return;const{nested:r,children:s,operators:c}=i.filterable,d={name:e.name,type:e.type,target:e.target,title:n(e.title),schema:e==null?void 0:e.uiSchema,operators:(((l=c==null?void 0:c.filter)==null?void 0:l.call(c,u=>!(u!=null&&u.visible)||u.visible(e)))||[]).map(u=>T(f({},u),{label:n(u.label)}))};if(!(e.target&&t>2)){if(t>2)return d;if(s!=null&&s.length&&(d.children=s),r){const u=e.getFields().filter(h=>h.target!=="attachments"&&h.interface!=="formula"),p=Qw(u,t+1,o,n).filter(Boolean);d.children=d.children||[],d.children.push(...p)}return d}};w.observer(e=>{var t;const{path:o,operator:n,value:l}=e.value,i=e.model,r=((t=i.context.blockModel.collection)==null?void 0:t.getFields().filter(v=>v.target!=="attachments"))||[],s=OG(i.props.filterableFieldNames||[],r.map(v=>v.name)),c=i.translate,d=Qw(r.filter(v=>v.target!=="attachments"&&v.interface!=="formula"&&!["belongsTo","belongsToMany","hasOne","hasMany","oho","obo","m2o","o2m","m2m"].includes(v.type)),1,e.noIgnore?[]:s,c).filter(Boolean),u=m.useMemo(()=>{const v=d.find(x=>x.name===o);return(v==null?void 0:v.operators)||[]},[d,o]),p=v=>{var x;e.value.path=v;const b=d.find(S=>S.name===v);((x=b==null?void 0:b.operators)==null?void 0:x.length)>0?e.value.operator=b.operators[0].value:e.value.operator="",e.value.value=""},h=v=>{e.value.operator=v},g=v=>{e.value.value=v.target.value};return a.jsxs(I.Space,{children:[a.jsx(I.Select,{style:{width:200},placeholder:c("Select field"),value:o||void 0,onChange:p,children:d.map(v=>a.jsx(I.Select.Option,{value:v.name,children:v.title},v.name))}),a.jsx(I.Select,{style:{width:120},placeholder:c("Select operator"),value:n||void 0,onChange:h,disabled:!o||u.length===0,children:u.map(v=>a.jsx(I.Select.Option,{value:v.value,children:v.label},v.value))}),a.jsx(I.Input,{style:{width:200},placeholder:c("Enter value"),value:l,onChange:g})]})},{displayName:"FilterItem"});function OG(e,t){return t==null?void 0:t.filter(o=>!e.includes(o))}function Zw(e=[]){return Array.isArray(e)?e.map(t=>{var o;if(t&&typeof t=="object"&&!Array.isArray(t)){const n=t,l=typeof n.label<"u",i=typeof n.value<"u",r=l?n.label:String((o=n.value)!=null?o:""),s=i?n.value:r,c={label:r,value:s};return n.color&&(c.color=n.color),n.icon&&(c.icon=n.icon),c}return{label:String(t),value:t}}):[]}function eP(e=[],t){return Array.isArray(e)?e.map(o=>typeof(o==null?void 0:o.label)=="string"?T(f({},o),{label:t(o.label)}):o):[]}function Wx(e,t){if(!e||!Array.isArray(e)||e.length===0)return;const o=Zw(e);return eP(o,t)}function Yx(e,t){var o,n,l,i;const r=t==null?void 0:t.interface;if(!["radioGroup","checkboxGroup","select","multipleSelect"].includes(r)||Array.isArray((o=e.props)==null?void 0:o.options)&&((l=(n=e.props)==null?void 0:n.options)==null?void 0:l.length)>0)return!1;const s=(i=t.uiSchema)==null?void 0:i.enum;if(!Array.isArray(s)||s.length===0)return!1;const c=Zw(s);return c.length?(e.setProps({options:c}),!0):!1}function Jx(e,t,o){var n;if(!o||!Array.isArray(o))return null;const l=o.find(d=>(d==null?void 0:d.value)===t),i=l==null?void 0:l.schema,r=i==null?void 0:i["x-component"];if(!r)return null;const s=(n=e==null?void 0:e.getComponent)==null?void 0:n.call(e,r);if(!s)return null;const c=(i==null?void 0:i["x-component-props"])||{};return{Comp:s,props:c}}const{DateFilterDynamicComponent:LG}=_r(()=>Promise.resolve().then(()=>O8),"DateFilterDynamicComponent");function VG(e){return O(this,null,function*(){var t,o,n,l;const i=d=>O(this,null,function*(){return Array.isArray(d)?d:typeof d=="function"?yield d():[]});if((o=(t=e.getPropertyOptions)==null?void 0:t.call(e,"collection"))!=null&&o.meta){const d=(n=e.getPropertyMetaTree)==null?void 0:n.call(e,"{{ ctx.collection }}");return yield i(d)}const r=()=>{var d;return(d=e==null?void 0:e.collection)!=null?d:null},s=yield w.createEphemeralContext(e,{defineProperties:{collection:{get:r,meta:w.createCollectionContextMeta(r,"Current collection")}}}),c=(l=s.getPropertyMetaTree)==null?void 0:l.call(s,"{{ ctx.collection }}");return yield i(c)})}function zG(e,t,o,n){var l;const i=e==null?void 0:e["x-component"],r=((l=t==null?void 0:t.uiSchema)==null?void 0:l["x-component-props"])||{},s=(e==null?void 0:e["x-component-props"])||{},c=gr({},r,s),d=Wx(e==null?void 0:e.enum,o)||[],u=f({style:f({width:200},(c==null?void 0:c.style)||{}),placeholder:(c==null?void 0:c.placeholder)||o("Enter value")},c),p=h=>{if(typeof h=="number"||(c==null?void 0:c.stringMode)===!0&&typeof h=="string")return h};return h=>{const g=h||{},{value:v,onChange:x}=g,b=ne(g,["value","onChange"]);if(i==="InputNumber")return a.jsx(I.InputNumber,T(f(f({},u),b),{value:p(v),onChange:S=>x==null?void 0:x(S)}));if(i==="NumberPicker")return a.jsx(ue.NumberPicker,T(f(f({},u),b),{value:p(v),onChange:S=>x==null?void 0:x(S)}));if(i==="Switch")return a.jsx(I.Switch,T(f(f({},u),b),{checked:!!v,onChange:S=>x==null?void 0:x(S)}));if(i==="Select")return a.jsx(I.Select,T(f(f({options:d},u),b),{value:Array.isArray(v)||typeof v=="string"||typeof v=="number"||typeof v=="boolean"?v:void 0,onChange:S=>x==null?void 0:x(S)}));if(i==="DateFilterDynamicComponent")return a.jsx(LG,T(f(f({},u),b),{value:v,onChange:S=>x==null?void 0:x(S)}));if(i&&n!=null&&n.getComponent){const S=n.getComponent(i);if(S)return a.jsx(S,T(f(f({},u),b),{value:v,onChange:C=>x==null?void 0:x(C),style:f(f({width:200},u.style||{}),b==null?void 0:b.style)}))}return a.jsx(I.Input,T(f(f({},u),b),{value:typeof v=="string"?v:v==null?"":String(v),onChange:S=>x==null?void 0:x(S.target.value)}))}}function _G(e){var t;if(e&&typeof e=="object"){const o=e;if(typeof o.preventDefault=="function"||o.nativeEvent||"target"in o){const n=(t=o.target)==null?void 0:t.value;return n!==void 0?n:e}}return e}const Ga=w.observer(({value:e,model:t,rightAsVariable:o,rightMetaTree:n,ignoreFieldNames:l})=>{const i=w.useFlowViewContext(),r=t.translate,{path:s,operator:c,value:d}=e,[u,p]=m.useState(null),h=m.useMemo(()=>{var _,H,G,W;if(!u)return[];const Q=(_=t.context.app)==null?void 0:_.dataSourceManager,Y=u.interface?(H=Q==null?void 0:Q.collectionFieldInterfaceManager)==null?void 0:H.getFieldInterface(u.interface):void 0,J=(G=u==null?void 0:u.uiSchema)==null?void 0:G["x-filter-operators"];return((Array.isArray(J)&&J.length?J:(W=Y==null?void 0:Y.filterable)==null?void 0:W.operators)||[]).filter(ae=>!ae.visible||ae.visible(u))},[u,t]);m.useEffect(()=>{if(!h.length)return;const _=L.find(h,H=>H.value===e.operator);if(_)e.noValue=!!_.noValue;else{const H=h[0];e.operator=H.value,e.value=H.noValue?!0:void 0,e.noValue=!!H.noValue}},[h,e]);const g=m.useMemo(()=>h.map(_=>({value:_.value,label:typeof _.label=="string"?r(_.label):_.label})),[h,r]),v=m.useCallback((_,H)=>{e.path=_||"",H&&p(H)},[e]),x=m.useMemo(()=>({resolveValueFromPath:_=>(p(_),(_==null?void 0:_.paths.slice(1).join("."))||null),resolvePathFromValue(_){return _&&["collection",...String(_).split(".")]}}),[]),b=m.useCallback(_=>{e.operator=_;const H=h.find(G=>G.value===_);H!=null&&H.noValue?(e.value=!0,e.noValue=!0):(e.value=void 0,e.noValue=!1)},[h,e]),S=m.useMemo(()=>h.find(_=>_.value===c),[h,c]),C=m.useMemo(()=>{const _=(u==null?void 0:u.uiSchema)||{},H=(S==null?void 0:S.schema)||{},G=gr({},_,H);if((u==null?void 0:u.interface)==="formula"){const W={"x-read-pretty":!1,"x-component":"Input","x-component-props":f({},G["x-component-props"])};return gr({},G,W)}return G},[u,S]),k=m.useRef(C==null?void 0:C["x-component"]),F=C==null?void 0:C["x-component"],j=m.useMemo(()=>{const _=k.current;k.current=F;const H=_!==void 0&&_!==F;if(S!=null&&S.noValue)return d;if(H&&d!=null){e.value=void 0;return}return d},[F,d,e,S]),P=m.useCallback(_=>{e.value=_G(_)},[e]),M=m.useRef(r);m.useEffect(()=>{M.current=r},[r]);const R=m.useCallback(_=>{var H,G;return(G=(H=M.current)==null?void 0:H.call(M,_))!=null?G:_},[]),N=m.useMemo(()=>Wx(C==null?void 0:C.enum,R)||[],[C,R]),D=m.useMemo(()=>zG(C,u,R,t.context.app),[C,u,R,t.context.app]),B=m.useCallback(_=>_?_==="Input"||_==="InputNumber"||_==="NumberPicker"||_==="Switch"||_==="Select"||_==="DateFilterDynamicComponent":!0,[]),$=m.useMemo(()=>{function _({dynValue:H}){const G=m.useRef(()=>{}),W=m.useCallback(J=>{P(J)},[P]);m.useEffect(()=>{G.current=W},[W]);const Q=m.useRef(null);Q.current||(Q.current=Oe.createForm({values:{value:H},effects(){const J=ae=>"value"in ae;Oe.onFieldValueChange("value",ae=>{J(ae)&&G.current(ae.value)})}})),m.useEffect(()=>{var J;(J=Q.current)==null||J.setValues({value:H})},[H]);const Y=m.useMemo(()=>gr({name:"value","x-component":"Input","x-component-props":{style:{width:200},placeholder:R("Enter value")},"x-read-pretty":!1,"x-validator":void 0,"x-decorator":void 0},C||{}),[C,R]);return a.jsx(Io,{form:Q.current,children:a.jsx("div",{style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},children:a.jsx(He,{schema:Y})})})}return _},[C,R,P]),q=m.useCallback(()=>{const _=Jx(t.context.app,c,h);if(_&&(c==="$in"||c==="$notIn")){const{Comp:H,props:G}=_;(!(G!=null&&G.options)||(G==null?void 0:G.options.length)===0)&&N!=null&&N.length&&(G.options=N);const W=f({flex:"1 1 40%",minWidth:160,maxWidth:"100%"},(G==null?void 0:G.style)||{}),Q=Array.isArray(j)&&j.every(Y=>typeof Y=="string"||typeof Y=="number")?j:typeof j=="string"?j.split(/\r?\n/).map(Y=>Y.trim()).filter(Boolean):[];return a.jsx("div",{style:W,children:a.jsx(H,T(f({},G),{style:f({width:"100%"},(G==null?void 0:G.style)||{}),value:Q,onChange:Y=>P(Y)}))})}return B(F)?a.jsx("div",{style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},children:a.jsx(D,{value:j,onChange:H=>P(H)})}):a.jsx($,{dynValue:j})},[$,B,c,h,j,D,t.context.app,P,N]),E=m.useMemo(()=>function(){return a.jsx(I.Input,{placeholder:`<${r("Null")}>`,readOnly:!0})},[r]),U=m.useMemo(()=>()=>O(void 0,null,function*(){const _=typeof n=="function"?yield n():n??i.getPropertyMetaTree(),H=Array.isArray(_)?_:yield _();return[{title:r("Constant"),name:"constant",type:"string",paths:["constant"],render:D},{title:r("Null"),name:"null",type:"object",paths:["null"],render:E},...H]}),[n,i,D,E,r]),V=m.useMemo(()=>({renderInputComponent:_=>{var H;const G=(H=_==null?void 0:_.paths)==null?void 0:H[0];return G==="constant"?D:G==="null"?E:null},resolveValueFromPath:_=>{var H;const G=(H=_==null?void 0:_.paths)==null?void 0:H[0];if(G==="constant")return"";if(G==="null")return null},resolvePathFromValue:_=>_===null?["null"]:(typeof _=="string"?w.parseValueToPath(_):void 0)||["constant"]}),[E,D]),z=m.useMemo(()=>()=>O(void 0,null,function*(){var _;const H=(_=t.context.app)==null?void 0:_.dataSourceManager,G=H==null?void 0:H.collectionFieldInterfaceManager,W=yield VG(t.context),Q=J=>O(void 0,null,function*(){var ae,le;const ce=J.interface?G==null?void 0:G.getFieldInterface(J.interface):void 0,oe=[],ge=ce==null?void 0:ce.filterable,me=ge==null?void 0:ge.children;if(Array.isArray(me)&&me.length)for(const pe of me)oe.push({name:pe.name,title:pe.title||pe.name,type:((ae=pe.schema)==null?void 0:ae.type)||"string",interface:((le=pe.schema)==null?void 0:le["x-component"])==="Select"?"select":"input",uiSchema:T(f({},pe.schema||{}),{"x-filter-operators":pe.operators}),paths:[...J.paths||[],pe.name],parentTitles:[...J.parentTitles||[],J.title]});if(typeof J.children=="function"){const pe=J.children;return T(f({},J),{children:()=>O(void 0,null,function*(){const Se=yield pe();return[...Array.isArray(Se)?Se:[],...oe]})})}const ye=[...Array.isArray(J.children)?J.children:[],...oe];return T(f({},J),{children:ye.length?ye:J.children})}),Y=[];for(const J of W)Y.push(yield Q(J));return Y}),[t]);return a.jsxs(I.Space,{wrap:!0,style:{width:"100%"},children:[a.jsx(w.VariableInput,{value:s,metaTree:z,onChange:v,converters:x,showValueComponent:!1,style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},onlyLeafSelectable:!0,placeholder:r("Select field"),ignoreFieldNames:l}),a.jsx(I.Select,{style:{flex:"0 0 140px",minWidth:120,maxWidth:"100%"},placeholder:r("Comparison"),value:c||void 0,onChange:b,children:g.map(_=>a.jsx(I.Select.Option,{value:_.value,children:_.label},_.value))}),!(S!=null&&S.noValue)&&(o?a.jsx(w.VariableInput,{value:j,onChange:_=>P(_),metaTree:U,converters:V,showValueComponent:!0,style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},placeholder:r("Enter value")}):q())]})}),{DateFilterDynamicComponent:KG}=_r(()=>Promise.resolve().then(()=>S5),"DateFilterDynamicComponent");function UG(e,t,o){var n,l,i;const r=e==null?void 0:e["x-component"],s=((n=t==null?void 0:t.uiSchema)==null?void 0:n["x-component-props"])||{},c=(e==null?void 0:e["x-component-props"])||{},d=gr({},s,c),u=Array.isArray((l=t==null?void 0:t.uiSchema)==null?void 0:l.enum)?(i=t==null?void 0:t.uiSchema)==null?void 0:i.enum:void 0,p=Wx(u,o),h=f({style:f({width:200},(d==null?void 0:d.style)||{}),placeholder:(d==null?void 0:d.placeholder)||o("Enter value")},d);return g=>{const v=g||{},{value:x,onChange:b}=v,S=ne(v,["value","onChange"]);if(r==="InputNumber")return a.jsx(I.InputNumber,T(f(f({},h),S),{value:x,onChange:b}));if(r==="NumberPicker")return a.jsx(ue.NumberPicker,T(f(f({},h),S),{value:x,onChange:b}));if(r==="Switch")return a.jsx(I.Switch,T(f(f({},h),S),{checked:!!x,onChange:b}));if(r==="Select"){let C=h;return Array.isArray(C==null?void 0:C.options)&&C.options.length>0?C=T(f({},C),{options:eP(C.options,o)}):p&&(C=T(f({},C),{options:p})),a.jsx(I.Select,T(f(f({},C),S),{value:x,onChange:b}))}return r==="DateFilterDynamicComponent"?a.jsx(KG,T(f(f({},h),S),{value:x,onChange:b})):a.jsx(I.Input,T(f(f({},h),S),{value:x,onChange:C=>{var k;return b==null?void 0:b((k=C==null?void 0:C.target)==null?void 0:k.value)}}))}}const HG=[{value:"$includes",label:"contains",selected:!0},{value:"$notIncludes",label:"does not contain"},{value:"$eq",label:"is"},{value:"$ne",label:"is not"},{value:"$empty",label:"is empty",noValue:!0},{value:"$notEmpty",label:"is not empty",noValue:!0}],tP=w.observer(e=>{var t;const{value:o,model:n}=e,l=w.useFlowViewContext(),i=n.translate,{path:r,operator:s,value:c}=o||{},[d,u]=m.useState(null),p=m.useRef(!1),h=m.useMemo(()=>{if(!d)return"";const D=d.interface||"",B=Array.isArray(d.paths)?d.paths.join("."):"";return`${D}|${B}`},[d]),g=m.useMemo(()=>d!=null&&d.interface?(n.context.app.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(d.interface).filterable.operators||[]).filter(D=>!D.visible||D.visible(d)).map(D=>({value:D.value,label:typeof D.label=="string"?D.label:String(D.label),noValue:!!D.noValue,schema:D.schema,selected:!!D.selected})):d?HG:[],[h,n]),v=m.useMemo(()=>g.map(D=>({value:D.value,label:i(D.label)})),[g,i]);m.useEffect(()=>{if(g.length!==0){if(!s){if(p.current){const D=g.find(B=>B.selected)||g[0];o.operator=(D==null?void 0:D.value)||"",D!=null&&D.noValue?(o.value=!0,o.noValue=!0):o.noValue=!1,p.current=!1}return}if(!g.some(D=>D.value===s)){const D=g.find(B=>B.selected)||g[0];o.operator=(D==null?void 0:D.value)||"",D!=null&&D.noValue?(o.value=!0,o.noValue=!0):o.noValue=!1}}},[g,s,o]);const x=m.useMemo(()=>g.find(D=>D.value===s),[g,s]),b=m.useMemo(()=>{const D=(d==null?void 0:d.uiSchema)||{},B=(x==null?void 0:x.schema)||{};return gr({},D,B)},[d,x]),S=m.useRef(i);m.useEffect(()=>{S.current=i},[i]);const C=m.useCallback(D=>{var B,$;return($=(B=S.current)==null?void 0:B.call(S,D))!=null?$:D},[]),k=m.useMemo(()=>UG(b,d,C),[b,d,C]),F=m.useMemo(()=>function(){return a.jsx(I.Input,{placeholder:`<${i("Null")}>`,readOnly:!0})},[i]),j=m.useMemo(()=>()=>O(void 0,null,function*(){const D=(n==null?void 0:n.context.getPropertyMetaTree())||l.getPropertyMetaTree();return[{title:i("Constant"),name:"constant",type:"string",paths:["constant"]},{title:i("Null"),name:"null",type:"object",paths:["null"]},...Array.isArray(D)?D:[]]}),[l,n,i]),P=m.useCallback(()=>{var D,B;return((B=(D=n==null?void 0:n.context)==null?void 0:D.getPropertyMetaTree)==null?void 0:B.call(D))||l.getPropertyMetaTree()},[l,n]),M=m.useMemo(()=>({renderInputComponent:D=>{var B;const $=(B=D==null?void 0:D.paths)==null?void 0:B[0];return $==="constant"?k:$==="null"?F:null},resolveValueFromPath:D=>{var B;const $=(B=D==null?void 0:D.paths)==null?void 0:B[0];if($==="constant")return"";if($==="null")return null},resolvePathFromValue:D=>D===null?["null"]:w.parseValueToPath(D)||["constant"]}),[F,k]),R=m.useCallback((D,B)=>{const $=o.path||"",q=D||"",E=q!==$;o.path=q,E&&$&&(o.operator="",o.value="",p.current=!0),!$&&q&&!o.operator&&(p.current=!0),B&&u(B)},[o]),N=m.useCallback(D=>{o.operator=D;const B=g.find($=>$.value===D);B!=null&&B.noValue?(o.value=!0,o.noValue=!0):o.noValue=!1},[o,g]);return a.jsxs(I.Space,{wrap:!0,style:{width:"100%"},children:[a.jsx(w.VariableInput,{value:r,onChange:R,metaTree:P,showValueComponent:!0,style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},placeholder:i("Select variable"),onlyLeafSelectable:!0}),a.jsx(I.Select,{style:{flex:"0 0 140px",minWidth:120,maxWidth:"100%"},placeholder:i("Comparison"),value:s||void 0,onChange:N,children:v.map(D=>a.jsx(I.Select.Option,{value:D.value,children:D.label},D.value))}),!((t=g.find(D=>D.value===s))!=null&&t.noValue)&&a.jsx(w.VariableInput,{value:c,onChange:D=>o.value=D,metaTree:j,converters:M,showValueComponent:!0,style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},placeholder:i("Enter value"),clearValue:""})]})}),GG=w.defineAction({name:"dataScope",title:w.tExpr("Data scope"),uiMode:{type:"dialog",props:{width:800}},uiSchema:{filter:{type:"object","x-decorator":"FormItem","x-component":function(t){const o=w.useFlowSettingsContext();return a.jsx(tr,{value:t.value,FilterItem:n=>a.jsx(Ga,T(f({},n),{model:o.model,rightAsVariable:!0}))})}}},defaultParams(e){return{filter:{logic:"$and",items:[]}}},handler(e,t){return O(this,null,function*(){var o;const n=(o=e.model)==null?void 0:o.resource;if(!n)return;const l=w.pruneFilter(de.transformFilter(t.filter));de.isEmptyFilter(l)?n.removeFilterGroup(e.model.uid):n.addFilterGroup(e.model.uid,l)})}});function On(e){return a.jsx(I.Card,T(f({},e),{children:a.jsx(I.Skeleton,{paragraph:{rows:3}})}))}class Xx extends w.FlowModel{}Xx.registerFlow({key:"popupSettings",on:"click",steps:{openView:{use:"openView",defaultParams(e){return{mode:"embed",preventClose:!0,pageModelClass:"RootPageModel"}}}}});function WG(e,t,o){return t.map((n,l)=>{let i,r=n.viewUid;return l===0?(i=o,r=o.uid):i=e.getModel(n.viewUid,!0),{params:n,modelUid:r,model:i,hidden:w.observable.ref(!1),index:l}})}function hy(e){let t=!1;for(let o=e.length-1;o>=0;o--){const n=e[o];YG(n)==="embed"&&!t?(t=!0,n.hidden.value=!1):n.hidden.value=t}}function YG(e){if(e.model instanceof Xx)return"embed";if(!e.model)return"drawer";const t=e.model.getStepParams("popupSettings","openView");return(t==null?void 0:t.mode)||"drawer"}const La=e=>e==null?"":typeof e=="object"?Array.isArray(e)?"["+e.map(La).join(",")+"]":"{"+Object.keys(e).sort().map(t=>`${t}:${La(e[t])}`).join(",")+"}":String(e),si=e=>{const{params:t,index:o}=e;return[La(t.viewUid),La(t.sourceId),La(t.filterByTk),String(o)].join("_")};function JG(e,t){const o=new Map,n=new Map;e.forEach(r=>{const s=si(r);o.set(s,r)}),t.forEach(r=>{n.set(si(r),r)});const l=[];o.forEach((r,s)=>{n.has(s)?n.get(s).hidden=r.hidden:l.push(r)});const i=[];return n.forEach((r,s)=>{o.has(s)||i.push(r)}),{viewsToClose:l,viewsToOpen:i}}const oP=w.defineFlow({key:"popupSettings",title:w.tExpr("Popup settings"),on:"click",sort:300,steps:{openView:{use:"openView",hideInSettings:e=>O(void 0,null,function*(){var t,o,n,l;const i=(n=(o=(t=e.model).getStepParams)==null?void 0:o.call(t,"displayFieldSettings","clickToOpen"))==null?void 0:n.clickToOpen;return e.collectionField?i===void 0?!((l=e.collectionField)!=null&&l.isAssociationField()):i===!1:!1})}},defaultParams:e=>{var t,o,n,l,i,r,s,c;let d,u,p;const h=e.collectionField,g=e.blockModel,v=(o=(t=e.model)==null?void 0:t.parent)==null?void 0:o.associationPathName,x=e.collection||(g==null?void 0:g.collection),b=k=>{var F;return!!((F=k==null?void 0:k.isAssociationField)!=null&&F.call(k))},S=!b(h)&&v?(n=x==null?void 0:x.getFieldByPath)==null?void 0:n.call(x,v):void 0,C=b(h)?h:S;if(b(C)){const k=C.targetCollection;g==null||g.collection,d=k==null?void 0:k.name,u=k==null?void 0:k.dataSourceKey,p=C==null?void 0:C.resourceName}else h?(d=(l=e.collection)==null?void 0:l.name,u=(i=e.collection)==null?void 0:i.dataSourceKey,p=h==null?void 0:h.target):(d=(r=e.collection)==null?void 0:r.name,u=(s=e.collection)==null?void 0:s.dataSourceKey,p=(c=e.association)==null?void 0:c.resourceName);return{openView:{collectionName:d,associationName:p,dataSourceKey:u}}}}),XG=e=>e.getStepParams("popupSettings","openView");function nP(e){var t=e,{uid:o}=t,n=ne(t,["uid"]);const l=w.useFlowModelById(o);return a.jsx(w.FlowModelRenderer,f({model:l,fallback:a.jsx(On,{style:{margin:l!=null&&l.context.isMobileLayout?8:l==null?void 0:l.context.themeToken.marginBlock}}),hideRemoveInSettings:!0,showFlowSettings:{showBackground:!1,showBorder:!1}},n))}const QG=()=>{const e=m.useRef(null),t=w.useFlowEngine(),o=ko(),{refresh:n}=un(),{isMobileLayout:l}=to(),i=m.useRef(t.context.route.params.name),r=m.useRef({}),s=m.useRef([]),c=m.useRef(!1),{designable:d}=X(),{active:u}=Mi(),p=m.useRef(!1),h=m.useMemo(()=>t.createModel({uid:i.current,use:"RouteModel"}),[t]);return m.useEffect(()=>{h.context.defineProperty("pageActive",{value:w.observable.ref(!1)})},[h]),m.useEffect(()=>{h.context.pageActive.value=u},[u,h]),m.useEffect(()=>{t.context.defineProperty("isMobileLayout",{get:()=>l}),t.context.defineProperty("deviceType",{get:()=>vi.deviceType==="browser"?"computer":vi.deviceType,cache:!1,meta:{type:"string",title:t.translate("Current device type"),interface:"select",uiSchema:{enum:[{label:t.translate("Computer"),value:"computer"},{label:t.translate("Mobile"),value:"mobile"},{label:t.translate("Tablet"),value:"tablet"},{label:t.translate("SmartTv"),value:"smarttv"},{label:t.translate("Console"),value:"console"},{label:t.translate("Wearable"),value:"wearable"},{label:t.translate("Embedded"),value:"embedded"}],"x-component":"Select"}}})},[l,t]),m.useEffect(()=>{l?t.flowSettings.disable():d&&t.flowSettings.enable()},[d,t,l]),m.useEffect(()=>{e.current&&(t.context.defineProperty("layoutContentElement",{get:()=>e.current}),h.context.defineProperty("currentRoute",{get:()=>o}),t.context.defineProperty("currentRoute",{get:()=>o}),h.context.defineProperty("refreshDesktopRoutes",{get:()=>n}))},[h,o,n,t]),m.useEffect(()=>{const g=w.reaction(()=>t.context.route,v=>{var x;if(v.params.name!==i.current){p.current=!0;return}try{p.current=!1;const b=w.parsePathnameToViewParams(v.pathname),S=WG(t,b,h);if(s.current.length===0&&S.length>1&&!c.current){const F=j=>{S[j]&&(j===0?new w.ViewNavigation(t.context,[]).navigateTo(S[j].params,{replace:!0}):new w.ViewNavigation(t.context,S.slice(0,j).map(P=>P.params)).navigateTo(S[j].params),F(j+1))};F(0),c.current=!0;return}const{viewsToClose:C,viewsToOpen:k}=JG(s.current,S);if(console.log("[NocoBase] FlowRoute view diff:",{viewsToClose:C,viewsToOpen:k}),C.length&&(C.forEach(F=>{var j,P;(P=(j=r.current[si(F)])==null?void 0:j.destroy)==null||P.call(j,!0),delete r.current[si(F)]}),hy(S)),k.length&&O(void 0,null,function*(){const F=k.filter(P=>!P.model);if(F.length>0&&(yield Promise.all(F.map(P=>O(void 0,null,function*(){try{P.model=yield t.loadModel({uid:P.modelUid})}catch(M){console.error(`[NocoBase] Failed to load model ${P.modelUid}:`,M)}})))),p.current)return;hy(S);const j=P=>{if(!k[P])return;const M=k[P];if(!M.model)return;const R=m.createRef(),N=m.createRef(),D=XG(M.model),B=S.slice(0,M.index).map(q=>q.params.viewUid),$=new w.ViewNavigation(t.context,S.slice(0,M.index+1).map(q=>q.params));M.model.dispatchEvent("click",T(f({target:e.current,collectionName:D==null?void 0:D.collectionName,associationName:D==null?void 0:D.associationName,dataSourceKey:D==null?void 0:D.dataSourceKey,destroyRef:R,updateRef:N,openerUids:B},M.params),{navigation:$,onOpen(){j(P+1)},hidden:M.hidden,isMobileLayout:l,triggerByRouter:!0})),r.current[si(M)]={destroy:q=>{var E;return(E=R.current)==null?void 0:E.call(R)},update:q=>{var E;return(E=N.current)==null?void 0:E.call(N,q)},navigation:$}};j(0)}),C.length===0&&k.length===0){const F=S.at(-1);F&&((x=r.current[si(F)])==null||x.navigation.setViewStack(S.map(j=>j.params)))}s.current=[...S]}catch(b){console.error("[NocoBase] Failed to resolve view params to view list:",b)}},{fireImmediately:!0});return()=>{g==null||g(),s.current.forEach(v=>{var x;t.removeModelWithSubModels(v.params.viewUid),(x=r.current[si(v)])==null||x.destroy()})}},[t,l,h]),a.jsx("div",{ref:e})},lP=m.memo(e=>{const t=e,{pageModelClass:o="ChildPageModel",parentId:n,onModelLoaded:l,defaultTabTitle:i}=t,r=ne(t,["pageModelClass","parentId","onModelLoaded","defaultTabTitle"]),s=w.useFlowEngine(),c=w.useFlowViewContext(),{loading:d,data:u}=Ct.useRequest(()=>O(void 0,null,function*(){var p;const h={async:!0,parentId:n,subKey:"page",subType:"object",use:o};if(o==="ChildPageModel"){const v=i||((p=s.translate)==null?void 0:p.call(s,"Details"));h.subModels={tabs:[{use:"ChildPageTabModel",stepParams:{pageTabSettings:{tab:{title:v}}}}]},h.stepParams={pageSettings:{general:{displayTitle:!1,enableTabs:!0}}}}const g=yield s.loadOrCreateModel(h);return g!=null&&g.uid&&l&&(g.context.addDelegate(c),g.removeParentDelegate(),l(g.uid,g)),g}),{refreshDeps:[n]});return d||!(u!=null&&u.uid)?a.jsx(On,{style:{margin:c!=null&&c.isMobileLayout?8:c==null?void 0:c.themeToken.marginBlock}}):a.jsx(nP,f({uid:u.uid},r))});lP.displayName="FlowPage";const ZG=e=>{const t=e,{uid:o,parentId:n,subKey:l}=t,i=ne(t,["uid","parentId","subKey"]),r=w.useFlowEngine(),{loading:s,data:c}=Ct.useRequest(()=>O(void 0,null,function*(){return yield r.loadModel({uid:o,parentId:n,subKey:l})}),{refreshDeps:[o,n,l]});return s||!(c!=null&&c.uid)?a.jsx(On,{style:{margin:16}}):a.jsx(nP,f({uid:c.uid},i))},Ta=w.observer(e=>{const t=w.useFlowContext();return a.jsx(tr,{value:e.value||{logic:"$and",items:[]},FilterItem:o=>a.jsx(tP,{model:t.model,value:o.value}),onChange:e.onChange})}),Ma=(e,t)=>{const{condition:o={logic:"$and",items:[]}}=t,n=(l,i,r)=>e.app.jsonLogic.apply({[i]:[l,r]});de.evaluateConditions(de.removeInvalidFilterItems(o),n)||e.exit()};function cc(e){const{t}=K.useTranslation(),o=w.useFlowModel(),n=o.context.blockModel,l=e.collection||n.collection,i=l.dataSource,r=m.useMemo(()=>{const d=`${t(i.displayName||i.key)} > `,u=l?`${t(l.title)||l.name||l.tableName} `:"";return`${d}${u}`},[]),{actionName:s}=(e==null?void 0:e.forbidden)||o.forbidden,c=m.useMemo(()=>t(`The current user only has the UI configuration permission, but don't have "{{actionName}}" permission for collection "{{name}}"`,{name:r,actionName:t(L.capitalize(s))}).replaceAll(">",">"),[s,r,t]);return a.jsx(I.Tooltip,{title:e.message||c,children:e.children})}const mo={collection:"collection",record:"record",all:["collection","record"],both:["collection","record"]};class Ut extends w.FlowModel{constructor(){super(...arguments),A(this,"defaultProps",{type:"default",title:w.tExpr("Action")}),A(this,"enableEditTooltip",!0),A(this,"enableEditTitle",!0),A(this,"enableEditIcon",!0),A(this,"enableEditType",!0),A(this,"enableEditDanger",!0),A(this,"enableEditColor",!1)}static _getScene(){return L.castArray(this.scene||[])}static _isScene(t){return this._getScene().includes(t)}getAclActionName(){return null}onInit(t){super.onInit(t),this.context.defineProperty("actionName",{get:()=>this.getAclActionName(),cache:!1})}getInputArgs(){const t={},o=[];if(this.context.resource){const n=this.context.resource.getSourceId();n&&(t.sourceId=n,o.push("sourceId"))}if(this.context.collection&&this.context.record){const n=this.context.collection.getFilterByTK(this.context.record);n&&(t.filterByTk=n,o.push("filterByTk"))}return o.length&&(t.defaultInputKeys=o),t}onClick(t){this.dispatchEvent("click",f({event:t},this.getInputArgs()),{debounce:!0})}getTitle(){return this.props.title}getIcon(){return this.props.icon}renderButton(){const t=this.props,o=this.getIcon()?a.jsx(ct,{type:this.getIcon()}):void 0;return a.jsx(I.Button,T(f({},t),{onClick:this.onClick.bind(this),icon:o,children:t.children||this.getTitle()}))}render(){return this.props.tooltip?a.jsx(I.Tooltip,{title:this.props.tooltip,children:this.renderButton()}):this.renderButton()}renderHiddenInConfig(){const t=this.props,o=this.getIcon()?a.jsx(ct,{type:this.getIcon()}):void 0;return this.forbidden?a.jsx(cc,{children:a.jsx(I.Button,T(f({},t),{onClick:this.onClick.bind(this),icon:o,style:{opacity:"0.3"},children:t.children||this.getTitle()}))}):a.jsx(I.Tooltip,{title:this.context.t("The button is hidden and only visible when the UI Editor is active"),children:a.jsx(I.Button,T(f({},t),{onClick:this.onClick.bind(this),icon:o,style:{opacity:"0.3"},children:t.children||this.getTitle()}))})}}Ut.registerFlow({key:"buttonSettings",title:w.tExpr("Button settings"),sort:-999,steps:{general:{title:w.tExpr("Edit button"),uiSchema(e){return{title:e.model.enableEditTitle?{"x-decorator":"FormItem","x-component":"Input",title:w.tExpr("Button title")}:void 0,tooltip:e.model.enableEditTooltip?{"x-decorator":"FormItem","x-component":"Input",title:w.tExpr("Button tooltip")}:void 0,icon:e.model.enableEditIcon?{"x-decorator":"FormItem","x-component":"IconPicker",title:w.tExpr("Button icon")}:void 0,type:e.model.enableEditType?{"x-decorator":"FormItem","x-component":"Radio.Group",title:w.tExpr("Button type"),enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Primary")}}'},{value:"dashed",label:'{{t("Dashed")}}'},{value:"link",label:'{{t("Link")}}'},{value:"text",label:'{{t("Text")}}'}]}:void 0,danger:e.model.enableEditDanger?{"x-decorator":"FormItem","x-component":"Switch",title:w.tExpr("Danger action")}:void 0,color:e.model.enableEditColor?{"x-decorator":"FormItem","x-component":jr,title:w.tExpr("Color")}:void 0}},defaultParams(e){return e.model.defaultProps},handler(e,t){const o=t,{title:n,tooltip:l}=o,i=ne(o,["title","tooltip"]);e.model.setProps(f({title:n?e.t(n):void 0,tooltip:l?e.t(l):void 0},i))}},aclCheck:{use:"aclCheck"},linkageRules:{use:"actionLinkageRules"}}});Ut.registerEvents({click:{title:w.tExpr("Click"),name:"click",uiSchema:{condition:{type:"object",title:w.tExpr("Trigger condition"),"x-decorator":"FormItem","x-component":Ta}},handler:Ma}});class ql extends w.FlowModel{static getAllParentClasses(){const t=[];let o=this;for(;o&&o!==Object;)o=Object.getPrototypeOf(o),o!=null&&o.currentModels&&t.push(o);return t}static get currentModels(){return(!Object.prototype.hasOwnProperty.call(this,"_models")||!this._models)&&(this._models=new Map),this._models}static get models(){const t=new Map,o=this.getAllParentClasses();for(const n of o)for(const[l,i]of n.currentModels)t.set(l,i);for(const[n,l]of this.currentModels)t.set(n,l);return t}static registerActionModels(t){for(const[o,n]of Object.entries(t))Object.defineProperty(n,"name",{value:o}),this.currentModels.set(o,n)}static defineChildren(t){return O(this,null,function*(){const o=this.baseClass?yield w.buildSubModelItems(this.baseClass)(t):[],n=[],l=o.filter(i=>this.scene?t.engine.getModelClass(i.useModel)._isScene(this.scene):!0);for(const[i,r]of this.models){if(l.find(c=>c.useModel===r.name))continue;const s=yield w.buildSubModelItem(r,t);s&&n.push(s)}return L.sortBy([...l,...n],"sort")})}}A(ql,"baseClass"),A(ql,"scene"),A(ql,"_models");class hh extends ql{}A(hh,"baseClass",Ut),A(hh,"scene",mo.collection);class xd extends ql{}A(xd,"baseClass",Ut),A(xd,"scene",mo.record);class dc extends w.FlowModel{static defineChildren(t){const o=this.itemModelName,n=(l,i="")=>l.getToOneAssociationFields().map(r=>{const s=i?`${i}.${r.name}`:r.name;if(!r.targetCollection){console.error(`AssociationFieldGroupModel: target collection ${r.target} not found for field ${r.name}`);return}return{key:`${s}-assocationField`,label:r.title,children:()=>[{key:`${s}-children-collectionField`,label:"Display collection fields",type:"group",children:r.targetCollection.getFields().map(c=>{const d=`${s}.${c.name}`,u=w.DisplayItemModel.getDefaultBindingByField(t,c,{fallbackToTargetTitleField:!0});if(!u)return;const p=u.modelName;return{key:`c-${s}.${c.name}`,label:c.title,useModel:o,toggleable:h=>{var g;return((g=h.getStepParams("fieldSettings","init"))==null?void 0:g.fieldPath)===d},createModelOptions:{stepParams:{fieldSettings:{init:{dataSourceKey:t.collection.dataSourceKey,collectionName:t.collection.name,fieldPath:d,associationPathName:s}}},subModels:{field:{use:p}}}}}).filter(Boolean)},{key:`${s}-children-associationField`,label:"Display association fields",type:"group",children:(n(r.targetCollection,s)||[]).filter(Boolean)}]}});return n(t.collection)}}A(dc,"itemModelName","DetailsItemModel");dc.define({label:'{{t("Display association fields")}}'});function Qx(e){var t,o,n,l,i,r;return e.operator||((t=e.getStepParams("filterFormItemSettings","defaultOperator"))==null?void 0:t.value)||((o=e.subModels.field)==null?void 0:o.operator)||((r=(i=(l=(n=e.collectionField)==null?void 0:n.filterable)==null?void 0:l.operators)==null?void 0:i[0])==null?void 0:r.value)||"$includes"}function iP(e){return!!(e==null||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.filter(t=>!(t==null||typeof t=="string"&&t.trim()==="")).length===0||typeof e=="object"&&e.constructor===Object&&Object.keys(e).length===0)}function Bp(e){return e.filterSubModels("items",t=>{var o;return!!((o=t.resource)!=null&&o.supportsFilter)})}class Zx{constructor(t,o){A(this,"filterConfigs"),A(this,"gridModel"),this.gridModel=t,this.filterConfigs=o||[]}saveFilterConfigs(){return O(this,null,function*(){yield this.gridModel.saveStepParams()})}getFilterConfigs(){return this.filterConfigs}getConnectFieldsConfig(t){const o=this.filterConfigs.filter(n=>n.filterId===t);if(o.length!==0)return{targets:o.map(n=>({targetId:n.targetId,filterPaths:n.filterPaths}))}}saveConnectFieldsConfig(t,o){return O(this,null,function*(){const n=o.targets.map(i=>({filterId:t,targetId:i.targetId,filterPaths:i.filterPaths})),l=this.filterConfigs.filter(i=>i.filterId!==t);this.filterConfigs=[],this.filterConfigs.push(...l,...n),yield this.saveFilterConfigs()})}addFilterConfig(t){return O(this,null,function*(){if(!t.filterId||!t.targetId){console.error("FilterConfig must have filterId, targetId, and operator");return}if(!Array.isArray(t.filterPaths)||t.filterPaths.length===0){console.error("FilterConfig must have non-empty filterPaths array");return}const o=this.filterConfigs.findIndex(n=>n.filterId===t.filterId&&n.targetId===t.targetId);o>=0?this.filterConfigs[o]=f({},t):this.filterConfigs.push(f({},t)),yield this.saveFilterConfigs()})}removeFilterConfig(t){return O(this,arguments,function*({filterId:o,targetId:n,persist:l=!0}){if(!o&&!n)return console.error("At least one of filterId or targetId must be provided"),0;const i=this.filterConfigs.length;this.filterConfigs=this.filterConfigs.filter(s=>o&&n?!(s.filterId===o&&s.targetId===n):o?s.filterId!==o:n?s.targetId!==n:!0);const r=i-this.filterConfigs.length;return r>0&&l&&(yield this.saveFilterConfigs()),r})}bindToTarget(t){if(!t||typeof t!="string"){console.error("[NocoBase]: targetId must be a non-empty string");return}const o=this.gridModel.flowEngine.getModel(t);if(!o){console.error(`[NocoBase]: Target model with uid "${t}" not found`);return}if(!o.resource||typeof o.resource.addFilterGroup!="function"){console.error(`[NocoBase]: Target model with uid "${t}" does not have a valid resource with addFilterGroup method`);return}if(typeof o.resource.removeFilterGroup!="function"){console.error(`[NocoBase]: Target model with uid "${t}" does not have a valid resource with removeFilterGroup method`);return}const n=this.filterConfigs.filter(l=>l.targetId===t);n.length!==0&&n.forEach(l=>{const i=this.gridModel.flowEngine.getModel(l.filterId);if(!i){console.error(`[NocoBase]: Filter model with uid "${l.filterId}" not found`);return}if(!i.getFilterValue){console.error(`[NocoBase]: Filter model with uid "${l.filterId}" does not have getFilterValue method`);return}const r=i.getFilterValue();if(iP(r)){try{o.resource.removeFilterGroup(l.filterId)}catch(c){console.error(`[NocoBase]: Failed to remove filter configuration from target model: ${c.message}`);return}return}const s=l.filterPaths.map(c=>({path:c,operator:l.operator||Qx(i),value:r}));try{if(s.length===1)o.resource.addFilterGroup(l.filterId,new w.FilterItem({path:s[0].path,operator:s[0].operator,value:s[0].value}));else if(s.length>1){const c={logic:"$or",items:s};o.resource.addFilterGroup(l.filterId,new w.FilterGroup(c))}}catch(c){console.error(`Failed to bind filter configuration to target model: ${c.message}`);return}})}unbindFromTarget(t){if(!t||typeof t!="string"){console.error("targetId must be a non-empty string");return}const o=this.gridModel.flowEngine.getModel(t);if(!o){console.error(`Target model with uid "${t}" not found`);return}if(!o.resource||typeof o.resource.removeFilterGroup!="function"){console.error(`Target model with uid "${t}" does not have a valid resource with removeFilterGroup method`);return}const n=this.filterConfigs.filter(l=>l.targetId===t);n.length!==0&&n.forEach(l=>{try{o.resource.removeFilterGroup(l.filterId)}catch(i){console.error(`Failed to unbind filter configuration from target model: ${i.message}`);return}})}refreshTargetsByFilter(t){return O(this,null,function*(){if(!t){console.error("filterId must be provided");return}const o=Array.isArray(t)?t:[t];if(o.length===0||o.some(i=>!i||typeof i!="string")){console.error("filterId must be non-empty string(s)");return}const n=this.filterConfigs.filter(i=>o.includes(i.filterId));if(n.length===0)return;const l=[...new Set(n.map(i=>i.targetId))].map(i=>O(this,null,function*(){var r,s;try{this.bindToTarget(i);const c=this.gridModel.flowEngine.getModel(i);if(!c){console.error(`Target model with uid "${i}" not found`);return}if(!c.resource||typeof c.resource.refresh!="function"){console.error(`Target model with uid "${i}" does not have a valid resource with refresh method`);return}(s=(r=c.resource).setPage)==null||s.call(r,1),yield c.resource.refresh()}catch(c){console.error(`Failed to refresh target model "${i}": ${c.message}`);return}}));yield Promise.all(l)})}}function eW({rows:e,sizes:t={},renderItem:o,rowGap:n=16,colGap:l=16,dragOverlayRect:i}){return Object.keys(e||{}).length===0?a.jsx("div",{style:{position:"relative"},"data-grid-empty-container":!0,children:i&&a.jsx(gy,{rect:i})}):a.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",gap:n},children:[i&&a.jsx(gy,{rect:i}),Object.entries(e).map(([r,s])=>{const c=s.length,d=t[r]||[],u=d.some(h=>h!=null&&h!==void 0),p=s.map((h,g)=>{var v;if(u){const x=d.reduce((C,k)=>C+(k||0),0),b=c-d.filter(Boolean).length,S=b>0?(24-x)/b:0;return(v=d[g])!=null?v:S}else return 24/c});return a.jsx(I.Row,{gutter:l,"data-grid-row-id":r,children:s.map((h,g)=>a.jsx(rP,{rowKey:r,columnIndex:g,span:p[g],rowGap:n,cell:h,renderItem:o},`${r}:${h.join("|")||"empty"}`))},r)})]})}const rP=m.memo(function({rowKey:t,columnIndex:o,span:n,rowGap:l,cell:i,renderItem:r}){return a.jsx(I.Col,{span:n,"data-grid-column-row-id":t,"data-grid-column-index":o,children:a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:l},children:i.map((s,c)=>s===w.EMPTY_COLUMN_UID?null:a.jsx("div",{"data-grid-item-row-id":t,"data-grid-column-index":o,"data-grid-item-index":c,"data-grid-item-uid":s,children:r(s)},s))})})});rP.displayName="GridColumn";function gy({rect:e}){const t={position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height,borderRadius:6,pointerEvents:"none",transition:"all 60ms ease-out",zIndex:100},o={column:{border:"2px dashed var(--colorPrimary)",backgroundColor:"rgba(22, 119, 255, 0.08)"},"column-edge":{border:"2px solid var(--colorPrimary)",backgroundColor:"rgba(22, 119, 255, 0.12)"},"row-gap":{border:"2px dashed var(--colorPrimary)",backgroundColor:"rgba(22, 119, 255, 0.05)"},"empty-row":{border:"2px dashed var(--colorPrimary)",backgroundColor:"rgba(22, 119, 255, 0.04)"},"empty-column":{border:"2px dashed var(--colorPrimary)",backgroundColor:"rgba(22, 119, 255, 0.04)"}};return a.jsx("div",{style:f(f({},t),o[e.type])})}const tW=e=>{var t=e,{value:o,onChange:n,rows:l=10}=t,i=ne(t,["value","onChange","rows"]);const[r,s]=m.useState(()=>o?JSON.stringify(o,null,2):""),[c,d]=m.useState(null);m.useEffect(()=>{s(o?JSON.stringify(o,null,2):"")},[o]);const u=p=>{const h=p.target.value;s(h);try{const g=h.trim()?JSON.parse(h):void 0;d(null),n==null||n(g)}catch(g){d(g.message)}};return a.jsxs("div",{children:[a.jsx(I.Input.TextArea,f({value:r,autoSize:{minRows:l,maxRows:l+10},onChange:u},i)),c&&a.jsx(I.Alert,{type:"error",message:c,showIcon:!0,style:{marginTop:8}})]})},vy=y.connect(tW),ci="gridSettings",mr="grid",xy=e=>{if(!e)return null;if(typeof e.clientX=="number"&&typeof e.clientY=="number")return{x:e.clientX,y:e.clientY};if(e.touches&&e.touches.length>0){const t=e.touches[0];return{x:t.clientX,y:t.clientY}}if(e.changedTouches&&e.changedTouches.length>0){const t=e.changedTouches[0];return{x:t.clientX,y:t.clientY}}return null};class Aa extends w.FlowModel{constructor(){super(...arguments),A(this,"subModelBaseClass","BlockModel"),A(this,"gridContainerRef",m.createRef()),A(this,"prevMoveDistance",0),A(this,"itemSettingsMenuLevel",1),A(this,"itemFlowSettings",{}),A(this,"dragOverlayConfig"),A(this,"itemFallback",a.jsx(On,{})),A(this,"itemExtraToolbarItems",[{key:"drag-handler",component:w.DragHandler,sort:1}]),A(this,"dragState"),A(this,"_memoItemFlowSettings")}getItemFlowSettings(){return this._memoItemFlowSettings||(this._memoItemFlowSettings=f({showBackground:!1,showDragHandle:!0},this.itemFlowSettings)),this._memoItemFlowSettings}onMount(){super.onMount(),this.emitter.on("onSubModelAdded",t=>{if(!t.isNew)return;this.resetRows(!0);const o=w.findModelUidPosition(t.uid,this.props.rows||{});if(o){const n=L.cloneDeep(this.props.sizes||{});n[o.rowId]=[24],this.setStepParams(ci,mr,{rows:this.props.rows||{},sizes:n}),this.setProps("sizes",n)}}),this.emitter.on("onSubModelDestroyed",t=>{var o,n,l,i;const r=t.uid,s=w.findModelUidPosition(r,this.props.rows||{});if(this.resetRows(!0),s){const c=this.props.rows||{},d=L.cloneDeep(this.props.sizes||{});((o=c[s.rowId])==null?void 0:o[s.columnIndex])===void 0&&((n=d[s.rowId])==null||n.splice(s.columnIndex,1)),c[s.rowId]===void 0&&delete d[s.rowId],this.setStepParams(ci,mr,{rows:c,sizes:d}),this.setProps("sizes",d)}(l=this.context.filterManager)==null||l.removeFilterConfig({targetId:r}),(i=this.context.filterManager)==null||i.removeFilterConfig({filterId:r}),this.saveStepParams()}),this.emitter.on("onSubModelMoved",()=>{this.resetRows(!0)}),this.emitter.on("onResizeLeft",({resizeDistance:t,model:o})=>{var n;const l=w.findModelUidPosition(o.uid,this.props.rows||{}),i=((n=this.gridContainerRef.current)==null?void 0:n.clientWidth)||0,{newRows:r,newSizes:s,moveDistance:c}=gh({position:l,direction:"left",resizeDistance:t,prevMoveDistance:this.prevMoveDistance,oldRows:this.props.rows||{},oldSizes:this.props.sizes||{},gutter:this.context.themeToken.marginBlock,gridContainerWidth:i});this.prevMoveDistance=c,this.setProps("rows",r),this.setProps("sizes",s)}),this.emitter.on("onResizeRight",({resizeDistance:t,model:o})=>{var n;const l=w.findModelUidPosition(o.uid,this.props.rows||{}),i=((n=this.gridContainerRef.current)==null?void 0:n.clientWidth)||0,{newRows:r,newSizes:s,moveDistance:c}=gh({position:l,direction:"right",resizeDistance:t,prevMoveDistance:this.prevMoveDistance,oldRows:this.props.rows||{},oldSizes:this.props.sizes||{},gutter:this.context.themeToken.marginBlock,gridContainerWidth:i});this.prevMoveDistance=c,this.setProps("rows",r),this.setProps("sizes",s)}),this.emitter.on("onResizeBottom",({resizeDistance:t,model:o})=>{}),this.emitter.on("onResizeEnd",()=>{this.prevMoveDistance=0,this.saveGridLayout()})}saveGridLayout(t){var o,n,l,i;const r=(n=(o=t==null?void 0:t.rows)!=null?o:this.props.rows)!=null?n:{},s=(i=(l=t==null?void 0:t.sizes)!=null?l:this.props.sizes)!=null?i:{};this.setStepParams(ci,mr,{rows:r,sizes:s}),this.saveStepParams()}mergeRowsWithItems(t){const o=this.subModels.items||[];if(!o||o.length===0)return{};const n=new Set(o.map(s=>s.uid));n.add(w.EMPTY_COLUMN_UID);const l=new Set,i={};for(const[s,c]of Object.entries(t)){const d=c.map(u=>L.castArray(u).filter(p=>n.has(p))).filter(u=>u.length>0);d.length>0&&(i[s]=d,d.forEach(u=>u.forEach(p=>l.add(p))))}const r=new Set;Object.values(i).forEach(s=>s.forEach(c=>c.forEach(d=>r.add(d))));for(const s of o)r.has(s.uid)||(i[ee.uid()]=[[s.uid]]);return i}resetRows(t=!1){const o=this.getStepParams(ci,mr)||{},n=this.mergeRowsWithItems(o.rows||{});this.setStepParams(ci,mr,{rows:n,sizes:o.sizes||{}}),t&&this.setProps("rows",n)}computePointerPosition(t){var o;if(!this.dragState)return null;const n=this.dragState.pointerOrigin;if(n)return{x:n.x+t.delta.x,y:n.y+t.delta.y};const l=xy(t.activatorEvent);if(l)return this.dragState.pointerOrigin=l,{x:l.x+t.delta.x,y:l.y+t.delta.y};const i=(o=t.over)==null?void 0:o.rect;return i?{x:i.left+i.width/2,y:i.top+i.height/2}:null}updateLayoutSnapshot(){if(!this.dragState)return;const t=w.buildLayoutSnapshot({container:this.gridContainerRef.current});this.dragState.slots=t.slots,this.dragState.containerRect=t.containerRect}scheduleSnapshotRefresh(){this.dragState&&(this.dragState.refreshTimer&&clearTimeout(this.dragState.refreshTimer),this.dragState.refreshTimer=setTimeout(()=>{this.dragState&&(this.dragState.refreshTimer=null,this.updateLayoutSnapshot())},16))}computeOverlayRect(t){var o,n,l,i,r,s,c,d,u;const p=this.dragOverlayConfig,h=t.rect;switch(t.type){case"column":{const g=(o=p==null?void 0:p.columnInsert)==null?void 0:o[t.position],v=(n=g==null?void 0:g.height)!=null?n:h.height,x=(l=g==null?void 0:g.offsetTop)!=null?l:0;return{top:h.top+x,left:h.left,width:h.width,height:v}}case"column-edge":{const g=(i=p==null?void 0:p.columnEdge)==null?void 0:i[t.direction],v=(r=g==null?void 0:g.width)!=null?r:h.width,x=(s=g==null?void 0:g.offsetLeft)!=null?s:0;return{top:h.top,left:h.left+x,width:v,height:h.height}}case"row-gap":{const g=(c=p==null?void 0:p.rowGap)==null?void 0:c[t.position],v=(d=g==null?void 0:g.height)!=null?d:h.height,x=(u=g==null?void 0:g.offsetTop)!=null?u:0;return{top:h.top+x,left:h.left,width:h.width,height:v}}case"empty-column":case"empty-row":return{top:h.top,left:h.left,width:h.width,height:h.height};default:return{top:h.top,left:h.left,width:h.width,height:h.height}}}applyPreview(t){var o,n;if(!this.dragState)return;if(!t){this.dragState.activeSlotKey!==null&&(this.dragState.activeSlotKey=null,this.dragState.previewLayout=void 0,this.setProps("dragOverlayRect",null));return}const l=w.getSlotKey(t);if(this.dragState.activeSlotKey===l&&this.dragState.previewLayout)return;const i=w.simulateLayoutForSlot({slot:t,sourceUid:this.dragState.sourceUid,layout:this.dragState.snapshot,generateRowId:ee.uid});this.dragState.previewLayout={rows:L.cloneDeep(i.rows),sizes:L.cloneDeep(i.sizes)};const r=this.gridContainerRef.current,s=(o=r==null?void 0:r.scrollTop)!=null?o:0,c=(n=r==null?void 0:r.scrollLeft)!=null?n:0,d=this.computeOverlayRect(t),u={top:d.top-this.dragState.containerRect.top+s,left:d.left-this.dragState.containerRect.left+c,width:d.width,height:d.height,type:t.type};this.setProps("dragOverlayRect",u),this.dragState.activeSlotKey=l}handleDragStart(t){var o;const n=t.active.id;this.dragState={sourceUid:n,snapshot:{rows:L.cloneDeep(this.props.rows||{}),sizes:L.cloneDeep(this.props.sizes||{})},slots:[],containerRect:{top:0,left:0,width:0,height:0},pointerOrigin:(o=xy(t.activatorEvent))!=null?o:void 0,activeSlotKey:null,previewLayout:void 0,refreshTimer:null},this.setProps("dragOverlayRect",null),this.updateLayoutSnapshot(),this.scheduleSnapshotRefresh()}handleDragMove(t){if(!this.dragState)return;this.dragState.slots.length||this.updateLayoutSnapshot();const o=this.computePointerPosition(t);if(!o){this.applyPreview(null);return}const n=w.resolveDropIntent(o,this.dragState.slots);this.applyPreview(n)}finishDrag(){this.dragState&&(this.dragState.refreshTimer&&clearTimeout(this.dragState.refreshTimer),this.dragState=void 0,this.setProps("dragOverlayRect",null))}handleDragEnd(t){if(!this.dragState)return;const o=this.dragState.previewLayout;o&&(this.setProps("rows",L.cloneDeep(o.rows)),this.setProps("sizes",L.cloneDeep(o.sizes)),this.saveGridLayout(o)),this.finishDrag()}handleDragCancel(t){this.finishDrag()}renderAddSubModelButton(){throw new Error("renderAddSubModelButton method must be implemented in subclasses of GridModel")}getVisibleLayout(){var t;const o=this.props.rows||{},n=this.props.sizes||{},l=this.context.isMobileLayout?aP(o):o,i=this.context.isMobileLayout?{}:n;if(this.context.flowSettingsEnabled)return{rows:l,sizes:i};const r=((t=this.subModels)==null?void 0:t.items)||[];if(!r.length)return{rows:l,sizes:i};const s=new Map(r.map(u=>[u.uid,u])),c={},d={};return Object.entries(l).forEach(([u,p])=>{const h=p,g=i[u]||[],v=[],x=[];h.forEach((b,S)=>{b.some(C=>{if(C===w.EMPTY_COLUMN_UID)return!1;const k=s.get(C);return!k||!k.hidden})&&(v.push(b),x.push(g[S]))}),v.length>0&&(c[u]=v,x.length>0&&(d[u]=x))}),{rows:c,sizes:d}}render(){const{rows:t,sizes:o}=this.getVisibleLayout(),n=Object.keys(t||{}).length>0;return a.jsxs(a.Fragment,{children:[n&&a.jsx(I.Space,{ref:this.gridContainerRef,direction:"vertical",style:{width:"100%",marginBottom:this.props.rowGap},size:this.props.rowGap,children:a.jsx(w.DndProvider,{onDragStart:this.handleDragStart.bind(this),onDragMove:this.handleDragMove.bind(this),onDragEnd:this.handleDragEnd.bind(this),onDragCancel:this.handleDragCancel.bind(this),children:a.jsx(eW,{rowGap:this.props.rowGap,colGap:this.props.colGap,rows:t,sizes:o,dragOverlayRect:this.props.dragOverlayRect,renderItem:l=>{var i,r;const s=this.flowEngine.getModel(l);if(!s)return this.itemFallback;const c=this.context.fieldKey,d=this.context.fieldIndex,u=this.context.record,p=this.context.currentObject,h=d==null?s:(()=>{const g=s.createFork({},`${c}:${l}`);return g.context.defineProperty("fieldIndex",{get:()=>d}),g.context.defineProperty("fieldKey",{get:()=>c}),g.context.defineProperty("record",{get:()=>u,cache:!1}),g.context.defineProperty("currentObject",{get:()=>p,cache:!1}),g})();return a.jsx(w.Droppable,{model:h,children:a.jsx(w.MemoFlowModelRenderer,{model:h,fallback:s.skeleton||this.itemFallback,showFlowSettings:this.context.flowSettingsEnabled?this.getItemFlowSettings():!1,showErrorFallback:!0,settingsMenuLevel:(i=h==null?void 0:h.settingsMenuLevel)!=null?i:this.itemSettingsMenuLevel,showTitle:!0,extraToolbarItems:this.itemExtraToolbarItems},`${h.uid}:${c}:${(h==null?void 0:h.use)||((r=h==null?void 0:h.constructor)==null?void 0:r.name)||"m"}`)})}})})}),this.context.flowSettingsEnabled&&a.jsx("div",{style:{marginBottom:16},children:this.renderAddSubModelButton()})]})}}Aa.registerFlow({key:ci,steps:{resetRows:{handler(e){e.model.resetRows()}},grid:{uiSchema:{rows:{title:w.tExpr("Rows"),"x-decorator":"FormItem","x-component":vy,"x-component-props":{autoSize:{minRows:10,maxRows:20},description:w.tExpr("Configure the rows and columns of the grid.")}},sizes:{title:w.tExpr("Sizes"),"x-decorator":"FormItem","x-component":vy,"x-component-props":{rows:5},description:w.tExpr("Configure the sizes of each row. The value is an array of numbers representing the width of each column in the row.")}},handler(e,t){return O(this,null,function*(){const o=e.model.mergeRowsWithItems(t.rows||{});e.model.setProps("rows",o),e.model.setProps("sizes",t.sizes||{})})}}}});function aP(e,t){var o;const n=(o=t==null?void 0:t.emptyColumnUid)!=null?o:w.EMPTY_COLUMN_UID,l={};return Object.keys(e).forEach(i=>{e[i].forEach(r=>{const s=r.filter(c=>c!==n);s.length>0&&(l[ee.uid()]=[s])})}),l}function gh({position:e,direction:t,resizeDistance:o,prevMoveDistance:n,oldSizes:l,oldRows:i,gridContainerWidth:r,gutter:s=16,columnCount:c=24}){var d;const u=L.cloneDeep(i),p=L.cloneDeep(l),h=p[e.rowId]||[],g=s*(h.length-1);let v=Math.floor(o/(r-g)*c);if(v===n)return{newRows:u,newSizes:p,moveDistance:v};p[d=e.rowId]!=null||(p[d]=[c]);const x=p[e.rowId];let b=v-n;const S=t==="left"&&e.columnIndex>0,C=t==="right"&&e.columnIndex<x.length-1;if(!S&&!C&&b>0){const k=x.reduce((j,P)=>j+P,0),F=c-k;if(F<=0)return{newRows:u,newSizes:p,moveDistance:n};b>F&&(v=n+F,b=F)}if(p[e.rowId][e.columnIndex]+=b,t==="left"&&e.columnIndex>0&&(p[e.rowId][e.columnIndex-1]-=b,p[e.rowId][e.columnIndex-1]===0&&by({rows:u,sizes:p,position:e,direction:"left"})),t==="left"&&e.columnIndex===0){const k=p[e.rowId].slice(1).reduce((F,j)=>F+j,0);p[e.rowId][0]<c-k&&fy({rows:u,sizes:p,position:e,direction:"left"})}if(t==="right"&&e.columnIndex<p[e.rowId].length-1&&(p[e.rowId][e.columnIndex+1]-=b,p[e.rowId][e.columnIndex+1]===0&&by({rows:u,sizes:p,position:e,direction:"right"})),t==="right"&&e.columnIndex===p[e.rowId].length-1){const k=p[e.rowId].slice(0,-1).reduce((F,j)=>F+j,0);p[e.rowId][e.columnIndex]<c-k&&fy({rows:u,sizes:p,position:e,direction:"right"})}return{newRows:u,newSizes:p,moveDistance:v}}function fy({rows:e,sizes:t,position:o,direction:n}){const l=e[o.rowId]||[],i=t[o.rowId]||[];if(n==="left"){const r=l[o.columnIndex-1];if(r!=null&&r.includes(w.EMPTY_COLUMN_UID))return;l.splice(o.columnIndex,0,[w.EMPTY_COLUMN_UID]),i.splice(o.columnIndex,0,1)}if(n==="right"){const r=l[o.columnIndex+1];if(r!=null&&r.includes(w.EMPTY_COLUMN_UID))return;l.splice(o.columnIndex+1,0,[w.EMPTY_COLUMN_UID]),i.splice(o.columnIndex+1,0,1)}}function by({rows:e,sizes:t,position:o,direction:n}){const l=e[o.rowId]||[],i=t[o.rowId]||[];if(n==="left"){const r=l[o.columnIndex-1];if(!(r!=null&&r.includes(w.EMPTY_COLUMN_UID)))return;l.splice(o.columnIndex-1,1),i.splice(o.columnIndex-1,1)}if(n==="right"){const r=l[o.columnIndex+1];if(!(r!=null&&r.includes(w.EMPTY_COLUMN_UID)))return;l.splice(o.columnIndex+1,1),i.splice(o.columnIndex+1,1)}}class sP extends Aa{constructor(){super(...arguments),A(this,"dragOverlayConfig",{columnInsert:{before:{offsetTop:-24},after:{offsetTop:24}},columnEdge:{left:{offsetLeft:-5},right:{offsetLeft:6}}})}onInit(t){super.onInit(t),this.context.defineProperty("blockGridModel",{value:this}),this.context.defineProperty("filterManager",{once:!0,get:()=>new Zx(this,t.filterManager)})}get subModelBaseClasses(){var t,o;const n=(o=(t=this.context.view)==null?void 0:t.inputArgs)!=null?o:{};return n.collectionName&&!n.filterByTk?["DataBlockModel","FilterBlockModel","BlockModel"]:["DataBlockModel","FilterBlockModel","BlockModel"]}get filterManager(){return this.context.filterManager}serialize(){const t=super.serialize();return t.filterManager=this.filterManager.getFilterConfigs(),t}renderAddSubModelButton(){return a.jsx(w.AddSubModelButton,{model:this,subModelKey:"items",subModelBaseClasses:this.subModelBaseClasses,children:a.jsx(w.FlowSettingsButton,{icon:a.jsx(te.PlusOutlined,{}),children:this.context.t("Add block")})})}render(){return a.jsx("div",{style:{padding:this.context.isMobileLayout?8:this.context.themeToken.marginBlock},children:super.render()})}}sP.registerFlow({key:"blockGridSettings",steps:{grid:{handler(e,t){e.model.setProps("rowGap",e.isMobileLayout?12:e.themeToken.marginBlock),e.model.setProps("colGap",e.themeToken.marginBlock)}}}});const oW=L.memoize(e=>O(void 0,null,function*(){return e&&(yield Promise.resolve().then(()=>require("./md-BbvRKckr-IQIU5F3r.js"))).default.render(e)}));function nW(e){const[t,o]=m.useState(""),[n,l]=m.useState(!0);return m.useEffect(()=>{l(!0),oW(e).then(i=>{o(i),l(!1)}).catch(i=>console.log(i))},[e]),{html:t,loading:n}}function lW(e){const t=e;let o=document.createElement("div");o.innerHTML=t;const n=o.innerText;return o=null,(n==null?void 0:n.replace(/[\n\r]/g,""))||""}const iW=()=>{const{token:e}=I.theme.useToken(),{isDarkTheme:t}=Go(),o=new pl.TinyColor(e.colorFillAlter).onBackground(e.colorBgContainer).toHexShortString(),n={lineHeight:"inherit","&.nb-markdown-default":{"pre code.hljs":{display:"block",overflowX:"auto",padding:"1em"},"code.hljs":{padding:"3px 5px"},":not(pre) code":{padding:"2px 5px",color:"#d56161",background:e.colorFillQuaternary,border:`1px solid ${e.colorBorder}`,borderRadius:e.borderRadiusSM},blockquote:{borderLeft:"4px solid #ccc",paddingLeft:"20px",marginLeft:"0",color:"#666",fontStyle:"italic"},img:{maxWidth:"100%"},".hljs":{background:"#f8f8f8",color:"#444"},".hljs-comment":{color:"#697070"},".hljs-punctuation,.hljs-tag":{color:"#444a"},".hljs-tag .hljs-attr,.hljs-tag .hljs-name":{color:"#444"},".hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag":{fontWeight:700},".hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type":{color:"#800"},".hljs-section,.hljs-title":{color:"#800",fontWeight:700},".hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable":{color:"#ab5656"},".hljs-literal":{color:"#695"},".hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code":{color:"#397300"},".hljs-meta":{color:"#1f7199"},".hljs-meta .hljs-string":{color:"#38a"},".hljs-emphasis":{fontStyle:"italic"},".hljs-strong":{fontWeight:700}},"&.nb-markdown-table":{table:{borderCollapse:"collapse",width:"100%",fontFamily:"Arial, sans-serif",marginBottom:"1.5rem"},"th, td":{borderBottom:`1px solid ${e.colorBorderSecondary}`,padding:`${e.paddingContentVertical}px ${e.paddingContentHorizontal}px`,textAlign:"left"},th:{backgroundColor:o,fontWeight:"bold",color:e.colorText},"tr:hover":{backgroundColor:e.colorFillTertiary},"tr:last-child td":{borderBottom:"none"},"tr:first-child th":{borderTop:"none"}}},l={"&.nb-markdown-default":{"pre code.hljs":{display:"block",overflowX:"auto",padding:"1em"},"code.hljs":{padding:"3px 5px"},":not(pre) code":{padding:"2px 5px",color:"#d56161",background:e.colorFillQuaternary,border:`1px solid ${e.colorBorder}`,borderRadius:e.borderRadiusSM},".hljs":{color:"#adbac7",background:"#22272e"},".hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_":{color:"#f47067"},".hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_":{color:"#dcbdfb"},".hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable":{color:"#6cb6ff"},".hljs-meta .hljs-string,.hljs-regexp,.hljs-string":{color:"#96d0ff"},".hljs-built_in,.hljs-symbol":{color:"#f69d50"},".hljs-code,.hljs-comment,.hljs-formula":{color:"#768390"},".hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag":{color:"#8ddb8c"},".hljs-subst":{color:"#adbac7"},".hljs-section":{color:"#316dca",fontWeight:700},".hljs-bullet":{color:"#eac55f"},".hljs-emphasis":{color:"#adbac7",fontStyle:"italic"},".hljs-strong":{color:"#adbac7",fontWeight:700},".hljs-addition":{color:"#b4f1b4",backgroundColor:"#1b4721"},".hljs-deletion":{color:"#ffd8d3",backgroundColor:"#78191b"}},"&.nb-markdown-table":{table:{borderCollapse:"collapse",width:"100%",fontFamily:"Arial, sans-serif",marginBottom:"1.5rem"},"th, td":{borderBottom:`1px solid ${e.colorBorderSecondary}`,padding:`${e.paddingContentVertical}px ${e.paddingContentHorizontal}px`,textAlign:"left"},th:{backgroundColor:o,fontWeight:"bold",color:e.colorText},"tr:hover":{backgroundColor:e.colorFillTertiary},"tr:last-child td":{borderBottom:"none"},"tr:first-child th":{borderTop:"none"}}};return Z.css(f({lineHeight:e.lineHeight,"& > *:last-child":{marginBottom:"0"},".ant-description-textarea, .ant-description-input":{lineHeight:e.lineHeight},".field-interface-datetime":{minWidth:"100px"}},t?l:n))},cP=e=>{const{textOnly:t,overflowMode:o,style:n}=e,l=iW(),{html:i=""}=nW(e.value),r=lW(i),s=o==="ellipsis",c=m.useRef(null),[d,u]=m.useState(!1);m.useEffect(()=>{if(c.current){const g=c.current,v=g.scrollWidth>g.clientWidth||g.scrollHeight>g.clientHeight;u(v)}},[i,n,o]);const p=f(f({},n||{}),s?{display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal",wordBreak:"break-word",cursor:"default"}:{}),h=a.jsx("div",{ref:c,className:`${l} nb-markdown`,dangerouslySetInnerHTML:{__html:t?r:i},style:p});return s&&d?a.jsx(I.Tooltip,{title:a.jsx("div",{dangerouslySetInnerHTML:{__html:i},style:{maxHeight:500,overflowY:"auto",padding:10,color:"#000"}}),overlayInnerStyle:{background:"#fff",color:"#000",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},color:"#fff",children:h}):h},rW=({height:e,heightMode:t})=>t!=="specifyValue"?null:e,Wa=m.forwardRef((e,t)=>{const{t:o}=K.useTranslation(),{token:n}=I.theme.useToken(),l=e,{title:i,description:r,children:s,className:c}=l,d=ne(l,["title","description","children","className"]),u=rW(e),p=(i||r)&&a.jsxs("div",{children:[a.jsxs("span",{children:[" ",o(i,{ns:Qt})]}),r&&a.jsx(cP,{value:o(r,{ns:Qt}),style:{overflowWrap:"break-word",whiteSpace:"normal",fontWeight:400,color:n.colorTextDescription,borderRadius:"4px"}})]});return a.jsxs(I.Card,T(f({ref:t,title:p,style:{display:"flex",flexDirection:"column",height:u},styles:{body:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},header:{marginTop:"8px"}},className:c},d),{children:[e.beforeContent,s,e.afterContent]}))}),aW=e=>{if(e){const t=document.createRange();return t.selectNodeContents(e),t.getBoundingClientRect().width}},sW={overflow:"hidden",overflowWrap:"break-word",textOverflow:"ellipsis",whiteSpace:"nowrap",wordBreak:"break-all"},cW={overflowWrap:"break-word",whiteSpace:"normal",wordBreak:"break-word"},dW=e=>{if(!e)return!1;const t=aW(e),o=e.offsetWidth;return t>o},uW={maxWidth:600,overflow:"auto",maxHeight:400},Yc=m.forwardRef((e,t)=>{const[o,n]=m.useState(!1),[l,i]=m.useState(!1),r=m.useRef();m.useImperativeHandle(t,()=>({setPopoverVisible:i}),[]);const s=m.useCallback(d=>{const u=d.target;dW(r.current)&&n(u.scrollWidth>=u.clientWidth)},[]),c=m.useMemo(()=>{const d=e.ellipsis?{onMouseEnter:s}:{};return a.jsx("div",T(f({ref:r,role:e.role,style:e.ellipsis?sW:cW},d),{children:e.children}))},[s,e.children,e.ellipsis,e.role]);return!e.ellipsis||!o?c:a.jsx(I.Popover,{open:o&&l,onOpenChange:d=>{i(o&&d)},content:a.jsx("div",{style:uW,children:e.popoverContent||e.children}),children:c})});Yc.displayName="EllipsisWithTooltip";const Pm=Me(),pW=Z.css`
|
|
1702
|
+
`,children:"x"})})})]})},BG=w.defineAction({name:"confirm",title:w.tExpr("Confirmation"),uiSchema:{enable:{type:"boolean",title:w.tExpr("Enable secondary confirmation"),"x-decorator":"FormItem","x-component":"Switch"},title:{type:"string",title:w.tExpr("Title"),"x-decorator":"FormItem","x-component":Rr,"x-component-props":{rows:2}},content:{type:"string",title:w.tExpr("Content"),"x-decorator":"FormItem","x-component":Rr,"x-component-props":{rows:3}}},defaultParams:{enable:!1,title:w.tExpr("Please Confirm"),content:w.tExpr("Are you sure you want to perform the action?")},handler(e,t){return O(this,null,function*(){t.enable&&((yield e.modal.confirm({title:e.t(t.title),content:e.t(t.content),okText:e.t("Confirm"),cancelText:e.t("Cancel")}))||e.exit())})}}),uy=new WeakMap;let py=0;const Lc=e=>{let t=uy.get(e);return t||(py+=1,t=`filter-item-${py}`,uy.set(e,t)),t},tr=w.observer(e=>{const{token:t}=I.theme.useToken(),{value:o={logic:"$and",items:[]},FilterItem:n,showBorder:l=!1,onRemove:i,onChange:r,closeIcon:s=a.jsx(te.CloseCircleOutlined,{style:{color:t.colorIcon}})}=e,{t:c}=K.useTranslation();o.logic||(o.logic="$and"),Array.isArray(o.items)||(o.items=[]);const{logic:d,items:u}=o,p=l?{position:"relative",border:`1px dashed ${t.colorBorder}`,padding:t.paddingSM,marginBottom:t.marginXS,borderRadius:t.borderRadius}:{position:"relative",marginBottom:t.marginXS},h=C=>{o.logic=C,r==null||r(o)},g=()=>{u.push({path:"",operator:"",value:""}),r==null||r(o)},v=()=>{u.push({logic:"$and",items:[]}),r==null||r(o)},x=C=>{u.splice(C,1),r==null||r(o)},b=C=>"path"in C||"operator"in C||"value"in C,S=C=>"logic"in C&&"items"in C;return a.jsxs("div",{style:p,children:[l&&i&&a.jsx("button",{type:"button","aria-label":"icon-close",style:{position:"absolute",right:10,top:10,cursor:"pointer",background:"transparent",border:0,padding:0},onClick:i,children:s}),a.jsx("div",{style:{marginBottom:8,color:t.colorText},children:a.jsxs("span",{children:[c("Meet")," ",a.jsxs(I.Select,{"data-testid":"filter-select-all-or-any",style:{width:"auto"},value:d,onChange:h,children:[a.jsx(I.Select.Option,{value:"$and",children:c("All")}),a.jsx(I.Select.Option,{value:"$or",children:c("Any")})]})," ",c("conditions in the group")]})}),a.jsx("div",{children:u.map((C,k)=>S(C)?a.jsx(tr,{value:C,FilterItem:n,showBorder:!0,onRemove:()=>x(k),onChange:F=>{u[k]=F,r==null||r(o)}},Lc(C)):b(C)?n?a.jsx("div",{style:{marginBottom:8,display:"flex",alignItems:"flex-end"},children:a.jsxs(I.Space,{style:{flex:1,minWidth:0},children:[a.jsx(n,{value:C}),a.jsx("button",{type:"button","aria-label":"icon-close",style:{marginLeft:8,marginRight:8,flex:"0 0 auto",cursor:"pointer",background:"transparent",border:0,padding:0},onClick:()=>x(k),children:s})]})},Lc(C)):a.jsx("div",{style:{marginBottom:8,display:"flex",alignItems:"flex-end"},children:a.jsxs(I.Space,{style:{flex:1,minWidth:0},children:[a.jsxs("span",{children:[C.path," ",C.operator," ",String(C.value)]}),a.jsx("button",{type:"button","aria-label":"icon-close",style:{marginLeft:8,marginRight:8,flex:"0 0 auto",cursor:"pointer",background:"transparent",border:0,padding:0},onClick:()=>x(k),children:s})]})},Lc(C)):a.jsx("div",{style:{marginBottom:8,display:"flex",alignItems:"flex-end"},children:a.jsxs(I.Space,{style:{flex:1,minWidth:0},children:[a.jsx("span",{style:{color:t.colorTextTertiary},children:"Invalid filter item"}),a.jsx("button",{type:"button","aria-label":"icon-close",style:{marginLeft:8,marginRight:8,flex:"0 0 auto",cursor:"pointer",background:"transparent",border:0,padding:0},onClick:()=>x(k),children:s})]})},Lc(C)))}),a.jsxs(I.Space,{size:16,style:{marginTop:8,marginBottom:8},children:[a.jsx(I.Button,{style:{padding:0},type:"link",size:"small",icon:a.jsx(te.PlusOutlined,{}),onClick:g,children:c("Add condition")}),a.jsx(I.Button,{style:{padding:0},type:"link",size:"small",icon:a.jsx(te.PlusOutlined,{}),onClick:v,children:c("Add condition group")})]})]})},{displayName:"FilterGroup"}),my=w.observer(e=>{var t;const{value:o,FilterItem:n,ctx:l}=e;o.logic||(o.logic="$and"),Array.isArray(o.items)||(o.items=[]);const i=()=>{var c;(c=l==null?void 0:l.model)!=null&&c.dispatchEvent&&l.model.dispatchEvent("reset")},r=()=>{var c;(c=l==null?void 0:l.model)!=null&&c.dispatchEvent&&l.model.dispatchEvent("submit")},s=((t=l==null?void 0:l.model)==null?void 0:t.translate)||(c=>c);return a.jsxs("form",{onSubmit:c=>{c.preventDefault(),r()},children:[a.jsx(tr,{value:o,FilterItem:n}),a.jsxs(I.Space,{style:{width:"100%",display:"flex",justifyContent:"flex-end"},children:[a.jsx(I.Button,{htmlType:"button",onClick:i,children:s("Reset")}),a.jsx(I.Button,{type:"primary",htmlType:"submit",children:s("Submit")})]})]})},{displayName:"FilterContent"}),Qw=(e,t,o,n)=>e.map(l=>$G(l,t,o,n)).filter(Boolean),$G=(e,t,o,n)=>{var l;if(o.length&&t===1&&o.includes(e.name)||!e.interface||e.filterable===!1)return;const i=e.getInterfaceOptions();if(!(i!=null&&i.filterable))return;const{nested:r,children:s,operators:c}=i.filterable,d={name:e.name,type:e.type,target:e.target,title:n(e.title),schema:e==null?void 0:e.uiSchema,operators:(((l=c==null?void 0:c.filter)==null?void 0:l.call(c,u=>!(u!=null&&u.visible)||u.visible(e)))||[]).map(u=>T(f({},u),{label:n(u.label)}))};if(!(e.target&&t>2)){if(t>2)return d;if(s!=null&&s.length&&(d.children=s),r){const u=e.getFields().filter(h=>h.target!=="attachments"&&h.interface!=="formula"),p=Qw(u,t+1,o,n).filter(Boolean);d.children=d.children||[],d.children.push(...p)}return d}};w.observer(e=>{var t;const{path:o,operator:n,value:l}=e.value,i=e.model,r=((t=i.context.blockModel.collection)==null?void 0:t.getFields().filter(v=>v.target!=="attachments"))||[],s=OG(i.props.filterableFieldNames||[],r.map(v=>v.name)),c=i.translate,d=Qw(r.filter(v=>v.target!=="attachments"&&v.interface!=="formula"&&!["belongsTo","belongsToMany","hasOne","hasMany","oho","obo","m2o","o2m","m2m"].includes(v.type)),1,e.noIgnore?[]:s,c).filter(Boolean),u=m.useMemo(()=>{const v=d.find(x=>x.name===o);return(v==null?void 0:v.operators)||[]},[d,o]),p=v=>{var x;e.value.path=v;const b=d.find(S=>S.name===v);((x=b==null?void 0:b.operators)==null?void 0:x.length)>0?e.value.operator=b.operators[0].value:e.value.operator="",e.value.value=""},h=v=>{e.value.operator=v},g=v=>{e.value.value=v.target.value};return a.jsxs(I.Space,{children:[a.jsx(I.Select,{style:{width:200},placeholder:c("Select field"),value:o||void 0,onChange:p,children:d.map(v=>a.jsx(I.Select.Option,{value:v.name,children:v.title},v.name))}),a.jsx(I.Select,{style:{width:120},placeholder:c("Select operator"),value:n||void 0,onChange:h,disabled:!o||u.length===0,children:u.map(v=>a.jsx(I.Select.Option,{value:v.value,children:v.label},v.value))}),a.jsx(I.Input,{style:{width:200},placeholder:c("Enter value"),value:l,onChange:g})]})},{displayName:"FilterItem"});function OG(e,t){return t==null?void 0:t.filter(o=>!e.includes(o))}function Zw(e=[]){return Array.isArray(e)?e.map(t=>{var o;if(t&&typeof t=="object"&&!Array.isArray(t)){const n=t,l=typeof n.label<"u",i=typeof n.value<"u",r=l?n.label:String((o=n.value)!=null?o:""),s=i?n.value:r,c={label:r,value:s};return n.color&&(c.color=n.color),n.icon&&(c.icon=n.icon),c}return{label:String(t),value:t}}):[]}function eP(e=[],t){return Array.isArray(e)?e.map(o=>typeof(o==null?void 0:o.label)=="string"?T(f({},o),{label:t(o.label)}):o):[]}function Wx(e,t){if(!e||!Array.isArray(e)||e.length===0)return;const o=Zw(e);return eP(o,t)}function Yx(e,t){var o,n,l,i;const r=t==null?void 0:t.interface;if(!["radioGroup","checkboxGroup","select","multipleSelect"].includes(r)||Array.isArray((o=e.props)==null?void 0:o.options)&&((l=(n=e.props)==null?void 0:n.options)==null?void 0:l.length)>0)return!1;const s=(i=t.uiSchema)==null?void 0:i.enum;if(!Array.isArray(s)||s.length===0)return!1;const c=Zw(s);return c.length?(e.setProps({options:c}),!0):!1}function Jx(e,t,o){var n;if(!o||!Array.isArray(o))return null;const l=o.find(d=>(d==null?void 0:d.value)===t),i=l==null?void 0:l.schema,r=i==null?void 0:i["x-component"];if(!r)return null;const s=(n=e==null?void 0:e.getComponent)==null?void 0:n.call(e,r);if(!s)return null;const c=(i==null?void 0:i["x-component-props"])||{};return{Comp:s,props:c}}const{DateFilterDynamicComponent:LG}=_r(()=>Promise.resolve().then(()=>O8),"DateFilterDynamicComponent");function VG(e){return O(this,null,function*(){var t,o,n,l;const i=d=>O(this,null,function*(){return Array.isArray(d)?d:typeof d=="function"?yield d():[]});if((o=(t=e.getPropertyOptions)==null?void 0:t.call(e,"collection"))!=null&&o.meta){const d=(n=e.getPropertyMetaTree)==null?void 0:n.call(e,"{{ ctx.collection }}");return yield i(d)}const r=()=>{var d;return(d=e==null?void 0:e.collection)!=null?d:null},s=yield w.createEphemeralContext(e,{defineProperties:{collection:{get:r,meta:w.createCollectionContextMeta(r,"Current collection")}}}),c=(l=s.getPropertyMetaTree)==null?void 0:l.call(s,"{{ ctx.collection }}");return yield i(c)})}function zG(e,t,o,n){var l;const i=e==null?void 0:e["x-component"],r=((l=t==null?void 0:t.uiSchema)==null?void 0:l["x-component-props"])||{},s=(e==null?void 0:e["x-component-props"])||{},c=gr({},r,s),d=Wx(e==null?void 0:e.enum,o)||[],u=f({style:f({width:200},(c==null?void 0:c.style)||{}),placeholder:(c==null?void 0:c.placeholder)||o("Enter value")},c),p=h=>{if(typeof h=="number"||(c==null?void 0:c.stringMode)===!0&&typeof h=="string")return h};return h=>{const g=h||{},{value:v,onChange:x}=g,b=ne(g,["value","onChange"]);if(i==="InputNumber")return a.jsx(I.InputNumber,T(f(f({},u),b),{value:p(v),onChange:S=>x==null?void 0:x(S)}));if(i==="NumberPicker")return a.jsx(ue.NumberPicker,T(f(f({},u),b),{value:p(v),onChange:S=>x==null?void 0:x(S)}));if(i==="Switch")return a.jsx(I.Switch,T(f(f({},u),b),{checked:!!v,onChange:S=>x==null?void 0:x(S)}));if(i==="Select")return a.jsx(I.Select,T(f(f({options:d},u),b),{value:Array.isArray(v)||typeof v=="string"||typeof v=="number"||typeof v=="boolean"?v:void 0,onChange:S=>x==null?void 0:x(S)}));if(i==="DateFilterDynamicComponent")return a.jsx(LG,T(f(f({},u),b),{value:v,onChange:S=>x==null?void 0:x(S)}));if(i&&n!=null&&n.getComponent){const S=n.getComponent(i);if(S)return a.jsx(S,T(f(f({},u),b),{value:v,onChange:C=>x==null?void 0:x(C),style:f(f({width:200},u.style||{}),b==null?void 0:b.style)}))}return a.jsx(I.Input,T(f(f({},u),b),{value:typeof v=="string"?v:v==null?"":String(v),onChange:S=>x==null?void 0:x(S.target.value)}))}}function _G(e){var t;if(e&&typeof e=="object"){const o=e;if(typeof o.preventDefault=="function"||o.nativeEvent||"target"in o){const n=(t=o.target)==null?void 0:t.value;return n!==void 0?n:e}}return e}const Ga=w.observer(({value:e,model:t,rightAsVariable:o,rightMetaTree:n,ignoreFieldNames:l})=>{const i=w.useFlowViewContext(),r=t.translate,{path:s,operator:c,value:d}=e,[u,p]=m.useState(null),h=m.useMemo(()=>{var _,H,G,W;if(!u)return[];const Q=(_=t.context.app)==null?void 0:_.dataSourceManager,Y=u.interface?(H=Q==null?void 0:Q.collectionFieldInterfaceManager)==null?void 0:H.getFieldInterface(u.interface):void 0,J=(G=u==null?void 0:u.uiSchema)==null?void 0:G["x-filter-operators"];return((Array.isArray(J)&&J.length?J:(W=Y==null?void 0:Y.filterable)==null?void 0:W.operators)||[]).filter(ae=>!ae.visible||ae.visible(u))},[u,t]);m.useEffect(()=>{if(!h.length)return;const _=L.find(h,H=>H.value===e.operator);if(_)e.noValue=!!_.noValue;else{const H=h[0];e.operator=H.value,e.value=H.noValue?!0:void 0,e.noValue=!!H.noValue}},[h,e]);const g=m.useMemo(()=>h.map(_=>({value:_.value,label:typeof _.label=="string"?r(_.label):_.label})),[h,r]),v=m.useCallback((_,H)=>{e.path=_||"",H&&p(H)},[e]),x=m.useMemo(()=>({resolveValueFromPath:_=>(p(_),(_==null?void 0:_.paths.slice(1).join("."))||null),resolvePathFromValue(_){return _&&["collection",...String(_).split(".")]}}),[]),b=m.useCallback(_=>{e.operator=_;const H=h.find(G=>G.value===_);H!=null&&H.noValue?(e.value=!0,e.noValue=!0):(e.value=void 0,e.noValue=!1)},[h,e]),S=m.useMemo(()=>h.find(_=>_.value===c),[h,c]),C=m.useMemo(()=>{const _=(u==null?void 0:u.uiSchema)||{},H=(S==null?void 0:S.schema)||{},G=gr({},_,H);if((u==null?void 0:u.interface)==="formula"){const W={"x-read-pretty":!1,"x-component":"Input","x-component-props":f({},G["x-component-props"])};return gr({},G,W)}return G},[u,S]),k=m.useRef(C==null?void 0:C["x-component"]),F=C==null?void 0:C["x-component"],j=m.useMemo(()=>{const _=k.current;k.current=F;const H=_!==void 0&&_!==F;if(S!=null&&S.noValue)return d;if(H&&d!=null){e.value=void 0;return}return d},[F,d,e,S]),P=m.useCallback(_=>{e.value=_G(_)},[e]),M=m.useRef(r);m.useEffect(()=>{M.current=r},[r]);const R=m.useCallback(_=>{var H,G;return(G=(H=M.current)==null?void 0:H.call(M,_))!=null?G:_},[]),N=m.useMemo(()=>Wx(C==null?void 0:C.enum,R)||[],[C,R]),D=m.useMemo(()=>zG(C,u,R,t.context.app),[C,u,R,t.context.app]),B=m.useCallback(_=>_?_==="Input"||_==="InputNumber"||_==="NumberPicker"||_==="Switch"||_==="Select"||_==="DateFilterDynamicComponent":!0,[]),$=m.useMemo(()=>{function _({dynValue:H}){const G=m.useRef(()=>{}),W=m.useCallback(J=>{P(J)},[P]);m.useEffect(()=>{G.current=W},[W]);const Q=m.useRef(null);Q.current||(Q.current=Oe.createForm({values:{value:H},effects(){const J=ae=>"value"in ae;Oe.onFieldValueChange("value",ae=>{J(ae)&&G.current(ae.value)})}})),m.useEffect(()=>{var J;(J=Q.current)==null||J.setValues({value:H})},[H]);const Y=m.useMemo(()=>gr({name:"value","x-component":"Input","x-component-props":{style:{width:200},placeholder:R("Enter value")},"x-read-pretty":!1,"x-validator":void 0,"x-decorator":void 0},C||{}),[C,R]);return a.jsx(Io,{form:Q.current,children:a.jsx("div",{style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},children:a.jsx(He,{schema:Y})})})}return _},[C,R,P]),q=m.useCallback(()=>{const _=Jx(t.context.app,c,h);if(_&&(c==="$in"||c==="$notIn")){const{Comp:H,props:G}=_;(!(G!=null&&G.options)||(G==null?void 0:G.options.length)===0)&&N!=null&&N.length&&(G.options=N);const W=f({flex:"1 1 40%",minWidth:160,maxWidth:"100%"},(G==null?void 0:G.style)||{}),Q=Array.isArray(j)&&j.every(Y=>typeof Y=="string"||typeof Y=="number")?j:typeof j=="string"?j.split(/\r?\n/).map(Y=>Y.trim()).filter(Boolean):[];return a.jsx("div",{style:W,children:a.jsx(H,T(f({},G),{style:f({width:"100%"},(G==null?void 0:G.style)||{}),value:Q,onChange:Y=>P(Y)}))})}return B(F)?a.jsx("div",{style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},children:a.jsx(D,{value:j,onChange:H=>P(H)})}):a.jsx($,{dynValue:j})},[$,B,c,h,j,D,t.context.app,P,N]),E=m.useMemo(()=>function(){return a.jsx(I.Input,{placeholder:`<${r("Null")}>`,readOnly:!0})},[r]),U=m.useMemo(()=>()=>O(void 0,null,function*(){const _=typeof n=="function"?yield n():n??i.getPropertyMetaTree(),H=Array.isArray(_)?_:yield _();return[{title:r("Constant"),name:"constant",type:"string",paths:["constant"],render:D},{title:r("Null"),name:"null",type:"object",paths:["null"],render:E},...H]}),[n,i,D,E,r]),V=m.useMemo(()=>({renderInputComponent:_=>{var H;const G=(H=_==null?void 0:_.paths)==null?void 0:H[0];return G==="constant"?D:G==="null"?E:null},resolveValueFromPath:_=>{var H;const G=(H=_==null?void 0:_.paths)==null?void 0:H[0];if(G==="constant")return"";if(G==="null")return null},resolvePathFromValue:_=>_===null?["null"]:(typeof _=="string"?w.parseValueToPath(_):void 0)||["constant"]}),[E,D]),z=m.useMemo(()=>()=>O(void 0,null,function*(){var _;const H=(_=t.context.app)==null?void 0:_.dataSourceManager,G=H==null?void 0:H.collectionFieldInterfaceManager,W=yield VG(t.context),Q=J=>O(void 0,null,function*(){var ae,le;const ce=J.interface?G==null?void 0:G.getFieldInterface(J.interface):void 0,oe=[],ge=ce==null?void 0:ce.filterable,me=ge==null?void 0:ge.children;if(Array.isArray(me)&&me.length)for(const pe of me)oe.push({name:pe.name,title:pe.title||pe.name,type:((ae=pe.schema)==null?void 0:ae.type)||"string",interface:((le=pe.schema)==null?void 0:le["x-component"])==="Select"?"select":"input",uiSchema:T(f({},pe.schema||{}),{"x-filter-operators":pe.operators}),paths:[...J.paths||[],pe.name],parentTitles:[...J.parentTitles||[],J.title]});if(typeof J.children=="function"){const pe=J.children;return T(f({},J),{children:()=>O(void 0,null,function*(){const Se=yield pe();return[...Array.isArray(Se)?Se:[],...oe]})})}const ye=[...Array.isArray(J.children)?J.children:[],...oe];return T(f({},J),{children:ye.length?ye:J.children})}),Y=[];for(const J of W)Y.push(yield Q(J));return Y}),[t]);return a.jsxs(I.Space,{wrap:!0,style:{width:"100%"},children:[a.jsx(w.VariableInput,{value:s,metaTree:z,onChange:v,converters:x,showValueComponent:!1,style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},onlyLeafSelectable:!0,placeholder:r("Select field"),ignoreFieldNames:l}),a.jsx(I.Select,{style:{flex:"0 0 140px",minWidth:120,maxWidth:"100%"},placeholder:r("Comparison"),value:c||void 0,onChange:b,children:g.map(_=>a.jsx(I.Select.Option,{value:_.value,children:_.label},_.value))}),!(S!=null&&S.noValue)&&(o?a.jsx(w.VariableInput,{value:j,onChange:_=>P(_),metaTree:U,converters:V,showValueComponent:!0,style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},placeholder:r("Enter value")}):q())]})}),{DateFilterDynamicComponent:KG}=_r(()=>Promise.resolve().then(()=>S5),"DateFilterDynamicComponent");function UG(e,t,o){var n,l,i;const r=e==null?void 0:e["x-component"],s=((n=t==null?void 0:t.uiSchema)==null?void 0:n["x-component-props"])||{},c=(e==null?void 0:e["x-component-props"])||{},d=gr({},s,c),u=Array.isArray((l=t==null?void 0:t.uiSchema)==null?void 0:l.enum)?(i=t==null?void 0:t.uiSchema)==null?void 0:i.enum:void 0,p=Wx(u,o),h=f({style:f({width:200},(d==null?void 0:d.style)||{}),placeholder:(d==null?void 0:d.placeholder)||o("Enter value")},d);return g=>{const v=g||{},{value:x,onChange:b}=v,S=ne(v,["value","onChange"]);if(r==="InputNumber")return a.jsx(I.InputNumber,T(f(f({},h),S),{value:x,onChange:b}));if(r==="NumberPicker")return a.jsx(ue.NumberPicker,T(f(f({},h),S),{value:x,onChange:b}));if(r==="Switch")return a.jsx(I.Switch,T(f(f({},h),S),{checked:!!x,onChange:b}));if(r==="Select"){let C=h;return Array.isArray(C==null?void 0:C.options)&&C.options.length>0?C=T(f({},C),{options:eP(C.options,o)}):p&&(C=T(f({},C),{options:p})),a.jsx(I.Select,T(f(f({},C),S),{value:x,onChange:b}))}return r==="DateFilterDynamicComponent"?a.jsx(KG,T(f(f({},h),S),{value:x,onChange:b})):a.jsx(I.Input,T(f(f({},h),S),{value:x,onChange:C=>{var k;return b==null?void 0:b((k=C==null?void 0:C.target)==null?void 0:k.value)}}))}}const HG=[{value:"$includes",label:"contains",selected:!0},{value:"$notIncludes",label:"does not contain"},{value:"$eq",label:"is"},{value:"$ne",label:"is not"},{value:"$empty",label:"is empty",noValue:!0},{value:"$notEmpty",label:"is not empty",noValue:!0}],tP=w.observer(e=>{var t;const{value:o,model:n}=e,l=w.useFlowViewContext(),i=n.translate,{path:r,operator:s,value:c}=o||{},[d,u]=m.useState(null),p=m.useRef(!1),h=m.useMemo(()=>{if(!d)return"";const D=d.interface||"",B=Array.isArray(d.paths)?d.paths.join("."):"";return`${D}|${B}`},[d]),g=m.useMemo(()=>d!=null&&d.interface?(n.context.app.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(d.interface).filterable.operators||[]).filter(D=>!D.visible||D.visible(d)).map(D=>({value:D.value,label:typeof D.label=="string"?D.label:String(D.label),noValue:!!D.noValue,schema:D.schema,selected:!!D.selected})):d?HG:[],[h,n]),v=m.useMemo(()=>g.map(D=>({value:D.value,label:i(D.label)})),[g,i]);m.useEffect(()=>{if(g.length!==0){if(!s){if(p.current){const D=g.find(B=>B.selected)||g[0];o.operator=(D==null?void 0:D.value)||"",D!=null&&D.noValue?(o.value=!0,o.noValue=!0):o.noValue=!1,p.current=!1}return}if(!g.some(D=>D.value===s)){const D=g.find(B=>B.selected)||g[0];o.operator=(D==null?void 0:D.value)||"",D!=null&&D.noValue?(o.value=!0,o.noValue=!0):o.noValue=!1}}},[g,s,o]);const x=m.useMemo(()=>g.find(D=>D.value===s),[g,s]),b=m.useMemo(()=>{const D=(d==null?void 0:d.uiSchema)||{},B=(x==null?void 0:x.schema)||{};return gr({},D,B)},[d,x]),S=m.useRef(i);m.useEffect(()=>{S.current=i},[i]);const C=m.useCallback(D=>{var B,$;return($=(B=S.current)==null?void 0:B.call(S,D))!=null?$:D},[]),k=m.useMemo(()=>UG(b,d,C),[b,d,C]),F=m.useMemo(()=>function(){return a.jsx(I.Input,{placeholder:`<${i("Null")}>`,readOnly:!0})},[i]),j=m.useMemo(()=>()=>O(void 0,null,function*(){const D=(n==null?void 0:n.context.getPropertyMetaTree())||l.getPropertyMetaTree();return[{title:i("Constant"),name:"constant",type:"string",paths:["constant"]},{title:i("Null"),name:"null",type:"object",paths:["null"]},...Array.isArray(D)?D:[]]}),[l,n,i]),P=m.useCallback(()=>{var D,B;return((B=(D=n==null?void 0:n.context)==null?void 0:D.getPropertyMetaTree)==null?void 0:B.call(D))||l.getPropertyMetaTree()},[l,n]),M=m.useMemo(()=>({renderInputComponent:D=>{var B;const $=(B=D==null?void 0:D.paths)==null?void 0:B[0];return $==="constant"?k:$==="null"?F:null},resolveValueFromPath:D=>{var B;const $=(B=D==null?void 0:D.paths)==null?void 0:B[0];if($==="constant")return"";if($==="null")return null},resolvePathFromValue:D=>D===null?["null"]:w.parseValueToPath(D)||["constant"]}),[F,k]),R=m.useCallback((D,B)=>{const $=o.path||"",q=D||"",E=q!==$;o.path=q,E&&$&&(o.operator="",o.value="",p.current=!0),!$&&q&&!o.operator&&(p.current=!0),B&&u(B)},[o]),N=m.useCallback(D=>{o.operator=D;const B=g.find($=>$.value===D);B!=null&&B.noValue?(o.value=!0,o.noValue=!0):o.noValue=!1},[o,g]);return a.jsxs(I.Space,{wrap:!0,style:{width:"100%"},children:[a.jsx(w.VariableInput,{value:r,onChange:R,metaTree:P,showValueComponent:!0,style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},placeholder:i("Select variable"),onlyLeafSelectable:!0}),a.jsx(I.Select,{style:{flex:"0 0 140px",minWidth:120,maxWidth:"100%"},placeholder:i("Comparison"),value:s||void 0,onChange:N,children:v.map(D=>a.jsx(I.Select.Option,{value:D.value,children:D.label},D.value))}),!((t=g.find(D=>D.value===s))!=null&&t.noValue)&&a.jsx(w.VariableInput,{value:c,onChange:D=>o.value=D,metaTree:j,converters:M,showValueComponent:!0,style:{flex:"1 1 40%",minWidth:160,maxWidth:"100%"},placeholder:i("Enter value"),clearValue:""})]})}),GG=w.defineAction({name:"dataScope",title:w.tExpr("Data scope"),uiMode:{type:"dialog",props:{width:800}},uiSchema:{filter:{type:"object","x-decorator":"FormItem","x-component":function(t){const o=w.useFlowSettingsContext();return a.jsx(tr,{value:t.value,FilterItem:n=>a.jsx(Ga,T(f({},n),{model:o.model,rightAsVariable:!0}))})}}},defaultParams(e){return{filter:{logic:"$and",items:[]}}},handler(e,t){return O(this,null,function*(){var o;const n=(o=e.model)==null?void 0:o.resource;if(!n)return;const l=w.pruneFilter(de.transformFilter(t.filter));de.isEmptyFilter(l)?n.removeFilterGroup(e.model.uid):n.addFilterGroup(e.model.uid,l)})}});function On(e){return a.jsx(I.Card,T(f({},e),{children:a.jsx(I.Skeleton,{paragraph:{rows:3}})}))}class Xx extends w.FlowModel{}Xx.registerFlow({key:"popupSettings",on:"click",steps:{openView:{use:"openView",defaultParams(e){return{mode:"embed",preventClose:!0,pageModelClass:"RootPageModel"}}}}});function WG(e,t,o){return t.map((n,l)=>{let i,r=n.viewUid;return l===0?(i=o,r=o.uid):i=e.getModel(n.viewUid,!0),{params:n,modelUid:r,model:i,hidden:w.observable.ref(!1),index:l}})}function hy(e){let t=!1;for(let o=e.length-1;o>=0;o--){const n=e[o];YG(n)==="embed"&&!t?(t=!0,n.hidden.value=!1):n.hidden.value=t}}function YG(e){if(e.model instanceof Xx)return"embed";if(!e.model)return"drawer";const t=e.model.getStepParams("popupSettings","openView");return(t==null?void 0:t.mode)||"drawer"}const La=e=>e==null?"":typeof e=="object"?Array.isArray(e)?"["+e.map(La).join(",")+"]":"{"+Object.keys(e).sort().map(t=>`${t}:${La(e[t])}`).join(",")+"}":String(e),si=e=>{const{params:t,index:o}=e;return[La(t.viewUid),La(t.sourceId),La(t.filterByTk),String(o)].join("_")};function JG(e,t){const o=new Map,n=new Map;e.forEach(r=>{const s=si(r);o.set(s,r)}),t.forEach(r=>{n.set(si(r),r)});const l=[];o.forEach((r,s)=>{n.has(s)?n.get(s).hidden=r.hidden:l.push(r)});const i=[];return n.forEach((r,s)=>{o.has(s)||i.push(r)}),{viewsToClose:l,viewsToOpen:i}}const oP=w.defineFlow({key:"popupSettings",title:w.tExpr("Popup settings"),on:"click",sort:300,steps:{openView:{use:"openView",hideInSettings:e=>O(void 0,null,function*(){var t,o,n,l;const i=(n=(o=(t=e.model).getStepParams)==null?void 0:o.call(t,"displayFieldSettings","clickToOpen"))==null?void 0:n.clickToOpen;return e.collectionField?i===void 0?!((l=e.collectionField)!=null&&l.isAssociationField()):i===!1:!1})}},defaultParams:e=>{var t,o,n,l,i,r,s,c;let d,u,p;const h=e.collectionField,g=e.blockModel,v=(o=(t=e.model)==null?void 0:t.parent)==null?void 0:o.associationPathName,x=e.collection||(g==null?void 0:g.collection),b=k=>{var F;return!!((F=k==null?void 0:k.isAssociationField)!=null&&F.call(k))},S=!b(h)&&v?(n=x==null?void 0:x.getFieldByPath)==null?void 0:n.call(x,v):void 0,C=b(h)?h:S;if(b(C)){const k=C.targetCollection;g==null||g.collection,d=k==null?void 0:k.name,u=k==null?void 0:k.dataSourceKey,p=C==null?void 0:C.resourceName}else h?(d=(l=e.collection)==null?void 0:l.name,u=(i=e.collection)==null?void 0:i.dataSourceKey,p=h==null?void 0:h.target):(d=(r=e.collection)==null?void 0:r.name,u=(s=e.collection)==null?void 0:s.dataSourceKey,p=(c=e.association)==null?void 0:c.resourceName);return{openView:{collectionName:d,associationName:p,dataSourceKey:u}}}}),XG=e=>e.getStepParams("popupSettings","openView");function nP(e){var t=e,{uid:o}=t,n=ne(t,["uid"]);const l=w.useFlowModelById(o);return a.jsx(w.FlowModelRenderer,f({model:l,fallback:a.jsx(On,{style:{margin:l!=null&&l.context.isMobileLayout?8:l==null?void 0:l.context.themeToken.marginBlock}}),hideRemoveInSettings:!0,showFlowSettings:{showBackground:!1,showBorder:!1}},n))}const QG=()=>{const e=m.useRef(null),t=w.useFlowEngine(),o=ko(),{refresh:n}=un(),{isMobileLayout:l}=to(),i=m.useRef(t.context.route.params.name),r=m.useRef({}),s=m.useRef([]),c=m.useRef(!1),{designable:d}=X(),{active:u}=Mi(),p=m.useRef(!1),h=m.useMemo(()=>t.createModel({uid:i.current,use:"RouteModel"}),[t]);return m.useEffect(()=>{h.context.defineProperty("pageActive",{value:w.observable.ref(!1)})},[h]),m.useEffect(()=>{h.context.pageActive.value=u},[u,h]),m.useEffect(()=>{t.context.defineProperty("isMobileLayout",{get:()=>l}),t.context.defineProperty("deviceType",{get:()=>vi.deviceType==="browser"?"computer":vi.deviceType,cache:!1,meta:{type:"string",title:t.translate("Current device type"),interface:"select",uiSchema:{enum:[{label:t.translate("Computer"),value:"computer"},{label:t.translate("Mobile"),value:"mobile"},{label:t.translate("Tablet"),value:"tablet"},{label:t.translate("SmartTv"),value:"smarttv"},{label:t.translate("Console"),value:"console"},{label:t.translate("Wearable"),value:"wearable"},{label:t.translate("Embedded"),value:"embedded"}],"x-component":"Select"}}})},[l,t]),m.useEffect(()=>{l?t.flowSettings.disable():d&&t.flowSettings.enable()},[d,t,l]),m.useEffect(()=>{e.current&&(t.context.defineProperty("layoutContentElement",{get:()=>e.current}),h.context.defineProperty("currentRoute",{get:()=>o}),t.context.defineProperty("currentRoute",{get:()=>o}),h.context.defineProperty("refreshDesktopRoutes",{get:()=>n}))},[h,o,n,t]),m.useEffect(()=>{const g=w.reaction(()=>t.context.route,v=>{var x;if(v.params.name!==i.current){p.current=!0;return}try{p.current=!1;const b=w.parsePathnameToViewParams(v.pathname),S=WG(t,b,h);if(s.current.length===0&&S.length>1&&!c.current){const F=j=>{S[j]&&(j===0?new w.ViewNavigation(t.context,[]).navigateTo(S[j].params,{replace:!0}):new w.ViewNavigation(t.context,S.slice(0,j).map(P=>P.params)).navigateTo(S[j].params),F(j+1))};F(0),c.current=!0;return}const{viewsToClose:C,viewsToOpen:k}=JG(s.current,S);if(console.log("[NocoBase] FlowRoute view diff:",{viewsToClose:C,viewsToOpen:k}),C.length&&(C.forEach(F=>{var j,P;(P=(j=r.current[si(F)])==null?void 0:j.destroy)==null||P.call(j,!0),delete r.current[si(F)]}),hy(S)),k.length&&O(void 0,null,function*(){const F=k.filter(P=>!P.model);if(F.length>0&&(yield Promise.all(F.map(P=>O(void 0,null,function*(){try{P.model=yield t.loadModel({uid:P.modelUid})}catch(M){console.error(`[NocoBase] Failed to load model ${P.modelUid}:`,M)}})))),p.current)return;hy(S);const j=P=>{if(!k[P])return;const M=k[P];if(!M.model)return;const R=m.createRef(),N=m.createRef(),D=XG(M.model),B=S.slice(0,M.index).map(q=>q.params.viewUid),$=new w.ViewNavigation(t.context,S.slice(0,M.index+1).map(q=>q.params));M.model.dispatchEvent("click",T(f({target:e.current,collectionName:D==null?void 0:D.collectionName,associationName:D==null?void 0:D.associationName,dataSourceKey:D==null?void 0:D.dataSourceKey,destroyRef:R,updateRef:N,openerUids:B},M.params),{navigation:$,onOpen(){j(P+1)},hidden:M.hidden,isMobileLayout:l,triggerByRouter:!0})),r.current[si(M)]={destroy:q=>{var E;return(E=R.current)==null?void 0:E.call(R)},update:q=>{var E;return(E=N.current)==null?void 0:E.call(N,q)},navigation:$}};j(0)}),C.length===0&&k.length===0){const F=S.at(-1);F&&((x=r.current[si(F)])==null||x.navigation.setViewStack(S.map(j=>j.params)))}s.current=[...S]}catch(b){console.error("[NocoBase] Failed to resolve view params to view list:",b)}},{fireImmediately:!0});return()=>{g==null||g(),s.current.forEach(v=>{var x;t.removeModelWithSubModels(v.params.viewUid),(x=r.current[si(v)])==null||x.destroy()})}},[t,l,h]),a.jsx("div",{ref:e})},lP=m.memo(e=>{const t=e,{pageModelClass:o="ChildPageModel",parentId:n,onModelLoaded:l,defaultTabTitle:i}=t,r=ne(t,["pageModelClass","parentId","onModelLoaded","defaultTabTitle"]),s=w.useFlowEngine(),c=w.useFlowViewContext(),{loading:d,data:u}=Ct.useRequest(()=>O(void 0,null,function*(){var p;const h={async:!0,parentId:n,subKey:"page",subType:"object",use:o};if(o==="ChildPageModel"){const v=i||((p=s.translate)==null?void 0:p.call(s,"Details"));h.subModels={tabs:[{use:"ChildPageTabModel",stepParams:{pageTabSettings:{tab:{title:v}}}}]},h.stepParams={pageSettings:{general:{displayTitle:!1,enableTabs:!0}}}}const g=yield s.loadOrCreateModel(h);return g!=null&&g.uid&&l&&(g.context.addDelegate(c),g.removeParentDelegate(),l(g.uid,g)),g}),{refreshDeps:[n]});return d||!(u!=null&&u.uid)?a.jsx(On,{style:{margin:c!=null&&c.isMobileLayout?8:c==null?void 0:c.themeToken.marginBlock}}):a.jsx(nP,f({uid:u.uid},r))});lP.displayName="FlowPage";const ZG=e=>{const t=e,{uid:o,parentId:n,subKey:l}=t,i=ne(t,["uid","parentId","subKey"]),r=w.useFlowEngine(),{loading:s,data:c}=Ct.useRequest(()=>O(void 0,null,function*(){return yield r.loadModel({uid:o,parentId:n,subKey:l})}),{refreshDeps:[o,n,l]});return s||!(c!=null&&c.uid)?a.jsx(On,{style:{margin:16}}):a.jsx(nP,f({uid:c.uid},i))},Ta=w.observer(e=>{const t=w.useFlowContext();return a.jsx(tr,{value:e.value||{logic:"$and",items:[]},FilterItem:o=>a.jsx(tP,{model:t.model,value:o.value}),onChange:e.onChange})}),Ma=(e,t)=>{const{condition:o={logic:"$and",items:[]}}=t,n=(l,i,r)=>e.app.jsonLogic.apply({[i]:[l,r]});de.evaluateConditions(de.removeInvalidFilterItems(o),n)||e.exit()};function cc(e){const{t}=K.useTranslation(),o=w.useFlowModel(),n=o.context.blockModel,l=e.collection||n.collection,i=l.dataSource,r=m.useMemo(()=>{const d=`${t(i.displayName||i.key)} > `,u=l?`${t(l.title)||l.name||l.tableName} `:"";return`${d}${u}`},[]),{actionName:s}=(e==null?void 0:e.forbidden)||o.forbidden,c=m.useMemo(()=>t(`The current user only has the UI configuration permission, but don't have "{{actionName}}" permission for collection "{{name}}"`,{name:r,actionName:t(L.capitalize(s))}).replaceAll(">",">"),[s,r,t]);return a.jsx(I.Tooltip,{title:e.message||c,children:e.children})}const mo={collection:"collection",record:"record",all:["collection","record"],both:["collection","record"]};class Ut extends w.FlowModel{constructor(){super(...arguments),A(this,"defaultProps",{type:"default",title:w.tExpr("Action")}),A(this,"enableEditTooltip",!0),A(this,"enableEditTitle",!0),A(this,"enableEditIcon",!0),A(this,"enableEditType",!0),A(this,"enableEditDanger",!0),A(this,"enableEditColor",!1)}static _getScene(){return L.castArray(this.scene||[])}static _isScene(t){return this._getScene().includes(t)}getAclActionName(){return null}onInit(t){super.onInit(t),this.context.defineProperty("actionName",{get:()=>this.getAclActionName(),cache:!1})}getInputArgs(){const t={},o=[];if(this.context.resource){const n=this.context.resource.getSourceId();n&&(t.sourceId=n,o.push("sourceId"))}if(this.context.collection&&this.context.record){const n=this.context.collection.getFilterByTK(this.context.record);n&&(t.filterByTk=n,o.push("filterByTk"))}return o.length&&(t.defaultInputKeys=o),t}onClick(t){this.dispatchEvent("click",f({event:t},this.getInputArgs()),{debounce:!0})}getTitle(){return this.props.title}getIcon(){return this.props.icon}renderButton(){const t=this.props,o=this.getIcon()?a.jsx(ct,{type:this.getIcon()}):void 0;return a.jsx(I.Button,T(f({},t),{onClick:this.onClick.bind(this),icon:o,children:t.children||this.getTitle()}))}render(){return this.props.tooltip?a.jsx(I.Tooltip,{title:this.props.tooltip,children:this.renderButton()}):this.renderButton()}renderHiddenInConfig(){const t=this.props,o=this.getIcon()?a.jsx(ct,{type:this.getIcon()}):void 0;return this.forbidden?a.jsx(cc,{children:a.jsx(I.Button,T(f({},t),{onClick:this.onClick.bind(this),icon:o,style:{opacity:"0.3"},children:t.children||this.getTitle()}))}):a.jsx(I.Tooltip,{title:this.context.t("The button is hidden and only visible when the UI Editor is active"),children:a.jsx(I.Button,T(f({},t),{onClick:this.onClick.bind(this),icon:o,style:{opacity:"0.3"},children:t.children||this.getTitle()}))})}}Ut.registerFlow({key:"buttonSettings",title:w.tExpr("Button settings"),sort:-999,steps:{general:{title:w.tExpr("Edit button"),uiSchema(e){return{title:e.model.enableEditTitle?{"x-decorator":"FormItem","x-component":"Input",title:w.tExpr("Button title")}:void 0,tooltip:e.model.enableEditTooltip?{"x-decorator":"FormItem","x-component":"Input",title:w.tExpr("Button tooltip")}:void 0,icon:e.model.enableEditIcon?{"x-decorator":"FormItem","x-component":"IconPicker",title:w.tExpr("Button icon")}:void 0,type:e.model.enableEditType?{"x-decorator":"FormItem","x-component":"Radio.Group",title:w.tExpr("Button type"),enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Primary")}}'},{value:"dashed",label:'{{t("Dashed")}}'},{value:"link",label:'{{t("Link")}}'},{value:"text",label:'{{t("Text")}}'}]}:void 0,danger:e.model.enableEditDanger?{"x-decorator":"FormItem","x-component":"Switch",title:w.tExpr("Danger action")}:void 0,color:e.model.enableEditColor?{"x-decorator":"FormItem","x-component":jr,title:w.tExpr("Color")}:void 0}},defaultParams(e){return e.model.defaultProps},handler(e,t){const o=t,{title:n,tooltip:l}=o,i=ne(o,["title","tooltip"]);e.model.setProps(f({title:n?e.t(n):void 0,tooltip:l?e.t(l):void 0},i))}},aclCheck:{use:"aclCheck"},linkageRules:{use:"actionLinkageRules"}}});Ut.registerEvents({click:{title:w.tExpr("Click"),name:"click",uiSchema:{condition:{type:"object",title:w.tExpr("Trigger condition"),"x-decorator":"FormItem","x-component":Ta}},handler:Ma}});class ql extends w.FlowModel{static getAllParentClasses(){const t=[];let o=this;for(;o&&o!==Object;)o=Object.getPrototypeOf(o),o!=null&&o.currentModels&&t.push(o);return t}static get currentModels(){return(!Object.prototype.hasOwnProperty.call(this,"_models")||!this._models)&&(this._models=new Map),this._models}static get models(){const t=new Map,o=this.getAllParentClasses();for(const n of o)for(const[l,i]of n.currentModels)t.set(l,i);for(const[n,l]of this.currentModels)t.set(n,l);return t}static registerActionModels(t){for(const[o,n]of Object.entries(t))Object.defineProperty(n,"name",{value:o}),this.currentModels.set(o,n)}static defineChildren(t){return O(this,null,function*(){const o=this.baseClass?yield w.buildSubModelItems(this.baseClass)(t):[],n=[],l=o.filter(i=>this.scene?t.engine.getModelClass(i.useModel)._isScene(this.scene):!0);for(const[i,r]of this.models){if(l.find(c=>c.useModel===r.name))continue;const s=yield w.buildSubModelItem(r,t);s&&n.push(s)}return L.sortBy([...l,...n],"sort")})}}A(ql,"baseClass"),A(ql,"scene"),A(ql,"_models");class hh extends ql{}A(hh,"baseClass",Ut),A(hh,"scene",mo.collection);class xd extends ql{}A(xd,"baseClass",Ut),A(xd,"scene",mo.record);class dc extends w.FlowModel{static defineChildren(t){const o=this.itemModelName,n=(l,i="")=>l.getToOneAssociationFields().map(r=>{const s=i?`${i}.${r.name}`:r.name;if(!r.targetCollection){console.error(`AssociationFieldGroupModel: target collection ${r.target} not found for field ${r.name}`);return}return{key:`${s}-assocationField`,label:r.title,children:()=>[{key:`${s}-children-collectionField`,label:"Display collection fields",type:"group",children:r.targetCollection.getFields().map(c=>{const d=`${s}.${c.name}`,u=w.DisplayItemModel.getDefaultBindingByField(t,c,{fallbackToTargetTitleField:!0});if(!u)return;const p=u.modelName;return{key:`c-${s}.${c.name}`,label:c.title,useModel:o,toggleable:h=>{var g;return((g=h.getStepParams("fieldSettings","init"))==null?void 0:g.fieldPath)===d},createModelOptions:{stepParams:{fieldSettings:{init:{dataSourceKey:t.collection.dataSourceKey,collectionName:t.collection.name,fieldPath:d,associationPathName:s}}},subModels:{field:{use:p}}}}}).filter(Boolean)},{key:`${s}-children-associationField`,label:"Display association fields",type:"group",children:(n(r.targetCollection,s)||[]).filter(Boolean)}]}});return n(t.collection)}}A(dc,"itemModelName","DetailsItemModel");dc.define({label:'{{t("Display association fields")}}'});function Qx(e){var t,o,n,l,i,r;return e.operator||((t=e.getStepParams("filterFormItemSettings","defaultOperator"))==null?void 0:t.value)||((o=e.subModels.field)==null?void 0:o.operator)||((r=(i=(l=(n=e.collectionField)==null?void 0:n.filterable)==null?void 0:l.operators)==null?void 0:i[0])==null?void 0:r.value)||"$includes"}function iP(e){return!!(e==null||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.filter(t=>!(t==null||typeof t=="string"&&t.trim()==="")).length===0||typeof e=="object"&&e.constructor===Object&&Object.keys(e).length===0)}function Bp(e){return e.filterSubModels("items",t=>{var o;return!!((o=t.resource)!=null&&o.supportsFilter)})}class Zx{constructor(t,o){A(this,"filterConfigs"),A(this,"gridModel"),this.gridModel=t,this.filterConfigs=o||[]}saveFilterConfigs(){return O(this,null,function*(){yield this.gridModel.saveStepParams()})}getFilterConfigs(){return this.filterConfigs}getConnectFieldsConfig(t){const o=this.filterConfigs.filter(n=>n.filterId===t);if(o.length!==0)return{targets:o.map(n=>({targetId:n.targetId,filterPaths:n.filterPaths}))}}saveConnectFieldsConfig(t,o){return O(this,null,function*(){const n=o.targets.map(i=>({filterId:t,targetId:i.targetId,filterPaths:i.filterPaths})),l=this.filterConfigs.filter(i=>i.filterId!==t);this.filterConfigs=[],this.filterConfigs.push(...l,...n),yield this.saveFilterConfigs()})}addFilterConfig(t){return O(this,null,function*(){if(!t.filterId||!t.targetId){console.error("FilterConfig must have filterId, targetId, and operator");return}if(!Array.isArray(t.filterPaths)||t.filterPaths.length===0){console.error("FilterConfig must have non-empty filterPaths array");return}const o=this.filterConfigs.findIndex(n=>n.filterId===t.filterId&&n.targetId===t.targetId);o>=0?this.filterConfigs[o]=f({},t):this.filterConfigs.push(f({},t)),yield this.saveFilterConfigs()})}removeFilterConfig(t){return O(this,arguments,function*({filterId:o,targetId:n,persist:l=!0}){if(!o&&!n)return console.error("At least one of filterId or targetId must be provided"),0;const i=this.filterConfigs.length;this.filterConfigs=this.filterConfigs.filter(s=>o&&n?!(s.filterId===o&&s.targetId===n):o?s.filterId!==o:n?s.targetId!==n:!0);const r=i-this.filterConfigs.length;return r>0&&l&&(yield this.saveFilterConfigs()),r})}bindToTarget(t){if(!t||typeof t!="string"){console.error("[NocoBase]: targetId must be a non-empty string");return}const o=this.gridModel.flowEngine.getModel(t);if(!o){console.error(`[NocoBase]: Target model with uid "${t}" not found`);return}if(!o.resource||typeof o.resource.addFilterGroup!="function"){console.error(`[NocoBase]: Target model with uid "${t}" does not have a valid resource with addFilterGroup method`);return}if(typeof o.resource.removeFilterGroup!="function"){console.error(`[NocoBase]: Target model with uid "${t}" does not have a valid resource with removeFilterGroup method`);return}const n=this.filterConfigs.filter(l=>l.targetId===t);n.length!==0&&n.forEach(l=>{const i=this.gridModel.flowEngine.getModel(l.filterId);if(!i){console.error(`[NocoBase]: Filter model with uid "${l.filterId}" not found`);return}if(!i.getFilterValue){console.error(`[NocoBase]: Filter model with uid "${l.filterId}" does not have getFilterValue method`);return}const r=i.getFilterValue();if(iP(r)){try{o.resource.removeFilterGroup(l.filterId)}catch(c){console.error(`[NocoBase]: Failed to remove filter configuration from target model: ${c.message}`);return}return}const s=l.filterPaths.map(c=>({path:c,operator:l.operator||Qx(i),value:r}));try{if(s.length===1)o.resource.addFilterGroup(l.filterId,new w.FilterItem({path:s[0].path,operator:s[0].operator,value:s[0].value}));else if(s.length>1){const c={logic:"$or",items:s};o.resource.addFilterGroup(l.filterId,new w.FilterGroup(c))}}catch(c){console.error(`Failed to bind filter configuration to target model: ${c.message}`);return}})}unbindFromTarget(t){if(!t||typeof t!="string"){console.error("targetId must be a non-empty string");return}const o=this.gridModel.flowEngine.getModel(t);if(!o){console.error(`Target model with uid "${t}" not found`);return}if(!o.resource||typeof o.resource.removeFilterGroup!="function"){console.error(`Target model with uid "${t}" does not have a valid resource with removeFilterGroup method`);return}const n=this.filterConfigs.filter(l=>l.targetId===t);n.length!==0&&n.forEach(l=>{try{o.resource.removeFilterGroup(l.filterId)}catch(i){console.error(`Failed to unbind filter configuration from target model: ${i.message}`);return}})}refreshTargetsByFilter(t){return O(this,null,function*(){if(!t){console.error("filterId must be provided");return}const o=Array.isArray(t)?t:[t];if(o.length===0||o.some(i=>!i||typeof i!="string")){console.error("filterId must be non-empty string(s)");return}const n=this.filterConfigs.filter(i=>o.includes(i.filterId));if(n.length===0)return;const l=[...new Set(n.map(i=>i.targetId))].map(i=>O(this,null,function*(){var r,s;try{this.bindToTarget(i);const c=this.gridModel.flowEngine.getModel(i);if(!c){console.error(`Target model with uid "${i}" not found`);return}if(!c.resource||typeof c.resource.refresh!="function"){console.error(`Target model with uid "${i}" does not have a valid resource with refresh method`);return}(s=(r=c.resource).setPage)==null||s.call(r,1),yield c.resource.refresh()}catch(c){console.error(`Failed to refresh target model "${i}": ${c.message}`);return}}));yield Promise.all(l)})}}function eW({rows:e,sizes:t={},renderItem:o,rowGap:n=16,colGap:l=16,dragOverlayRect:i}){return Object.keys(e||{}).length===0?a.jsx("div",{style:{position:"relative"},"data-grid-empty-container":!0,children:i&&a.jsx(gy,{rect:i})}):a.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",gap:n},children:[i&&a.jsx(gy,{rect:i}),Object.entries(e).map(([r,s])=>{const c=s.length,d=t[r]||[],u=d.some(h=>h!=null&&h!==void 0),p=s.map((h,g)=>{var v;if(u){const x=d.reduce((C,k)=>C+(k||0),0),b=c-d.filter(Boolean).length,S=b>0?(24-x)/b:0;return(v=d[g])!=null?v:S}else return 24/c});return a.jsx(I.Row,{gutter:l,"data-grid-row-id":r,children:s.map((h,g)=>a.jsx(rP,{rowKey:r,columnIndex:g,span:p[g],rowGap:n,cell:h,renderItem:o},`${r}:${h.join("|")||"empty"}`))},r)})]})}const rP=m.memo(function({rowKey:t,columnIndex:o,span:n,rowGap:l,cell:i,renderItem:r}){return a.jsx(I.Col,{span:n,"data-grid-column-row-id":t,"data-grid-column-index":o,children:a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:l},children:i.map((s,c)=>s===w.EMPTY_COLUMN_UID?null:a.jsx("div",{"data-grid-item-row-id":t,"data-grid-column-index":o,"data-grid-item-index":c,"data-grid-item-uid":s,children:r(s)},s))})})});rP.displayName="GridColumn";function gy({rect:e}){const t={position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height,borderRadius:6,pointerEvents:"none",transition:"all 60ms ease-out",zIndex:100},o={column:{border:"2px dashed var(--colorPrimary)",backgroundColor:"rgba(22, 119, 255, 0.08)"},"column-edge":{border:"2px solid var(--colorPrimary)",backgroundColor:"rgba(22, 119, 255, 0.12)"},"row-gap":{border:"2px dashed var(--colorPrimary)",backgroundColor:"rgba(22, 119, 255, 0.05)"},"empty-row":{border:"2px dashed var(--colorPrimary)",backgroundColor:"rgba(22, 119, 255, 0.04)"},"empty-column":{border:"2px dashed var(--colorPrimary)",backgroundColor:"rgba(22, 119, 255, 0.04)"}};return a.jsx("div",{style:f(f({},t),o[e.type])})}const tW=e=>{var t=e,{value:o,onChange:n,rows:l=10}=t,i=ne(t,["value","onChange","rows"]);const[r,s]=m.useState(()=>o?JSON.stringify(o,null,2):""),[c,d]=m.useState(null);m.useEffect(()=>{s(o?JSON.stringify(o,null,2):"")},[o]);const u=p=>{const h=p.target.value;s(h);try{const g=h.trim()?JSON.parse(h):void 0;d(null),n==null||n(g)}catch(g){d(g.message)}};return a.jsxs("div",{children:[a.jsx(I.Input.TextArea,f({value:r,autoSize:{minRows:l,maxRows:l+10},onChange:u},i)),c&&a.jsx(I.Alert,{type:"error",message:c,showIcon:!0,style:{marginTop:8}})]})},vy=y.connect(tW),ci="gridSettings",mr="grid",xy=e=>{if(!e)return null;if(typeof e.clientX=="number"&&typeof e.clientY=="number")return{x:e.clientX,y:e.clientY};if(e.touches&&e.touches.length>0){const t=e.touches[0];return{x:t.clientX,y:t.clientY}}if(e.changedTouches&&e.changedTouches.length>0){const t=e.changedTouches[0];return{x:t.clientX,y:t.clientY}}return null};class Aa extends w.FlowModel{constructor(){super(...arguments),A(this,"subModelBaseClass","BlockModel"),A(this,"gridContainerRef",m.createRef()),A(this,"prevMoveDistance",0),A(this,"itemSettingsMenuLevel",1),A(this,"itemFlowSettings",{}),A(this,"dragOverlayConfig"),A(this,"itemFallback",a.jsx(On,{})),A(this,"itemExtraToolbarItems",[{key:"drag-handler",component:w.DragHandler,sort:1}]),A(this,"dragState"),A(this,"_memoItemFlowSettings")}getItemFlowSettings(){return this._memoItemFlowSettings||(this._memoItemFlowSettings=f({showBackground:!1,showDragHandle:!0},this.itemFlowSettings)),this._memoItemFlowSettings}onMount(){super.onMount(),this.emitter.on("onSubModelAdded",t=>{if(!t.isNew)return;this.resetRows(!0);const o=w.findModelUidPosition(t.uid,this.props.rows||{});if(o){const n=L.cloneDeep(this.props.sizes||{});n[o.rowId]=[24],this.setStepParams(ci,mr,{rows:this.props.rows||{},sizes:n}),this.setProps("sizes",n)}}),this.emitter.on("onSubModelDestroyed",t=>{var o,n,l,i;const r=t.uid,s=w.findModelUidPosition(r,this.props.rows||{});if(this.resetRows(!0),s){const c=this.props.rows||{},d=L.cloneDeep(this.props.sizes||{});((o=c[s.rowId])==null?void 0:o[s.columnIndex])===void 0&&((n=d[s.rowId])==null||n.splice(s.columnIndex,1)),c[s.rowId]===void 0&&delete d[s.rowId],this.setStepParams(ci,mr,{rows:c,sizes:d}),this.setProps("sizes",d)}(l=this.context.filterManager)==null||l.removeFilterConfig({targetId:r}),(i=this.context.filterManager)==null||i.removeFilterConfig({filterId:r}),this.saveStepParams()}),this.emitter.on("onSubModelMoved",()=>{this.resetRows(!0)}),this.emitter.on("onResizeLeft",({resizeDistance:t,model:o})=>{var n;const l=w.findModelUidPosition(o.uid,this.props.rows||{}),i=((n=this.gridContainerRef.current)==null?void 0:n.clientWidth)||0,{newRows:r,newSizes:s,moveDistance:c}=gh({position:l,direction:"left",resizeDistance:t,prevMoveDistance:this.prevMoveDistance,oldRows:this.props.rows||{},oldSizes:this.props.sizes||{},gutter:this.context.themeToken.marginBlock,gridContainerWidth:i});this.prevMoveDistance=c,this.setProps("rows",r),this.setProps("sizes",s)}),this.emitter.on("onResizeRight",({resizeDistance:t,model:o})=>{var n;const l=w.findModelUidPosition(o.uid,this.props.rows||{}),i=((n=this.gridContainerRef.current)==null?void 0:n.clientWidth)||0,{newRows:r,newSizes:s,moveDistance:c}=gh({position:l,direction:"right",resizeDistance:t,prevMoveDistance:this.prevMoveDistance,oldRows:this.props.rows||{},oldSizes:this.props.sizes||{},gutter:this.context.themeToken.marginBlock,gridContainerWidth:i});this.prevMoveDistance=c,this.setProps("rows",r),this.setProps("sizes",s)}),this.emitter.on("onResizeBottom",({resizeDistance:t,model:o})=>{}),this.emitter.on("onResizeEnd",()=>{this.prevMoveDistance=0,this.saveGridLayout()})}saveGridLayout(t){var o,n,l,i;const r=(n=(o=t==null?void 0:t.rows)!=null?o:this.props.rows)!=null?n:{},s=(i=(l=t==null?void 0:t.sizes)!=null?l:this.props.sizes)!=null?i:{};this.setStepParams(ci,mr,{rows:r,sizes:s}),this.saveStepParams()}mergeRowsWithItems(t){const o=this.subModels.items||[];if(!o||o.length===0)return{};const n=new Set(o.map(s=>s.uid));n.add(w.EMPTY_COLUMN_UID);const l=new Set,i={};for(const[s,c]of Object.entries(t)){const d=c.map(u=>L.castArray(u).filter(p=>n.has(p))).filter(u=>u.length>0);d.length>0&&(i[s]=d,d.forEach(u=>u.forEach(p=>l.add(p))))}const r=new Set;Object.values(i).forEach(s=>s.forEach(c=>c.forEach(d=>r.add(d))));for(const s of o)r.has(s.uid)||(i[ee.uid()]=[[s.uid]]);return i}resetRows(t=!1){const o=this.getStepParams(ci,mr)||{},n=this.mergeRowsWithItems(o.rows||{});this.setStepParams(ci,mr,{rows:n,sizes:o.sizes||{}}),t&&this.setProps("rows",n)}computePointerPosition(t){var o;if(!this.dragState)return null;const n=this.dragState.pointerOrigin;if(n)return{x:n.x+t.delta.x,y:n.y+t.delta.y};const l=xy(t.activatorEvent);if(l)return this.dragState.pointerOrigin=l,{x:l.x+t.delta.x,y:l.y+t.delta.y};const i=(o=t.over)==null?void 0:o.rect;return i?{x:i.left+i.width/2,y:i.top+i.height/2}:null}updateLayoutSnapshot(){if(!this.dragState)return;const t=w.buildLayoutSnapshot({container:this.gridContainerRef.current});this.dragState.slots=t.slots,this.dragState.containerRect=t.containerRect}scheduleSnapshotRefresh(){this.dragState&&(this.dragState.refreshTimer&&clearTimeout(this.dragState.refreshTimer),this.dragState.refreshTimer=setTimeout(()=>{this.dragState&&(this.dragState.refreshTimer=null,this.updateLayoutSnapshot())},16))}computeOverlayRect(t){var o,n,l,i,r,s,c,d,u;const p=this.dragOverlayConfig,h=t.rect;switch(t.type){case"column":{const g=(o=p==null?void 0:p.columnInsert)==null?void 0:o[t.position],v=(n=g==null?void 0:g.height)!=null?n:h.height,x=(l=g==null?void 0:g.offsetTop)!=null?l:0;return{top:h.top+x,left:h.left,width:h.width,height:v}}case"column-edge":{const g=(i=p==null?void 0:p.columnEdge)==null?void 0:i[t.direction],v=(r=g==null?void 0:g.width)!=null?r:h.width,x=(s=g==null?void 0:g.offsetLeft)!=null?s:0;return{top:h.top,left:h.left+x,width:v,height:h.height}}case"row-gap":{const g=(c=p==null?void 0:p.rowGap)==null?void 0:c[t.position],v=(d=g==null?void 0:g.height)!=null?d:h.height,x=(u=g==null?void 0:g.offsetTop)!=null?u:0;return{top:h.top+x,left:h.left,width:h.width,height:v}}case"empty-column":case"empty-row":return{top:h.top,left:h.left,width:h.width,height:h.height};default:return{top:h.top,left:h.left,width:h.width,height:h.height}}}applyPreview(t){var o,n;if(!this.dragState)return;if(!t){this.dragState.activeSlotKey!==null&&(this.dragState.activeSlotKey=null,this.dragState.previewLayout=void 0,this.setProps("dragOverlayRect",null));return}const l=w.getSlotKey(t);if(this.dragState.activeSlotKey===l&&this.dragState.previewLayout)return;const i=w.simulateLayoutForSlot({slot:t,sourceUid:this.dragState.sourceUid,layout:this.dragState.snapshot,generateRowId:ee.uid});this.dragState.previewLayout={rows:L.cloneDeep(i.rows),sizes:L.cloneDeep(i.sizes)};const r=this.gridContainerRef.current,s=(o=r==null?void 0:r.scrollTop)!=null?o:0,c=(n=r==null?void 0:r.scrollLeft)!=null?n:0,d=this.computeOverlayRect(t),u={top:d.top-this.dragState.containerRect.top+s,left:d.left-this.dragState.containerRect.left+c,width:d.width,height:d.height,type:t.type};this.setProps("dragOverlayRect",u),this.dragState.activeSlotKey=l}handleDragStart(t){var o;const n=t.active.id;this.dragState={sourceUid:n,snapshot:{rows:L.cloneDeep(this.props.rows||{}),sizes:L.cloneDeep(this.props.sizes||{})},slots:[],containerRect:{top:0,left:0,width:0,height:0},pointerOrigin:(o=xy(t.activatorEvent))!=null?o:void 0,activeSlotKey:null,previewLayout:void 0,refreshTimer:null},this.setProps("dragOverlayRect",null),this.updateLayoutSnapshot(),this.scheduleSnapshotRefresh()}handleDragMove(t){if(!this.dragState)return;this.dragState.slots.length||this.updateLayoutSnapshot();const o=this.computePointerPosition(t);if(!o){this.applyPreview(null);return}const n=w.resolveDropIntent(o,this.dragState.slots);this.applyPreview(n)}finishDrag(){this.dragState&&(this.dragState.refreshTimer&&clearTimeout(this.dragState.refreshTimer),this.dragState=void 0,this.setProps("dragOverlayRect",null))}handleDragEnd(t){if(!this.dragState)return;const o=this.dragState.previewLayout;o&&(this.setProps("rows",L.cloneDeep(o.rows)),this.setProps("sizes",L.cloneDeep(o.sizes)),this.saveGridLayout(o)),this.finishDrag()}handleDragCancel(t){this.finishDrag()}renderAddSubModelButton(){throw new Error("renderAddSubModelButton method must be implemented in subclasses of GridModel")}getVisibleLayout(){var t;const o=this.props.rows||{},n=this.props.sizes||{},l=this.context.isMobileLayout?aP(o):o,i=this.context.isMobileLayout?{}:n;if(this.context.flowSettingsEnabled)return{rows:l,sizes:i};const r=((t=this.subModels)==null?void 0:t.items)||[];if(!r.length)return{rows:l,sizes:i};const s=new Map(r.map(u=>[u.uid,u])),c={},d={};return Object.entries(l).forEach(([u,p])=>{const h=p,g=i[u]||[],v=[],x=[];h.forEach((b,S)=>{b.some(C=>{if(C===w.EMPTY_COLUMN_UID)return!1;const k=s.get(C);return!k||!k.hidden})&&(v.push(b),x.push(g[S]))}),v.length>0&&(c[u]=v,x.length>0&&(d[u]=x))}),{rows:c,sizes:d}}render(){const{rows:t,sizes:o}=this.getVisibleLayout(),n=Object.keys(t||{}).length>0;return a.jsxs(a.Fragment,{children:[n&&a.jsx(I.Space,{ref:this.gridContainerRef,direction:"vertical",style:{width:"100%",marginBottom:this.props.rowGap},size:this.props.rowGap,children:a.jsx(w.DndProvider,{onDragStart:this.handleDragStart.bind(this),onDragMove:this.handleDragMove.bind(this),onDragEnd:this.handleDragEnd.bind(this),onDragCancel:this.handleDragCancel.bind(this),children:a.jsx(eW,{rowGap:this.props.rowGap,colGap:this.props.colGap,rows:t,sizes:o,dragOverlayRect:this.props.dragOverlayRect,renderItem:l=>{var i,r;const s=this.flowEngine.getModel(l);if(!s)return this.itemFallback;const c=this.context.fieldKey,d=this.context.fieldIndex,u=this.context.record,p=this.context.currentObject,h=d==null?s:(()=>{const g=s.createFork({},`${c}:${l}`);return g.context.defineProperty("fieldIndex",{get:()=>d}),g.context.defineProperty("fieldKey",{get:()=>c}),g.context.defineProperty("record",{get:()=>u,cache:!1}),g.context.defineProperty("currentObject",{get:()=>p,cache:!1}),g})();return a.jsx(w.Droppable,{model:h,children:a.jsx(w.MemoFlowModelRenderer,{model:h,fallback:s.skeleton||this.itemFallback,showFlowSettings:this.context.flowSettingsEnabled?this.getItemFlowSettings():!1,showErrorFallback:!0,settingsMenuLevel:(i=h==null?void 0:h.settingsMenuLevel)!=null?i:this.itemSettingsMenuLevel,showTitle:!0,extraToolbarItems:this.itemExtraToolbarItems},`${h.uid}:${c}:${(h==null?void 0:h.use)||((r=h==null?void 0:h.constructor)==null?void 0:r.name)||"m"}`)})}})})}),this.context.flowSettingsEnabled&&a.jsx("div",{style:{marginBottom:16},children:this.renderAddSubModelButton()})]})}}Aa.registerFlow({key:ci,steps:{resetRows:{handler(e){e.model.resetRows()}},grid:{uiSchema:{rows:{title:w.tExpr("Rows"),"x-decorator":"FormItem","x-component":vy,"x-component-props":{autoSize:{minRows:10,maxRows:20},description:w.tExpr("Configure the rows and columns of the grid.")}},sizes:{title:w.tExpr("Sizes"),"x-decorator":"FormItem","x-component":vy,"x-component-props":{rows:5},description:w.tExpr("Configure the sizes of each row. The value is an array of numbers representing the width of each column in the row.")}},handler(e,t){return O(this,null,function*(){const o=e.model.mergeRowsWithItems(t.rows||{});e.model.setProps("rows",o),e.model.setProps("sizes",t.sizes||{})})}}}});function aP(e,t){var o;const n=(o=t==null?void 0:t.emptyColumnUid)!=null?o:w.EMPTY_COLUMN_UID,l={};return Object.keys(e).forEach(i=>{e[i].forEach(r=>{const s=r.filter(c=>c!==n);s.length>0&&(l[ee.uid()]=[s])})}),l}function gh({position:e,direction:t,resizeDistance:o,prevMoveDistance:n,oldSizes:l,oldRows:i,gridContainerWidth:r,gutter:s=16,columnCount:c=24}){var d;const u=L.cloneDeep(i),p=L.cloneDeep(l),h=p[e.rowId]||[],g=s*(h.length-1);let v=Math.floor(o/(r-g)*c);if(v===n)return{newRows:u,newSizes:p,moveDistance:v};p[d=e.rowId]!=null||(p[d]=[c]);const x=p[e.rowId];let b=v-n;const S=t==="left"&&e.columnIndex>0,C=t==="right"&&e.columnIndex<x.length-1;if(!S&&!C&&b>0){const k=x.reduce((j,P)=>j+P,0),F=c-k;if(F<=0)return{newRows:u,newSizes:p,moveDistance:n};b>F&&(v=n+F,b=F)}if(p[e.rowId][e.columnIndex]+=b,t==="left"&&e.columnIndex>0&&(p[e.rowId][e.columnIndex-1]-=b,p[e.rowId][e.columnIndex-1]===0&&by({rows:u,sizes:p,position:e,direction:"left"})),t==="left"&&e.columnIndex===0){const k=p[e.rowId].slice(1).reduce((F,j)=>F+j,0);p[e.rowId][0]<c-k&&fy({rows:u,sizes:p,position:e,direction:"left"})}if(t==="right"&&e.columnIndex<p[e.rowId].length-1&&(p[e.rowId][e.columnIndex+1]-=b,p[e.rowId][e.columnIndex+1]===0&&by({rows:u,sizes:p,position:e,direction:"right"})),t==="right"&&e.columnIndex===p[e.rowId].length-1){const k=p[e.rowId].slice(0,-1).reduce((F,j)=>F+j,0);p[e.rowId][e.columnIndex]<c-k&&fy({rows:u,sizes:p,position:e,direction:"right"})}return{newRows:u,newSizes:p,moveDistance:v}}function fy({rows:e,sizes:t,position:o,direction:n}){const l=e[o.rowId]||[],i=t[o.rowId]||[];if(n==="left"){const r=l[o.columnIndex-1];if(r!=null&&r.includes(w.EMPTY_COLUMN_UID))return;l.splice(o.columnIndex,0,[w.EMPTY_COLUMN_UID]),i.splice(o.columnIndex,0,1)}if(n==="right"){const r=l[o.columnIndex+1];if(r!=null&&r.includes(w.EMPTY_COLUMN_UID))return;l.splice(o.columnIndex+1,0,[w.EMPTY_COLUMN_UID]),i.splice(o.columnIndex+1,0,1)}}function by({rows:e,sizes:t,position:o,direction:n}){const l=e[o.rowId]||[],i=t[o.rowId]||[];if(n==="left"){const r=l[o.columnIndex-1];if(!(r!=null&&r.includes(w.EMPTY_COLUMN_UID)))return;l.splice(o.columnIndex-1,1),i.splice(o.columnIndex-1,1)}if(n==="right"){const r=l[o.columnIndex+1];if(!(r!=null&&r.includes(w.EMPTY_COLUMN_UID)))return;l.splice(o.columnIndex+1,1),i.splice(o.columnIndex+1,1)}}class sP extends Aa{constructor(){super(...arguments),A(this,"dragOverlayConfig",{columnInsert:{before:{offsetTop:-24},after:{offsetTop:24}},columnEdge:{left:{offsetLeft:-5},right:{offsetLeft:6}}})}onInit(t){super.onInit(t),this.context.defineProperty("blockGridModel",{value:this}),this.context.defineProperty("filterManager",{once:!0,get:()=>new Zx(this,t.filterManager)})}get subModelBaseClasses(){var t,o;const n=(o=(t=this.context.view)==null?void 0:t.inputArgs)!=null?o:{};return n.collectionName&&!n.filterByTk?["DataBlockModel","FilterBlockModel","BlockModel"]:["DataBlockModel","FilterBlockModel","BlockModel"]}get filterManager(){return this.context.filterManager}serialize(){const t=super.serialize();return t.filterManager=this.filterManager.getFilterConfigs(),t}renderAddSubModelButton(){return a.jsx(w.AddSubModelButton,{model:this,subModelKey:"items",subModelBaseClasses:this.subModelBaseClasses,children:a.jsx(w.FlowSettingsButton,{icon:a.jsx(te.PlusOutlined,{}),children:this.context.t("Add block")})})}render(){return a.jsx("div",{style:{padding:this.context.isMobileLayout?8:this.context.themeToken.marginBlock},children:super.render()})}}sP.registerFlow({key:"blockGridSettings",steps:{grid:{handler(e,t){e.model.setProps("rowGap",e.isMobileLayout?12:e.themeToken.marginBlock),e.model.setProps("colGap",e.themeToken.marginBlock)}}}});const oW=L.memoize(e=>O(void 0,null,function*(){return e&&(yield Promise.resolve().then(()=>require("./md-oH2RssNY-IQIU5F3r.js"))).default.render(e)}));function nW(e){const[t,o]=m.useState(""),[n,l]=m.useState(!0);return m.useEffect(()=>{l(!0),oW(e).then(i=>{o(i),l(!1)}).catch(i=>console.log(i))},[e]),{html:t,loading:n}}function lW(e){const t=e;let o=document.createElement("div");o.innerHTML=t;const n=o.innerText;return o=null,(n==null?void 0:n.replace(/[\n\r]/g,""))||""}const iW=()=>{const{token:e}=I.theme.useToken(),{isDarkTheme:t}=Go(),o=new pl.TinyColor(e.colorFillAlter).onBackground(e.colorBgContainer).toHexShortString(),n={lineHeight:"inherit","&.nb-markdown-default":{"pre code.hljs":{display:"block",overflowX:"auto",padding:"1em"},"code.hljs":{padding:"3px 5px"},":not(pre) code":{padding:"2px 5px",color:"#d56161",background:e.colorFillQuaternary,border:`1px solid ${e.colorBorder}`,borderRadius:e.borderRadiusSM},blockquote:{borderLeft:"4px solid #ccc",paddingLeft:"20px",marginLeft:"0",color:"#666",fontStyle:"italic"},img:{maxWidth:"100%"},".hljs":{background:"#f8f8f8",color:"#444"},".hljs-comment":{color:"#697070"},".hljs-punctuation,.hljs-tag":{color:"#444a"},".hljs-tag .hljs-attr,.hljs-tag .hljs-name":{color:"#444"},".hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag":{fontWeight:700},".hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type":{color:"#800"},".hljs-section,.hljs-title":{color:"#800",fontWeight:700},".hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable":{color:"#ab5656"},".hljs-literal":{color:"#695"},".hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code":{color:"#397300"},".hljs-meta":{color:"#1f7199"},".hljs-meta .hljs-string":{color:"#38a"},".hljs-emphasis":{fontStyle:"italic"},".hljs-strong":{fontWeight:700}},"&.nb-markdown-table":{table:{borderCollapse:"collapse",width:"100%",fontFamily:"Arial, sans-serif",marginBottom:"1.5rem"},"th, td":{borderBottom:`1px solid ${e.colorBorderSecondary}`,padding:`${e.paddingContentVertical}px ${e.paddingContentHorizontal}px`,textAlign:"left"},th:{backgroundColor:o,fontWeight:"bold",color:e.colorText},"tr:hover":{backgroundColor:e.colorFillTertiary},"tr:last-child td":{borderBottom:"none"},"tr:first-child th":{borderTop:"none"}}},l={"&.nb-markdown-default":{"pre code.hljs":{display:"block",overflowX:"auto",padding:"1em"},"code.hljs":{padding:"3px 5px"},":not(pre) code":{padding:"2px 5px",color:"#d56161",background:e.colorFillQuaternary,border:`1px solid ${e.colorBorder}`,borderRadius:e.borderRadiusSM},".hljs":{color:"#adbac7",background:"#22272e"},".hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_":{color:"#f47067"},".hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_":{color:"#dcbdfb"},".hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable":{color:"#6cb6ff"},".hljs-meta .hljs-string,.hljs-regexp,.hljs-string":{color:"#96d0ff"},".hljs-built_in,.hljs-symbol":{color:"#f69d50"},".hljs-code,.hljs-comment,.hljs-formula":{color:"#768390"},".hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag":{color:"#8ddb8c"},".hljs-subst":{color:"#adbac7"},".hljs-section":{color:"#316dca",fontWeight:700},".hljs-bullet":{color:"#eac55f"},".hljs-emphasis":{color:"#adbac7",fontStyle:"italic"},".hljs-strong":{color:"#adbac7",fontWeight:700},".hljs-addition":{color:"#b4f1b4",backgroundColor:"#1b4721"},".hljs-deletion":{color:"#ffd8d3",backgroundColor:"#78191b"}},"&.nb-markdown-table":{table:{borderCollapse:"collapse",width:"100%",fontFamily:"Arial, sans-serif",marginBottom:"1.5rem"},"th, td":{borderBottom:`1px solid ${e.colorBorderSecondary}`,padding:`${e.paddingContentVertical}px ${e.paddingContentHorizontal}px`,textAlign:"left"},th:{backgroundColor:o,fontWeight:"bold",color:e.colorText},"tr:hover":{backgroundColor:e.colorFillTertiary},"tr:last-child td":{borderBottom:"none"},"tr:first-child th":{borderTop:"none"}}};return Z.css(f({lineHeight:e.lineHeight,"& > *:last-child":{marginBottom:"0"},".ant-description-textarea, .ant-description-input":{lineHeight:e.lineHeight},".field-interface-datetime":{minWidth:"100px"}},t?l:n))},cP=e=>{const{textOnly:t,overflowMode:o,style:n}=e,l=iW(),{html:i=""}=nW(e.value),r=lW(i),s=o==="ellipsis",c=m.useRef(null),[d,u]=m.useState(!1);m.useEffect(()=>{if(c.current){const g=c.current,v=g.scrollWidth>g.clientWidth||g.scrollHeight>g.clientHeight;u(v)}},[i,n,o]);const p=f(f({},n||{}),s?{display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal",wordBreak:"break-word",cursor:"default"}:{}),h=a.jsx("div",{ref:c,className:`${l} nb-markdown`,dangerouslySetInnerHTML:{__html:t?r:i},style:p});return s&&d?a.jsx(I.Tooltip,{title:a.jsx("div",{dangerouslySetInnerHTML:{__html:i},style:{maxHeight:500,overflowY:"auto",padding:10,color:"#000"}}),overlayInnerStyle:{background:"#fff",color:"#000",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},color:"#fff",children:h}):h},rW=({height:e,heightMode:t})=>t!=="specifyValue"?null:e,Wa=m.forwardRef((e,t)=>{const{t:o}=K.useTranslation(),{token:n}=I.theme.useToken(),l=e,{title:i,description:r,children:s,className:c}=l,d=ne(l,["title","description","children","className"]),u=rW(e),p=(i||r)&&a.jsxs("div",{children:[a.jsxs("span",{children:[" ",o(i,{ns:Qt})]}),r&&a.jsx(cP,{value:o(r,{ns:Qt}),style:{overflowWrap:"break-word",whiteSpace:"normal",fontWeight:400,color:n.colorTextDescription,borderRadius:"4px"}})]});return a.jsxs(I.Card,T(f({ref:t,title:p,style:{display:"flex",flexDirection:"column",height:u},styles:{body:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},header:{marginTop:"8px"}},className:c},d),{children:[e.beforeContent,s,e.afterContent]}))}),aW=e=>{if(e){const t=document.createRange();return t.selectNodeContents(e),t.getBoundingClientRect().width}},sW={overflow:"hidden",overflowWrap:"break-word",textOverflow:"ellipsis",whiteSpace:"nowrap",wordBreak:"break-all"},cW={overflowWrap:"break-word",whiteSpace:"normal",wordBreak:"break-word"},dW=e=>{if(!e)return!1;const t=aW(e),o=e.offsetWidth;return t>o},uW={maxWidth:600,overflow:"auto",maxHeight:400},Yc=m.forwardRef((e,t)=>{const[o,n]=m.useState(!1),[l,i]=m.useState(!1),r=m.useRef();m.useImperativeHandle(t,()=>({setPopoverVisible:i}),[]);const s=m.useCallback(d=>{const u=d.target;dW(r.current)&&n(u.scrollWidth>=u.clientWidth)},[]),c=m.useMemo(()=>{const d=e.ellipsis?{onMouseEnter:s}:{};return a.jsx("div",T(f({ref:r,role:e.role,style:e.ellipsis?sW:cW},d),{children:e.children}))},[s,e.children,e.ellipsis,e.role]);return!e.ellipsis||!o?c:a.jsx(I.Popover,{open:o&&l,onOpenChange:d=>{i(o&&d)},content:a.jsx("div",{style:uW,children:e.popoverContent||e.children}),children:c})});Yc.displayName="EllipsisWithTooltip";const Pm=Me(),pW=Z.css`
|
|
1703
1703
|
width: 100%;
|
|
1704
1704
|
& > .ant-space-item {
|
|
1705
1705
|
flex: 1;
|