@nocobase/client 1.5.2 → 1.5.4

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.
package/lib/index.js CHANGED
@@ -13,7 +13,7 @@
13
13
  f.display = field.value ? 'visible' : 'none';
14
14
  f.value='HH:mm:ss'
15
15
  });
16
- }}}`,{dependencies:["uiSchema.x-component-props.picker"],when:'{{$deps[0]==="date"}}',fulfill:{state:{hidden:!1}},otherwise:{state:{hidden:!0,value:!1}}}]},"uiSchema.x-component-props.timeFormat":{type:"string",title:'{{t("Time format")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:"HH:mm:ss",enum:[{label:'{{t("12 hour")}}',value:"hh:mm:ss a"},{label:'{{t("24 hour")}}',value:"HH:mm:ss"}],"x-reactions":{dependencies:["uiSchema.x-component-props.showTime"],fulfill:{state:{hidden:"{{ !$deps[0] }}"}}}}},dataSource={type:"array",title:'{{t("Options")}}',"x-decorator":"FormItem","x-component":"ArrayTable","x-component-props":{pagination:{pageSize:1e3}},items:{type:"object",properties:{column1:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:50,title:"",align:"center"},properties:{sort:{type:"void","x-component":"ArrayTable.SortHandle"}}},column2:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:'{{t("Option value")}}'},properties:{value:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"Input","x-reactions":e=>{!e.initialValue&&!e.initialized&&(e.initialValue=(0,import_shared.uid)(),e.setValue((0,import_shared.uid)()))}}}},column3:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:'{{t("Option label")}}'},properties:{label:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},column4:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:'{{t("Color")}}'},properties:{color:{type:"string","x-decorator":"FormItem","x-component":"ColorSelect"}}},column5:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:"",dataIndex:"operations",fixed:"right"},properties:{item:{type:"void","x-component":"FormItem",properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}}}},properties:{add:{type:"void","x-component":"ArrayTable.Addition","x-component-props":{randomValue:!0},title:"{{t('Add option')}}"}}},defaultProps={"uiSchema.title":{type:"string",title:'{{t("Field display name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Field name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input","x-validator":"uid",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"}},recordPickerViewer={type:"void",title:'{{ t("View record") }}',"x-component":"RecordPicker.Viewer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}},collectionDataSource={type:"string",title:'{{t("Options")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0},enum:"{{collections}}"},index=Object.freeze(Object.defineProperty({__proto__:null,autoFill,autoIncrement,collectionDataSource,constraintsProps,dataSource,dateTimeProps,defaultProps,operators,primaryKey,recordPickerViewer,relationshipType,reverseFieldProperties,type,unique},Symbol.toStringTag,{value:"Module"}));class CollectionFieldInterface{constructor(t){A(this,"name"),A(this,"group"),A(this,"title"),A(this,"description"),A(this,"order"),A(this,"default"),A(this,"sortable"),A(this,"availableTypes"),A(this,"supportDataSourceType"),A(this,"notSupportDataSourceType"),A(this,"hasDefaultValue"),A(this,"componentOptions"),A(this,"isAssociation"),A(this,"operators"),A(this,"properties"),A(this,"filterable"),A(this,"titleUsable"),A(this,"hidden"),this.collectionFieldInterfaceManager=t}addComponentOption(t){var o,r,i,n,a,l;if(!this.componentOptions){this.componentOptions=[];const c=(r=(o=this.default)==null?void 0:o.uiSchema)==null?void 0:r["x-component"],u=(n=(i=this.default)==null?void 0:i.uiSchema)==null?void 0:n["x-component-props"];if(c){const m=((l=(a=this.default)==null?void 0:a.uiSchema)==null?void 0:l.type)||"string",d=(0,import_client.tval)(c.startsWith("Input")?(0,import_lodash.capitalize)(m):c.split(".").pop());this.componentOptions=[{label:d,value:c,useProps(){return u||{}}}]}}this.componentOptions.push(t)}getConfigureFormProperties(){const t=this.hasDefaultValue?this.getDefaultValueProperty():{};return x(x({},(0,import_lodash.cloneDeep)(x(x({},defaultProps),this==null?void 0:this.properties))),t)}getDefaultValueProperty(){var t,o;return{defaultValue:P(x(x({},(0,import_lodash.cloneDeep)((t=this==null?void 0:this.default)==null?void 0:t.uiSchema)),(o=this==null?void 0:this.properties)==null?void 0:o.uiSchema),{required:!1,title:'{{ t("Default value") }}',"x-decorator":"FormItem","x-reactions":[{dependencies:["uiSchema.x-component-props.gmt","uiSchema.x-component-props.showTime","uiSchema.x-component-props.dateFormat","uiSchema.x-component-props.timeFormat","uiSchema.x-component-props.picker"],fulfill:{state:{componentProps:{gmt:"{{$deps[0]}}",showTime:"{{$deps[1]}}",dateFormat:"{{$deps[2]}}",timeFormat:"{{$deps[3]}}",picker:"{{$deps[4]}}"}}}},{dependencies:["uiSchema.x-component-props.picker"],fulfill:{state:{value:null}}},{dependencies:["primaryKey","unique","autoIncrement","defaultToCurrentTime"],when:"{{$deps[0]||$deps[1]||$deps[2]||$deps[3]}}",fulfill:{state:{hidden:!0,value:null}},otherwise:{state:{hidden:!1}}},{dependencies:["uiSchema.enum"],fulfill:{state:{dataSource:"{{$deps[0]}}"}}}]})}}}class CollectionFieldInterfaceManager{constructor(t,o,r){A(this,"collectionFieldInterfaceInstances",{}),A(this,"collectionFieldGroups",{}),A(this,"actionList",{}),this.dataSourceManager=r,this.addFieldInterfaces(t),this.addFieldInterfaceGroups(o)}addFieldInterfaces(t=[]){const o=t.reduce((r,i)=>{const n=new i(this);return r[n.name]=n,Array.isArray(this.actionList[n.name])&&(this.actionList[n.name].forEach(a=>{n[a.type](a.data)}),this.actionList[n.name]=void 0),r},{});Object.assign(this.collectionFieldInterfaceInstances,o)}addFieldInterfaceComponentOption(t,o){const r=this.getFieldInterface(t);if(!r){this.actionList[t]||(this.actionList[t]=[]),this.actionList[t].push({type:"addComponentOption",data:o});return}r.addComponentOption(o)}getFieldInterface(t){return this.collectionFieldInterfaceInstances[t]}getFieldInterfaces(t){return Object.values(this.collectionFieldInterfaceInstances).filter(o=>{var r,i;if(!t||!o.supportDataSourceType&&!o.notSupportDataSourceType)return!0;if(o.supportDataSourceType)return(r=o.supportDataSourceType)==null?void 0:r.includes(t);if(o.notSupportDataSourceType)return!((i=o.notSupportDataSourceType)!=null&&i.includes(t))})}addFieldInterfaceGroups(t){Object.assign(this.collectionFieldGroups,t)}getFieldInterfaceGroups(){return this.collectionFieldGroups}getFieldInterfaceGroup(t){return this.collectionFieldGroups[t]}}const DEFAULT_DATA_SOURCE_KEY="main",DEFAULT_DATA_SOURCE_TITLE='{{t("Main")}}';class DataSourceManager{constructor(t={},o){A(this,"dataSourceInstancesMap",{}),A(this,"multiDataSources",[]),A(this,"collectionMixins",[]),A(this,"collectionTemplateManager"),A(this,"collectionFieldInterfaceManager"),this.options=t,this.app=o,this.collectionTemplateManager=new CollectionTemplateManager(t.collectionTemplates,this),this.collectionFieldInterfaceManager=new CollectionFieldInterfaceManager(t.fieldInterfaces,t.fieldInterfaceGroups,this),this.collectionMixins.push(...t.collectionMixins||[]),this.addDataSource(LocalDataSource,{key:DEFAULT_DATA_SOURCE_KEY,displayName:DEFAULT_DATA_SOURCE_TITLE,collections:t.collections||[]}),(t.dataSources||[]).forEach(r=>{this.addDataSource(LocalDataSource,r)})}addCollectionMixins(t=[]){const o=t.filter(r=>!this.collectionMixins.includes(r));o.length&&(this.collectionMixins.push(...o),this.getDataSources().forEach(r=>r.collectionManager.reAddCollections()))}getDataSources(t){const o=Object.values(this.dataSourceInstancesMap);return t?import_lodash.default.filter(o,t):o}getDataSource(t){return t?this.dataSourceInstancesMap[t]:this.dataSourceInstancesMap[DEFAULT_DATA_SOURCE_KEY]}removeDataSources(t){t.forEach(o=>{delete this.dataSourceInstancesMap[o]})}addDataSource(t,o){const r=new t(o,this);return this.dataSourceInstancesMap[r.key]=r,r}addDataSources(t,o){return q(this,null,function*(){this.multiDataSources.some(([r,i])=>r===t&&i===o)||this.multiDataSources.push([t,o])})}getAllCollections(t={}){const{filterCollection:o,filterDataSource:r}=t;return this.getDataSources(r).reduce((i,n)=>(i.push(P(x({},n.getOptions()),{collections:n.collectionManager.getCollections(o)})),i),[])}addFieldInterfaceGroups(t){this.collectionFieldInterfaceManager.addFieldInterfaceGroups(t)}addCollectionTemplates(t=[]){this.collectionTemplateManager.addCollectionTemplates(t)}addFieldInterfaces(t=[]){this.collectionFieldInterfaceManager.addFieldInterfaces(t)}reload(){return q(this,null,function*(){return yield Promise.all(this.multiDataSources.map(t=>q(this,[t],function*([o,r]){(yield o()).map(i=>this.addDataSource(r,i))}))),Promise.all(this.getDataSources().map(t=>t.reload()))})}}const HEADERS_DATA_SOURCE_KEY="x-data-source",isTitleField=(e,t)=>{var o;return(o=e.collectionFieldInterfaceManager.getFieldInterface(t.interface))==null?void 0:o.titleUsable},useDataSourceHeaders=e=>(0,import_react2.useMemo)(()=>{if(e&&e!==DEFAULT_DATA_SOURCE_KEY)return{[HEADERS_DATA_SOURCE_KEY]:e}},[e]),getDataSourceHeaders=e=>e&&e!==DEFAULT_DATA_SOURCE_KEY?{[HEADERS_DATA_SOURCE_KEY]:e}:{},TreeNode=e=>{const{tag:t,type:o,displayType:r=!0}=e,i={reference:"Reference",duplicate:"Duplicate",preloading:"Preloading"};return(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsxs)(import_antd.Tag,{color:{reference:"blue",duplicate:"green",preloading:"cyan"}[o],children:[(0,import_jsx_runtime.jsx)("span",{children:t})," ",r?`(${i[o]})`:""]})})},systemKeys=["sort","createdById","createdBy","createdAt","updatedById","updatedBy","updatedAt","password","sequence"],useCollectionState=(e,t=!0,o)=>{const{getCollectionFields:r,getAllCollectionsInheritChain:i,getCollection:n,getInterface:a}=useCollectionManager_deprecated(),[l]=(0,import_react2.useState)(m),c=useCompile(),u=(0,import_react.useField)();function m(){return(i(e)||[]).map(v=>{var S;return{label:(S=n(v))==null?void 0:S.title,value:v}})}const d=(v,{exclude:S=[],depth:C=0,maxDepth:b,prefix:y=""})=>C>b?[]:r(v).map(F=>{var j;if(S.includes(F.name)||!F.interface||["sort","password","sequence"].includes(F.type)||o&&o(F))return;const k={type:"duplicate",tag:c((j=F.uiSchema)==null?void 0:j.title)||F.name},T=P(x({},k),{role:"button",title:import_react2.default.createElement(TreeNode,P(x({},k),{displayType:t})),key:y?`${y}.${F.name}`:F.name,isLeaf:!0,field:F});return["belongsTo","belongsToMany"].includes(F.type)?(k.type="reference",T.type="reference",T.title=import_react2.default.createElement(TreeNode,P(x({},k),{type:"reference",displayType:t})),T.isLeaf=!1,T.children=p(F.target,{depth:C+1,maxDepth:b,prefix:T.key,exclude:systemKeys})):["hasOne","hasMany"].includes(F.type)&&(T.isLeaf=!1,T.children=d(F.target,{depth:C+1,maxDepth:b,prefix:T.key,exclude:["id",...systemKeys]})),T}).filter(Boolean),p=(v,{prefix:S,maxDepth:C,depth:b=0,exclude:y=[]})=>b>C?[]:r(v).map(F=>{var j;if(!F.target||!F.interface||y.includes(F.name))return;const k={type:"preloading",tag:c((j=F.uiSchema)==null?void 0:j.title)||F.name},T=S?`${S}.${F.name}`:F.name;return{role:"button",title:import_react2.default.createElement(TreeNode,P(x({},k),{displayType:t})),key:T,isLeaf:!1,field:F,children:p(F.target,{prefix:T,depth:b+1,maxDepth:C,exclude:y})}}).filter(Boolean),g=v=>v.map(S=>P(x({},S),{role:"button",title:import_react2.default.createElement(TreeNode,P(x({},S),{type:S.type,displayType:t})),children:S.children?g(S.children):null})),h=(0,import_react2.useCallback)((v,S,C)=>{var b,y;const F=S.index,j=(y=(b=u.initialValue)==null?void 0:b.items)==null?void 0:y[F];if(!v)return[];if(j!=null&&j.treeData||C)return g(C||j.treeData);try{return d(v,{exclude:["id",...systemKeys],maxDepth:1})}catch(k){return console.error(k),[]}},[]),f=(0,import_react2.useCallback)(v=>S=>new Promise(C=>{if(S.children.length)return S.children.forEach(b=>{loadChildren$1({node:b,traverseAssociations:p,traverseFields:d,systemKeys,fields:v})}),C(void 0);loadChildren$1({node:S,traverseAssociations:p,traverseFields:d,systemKeys,fields:v}),C(void 0)}),[]),_=(0,import_react2.useCallback)(v=>S=>{v.value=S},[]);return{collectionList:l,getEnableFieldTree:h,getOnLoadData:f,getOnCheck:_,getScopeDataSource:v=>{const S=r(v),C=(y,F)=>{var j,k;if(!y.interface)return;const T=a(y.interface);if(!(T!=null&&T.filterable))return;const{nested:O,children:N,operators:L}=T.filterable,D={name:y.name,title:((j=y==null?void 0:y.uiSchema)==null?void 0:j.title)||y.name,schema:y==null?void 0:y.uiSchema,operators:((k=L==null?void 0:L.filter)==null?void 0:k.call(L,R=>!(R!=null&&R.visible)||R.visible(y)))||[],interface:y.interface};if(!(y.target&&F>2)){if(F>2)return D;if(N!=null&&N.length&&(D.children=N),O){const R=r(y.target),$=b(R,F+1).filter(Boolean);D.children=D.children||[],D.children.push(...$)}return D}},b=(y,F)=>{const j=[];return y.forEach(k=>{const T=C(k,F);T&&j.push(T)}),j};return b(S,1)},useTitleFieldDataSource:v=>{const S=v.path.entire.replace("titleField","collection"),C=v.query(S).get("value"),b=r(C).filter(y=>{var F;return(F=a(y.interface))==null?void 0:F.titleUsable}).map(y=>{var F;return{value:y==null?void 0:y.name,label:c((F=y==null?void 0:y.uiSchema)==null?void 0:F.title)||(y==null?void 0:y.name)}});v.dataSource=b}}};function findNode(e,t){const o=[...e];for(;o.length;){const r=o.shift();if(r.key===t.key)return r;r.children&&o.push(...r.children)}}function loadChildren$1({node:e,traverseAssociations:t,traverseFields:o,systemKeys:r,fields:i}){const n=findNode(i.dataSource||i.componentProps.treeData,e);let a=[];return["belongsTo","belongsToMany"].includes(e.field.type)&&(e==null?void 0:e.type)==="reference"?a=t(e.field.target,{exclude:r,prefix:e.key,maxDepth:1}):(["hasOne","hasMany"].includes(e.field.type)||(e==null?void 0:e.type)==="duplicate")&&(a=o(e.field.target,{exclude:["id",...r],prefix:e.key,maxDepth:1})),a.length?n.children=a:n.isLeaf=!0,a}const NavigateNoUpdateContext=import_react2.default.createContext(null);NavigateNoUpdateContext.displayName="NavigateNoUpdateContext";const LocationNoUpdateContext=import_react2.default.createContext(null);LocationNoUpdateContext.displayName="LocationNoUpdateContext";const LocationSearchContext=import_react2.default.createContext("");LocationSearchContext.displayName="LocationSearchContext";const IsAdminPageContext=import_react2.default.createContext(!1);IsAdminPageContext.displayName="IsAdminPageContext";const CurrentPageUidContext=import_react2.default.createContext("");CurrentPageUidContext.displayName="CurrentPageUidContext";const MatchAdminContext=import_react2.default.createContext(!1);MatchAdminContext.displayName="MatchAdminContext";const MatchAdminNameContext=import_react2.default.createContext(!1);MatchAdminNameContext.displayName="MatchAdminNameContext";const IsInSettingsPageContext=import_react2.default.createContext(!1);IsInSettingsPageContext.displayName="IsInSettingsPageContext";const CurrentTabUidContext=import_react2.default.createContext("");CurrentTabUidContext.displayName="CurrentTabUidContext";const SearchParamsContext=import_react2.default.createContext(new URLSearchParams);SearchParamsContext.displayName="SearchParamsContext";const RouterBasenameContext=import_react2.default.createContext("");RouterBasenameContext.displayName="RouterBasenameContext";const IsSubPageClosedByPageMenuContext=import_react2.default.createContext({isSubPageClosedByPageMenu:!1,setFieldSchema:()=>{}});IsSubPageClosedByPageMenuContext.displayName="IsSubPageClosedByPageMenuContext";const IsSubPageClosedByPageMenuProvider=({children:e})=>{const t=(0,import_react_router_dom.useParams)(),o=(0,import_react2.useRef)({}),[r,i]=(0,import_react2.useState)(null),n=(0,import_react2.useMemo)(()=>{var l,c;const u=import_lodash.default.isEmpty(t["*"])&&((l=r==null?void 0:r["x-component-props"])==null?void 0:l.openMode)==="page"&&!!((c=o.current["*"])!=null&&c.includes(r["x-uid"]));return o.current=t,u},[r,t]),a=(0,import_react2.useMemo)(()=>({isSubPageClosedByPageMenu:n,setFieldSchema:i}),[n]);return(0,import_jsx_runtime.jsx)(IsSubPageClosedByPageMenuContext.Provider,{value:a,children:e})},RouterBasenameProvider=({children:e})=>{const t=(0,import_react_router_dom.useHref)("/");return(0,import_jsx_runtime.jsx)(RouterBasenameContext.Provider,{value:t,children:e})},SearchParamsProvider=({children:e})=>{const[t]=(0,import_react_router_dom.useSearchParams)();return(0,import_jsx_runtime.jsx)(SearchParamsContext.Provider,{value:t,children:e})},IsInSettingsPageProvider=({children:e})=>{const t=(0,import_react_router_dom.useLocation)().pathname.includes("/settings");return(0,import_jsx_runtime.jsx)(IsInSettingsPageContext.Provider,{value:t,children:e})},MatchAdminProvider=({children:e})=>{const t=!!(0,import_react_router_dom.useMatch)("/admin");return(0,import_jsx_runtime.jsx)(MatchAdminContext.Provider,{value:t,children:e})},MatchAdminNameProvider=({children:e})=>{const t=!!(0,import_react_router_dom.useMatch)("/admin/:name");return(0,import_jsx_runtime.jsx)(MatchAdminNameContext.Provider,{value:t,children:e})},IsAdminPageProvider=({children:e})=>{const t=(0,import_react_router_dom.useLocation)().pathname.startsWith("/admin");return(0,import_jsx_runtime.jsx)(IsAdminPageContext.Provider,{value:t,children:e})},CurrentPageUidProvider=({children:e})=>{const t=(0,import_react_router_dom.useParams)();return(0,import_jsx_runtime.jsx)(CurrentPageUidContext.Provider,{value:t.name,children:e})},CurrentTabUidProvider=({children:e})=>{const t=(0,import_react_router_dom.useParams)();return(0,import_jsx_runtime.jsx)(CurrentTabUidContext.Provider,{value:t.tabUid,children:e})},NavigateNoUpdateProvider=({children:e})=>{const t=(0,import_react_router_dom.useNavigate)(),o=import_react2.default.useRef(t);o.current=t;const r=import_react2.default.useCallback((i,n)=>{o.current(i,n)},[]);return(0,import_jsx_runtime.jsx)(NavigateNoUpdateContext.Provider,{value:r,children:e})},LocationNoUpdateProvider=({children:e})=>{const t=(0,import_react_router_dom.useLocation)(),o=import_react2.default.useRef({});return(0,import_react2.useEffect)(()=>{Object.assign(o.current,t)},[t]),(0,import_jsx_runtime.jsx)(LocationNoUpdateContext.Provider,{value:o.current,children:e})},LocationSearchProvider=({children:e})=>{const t=(0,import_react_router_dom.useLocation)();return(0,import_jsx_runtime.jsx)(LocationSearchContext.Provider,{value:t.search,children:e})},useNavigateNoUpdate=()=>import_react2.default.useContext(NavigateNoUpdateContext),useLocationNoUpdate=()=>import_react2.default.useContext(LocationNoUpdateContext),useLocationSearch=()=>import_react2.default.useContext(LocationSearchContext),useIsAdminPage=()=>import_react2.default.useContext(IsAdminPageContext),useCurrentPageUid=()=>import_react2.default.useContext(CurrentPageUidContext),useMatchAdmin=()=>import_react2.default.useContext(MatchAdminContext),useMatchAdminName=()=>import_react2.default.useContext(MatchAdminNameContext),useIsInSettingsPage=()=>import_react2.default.useContext(IsInSettingsPageContext),useCurrentTabUid=()=>import_react2.default.useContext(CurrentTabUidContext),useCurrentSearchParams=()=>import_react2.default.useContext(SearchParamsContext),useRouterBasename=()=>import_react2.default.useContext(RouterBasenameContext),useIsSubPageClosedByPageMenu=e=>{const{isSubPageClosedByPageMenu:t,setFieldSchema:o}=import_react2.default.useContext(IsSubPageClosedByPageMenuContext);return(0,import_react2.useEffect)(()=>{o(e)},[e,o]),t},CustomRouterContextProvider=({children:e})=>(0,import_jsx_runtime.jsx)(NavigateNoUpdateProvider,{children:(0,import_jsx_runtime.jsx)(LocationNoUpdateProvider,{children:(0,import_jsx_runtime.jsx)(IsAdminPageProvider,{children:(0,import_jsx_runtime.jsx)(LocationSearchProvider,{children:(0,import_jsx_runtime.jsx)(MatchAdminProvider,{children:(0,import_jsx_runtime.jsx)(MatchAdminNameProvider,{children:(0,import_jsx_runtime.jsx)(SearchParamsProvider,{children:(0,import_jsx_runtime.jsx)(RouterBasenameProvider,{children:(0,import_jsx_runtime.jsx)(IsInSettingsPageProvider,{children:e})})})})})})})})}),useDefaultDynamicComponentProps=()=>{},getHook=(e,t,o)=>{let r;return import_lodash.default.isFunction(e)?r=e:(r=t[e],r||console.error(`${o} is not registered`)),r||useDefaultDynamicComponentProps},getUseDynamicProps=(e,t)=>{if(!e)return useDefaultDynamicComponentProps;if(import_lodash.default.isFunction(e))return e;const o=e.split(".");let r;for(const i of o)r=getHook(i,r||t,e);return r};function useDynamicComponentProps(e,t){const o=(0,import_react.useExpressionScope)();return getUseDynamicProps(e,o)(t)}function withDynamicSchemaProps(e,t={}){const o=t.displayName||e.displayName||e.name,r=i=>{const{dn:n,findComponent:a}=useDesignable(),l=(0,import_react2.useMemo)(()=>{const m=n.getSchemaAttribute("x-component"),d=n.getSchemaAttribute("x-decorator"),p=n.getSchemaAttribute("x-use-component-props"),g=n.getSchemaAttribute("x-use-decorator-props");if(m&&p&&a(m)===r)return p;if(d&&g&&a(d)===r)return g},[n]),c=useDynamicComponentProps(l,i),u=(0,import_react2.useMemo)(()=>x(x({},i),c),[c,i]);return(0,import_jsx_runtime.jsx)(import_react2.Suspense,{fallback:(0,import_jsx_runtime.jsx)(import_antd.Spin,{}),children:(0,import_jsx_runtime.jsx)(e,P(x({},u),{children:i.children}))})};return e.displayName=o,r.displayName=`withSchemaProps(${o})`,r}const TreeRecordContext=(0,import_react2.createContext)(null),TreeRecordProvider=({children:e,parent:t})=>(0,import_jsx_runtime.jsx)(TreeRecordContext.Provider,{value:{parent:t},children:e}),useTreeParentRecord=()=>{const e=import_react2.default.useContext(TreeRecordContext);return e==null?void 0:e.parent},TemplateBlockContext=(0,import_react2.createContext)({});TemplateBlockContext.displayName="TemplateBlockContext";const useTemplateBlockContext=()=>(0,import_react2.useContext)(TemplateBlockContext),TemplateBlockProvider=({onTemplateLoaded:e,children:t})=>{const[o,r]=(0,import_react2.useState)(!1),i=(0,import_react2.useCallback)(()=>{r(!0),setTimeout(()=>{e==null||e()})},[e]),n=(0,import_react2.useMemo)(()=>({templateFinished:o,onTemplateSuccess:i}),[i,o]);return(0,import_jsx_runtime.jsx)(TemplateBlockContext.Provider,{value:n,children:t})},FormActiveFieldsContext=(0,import_react2.createContext)(null),FormActiveFieldsProvider=({children:e,name:t,getActiveFieldsName:o,addActiveFieldName:r,removeActiveFieldName:i})=>{const n=(0,import_react2.useRef)(new Set),a=(0,import_react2.useContext)(FormActiveFieldsContext),l=(0,import_react2.useMemo)(()=>({getActiveFieldsName:o||(c=>!c||c===t?Array.from(n.current):a==null?void 0:a.getActiveFieldsName(c)),addActiveFieldName:r||(c=>{n.current.add(c)}),removeActiveFieldName:i||(c=>{n.current.delete(c)}),name:t,parent:a}),[r,o,t,i,a]);return(0,import_jsx_runtime.jsx)(FormActiveFieldsContext.Provider,{value:l,children:e})},useFormActiveFields=()=>(0,import_react2.useContext)(FormActiveFieldsContext),FormBlockContext$1=(0,import_react2.createContext)({});FormBlockContext$1.displayName="FormBlockContext";const InternalFormBlockProvider=e=>{var t;const o=useCollectionManager(),r=useFormBlockContext(),{action:i,readPretty:n,params:a,collection:l,association:c}=e,u=(0,import_react.useField)(),m=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)({readPretty:n}),[n]),{resource:d,service:p,updateAssociationValues:g}=useBlockRequestContext(),h=(0,import_react2.useRef)(),f=useCollectionRecord(),_=(0,import_react2.useMemo)(()=>{var v;return P(x({},r),{params:a,action:i,form:m,type:i==="get"?"update":"create",field:u,service:p,resource:d,updateAssociationValues:g,formBlockRef:h,collectionName:l||((v=o.getCollectionField(c))==null?void 0:v.target),formRecord:f})},[i,c,o,l,r,u,m,a,f,d,p,g]);return(0,import_jsx_runtime.jsx)(FormBlockContext$1.Provider,{value:_,children:(0,import_jsx_runtime.jsx)(RecordProvider,{isNew:f==null?void 0:f.isNew,parent:(t=f==null?void 0:f.parentRecord)==null?void 0:t.data,record:f==null?void 0:f.data,children:(0,import_jsx_runtime.jsx)("div",{ref:h,children:e.children})})})},useFormBlockType=()=>{const e=useFormBlockContext()||{};return(0,import_react2.useMemo)(()=>({type:e.type}),[e.type])},useIsDetailBlock=()=>{const e=useFormBlockContext(),{fieldSchema:t}=useActionContext();return e.type!=="create"&&(t==null?void 0:t["x-acl-action"])!=="create"&&(t==null?void 0:t["x-action"])!=="create"},FormBlockProvider=withDynamicSchemaProps(e=>{const t=useCollectionParentRecordData(),{parentRecord:o}=e,r=useCollectionRecordData(),{association:i}=e,n=useCollectionManager(),{__collection:a}=r||{},{designable:l}=useDesignable(),c=e.collection||n.getCollection(i).name,u=(0,import_ahooks.useUpdate)();return!l&&a&&a!==c?null:(0,import_jsx_runtime.jsx)(TemplateBlockProvider,{onTemplateLoaded:u,children:(0,import_jsx_runtime.jsx)(BlockProvider,P(x({name:e.name||"form"},e),{block:"form",parentRecord:o||t,children:(0,import_jsx_runtime.jsx)(FormActiveFieldsProvider,{name:"form",children:(0,import_jsx_runtime.jsx)(InternalFormBlockProvider,x({},e))})}))})}),useFormBlockContext=()=>(0,import_react2.useContext)(FormBlockContext$1),useFormBlockProps$1=()=>{var e,t,o;const r=useFormBlockContext(),i=useTreeParentRecord();return(0,import_react2.useEffect)(()=>{var n;i&&((n=r.form)==null||n.query("parent").take(a=>{a.disabled=!0,a.value=i}))}),(0,import_react2.useEffect)(()=>{var n,a,l;const c=r.form;!c||(n=r.service)!=null&&n.loading||c.setInitialValues((l=(a=r.service)==null?void 0:a.data)==null?void 0:l.data)},[r.form,(t=(e=r.service)==null?void 0:e.data)==null?void 0:t.data,(o=r.service)==null?void 0:o.loading]),{form:r.form}},findFormBlock=e=>{for(;e;){if(e["x-decorator"]==="FormBlockProvider")return e;if(e["x-component"]==="AssociationField.Selector")return null;e=e.parent}return null},setDataLoadingModeSettingsItem={name:"setDataLoadingMode",Component:SetDataLoadingMode};function useDataLoadingMode(){const{dataLoadingMode:e}=useDataBlockProps()||{};return e||"auto"}function SetDataLoadingMode(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),n=useCollection(),{getEnableFieldTree:a,getOnLoadData:l}=useCollectionState(n==null?void 0:n.name),{getDataBlockRequest:c}=useDataBlockRequestGetter();return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:o("Set data loading mode"),scope:{getEnableFieldTree:a,name:n==null?void 0:n.name,getOnLoadData:l},schema:{type:"object",title:o("Data loading mode"),properties:{dataLoadingMode:{"x-decorator":"FormItem","x-component":"Radio.Group",default:((e=i["x-decorator-props"])==null?void 0:e.dataLoadingMode)||"auto",enum:[{value:"auto",label:o("Load all data when filter is empty")},{value:"manual",label:o("Do not load data when filter is empty")}]}}},onSubmit:({dataLoadingMode:u})=>{const m=c();import_lodash.default.set(i,"x-decorator-props.dataLoadingMode",u),r.decoratorProps.dataLoadingMode=u,t.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":x({},i["x-decorator-props"])}}),t.refresh(),u==="auto"?m.run():m.mutate(void 0)}})}const useSourceKey=e=>useCollectionManager().getSourceKeyByAssociation(e),KeepAliveContext=(0,import_react2.createContext)(!0),DesignableInterceptor=({children:e,active:t})=>{const o=(0,import_react2.useContext)(SchemaComponentContext),r=(0,import_react2.useContext)(import_react.SchemaOptionsContext),i=(0,import_react2.useContext)(import_react.SchemaComponentsContext),n=(0,import_react2.useContext)(import_react.SchemaExpressionScopeContext),a=(0,import_react2.useContext)(ACLContext),l=(0,import_react2.useRef)(o),c=(0,import_react2.useRef)(r),u=(0,import_react2.useRef)(i),m=(0,import_react2.useRef)(n),d=(0,import_react2.useRef)(a);return t&&(l.current=o,c.current=r,u.current=i,m.current=n,d.current=a),(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:l.current,children:(0,import_jsx_runtime.jsx)(import_react.SchemaOptionsContext.Provider,{value:c.current,children:(0,import_jsx_runtime.jsx)(import_react.SchemaComponentsContext.Provider,{value:u.current,children:(0,import_jsx_runtime.jsx)(import_react.SchemaExpressionScopeContext.Provider,{value:m.current,children:(0,import_jsx_runtime.jsx)(ACLContext.Provider,{value:d.current,children:e})})})})})},KeepAliveProvider=({children:e,active:t})=>{const o=(0,import_react2.useContext)(import_react_router_dom.UNSAFE_LocationContext),r=(0,import_react2.useContext)(import_react_router_dom.UNSAFE_RouteContext),i=(0,import_react2.useRef)(o),n=(0,import_react2.useRef)(r);return t&&!import_lodash.default.isEqual(import_lodash.default.omit(i.current.location,"key"),import_lodash.default.omit(o.location,"key"))&&(i.current=o),t&&!import_lodash.default.isEqual(n.current,r)&&(n.current=r),(0,import_jsx_runtime.jsx)(KeepAliveContext.Provider,{value:t,children:(0,import_jsx_runtime.jsx)(DesignableInterceptor,{active:t,children:(0,import_jsx_runtime.jsx)(import_react_router_dom.UNSAFE_LocationContext.Provider,{value:i.current,children:(0,import_jsx_runtime.jsx)(import_react_router_dom.UNSAFE_RouteContext.Provider,{value:n.current,children:e})})})})},useKeepAlive=()=>({active:(0,import_react2.useContext)(KeepAliveContext)}),getMaxPageCount=()=>{let e=5;try{const t=navigator.deviceMemory;if(t)return Math.min(Math.max(5,t*3),20);const o=performance.memory;if(o!=null&&o.jsHeapSizeLimit){const n=o.jsHeapSizeLimit/1073741824;return Math.min(Math.max(5,Math.floor(n*3)),20)}const r=performance.now();for(let n=0;n<1e6;n++);const i=performance.now()-r;return i<3?e=20:i<5?e=10:i<10&&(e=5),e}catch{return 5}},MAX_RENDERED_PAGE_COUNT=getMaxPageCount(),KeepAlive=import_react2.default.memo(({children:e,uid:t})=>{const o=(0,import_react2.useRef)([]);return o.current.includes(t)||(o.current.push(t),o.current.length>MAX_RENDERED_PAGE_COUNT&&(o.current=o.current.slice(-MAX_RENDERED_PAGE_COUNT))),(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:o.current.map(r=>(0,import_jsx_runtime.jsx)(CurrentPageUidContext.Provider,{value:r,children:(0,import_jsx_runtime.jsx)(KeepAliveProvider,{active:r===t,children:e(r)})},r))})});KeepAlive.displayName="KeepAlive";const DEBOUNCE_WAIT=100,LOADING_DELAY=void 0,EMPTY_OBJECT=Object.freeze({});class CollectionRecord{constructor(t){A(this,"data"),A(this,"parentRecord"),A(this,"isNew");const{data:o,parentRecord:r,isNew:i}=t;this.isNew=i,this.data=o,this.parentRecord=r}setData(t){this.data=t}setParentRecord(t){this.parentRecord=t}}const CollectionRecordContext=(0,import_react2.createContext)(null);CollectionRecordContext.displayName="CollectionRecordContext";const CollectionRecordProvider=import_react2.default.memo(({isNew:e,record:t,parentRecord:o,children:r})=>{const i=(0,import_react2.useMemo)(()=>{if(o)return o instanceof CollectionRecord?o:new CollectionRecord({data:o});if(t instanceof CollectionRecord)return t.parentRecord},[o,t]),n=(0,import_react2.useMemo)(()=>{let a;return t?t instanceof CollectionRecord?(a=t,a.isNew=t.isNew||e):a=new CollectionRecord({data:t,isNew:e}):a=new CollectionRecord({isNew:e}),a.setParentRecord(i),a},[t,i,e]);return(0,import_jsx_runtime.jsx)(CollectionRecordContext.Provider,{value:n,children:r})});CollectionRecordProvider.displayName="CollectionRecordProvider";function useCollectionRecord(){return(0,import_react2.useContext)(CollectionRecordContext)}function useCollectionRecordData(){const e=useCollectionRecord();return e==null?void 0:e.data}function useCollectionParentRecord(){const e=useCollectionRecord();return e==null?void 0:e.parentRecord}function useCollectionParentRecordData(){var e;const t=useCollectionRecord();return(e=t==null?void 0:t.parentRecord)==null?void 0:e.data}const DataBlockResourceContext$1=(0,import_react2.createContext)(null);DataBlockResourceContext$1.displayName="DataBlockResourceContext";const DataBlockResourceProvider=({children:e})=>{const t=useDataBlockProps(),o=useCollectionManager(),{association:r,collection:i,dataSource:n,sourceId:a,parentRecord:l}=t,c=useAPIClient(),u=useDataSourceHeaders(n),m=(0,import_react2.useMemo)(()=>typeof i=="string"?i:i==null?void 0:i.name,[i]),d=(0,import_react2.useMemo)(()=>{if(a)return a;if(r&&l){const g=o.getSourceKeyByAssociation(r),h=l instanceof CollectionRecord?l.data:l;if((0,import_lodash.isArray)(g)){const f={};for(const _ of g)f[_]=h==null?void 0:h[_];return encodeURIComponent(JSON.stringify(f))}else return h[g]}},[r,a,l]),p=(0,import_react2.useMemo)(()=>r?c.resource(r,d,u,!d):c.resource(m,void 0,u),[c,r,i,d,u]);return(0,import_jsx_runtime.jsx)(DataBlockResourceContext$1.Provider,{value:p,children:e})};function useDataBlockResource(){const e=(0,import_react2.useContext)(DataBlockResourceContext$1);if(!e)throw new Error("useDataBlockResource() must be used within a DataBlockResourceProvider");return e}const DataBlockContext=(0,import_react2.createContext)({});DataBlockContext.displayName="DataBlockContext";const DataBlockResourceContext=(0,import_react2.createContext)(null),RerenderDataBlockProvider=({children:e})=>{const[t,o]=import_react2.default.useState(!1),r=(0,import_react2.useMemo)(()=>({rerenderDataBlock:()=>{o(!0),setTimeout(()=>{o(!1)})}}),[]);return t?null:(0,import_jsx_runtime.jsx)(DataBlockResourceContext.Provider,{value:r,children:e})},AssociationOrCollectionProvider=e=>{const{collection:t,association:o,allowNull:r=!1}=e,i=(0,import_react2.useMemo)(()=>o?{Component:AssociationProvider,name:o}:{Component:SanitizedCollectionProvider,name:t},[t,o]);return(0,import_jsx_runtime.jsx)(i.Component,{name:i.name,allowNull:r,children:e.children})},DataBlockProvider=withDynamicSchemaProps(import_react2.default.memo(e=>{const t=e,{collection:o,association:r,dataSource:i,children:n,hidden:a}=t,l=K(t,["collection","association","dataSource","children","hidden"]),{dn:c}=useDesignable();return a?null:(0,import_jsx_runtime.jsx)(DataBlockContext.Provider,{value:{dn:c,props:P(x({},l),{collection:o,association:r,dataSource:i})},children:(0,import_jsx_runtime.jsx)(CollectionManagerProvider,{dataSource:i,children:(0,import_jsx_runtime.jsx)(AssociationOrCollectionProvider,{collection:o,association:r,children:(0,import_jsx_runtime.jsx)(ACLCollectionProvider,{children:(0,import_jsx_runtime.jsx)(DataBlockResourceProvider,{children:(0,import_jsx_runtime.jsx)(BlockRequestProvider,{children:(0,import_jsx_runtime.jsx)(DataBlockCollector,{params:e.params,children:(0,import_jsx_runtime.jsx)(RerenderDataBlockProvider,{children:n})})})})})})})})}),{displayName:"DataBlockProvider"}),useDataBlock=()=>{const e=(0,import_react2.useContext)(DataBlockContext);if(!e)throw new Error("useDataBlock() must be used within a DataBlockProvider");return e},useDataBlockProps=()=>useDataBlock().props,useRerenderDataBlock=()=>{const e=(0,import_react2.useContext)(DataBlockResourceContext);if(!e)throw new Error("useRerenderDataBlock() must be used within a DataBlockProvider");return e},BlockRequestRefContext=(0,import_react2.createContext)(null);BlockRequestRefContext.displayName="BlockRequestRefContext";const BlockRequestLoadingContext=(0,import_react2.createContext)(!1);BlockRequestLoadingContext.displayName="BlockRequestLoadingContext";const BlockRequestDataContext=(0,import_react2.createContext)(null);BlockRequestDataContext.displayName="BlockRequestDataContext";function useRecordRequest(e){const t=useDataLoadingMode(),o=useDataBlockResource(),{action:r,params:i={},record:n,requestService:a,requestOptions:l,sourceId:c,association:u,parentRecord:m}=e,d=useAPIClient(),p=useDataBlockProps(),g=useDataSourceHeaders(p.dataSource),h=useSourceKey(u),[f,_]=(0,import_react2.useMemo)(()=>[JSON.stringify(i),JSON.stringify(n)],[i,n]),v=S=>{var C;if(n)return Promise.resolve({data:n});if(!r)throw new Error("[nocobase]: The 'action' parameter is missing in the 'DataBlockRequestProvider' component");if(r==="get"&&import_lodash.default.isNil(i.filterByTk))return console.warn('[nocobase]: The "filterByTk" parameter is missing in the "DataBlockRequestProvider" component');const b=i.filterByTk===void 0?import_lodash.default.omit(i,"filterByTk"):i;return(C=o[r])==null?void 0:C.call(o,x(x({},b),S)).then(y=>y.data)};return useRequest((...S)=>q(this,null,function*(){const[C,b]=yield Promise.all([(a||v)(...S),requestParentRecordData({sourceId:c,association:u,parentRecord:m,api:d,headers:g,sourceKey:h})]);return C&&(C.parentRecord=b==null?void 0:b.data),C}),P(x({},l),{manual:t==="manual",ready:!!r,refreshDeps:[r,f,_,o,u,m,c]}))}function requestParentRecordData(e){return q(this,arguments,function*({sourceId:t,association:o,parentRecord:r,api:i,headers:n,sourceKey:a}){if(r)return Promise.resolve({data:r});if(!o||!a||!t)return Promise.resolve({data:void 0});const l=`${o.split(".")[0]}:get?filter[${a}]=${t}`;return(yield i.request({url:l,headers:n})).data})}const BlockRequestContextProvider=e=>{var t,o,r,i,n,a;const l=(0,import_react2.useRef)(e.recordRequest),c=(0,import_react2.useRef)((t=e.recordRequest)==null?void 0:t.data),{active:u}=useKeepAlive(),m=(0,import_react2.useRef)(u),d=(0,import_react2.useDeferredValue)(u),p=useDataBlockProps();return d&&!m.current&&p.dataLoadingMode==="auto"&&((o=e.recordRequest)==null||o.refresh()),d&&m.current&&!((r=e.recordRequest)!=null&&r.loading)&&!import_lodash.default.isEqual(c.current,(i=e.recordRequest)==null?void 0:i.data)&&(c.current=(n=e.recordRequest)==null?void 0:n.data),d!==m.current&&(m.current=d),l.current=e.recordRequest,(0,import_jsx_runtime.jsx)(BlockRequestRefContext.Provider,{value:l,children:(0,import_jsx_runtime.jsx)(BlockRequestLoadingContext.Provider,{value:(a=e.recordRequest)==null?void 0:a.loading,children:(0,import_jsx_runtime.jsx)(BlockRequestDataContext.Provider,{value:c.current,children:e.children})})})},BlockRequestProvider=import_react2.default.memo(({children:e})=>{var t,o;const r=useDataBlockProps(),{action:i,filterByTk:n,sourceId:a,params:l=EMPTY_OBJECT,association:c,collection:u,record:m,parentRecord:d,requestOptions:p,requestService:g}=r,h=(0,import_react2.useMemo)(()=>P(x({},l),{filterByTk:n||l.filterByTk}),[n,l]),f=useRecordRequest({action:i,sourceId:a,record:m,association:c,collection:u,requestOptions:p,requestService:g,params:h,parentRecord:d}),_=(t=f.data)==null?void 0:t.parentRecord,v=(0,import_react2.useMemo)(()=>_&&new CollectionRecord({isNew:!1,data:_ instanceof CollectionRecord?_.data:_}),[_]);return(0,import_jsx_runtime.jsx)(BlockRequestContextProvider,{recordRequest:f,children:i!=="list"?(0,import_jsx_runtime.jsx)(CollectionRecordProvider,{isNew:i==null,record:((o=f.data)==null?void 0:o.data)||m,parentRecord:v||d,children:e}):(0,import_jsx_runtime.jsx)(CollectionRecordProvider,{isNew:!1,record:null,parentRecord:v||d,children:e})})});BlockRequestProvider.displayName="DataBlockRequestProvider";const useDataBlockRequest=()=>{const e=(0,import_react2.useContext)(BlockRequestRefContext),t=(0,import_react2.useContext)(BlockRequestLoadingContext),o=(0,import_react2.useContext)(BlockRequestDataContext);return(0,import_react2.useMemo)(()=>e?P(x({},e.current),{loading:t,data:o}):null,[e,o,t])},useDataBlockRequestGetter=()=>{const e=(0,import_react2.useContext)(BlockRequestRefContext);return(0,import_react2.useMemo)(()=>({getDataBlockRequest:()=>e?e.current:null}),[e])},useDataBlockRequestData=()=>(0,import_react2.useContext)(BlockRequestDataContext);var FilterBlockType=(e=>(e[e.FORM=0]="FORM",e[e.TABLE=1]="TABLE",e[e.TREE=2]="TREE",e[e.COLLAPSE=3]="COLLAPSE",e))(FilterBlockType||{});const mergeFilter=(e,t="$and")=>{const o=e.filter(r=>{if(r&&typeof r=="object"&&!Array.isArray(r))return Object.values(r).filter(i=>i!==void 0).length});return o.length===0?{}:o.length===1?o[0]:{[t]:o}},getSupportFieldsByAssociation=(e,t)=>{var o;return(o=t.associatedFields)==null?void 0:o.filter(r=>e==null?void 0:e.some(i=>i===r.target))},getSupportFieldsByForeignKey=(e,t)=>{var o;return(o=t.foreignKeyFields)==null?void 0:o.filter(r=>e.fields.some(i=>i.type!=="belongsTo"&&i.foreignKey===r.name))},useSupportedBlocks=e=>{const{getDataBlocks:t}=useFilterBlock(),o=(0,import_react.useFieldSchema)(),r=useCollection(),{getAllCollectionsInheritChain:i}=useAllCollectionsInheritChainGetter();if(e===0||e===3)return t().filter(n=>isSameCollection(n.collection,r));if(e===1||e===2)return t().filter(n=>{var a,l;return o["x-uid"]!==n.uid&&(isSameCollection(n.collection,r)||((a=getSupportFieldsByAssociation(i(r.name,r.dataSource),n))==null?void 0:a.length)||((l=getSupportFieldsByForeignKey(r,n))==null?void 0:l.length))})},transformToFilter=(e,t,o,r)=>(e=(0,import_client.flatten)(e,{breakOn({value:i,path:n}){if(["$match","$notMatch","$anyOf","$noneOf","$childIn","$childNotIn","$dateBetween","$in","$notIn"].includes(t[n]))return!0;const a=o(`${r}.${n}`);if(a!=null&&a.target){if(Array.isArray(i))return!0;const l=a.targetKey||"id";if(i&&i[l]!=null)return!0}return!1}}),{$and:Object.keys(e).map(i=>{let n=import_lodash.default.get(e,i);const a=o(`${r}.${i}`);return a!=null&&a.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(a.type)&&(n=(0,import_client.getValuesByPath)(n,a.targetKey||"id"),i=`${i}.${a.targetKey||"id"}`,(a==null?void 0:a.interface)==="chinaRegion"&&(n=import_lodash.default.last(n))),!n&&n!==0&&n!==!1?null:{[i]:{[t[i]||"$eq"]:n}}}).filter(Boolean)}),useAssociatedFields=()=>{var e;return((e=useCollection())==null?void 0:e.fields.filter(t=>isAssocField(t)))||[]},isAssocField=e=>["o2o","oho","obo","m2o","createdBy","updatedBy","o2m","m2m","linkTo","chinaRegion","mbm"].includes(e==null?void 0:e.interface),isSameCollection=(e,t)=>e.name===t.name&&e.dataSource===t.dataSource,useFilterAPI=()=>{const e=(0,import_react.useFieldSchema)(),{getDataBlocks:t}=useFilterBlock(),{targets:o,uid:r}=findFilterTargets(e),i=t(),[n,a]=(0,import_react2.useState)(()=>o&&o.some(u=>i.some(m=>m.uid===u.uid))),l=Object.keys(o||{});(0,import_react2.useEffect)(()=>{a(o&&o.some(u=>i.some(m=>m.uid===u.uid)))},[l.length,o,i]);const c=(0,import_react2.useCallback)((u,m="id",d="$eq")=>{i.forEach(p=>{var g,h,f;const _=o.find(b=>b.uid===p.uid);if(!_)return;import_lodash.default.isFunction(m)&&(m=m(_)),import_lodash.default.isFunction(d)&&(d=d(_));const v=((g=p.service.params)==null?void 0:g[0])||{},S=((f=(h=p.service.params)==null?void 0:h[1])==null?void 0:f.filters)||{};u!==void 0?S[r]={$and:[{[m]:{[d]:u}}]}:delete S[r];const C=mergeFilter([...Object.values(S).map(b=>removeNullCondition(b)),p.defaultFilter]);p.doFilter(P(x({},v),{page:1,filter:C}),{filters:S})})},[i,o,r]);return{isConnected:n,doFilter:c}},isInFilterFormBlock=e=>{for(;e;){if(e["x-filter-targets"])return e["x-decorator"]==="FilterFormBlockProvider";e=e.parent}return!1},FilterContext$2=(0,import_react2.createContext)(null);FilterContext$2.displayName="FilterContext";const FilterBlockProvider=import_react2.default.memo(({children:e})=>{const t=import_react2.default.useRef([]),o=(0,import_react2.useCallback)(n=>{typeof n=="function"?t.current=n(t.current):t.current=n},[]),r=(0,import_react2.useCallback)(()=>t.current,[]),i=(0,import_react2.useMemo)(()=>({getDataBlocks:r,setDataBlocks:o}),[r,o]);return(0,import_jsx_runtime.jsx)(FilterContext$2.Provider,{value:i,children:e})});FilterBlockProvider.displayName="FilterBlockProvider";const DataBlockCollector=({children:e,params:t})=>{var o;const r=useCollection(),{recordDataBlocks:i}=useFilterBlock(),{getDataBlockRequest:n}=useDataBlockRequestGetter(),a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)(),c=useAssociatedFields(),u=(0,import_react2.useRef)(null),m=useDataLoadingMode(),d=a&&a.decoratorType!=="FilterFormBlockProvider"&&a.decoratorType!=="FormBlockProvider"&&a.decoratorProps.blockType!=="filter",p=(0,import_react2.useCallback)(()=>{const g=n();i({uid:l["x-uid"],title:a.componentProps.title,doFilter:g.runAsync,collection:r,associatedFields:c,foreignKeyFields:r==null?void 0:r.getFields("isForeignKey"),defaultFilter:(t==null?void 0:t.filter)||{},service:g,dom:u.current,dataLoadingMode:m,clearFilter(h){var f,_,v;const S=((f=this.service.params)==null?void 0:f[0])||{},C=((v=(_=this.service.params)==null?void 0:_[1])==null?void 0:v.filters)||{};delete C[h];const b=mergeFilter([...Object.values(C).map(y=>removeNullCondition(y)),(t==null?void 0:t.filter)||{}]);this.service.run(P(x({},S),{page:1,filter:b}),{filters:C})},clearData(){this.service.mutate(void 0)}})},[c,r,m,(o=a==null?void 0:a.componentProps)==null?void 0:o.title,l,t==null?void 0:t.filter,i,n]);return(0,import_react2.useEffect)(()=>{d&&p()},[p,d]),(0,import_jsx_runtime.jsx)("div",{ref:u,children:e})},useFilterBlock=()=>{const e=import_react2.default.useContext(FilterContext$2),t=(0,import_react2.useCallback)(()=>(e==null?void 0:e.getDataBlocks())||[],[e]),o=(0,import_react2.useCallback)(i=>{const n=e==null?void 0:e.getDataBlocks().find(a=>a.uid===i.uid);if(n){Object.assign(n,i);return}e==null||e.setDataBlocks(a=>[...a,i])},[e]),r=(0,import_react2.useCallback)(i=>{e!=null&&e.getDataBlocks().every(n=>n.uid!==i)||e==null||e.setDataBlocks(n=>n.filter(a=>a.uid!==i))},[e]);return e?{recordDataBlocks:o,getDataBlocks:t,removeDataBlock:r,inProvider:!0}:{inProvider:!1,recordDataBlocks:import_lodash.default.noop,getDataBlocks:t,removeDataBlock:import_lodash.default.noop}},useLabelUiSchemaV2=()=>{const e=useCollectionManager();return(t,o)=>{if(!t)return;const r=e==null?void 0:e.getCollectionField(`${t}.${o}`);return r==null?void 0:r.uiSchema}},useLabelUiSchema$1=(e,t)=>{const o=useCollectionManager();if(!e)return;const r=o==null?void 0:o.getCollectionField(`${e}.${t}`);return r==null?void 0:r.uiSchema},getDatePickerLabels$1=e=>{const t=(0,import_client.getDefaultFormat)(e),o=(0,import_client.str2moment)(e.value,e),r=o&&o.isValid()?o.format(t):e.value;return(0,import_shared.isArr)(r)?r.join("~"):r},toArr$2=e=>e?Array.isArray(e)?e:[e]:[],getLabelFormatValue$1=(e,t,o=!1)=>{const r=e==null?void 0:e.enum;if(Array.isArray(r)&&t){const i=toArr$2(t).map(n=>{const a=r.find(l=>l.value===n);return o?import_react2.default.createElement(import_antd.Tag,{color:a==null?void 0:a.color},a==null?void 0:a.label):a==null?void 0:a.label});return o?i:i.join(", ")}switch(e==null?void 0:e["x-component"]){case"DatePicker":return getDatePickerLabels$1(P(x({},e==null?void 0:e["x-component-props"]),{value:t}));default:return t}},getTabFormatValue=(e,t,o)=>{const r=e==null?void 0:e.enum;if(Array.isArray(r)&&t)return toArr$2(t).map(i=>{const n=r.find(a=>a.value===i);return import_react2.default.createElement(import_antd.Tag,{color:o||(n==null?void 0:n.color)},n==null?void 0:n.label)});switch(e==null?void 0:e["x-component"]){case"DatePicker":return import_react2.default.createElement(import_antd.Tag,{color:o},getDatePickerLabels$1(P(x({},e==null?void 0:e["x-component-props"]),{value:t})));default:return import_react2.default.createElement(import_antd.Tag,{color:o},t)}};function flatData$2(e){const t=[];for(let o=0;o<e.length;o++){const r=e[o].children;Array.isArray(r)&&t.push(...flatData$2(r)),t.push(x({},e[o]))}return t}function isSubMode(e){var t,o;const r=((t=e["x-component-props"])==null?void 0:t.mode)||((o=e.componentProps)==null?void 0:o.mode);return["Nester","SubTable","PopoverNester"].includes(r)}const REGEX_OF_VARIABLE=/^\s*\{\{\s*([a-zA-Z0-9_$-.]+?)\s*\}\}\s*$/g,REGEX_OF_VARIABLE_IN_EXPRESSION=/\{\{\s*([a-zA-Z0-9_$-.]+?)\s*\}\}/g,isVariable=e=>!(typeof e!="string"||!e.match(REGEX_OF_VARIABLE)),getVariablesFromExpression=e=>e.match(REGEX_OF_VARIABLE_IN_EXPRESSION)||[],transformVariableValue=(e,t)=>{const{targetCollectionField:o}=t;return e==null||!o?e:o.interface==="chinaRegion"&&Array.isArray(e)?e.map(r=>(import_lodash.default.isObject(r),r=x({},r),Object.keys(r).forEach(i=>{import_lodash.default.isObjectLike(r[i])&&delete r[i]}),r)):["hasMany","belongsToMany"].includes(o.type)?Array.isArray(e)?e:[e]:(o.interface,e)},toStringByPicker=(e,t="date",o)=>{if(!import_dayjs.default.isDayjs(e))return e;if(o==="local"){const r=new Date().getTimezoneOffset();return(0,import_dayjs.default)(toStringByPicker(e,t,"gmt")).add(r,"minutes").toISOString()}return t==="year"?e.format("YYYY")+"-01-01T00:00:00.000Z":t==="month"?e.format("YYYY-MM")+"-01T00:00:00.000Z":t==="quarter"?e.startOf("quarter").format("YYYY-MM")+"-01T00:00:00.000Z":t==="week"?e.startOf("week").add(1,"day").format("YYYY-MM-DD")+"T00:00:00.000Z":e.format("YYYY-MM-DDTHH:mm:ss.SSS")+"Z"},toGmtByPicker=(e,t)=>!e||!import_dayjs.default.isDayjs(e)?e:toStringByPicker(e,t,"gmt"),toLocalByPicker=(e,t)=>!e||!import_dayjs.default.isDayjs(e)?e:toStringByPicker(e,t,"local"),moment2str=(e,t={})=>{const{showTime:o,gmt:r,picker:i="date",utc:n=!0}=t;if(!e)return e;if(!n){const a=o?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD";return e.format(a)}return o?r?(0,import_client.toGmt)(e):(0,import_client.toLocal)(e):typeof r=="boolean"&&r?toGmtByPicker(e,i):toLocalByPicker(e,i)},handleChangeOnFilter=(e,t,o)=>{const r=o?"YYYY-MM-DD HH:mm:ss":(0,import_client.getPickerFormat)(t);return e&&(0,import_dayjs.default)(e).format(r)},handleDateChangeOnForm=(e,t,o,r,i,n)=>{const a=i?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD";if(!e)return e;if(t)return(0,import_dayjs.default)(e).startOf(r).format("YYYY-MM-DD");if(o){if(n)return(0,import_client.toGmt)(e);if(r!=="date")return(0,import_dayjs.default)(e).startOf(r).toISOString();const l=(0,import_dayjs.default)(e).format(a);return(0,import_dayjs.default)(l).toISOString()}return i?(0,import_dayjs.default)(e).format(a):(0,import_dayjs.default)(e).startOf(r).format(a)},mapDatePicker=function(){const e=isMobile();return t=>{const{dateOnly:o,showTime:r,picker:i="date",utc:n,gmt:a,underFilter:l}=t,c=(0,import_client.getDefaultFormat)(t),u=t.onChange;return P(x({},t),{inputReadOnly:e,format:c,value:(0,import_client.str2moment)(t.value,t),onChange:(m,d)=>{u&&u(l?handleChangeOnFilter(m,i,r):handleDateChangeOnForm(m,o,n,i,r,a))}})}};function isMobile(){return window.matchMedia("(max-width: 768px)").matches}const mapRangePicker=function(){const e=isMobile();return t=>{const o=(0,import_client.getDefaultFormat)(t),r=t.onChange,{dateOnly:i,showTime:n,picker:a="date",utc:l,gmt:c,underFilter:u}=t;return P(x({},t),{format:o,value:(0,import_client.str2moment)(t.value,t),inputReadOnly:e,onChange:m=>{r&&r(u?m?[handleChangeOnFilter(m[0],a,n),handleChangeOnFilter(m[1],a,n)]:[]:m?[moment2str(getRangeStart(m[0],t),t),moment2str(getRangeEnd(m[1],t),t)]:[])}})}};function getRangeStart(e,t){const{showTime:o}=t;return o?e:e.startOf("day")}function getRangeEnd(e,t){const{showTime:o}=t;return o?e:e.endOf("day")}const getStart=(e,t)=>(0,import_dayjs.default)().add(e,t==="isoWeek"?"week":t).startOf(t),getEnd=(e,t)=>(0,import_dayjs.default)().add(e,t==="isoWeek"?"week":t).endOf(t),getDateRanges=e=>{if(e!=null&&e.shouldBeString){const t=o=>Array.isArray(o)?o.map(r=>moment2str(r,{utc:e==null?void 0:e.utc})):moment2str(o,{utc:e==null?void 0:e.utc});return{now:()=>t((0,import_dayjs.default)()),today:o=>withParams(t([getStart(0,"day"),getEnd(0,"day")]),o),yesterday:o=>withParams(t([getStart(-1,"day"),getEnd(-1,"day")]),o),tomorrow:o=>withParams(t([getStart(1,"day"),getEnd(1,"day")]),o),thisWeek:o=>withParams(t([getStart(0,"isoWeek"),getEnd(0,"isoWeek")]),o),lastWeek:o=>withParams(t([getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")]),o),nextWeek:o=>withParams(t([getStart(1,"isoWeek"),getEnd(1,"isoWeek")]),o),thisIsoWeek:o=>withParams(t([getStart(0,"isoWeek"),getEnd(0,"isoWeek")]),o),lastIsoWeek:o=>withParams(t([getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")]),o),nextIsoWeek:o=>withParams(t([getStart(1,"isoWeek"),getEnd(1,"isoWeek")]),o),thisMonth:o=>withParams(t([getStart(0,"month"),getEnd(0,"month")]),o),lastMonth:o=>withParams(t([getStart(-1,"month"),getEnd(-1,"month")]),o),nextMonth:o=>withParams(t([getStart(1,"month"),getEnd(1,"month")]),o),thisQuarter:o=>withParams(t([getStart(0,"quarter"),getEnd(0,"quarter")]),o),lastQuarter:o=>withParams(t([getStart(-1,"quarter"),getEnd(-1,"quarter")]),o),nextQuarter:o=>withParams(t([getStart(1,"quarter"),getEnd(1,"quarter")]),o),thisYear:o=>withParams(t([getStart(0,"year"),getEnd(0,"year")]),o),lastYear:o=>withParams(t([getStart(-1,"year"),getEnd(-1,"year")]),o),nextYear:o=>withParams(t([getStart(1,"year"),getEnd(1,"year")]),o),last7Days:o=>withParams(t([getStart(-6,"days"),getEnd(0,"days")]),o),next7Days:o=>withParams(t([getStart(1,"day"),getEnd(7,"days")]),o),last30Days:o=>withParams(t([getStart(-29,"days"),getEnd(0,"days")]),o),next30Days:o=>withParams(t([getStart(1,"day"),getEnd(30,"days")]),o),last90Days:o=>withParams(t([getStart(-89,"days"),getEnd(0,"days")]),o),next90Days:o=>withParams(t([getStart(1,"day"),getEnd(90,"days")]),o)}}return{now:()=>(0,import_dayjs.default)().toISOString(),today:t=>withParams([getStart(0,"day"),getEnd(0,"day")],t),yesterday:t=>withParams([getStart(-1,"day"),getEnd(-1,"day")],t),tomorrow:t=>withParams([getStart(1,"day"),getEnd(1,"day")],t),thisWeek:t=>withParams([getStart(0,"isoWeek"),getEnd(0,"isoWeek")],t),lastWeek:t=>withParams([getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],t),nextWeek:t=>withParams([getStart(1,"isoWeek"),getEnd(1,"isoWeek")],t),thisIsoWeek:t=>withParams([getStart(0,"isoWeek"),getEnd(0,"isoWeek")],t),lastIsoWeek:t=>withParams([getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],t),nextIsoWeek:t=>withParams([getStart(1,"isoWeek"),getEnd(1,"isoWeek")],t),thisMonth:t=>withParams([getStart(0,"month"),getEnd(0,"month")],t),lastMonth:t=>withParams([getStart(-1,"month"),getEnd(-1,"month")],t),nextMonth:t=>withParams([getStart(1,"month"),getEnd(1,"month")],t),thisQuarter:t=>withParams([getStart(0,"quarter"),getEnd(0,"quarter")],t),lastQuarter:t=>withParams([getStart(-1,"quarter"),getEnd(-1,"quarter")],t),nextQuarter:t=>withParams([getStart(1,"quarter"),getEnd(1,"quarter")],t),thisYear:t=>withParams([getStart(0,"year"),getEnd(0,"year")],t),lastYear:t=>withParams([getStart(-1,"year"),getEnd(-1,"year")],t),nextYear:t=>withParams([getStart(1,"year"),getEnd(1,"year")],t),last7Days:t=>withParams([getStart(-6,"days"),getEnd(0,"days")],t),next7Days:t=>withParams([getStart(1,"day"),getEnd(7,"days")],t),last30Days:t=>withParams([getStart(-29,"days"),getEnd(0,"days")],t),next30Days:t=>withParams([getStart(1,"day"),getEnd(30,"days")],t),last90Days:t=>withParams([getStart(-89,"days"),getEnd(0,"days")],t),next90Days:t=>withParams([getStart(1,"day"),getEnd(90,"days")],t)}};function withParams(e,t){return t!=null&&t.isParsingVariable&&t!=null&&t.fieldOperator&&t.fieldOperator!=="$dateBetween"?e[0]:e}function inferPickerType(e){return/^\d{4}$/.test(e)?"year":/^\d{4}-\d{2}$/.test(e)?"month":/^\d{4}Q[1-4]$/.test(e)?"quarter":"date"}function getJsonLogic(){Array.isArray||(Array.isArray=function(i){return Object.prototype.toString.call(i)==="[object Array]"});function e(i){for(var n=[],a=0,l=i.length;a<l;a++)n.indexOf(i[a])===-1&&n.push(i[a]);return n}function t(i,n){return JSON.stringify(i)===JSON.stringify(n)}var o={},r={$is:function(i,n){return i===n},$match:function(i,n){return Array.isArray(i)&&Array.isArray(n)&&i.some(a=>Array.isArray(a))?i.some(a=>(a==null?void 0:a.length)===n.length&&(a==null?void 0:a.every((l,c)=>l===n[c]))):JSON.stringify(i)===JSON.stringify(n)},$eq:function(i,n){return Array.isArray(i)&&Array.isArray(n)?t(i,n):Array.isArray(i)?i.includes(n):i==n},$ne:function(i,n){return i!=n},"!==":function(i,n){return i!==n},$gt:function(i,n){return Array.isArray(i)?i.some(a=>a>n):i>n},$gte:function(i,n){return i>=n},$lt:function(i,n,a){return Array.isArray(i)?i.some(l=>l<n):a===void 0?i<n:i<n&&n<a},$lte:function(i,n,a){return a===void 0?i<=n:i<=n&&n<=a},$exists:function(i){return o.truthy(i)},$notEmpty:function(i){return o.truthy(i)},$empty:function(i){return Array.isArray(i)?i.some(n=>!o.truthy(n)):!o.truthy(i)},$notExists:function(i){return!o.truthy(i)},"%":function(i,n){return i%n},log:function(i){return i},$in:function(i,n){return!n||typeof n.indexOf>"u"?!1:Array.isArray(i)&&Array.isArray(n)?n.some(a=>i.includes(a)):n.indexOf(i)!==-1},$notIn:function(i,n){return!n||typeof n.indexOf>"u"?!1:n.indexOf(i)===-1},$includes:function(i,n){return!i||typeof i.indexOf>"u"?!1:Array.isArray(i)?i.some(a=>a==null?void 0:a.includes(n)):i.indexOf(n)!==-1},$notIncludes:function(i,n){return Array.isArray(i)?!i.some(a=>(a||"").includes(n)):(i=i||"",!i.includes(n))},$anyOf:function(i,n){return i.length===0?!1:Array.isArray(i)&&Array.isArray(n)&&i.some(a=>Array.isArray(a))?i.some(a=>a.some(l=>n.includes(l))):i.some(a=>n.includes(a))},$noneOf:function(i,n){return!i||(i==null?void 0:i.length)===0?!0:Array.isArray(i)&&Array.isArray(n)&&i.some(a=>Array.isArray(a))?i.some(a=>a.every(l=>!n.some(c=>l.includes(c)))):n.some(a=>!i.includes(a))},$notMatch:function(i,n){if(i.length!==n.length)return!0;for(let a=0;a<i.length;a++)if(i[a]!==n[a])return!0;return!1},$dateOn:function(i,n){return!i||!n?!1:i===n},$dateBefore:function(i,n){if(!i||!n)return!1;const a=parseDate(i),l=parseDate(n);if(!a||!l)throw new Error("Invalid date format");return a<l},$dateNotBefore:function(i,n){if(!i||!n)return!1;const a=parseDate(i),l=parseDate(n);if(!a||!l)throw new Error("Invalid date format");return a>=l},$dateAfter:function(i,n){if(!i||!n)return!1;const a=parseDate(i),l=parseDate(n);return a>l},$dateNotAfter:function(i,n){if(!i||!n)return!1;const a=parseDate(i),l=parseDate(n);if(!a||!l)throw new Error("Invalid date format");return a<=l},$dateBetween:function(i,n){if(!i||!n)return!1;const a=parseFullDate(i),l=parseFullDate(n[0]),c=parseFullDate(n[1]);if(!a||!l||!c)throw new Error("Invalid date format");return a>=l&&a<=c},$dateNotOn:function(i,n){return!i||!n?!1:i!==n},$isTruly:function(i){return Array.isArray(i)?i.some(n=>n===!0||n===1):i===!0||i===1},$isFalsy:function(i){return Array.isArray(i)?i.some(n=>!o.truthy(n)):!o.truthy(i)},cat:function(){return Array.prototype.join.call(arguments,"")},substr:function(i,n,a){if(a<0){var l=String(i).substr(n);return l.substr(0,l.length+a)}return String(i).substr(n,a)},"+":function(){return Array.prototype.reduce.call(arguments,function(i,n){return parseFloat(i,10)+parseFloat(n,10)},0)},"*":function(){return Array.prototype.reduce.call(arguments,function(i,n){return parseFloat(i,10)*parseFloat(n,10)})},"-":function(i,n){return n===void 0?-i:i-n},"/":function(i,n){return i/n},min:function(){return Math.min.apply(this,arguments)},max:function(){return Math.max.apply(this,arguments)},merge:function(){return Array.prototype.reduce.call(arguments,function(i,n){return i.concat(n)},[])},var:function(i,n){var a=n===void 0?null:n,l=this;if(typeof i>"u"||i===""||i===null)return l;for(var c=String(i).split("."),u=0;u<c.length;u++)if(l==null||(l=l[c[u]],l===void 0))return a;return l},missing:function(){for(var i=[],n=Array.isArray(arguments[0])?arguments[0]:arguments,a=0;a<n.length;a++){var l=n[a],c=o.apply({var:l},this);(c===null||c==="")&&i.push(l)}return i},missing_some:function(i,n){var a=o.apply({missing:n},this);return n.length-a.length>=i?[]:a}};return o.is_logic=function(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)&&Object.keys(i).length===1},o.truthy=function(i){return Array.isArray(i)&&i.length===0?!1:!!i},o.get_operator=function(i){return Object.keys(i)[0]},o.get_values=function(i){return i[o.get_operator(i)]},o.apply=function(i,n){if(Array.isArray(i))return i.map(function(f){return o.apply(f,n)});if(!o.is_logic(i))return i;var a=o.get_operator(i),l=i[a],c,u,m,d,p;if(Array.isArray(l)||(l=[l]),a==="if"||a=="?:"){for(c=0;c<l.length-1;c+=2)if(o.truthy(o.apply(l[c],n)))return o.apply(l[c+1],n);return l.length===c+1?o.apply(l[c],n):null}else if(a==="$and"){for(c=0;c<l.length;c+=1)if(u=o.apply(l[c],n),!o.truthy(u))return u;return u}else if(a==="or"){for(c=0;c<l.length;c+=1)if(u=o.apply(l[c],n),o.truthy(u))return u;return u}else{if(a==="filter")return d=o.apply(l[0],n),m=l[1],Array.isArray(d)?d.filter(function(f){return o.truthy(o.apply(m,f))}):[];if(a==="map")return d=o.apply(l[0],n),m=l[1],Array.isArray(d)?d.map(function(f){return o.apply(m,f)}):[];if(a==="reduce")return d=o.apply(l[0],n),m=l[1],p=typeof l[2]<"u"?l[2]:null,Array.isArray(d)?d.reduce(function(f,_){return o.apply(m,{current:_,accumulator:f})},p):p;if(a==="all"){if(d=o.apply(l[0],n),m=l[1],!Array.isArray(d)||!d.length)return!1;for(c=0;c<d.length;c+=1)if(!o.truthy(o.apply(m,d[c])))return!1;return!0}else if(a==="none"){if(d=o.apply(l[0],n),m=l[1],!Array.isArray(d)||!d.length)return!0;for(c=0;c<d.length;c+=1)if(o.truthy(o.apply(m,d[c])))return!1;return!0}else if(a==="some"){if(d=o.apply(l[0],n),m=l[1],!Array.isArray(d)||!d.length)return!1;for(c=0;c<d.length;c+=1)if(o.truthy(o.apply(m,d[c])))return!0;return!1}}if(l=l.map(function(f){return o.apply(f,n)}),r.hasOwnProperty(a)&&typeof r[a]=="function")return r[a].apply(n,l);if(a.indexOf(".")>0){var g=String(a).split("."),h=r;for(c=0;c<g.length;c++){if(!h.hasOwnProperty(g[c]))throw new Error("Unrecognized operation "+a+" (failed at "+g.slice(0,c+1).join(".")+")");h=h[g[c]]}return h.apply(n,l)}throw new Error("Unrecognized operation "+a)},o.uses_data=function(i){var n=[];if(o.is_logic(i)){var a=o.get_operator(i),l=i[a];Array.isArray(l)||(l=[l]),a==="var"?n.push(l[0]):l.forEach(function(c){n.push.apply(n,o.uses_data(c))})}return e(n)},o.add_operation=function(i,n){r[i]=n},o.rm_operation=function(i){delete r[i]},o.rule_like=function(i,n){if(n===i||n==="@")return!0;if(n==="number")return typeof i=="number";if(n==="string")return typeof i=="string";if(n==="array")return Array.isArray(i)&&!o.is_logic(i);if(o.is_logic(n)){if(o.is_logic(i)){var a=o.get_operator(n),l=o.get_operator(i);if(a==="@"||a===l)return o.rule_like(o.get_values(i,!1),o.get_values(n,!1))}return!1}if(Array.isArray(n))if(Array.isArray(i)){if(n.length!==i.length)return!1;for(var c=0;c<n.length;c+=1)if(!o.rule_like(i[c],n[c]))return!1;return!0}else return!1;return!1},o}function parseFullDate(e){return new Date(e)}function parseMonth(e){const[t,o]=e.split("-").map(Number);return new Date(t,o-1)}function parseQuarter(e){const t=parseInt(e.slice(0,4)),o=(parseInt(e.slice(5,6))-1)*3;return new Date(t,o)}function parseYear(e){const t=parseInt(e);return new Date(t,0)}function parseDate(e){let t=Array.isArray(e)?e[1]:e;return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(t)?new Date(t):/^\d{4}-\d{2}-\d{2}$/.test(t)?parseFullDate(t):/^\d{4}-\d{2}$/.test(t)?parseMonth(t):/^\d{4}Q[1-4]$/.test(t)?parseQuarter(t):/^\d{4}$/.test(t)?parseYear(t):null}const parseVariables=(e,t)=>{var o;const r=/{{(.*?)}}/,i=(o=e==null?void 0:e.match)==null?void 0:o.call(e,r);if(i){const n=import_lodash.default.get(t,i[1]);return import_lodash.default.isFunction(n)?n():n}else return e};function getInnermostKeyAndValue(e){if(typeof e!="object"||e===null)return null;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return Object.prototype.toString.call(e[t])==="[object Object]"&&e[t]!==null?getInnermostKeyAndValue(e[t]):{key:t,value:e[t]};return null}const getTargetField$1=e=>{const t=getAllKeys(e),o=(0,import_lodash.findIndex)(t,(r,i,n)=>{if(r.includes("$")&&i>0)return!0});return t.slice(0,o)};function getAllKeys(e){const t=[];function o(r){Object.keys(r).sort().forEach(function(i){t.push(i),r[i]&&typeof r[i]=="object"&&o(r[i])})}return o(e),t}const conditionAnalyses=e=>q(void 0,[e],function*({ruleGroup:t,variables:o,localVariables:r,variableNameOfLeftCondition:i}){const n=Object.keys(t)[0]||"$and";let a=t[n].map(l=>q(void 0,null,function*(){if("$and"in l||"$or"in l)return yield conditionAnalyses({ruleGroup:l,variables:o,localVariables:r});const c=getInnermostKeyAndValue(l),u=c==null?void 0:c.key;if(!u)return!0;const m=targetFieldToVariableString(getTargetField$1(l),i),d=o.parseVariable(m,r,{doNotRequest:!0}).then(({value:g})=>g),p=isVariable(c==null?void 0:c.value)?[o.parseVariable(c==null?void 0:c.value,r).then(({value:g})=>g),d]:[c==null?void 0:c.value,d];try{const g=getJsonLogic(),[h,f]=yield Promise.all(p),_=yield o.getCollectionField(m,r);let v=transformVariableValue(f,{targetCollectionField:_});const S=transformVariableValue(h,{targetCollectionField:_});if(_!=null&&_.type&&["datetime","date","datetimeNoTz","dateOnly","unixTimestamp"].includes(_.type)&&v){const C=inferPickerType(S),b=(0,import_client.getPickerFormat)(C);v=(0,import_client.dayjs)(v).format(b)}return g.apply({[u]:[v,S]})}catch(g){throw g}}));return a=yield Promise.all(a),n==="$and"?(0,import_lodash.every)(a,l=>l):(0,import_lodash.some)(a,l=>l)});function targetFieldToVariableString(e,t="$nForm"){return`{{ ${t}.${e.join(".")} }}`}const getVariablesData=e=>{const t={};return e.map(o=>{t[o.name]=o.ctx}),t};function getRenderContent(e,t,o,r,i){return q(this,null,function*(){var n,a;if(t&&e==="handlebars")try{const l=import_client.Handlebars.compile(t),c=getVariablesData(r),{$nDate:u}=((n=o==null?void 0:o.ctxRef)==null?void 0:n.current)||{},m={};Object.keys(u||{}).map(p=>{m[p]=u[p]()});const d=l(P(x(x({},(a=o==null?void 0:o.ctxRef)==null?void 0:a.current),c),{$nDate:m}));return yield i(d)}catch(l){return console.log(l),t}else try{const l=yield replaceVariableValue(t,o,r);return yield i(l)}catch(l){return console.log(l),t}})}const getPath=e=>e&&e.match(REGEX_OF_VARIABLE)[0].replace(REGEX_OF_VARIABLE,"$1"),getVariableName=e=>import_lodash.default.isString(e)?getPath(e).split(".")[0]:e;var ActionType=(e=>(e.Visible="visible",e.Editable="editable",e.ReadOnly="disabled",e.ReadPretty="readPretty",e.None="none",e.Hidden="hidden",e.Required="required",e.InRequired="notRequired",e.Disabled="disabled",e.Value="value",e.Active="enabled",e.Color="color",e.BackgroundColor="backgroundColor",e.TextAlign="textAlign",e))(ActionType||{}),LinkageRuleCategory=(e=>(e.default="default",e.style="style",e))(LinkageRuleCategory||{});const LinkageRuleDataKeyMap={style:"x-linkage-style-rules",default:"x-linkage-rules"};function bindLinkageRulesToFiled({field:e,linkageRules:t,formValues:o,localVariables:r,action:i,rule:n,variables:a,variableNameOfLeftCondition:l}){var c,u,m,d;return e.initStateOfLinkageRules={display:((c=e.initStateOfLinkageRules)==null?void 0:c.display)||getTempFieldState(!0,e.display),required:((u=e.initStateOfLinkageRules)==null?void 0:u.required)||getTempFieldState(!0,e.required||!1),pattern:((m=e.initStateOfLinkageRules)==null?void 0:m.pattern)||getTempFieldState(!0,e.pattern),value:((d=e.initStateOfLinkageRules)==null?void 0:d.value)||getTempFieldState(!0,e.value||e.initialValue)},(0,import_reactive.reaction)(()=>{const p=getFieldValuesInCondition({linkageRules:t,formValues:o}),g=getVariableValuesInCondition({linkageRules:t,localVariables:r}),h=getVariableValuesInExpression({action:i,localVariables:r});return[p,g,h].map(f=>JSON.stringify(f)).join(",")},getSubscriber({action:i,field:e,rule:n,variables:a,localVariables:r,variableNameOfLeftCondition:l}),{fireImmediately:!0,equals:import_lodash.default.isEqual})}function getFieldValuesInCondition({linkageRules:e,formValues:t}){return e.map(o=>{const r=i=>{const n=Object.keys(i)[0]||"$and";return i[n].map(a=>{if("$and"in a||"$or"in a)return r(a);const l=getTargetField$1(a).join(".");return(0,import_client.getValuesByPath)(t,l)}).filter(Boolean)};return r(o.condition)})}function getVariableValuesInCondition({linkageRules:e,localVariables:t}){return e.map(o=>{const r=Object.keys(o.condition)[0]||"$and";return o.condition[r].map(i=>{const n=getInnermostKeyAndValue(i);return n?isVariable(n.value)?getVariableValue(n.value,t):n.value:null}).filter(Boolean)})}function getVariableValuesInExpression({action:e,localVariables:t}){var o;const r=e.value,i=r==null?void 0:r.mode,n=(r==null?void 0:r.value)||(r==null?void 0:r.result);if(i==="express"&&n!=null)return(o=getVariablesFromExpression(n))==null?void 0:o.map(a=>getVariableValue(a,t)).filter(Boolean)}function getVariableValue(e,t){var o;if(!isVariable(e))return;const r=getVariableName(e),i={[r]:(o=t.find(n=>n.name===r))==null?void 0:o.ctx};return(0,import_client.getValuesByPath)(i,getPath(e))}function getSubscriber({action:e,field:t,rule:o,variables:r,localVariables:i,variableNameOfLeftCondition:n}){return()=>{collectFieldStateOfLinkageRules({operator:e.operator,value:e.value,field:t,condition:o.condition,variables:r,localVariables:i,variableNameOfLeftCondition:n}),setTimeout(()=>q(this,null,function*(){var a;const l=getFieldNameByOperator(e.operator);if(!((a=t.stateOfLinkageRules)!=null&&a[l]))return;let c=t.stateOfLinkageRules[l];c=yield Promise.all(c),c=c.filter(m=>m.condition);const u=c[c.length-1];l==="value"?c.length>1&&(t.value=u.value):(l==="display"&&(u==null?void 0:u.value)==="hidden"?(t.display="visible",t.data=t.data||{},t.data.hidden=!0,requestAnimationFrame(()=>{t.setState(m=>{m.display="visible"})})):(t[l]=u==null?void 0:u.value,requestAnimationFrame(()=>{t.setState(m=>{m[l]=u==null?void 0:u.value})})),l==="display"&&(u==null?void 0:u.value)==="none"&&(t.value=null)),t.stateOfLinkageRules[l]=null}))}}function getFieldNameByOperator(e){switch(e){case ActionType.Required:case ActionType.InRequired:return"required";case ActionType.Visible:case ActionType.None:case ActionType.Hidden:return"display";case ActionType.Editable:case ActionType.ReadOnly:case ActionType.ReadPretty:return"pattern";case ActionType.Value:return"value";default:return null}}const collectFieldStateOfLinkageRules=({operator:e,value:t,field:o,condition:r,variables:i,localVariables:n,variableNameOfLeftCondition:a})=>{var l,c,u,m,d,p,g,h;const f=((l=o==null?void 0:o.stateOfLinkageRules)==null?void 0:l.required)||[(c=o==null?void 0:o.initStateOfLinkageRules)==null?void 0:c.required],_=((u=o==null?void 0:o.stateOfLinkageRules)==null?void 0:u.display)||[(m=o==null?void 0:o.initStateOfLinkageRules)==null?void 0:m.display],v=((d=o==null?void 0:o.stateOfLinkageRules)==null?void 0:d.pattern)||[(p=o==null?void 0:o.initStateOfLinkageRules)==null?void 0:p.pattern],S=((g=o==null?void 0:o.stateOfLinkageRules)==null?void 0:g.value)||[(h=o==null?void 0:o.initStateOfLinkageRules)==null?void 0:h.value],{evaluate:C}=import_client2.evaluators.get("formula.js"),b={ruleGroup:r,variables:i,localVariables:n,variableNameOfLeftCondition:a};switch(e){case ActionType.Required:f.push(getTempFieldState(conditionAnalyses(b),!0)),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{required:f});break;case ActionType.InRequired:f.push(getTempFieldState(conditionAnalyses(b),!1)),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{required:f});break;case ActionType.Visible:case ActionType.None:case ActionType.Hidden:_.push(getTempFieldState(conditionAnalyses(b),e)),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{display:_});break;case ActionType.Editable:case ActionType.ReadOnly:case ActionType.ReadPretty:v.push(getTempFieldState(conditionAnalyses(b),e)),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{pattern:v});break;case ActionType.Value:{const y=()=>q(void 0,null,function*(){var F;if((t==null?void 0:t.mode)==="express"){if((t.value||t.result)==null)return;const{exp:j,scope:k}=yield replaceVariables(t.value||t.result,{variables:i,localVariables:n});try{return C(j,x({now:()=>new Date().toString()},k))}catch(T){console.error(T)}}else return(t==null?void 0:t.mode)==="constant"?(F=t==null?void 0:t.value)!=null?F:t:null});isConditionEmpty(r)?S.push(getTempFieldState(!0,y())):S.push(getTempFieldState(conditionAnalyses(b),y())),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{value:S})}break;default:return null}};function getTempFieldState(e,t){return q(this,null,function*(){return[e,t]=yield Promise.all([e,t]),{condition:e,value:t}})}function isConditionEmpty(e){const t=Object.keys(e)[0]||"$and",o=e[t];return import_lodash.default.isEmpty(o)}function replaceVariables(e,t){return q(this,arguments,function*(o,{variables:r,localVariables:i}){var n;const a={},l={};if(o==null)return;const c=(n=o.match(REGEX_OF_VARIABLE_IN_EXPRESSION))==null?void 0:n.map(u=>q(this,null,function*(){const{value:m}=yield r.parseVariable(u,i),d=`_${(0,import_client.uid)()}`;return l[d]=m,a[u]=d,m}));return c&&(yield Promise.all(c)),{exp:o.replace(REGEX_OF_VARIABLE_IN_EXPRESSION,u=>`{{${a[u]||u}}}`),scope:l}})}const useCloseAction$3=()=>{const{setVisible:e}=useActionContext(),t=(0,import_react.useForm)();return{run(){return q(this,null,function*(){e(!1),t.submit(o=>{console.log(o)})})}}},useSaveCurrentUserValues$1=()=>{const e=(0,import_react_router_dom.useNavigate)(),{setVisible:t}=useActionContext(),o=(0,import_react.useForm)(),r=useAPIClient();return{run(){return q(this,null,function*(){yield o.submit(),yield r.resource("auth").changePassword({values:o.values}),yield o.reset(),t(!1),e("/signin")})}}},schema$4={type:"object",properties:{[(0,import_shared.uid)()]:{"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{zIndex:1e4},type:"void",title:'{{t("Change password")}}',properties:{oldPassword:{type:"string",title:'{{t("Old password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem"},newPassword:{type:"string",title:'{{t("New password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirmPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirmPassword:{type:"string",required:!0,title:'{{t("Confirm password")}}',"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".newPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},footer:{"x-component":"Action.Drawer.Footer",type:"void",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ useCloseAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSaveCurrentUserValues }}"}}}}}}}},useChangePassword=()=>{const e=(0,import_react2.useContext)(DropdownVisibleContext),[t,o]=(0,import_react2.useState)(!1),{t:r}=(0,import_react_i18next.useTranslation)(),{data:i}=useSystemSettings()||{},{enableChangePassword:n}=(i==null?void 0:i.data)||{},a=(0,import_react2.useMemo)(()=>({key:"password",eventKey:"ChangePassword",onClick:()=>{o(!0),e==null||e.setVisible(!1)},label:(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[r("Change password"),(0,import_jsx_runtime.jsx)(ActionContextProvider,{value:{visible:t,setVisible:o},children:(0,import_jsx_runtime.jsx)("div",{onClick:l=>l.stopPropagation(),children:(0,import_jsx_runtime.jsx)(SchemaComponent,{scope:{useCloseAction:useCloseAction$3,useSaveCurrentUserValues:useSaveCurrentUserValues$1},schema:schema$4})})})]})}),[t]);return n===!1?null:a},CurrentUserSettingsMenuContext=(0,import_react2.createContext)(null);CurrentUserSettingsMenuContext.displayName="CurrentUserSettingsMenuContext";const useCurrentUserSettingsMenu=()=>{const{menuItems:e}=(0,import_react2.useContext)(CurrentUserSettingsMenuContext)||{},t=(0,import_react2.useCallback)(()=>e.current,[e]),o=(0,import_react2.useCallback)((r,i)=>{let n;if(i&&(r._options=i),(n=e.current.findIndex(l=>l.key===r.key))!==-1){e.current[n]=r,e.current=[...e.current];return}if(i){if(i.before){const l=e.current.findIndex(c=>c.key===i.before);e.current.splice(l,0,r);return}if(i.after){const l=e.current.findIndex(c=>c.key===i.after);e.current.splice(l+1,0,r);return}}const a=e.current;e.current=a.filter(l=>{var c,u;return r.key!==((c=l._options)==null?void 0:c.before)&&r.key!==((u=l._options)==null?void 0:u.after)}),e.current.push(...a.filter(l=>{var c;return((c=l._options)==null?void 0:c.before)===r.key})),e.current.push(r),e.current.push(...a.filter(l=>{var c;return((c=l._options)==null?void 0:c.after)===r.key}))},[e]);if(!e)throw(0,import_client.error)("CurrentUser: You should use `CurrentUserSettingsMenuProvider` in the root of your app."),new Error("CurrentUser: You should use `CurrentUserSettingsMenuProvider` in the root of your app.");return{getMenuItems:t,addMenuItem:o}},CurrentUserSettingsMenuProvider=({children:e})=>{const t=(0,import_react2.useRef)([]),o=(0,import_react2.useMemo)(()=>({menuItems:t}),[t]);return(0,import_jsx_runtime.jsx)(CurrentUserSettingsMenuContext.Provider,{value:o,children:e})},useCloseAction$2=()=>{const{setVisible:e}=useActionContext(),t=(0,import_react.useForm)();return{run(){return q(this,null,function*(){e(!1),t.submit(o=>{console.log(o)})})}}},useCurrentUserValues=e=>{const t=useCurrentUserContext();return useRequest(()=>Promise.resolve(t.data),e)},useSaveCurrentUserValues=()=>{const e=useCurrentUserContext(),{setVisible:t}=useActionContext(),o=(0,import_react.useForm)(),r=useAPIClient();return{run(){return q(this,null,function*(){var i;const n=yield o.submit();t(!1),yield r.resource("users").updateProfile({values:n}),e.mutate({data:x(x({},(i=e==null?void 0:e.data)==null?void 0:i.data),n)})})}}},schema$3={type:"object",properties:{[(0,import_shared.uid)()]:{"x-decorator":"Form","x-decorator-props":{useValues:"{{ useCurrentUserValues }}"},"x-component":"Action.Drawer","x-component-props":{zIndex:1e4},type:"void",title:'{{t("Edit profile")}}',properties:{nickname:{type:"string",title:"{{t('Nickname')}}","x-decorator":"FormItem","x-component":"Input","x-disabled":"{{ enableEditProfile === false }}"},username:{type:"string",title:'{{t("Username")}}',"x-decorator":"FormItem","x-component":"Input","x-validator":{username:!0},required:!0,"x-disabled":"{{ enableEditProfile === false }}"},email:{type:"string",title:'{{t("Email")}}',"x-decorator":"FormItem","x-component":"Input","x-validator":"email","x-disabled":"{{ enableEditProfile === false }}"},phone:{type:"string",title:'{{t("Phone")}}',"x-decorator":"FormItem","x-component":"Input","x-disabled":"{{ enableEditProfile === false }}"},footer:{"x-component":"Action.Drawer.Footer",type:"void",properties:{cancel:{title:"Cancel","x-component":"Action","x-component-props":{useAction:"{{ useCloseAction }}"}},submit:{title:"Submit","x-component":"Action","x-disabled":"{{ enableEditProfile === false }}","x-component-props":{type:"primary",useAction:"{{ useSaveCurrentUserValues }}"}}}}}}}},useEditProfile=()=>{const e=(0,import_react2.useContext)(DropdownVisibleContext),[t,o]=(0,import_react2.useState)(!1),{t:r}=(0,import_react_i18next.useTranslation)(),{data:i}=useSystemSettings()||{},{enableEditProfile:n}=(i==null?void 0:i.data)||{},a=(0,import_react2.useMemo)(()=>({key:"profile",eventKey:"EditProfile",onClick:()=>{o(!0),e==null||e.setVisible(!1)},label:(0,import_jsx_runtime.jsxs)("div",{children:[r("Edit profile"),(0,import_jsx_runtime.jsx)(ActionContextProvider,{value:{visible:t,setVisible:o},children:(0,import_jsx_runtime.jsx)("div",{onClick:l=>l.stopPropagation(),children:(0,import_jsx_runtime.jsx)(SchemaComponent,{scope:{useCurrentUserValues,useCloseAction:useCloseAction$2,useSaveCurrentUserValues,enableEditProfile:n},schema:schema$3})})})]})}),[t]);return n===!1?null:a},dayjsLocale={"ar-EG":"ar","az-AZ":"az","bg-BG":"bg","bn-BD":"bn-bd","by-BY":"en","ca-ES":"ca","cs-CZ":"cs","da-DK":"da","de-DE":"de","el-GR":"el","en-GB":"en-gb","en-US":"en","es-ES":"es","et-EE":"et","fa-IR":"fa","fi-FI":"fi","fr-BE":"fr","fr-CA":"fr","fr-FR":"fr","ga-IE":"ga","gl-ES":"gl","he-IL":"he","hi-IN":"hi","hr-HR":"hr","hu-HU":"hu","hy-AM":"hy-am","id-ID":"id","is-IS":"is","it-IT":"it","ja-JP":"ja","ka-GE":"ka","kk-KZ":"kk","km-KH":"km","kn-IN":"kn","ko-KR":"ko","ku-IQ":"ku","lt-LT":"lt","lv-LV":"lv","mk-MK":"mk","ml-IN":"ml","mn-MN":"mn","ms-MY":"ms","nb-NO":"nb","ne-NP":"ne","nl-BE":"nl-be","nl-NL":"nl","pl-PL":"pl","pt-BR":"pt-br","pt-PT":"pt","ro-RO":"ro","ru-RU":"ru","si-LK":"si","sk-SK":"sk","sl-SI":"sl","sr-RS":"sr","sv-SE":"sv","ta-IN":"ta","th-TH":"th","tk-TK":"tk","tr-TR":"tr","uk-UA":"uk","ur-PK":"ur","vi-VN":"vi","zh-CN":"zh-cn","zh-HK":"zh-hk","zh-TW":"zh-tw"},languageCodes={"ar-EG":{label:"العربية"},"az-AZ":{label:"Azərbaycan dili"},"bg-BG":{label:"Български"},"bn-BD":{label:"Bengali"},"by-BY":{label:"Беларускі"},"ca-ES":{label:"Сatalà/Espanya"},"cs-CZ":{label:"Česky"},"da-DK":{label:"Dansk"},"de-DE":{label:"Deutsch"},"el-GR":{label:"Ελληνικά"},"en-GB":{label:"English(GB)"},"en-US":{label:"English"},"es-ES":{label:"Español"},"et-EE":{label:"Estonian (Eesti)"},"fa-IR":{label:"فارسی"},"fi-FI":{label:"Suomi"},"fr-BE":{label:"Français(BE)"},"fr-CA":{label:"Français(CA)"},"fr-FR":{label:"Français"},"ga-IE":{label:"Gaeilge"},"gl-ES":{label:"Galego"},"he-IL":{label:"עברית"},"hi-IN":{label:"हिन्दी"},"hr-HR":{label:"Hrvatski jezik"},"hu-HU":{label:"Magyar"},"hy-AM":{label:"Հայերեն"},"id-ID":{label:"Bahasa Indonesia"},"is-IS":{label:"Íslenska"},"it-IT":{label:"Italiano"},"ja-JP":{label:"日本語"},"ka-GE":{label:"ქართული"},"kk-KZ":{label:"Қазақ тілі"},"km-KH":{label:"ភាសាខ្មែរ"},"kn-IN":{label:"ಕನ್ನಡ"},"ko-KR":{label:"한국어"},"ku-IQ":{label:"کوردی"},"lt-LT":{label:"lietuvių"},"lv-LV":{label:"Latviešu valoda"},"mk-MK":{label:"македонски јазик"},"ml-IN":{label:"മലയാളം"},"mn-MN":{label:"Монгол хэл"},"ms-MY":{label:"بهاس ملايو"},"nb-NO":{label:"Norsk bokmål"},"ne-NP":{label:"नेपाली"},"nl-BE":{label:"Vlaams"},"nl-NL":{label:"Nederlands"},"pl-PL":{label:"Polski"},"pt-BR":{label:"Português brasileiro"},"pt-PT":{label:"Português"},"ro-RO":{label:"România"},"ru-RU":{label:"Русский"},"si-LK":{label:"සිංහල"},"sk-SK":{label:"Slovenčina"},"sl-SI":{label:"Slovenščina"},"sr-RS":{label:"српски језик"},"sv-SE":{label:"Svenska"},"ta-IN":{label:"Tamil"},"th-TH":{label:"ภาษาไทย"},"tk-TK":{label:"Turkmen"},"tr-TR":{label:"Türkçe"},"uk-UA":{label:"Українська"},"ur-PK":{label:"Oʻzbekcha"},"vi-VN":{label:"Tiếng Việt"},"zh-CN":{label:"简体中文"},"zh-HK":{label:"繁體中文(香港)"},"zh-TW":{label:"繁體中文(台湾)"}},useLanguageSettings=()=>{var e;const{t,i18n:o}=(0,import_react_i18next.useTranslation)(),r=useAPIClient(),{data:i}=useSystemSettings()||{},n=(0,import_react2.useMemo)(()=>{var l;return((l=i==null?void 0:i.data)==null?void 0:l.enabledLanguages)||[]},[(e=i==null?void 0:i.data)==null?void 0:e.enabledLanguages]),a=(0,import_react2.useMemo)(()=>({key:"language",eventKey:"LanguageSettings",label:(0,import_jsx_runtime.jsx)(SelectWithTitle,{title:t("Language"),options:Object.keys(languageCodes).filter(l=>n.includes(l)).map(l=>({label:languageCodes[l].label,value:l})),defaultValue:o.language,onChange:l=>q(void 0,null,function*(){yield r.resource("users").updateLang({values:{appLang:l}}),r.auth.setLocale(l),window.location.reload()})})}),[r,n,o,t]);return n.length<2?null:a};function SelectWithTitle({title:e,defaultValue:t,onChange:o,options:r,fieldNames:i}){const[n,a]=(0,import_react2.useState)(!1),l=(0,import_react2.useRef)(null);return(0,import_jsx_runtime.jsxs)("div",{style:{alignItems:"center",display:"flex",justifyContent:"space-between"},onClick:c=>{c.stopPropagation(),a(u=>!u)},onMouseLeave:()=>{l.current=setTimeout(()=>{a(!1)},200)},children:[e,(0,import_jsx_runtime.jsx)(import_antd.Select,{open:n,"data-testid":`select-${e}`,popupMatchSelectWidth:!1,bordered:!1,defaultValue:t,onChange:o,popupClassName:`select-popup-${e.replaceAll(" ","-")}`,fieldNames:i,options:r,style:{textAlign:"right",minWidth:100},onMouseEnter:()=>{clearTimeout(l.current)}})]})}class SchemaSettings{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 r=t.split("."),i=P(x({},o),{name:r[r.length-1]});if(r.length===1){const l=this.items.findIndex(c=>c.name===t);l===-1?this.items.push(i):this.items[l]=i;return}const n=r.slice(0,-1).join("."),a=this.get(n);if(a){a.children||(a.children=[]);const l=t.replace(`${a.name}.`,""),c=a.children.findIndex(u=>u.name===l);c===-1?a.children.push(i):a.children[c]=i}}get(t){if(!t)return;const o=t.split(".");let r=this.items;for(let i=0;i<o.length;i++){const n=o[i];if(r=r.find(a=>a.name===n),!r||i===o.length-1)return r;if(r.children)r=r.children;else return}}remove(t){const o=t.split(".");if(o.length===1){const i=this.items.findIndex(n=>n.name===o[0]);i!==-1&&this.items.splice(i,1);return}const r=this.get(o.slice(0,-1).join("."));if(r&&r.children){const i=o[o.length-1],n=r.children.findIndex(a=>a.name===i);n!==-1&&r.children.splice(n,1)}}}class SchemaSettingsManager{constructor(t=[],o){A(this,"schemaSettings",{}),A(this,"actionList",{}),this._schemaSettings=t,this.app=o,this.app=o,this.add(...t)}add(...t){t.forEach(o=>{this.schemaSettings[o.name]=o,Array.isArray(this.actionList[o.name])&&(this.actionList[o.name].forEach(r=>{o[r.type](r.itemName,r.data)}),this.actionList[o.name]=void 0)})}addItem(t,o,r){const i=this.get(t);i?i.add(o,r):(this.actionList[t]||(this.actionList[t]=[]),this.actionList[t].push({type:"add",itemName:o,data:r}))}get(t){return this.schemaSettings[t]}getAll(){return this.schemaSettings}has(t){return!!this.get(t)}remove(t){delete this.schemaSettings[t]}removeItem(t,o){const r=this.get(t);r?r.remove(o):(this.actionList[t]||(this.actionList[t]=[]),this.actionList[t].push({type:"remove",itemName:o}))}}const defaultTheme={name:"",token:{colorPrimaryHeader:"#001529",colorBgHeader:"#001529",colorBgHeaderMenuHover:"#ffffff1a",colorBgHeaderMenuActive:"#ffffff1a",colorTextHeaderMenu:"#ffffffa6",colorTextHeaderMenuHover:"#ffffff",colorTextHeaderMenuActive:"#ffffff",colorSettings:"#F18B62",colorBgSettingsHover:"rgba(241, 139, 98, 0.06)",colorBorderSettingsHover:"rgba(241, 139, 98, 0.3)",motionUnit:.03,motion:!0}};function compatOldTheme(e){var t;return(t=e.token)!=null&&t.colorSettings||(e.token=x(x({},e.token),defaultTheme.token)),e}const customAlgorithm=(e,t)=>{const o=t||import_antd.theme.defaultAlgorithm(e);return o.paddingPageHorizontal===void 0&&(o.paddingPageHorizontal=o.sizeLG),o.paddingPageVertical===void 0&&(o.paddingPageVertical=o.sizeLG),o.paddingPopupHorizontal===void 0&&(o.paddingPopupHorizontal=o.sizeLG),o.paddingPopupVertical===void 0&&(o.paddingPopupVertical=o.size),o.marginBlock===void 0&&(o.marginBlock=o.sizeLG),o.borderRadiusBlock===void 0&&(o.borderRadiusBlock=o.borderRadiusLG),o},addCustomAlgorithmToTheme=e=>(Array.isArray(e.algorithm)?e.algorithm.includes(customAlgorithm)||e.algorithm.push(customAlgorithm):e.algorithm=[e.algorithm,customAlgorithm].filter(Boolean),e.algorithm=e.algorithm.filter(Boolean),e),AppInner=(0,import_react2.memo)(({children:e})=>{const t=useApp(),{notification:o}=import_antd.App.useApp(),r=useAPIClient();return(0,import_react2.useEffect)(()=>{r.notification=o,t.notification=o},[o]),(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e})});AppInner.displayName="AppInner";const AntdAppProvider=({children:e,className:t,style:o})=>(0,import_jsx_runtime.jsx)(import_antd.App,{className:t,style:x({height:"100%"},o),children:(0,import_jsx_runtime.jsx)(AppInner,{children:e})});AntdAppProvider.displayName="AntdAppProvider";const GlobalThemeContext=(0,import_react2.createContext)(null);GlobalThemeContext.displayName="GlobalThemeContext";const useGlobalTheme=()=>import_react2.default.useContext(GlobalThemeContext)||{theme:{},isDarkTheme:!1},GlobalThemeProvider=({children:e,theme:t})=>{const[o,r]=import_react2.default.useState(t||defaultTheme),i=(0,import_react2.useRef)(null),n=(0,import_react2.useRef)(null),a=(0,import_react2.useMemo)(()=>{const p=o==null?void 0:o.algorithm;return Array.isArray(p)?p.includes(import_antd.theme.darkAlgorithm):p===import_antd.theme.darkAlgorithm},[o==null?void 0:o.algorithm]),l=(0,import_react2.useCallback)(p=>{n.current=p&&import_lodash.default.cloneDeep(p)},[]),c=(0,import_react2.useCallback)(()=>n.current,[]),u=(0,import_react2.useCallback)(p=>{i.current=p&&import_lodash.default.cloneDeep(p)},[]),m=(0,import_react2.useCallback)(()=>i.current,[]),d=(0,import_react2.useMemo)(()=>({theme:addCustomAlgorithmToTheme(o),setTheme:r,setCurrentSettingTheme:u,getCurrentSettingTheme:m,setCurrentEditingTheme:l,getCurrentEditingTheme:c,isDarkTheme:a}),[c,m,a,l,u,o]);return(0,import_jsx_runtime.jsx)(GlobalThemeContext.Provider,{value:d,children:(0,import_jsx_runtime.jsx)(import_antd.ConfigProvider,{theme:compatOldTheme(d.theme),children:e})})},useToken$1=()=>import_antd.theme.useToken(),CSSVariableProvider=({children:e})=>{const{token:t}=useToken$1(),o=t.colorFillTertiary,r=new import_tinycolor.TinyColor(t.colorFill).onBackground(t.colorFillSecondary).toHexShortString(),i=new import_tinycolor.TinyColor(t.colorFill).onBackground(t.colorFill).toHexShortString(),n=new import_tinycolor.TinyColor(t.colorFill).onBackground(t.colorFill).onBackground(t.colorFill).toHexShortString();return(0,import_react2.useEffect)(()=>{document.body.style.setProperty("--nb-spacing",`${t.marginLG}px`),document.body.style.setProperty("--nb-designer-offset",`${t.marginXS}px`),document.body.style.setProperty("--nb-header-height",`${t.sizeXXL-2}px`),document.body.style.setProperty("--nb-box-bg",t.colorBgLayout),document.body.style.setProperty("--nb-box-bg",t.colorBgLayout),document.body.style.setProperty("--controlHeightLG",`${t.controlHeightLG}px`),document.body.style.setProperty("--paddingContentVerticalSM",`${t.paddingContentVerticalSM}px`),document.body.style.setProperty("--marginSM",`${t.marginSM}px`),document.body.style.setProperty("--colorInfoBg",t.colorInfoBg),document.body.style.setProperty("--colorInfoBorder",t.colorInfoBorder),document.body.style.setProperty("--colorWarningBg",t.colorWarningBg),document.body.style.setProperty("--colorWarningBorder",t.colorWarningBorder),document.body.style.setProperty("--colorText",t.colorText),document.body.style.setProperty("--colorPrimaryText",t.colorPrimaryText),document.body.style.setProperty("--colorPrimaryTextActive",t.colorPrimaryTextActive),document.body.style.setProperty("--colorPrimaryTextHover",t.colorPrimaryTextHover),document.body.style.setProperty("--colorBgScrollTrack",o),document.body.style.setProperty("--colorBgScrollBar",r),document.body.style.setProperty("--colorBgScrollBarHover",i),document.body.style.setProperty("--colorBgScrollBarActive",n),document.body.style.setProperty("--colorSettings",t.colorSettings||defaultTheme.token.colorSettings),document.body.style.setProperty("--colorBgSettingsHover",t.colorBgSettingsHover),document.body.style.setProperty("--colorBorderSettingsHover",t.colorBorderSettingsHover),document.body.style.setProperty("background-color",t.colorBgContainer)},[r,n,i,o,t.colorBgContainer,t.colorBgLayout,t.colorBgSettingsHover,t.colorBorderSettingsHover,t.colorInfoBg,t.colorInfoBorder,t.colorPrimaryText,t.colorPrimaryTextActive,t.colorPrimaryTextHover,t.colorSettings,t.colorText,t.colorWarningBg,t.colorWarningBorder,t.controlHeightLG,t.marginLG,t.marginSM,t.marginXS,t.paddingContentVerticalSM,t.sizeXXL]),e};CSSVariableProvider.displayName="CSSVariableProvider";function tval(e,t){return t?`{{t(${JSON.stringify(e)}, ${JSON.stringify(t)})}}`:`{{t(${JSON.stringify(e)})}}`}const i18n=import_i18next.default.createInstance();Object.keys(languageCodes).forEach(e=>{languageCodes[e].resources});i18n.use(import_react_i18next.initReactI18next).init({lng:"en-US",defaultNS:"client",resources:{},keySeparator:!1,nsSeparator:!1});function defineDevPlugins(e){Object.entries(e).forEach(([t,o])=>{window.define(`${t}/client`,()=>o)})}function definePluginClient(e){window.define(`${e}/client`,["exports",e],function(t,o){Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(o).forEach(function(r){r!=="__esModule"&&(r in t&&t[r]===o[r]||Object.defineProperty(t,r,{enumerable:!0,get:function(){return o[r]}}))})})}function configRequirejs(e,t){e.requirejs.config({waitSeconds:120,paths:t.reduce((o,r)=>(o[r.packageName]=r.url,o),{})})}function processRemotePlugins(e,t){return(...o)=>{const r=o.map((n,a)=>[e[a].name,(n==null?void 0:n.default)||n]).filter(n=>n[1]);t(r);const i=o.map((n,a)=>n?null:a).filter(n=>n!==null).map(n=>e[n].packageName);i.length>0&&console.error("[nocobase load plugin error]: These plugins do not have an `export.default` exported content or there is an error in the plugins. error plugins: \r\n%s",i.join(`, \r
16
+ }}}`,{dependencies:["uiSchema.x-component-props.picker"],when:'{{$deps[0]==="date"}}',fulfill:{state:{hidden:!1}},otherwise:{state:{hidden:!0,value:!1}}}]},"uiSchema.x-component-props.timeFormat":{type:"string",title:'{{t("Time format")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:"HH:mm:ss",enum:[{label:'{{t("12 hour")}}',value:"hh:mm:ss a"},{label:'{{t("24 hour")}}',value:"HH:mm:ss"}],"x-reactions":{dependencies:["uiSchema.x-component-props.showTime"],fulfill:{state:{hidden:"{{ !$deps[0] }}"}}}}},dataSource={type:"array",title:'{{t("Options")}}',"x-decorator":"FormItem","x-component":"ArrayTable","x-component-props":{pagination:{pageSize:1e3}},items:{type:"object",properties:{column1:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:50,title:"",align:"center"},properties:{sort:{type:"void","x-component":"ArrayTable.SortHandle"}}},column2:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:'{{t("Option value")}}'},properties:{value:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"Input","x-reactions":e=>{!e.initialValue&&!e.initialized&&(e.initialValue=(0,import_shared.uid)(),e.setValue((0,import_shared.uid)()))}}}},column3:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:'{{t("Option label")}}'},properties:{label:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"Input"}}},column4:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:'{{t("Color")}}'},properties:{color:{type:"string","x-decorator":"FormItem","x-component":"ColorSelect"}}},column5:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:"",dataIndex:"operations",fixed:"right"},properties:{item:{type:"void","x-component":"FormItem",properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}}}},properties:{add:{type:"void","x-component":"ArrayTable.Addition","x-component-props":{randomValue:!0},title:"{{t('Add option')}}"}}},defaultProps={"uiSchema.title":{type:"string",title:'{{t("Field display name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Field name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input","x-validator":"uid",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"}},recordPickerViewer={type:"void",title:'{{ t("View record") }}',"x-component":"RecordPicker.Viewer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}},collectionDataSource={type:"string",title:'{{t("Options")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0},enum:"{{collections}}"},index=Object.freeze(Object.defineProperty({__proto__:null,autoFill,autoIncrement,collectionDataSource,constraintsProps,dataSource,dateTimeProps,defaultProps,operators,primaryKey,recordPickerViewer,relationshipType,reverseFieldProperties,type,unique},Symbol.toStringTag,{value:"Module"}));class CollectionFieldInterface{constructor(t){A(this,"name"),A(this,"group"),A(this,"title"),A(this,"description"),A(this,"order"),A(this,"default"),A(this,"sortable"),A(this,"availableTypes"),A(this,"supportDataSourceType"),A(this,"notSupportDataSourceType"),A(this,"hasDefaultValue"),A(this,"componentOptions"),A(this,"isAssociation"),A(this,"operators"),A(this,"properties"),A(this,"filterable"),A(this,"titleUsable"),A(this,"hidden"),this.collectionFieldInterfaceManager=t}addComponentOption(t){var o,r,i,n,a,l;if(!this.componentOptions){this.componentOptions=[];const c=(r=(o=this.default)==null?void 0:o.uiSchema)==null?void 0:r["x-component"],u=(n=(i=this.default)==null?void 0:i.uiSchema)==null?void 0:n["x-component-props"];if(c){const m=((l=(a=this.default)==null?void 0:a.uiSchema)==null?void 0:l.type)||"string",d=(0,import_client.tval)(c.startsWith("Input")?(0,import_lodash.capitalize)(m):c.split(".").pop());this.componentOptions=[{label:d,value:c,useProps(){return u||{}}}]}}this.componentOptions.push(t)}getConfigureFormProperties(){const t=this.hasDefaultValue?this.getDefaultValueProperty():{};return x(x({},(0,import_lodash.cloneDeep)(x(x({},defaultProps),this==null?void 0:this.properties))),t)}getDefaultValueProperty(){var t,o;return{defaultValue:P(x(x({},(0,import_lodash.cloneDeep)((t=this==null?void 0:this.default)==null?void 0:t.uiSchema)),(o=this==null?void 0:this.properties)==null?void 0:o.uiSchema),{required:!1,title:'{{ t("Default value") }}',"x-decorator":"FormItem","x-reactions":[{dependencies:["uiSchema.x-component-props.gmt","uiSchema.x-component-props.showTime","uiSchema.x-component-props.dateFormat","uiSchema.x-component-props.timeFormat","uiSchema.x-component-props.picker"],fulfill:{state:{componentProps:{gmt:"{{$deps[0]}}",showTime:"{{$deps[1]}}",dateFormat:"{{$deps[2]}}",timeFormat:"{{$deps[3]}}",picker:"{{$deps[4]}}"}}}},{dependencies:["uiSchema.x-component-props.picker"],fulfill:{state:{value:null}}},{dependencies:["primaryKey","unique","autoIncrement","defaultToCurrentTime"],when:"{{$deps[0]||$deps[1]||$deps[2]||$deps[3]}}",fulfill:{state:{hidden:!0,value:null}},otherwise:{state:{hidden:!1}}},{dependencies:["uiSchema.enum"],fulfill:{state:{dataSource:"{{$deps[0]}}"}}}]})}}}class CollectionFieldInterfaceManager{constructor(t,o,r){A(this,"collectionFieldInterfaceInstances",{}),A(this,"collectionFieldGroups",{}),A(this,"actionList",{}),this.dataSourceManager=r,this.addFieldInterfaces(t),this.addFieldInterfaceGroups(o)}addFieldInterfaces(t=[]){const o=t.reduce((r,i)=>{const n=new i(this);return r[n.name]=n,Array.isArray(this.actionList[n.name])&&(this.actionList[n.name].forEach(a=>{n[a.type](a.data)}),this.actionList[n.name]=void 0),r},{});Object.assign(this.collectionFieldInterfaceInstances,o)}addFieldInterfaceComponentOption(t,o){const r=this.getFieldInterface(t);if(!r){this.actionList[t]||(this.actionList[t]=[]),this.actionList[t].push({type:"addComponentOption",data:o});return}r.addComponentOption(o)}getFieldInterface(t){return this.collectionFieldInterfaceInstances[t]}getFieldInterfaces(t){return Object.values(this.collectionFieldInterfaceInstances).filter(o=>{var r,i;if(!t||!o.supportDataSourceType&&!o.notSupportDataSourceType)return!0;if(o.supportDataSourceType)return(r=o.supportDataSourceType)==null?void 0:r.includes(t);if(o.notSupportDataSourceType)return!((i=o.notSupportDataSourceType)!=null&&i.includes(t))})}addFieldInterfaceGroups(t){Object.assign(this.collectionFieldGroups,t)}getFieldInterfaceGroups(){return this.collectionFieldGroups}getFieldInterfaceGroup(t){return this.collectionFieldGroups[t]}}const DEFAULT_DATA_SOURCE_KEY="main",DEFAULT_DATA_SOURCE_TITLE='{{t("Main")}}';class DataSourceManager{constructor(t={},o){A(this,"dataSourceInstancesMap",{}),A(this,"multiDataSources",[]),A(this,"collectionMixins",[]),A(this,"collectionTemplateManager"),A(this,"collectionFieldInterfaceManager"),this.options=t,this.app=o,this.collectionTemplateManager=new CollectionTemplateManager(t.collectionTemplates,this),this.collectionFieldInterfaceManager=new CollectionFieldInterfaceManager(t.fieldInterfaces,t.fieldInterfaceGroups,this),this.collectionMixins.push(...t.collectionMixins||[]),this.addDataSource(LocalDataSource,{key:DEFAULT_DATA_SOURCE_KEY,displayName:DEFAULT_DATA_SOURCE_TITLE,collections:t.collections||[]}),(t.dataSources||[]).forEach(r=>{this.addDataSource(LocalDataSource,r)})}addCollectionMixins(t=[]){const o=t.filter(r=>!this.collectionMixins.includes(r));o.length&&(this.collectionMixins.push(...o),this.getDataSources().forEach(r=>r.collectionManager.reAddCollections()))}getDataSources(t){const o=Object.values(this.dataSourceInstancesMap);return t?import_lodash.default.filter(o,t):o}getDataSource(t){return t?this.dataSourceInstancesMap[t]:this.dataSourceInstancesMap[DEFAULT_DATA_SOURCE_KEY]}removeDataSources(t){t.forEach(o=>{delete this.dataSourceInstancesMap[o]})}addDataSource(t,o){const r=new t(o,this);return this.dataSourceInstancesMap[r.key]=r,r}addDataSources(t,o){return q(this,null,function*(){this.multiDataSources.some(([r,i])=>r===t&&i===o)||this.multiDataSources.push([t,o])})}getAllCollections(t={}){const{filterCollection:o,filterDataSource:r}=t;return this.getDataSources(r).reduce((i,n)=>(i.push(P(x({},n.getOptions()),{collections:n.collectionManager.getCollections(o)})),i),[])}addFieldInterfaceGroups(t){this.collectionFieldInterfaceManager.addFieldInterfaceGroups(t)}addCollectionTemplates(t=[]){this.collectionTemplateManager.addCollectionTemplates(t)}addFieldInterfaces(t=[]){this.collectionFieldInterfaceManager.addFieldInterfaces(t)}reload(){return q(this,null,function*(){return yield Promise.all(this.multiDataSources.map(t=>q(this,[t],function*([o,r]){(yield o()).map(i=>this.addDataSource(r,i))}))),Promise.all(this.getDataSources().map(t=>t.reload()))})}}const HEADERS_DATA_SOURCE_KEY="x-data-source",isTitleField=(e,t)=>{var o;return(o=e.collectionFieldInterfaceManager.getFieldInterface(t.interface))==null?void 0:o.titleUsable},useDataSourceHeaders=e=>(0,import_react2.useMemo)(()=>{if(e&&e!==DEFAULT_DATA_SOURCE_KEY)return{[HEADERS_DATA_SOURCE_KEY]:e}},[e]),getDataSourceHeaders=e=>e&&e!==DEFAULT_DATA_SOURCE_KEY?{[HEADERS_DATA_SOURCE_KEY]:e}:{},TreeNode=e=>{const{tag:t,type:o,displayType:r=!0}=e,i={reference:"Reference",duplicate:"Duplicate",preloading:"Preloading"};return(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsxs)(import_antd.Tag,{color:{reference:"blue",duplicate:"green",preloading:"cyan"}[o],children:[(0,import_jsx_runtime.jsx)("span",{children:t})," ",r?`(${i[o]})`:""]})})},systemKeys=["sort","createdById","createdBy","createdAt","updatedById","updatedBy","updatedAt","password","sequence"],useCollectionState=(e,t=!0,o)=>{const{getCollectionFields:r,getAllCollectionsInheritChain:i,getCollection:n,getInterface:a}=useCollectionManager_deprecated(),[l]=(0,import_react2.useState)(m),c=useCompile(),u=(0,import_react.useField)();function m(){return(i(e)||[]).map(v=>{var S;return{label:(S=n(v))==null?void 0:S.title,value:v}})}const d=(v,{exclude:S=[],depth:C=0,maxDepth:b,prefix:y=""})=>C>b?[]:r(v).map(F=>{var j;if(S.includes(F.name)||!F.interface||["sort","password","sequence"].includes(F.type)||o&&o(F))return;const k={type:"duplicate",tag:c((j=F.uiSchema)==null?void 0:j.title)||F.name},T=P(x({},k),{role:"button",title:import_react2.default.createElement(TreeNode,P(x({},k),{displayType:t})),key:y?`${y}.${F.name}`:F.name,isLeaf:!0,field:F});return["belongsTo","belongsToMany"].includes(F.type)?(k.type="reference",T.type="reference",T.title=import_react2.default.createElement(TreeNode,P(x({},k),{type:"reference",displayType:t})),T.isLeaf=!1,T.children=p(F.target,{depth:C+1,maxDepth:b,prefix:T.key,exclude:systemKeys})):["hasOne","hasMany"].includes(F.type)&&(T.isLeaf=!1,T.children=d(F.target,{depth:C+1,maxDepth:b,prefix:T.key,exclude:["id",...systemKeys]})),T}).filter(Boolean),p=(v,{prefix:S,maxDepth:C,depth:b=0,exclude:y=[]})=>b>C?[]:r(v).map(F=>{var j;if(!F.target||!F.interface||y.includes(F.name))return;const k={type:"preloading",tag:c((j=F.uiSchema)==null?void 0:j.title)||F.name},T=S?`${S}.${F.name}`:F.name;return{role:"button",title:import_react2.default.createElement(TreeNode,P(x({},k),{displayType:t})),key:T,isLeaf:!1,field:F,children:p(F.target,{prefix:T,depth:b+1,maxDepth:C,exclude:y})}}).filter(Boolean),g=v=>v.map(S=>P(x({},S),{role:"button",title:import_react2.default.createElement(TreeNode,P(x({},S),{type:S.type,displayType:t})),children:S.children?g(S.children):null})),h=(0,import_react2.useCallback)((v,S,C)=>{var b,y;const F=S.index,j=(y=(b=u.initialValue)==null?void 0:b.items)==null?void 0:y[F];if(!v)return[];if(j!=null&&j.treeData||C)return g(C||j.treeData);try{return d(v,{exclude:["id",...systemKeys],maxDepth:1})}catch(k){return console.error(k),[]}},[]),f=(0,import_react2.useCallback)(v=>S=>new Promise(C=>{if(S.children.length)return S.children.forEach(b=>{loadChildren$1({node:b,traverseAssociations:p,traverseFields:d,systemKeys,fields:v})}),C(void 0);loadChildren$1({node:S,traverseAssociations:p,traverseFields:d,systemKeys,fields:v}),C(void 0)}),[]),_=(0,import_react2.useCallback)(v=>S=>{v.value=S},[]);return{collectionList:l,getEnableFieldTree:h,getOnLoadData:f,getOnCheck:_,getScopeDataSource:v=>{const S=r(v),C=(y,F)=>{var j,k;if(!y.interface)return;const T=a(y.interface);if(!(T!=null&&T.filterable))return;const{nested:O,children:N,operators:L}=T.filterable,D={name:y.name,title:((j=y==null?void 0:y.uiSchema)==null?void 0:j.title)||y.name,schema:y==null?void 0:y.uiSchema,operators:((k=L==null?void 0:L.filter)==null?void 0:k.call(L,R=>!(R!=null&&R.visible)||R.visible(y)))||[],interface:y.interface};if(!(y.target&&F>2)){if(F>2)return D;if(N!=null&&N.length&&(D.children=N),O){const R=r(y.target),$=b(R,F+1).filter(Boolean);D.children=D.children||[],D.children.push(...$)}return D}},b=(y,F)=>{const j=[];return y.forEach(k=>{const T=C(k,F);T&&j.push(T)}),j};return b(S,1)},useTitleFieldDataSource:v=>{const S=v.path.entire.replace("titleField","collection"),C=v.query(S).get("value"),b=r(C).filter(y=>{var F;return(F=a(y.interface))==null?void 0:F.titleUsable}).map(y=>{var F;return{value:y==null?void 0:y.name,label:c((F=y==null?void 0:y.uiSchema)==null?void 0:F.title)||(y==null?void 0:y.name)}});v.dataSource=b}}};function findNode(e,t){const o=[...e];for(;o.length;){const r=o.shift();if(r.key===t.key)return r;r.children&&o.push(...r.children)}}function loadChildren$1({node:e,traverseAssociations:t,traverseFields:o,systemKeys:r,fields:i}){const n=findNode(i.dataSource||i.componentProps.treeData,e);let a=[];return["belongsTo","belongsToMany"].includes(e.field.type)&&(e==null?void 0:e.type)==="reference"?a=t(e.field.target,{exclude:r,prefix:e.key,maxDepth:1}):(["hasOne","hasMany"].includes(e.field.type)||(e==null?void 0:e.type)==="duplicate")&&(a=o(e.field.target,{exclude:["id",...r],prefix:e.key,maxDepth:1})),a.length?n.children=a:n.isLeaf=!0,a}const NavigateNoUpdateContext=import_react2.default.createContext(null);NavigateNoUpdateContext.displayName="NavigateNoUpdateContext";const LocationNoUpdateContext=import_react2.default.createContext(null);LocationNoUpdateContext.displayName="LocationNoUpdateContext";const LocationSearchContext=import_react2.default.createContext("");LocationSearchContext.displayName="LocationSearchContext";const IsAdminPageContext=import_react2.default.createContext(!1);IsAdminPageContext.displayName="IsAdminPageContext";const CurrentPageUidContext=import_react2.default.createContext("");CurrentPageUidContext.displayName="CurrentPageUidContext";const MatchAdminContext=import_react2.default.createContext(!1);MatchAdminContext.displayName="MatchAdminContext";const MatchAdminNameContext=import_react2.default.createContext(!1);MatchAdminNameContext.displayName="MatchAdminNameContext";const IsInSettingsPageContext=import_react2.default.createContext(!1);IsInSettingsPageContext.displayName="IsInSettingsPageContext";const CurrentTabUidContext=import_react2.default.createContext("");CurrentTabUidContext.displayName="CurrentTabUidContext";const SearchParamsContext=import_react2.default.createContext(new URLSearchParams);SearchParamsContext.displayName="SearchParamsContext";const RouterBasenameContext=import_react2.default.createContext("");RouterBasenameContext.displayName="RouterBasenameContext";const IsSubPageClosedByPageMenuContext=import_react2.default.createContext({isSubPageClosedByPageMenu:!1,setFieldSchema:()=>{}});IsSubPageClosedByPageMenuContext.displayName="IsSubPageClosedByPageMenuContext";const IsSubPageClosedByPageMenuProvider=({children:e})=>{const t=(0,import_react_router_dom.useParams)(),o=(0,import_react2.useRef)({}),[r,i]=(0,import_react2.useState)(null),n=(0,import_react2.useMemo)(()=>{var l,c;const u=import_lodash.default.isEmpty(t["*"])&&((l=r==null?void 0:r["x-component-props"])==null?void 0:l.openMode)==="page"&&!!((c=o.current["*"])!=null&&c.includes(r["x-uid"]));return o.current=t,u},[r,t]),a=(0,import_react2.useMemo)(()=>({isSubPageClosedByPageMenu:n,setFieldSchema:i}),[n]);return(0,import_jsx_runtime.jsx)(IsSubPageClosedByPageMenuContext.Provider,{value:a,children:e})},RouterBasenameProvider=({children:e})=>{const t=(0,import_react_router_dom.useHref)("/");return(0,import_jsx_runtime.jsx)(RouterBasenameContext.Provider,{value:t,children:e})},SearchParamsProvider=({children:e})=>{const[t]=(0,import_react_router_dom.useSearchParams)();return(0,import_jsx_runtime.jsx)(SearchParamsContext.Provider,{value:t,children:e})},IsInSettingsPageProvider=({children:e})=>{const t=(0,import_react_router_dom.useLocation)().pathname.includes("/settings");return(0,import_jsx_runtime.jsx)(IsInSettingsPageContext.Provider,{value:t,children:e})},MatchAdminProvider=({children:e})=>{const t=!!(0,import_react_router_dom.useMatch)("/admin");return(0,import_jsx_runtime.jsx)(MatchAdminContext.Provider,{value:t,children:e})},MatchAdminNameProvider=({children:e})=>{const t=!!(0,import_react_router_dom.useMatch)("/admin/:name");return(0,import_jsx_runtime.jsx)(MatchAdminNameContext.Provider,{value:t,children:e})},IsAdminPageProvider=({children:e})=>{const t=(0,import_react_router_dom.useLocation)().pathname.startsWith("/admin");return(0,import_jsx_runtime.jsx)(IsAdminPageContext.Provider,{value:t,children:e})},CurrentPageUidProvider=({children:e})=>{const t=(0,import_react_router_dom.useParams)();return(0,import_jsx_runtime.jsx)(CurrentPageUidContext.Provider,{value:t.name,children:e})},CurrentTabUidProvider=({children:e})=>{const t=(0,import_react_router_dom.useParams)();return(0,import_jsx_runtime.jsx)(CurrentTabUidContext.Provider,{value:t.tabUid,children:e})},NavigateNoUpdateProvider=({children:e})=>{const t=(0,import_react_router_dom.useNavigate)(),o=import_react2.default.useRef(t);o.current=t;const r=import_react2.default.useCallback((i,n)=>{o.current(i,n)},[]);return(0,import_jsx_runtime.jsx)(NavigateNoUpdateContext.Provider,{value:r,children:e})},LocationNoUpdateProvider=({children:e})=>{const t=(0,import_react_router_dom.useLocation)(),o=import_react2.default.useRef({});return(0,import_react2.useEffect)(()=>{Object.assign(o.current,t)},[t]),(0,import_jsx_runtime.jsx)(LocationNoUpdateContext.Provider,{value:o.current,children:e})},LocationSearchProvider=({children:e})=>{const t=(0,import_react_router_dom.useLocation)();return(0,import_jsx_runtime.jsx)(LocationSearchContext.Provider,{value:t.search,children:e})},useNavigateNoUpdate=()=>import_react2.default.useContext(NavigateNoUpdateContext),useLocationNoUpdate=()=>import_react2.default.useContext(LocationNoUpdateContext),useLocationSearch=()=>import_react2.default.useContext(LocationSearchContext),useIsAdminPage=()=>import_react2.default.useContext(IsAdminPageContext),useCurrentPageUid=()=>import_react2.default.useContext(CurrentPageUidContext),useMatchAdmin=()=>import_react2.default.useContext(MatchAdminContext),useMatchAdminName=()=>import_react2.default.useContext(MatchAdminNameContext),useIsInSettingsPage=()=>import_react2.default.useContext(IsInSettingsPageContext),useCurrentTabUid=()=>import_react2.default.useContext(CurrentTabUidContext),useCurrentSearchParams=()=>import_react2.default.useContext(SearchParamsContext),useRouterBasename=()=>import_react2.default.useContext(RouterBasenameContext),useIsSubPageClosedByPageMenu=e=>{const{isSubPageClosedByPageMenu:t,setFieldSchema:o}=import_react2.default.useContext(IsSubPageClosedByPageMenuContext);return(0,import_react2.useEffect)(()=>{o(e)},[e,o]),t},CustomRouterContextProvider=({children:e})=>(0,import_jsx_runtime.jsx)(NavigateNoUpdateProvider,{children:(0,import_jsx_runtime.jsx)(LocationNoUpdateProvider,{children:(0,import_jsx_runtime.jsx)(IsAdminPageProvider,{children:(0,import_jsx_runtime.jsx)(LocationSearchProvider,{children:(0,import_jsx_runtime.jsx)(MatchAdminProvider,{children:(0,import_jsx_runtime.jsx)(MatchAdminNameProvider,{children:(0,import_jsx_runtime.jsx)(SearchParamsProvider,{children:(0,import_jsx_runtime.jsx)(RouterBasenameProvider,{children:(0,import_jsx_runtime.jsx)(IsInSettingsPageProvider,{children:e})})})})})})})})}),useDefaultDynamicComponentProps=()=>{},getHook=(e,t,o)=>{let r;return import_lodash.default.isFunction(e)?r=e:(r=t[e],r||console.error(`${o} is not registered`)),r||useDefaultDynamicComponentProps},getUseDynamicProps=(e,t)=>{if(!e)return useDefaultDynamicComponentProps;if(import_lodash.default.isFunction(e))return e;const o=e.split(".");let r;for(const i of o)r=getHook(i,r||t,e);return r};function useDynamicComponentProps(e,t){const o=(0,import_react.useExpressionScope)();return getUseDynamicProps(e,o)(t)}function withDynamicSchemaProps(e,t={}){const o=t.displayName||e.displayName||e.name,r=i=>{const{dn:n,findComponent:a}=useDesignable(),l=(0,import_react2.useMemo)(()=>{const m=n.getSchemaAttribute("x-component"),d=n.getSchemaAttribute("x-decorator"),p=n.getSchemaAttribute("x-use-component-props"),g=n.getSchemaAttribute("x-use-decorator-props");if(m&&p&&a(m)===r)return p;if(d&&g&&a(d)===r)return g},[n]),c=useDynamicComponentProps(l,i),u=(0,import_react2.useMemo)(()=>x(x({},i),c),[c,i]);return(0,import_jsx_runtime.jsx)(import_react2.Suspense,{fallback:(0,import_jsx_runtime.jsx)(import_antd.Spin,{}),children:(0,import_jsx_runtime.jsx)(e,P(x({},u),{children:i.children}))})};return e.displayName=o,r.displayName=`withSchemaProps(${o})`,r}const TreeRecordContext=(0,import_react2.createContext)(null),TreeRecordProvider=({children:e,parent:t})=>(0,import_jsx_runtime.jsx)(TreeRecordContext.Provider,{value:{parent:t},children:e}),useTreeParentRecord=()=>{const e=import_react2.default.useContext(TreeRecordContext);return e==null?void 0:e.parent},TemplateBlockContext=(0,import_react2.createContext)({});TemplateBlockContext.displayName="TemplateBlockContext";const useTemplateBlockContext=()=>(0,import_react2.useContext)(TemplateBlockContext),TemplateBlockProvider=({onTemplateLoaded:e,children:t})=>{const[o,r]=(0,import_react2.useState)(!1),i=(0,import_react2.useCallback)(()=>{r(!0),setTimeout(()=>{e==null||e()})},[e]),n=(0,import_react2.useMemo)(()=>({templateFinished:o,onTemplateSuccess:i}),[i,o]);return(0,import_jsx_runtime.jsx)(TemplateBlockContext.Provider,{value:n,children:t})},FormActiveFieldsContext=(0,import_react2.createContext)(null),FormActiveFieldsProvider=({children:e,name:t,getActiveFieldsName:o,addActiveFieldName:r,removeActiveFieldName:i})=>{const n=(0,import_react2.useRef)(new Set),a=(0,import_react2.useContext)(FormActiveFieldsContext),l=(0,import_react2.useMemo)(()=>({getActiveFieldsName:o||(c=>!c||c===t?Array.from(n.current):a==null?void 0:a.getActiveFieldsName(c)),addActiveFieldName:r||(c=>{n.current.add(c)}),removeActiveFieldName:i||(c=>{n.current.delete(c)}),name:t,parent:a}),[r,o,t,i,a]);return(0,import_jsx_runtime.jsx)(FormActiveFieldsContext.Provider,{value:l,children:e})},useFormActiveFields=()=>(0,import_react2.useContext)(FormActiveFieldsContext),FormBlockContext$1=(0,import_react2.createContext)({});FormBlockContext$1.displayName="FormBlockContext";const InternalFormBlockProvider=e=>{var t;const o=useCollectionManager(),r=useFormBlockContext(),{action:i,readPretty:n,params:a,collection:l,association:c}=e,u=(0,import_react.useField)(),m=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)({readPretty:n}),[n]),{resource:d,service:p,updateAssociationValues:g}=useBlockRequestContext(),h=(0,import_react2.useRef)(),f=useCollectionRecord(),_=(0,import_react2.useMemo)(()=>{var v;return P(x({},r),{params:a,action:i,form:m,type:i==="get"?"update":"create",field:u,service:p,resource:d,updateAssociationValues:g,formBlockRef:h,collectionName:l||((v=o.getCollectionField(c))==null?void 0:v.target),formRecord:f})},[i,c,o,l,r,u,m,a,f,d,p,g]);return(0,import_jsx_runtime.jsx)(FormBlockContext$1.Provider,{value:_,children:(0,import_jsx_runtime.jsx)(RecordProvider,{isNew:f==null?void 0:f.isNew,parent:(t=f==null?void 0:f.parentRecord)==null?void 0:t.data,record:f==null?void 0:f.data,children:(0,import_jsx_runtime.jsx)("div",{ref:h,children:e.children})})})},useFormBlockType=()=>{const e=useFormBlockContext()||{};return(0,import_react2.useMemo)(()=>({type:e.type}),[e.type])},useIsDetailBlock=()=>{const e=useFormBlockContext(),{fieldSchema:t}=useActionContext();return e.type!=="create"&&(t==null?void 0:t["x-acl-action"])!=="create"&&(t==null?void 0:t["x-action"])!=="create"},FormBlockProvider=withDynamicSchemaProps(e=>{const t=useCollectionParentRecordData(),{parentRecord:o}=e,r=useCollectionRecordData(),{association:i}=e,n=useCollectionManager(),{__collection:a}=r||{},{designable:l}=useDesignable(),c=e.collection||n.getCollection(i).name,u=(0,import_ahooks.useUpdate)();return!l&&a&&a!==c?null:(0,import_jsx_runtime.jsx)(TemplateBlockProvider,{onTemplateLoaded:u,children:(0,import_jsx_runtime.jsx)(BlockProvider,P(x({name:e.name||"form"},e),{block:"form",parentRecord:o||t,children:(0,import_jsx_runtime.jsx)(FormActiveFieldsProvider,{name:"form",children:(0,import_jsx_runtime.jsx)(InternalFormBlockProvider,x({},e))})}))})}),useFormBlockContext=()=>(0,import_react2.useContext)(FormBlockContext$1),useFormBlockProps$1=()=>{var e,t,o;const r=useFormBlockContext(),i=useTreeParentRecord();return(0,import_react2.useEffect)(()=>{var n;i&&((n=r.form)==null||n.query("parent").take(a=>{a.disabled=!0,a.value=i}))}),(0,import_react2.useEffect)(()=>{var n,a,l;const c=r.form;!c||(n=r.service)!=null&&n.loading||c.setInitialValues((l=(a=r.service)==null?void 0:a.data)==null?void 0:l.data)},[r.form,(t=(e=r.service)==null?void 0:e.data)==null?void 0:t.data,(o=r.service)==null?void 0:o.loading]),{form:r.form}},findFormBlock=e=>{for(;e;){if(e["x-decorator"]==="FormBlockProvider")return e;if(e["x-component"]==="AssociationField.Selector")return null;e=e.parent}return null},setDataLoadingModeSettingsItem={name:"setDataLoadingMode",Component:SetDataLoadingMode};function useDataLoadingMode(){const{dataLoadingMode:e}=useDataBlockProps()||{};return e||"auto"}function SetDataLoadingMode(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),n=useCollection(),{getEnableFieldTree:a,getOnLoadData:l}=useCollectionState(n==null?void 0:n.name),{getDataBlockRequest:c}=useDataBlockRequestGetter();return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:o("Set data loading mode"),scope:{getEnableFieldTree:a,name:n==null?void 0:n.name,getOnLoadData:l},schema:{type:"object",title:o("Data loading mode"),properties:{dataLoadingMode:{"x-decorator":"FormItem","x-component":"Radio.Group",default:((e=i["x-decorator-props"])==null?void 0:e.dataLoadingMode)||"auto",enum:[{value:"auto",label:o("Load all data when filter is empty")},{value:"manual",label:o("Do not load data when filter is empty")}]}}},onSubmit:({dataLoadingMode:u})=>{const m=c();import_lodash.default.set(i,"x-decorator-props.dataLoadingMode",u),r.decoratorProps.dataLoadingMode=u,t.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":x({},i["x-decorator-props"])}}),t.refresh(),u==="auto"?m.run():m.mutate(void 0)}})}const useSourceKey=e=>useCollectionManager().getSourceKeyByAssociation(e),KeepAliveContext=(0,import_react2.createContext)(!0),DesignableInterceptor=({children:e,active:t})=>{const o=(0,import_react2.useContext)(SchemaComponentContext),r=(0,import_react2.useContext)(import_react.SchemaOptionsContext),i=(0,import_react2.useContext)(import_react.SchemaComponentsContext),n=(0,import_react2.useContext)(import_react.SchemaExpressionScopeContext),a=(0,import_react2.useContext)(ACLContext),l=(0,import_react2.useRef)(o),c=(0,import_react2.useRef)(r),u=(0,import_react2.useRef)(i),m=(0,import_react2.useRef)(n),d=(0,import_react2.useRef)(a);return t&&(l.current=o,c.current=r,u.current=i,m.current=n,d.current=a),(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:l.current,children:(0,import_jsx_runtime.jsx)(import_react.SchemaOptionsContext.Provider,{value:c.current,children:(0,import_jsx_runtime.jsx)(import_react.SchemaComponentsContext.Provider,{value:u.current,children:(0,import_jsx_runtime.jsx)(import_react.SchemaExpressionScopeContext.Provider,{value:m.current,children:(0,import_jsx_runtime.jsx)(ACLContext.Provider,{value:d.current,children:e})})})})})},KeepAliveProvider=({children:e,active:t})=>{const o=(0,import_react2.useContext)(import_react_router_dom.UNSAFE_LocationContext),r=(0,import_react2.useContext)(import_react_router_dom.UNSAFE_RouteContext),i=(0,import_react2.useRef)(o),n=(0,import_react2.useRef)(r);return t&&!import_lodash.default.isEqual(import_lodash.default.omit(i.current.location,"key"),import_lodash.default.omit(o.location,"key"))&&(i.current=o),t&&!import_lodash.default.isEqual(n.current,r)&&(n.current=r),(0,import_jsx_runtime.jsx)(KeepAliveContext.Provider,{value:t,children:(0,import_jsx_runtime.jsx)(DesignableInterceptor,{active:t,children:(0,import_jsx_runtime.jsx)(import_react_router_dom.UNSAFE_LocationContext.Provider,{value:i.current,children:(0,import_jsx_runtime.jsx)(import_react_router_dom.UNSAFE_RouteContext.Provider,{value:n.current,children:e})})})})},useKeepAlive=()=>({active:(0,import_react2.useContext)(KeepAliveContext)}),getMaxPageCount=()=>{let e=5;try{const t=navigator.deviceMemory;if(t)return Math.min(Math.max(5,t*3),20);const o=performance.memory;if(o!=null&&o.jsHeapSizeLimit){const n=o.jsHeapSizeLimit/1073741824;return Math.min(Math.max(5,Math.floor(n*3)),20)}const r=performance.now();for(let n=0;n<1e6;n++);const i=performance.now()-r;return i<3?e=20:i<5?e=10:i<10&&(e=5),e}catch{return 5}},MAX_RENDERED_PAGE_COUNT=getMaxPageCount(),KeepAlive=import_react2.default.memo(({children:e,uid:t})=>{const o=(0,import_react2.useRef)([]);return o.current.includes(t)||(o.current.push(t),o.current.length>MAX_RENDERED_PAGE_COUNT&&(o.current=o.current.slice(-MAX_RENDERED_PAGE_COUNT))),(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:o.current.map(r=>(0,import_jsx_runtime.jsx)(CurrentPageUidContext.Provider,{value:r,children:(0,import_jsx_runtime.jsx)(KeepAliveProvider,{active:r===t,children:e(r)})},r))})});KeepAlive.displayName="KeepAlive";const DEBOUNCE_WAIT=100,LOADING_DELAY=void 0,EMPTY_OBJECT=Object.freeze({});class CollectionRecord{constructor(t){A(this,"data"),A(this,"parentRecord"),A(this,"isNew");const{data:o,parentRecord:r,isNew:i}=t;this.isNew=i,this.data=o,this.parentRecord=r}setData(t){this.data=t}setParentRecord(t){this.parentRecord=t}}const CollectionRecordContext=(0,import_react2.createContext)(null);CollectionRecordContext.displayName="CollectionRecordContext";const CollectionRecordProvider=import_react2.default.memo(({isNew:e,record:t,parentRecord:o,children:r})=>{const i=(0,import_react2.useMemo)(()=>{if(o)return o instanceof CollectionRecord?o:new CollectionRecord({data:o});if(t instanceof CollectionRecord)return t.parentRecord},[o,t]),n=(0,import_react2.useMemo)(()=>{let a;return t?t instanceof CollectionRecord?(a=t,a.isNew=t.isNew||e):a=new CollectionRecord({data:t,isNew:e}):a=new CollectionRecord({isNew:e}),a.setParentRecord(i),a},[t,i,e]);return(0,import_jsx_runtime.jsx)(CollectionRecordContext.Provider,{value:n,children:r})});CollectionRecordProvider.displayName="CollectionRecordProvider";function useCollectionRecord(){return(0,import_react2.useContext)(CollectionRecordContext)}function useCollectionRecordData(){const e=useCollectionRecord();return e==null?void 0:e.data}function useCollectionParentRecord(){const e=useCollectionRecord();return e==null?void 0:e.parentRecord}function useCollectionParentRecordData(){var e;const t=useCollectionRecord();return(e=t==null?void 0:t.parentRecord)==null?void 0:e.data}const DataBlockResourceContext$1=(0,import_react2.createContext)(null);DataBlockResourceContext$1.displayName="DataBlockResourceContext";const DataBlockResourceProvider=({children:e})=>{const t=useDataBlockProps(),o=useCollectionManager(),{association:r,collection:i,dataSource:n,sourceId:a,parentRecord:l}=t,c=useAPIClient(),u=useDataSourceHeaders(n),m=(0,import_react2.useMemo)(()=>typeof i=="string"?i:i==null?void 0:i.name,[i]),d=(0,import_react2.useMemo)(()=>{if(a)return a;if(r&&l){const g=o.getSourceKeyByAssociation(r),h=l instanceof CollectionRecord?l.data:l;if((0,import_lodash.isArray)(g)){const f={};for(const _ of g)f[_]=h==null?void 0:h[_];return encodeURIComponent(JSON.stringify(f))}else return h[g]}},[r,a,l]),p=(0,import_react2.useMemo)(()=>r?c.resource(r,d,u,!d):c.resource(m,void 0,u),[c,r,i,d,u]);return(0,import_jsx_runtime.jsx)(DataBlockResourceContext$1.Provider,{value:p,children:e})};function useDataBlockResource(){const e=(0,import_react2.useContext)(DataBlockResourceContext$1);if(!e)throw new Error("useDataBlockResource() must be used within a DataBlockResourceProvider");return e}const DataBlockContext=(0,import_react2.createContext)({});DataBlockContext.displayName="DataBlockContext";const DataBlockResourceContext=(0,import_react2.createContext)(null),RerenderDataBlockProvider=({children:e})=>{const[t,o]=import_react2.default.useState(!1),r=(0,import_react2.useMemo)(()=>({rerenderDataBlock:()=>{o(!0),setTimeout(()=>{o(!1)})}}),[]);return t?null:(0,import_jsx_runtime.jsx)(DataBlockResourceContext.Provider,{value:r,children:e})},AssociationOrCollectionProvider=e=>{const{collection:t,association:o,allowNull:r=!1}=e,i=(0,import_react2.useMemo)(()=>o?{Component:AssociationProvider,name:o}:{Component:SanitizedCollectionProvider,name:t},[t,o]);return(0,import_jsx_runtime.jsx)(i.Component,{name:i.name,allowNull:r,children:e.children})},DataBlockProvider=withDynamicSchemaProps(import_react2.default.memo(e=>{const t=e,{collection:o,association:r,dataSource:i,children:n,hidden:a}=t,l=K(t,["collection","association","dataSource","children","hidden"]),{dn:c}=useDesignable();return a?null:(0,import_jsx_runtime.jsx)(DataBlockContext.Provider,{value:{dn:c,props:P(x({},l),{collection:o,association:r,dataSource:i})},children:(0,import_jsx_runtime.jsx)(CollectionManagerProvider,{dataSource:i,children:(0,import_jsx_runtime.jsx)(AssociationOrCollectionProvider,{collection:o,association:r,children:(0,import_jsx_runtime.jsx)(ACLCollectionProvider,{children:(0,import_jsx_runtime.jsx)(DataBlockResourceProvider,{children:(0,import_jsx_runtime.jsx)(BlockRequestProvider,{children:(0,import_jsx_runtime.jsx)(DataBlockCollector,{params:e.params,children:(0,import_jsx_runtime.jsx)(RerenderDataBlockProvider,{children:n})})})})})})})})}),{displayName:"DataBlockProvider"}),useDataBlock=()=>{const e=(0,import_react2.useContext)(DataBlockContext);if(!e)throw new Error("useDataBlock() must be used within a DataBlockProvider");return e},useDataBlockProps=()=>useDataBlock().props,useRerenderDataBlock=()=>{const e=(0,import_react2.useContext)(DataBlockResourceContext);if(!e)throw new Error("useRerenderDataBlock() must be used within a DataBlockProvider");return e},BlockRequestRefContext=(0,import_react2.createContext)(null);BlockRequestRefContext.displayName="BlockRequestRefContext";const BlockRequestLoadingContext=(0,import_react2.createContext)(!1);BlockRequestLoadingContext.displayName="BlockRequestLoadingContext";const BlockRequestDataContext=(0,import_react2.createContext)(null);BlockRequestDataContext.displayName="BlockRequestDataContext";function useRecordRequest(e){const t=useDataLoadingMode(),o=useDataBlockResource(),{action:r,params:i={},record:n,requestService:a,requestOptions:l,sourceId:c,association:u,parentRecord:m}=e,d=useAPIClient(),p=useDataBlockProps(),g=useDataSourceHeaders(p.dataSource),h=useSourceKey(u),[f,_]=(0,import_react2.useMemo)(()=>[JSON.stringify(i),JSON.stringify(n)],[i,n]),v=S=>{var C;if(n)return Promise.resolve({data:n});if(!r)throw new Error("[nocobase]: The 'action' parameter is missing in the 'DataBlockRequestProvider' component");if(r==="get"&&import_lodash.default.isNil(i.filterByTk))return console.warn('[nocobase]: The "filterByTk" parameter is missing in the "DataBlockRequestProvider" component');const b=i.filterByTk===void 0?import_lodash.default.omit(i,"filterByTk"):i;return(C=o[r])==null?void 0:C.call(o,x(x({},b),S)).then(y=>y.data)};return useRequest((...S)=>q(this,null,function*(){const[C,b]=yield Promise.all([(a||v)(...S),requestParentRecordData({sourceId:c,association:u,parentRecord:m,api:d,headers:g,sourceKey:h})]);return C&&(C.parentRecord=b==null?void 0:b.data),C}),P(x({},l),{manual:t==="manual",ready:!!r,refreshDeps:[r,f,_,o,u,m,c]}))}function requestParentRecordData(e){return q(this,arguments,function*({sourceId:t,association:o,parentRecord:r,api:i,headers:n,sourceKey:a}){if(r)return Promise.resolve({data:r});if(!o||!a||!t)return Promise.resolve({data:void 0});const l=`${o.split(".")[0]}:get?filter[${a}]=${t}`;return(yield i.request({url:l,headers:n})).data})}const BlockRequestContextProvider=e=>{var t,o,r,i,n,a;const l=(0,import_react2.useRef)(e.recordRequest),c=(0,import_react2.useRef)((t=e.recordRequest)==null?void 0:t.data),{active:u}=useKeepAlive(),m=(0,import_react2.useRef)(u),d=(0,import_react2.useDeferredValue)(u),p=useDataBlockProps();return d&&!m.current&&p.dataLoadingMode==="auto"&&((o=e.recordRequest)==null||o.refresh()),d&&m.current&&!((r=e.recordRequest)!=null&&r.loading)&&!import_lodash.default.isEqual(c.current,(i=e.recordRequest)==null?void 0:i.data)&&(c.current=(n=e.recordRequest)==null?void 0:n.data),d!==m.current&&(m.current=d),l.current=e.recordRequest,(0,import_jsx_runtime.jsx)(BlockRequestRefContext.Provider,{value:l,children:(0,import_jsx_runtime.jsx)(BlockRequestLoadingContext.Provider,{value:(a=e.recordRequest)==null?void 0:a.loading,children:(0,import_jsx_runtime.jsx)(BlockRequestDataContext.Provider,{value:c.current,children:e.children})})})},BlockRequestProvider=import_react2.default.memo(({children:e})=>{var t,o;const r=useDataBlockProps(),{action:i,filterByTk:n,sourceId:a,params:l=EMPTY_OBJECT,association:c,collection:u,record:m,parentRecord:d,requestOptions:p,requestService:g}=r,h=(0,import_react2.useMemo)(()=>P(x({},l),{filterByTk:n||l.filterByTk}),[n,l]),f=useRecordRequest({action:i,sourceId:a,record:m,association:c,collection:u,requestOptions:p,requestService:g,params:h,parentRecord:d}),_=(t=f.data)==null?void 0:t.parentRecord,v=(0,import_react2.useMemo)(()=>_&&new CollectionRecord({isNew:!1,data:_ instanceof CollectionRecord?_.data:_}),[_]);return(0,import_jsx_runtime.jsx)(BlockRequestContextProvider,{recordRequest:f,children:i!=="list"?(0,import_jsx_runtime.jsx)(CollectionRecordProvider,{isNew:i==null,record:((o=f.data)==null?void 0:o.data)||m,parentRecord:v||d,children:e}):(0,import_jsx_runtime.jsx)(CollectionRecordProvider,{isNew:!1,record:null,parentRecord:v||d,children:e})})});BlockRequestProvider.displayName="DataBlockRequestProvider";const useDataBlockRequest=()=>{const e=(0,import_react2.useContext)(BlockRequestRefContext),t=(0,import_react2.useContext)(BlockRequestLoadingContext),o=(0,import_react2.useContext)(BlockRequestDataContext);return(0,import_react2.useMemo)(()=>e?P(x({},e.current),{loading:t,data:o}):null,[e,o,t])},useDataBlockRequestGetter=()=>{const e=(0,import_react2.useContext)(BlockRequestRefContext);return(0,import_react2.useMemo)(()=>({getDataBlockRequest:()=>e?e.current:null}),[e])},useDataBlockRequestData=()=>(0,import_react2.useContext)(BlockRequestDataContext);var FilterBlockType=(e=>(e[e.FORM=0]="FORM",e[e.TABLE=1]="TABLE",e[e.TREE=2]="TREE",e[e.COLLAPSE=3]="COLLAPSE",e))(FilterBlockType||{});const mergeFilter=(e,t="$and")=>{const o=e.filter(r=>{if(r&&typeof r=="object"&&!Array.isArray(r))return Object.values(r).filter(i=>i!==void 0).length});return o.length===0?{}:o.length===1?o[0]:{[t]:o}},getSupportFieldsByAssociation=(e,t)=>{var o;return(o=t.associatedFields)==null?void 0:o.filter(r=>e==null?void 0:e.some(i=>i===r.target))},getSupportFieldsByForeignKey=(e,t)=>{var o;return(o=t.foreignKeyFields)==null?void 0:o.filter(r=>e.fields.some(i=>i.type!=="belongsTo"&&i.foreignKey===r.name))},useSupportedBlocks=e=>{const{getDataBlocks:t}=useFilterBlock(),o=(0,import_react.useFieldSchema)(),r=useCollection(),{getAllCollectionsInheritChain:i}=useAllCollectionsInheritChainGetter();if(e===0||e===3)return t().filter(n=>isSameCollection(n.collection,r));if(e===1||e===2)return t().filter(n=>{var a,l;return o["x-uid"]!==n.uid&&(isSameCollection(n.collection,r)||((a=getSupportFieldsByAssociation(i(r.name,r.dataSource),n))==null?void 0:a.length)||((l=getSupportFieldsByForeignKey(r,n))==null?void 0:l.length))})},transformToFilter=(e,t,o,r)=>(e=(0,import_client.flatten)(e,{breakOn({value:i,path:n}){if(["$match","$notMatch","$anyOf","$noneOf","$childIn","$childNotIn","$dateBetween","$in","$notIn"].includes(t[n]))return!0;const a=o(`${r}.${n}`);if(a!=null&&a.target){if(Array.isArray(i))return!0;const l=a.targetKey||"id";if(i&&i[l]!=null)return!0}return!1}}),{$and:Object.keys(e).map(i=>{let n=import_lodash.default.get(e,i);const a=o(`${r}.${i}`);return a!=null&&a.target&&["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(a.type)&&(n=(0,import_client.getValuesByPath)(n,a.targetKey||"id"),i=`${i}.${a.targetKey||"id"}`,(a==null?void 0:a.interface)==="chinaRegion"&&(n=import_lodash.default.last(n))),!n&&n!==0&&n!==!1?null:{[i]:{[t[i]||"$eq"]:n}}}).filter(Boolean)}),useAssociatedFields=()=>{var e;return((e=useCollection())==null?void 0:e.fields.filter(t=>isAssocField(t)))||[]},isAssocField=e=>["o2o","oho","obo","m2o","createdBy","updatedBy","o2m","m2m","linkTo","chinaRegion","mbm"].includes(e==null?void 0:e.interface),isSameCollection=(e,t)=>e.name===t.name&&e.dataSource===t.dataSource,useFilterAPI=()=>{const e=(0,import_react.useFieldSchema)(),{getDataBlocks:t}=useFilterBlock(),{targets:o,uid:r}=findFilterTargets(e),i=t(),[n,a]=(0,import_react2.useState)(()=>o&&o.some(u=>i.some(m=>m.uid===u.uid))),l=Object.keys(o||{});(0,import_react2.useEffect)(()=>{a(o&&o.some(u=>i.some(m=>m.uid===u.uid)))},[l.length,o,i]);const c=(0,import_react2.useCallback)((u,m="id",d="$eq")=>{i.forEach(p=>{var g,h,f;const _=o.find(b=>b.uid===p.uid);if(!_)return;import_lodash.default.isFunction(m)&&(m=m(_)),import_lodash.default.isFunction(d)&&(d=d(_));const v=((g=p.service.params)==null?void 0:g[0])||{},S=((f=(h=p.service.params)==null?void 0:h[1])==null?void 0:f.filters)||{};u!==void 0?S[r]={$and:[{[m]:{[d]:u}}]}:delete S[r];const C=mergeFilter([...Object.values(S).map(b=>removeNullCondition(b)),p.defaultFilter]);p.doFilter(P(x({},v),{page:1,filter:C}),{filters:S})})},[i,o,r]);return{isConnected:n,doFilter:c}},isInFilterFormBlock=e=>{for(;e;){if(e["x-filter-targets"])return e["x-decorator"]==="FilterFormBlockProvider";e=e.parent}return!1},FilterContext$2=(0,import_react2.createContext)(null);FilterContext$2.displayName="FilterContext";const FilterBlockProvider=import_react2.default.memo(({children:e})=>{const t=import_react2.default.useRef([]),o=(0,import_react2.useCallback)(n=>{typeof n=="function"?t.current=n(t.current):t.current=n},[]),r=(0,import_react2.useCallback)(()=>t.current,[]),i=(0,import_react2.useMemo)(()=>({getDataBlocks:r,setDataBlocks:o}),[r,o]);return(0,import_jsx_runtime.jsx)(FilterContext$2.Provider,{value:i,children:e})});FilterBlockProvider.displayName="FilterBlockProvider";const DataBlockCollector=({children:e,params:t})=>{var o;const r=useCollection(),{recordDataBlocks:i}=useFilterBlock(),{getDataBlockRequest:n}=useDataBlockRequestGetter(),a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)(),c=useAssociatedFields(),u=(0,import_react2.useRef)(null),m=useDataLoadingMode(),d=a&&a.decoratorType!=="FilterFormBlockProvider"&&a.decoratorType!=="FormBlockProvider"&&a.decoratorProps.blockType!=="filter",p=(0,import_react2.useCallback)(()=>{const g=n();i({uid:l["x-uid"],title:a.componentProps.title,doFilter:g.runAsync,collection:r,associatedFields:c,foreignKeyFields:r==null?void 0:r.getFields("isForeignKey"),defaultFilter:(t==null?void 0:t.filter)||{},service:g,dom:u.current,dataLoadingMode:m,clearFilter(h){var f,_,v;const S=((f=this.service.params)==null?void 0:f[0])||{},C=((v=(_=this.service.params)==null?void 0:_[1])==null?void 0:v.filters)||{};delete C[h];const b=mergeFilter([...Object.values(C).map(y=>removeNullCondition(y)),(t==null?void 0:t.filter)||{}]);this.service.run(P(x({},S),{page:1,filter:b}),{filters:C})},clearData(){this.service.mutate(void 0)}})},[c,r,m,(o=a==null?void 0:a.componentProps)==null?void 0:o.title,l,t==null?void 0:t.filter,i,n]);return(0,import_react2.useEffect)(()=>{d&&p()},[p,d]),(0,import_jsx_runtime.jsx)("div",{ref:u,children:e})},useFilterBlock=()=>{const e=import_react2.default.useContext(FilterContext$2),t=(0,import_react2.useCallback)(()=>(e==null?void 0:e.getDataBlocks())||[],[e]),o=(0,import_react2.useCallback)(i=>{const n=e==null?void 0:e.getDataBlocks().find(a=>a.uid===i.uid);if(n){Object.assign(n,i);return}e==null||e.setDataBlocks(a=>[...a,i])},[e]),r=(0,import_react2.useCallback)(i=>{e!=null&&e.getDataBlocks().every(n=>n.uid!==i)||e==null||e.setDataBlocks(n=>n.filter(a=>a.uid!==i))},[e]);return e?{recordDataBlocks:o,getDataBlocks:t,removeDataBlock:r,inProvider:!0}:{inProvider:!1,recordDataBlocks:import_lodash.default.noop,getDataBlocks:t,removeDataBlock:import_lodash.default.noop}},useLabelUiSchemaV2=()=>{const e=useCollectionManager();return(t,o)=>{if(!t)return;const r=e==null?void 0:e.getCollectionField(`${t}.${o}`);return r==null?void 0:r.uiSchema}},useLabelUiSchema$1=(e,t)=>{const o=useCollectionManager();if(!e)return;const r=o==null?void 0:o.getCollectionField(`${e}.${t}`);return r==null?void 0:r.uiSchema},getDatePickerLabels$1=e=>{const t=(0,import_client.getDefaultFormat)(e),o=(0,import_client.str2moment)(e.value,e),r=o&&o.isValid()?o.format(t):e.value;return(0,import_shared.isArr)(r)?r.join("~"):r},toArr$2=e=>e?Array.isArray(e)?e:[e]:[],getLabelFormatValue$1=(e,t,o=!1)=>{const r=e==null?void 0:e.enum;if(Array.isArray(r)&&t){const i=toArr$2(t).map(n=>{const a=r.find(l=>l.value===n);return o?import_react2.default.createElement(import_antd.Tag,{color:a==null?void 0:a.color},a==null?void 0:a.label):a==null?void 0:a.label});return o?i:i.join(", ")}switch(e==null?void 0:e["x-component"]){case"DatePicker":return getDatePickerLabels$1(P(x({},e==null?void 0:e["x-component-props"]),{value:t}));default:return t}},getTabFormatValue=(e,t,o)=>{const r=e==null?void 0:e.enum;if(Array.isArray(r)&&t)return toArr$2(t).map(i=>{const n=r.find(a=>a.value===i);return import_react2.default.createElement(import_antd.Tag,{color:o||(n==null?void 0:n.color)},n==null?void 0:n.label)});switch(e==null?void 0:e["x-component"]){case"DatePicker":return import_react2.default.createElement(import_antd.Tag,{color:o},getDatePickerLabels$1(P(x({},e==null?void 0:e["x-component-props"]),{value:t})));default:return import_react2.default.createElement(import_antd.Tag,{color:o},t)}};function flatData$2(e){const t=[];for(let o=0;o<e.length;o++){const r=e[o].children;Array.isArray(r)&&t.push(...flatData$2(r)),t.push(x({},e[o]))}return t}function isSubMode(e){var t,o;const r=((t=e["x-component-props"])==null?void 0:t.mode)||((o=e.componentProps)==null?void 0:o.mode);return["Nester","SubTable","PopoverNester"].includes(r)}const REGEX_OF_VARIABLE=/^\s*\{\{\s*([a-zA-Z0-9_$-.]+?)\s*\}\}\s*$/g,REGEX_OF_VARIABLE_IN_EXPRESSION=/\{\{\s*([a-zA-Z0-9_$-.]+?)\s*\}\}/g,isVariable=e=>!(typeof e!="string"||!e.match(REGEX_OF_VARIABLE)),getVariablesFromExpression=e=>e.match(REGEX_OF_VARIABLE_IN_EXPRESSION)||[],transformVariableValue=(e,t)=>{const{targetCollectionField:o}=t;return e==null||!o?e:o.interface==="chinaRegion"&&Array.isArray(e)?e.map(r=>(import_lodash.default.isObject(r),r=x({},r),Object.keys(r).forEach(i=>{import_lodash.default.isObjectLike(r[i])&&delete r[i]}),r)):["hasMany","belongsToMany"].includes(o.type)?Array.isArray(e)?e:[e]:(o.interface,e)},toStringByPicker=(e,t="date",o)=>{if(!import_dayjs.default.isDayjs(e))return e;if(o==="local"){const r=new Date().getTimezoneOffset();return(0,import_dayjs.default)(toStringByPicker(e,t,"gmt")).add(r,"minutes").toISOString()}return t==="year"?e.format("YYYY")+"-01-01T00:00:00.000Z":t==="month"?e.format("YYYY-MM")+"-01T00:00:00.000Z":t==="quarter"?e.startOf("quarter").format("YYYY-MM")+"-01T00:00:00.000Z":t==="week"?e.startOf("week").add(1,"day").format("YYYY-MM-DD")+"T00:00:00.000Z":e.format("YYYY-MM-DDTHH:mm:ss.SSS")+"Z"},toGmtByPicker=(e,t)=>!e||!import_dayjs.default.isDayjs(e)?e:toStringByPicker(e,t,"gmt"),toLocalByPicker=(e,t)=>!e||!import_dayjs.default.isDayjs(e)?e:toStringByPicker(e,t,"local"),moment2str=(e,t={})=>{const{showTime:o,gmt:r,picker:i="date",utc:n=!0}=t;if(!e)return e;if(!n){const a=o?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD";return e.format(a)}return o?r?(0,import_client.toGmt)(e):(0,import_client.toLocal)(e):typeof r=="boolean"&&r?toGmtByPicker(e,i):toLocalByPicker(e,i)},handleChangeOnFilter=(e,t,o)=>{const r=o?"YYYY-MM-DD HH:mm:ss":(0,import_client.getPickerFormat)(t);return e&&(0,import_dayjs.default)(e).format(r)},handleDateChangeOnForm=(e,t,o,r,i,n)=>{const a=i?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD";if(!e)return e;if(t)return(0,import_dayjs.default)(e).startOf(r).format("YYYY-MM-DD");if(o){if(n)return(0,import_client.toGmt)(e);if(r!=="date")return(0,import_dayjs.default)(e).startOf(r).toISOString();const l=(0,import_dayjs.default)(e).format(a);return(0,import_dayjs.default)(l).toISOString()}return i?(0,import_dayjs.default)(e).format(a):(0,import_dayjs.default)(e).startOf(r).format(a)},mapDatePicker=function(){const e=isMobile();return t=>{const{dateOnly:o,showTime:r,picker:i="date",utc:n,gmt:a,underFilter:l}=t,c=(0,import_client.getDefaultFormat)(t),u=t.onChange;return P(x({},t),{inputReadOnly:e,format:c,value:(0,import_client.str2moment)(t.value,t),onChange:(m,d)=>{u&&u(l?handleChangeOnFilter(m,i,r):handleDateChangeOnForm(m,o,n,i,r,a))}})}};function isMobile(){return window.matchMedia("(max-width: 768px)").matches}const mapRangePicker=function(){const e=isMobile();return t=>{const o=(0,import_client.getDefaultFormat)(t),r=t.onChange,{dateOnly:i,showTime:n,picker:a="date",utc:l,gmt:c,underFilter:u}=t;return P(x({},t),{format:o,value:(0,import_client.str2moment)(t.value,t),inputReadOnly:e,onChange:m=>{r&&r(u?m?[handleChangeOnFilter(m[0],a,n),handleChangeOnFilter(m[1],a,n)]:[]:m?[moment2str(getRangeStart(m[0],t),t),moment2str(getRangeEnd(m[1],t),t)]:[])}})}};function getRangeStart(e,t){const{showTime:o}=t;return o?e:e.startOf("day")}function getRangeEnd(e,t){const{showTime:o}=t;return o?e:e.endOf("day")}const getStart=(e,t)=>(0,import_dayjs.default)().add(e,t==="isoWeek"?"week":t).startOf(t),getEnd=(e,t)=>(0,import_dayjs.default)().add(e,t==="isoWeek"?"week":t).endOf(t),getDateRanges=e=>{if(e!=null&&e.shouldBeString){const t=o=>Array.isArray(o)?o.map(r=>moment2str(r,{utc:e==null?void 0:e.utc})):moment2str(o,{utc:e==null?void 0:e.utc});return{now:()=>t((0,import_dayjs.default)()),today:o=>withParams(t([getStart(0,"day"),getEnd(0,"day")]),o),yesterday:o=>withParams(t([getStart(-1,"day"),getEnd(-1,"day")]),o),tomorrow:o=>withParams(t([getStart(1,"day"),getEnd(1,"day")]),o),thisWeek:o=>withParams(t([getStart(0,"isoWeek"),getEnd(0,"isoWeek")]),o),lastWeek:o=>withParams(t([getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")]),o),nextWeek:o=>withParams(t([getStart(1,"isoWeek"),getEnd(1,"isoWeek")]),o),thisIsoWeek:o=>withParams(t([getStart(0,"isoWeek"),getEnd(0,"isoWeek")]),o),lastIsoWeek:o=>withParams(t([getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")]),o),nextIsoWeek:o=>withParams(t([getStart(1,"isoWeek"),getEnd(1,"isoWeek")]),o),thisMonth:o=>withParams(t([getStart(0,"month"),getEnd(0,"month")]),o),lastMonth:o=>withParams(t([getStart(-1,"month"),getEnd(-1,"month")]),o),nextMonth:o=>withParams(t([getStart(1,"month"),getEnd(1,"month")]),o),thisQuarter:o=>withParams(t([getStart(0,"quarter"),getEnd(0,"quarter")]),o),lastQuarter:o=>withParams(t([getStart(-1,"quarter"),getEnd(-1,"quarter")]),o),nextQuarter:o=>withParams(t([getStart(1,"quarter"),getEnd(1,"quarter")]),o),thisYear:o=>withParams(t([getStart(0,"year"),getEnd(0,"year")]),o),lastYear:o=>withParams(t([getStart(-1,"year"),getEnd(-1,"year")]),o),nextYear:o=>withParams(t([getStart(1,"year"),getEnd(1,"year")]),o),last7Days:o=>withParams(t([getStart(-6,"days"),getEnd(0,"days")]),o),next7Days:o=>withParams(t([getStart(1,"day"),getEnd(7,"days")]),o),last30Days:o=>withParams(t([getStart(-29,"days"),getEnd(0,"days")]),o),next30Days:o=>withParams(t([getStart(1,"day"),getEnd(30,"days")]),o),last90Days:o=>withParams(t([getStart(-89,"days"),getEnd(0,"days")]),o),next90Days:o=>withParams(t([getStart(1,"day"),getEnd(90,"days")]),o)}}return{now:()=>(0,import_dayjs.default)().toISOString(),today:t=>withParams([getStart(0,"day"),getEnd(0,"day")],t),yesterday:t=>withParams([getStart(-1,"day"),getEnd(-1,"day")],t),tomorrow:t=>withParams([getStart(1,"day"),getEnd(1,"day")],t),thisWeek:t=>withParams([getStart(0,"isoWeek"),getEnd(0,"isoWeek")],t),lastWeek:t=>withParams([getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],t),nextWeek:t=>withParams([getStart(1,"isoWeek"),getEnd(1,"isoWeek")],t),thisIsoWeek:t=>withParams([getStart(0,"isoWeek"),getEnd(0,"isoWeek")],t),lastIsoWeek:t=>withParams([getStart(-1,"isoWeek"),getEnd(-1,"isoWeek")],t),nextIsoWeek:t=>withParams([getStart(1,"isoWeek"),getEnd(1,"isoWeek")],t),thisMonth:t=>withParams([getStart(0,"month"),getEnd(0,"month")],t),lastMonth:t=>withParams([getStart(-1,"month"),getEnd(-1,"month")],t),nextMonth:t=>withParams([getStart(1,"month"),getEnd(1,"month")],t),thisQuarter:t=>withParams([getStart(0,"quarter"),getEnd(0,"quarter")],t),lastQuarter:t=>withParams([getStart(-1,"quarter"),getEnd(-1,"quarter")],t),nextQuarter:t=>withParams([getStart(1,"quarter"),getEnd(1,"quarter")],t),thisYear:t=>withParams([getStart(0,"year"),getEnd(0,"year")],t),lastYear:t=>withParams([getStart(-1,"year"),getEnd(-1,"year")],t),nextYear:t=>withParams([getStart(1,"year"),getEnd(1,"year")],t),last7Days:t=>withParams([getStart(-6,"days"),getEnd(0,"days")],t),next7Days:t=>withParams([getStart(1,"day"),getEnd(7,"days")],t),last30Days:t=>withParams([getStart(-29,"days"),getEnd(0,"days")],t),next30Days:t=>withParams([getStart(1,"day"),getEnd(30,"days")],t),last90Days:t=>withParams([getStart(-89,"days"),getEnd(0,"days")],t),next90Days:t=>withParams([getStart(1,"day"),getEnd(90,"days")],t)}};function withParams(e,t){return t!=null&&t.isParsingVariable&&t!=null&&t.fieldOperator&&t.fieldOperator!=="$dateBetween"?e[0]:e}function inferPickerType(e){return/^\d{4}$/.test(e)?"year":/^\d{4}-\d{2}$/.test(e)?"month":/^\d{4}Q[1-4]$/.test(e)?"quarter":"date"}function getJsonLogic(){Array.isArray||(Array.isArray=function(i){return Object.prototype.toString.call(i)==="[object Array]"});function e(i){for(var n=[],a=0,l=i.length;a<l;a++)n.indexOf(i[a])===-1&&n.push(i[a]);return n}function t(i,n){return JSON.stringify(i)===JSON.stringify(n)}var o={},r={$is:function(i,n){return i===n},$match:function(i,n){return Array.isArray(i)&&Array.isArray(n)&&i.some(a=>Array.isArray(a))?i.some(a=>(a==null?void 0:a.length)===n.length&&(a==null?void 0:a.every((l,c)=>l===n[c]))):JSON.stringify(i)===JSON.stringify(n)},$eq:function(i,n){return Array.isArray(i)&&Array.isArray(n)?t(i,n):Array.isArray(i)?i.includes(n):i==n},$ne:function(i,n){return i!=n},"!==":function(i,n){return i!==n},$gt:function(i,n){return Array.isArray(i)?i.some(a=>a>n):i>n},$gte:function(i,n){return i>=n},$lt:function(i,n,a){return Array.isArray(i)?i.some(l=>l<n):a===void 0?i<n:i<n&&n<a},$lte:function(i,n,a){return a===void 0?i<=n:i<=n&&n<=a},$exists:function(i){return o.truthy(i)},$notEmpty:function(i){return o.truthy(i)},$empty:function(i){return Array.isArray(i)?i.some(n=>!o.truthy(n)):!o.truthy(i)},$notExists:function(i){return!o.truthy(i)},"%":function(i,n){return i%n},log:function(i){return i},$in:function(i,n){return!n||typeof n.indexOf>"u"?!1:Array.isArray(i)&&Array.isArray(n)?n.some(a=>i.includes(a)):n.indexOf(i)!==-1},$notIn:function(i,n){return!n||typeof n.indexOf>"u"?!1:n.indexOf(i)===-1},$includes:function(i,n){return!i||typeof i.indexOf>"u"?!1:Array.isArray(i)?i.some(a=>a==null?void 0:a.includes(n)):i.indexOf(n)!==-1},$notIncludes:function(i,n){return Array.isArray(i)?!i.some(a=>(a||"").includes(n)):(i=i||"",!i.includes(n))},$anyOf:function(i,n){return i.length===0?!1:Array.isArray(i)&&Array.isArray(n)&&i.some(a=>Array.isArray(a))?i.some(a=>a.some(l=>n.includes(l))):i.some(a=>n.includes(a))},$noneOf:function(i,n){return!i||(i==null?void 0:i.length)===0?!0:Array.isArray(i)&&Array.isArray(n)&&i.some(a=>Array.isArray(a))?i.some(a=>a.every(l=>!n.some(c=>l.includes(c)))):n.some(a=>!i.includes(a))},$notMatch:function(i,n){if(i.length!==n.length)return!0;for(let a=0;a<i.length;a++)if(i[a]!==n[a])return!0;return!1},$dateOn:function(i,n){return!i||!n?!1:i===n},$dateBefore:function(i,n){if(!i||!n)return!1;const a=parseDate(i),l=parseDate(n);if(!a||!l)throw new Error("Invalid date format");return a<l},$dateNotBefore:function(i,n){if(!i||!n)return!1;const a=parseDate(i),l=parseDate(n);if(!a||!l)throw new Error("Invalid date format");return a>=l},$dateAfter:function(i,n){if(!i||!n)return!1;const a=parseDate(i),l=parseDate(n);return a>l},$dateNotAfter:function(i,n){if(!i||!n)return!1;const a=parseDate(i),l=parseDate(n);if(!a||!l)throw new Error("Invalid date format");return a<=l},$dateBetween:function(i,n){if(!i||!n)return!1;const a=parseFullDate(i),l=parseFullDate(n[0]),c=parseFullDate(n[1]);if(!a||!l||!c)throw new Error("Invalid date format");return a>=l&&a<=c},$dateNotOn:function(i,n){return!i||!n?!1:i!==n},$isTruly:function(i){return Array.isArray(i)?i.some(n=>n===!0||n===1):i===!0||i===1},$isFalsy:function(i){return Array.isArray(i)?i.some(n=>!o.truthy(n)):!o.truthy(i)},cat:function(){return Array.prototype.join.call(arguments,"")},substr:function(i,n,a){if(a<0){var l=String(i).substr(n);return l.substr(0,l.length+a)}return String(i).substr(n,a)},"+":function(){return Array.prototype.reduce.call(arguments,function(i,n){return parseFloat(i,10)+parseFloat(n,10)},0)},"*":function(){return Array.prototype.reduce.call(arguments,function(i,n){return parseFloat(i,10)*parseFloat(n,10)})},"-":function(i,n){return n===void 0?-i:i-n},"/":function(i,n){return i/n},min:function(){return Math.min.apply(this,arguments)},max:function(){return Math.max.apply(this,arguments)},merge:function(){return Array.prototype.reduce.call(arguments,function(i,n){return i.concat(n)},[])},var:function(i,n){var a=n===void 0?null:n,l=this;if(typeof i>"u"||i===""||i===null)return l;for(var c=String(i).split("."),u=0;u<c.length;u++)if(l==null||(l=l[c[u]],l===void 0))return a;return l},missing:function(){for(var i=[],n=Array.isArray(arguments[0])?arguments[0]:arguments,a=0;a<n.length;a++){var l=n[a],c=o.apply({var:l},this);(c===null||c==="")&&i.push(l)}return i},missing_some:function(i,n){var a=o.apply({missing:n},this);return n.length-a.length>=i?[]:a}};return o.is_logic=function(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)&&Object.keys(i).length===1},o.truthy=function(i){return Array.isArray(i)&&i.length===0?!1:!!i},o.get_operator=function(i){return Object.keys(i)[0]},o.get_values=function(i){return i[o.get_operator(i)]},o.apply=function(i,n){if(Array.isArray(i))return i.map(function(f){return o.apply(f,n)});if(!o.is_logic(i))return i;var a=o.get_operator(i),l=i[a],c,u,m,d,p;if(Array.isArray(l)||(l=[l]),a==="if"||a=="?:"){for(c=0;c<l.length-1;c+=2)if(o.truthy(o.apply(l[c],n)))return o.apply(l[c+1],n);return l.length===c+1?o.apply(l[c],n):null}else if(a==="$and"){for(c=0;c<l.length;c+=1)if(u=o.apply(l[c],n),!o.truthy(u))return u;return u}else if(a==="or"){for(c=0;c<l.length;c+=1)if(u=o.apply(l[c],n),o.truthy(u))return u;return u}else{if(a==="filter")return d=o.apply(l[0],n),m=l[1],Array.isArray(d)?d.filter(function(f){return o.truthy(o.apply(m,f))}):[];if(a==="map")return d=o.apply(l[0],n),m=l[1],Array.isArray(d)?d.map(function(f){return o.apply(m,f)}):[];if(a==="reduce")return d=o.apply(l[0],n),m=l[1],p=typeof l[2]<"u"?l[2]:null,Array.isArray(d)?d.reduce(function(f,_){return o.apply(m,{current:_,accumulator:f})},p):p;if(a==="all"){if(d=o.apply(l[0],n),m=l[1],!Array.isArray(d)||!d.length)return!1;for(c=0;c<d.length;c+=1)if(!o.truthy(o.apply(m,d[c])))return!1;return!0}else if(a==="none"){if(d=o.apply(l[0],n),m=l[1],!Array.isArray(d)||!d.length)return!0;for(c=0;c<d.length;c+=1)if(o.truthy(o.apply(m,d[c])))return!1;return!0}else if(a==="some"){if(d=o.apply(l[0],n),m=l[1],!Array.isArray(d)||!d.length)return!1;for(c=0;c<d.length;c+=1)if(o.truthy(o.apply(m,d[c])))return!0;return!1}}if(l=l.map(function(f){return o.apply(f,n)}),r.hasOwnProperty(a)&&typeof r[a]=="function")return r[a].apply(n,l);if(a.indexOf(".")>0){var g=String(a).split("."),h=r;for(c=0;c<g.length;c++){if(!h.hasOwnProperty(g[c]))throw new Error("Unrecognized operation "+a+" (failed at "+g.slice(0,c+1).join(".")+")");h=h[g[c]]}return h.apply(n,l)}throw new Error("Unrecognized operation "+a)},o.uses_data=function(i){var n=[];if(o.is_logic(i)){var a=o.get_operator(i),l=i[a];Array.isArray(l)||(l=[l]),a==="var"?n.push(l[0]):l.forEach(function(c){n.push.apply(n,o.uses_data(c))})}return e(n)},o.add_operation=function(i,n){r[i]=n},o.rm_operation=function(i){delete r[i]},o.rule_like=function(i,n){if(n===i||n==="@")return!0;if(n==="number")return typeof i=="number";if(n==="string")return typeof i=="string";if(n==="array")return Array.isArray(i)&&!o.is_logic(i);if(o.is_logic(n)){if(o.is_logic(i)){var a=o.get_operator(n),l=o.get_operator(i);if(a==="@"||a===l)return o.rule_like(o.get_values(i,!1),o.get_values(n,!1))}return!1}if(Array.isArray(n))if(Array.isArray(i)){if(n.length!==i.length)return!1;for(var c=0;c<n.length;c+=1)if(!o.rule_like(i[c],n[c]))return!1;return!0}else return!1;return!1},o}function parseFullDate(e){return new Date(e)}function parseMonth(e){const[t,o]=e.split("-").map(Number);return new Date(t,o-1)}function parseQuarter(e){const t=parseInt(e.slice(0,4)),o=(parseInt(e.slice(5,6))-1)*3;return new Date(t,o)}function parseYear(e){const t=parseInt(e);return new Date(t,0)}function parseDate(e){let t=Array.isArray(e)?e[1]:e;return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(t)?new Date(t):/^\d{4}-\d{2}-\d{2}$/.test(t)?parseFullDate(t):/^\d{4}-\d{2}$/.test(t)?parseMonth(t):/^\d{4}Q[1-4]$/.test(t)?parseQuarter(t):/^\d{4}$/.test(t)?parseYear(t):null}const parseVariables=(e,t)=>{var o;const r=/{{(.*?)}}/,i=(o=e==null?void 0:e.match)==null?void 0:o.call(e,r);if(i){const n=import_lodash.default.get(t,i[1]);return import_lodash.default.isFunction(n)?n():n}else return e};function getInnermostKeyAndValue(e){if(typeof e!="object"||e===null)return null;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return Object.prototype.toString.call(e[t])==="[object Object]"&&e[t]!==null?getInnermostKeyAndValue(e[t]):{key:t,value:e[t]};return null}const getTargetField$1=e=>{const t=getAllKeys(e),o=(0,import_lodash.findIndex)(t,(r,i,n)=>{if(r.includes("$")&&i>0)return!0});return t.slice(0,o)};function getAllKeys(e){const t=[];function o(r){Object.keys(r).sort().forEach(function(i){t.push(i),r[i]&&typeof r[i]=="object"&&o(r[i])})}return o(e),t}const conditionAnalyses=e=>q(void 0,[e],function*({ruleGroup:t,variables:o,localVariables:r,variableNameOfLeftCondition:i}){const n=Object.keys(t)[0]||"$and";let a=t[n].map(l=>q(void 0,null,function*(){if("$and"in l||"$or"in l)return yield conditionAnalyses({ruleGroup:l,variables:o,localVariables:r});const c=getInnermostKeyAndValue(l),u=c==null?void 0:c.key;if(!u)return!0;const m=targetFieldToVariableString(getTargetField$1(l),i),d=o.parseVariable(m,r,{doNotRequest:!0}).then(({value:g})=>g),p=isVariable(c==null?void 0:c.value)?[o.parseVariable(c==null?void 0:c.value,r).then(({value:g})=>g),d]:[c==null?void 0:c.value,d];try{const g=getJsonLogic(),[h,f]=yield Promise.all(p),_=yield o.getCollectionField(m,r);let v=transformVariableValue(f,{targetCollectionField:_});const S=transformVariableValue(h,{targetCollectionField:_});if(_!=null&&_.type&&["datetime","date","datetimeNoTz","dateOnly","unixTimestamp"].includes(_.type)&&v){const C=inferPickerType(S),b=(0,import_client.getPickerFormat)(C);v=(0,import_client.dayjs)(v).format(b)}return g.apply({[u]:[v,S]})}catch(g){throw g}}));return a=yield Promise.all(a),n==="$and"?(0,import_lodash.every)(a,l=>l):(0,import_lodash.some)(a,l=>l)});function targetFieldToVariableString(e,t="$nForm"){return`{{ ${t}.${e.join(".")} }}`}const getVariablesData=e=>{const t={};return e.map(o=>{t[o.name]=o.ctx}),t};function getRenderContent(e,t,o,r,i){return q(this,null,function*(){var n,a;if(t&&e==="handlebars")try{const l=import_client.Handlebars.compile(t),c=getVariablesData(r),{$nDate:u}=((n=o==null?void 0:o.ctxRef)==null?void 0:n.current)||{},m={};Object.keys(u||{}).map(p=>{m[p]=u[p]()});const d=l(P(x(x({},(a=o==null?void 0:o.ctxRef)==null?void 0:a.current),c),{$nDate:m}));return yield i(d)}catch(l){return console.log(l),t}else try{const l=yield replaceVariableValue(t,o,r);return yield i(l)}catch(l){return console.log(l),t}})}const getPath=e=>e&&e.match(REGEX_OF_VARIABLE)[0].replace(REGEX_OF_VARIABLE,"$1"),getVariableName=e=>import_lodash.default.isString(e)?getPath(e).split(".")[0]:e;var ActionType=(e=>(e.Visible="visible",e.Editable="editable",e.ReadOnly="disabled",e.ReadPretty="readPretty",e.None="none",e.Hidden="hidden",e.Required="required",e.InRequired="notRequired",e.Disabled="disabled",e.Value="value",e.Active="enabled",e.Color="color",e.BackgroundColor="backgroundColor",e.TextAlign="textAlign",e))(ActionType||{}),LinkageRuleCategory=(e=>(e.default="default",e.style="style",e))(LinkageRuleCategory||{});const LinkageRuleDataKeyMap={style:"x-linkage-style-rules",default:"x-linkage-rules"};function bindLinkageRulesToFiled({field:e,linkageRules:t,formValues:o,localVariables:r,action:i,rule:n,variables:a,variableNameOfLeftCondition:l}){var c,u,m,d;return e.initStateOfLinkageRules={display:((c=e.initStateOfLinkageRules)==null?void 0:c.display)||getTempFieldState(!0,e.display),required:((u=e.initStateOfLinkageRules)==null?void 0:u.required)||getTempFieldState(!0,e.required||!1),pattern:((m=e.initStateOfLinkageRules)==null?void 0:m.pattern)||getTempFieldState(!0,e.pattern),value:((d=e.initStateOfLinkageRules)==null?void 0:d.value)||getTempFieldState(!0,e.value||e.initialValue)},(0,import_reactive.reaction)(()=>{const p=getFieldValuesInCondition({linkageRules:t,formValues:o}),g=getVariableValuesInCondition({linkageRules:t,localVariables:r}),h=getVariableValuesInExpression({action:i,localVariables:r});return[p,g,h].map(f=>JSON.stringify(f)).join(",")},getSubscriber({action:i,field:e,rule:n,variables:a,localVariables:r,variableNameOfLeftCondition:l}),{fireImmediately:!0,equals:import_lodash.default.isEqual})}function getFieldValuesInCondition({linkageRules:e,formValues:t}){return e.map(o=>{const r=i=>{const n=Object.keys(i)[0]||"$and";return i[n].map(a=>{if("$and"in a||"$or"in a)return r(a);const l=getTargetField$1(a).join(".");return(0,import_client.getValuesByPath)(t,l)}).filter(Boolean)};return r(o.condition)})}function getVariableValuesInCondition({linkageRules:e,localVariables:t}){return e.map(o=>{const r=Object.keys(o.condition)[0]||"$and";return o.condition[r].map(i=>{const n=getInnermostKeyAndValue(i);return n?isVariable(n.value)?getVariableValue(n.value,t):n.value:null}).filter(Boolean)})}function getVariableValuesInExpression({action:e,localVariables:t}){var o;const r=e.value,i=r==null?void 0:r.mode,n=(r==null?void 0:r.value)||(r==null?void 0:r.result);if(i==="express"&&n!=null)return(o=getVariablesFromExpression(n))==null?void 0:o.map(a=>getVariableValue(a,t)).filter(Boolean)}function getVariableValue(e,t){var o;if(!isVariable(e))return;const r=getVariableName(e),i={[r]:(o=t.find(n=>n.name===r))==null?void 0:o.ctx};return(0,import_client.getValuesByPath)(i,getPath(e))}function getSubscriber({action:e,field:t,rule:o,variables:r,localVariables:i,variableNameOfLeftCondition:n}){return()=>{collectFieldStateOfLinkageRules({operator:e.operator,value:e.value,field:t,condition:o.condition,variables:r,localVariables:i,variableNameOfLeftCondition:n}),setTimeout(()=>q(this,null,function*(){var a;const l=getFieldNameByOperator(e.operator);if(!((a=t.stateOfLinkageRules)!=null&&a[l]))return;let c=t.stateOfLinkageRules[l];c=yield Promise.all(c),c=c.filter(m=>m.condition);const u=c[c.length-1];l==="value"?c.length>1&&(t.value=u.value):(l==="display"&&(u==null?void 0:u.value)==="hidden"?(t.display="visible",t.data=t.data||{},t.data.hidden=!0,requestAnimationFrame(()=>{t.setState(m=>{m.display="visible"})})):(t[l]=u==null?void 0:u.value,t.data=t.data||{},t.data.hidden=!1,requestAnimationFrame(()=>{t.setState(m=>{m[l]=u==null?void 0:u.value})})),l==="display"&&(u==null?void 0:u.value)==="none"&&(t.value=null)),t.stateOfLinkageRules[l]=null}))}}function getFieldNameByOperator(e){switch(e){case ActionType.Required:case ActionType.InRequired:return"required";case ActionType.Visible:case ActionType.None:case ActionType.Hidden:return"display";case ActionType.Editable:case ActionType.ReadOnly:case ActionType.ReadPretty:return"pattern";case ActionType.Value:return"value";default:return null}}const collectFieldStateOfLinkageRules=({operator:e,value:t,field:o,condition:r,variables:i,localVariables:n,variableNameOfLeftCondition:a})=>{var l,c,u,m,d,p,g,h;const f=((l=o==null?void 0:o.stateOfLinkageRules)==null?void 0:l.required)||[(c=o==null?void 0:o.initStateOfLinkageRules)==null?void 0:c.required],_=((u=o==null?void 0:o.stateOfLinkageRules)==null?void 0:u.display)||[(m=o==null?void 0:o.initStateOfLinkageRules)==null?void 0:m.display],v=((d=o==null?void 0:o.stateOfLinkageRules)==null?void 0:d.pattern)||[(p=o==null?void 0:o.initStateOfLinkageRules)==null?void 0:p.pattern],S=((g=o==null?void 0:o.stateOfLinkageRules)==null?void 0:g.value)||[(h=o==null?void 0:o.initStateOfLinkageRules)==null?void 0:h.value],{evaluate:C}=import_client2.evaluators.get("formula.js"),b={ruleGroup:r,variables:i,localVariables:n,variableNameOfLeftCondition:a};switch(e){case ActionType.Required:f.push(getTempFieldState(conditionAnalyses(b),!0)),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{required:f});break;case ActionType.InRequired:f.push(getTempFieldState(conditionAnalyses(b),!1)),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{required:f});break;case ActionType.Visible:case ActionType.None:case ActionType.Hidden:_.push(getTempFieldState(conditionAnalyses(b),e)),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{display:_});break;case ActionType.Editable:case ActionType.ReadOnly:case ActionType.ReadPretty:v.push(getTempFieldState(conditionAnalyses(b),e)),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{pattern:v});break;case ActionType.Value:{const y=()=>q(void 0,null,function*(){var F;if((t==null?void 0:t.mode)==="express"){if((t.value||t.result)==null)return;const{exp:j,scope:k}=yield replaceVariables(t.value||t.result,{variables:i,localVariables:n});try{return C(j,x({now:()=>new Date().toString()},k))}catch(T){console.error(T)}}else return(t==null?void 0:t.mode)==="constant"?(F=t==null?void 0:t.value)!=null?F:t:null});isConditionEmpty(r)?S.push(getTempFieldState(!0,y())):S.push(getTempFieldState(conditionAnalyses(b),y())),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{value:S})}break;default:return null}};function getTempFieldState(e,t){return q(this,null,function*(){return[e,t]=yield Promise.all([e,t]),{condition:e,value:t}})}function isConditionEmpty(e){const t=Object.keys(e)[0]||"$and",o=e[t];return import_lodash.default.isEmpty(o)}function replaceVariables(e,t){return q(this,arguments,function*(o,{variables:r,localVariables:i}){var n;const a={},l={};if(o==null)return;const c=(n=o.match(REGEX_OF_VARIABLE_IN_EXPRESSION))==null?void 0:n.map(u=>q(this,null,function*(){const{value:m}=yield r.parseVariable(u,i),d=`_${(0,import_client.uid)()}`;return l[d]=m,a[u]=d,m}));return c&&(yield Promise.all(c)),{exp:o.replace(REGEX_OF_VARIABLE_IN_EXPRESSION,u=>`{{${a[u]||u}}}`),scope:l}})}const useCloseAction$3=()=>{const{setVisible:e}=useActionContext(),t=(0,import_react.useForm)();return{run(){return q(this,null,function*(){e(!1),t.submit(o=>{console.log(o)})})}}},useSaveCurrentUserValues$1=()=>{const e=(0,import_react_router_dom.useNavigate)(),{setVisible:t}=useActionContext(),o=(0,import_react.useForm)(),r=useAPIClient();return{run(){return q(this,null,function*(){yield o.submit(),yield r.resource("auth").changePassword({values:o.values}),yield o.reset(),t(!1),e("/signin")})}}},schema$4={type:"object",properties:{[(0,import_shared.uid)()]:{"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{zIndex:1e4},type:"void",title:'{{t("Change password")}}',properties:{oldPassword:{type:"string",title:'{{t("Old password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem"},newPassword:{type:"string",title:'{{t("New password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirmPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirmPassword:{type:"string",required:!0,title:'{{t("Confirm password")}}',"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".newPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},footer:{"x-component":"Action.Drawer.Footer",type:"void",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ useCloseAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSaveCurrentUserValues }}"}}}}}}}},useChangePassword=()=>{const e=(0,import_react2.useContext)(DropdownVisibleContext),[t,o]=(0,import_react2.useState)(!1),{t:r}=(0,import_react_i18next.useTranslation)(),{data:i}=useSystemSettings()||{},{enableChangePassword:n}=(i==null?void 0:i.data)||{},a=(0,import_react2.useMemo)(()=>({key:"password",eventKey:"ChangePassword",onClick:()=>{o(!0),e==null||e.setVisible(!1)},label:(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[r("Change password"),(0,import_jsx_runtime.jsx)(ActionContextProvider,{value:{visible:t,setVisible:o},children:(0,import_jsx_runtime.jsx)("div",{onClick:l=>l.stopPropagation(),children:(0,import_jsx_runtime.jsx)(SchemaComponent,{scope:{useCloseAction:useCloseAction$3,useSaveCurrentUserValues:useSaveCurrentUserValues$1},schema:schema$4})})})]})}),[t]);return n===!1?null:a},CurrentUserSettingsMenuContext=(0,import_react2.createContext)(null);CurrentUserSettingsMenuContext.displayName="CurrentUserSettingsMenuContext";const useCurrentUserSettingsMenu=()=>{const{menuItems:e}=(0,import_react2.useContext)(CurrentUserSettingsMenuContext)||{},t=(0,import_react2.useCallback)(()=>e.current,[e]),o=(0,import_react2.useCallback)((r,i)=>{let n;if(i&&(r._options=i),(n=e.current.findIndex(l=>l.key===r.key))!==-1){e.current[n]=r,e.current=[...e.current];return}if(i){if(i.before){const l=e.current.findIndex(c=>c.key===i.before);e.current.splice(l,0,r);return}if(i.after){const l=e.current.findIndex(c=>c.key===i.after);e.current.splice(l+1,0,r);return}}const a=e.current;e.current=a.filter(l=>{var c,u;return r.key!==((c=l._options)==null?void 0:c.before)&&r.key!==((u=l._options)==null?void 0:u.after)}),e.current.push(...a.filter(l=>{var c;return((c=l._options)==null?void 0:c.before)===r.key})),e.current.push(r),e.current.push(...a.filter(l=>{var c;return((c=l._options)==null?void 0:c.after)===r.key}))},[e]);if(!e)throw(0,import_client.error)("CurrentUser: You should use `CurrentUserSettingsMenuProvider` in the root of your app."),new Error("CurrentUser: You should use `CurrentUserSettingsMenuProvider` in the root of your app.");return{getMenuItems:t,addMenuItem:o}},CurrentUserSettingsMenuProvider=({children:e})=>{const t=(0,import_react2.useRef)([]),o=(0,import_react2.useMemo)(()=>({menuItems:t}),[t]);return(0,import_jsx_runtime.jsx)(CurrentUserSettingsMenuContext.Provider,{value:o,children:e})},useCloseAction$2=()=>{const{setVisible:e}=useActionContext(),t=(0,import_react.useForm)();return{run(){return q(this,null,function*(){e(!1),t.submit(o=>{console.log(o)})})}}},useCurrentUserValues=e=>{const t=useCurrentUserContext();return useRequest(()=>Promise.resolve(t.data),e)},useSaveCurrentUserValues=()=>{const e=useCurrentUserContext(),{setVisible:t}=useActionContext(),o=(0,import_react.useForm)(),r=useAPIClient();return{run(){return q(this,null,function*(){var i;const n=yield o.submit();t(!1),yield r.resource("users").updateProfile({values:n}),e.mutate({data:x(x({},(i=e==null?void 0:e.data)==null?void 0:i.data),n)})})}}},schema$3={type:"object",properties:{[(0,import_shared.uid)()]:{"x-decorator":"Form","x-decorator-props":{useValues:"{{ useCurrentUserValues }}"},"x-component":"Action.Drawer","x-component-props":{zIndex:1e4},type:"void",title:'{{t("Edit profile")}}',properties:{nickname:{type:"string",title:"{{t('Nickname')}}","x-decorator":"FormItem","x-component":"Input","x-disabled":"{{ enableEditProfile === false }}"},username:{type:"string",title:'{{t("Username")}}',"x-decorator":"FormItem","x-component":"Input","x-validator":{username:!0},required:!0,"x-disabled":"{{ enableEditProfile === false }}"},email:{type:"string",title:'{{t("Email")}}',"x-decorator":"FormItem","x-component":"Input","x-validator":"email","x-disabled":"{{ enableEditProfile === false }}"},phone:{type:"string",title:'{{t("Phone")}}',"x-decorator":"FormItem","x-component":"Input","x-disabled":"{{ enableEditProfile === false }}"},footer:{"x-component":"Action.Drawer.Footer",type:"void",properties:{cancel:{title:"Cancel","x-component":"Action","x-component-props":{useAction:"{{ useCloseAction }}"}},submit:{title:"Submit","x-component":"Action","x-disabled":"{{ enableEditProfile === false }}","x-component-props":{type:"primary",useAction:"{{ useSaveCurrentUserValues }}"}}}}}}}},useEditProfile=()=>{const e=(0,import_react2.useContext)(DropdownVisibleContext),[t,o]=(0,import_react2.useState)(!1),{t:r}=(0,import_react_i18next.useTranslation)(),{data:i}=useSystemSettings()||{},{enableEditProfile:n}=(i==null?void 0:i.data)||{},a=(0,import_react2.useMemo)(()=>({key:"profile",eventKey:"EditProfile",onClick:()=>{o(!0),e==null||e.setVisible(!1)},label:(0,import_jsx_runtime.jsxs)("div",{children:[r("Edit profile"),(0,import_jsx_runtime.jsx)(ActionContextProvider,{value:{visible:t,setVisible:o},children:(0,import_jsx_runtime.jsx)("div",{onClick:l=>l.stopPropagation(),children:(0,import_jsx_runtime.jsx)(SchemaComponent,{scope:{useCurrentUserValues,useCloseAction:useCloseAction$2,useSaveCurrentUserValues,enableEditProfile:n},schema:schema$3})})})]})}),[t]);return n===!1?null:a},dayjsLocale={"ar-EG":"ar","az-AZ":"az","bg-BG":"bg","bn-BD":"bn-bd","by-BY":"en","ca-ES":"ca","cs-CZ":"cs","da-DK":"da","de-DE":"de","el-GR":"el","en-GB":"en-gb","en-US":"en","es-ES":"es","et-EE":"et","fa-IR":"fa","fi-FI":"fi","fr-BE":"fr","fr-CA":"fr","fr-FR":"fr","ga-IE":"ga","gl-ES":"gl","he-IL":"he","hi-IN":"hi","hr-HR":"hr","hu-HU":"hu","hy-AM":"hy-am","id-ID":"id","is-IS":"is","it-IT":"it","ja-JP":"ja","ka-GE":"ka","kk-KZ":"kk","km-KH":"km","kn-IN":"kn","ko-KR":"ko","ku-IQ":"ku","lt-LT":"lt","lv-LV":"lv","mk-MK":"mk","ml-IN":"ml","mn-MN":"mn","ms-MY":"ms","nb-NO":"nb","ne-NP":"ne","nl-BE":"nl-be","nl-NL":"nl","pl-PL":"pl","pt-BR":"pt-br","pt-PT":"pt","ro-RO":"ro","ru-RU":"ru","si-LK":"si","sk-SK":"sk","sl-SI":"sl","sr-RS":"sr","sv-SE":"sv","ta-IN":"ta","th-TH":"th","tk-TK":"tk","tr-TR":"tr","uk-UA":"uk","ur-PK":"ur","vi-VN":"vi","zh-CN":"zh-cn","zh-HK":"zh-hk","zh-TW":"zh-tw"},languageCodes={"ar-EG":{label:"العربية"},"az-AZ":{label:"Azərbaycan dili"},"bg-BG":{label:"Български"},"bn-BD":{label:"Bengali"},"by-BY":{label:"Беларускі"},"ca-ES":{label:"Сatalà/Espanya"},"cs-CZ":{label:"Česky"},"da-DK":{label:"Dansk"},"de-DE":{label:"Deutsch"},"el-GR":{label:"Ελληνικά"},"en-GB":{label:"English(GB)"},"en-US":{label:"English"},"es-ES":{label:"Español"},"et-EE":{label:"Estonian (Eesti)"},"fa-IR":{label:"فارسی"},"fi-FI":{label:"Suomi"},"fr-BE":{label:"Français(BE)"},"fr-CA":{label:"Français(CA)"},"fr-FR":{label:"Français"},"ga-IE":{label:"Gaeilge"},"gl-ES":{label:"Galego"},"he-IL":{label:"עברית"},"hi-IN":{label:"हिन्दी"},"hr-HR":{label:"Hrvatski jezik"},"hu-HU":{label:"Magyar"},"hy-AM":{label:"Հայերեն"},"id-ID":{label:"Bahasa Indonesia"},"is-IS":{label:"Íslenska"},"it-IT":{label:"Italiano"},"ja-JP":{label:"日本語"},"ka-GE":{label:"ქართული"},"kk-KZ":{label:"Қазақ тілі"},"km-KH":{label:"ភាសាខ្មែរ"},"kn-IN":{label:"ಕನ್ನಡ"},"ko-KR":{label:"한국어"},"ku-IQ":{label:"کوردی"},"lt-LT":{label:"lietuvių"},"lv-LV":{label:"Latviešu valoda"},"mk-MK":{label:"македонски јазик"},"ml-IN":{label:"മലയാളം"},"mn-MN":{label:"Монгол хэл"},"ms-MY":{label:"بهاس ملايو"},"nb-NO":{label:"Norsk bokmål"},"ne-NP":{label:"नेपाली"},"nl-BE":{label:"Vlaams"},"nl-NL":{label:"Nederlands"},"pl-PL":{label:"Polski"},"pt-BR":{label:"Português brasileiro"},"pt-PT":{label:"Português"},"ro-RO":{label:"România"},"ru-RU":{label:"Русский"},"si-LK":{label:"සිංහල"},"sk-SK":{label:"Slovenčina"},"sl-SI":{label:"Slovenščina"},"sr-RS":{label:"српски језик"},"sv-SE":{label:"Svenska"},"ta-IN":{label:"Tamil"},"th-TH":{label:"ภาษาไทย"},"tk-TK":{label:"Turkmen"},"tr-TR":{label:"Türkçe"},"uk-UA":{label:"Українська"},"ur-PK":{label:"Oʻzbekcha"},"vi-VN":{label:"Tiếng Việt"},"zh-CN":{label:"简体中文"},"zh-HK":{label:"繁體中文(香港)"},"zh-TW":{label:"繁體中文(台湾)"}},useLanguageSettings=()=>{var e;const{t,i18n:o}=(0,import_react_i18next.useTranslation)(),r=useAPIClient(),{data:i}=useSystemSettings()||{},n=(0,import_react2.useMemo)(()=>{var l;return((l=i==null?void 0:i.data)==null?void 0:l.enabledLanguages)||[]},[(e=i==null?void 0:i.data)==null?void 0:e.enabledLanguages]),a=(0,import_react2.useMemo)(()=>({key:"language",eventKey:"LanguageSettings",label:(0,import_jsx_runtime.jsx)(SelectWithTitle,{title:t("Language"),options:Object.keys(languageCodes).filter(l=>n.includes(l)).map(l=>({label:languageCodes[l].label,value:l})),defaultValue:o.language,onChange:l=>q(void 0,null,function*(){yield r.resource("users").updateLang({values:{appLang:l}}),r.auth.setLocale(l),window.location.reload()})})}),[r,n,o,t]);return n.length<2?null:a};function SelectWithTitle({title:e,defaultValue:t,onChange:o,options:r,fieldNames:i}){const[n,a]=(0,import_react2.useState)(!1),l=(0,import_react2.useRef)(null);return(0,import_jsx_runtime.jsxs)("div",{style:{alignItems:"center",display:"flex",justifyContent:"space-between"},onClick:c=>{c.stopPropagation(),a(u=>!u)},onMouseLeave:()=>{l.current=setTimeout(()=>{a(!1)},200)},children:[e,(0,import_jsx_runtime.jsx)(import_antd.Select,{open:n,"data-testid":`select-${e}`,popupMatchSelectWidth:!1,bordered:!1,defaultValue:t,onChange:o,popupClassName:`select-popup-${e.replaceAll(" ","-")}`,fieldNames:i,options:r,style:{textAlign:"right",minWidth:100},onMouseEnter:()=>{clearTimeout(l.current)}})]})}class SchemaSettings{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 r=t.split("."),i=P(x({},o),{name:r[r.length-1]});if(r.length===1){const l=this.items.findIndex(c=>c.name===t);l===-1?this.items.push(i):this.items[l]=i;return}const n=r.slice(0,-1).join("."),a=this.get(n);if(a){a.children||(a.children=[]);const l=t.replace(`${a.name}.`,""),c=a.children.findIndex(u=>u.name===l);c===-1?a.children.push(i):a.children[c]=i}}get(t){if(!t)return;const o=t.split(".");let r=this.items;for(let i=0;i<o.length;i++){const n=o[i];if(r=r.find(a=>a.name===n),!r||i===o.length-1)return r;if(r.children)r=r.children;else return}}remove(t){const o=t.split(".");if(o.length===1){const i=this.items.findIndex(n=>n.name===o[0]);i!==-1&&this.items.splice(i,1);return}const r=this.get(o.slice(0,-1).join("."));if(r&&r.children){const i=o[o.length-1],n=r.children.findIndex(a=>a.name===i);n!==-1&&r.children.splice(n,1)}}}class SchemaSettingsManager{constructor(t=[],o){A(this,"schemaSettings",{}),A(this,"actionList",{}),this._schemaSettings=t,this.app=o,this.app=o,this.add(...t)}add(...t){t.forEach(o=>{this.schemaSettings[o.name]=o,Array.isArray(this.actionList[o.name])&&(this.actionList[o.name].forEach(r=>{o[r.type](r.itemName,r.data)}),this.actionList[o.name]=void 0)})}addItem(t,o,r){const i=this.get(t);i?i.add(o,r):(this.actionList[t]||(this.actionList[t]=[]),this.actionList[t].push({type:"add",itemName:o,data:r}))}get(t){return this.schemaSettings[t]}getAll(){return this.schemaSettings}has(t){return!!this.get(t)}remove(t){delete this.schemaSettings[t]}removeItem(t,o){const r=this.get(t);r?r.remove(o):(this.actionList[t]||(this.actionList[t]=[]),this.actionList[t].push({type:"remove",itemName:o}))}}const defaultTheme={name:"",token:{colorPrimaryHeader:"#001529",colorBgHeader:"#001529",colorBgHeaderMenuHover:"#ffffff1a",colorBgHeaderMenuActive:"#ffffff1a",colorTextHeaderMenu:"#ffffffa6",colorTextHeaderMenuHover:"#ffffff",colorTextHeaderMenuActive:"#ffffff",colorSettings:"#F18B62",colorBgSettingsHover:"rgba(241, 139, 98, 0.06)",colorBorderSettingsHover:"rgba(241, 139, 98, 0.3)",motionUnit:.03,motion:!0}};function compatOldTheme(e){var t;return(t=e.token)!=null&&t.colorSettings||(e.token=x(x({},e.token),defaultTheme.token)),e}const customAlgorithm=(e,t)=>{const o=t||import_antd.theme.defaultAlgorithm(e);return o.paddingPageHorizontal===void 0&&(o.paddingPageHorizontal=o.sizeLG),o.paddingPageVertical===void 0&&(o.paddingPageVertical=o.sizeLG),o.paddingPopupHorizontal===void 0&&(o.paddingPopupHorizontal=o.sizeLG),o.paddingPopupVertical===void 0&&(o.paddingPopupVertical=o.size),o.marginBlock===void 0&&(o.marginBlock=o.sizeLG),o.borderRadiusBlock===void 0&&(o.borderRadiusBlock=o.borderRadiusLG),o},addCustomAlgorithmToTheme=e=>(Array.isArray(e.algorithm)?e.algorithm.includes(customAlgorithm)||e.algorithm.push(customAlgorithm):e.algorithm=[e.algorithm,customAlgorithm].filter(Boolean),e.algorithm=e.algorithm.filter(Boolean),e),AppInner=(0,import_react2.memo)(({children:e})=>{const t=useApp(),{notification:o}=import_antd.App.useApp(),r=useAPIClient();return(0,import_react2.useEffect)(()=>{r.notification=o,t.notification=o},[o]),(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e})});AppInner.displayName="AppInner";const AntdAppProvider=({children:e,className:t,style:o})=>(0,import_jsx_runtime.jsx)(import_antd.App,{className:t,style:x({height:"100%"},o),children:(0,import_jsx_runtime.jsx)(AppInner,{children:e})});AntdAppProvider.displayName="AntdAppProvider";const GlobalThemeContext=(0,import_react2.createContext)(null);GlobalThemeContext.displayName="GlobalThemeContext";const useGlobalTheme=()=>import_react2.default.useContext(GlobalThemeContext)||{theme:{},isDarkTheme:!1},GlobalThemeProvider=({children:e,theme:t})=>{const[o,r]=import_react2.default.useState(t||defaultTheme),i=(0,import_react2.useRef)(null),n=(0,import_react2.useRef)(null),a=(0,import_react2.useMemo)(()=>{const p=o==null?void 0:o.algorithm;return Array.isArray(p)?p.includes(import_antd.theme.darkAlgorithm):p===import_antd.theme.darkAlgorithm},[o==null?void 0:o.algorithm]),l=(0,import_react2.useCallback)(p=>{n.current=p&&import_lodash.default.cloneDeep(p)},[]),c=(0,import_react2.useCallback)(()=>n.current,[]),u=(0,import_react2.useCallback)(p=>{i.current=p&&import_lodash.default.cloneDeep(p)},[]),m=(0,import_react2.useCallback)(()=>i.current,[]),d=(0,import_react2.useMemo)(()=>({theme:addCustomAlgorithmToTheme(o),setTheme:r,setCurrentSettingTheme:u,getCurrentSettingTheme:m,setCurrentEditingTheme:l,getCurrentEditingTheme:c,isDarkTheme:a}),[c,m,a,l,u,o]);return(0,import_jsx_runtime.jsx)(GlobalThemeContext.Provider,{value:d,children:(0,import_jsx_runtime.jsx)(import_antd.ConfigProvider,{theme:compatOldTheme(d.theme),children:e})})},useToken$1=()=>import_antd.theme.useToken(),CSSVariableProvider=({children:e})=>{const{token:t}=useToken$1(),o=t.colorFillTertiary,r=new import_tinycolor.TinyColor(t.colorFill).onBackground(t.colorFillSecondary).toHexShortString(),i=new import_tinycolor.TinyColor(t.colorFill).onBackground(t.colorFill).toHexShortString(),n=new import_tinycolor.TinyColor(t.colorFill).onBackground(t.colorFill).onBackground(t.colorFill).toHexShortString();return(0,import_react2.useEffect)(()=>{document.body.style.setProperty("--nb-spacing",`${t.marginLG}px`),document.body.style.setProperty("--nb-designer-offset",`${t.marginXS}px`),document.body.style.setProperty("--nb-header-height",`${t.sizeXXL-2}px`),document.body.style.setProperty("--nb-box-bg",t.colorBgLayout),document.body.style.setProperty("--nb-box-bg",t.colorBgLayout),document.body.style.setProperty("--controlHeightLG",`${t.controlHeightLG}px`),document.body.style.setProperty("--paddingContentVerticalSM",`${t.paddingContentVerticalSM}px`),document.body.style.setProperty("--marginSM",`${t.marginSM}px`),document.body.style.setProperty("--colorInfoBg",t.colorInfoBg),document.body.style.setProperty("--colorInfoBorder",t.colorInfoBorder),document.body.style.setProperty("--colorWarningBg",t.colorWarningBg),document.body.style.setProperty("--colorWarningBorder",t.colorWarningBorder),document.body.style.setProperty("--colorText",t.colorText),document.body.style.setProperty("--colorPrimaryText",t.colorPrimaryText),document.body.style.setProperty("--colorPrimaryTextActive",t.colorPrimaryTextActive),document.body.style.setProperty("--colorPrimaryTextHover",t.colorPrimaryTextHover),document.body.style.setProperty("--colorBgScrollTrack",o),document.body.style.setProperty("--colorBgScrollBar",r),document.body.style.setProperty("--colorBgScrollBarHover",i),document.body.style.setProperty("--colorBgScrollBarActive",n),document.body.style.setProperty("--colorSettings",t.colorSettings||defaultTheme.token.colorSettings),document.body.style.setProperty("--colorBgSettingsHover",t.colorBgSettingsHover),document.body.style.setProperty("--colorBorderSettingsHover",t.colorBorderSettingsHover),document.body.style.setProperty("background-color",t.colorBgContainer)},[r,n,i,o,t.colorBgContainer,t.colorBgLayout,t.colorBgSettingsHover,t.colorBorderSettingsHover,t.colorInfoBg,t.colorInfoBorder,t.colorPrimaryText,t.colorPrimaryTextActive,t.colorPrimaryTextHover,t.colorSettings,t.colorText,t.colorWarningBg,t.colorWarningBorder,t.controlHeightLG,t.marginLG,t.marginSM,t.marginXS,t.paddingContentVerticalSM,t.sizeXXL]),e};CSSVariableProvider.displayName="CSSVariableProvider";function tval(e,t){return t?`{{t(${JSON.stringify(e)}, ${JSON.stringify(t)})}}`:`{{t(${JSON.stringify(e)})}}`}const i18n=import_i18next.default.createInstance();Object.keys(languageCodes).forEach(e=>{languageCodes[e].resources});i18n.use(import_react_i18next.initReactI18next).init({lng:"en-US",defaultNS:"client",resources:{},keySeparator:!1,nsSeparator:!1});function defineDevPlugins(e){Object.entries(e).forEach(([t,o])=>{window.define(`${t}/client`,()=>o)})}function definePluginClient(e){window.define(`${e}/client`,["exports",e],function(t,o){Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(o).forEach(function(r){r!=="__esModule"&&(r in t&&t[r]===o[r]||Object.defineProperty(t,r,{enumerable:!0,get:function(){return o[r]}}))})})}function configRequirejs(e,t){e.requirejs.config({waitSeconds:120,paths:t.reduce((o,r)=>(o[r.packageName]=r.url,o),{})})}function processRemotePlugins(e,t){return(...o)=>{const r=o.map((n,a)=>[e[a].name,(n==null?void 0:n.default)||n]).filter(n=>n[1]);t(r);const i=o.map((n,a)=>n?null:a).filter(n=>n!==null).map(n=>e[n].packageName);i.length>0&&console.error("[nocobase load plugin error]: These plugins do not have an `export.default` exported content or there is an error in the plugins. error plugins: \r\n%s",i.join(`, \r
17
17
  `))}}function getRemotePlugins(e,t=[]){configRequirejs(e,t);const o=t.map(r=>r.packageName);return o.forEach(r=>{definePluginClient(r)}),new Promise((r,i)=>{e.requirejs(o,processRemotePlugins(t,r),i)})}function getPlugins(e){return q(this,null,function*(){const{requirejs:t,pluginData:o,devDynamicImport:r}=e;if(o.length===0)return[];const i=[],n={};if(r){try{for(var a=ke(o),l,c,u;l=!(c=yield a.next()).done;l=!1){const d=c.value,p=yield r(d.packageName);p&&(i.push([d.name,p.default]),n[d.packageName]=p.default)}}catch(d){u=[d]}finally{try{l&&(c=a.return)&&(yield c.call(a))}finally{if(u)throw u[0]}}defineDevPlugins(n)}const m=o.filter(d=>!n[d.packageName]);if(m.length===0)return i;if(i.length===0){const d=yield getRemotePlugins(t,m);i.push(...d)}return i})}let PluginManager$1=class{constructor(e,t,o){A(this,"pluginInstances",new Map),A(this,"pluginsAliases",{}),A(this,"initPlugins"),this._plugins=e,this.loadRemotePlugins=t,this.app=o,this.app=o,this.initPlugins=this.init(e)}init(e){return q(this,null,function*(){yield this.initStaticPlugins(e),this.loadRemotePlugins&&(yield this.initRemotePlugins())})}initStaticPlugins(){return q(this,arguments,function*(e=[]){try{for(var t=ke(e),o,r,i;o=!(r=yield t.next()).done;o=!1){const n=r.value,a=Array.isArray(n)?n[0]:n,l=Array.isArray(n)?n[1]:void 0;yield this.add(a,l)}}catch(n){i=[n]}finally{try{o&&(r=t.return)&&(yield r.call(t))}finally{if(i)throw i[0]}}})}initRemotePlugins(){return q(this,null,function*(){var e;const t=yield this.app.apiClient.request({url:"pm:listEnabled"}),o=((e=t==null?void 0:t.data)==null?void 0:e.data)||[],r=yield getPlugins({requirejs:this.app.requirejs,pluginData:o,devDynamicImport:this.app.devDynamicImport});try{for(var i=ke(r),n,a,l;n=!(a=yield i.next()).done;n=!1){const[c,u]=a.value,m=o.find(d=>d.name===c);yield this.add(u,m)}}catch(c){l=[c]}finally{try{n&&(a=i.return)&&(yield a.call(i))}finally{if(l)throw l[0]}}})}add(e){return q(this,arguments,function*(t,o={}){const r=this.getInstance(t,o);this.pluginInstances.set(t,r),o.name&&(this.pluginsAliases[o.name]=r),o.packageName&&(this.pluginsAliases[o.packageName]=r),yield r.afterAdd()})}get(e){return typeof e=="string"?this.pluginsAliases[e]:this.pluginInstances.get(e.default||e)}getInstance(e,t){return new e(t,this.app)}load(){return q(this,null,function*(){yield this.initPlugins;for(const e of this.pluginInstances.values())yield e.beforeLoad();for(const e of this.pluginInstances.values())yield e.load(),this.app.eventBus.dispatchEvent(new CustomEvent(`plugin:${e.options.name}:loaded`,{detail:e}))})}},IconFont;const icons=new Map;function registerIcon(e,t=IconFont){icons.set(e.toLowerCase(),t)}function hasIcon(e){return e?icons.has(e.toLowerCase()):!1}function registerIcons(e){Object.keys(e).forEach(t=>{registerIcon(t,e[t])})}Object.keys(antIcons).forEach(e=>{e.endsWith("Outlined")&&registerIcon(e,antIcons[e])});const Icon=e=>{const t=e,{type:o="",component:r}=t,i=K(t,["type","component"]);if(r)return(0,import_jsx_runtime.jsx)(import_icons.default,x({component:r},i));if(o&&icons.has(o.toLowerCase())){const n=icons.get(o.toLowerCase());return(0,import_jsx_runtime.jsx)(n,x({},i))}return o&&IconFont?(0,import_jsx_runtime.jsx)(IconFont,{type:o}):null};Icon.createFromIconfontCN=e=>{IconFont=(0,import_icons.createFromIconfontCN)(e)};Icon.register=e=>{registerIcons(e)};const ADMIN_SETTINGS_KEY="admin.settings.",ADMIN_SETTINGS_PATH="/admin/settings/",SNIPPET_PREFIX="pm.";class PluginSettingsManager{constructor(t,o){A(this,"settings",{}),A(this,"aclSnippets",[]),A(this,"app"),A(this,"cachedList",{}),this.app=o,Object.entries(t||{}).forEach(([r,i])=>{this.add(r,i)})}clearCache(){this.cachedList={}}setAclSnippets(t){this.aclSnippets=t}getAclSnippet(t){const o=this.settings[t];return o!=null&&o.skipAclConfigure?null:o!=null&&o.aclSnippet?o.aclSnippet:`${SNIPPET_PREFIX}${t}`}getRouteName(t){return`${ADMIN_SETTINGS_KEY}${t}`}getRoutePath(t){return`${ADMIN_SETTINGS_PATH}${t.replaceAll(".","/")}`}add(t,o){const r=t.split("."),i=r[0];this.settings[t]=P(x(P(x({},this.settings[t]),{Component:import_react_router_dom.Outlet}),o),{name:t,topLevelName:o.topLevelName||i}),r.length>1&&(0,import_lodash.set)(this.settings,r.join(".children."),this.settings[t]),this.app.router.add(this.getRouteName(t),{path:this.getRoutePath(t),Component:this.settings[t].Component})}remove(t){Object.keys(this.settings).forEach(o=>{o.startsWith(t)&&(delete this.settings[o],this.app.router.remove(`${ADMIN_SETTINGS_KEY}${o}`))})}hasAuth(t){return this.aclSnippets.includes(`!${this.getAclSnippet("*")}`)?!1:this.aclSnippets.includes(`!${this.getAclSnippet(t)}`)===!1}getSetting(t){return this.settings[t]}has(t){return this.hasAuth(t)?!!this.getSetting(t):!1}get(t,o=!0){const r=this.hasAuth(t),i=this.getSetting(t);if(o&&!r||!i)return null;const n=Object.keys(i.children||{}).sort((d,p)=>d.localeCompare(p)).map(d=>this.get(i.children[d].name,o)).filter(Boolean).sort((d,p)=>(d.sort||0)-(p.sort||0)),a=i,{title:l,icon:c,aclSnippet:u}=a,m=K(a,["title","icon","aclSnippet"]);return P(x({isTopLevel:t===i.topLevelName},m),{aclSnippet:this.getAclSnippet(t),title:l,isAllow:r,label:l,icon:typeof c=="string"?(0,import_react2.createElement)(Icon,{type:c}):c,path:this.getRoutePath(t),key:t,children:n.length?n:void 0})}getList(t=!0){const o=JSON.stringify(t);return this.cachedList[o]?this.cachedList[o]:this.cachedList[o]=Array.from(new Set(Object.values(this.settings).map(r=>r.topLevelName))).sort((r,i)=>r.localeCompare(i)).map(r=>this.get(r,t)).filter(Boolean).sort((r,i)=>(r.sort||0)-(i.sort||0))}getAclSnippets(){return Object.keys(this.settings).map(t=>this.getAclSnippet(t)).filter(Boolean)}}const ApplicationContext=(0,import_react2.createContext)(null);ApplicationContext.displayName="ApplicationContext";const AppComponent=(0,import_reactive_react.observer)(e=>{var t=e,{children:o}=t,r=K(t,["children"]),i;const{app:n}=r,a=(0,import_react2.useCallback)((c,u)=>{console.error(c);const m=new Error;m.stack=u.componentStack.trim(),console.error(m)},[]);(0,import_react2.useEffect)(()=>{n.load()},[n]);const l=n.getComponent("AppError");return n.loading?n.renderComponent("AppSpin",{app:n}):!n.maintained&&n.maintaining?n.renderComponent("AppMaintaining",{app:n}):(i=n.error)!=null&&i.code&&!(n.maintained&&n.maintaining)?(0,import_jsx_runtime.jsx)(l,{app:n,error:n.error}):(0,import_jsx_runtime.jsx)(import_react_error_boundary.ErrorBoundary,{FallbackComponent:c=>(0,import_jsx_runtime.jsx)(l,x({app:n,error:n.error},c)),onError:a,children:(0,import_jsx_runtime.jsxs)(ApplicationContext.Provider,{value:n,children:[n.maintained&&n.maintaining&&n.renderComponent("AppMaintainingDialog",{app:n}),n.renderComponent("AppMain",void 0,o)]})})},{displayName:"AppComponent"}),BlankComponent=({children:e})=>(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e}),useApp=()=>(0,import_react2.useContext)(ApplicationContext)||{},useAppSpin=()=>{const e=useApp();return{render:(0,import_react2.useCallback)(()=>{var t;return e!=null&&e.renderComponent?(t=e==null?void 0:e.renderComponent)==null?void 0:t.call(e,"AppSpin"):import_react2.default.createElement(import_antd.Spin)},[e])}};function usePlugin(e){return useApp().pm.get(e)}const useRouter=()=>useApp().router,MainComponent=import_react2.default.memo(({children:e})=>{const t=useApp(),o=(0,import_react2.useMemo)(()=>t.router.getRouterComponent(e),[t]),r=(0,import_react2.useMemo)(()=>t.getComposeProviders(),[t]);return(0,import_jsx_runtime.jsx)(o,{BaseLayout:r})});MainComponent.displayName="MainComponent";const Loading=()=>(0,import_jsx_runtime.jsx)("div",{children:"Loading..."}),AppError$1=({error:e})=>(0,import_jsx_runtime.jsxs)("div",{children:[(0,import_jsx_runtime.jsx)("div",{children:"App Error"}),e==null?void 0:e.message,!1]}),AppNotFound$1=()=>(0,import_jsx_runtime.jsx)("div",{}),defaultAppComponents={AppMain:MainComponent,AppSpin:Loading,AppError:AppError$1,AppNotFound:AppNotFound$1},RouterContextCleaner=import_react2.default.memo(e=>(0,import_jsx_runtime.jsx)(import_react_router_dom.UNSAFE_RouteContext.Provider,{value:{outlet:null,matches:[],isDataRoute:!1},children:(0,import_jsx_runtime.jsx)(import_react_router_dom.UNSAFE_LocationContext.Provider,{value:null,children:e.children})}));RouterContextCleaner.displayName="RouterContextCleaner";class RouterManager{constructor(t={},o){A(this,"routes",{}),A(this,"options"),A(this,"app"),this.options=t,this.app=o,this.routes=t.routes||{}}getRoutesTree(){const t={};for(const[r,i]of Object.entries(this.routes))(0,import_lodash.set)(t,r.split(".").join(".children."),x(x({},(0,import_lodash.get)(t,r.split(".").join(".children."))),i));const o=r=>Object.values(r).reduce((i,n)=>{if(Object.keys(n).length===1&&n.children)i.push(...o(n.children));else{const a=n,{Component:l,element:c,children:u}=a,m=K(a,["Component","element","children"]);let d=c;l&&(typeof l=="string"?d=this.app.renderComponent(l):d=import_react2.default.createElement(l));const p=P(x({},m),{element:d,children:u?o(u):void 0});i.push(p)}return i},[]);return o(t)}getRoutes(){return this.routes}setType(t){this.options.type=t}getBasename(){return this.options.basename}setBasename(t){this.options.basename=t}getRouterComponent(t){const o=this.options,{type:r="browser"}=o,i=K(o,["type"]),n={hash:import_react_router_dom.HashRouter,browser:import_react_router_dom.BrowserRouter,memory:import_react_router_dom.MemoryRouter}[r],a=this.getRoutesTree(),l=()=>(0,import_react_router_dom.useRoutes)(a);return({BaseLayout:c=BlankComponent})=>(0,import_jsx_runtime.jsx)(RouterContextCleaner,{children:(0,import_jsx_runtime.jsx)(n,P(x({},i),{children:(0,import_jsx_runtime.jsx)(CustomRouterContextProvider,{children:(0,import_jsx_runtime.jsx)(c,{children:(0,import_jsx_runtime.jsxs)(VariablesProvider$1,{children:[(0,import_jsx_runtime.jsx)(l,{}),t]})})})}))})}add(t,o){this.routes[t]=o}get(t){return this.routes[t]}has(t){return!!this.get(t)}remove(t){delete this.routes[t]}}function createRouterManager(e,t){return new RouterManager(e,t)}class WebSocketClient{constructor(t){if(A(this,"_ws"),A(this,"_reconnectTimes",0),A(this,"events",[]),A(this,"options"),A(this,"app"),A(this,"enabled"),A(this,"connected",!1),A(this,"serverDown",!1),A(this,"lastMessage",{}),!t){this.enabled=!1;return}this.options=t===!0?{}:t,this.enabled=!0,(0,import_reactive.define)(this,{serverDown:import_reactive.observable.ref,connected:import_reactive.observable.ref,lastMessage:import_reactive.observable.ref})}getURL(){if(!this.app)return;const t=this.app.getApiUrl();if(!t)return;const o=(0,import_sdk.getSubAppName)(this.app.getPublicPath()),r=o?`?__appName=${o}`:"",i=this.options.basename||"/ws";if(this.options.url){const n=new URL(this.options.url);return n.hostname==="localhost"?`${location.protocol==="https:"?"wss":"ws"}://${location.hostname}:${n.port}${i}${r}`:`${this.options.url}${r}`}try{const n=new URL(t);return`${n.protocol==="https:"?"wss":"ws"}://${n.host}${i}${r}`}catch{return`${location.protocol==="https:"?"wss":"ws"}://${location.host}${i}${r}`}}get reconnectAttempts(){var t;return((t=this.options)==null?void 0:t.reconnectAttempts)||30}get reconnectInterval(){var t;return((t=this.options)==null?void 0:t.reconnectInterval)||1e3}get pingInterval(){var t;return((t=this.options)==null?void 0:t.pingInterval)||3e4}get readyState(){return this._ws?this._ws.readyState:-1}connect(){if(!this.enabled||(this._reconnectTimes===0&&console.log("[nocobase-ws]: connecting..."),this._reconnectTimes>=this.reconnectAttempts)||this.readyState===WebSocket.OPEN)return;this._reconnectTimes++;const t=new WebSocket(this.getURL(),this.options.protocols);let o;t.onopen=()=>{console.log("[nocobase-ws]: connected."),this.serverDown=!1,this._ws&&this.removeAllListeners(),this._reconnectTimes=0,this._ws=t;for(const{type:r,listener:i,options:n}of this.events)this._ws.addEventListener(r,i,n);o=setInterval(()=>this.send("ping"),this.pingInterval),this.connected=!0,this.emit("open",{})},t.onerror=()=>q(this,null,function*(){console.log("onerror",this.readyState,this._reconnectTimes)}),t.onclose=r=>q(this,null,function*(){setTimeout(()=>this.connect(),this.reconnectInterval),console.log("onclose",this.readyState,this._reconnectTimes,this.serverDown),this.connected=!1,clearInterval(o)})}reconnect(){this._reconnectTimes=0,this.connect()}close(){if(this._ws)return this._reconnectTimes=this.reconnectAttempts,this._ws.close()}send(t){if(this._ws)return this._ws.send(t)}on(t,o,r){this.events.push({type:t,listener:o,options:r}),this._ws&&this._ws.addEventListener(t,o,r)}emit(t,o){for(const r of this.events)r.type===t&&r.listener(o)}off(t,o,r){let i=0;for(const n of this.events){if(n.type===t&&n.listener===o){this.events.splice(i,1);break}i++}this._ws&&this._ws.removeEventListener(t,o,r)}removeAllListeners(){if(this._ws)for(const{type:t,listener:o,options:r}of this.events)this._ws.removeEventListener(t,o,r)}}const useNiceDropdownMaxHeight=(e=[])=>{const t=(0,import_react2.useRef)(0);return(0,import_react2.useEffect)(()=>{const o=r=>{const{clientY:i}=r,n=Math.max(i,window.innerHeight-i);t.current=n};return window.addEventListener("mousemove",o),()=>{window.removeEventListener("mousemove",o)}},[]),(0,import_react2.useMemo)(()=>t.current-40,e)},FlagContext=import_react2.default.createContext(null),FlagProvider=e=>(0,import_jsx_runtime.jsx)(FlagContext.Provider,{value:e,children:e.children}),useFlag=()=>(0,import_react2.useContext)(FlagContext)||{},{ConfigContext}=import_antd.ConfigProvider,useConfig=()=>(0,import_react2.useContext)(ConfigContext),usePrefixCls=(e,t)=>{const{getPrefixCls:o}=(0,import_react2.useContext)(import_antd.ConfigProvider.ConfigContext)||{};return"ConfigContext"in import_antd.ConfigProvider?(o==null?void 0:o(e,void 0))||"":`ant-${e??""}`},useToken=()=>import_antd.theme.useToken(),loading$1=(e="Loading...",t)=>q(void 0,null,function*(){let o=null;const r=setTimeout(()=>{o=import_antd.message.loading(e)},100);try{return yield t()}finally{o==null||o(),clearTimeout(r)}}),fullClone=x({},ReactDOM),{version:version$1,render:reactRender,unmountComponentAtNode}=fullClone;let createRoot;try{Number((version$1||"").split(".")[0])>=18&&fullClone.createRoot&&(createRoot=fullClone.createRoot)}catch{}function toggleWarning(e){const{__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:t}=fullClone;t&&typeof t=="object"&&(t.usingClientEntryPoint=e)}const MARK="__antd_mobile_root__";function legacyRender(e,t){reactRender(e,t)}function concurrentRender(e,t){toggleWarning(!0);const o=t[MARK]||createRoot(t);toggleWarning(!1),o.render(e),t[MARK]=o}function render(e,t){if(createRoot){concurrentRender(e,t);return}legacyRender(e,t)}function legacyUnmount(e){return unmountComponentAtNode(e)}function concurrentUnmount(e){return q(this,null,function*(){return Promise.resolve().then(()=>{var t;(t=e[MARK])==null||t.unmount(),delete e[MARK]})})}function unmount(e){return createRoot?concurrentUnmount(e):legacyUnmount(e)}const PortalMap=(0,import_reactive.observable)(new Map),createPortalProvider=e=>{const t=o=>(o.id&&!PortalMap.has(o.id)&&PortalMap.set(o.id,null),(0,import_jsx_runtime.jsxs)(import_react2.Fragment,{children:[o.children,(0,import_jsx_runtime.jsx)(import_react.Observer,{children:()=>{if(!o.id)return(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{});const r=PortalMap.get(o.id);return r?(0,import_react_dom.createPortal)(r,document.body):(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{})}})]}));return t.defaultProps={id:e},t};function createPortalRoot(e,t){function o(i){PortalMap.has(t)?PortalMap.set(t,i==null?void 0:i()):e&&render((0,import_jsx_runtime.jsx)(import_react2.Fragment,{children:i==null?void 0:i()}),e)}function r(){var i;PortalMap.has(t)&&PortalMap.set(t,null),e&&unmount(e)&&e.parentNode&&((i=e.parentNode)==null||i.removeChild(e))}return{render:o,unmount:r}}const genCommonStyle=(e,t)=>{const{fontFamily:o,fontSize:r}=e,i=`[class^="${t}"], [class*=" ${t}"]`;return{[i]:{fontFamily:o,fontSize:r,boxSizing:"border-box","&::before, &::after":{boxSizing:"border-box"},[i]:{boxSizing:"border-box","&::before, &::after":{boxSizing:"border-box"}}}}},genStyleHook=(e,t)=>o=>{const{theme:r,token:i,hashId:n}=useToken(),{getPrefixCls:a,iconPrefixCls:l}=useConfig(),c=usePrefixCls(e),u=a(),m=(0,import_cssinjs.useStyleRegister)({theme:r,token:i,hashId:n,path:["formily-antd",e,c,l]},()=>{const d=`.${c}`,p=(0,import_shared.merge)(i,{componentCls:d,prefixCls:c,iconCls:`.${l}`,antCls:`.${u}`}),g=t(p,o,{hashId:n,prefixCls:c,rootPrefixCls:u,iconPrefixCls:l});return[genCommonStyle(i,c),g]});return{wrapSSR:(0,import_react2.useMemo)(()=>m,[r,i,n,c,l,u,o]),hashId:n,componentCls:c,rootPrefixCls:u}},useSchemaInitializerStyles=genStyleHook("nb-schema-initializer",e=>{const{componentCls:t}=e;return{[t]:{".ant-menu":{background:"transparent",borderInlineEnd:"none !important"},":not(.ant-menu)":{[`${t}-group-title`]:{color:e.colorTextDescription,lineHeight:`${e.controlHeight}px`,paddingLeft:e.padding,paddingRight:e.paddingSM},[`${t}-menu-item`]:{marginInline:e.marginXXS,paddingLeft:e.padding,paddingRight:e.paddingSM,lineHeight:`${e.controlHeight}px`,color:e.colorText,[`&:not(${t}-menu-item-disabled)`]:{cursor:"pointer","&:hover":{borderRadius:e.borderRadiusSM,backgroundColor:e.colorBgTextHover}},[`&${t}-menu-item-disabled`]:{cursor:"not-allowed",color:e.colorTextDisabled}}}},[`${t}-item-content`]:{marginLeft:e.marginXS}}}),SchemaInitializerContext=(0,import_react2.createContext)({});SchemaInitializerContext.displayName="SchemaInitializerContext";const useSchemaInitializer=()=>import_react2.default.useContext(SchemaInitializerContext),SchemaInitializerItemContext=(0,import_react2.createContext)({});SchemaInitializerItemContext.displayName="SchemaInitializerItemContext";const useSchemaInitializerItem=()=>import_react2.default.useContext(SchemaInitializerItemContext),defaultWrap$1=e=>e,useWrapDefault=(e=defaultWrap$1)=>e;function withInitializer(e){return(0,import_react.observer)(t=>{const{designable:o,insertAdjacent:r}=useDesignable(),{isInSubTable:i}=useFlag()||{},{insert:n,useInsert:a,useWrap:l=useWrapDefault,wrap:c=defaultWrap$1,insertPosition:u="beforeEnd",onSuccess:m,designable:d,popoverProps:p,children:g,popover:h=!0,style:f,componentProps:_}=t,v=a?a():n,S=l(c),C=(0,import_react2.useCallback)(R=>{v?v(S(R,{isInSubTable:i})):r(u,S(R,{isInSubTable:i}),{onSuccess:m})},[v,S,i,r,u,m]),{wrapSSR:b,hashId:y,componentCls:F}=useSchemaInitializerStyles(),[j,k]=(0,import_react2.useState)(!1),{token:T}=import_antd.theme.useToken(),O=useNiceDropdownMaxHeight([j]),N=(0,import_react2.useMemo)(()=>x({options:t,style:f},_),[_,t,f]),L=(0,import_react2.useMemo)(()=>import_css.css`
18
18
  .ant-popover-inner {
19
19
  padding: ${`${T.paddingXXS}px 0`};
@@ -253,7 +253,7 @@ ${JSON.stringify(B,null,2)}`)},[u,c,l,i,r,j,t,a,n,h,o,f,C,k,b,y,g]),O=(0,import_
253
253
  display: ${C?"block":"none"};
254
254
  }
255
255
  }
256
- `),footer:C?(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:p.address,schema:d,onlyRenderProperties:!0,filterProperties:y=>y["x-component"]===o}):!1,children:(0,import_jsx_runtime.jsx)(ActionModalContent,{footerNodeName:o,field:p,schema:d})}))}))})})},{displayName:"ActionModal"}),ActionModal=e=>(0,import_jsx_runtime.jsx)(import_react_error_boundary.ErrorBoundary,{FallbackComponent:ModalErrorFallback,onError:console.log,children:(0,import_jsx_runtime.jsx)(InternalActionModal,x({},e))});ActionModal.Footer=(0,import_react.observer)(()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)();return(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:e.address,schema:t,onlyRenderProperties:!0})},{displayName:"ActionModal.Footer"});const CurrentPopupRecordContext=import_react2.default.createContext(null),CurrentParentPopupRecordContext=import_react2.default.createContext(null),VariablePopupRecordProvider=import_react2.default.memo(e=>{var t,o;const{t:r}=(0,import_react_i18next.useTranslation)(),i=useCollectionRecordData(),n=useCollection(),a=useCurrentPopupRecord();return(0,import_jsx_runtime.jsx)(CurrentParentPopupRecordContext.Provider,{value:{name:"$nParentPopupRecord",title:r("Parent popup record"),value:((t=e.parent)==null?void 0:t.recordData)||(a==null?void 0:a.value),collection:((o=e.parent)==null?void 0:o.collection)||(a==null?void 0:a.collection)},children:(0,import_jsx_runtime.jsx)(CurrentPopupRecordContext.Provider,{value:{name:"$nPopupRecord",title:r("Current popup record"),value:e.recordData||i,collection:e.collection||n},children:e.children})})});VariablePopupRecordProvider.displayName="VariablePopupRecordProvider";const useCurrentPopupRecord=()=>import_react2.default.useContext(CurrentPopupRecordContext),useParentPopupRecord=()=>import_react2.default.useContext(CurrentParentPopupRecordContext),useDef$3=()=>({}),useProps=(e={})=>{const t=e,{useProps:o=useDef$3}=t,r=K(t,["useProps"]);let i=o;typeof o!="function"&&(i=useDef$3);const n=i();return x(x({},r),n)},PopupLevelContext=import_react2.default.createContext(0),ActionContainer=(0,import_react.observer)(e=>{const{getComponentByOpenMode:t,defaultOpenMode:o}=useOpenModeContext()||{},{openMode:r=o}=useActionContext(),i=import_react2.default.useContext(PopupLevelContext)+1,n=t(r)||ActionDrawer;return(0,import_jsx_runtime.jsx)(PopupLevelContext.Provider,{value:i,children:(0,import_jsx_runtime.jsx)(n,x({footerNodeName:"Action.Container.Footer",level:i||1},e))})},{displayName:"ActionContainer"});ActionContainer.Footer=(0,import_react.observer)(()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)();return(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:e.address,schema:t,onlyRenderProperties:!0})},{displayName:"ActionContainer.Footer"});const SchemaToolbarContext=(0,import_react2.createContext)({});SchemaToolbarContext.displayName="SchemaToolbarContext";const SchemaToolbarProvider=e=>{const t=e,{children:o}=t,r=K(t,["children"]);return(0,import_jsx_runtime.jsx)(SchemaToolbarContext.Provider,{value:r,children:o})};function useSchemaToolbar(){return(0,import_react2.useContext)(SchemaToolbarContext)}function useSchemaSettingsRender(e,t){const o=useApp(),r=(0,import_react2.useMemo)(()=>typeof e=="object"?e:o.schemaSettingsManager.get(e),[o.schemaSettingsManager,e]);return e?r?{exists:!0,render:(i={})=>import_react2.default.createElement(SchemaSettingsWrapper,x(x(x({},r.options),t),i))}:(console.error(`[nocobase]: SchemaSettings "${e}" not found`),{exists:!1,render:()=>null}):{exists:!1,render:()=>null}}const EditableTitle=e=>{const[t,o]=(0,import_react2.useState)(e.title),[r,i]=(0,import_react2.useState)(!1),{refresh:n}=useSchemaTemplateManager();useAPIClient();const{run:a}=useRequest({resource:"uiSchemaTemplates",action:"update",params:{filterByTk:e.filterByTk}},{manual:!0,debounceWait:500,onSuccess(){n()}});return(0,import_jsx_runtime.jsx)("div",{children:r?(0,import_jsx_runtime.jsx)(import_antd.Input,{defaultValue:t,size:"large",onBlur:()=>{i(!1)},onChange:l=>{o(l.target.value),a({filterByTk:e.filterByTk,values:{name:l.target.value}})}}):(0,import_jsx_runtime.jsx)("div",{onClick:()=>{i(!0)},children:t||(0,import_jsx_runtime.jsx)("span",{style:{color:"#bbb"},children:"未命名"})})})},BlockTemplateDetails=()=>{var e,t;const o=useNavigateNoUpdate(),r=(0,import_react_router_dom.useParams)(),i=r==null?void 0:r.key,n=(0,import_react2.useContext)(SchemaComponentContext),a=(0,import_react2.useMemo)(()=>P(x({},n),{designable:!0}),[n]),{data:l,loading:c}=useRequest({resource:"uiSchemaTemplates",action:"get",params:{filterByTk:i}});return c?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(0,import_jsx_runtime.jsxs)("div",{children:[(0,import_jsx_runtime.jsx)(import_pro_layout.PageHeader,{style:{backgroundColor:"white"},onBack:()=>{o("/admin/plugins/block-templates")},ghost:!1,title:(0,import_jsx_runtime.jsx)(EditableTitle,{filterByTk:i,title:(e=l==null?void 0:l.data)==null?void 0:e.name})}),(0,import_jsx_runtime.jsx)("div",{style:{margin:"var(--nb-spacing)"},children:(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:a,children:(0,import_jsx_runtime.jsx)(RemoteSchemaComponent,{uid:(t=l==null?void 0:l.data)==null?void 0:t.uid})})})]})},uiSchemaTemplatesCollection={name:"uiSchemaTemplates",filterTargetKey:"key",targetKey:"key",fields:[{type:"integer",name:"name",interface:"input",uiSchema:{title:'{{ t("Template name") }}',type:"number","x-component":"Input",required:!0}}]},CollectionTitle=e=>{const{dataSourceKey:t="main",collectionName:o}=useCollectionRecordData(),r=useDataSourceManager(),i=useCompile(),[n,a]=(0,import_react2.useMemo)(()=>{const l=r.getDataSource(t);if(l){const c=l.collectionManager.getCollection(o);return[l.displayName,(c==null?void 0:c.title)||o]}return[t,null]},[r,t,o]);return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[i(n)," ",">"," ",i(a)]})},ActionSchemaToolbar=e=>(0,import_jsx_runtime.jsx)(SchemaToolbar,x({initializer:!1,showBorder:!1,showBackground:!0},e)),BlockSchemaToolbar=e=>{const{t}=(0,import_react_i18next.useTranslation)(),o=useCollectionManager();let{name:r,title:i}=useCollection()||{};const n=useSchemaTemplate(),{association:a,collection:l}=useDataBlockProps()||{},c=useCompile();if(a){const[g]=a.split("."),{name:h,title:f}=o.getCollection(g);r=h,i=f}const u=o.getCollectionField(a),m=o.getCollection(l||(u==null?void 0:u.target)),d=["FormItem","ReadPrettyFormItem"].includes(n==null?void 0:n.componentName)?`${n==null?void 0:n.name} ${t("(Fields only)")}`:n==null?void 0:n.name,p=(0,import_react2.useMemo)(()=>[getCollectionTitle({collectionTitle:i,collectionName:r,associationField:u,associationCollection:m,compile:c}),d].filter(Boolean),[i,r,u,m,c,d]);return(0,import_jsx_runtime.jsx)(SchemaToolbar,x({title:p},e))};function getCollectionTitle(e){var t;const{collectionTitle:o,collectionName:r,associationField:i,compile:n,associationCollection:a}=e;return i?`${n(o||r)} > ${n(((t=i.uiSchema)==null?void 0:t.title)||i.name)} (${n((a==null?void 0:a.title)||(a==null?void 0:a.name))})`:n(o||r)}const useDetailsWithPaginationBlockParams=e=>{const{params:t}=e,{filter:o,parseVariableLoading:r}=useParsedFilter({filterOption:t==null?void 0:t.filter});return{params:(0,import_react2.useMemo)(()=>P(x({},t),{filter:o}),[JSON.stringify(o)]),parseVariableLoading:r}};function useDetailsWithPaginationDecoratorProps(e){let t;const{params:o,parseVariableLoading:r}=useDetailsWithPaginationBlockParams(e);return e.association&&(t=useParentRecordCommon(e.association)),{parentRecord:t,params:o,parseVariableLoading:r}}const useSpecialCase=()=>{const e=(0,import_react.useForm)(),t=(0,import_react.useFieldSchema)(),{getField:o}=useCollection_deprecated(),{getCollectionField:r}=useCollectionManager_deprecated(),i=(0,import_react2.useMemo)(()=>o(t.name),[t.name,o]),n=(0,import_react2.useCallback)(()=>isSpecialCaseField({collectionField:i,fieldSchema:t,getCollectionField:r}),[i,t,r]),a=(0,import_react2.useCallback)(l=>{const c=getParentFieldSchema(t);if(c){const u=e.query(c.name).take();if(u){const m=import_lodash.default.isEmpty(l)?[]:import_lodash.default.map(transformValue(l,{field:u,subFieldSchema:t}),d=>markRecordAsNew(d));isSubset(m,u.initialValue)||u.setInitialValue(m)}}},[t,e]);return{isSpecialCase:n,setDefaultValue:a}};function getParentFieldSchema(e){for(;e!=null&&e.parent;)if(e=e.parent,isSubMode(e))return e;return e}function isSpecialCaseField({collectionField:e,fieldSchema:t,getCollectionField:o}){if(!t.default||!t.default.includes("$context"))return!1;if(e&&["hasOne","belongsTo"].includes(e.type)&&t){const r=getParentFieldSchema(t);if(r&&r["x-collection-field"]){const i=o(r["x-collection-field"]);if(["hasMany","belongsToMany"].includes(i==null?void 0:i.type))return!0}}return!1}function transformValue(e,t){const{field:o,subFieldSchema:r}=t,i=o.value;let n=null;return Array.isArray(e)?n=e.map(a=>({[r.name]:a})):n=[{[r.name]:e}],import_lodash.default.assignWith([...i],n,(a,l)=>(!a&&l&&(l.__notFromDatabase=!0),import_lodash.default.assign(x({},i[0]),l)))}const useSubTableSpecialCase=({rootField:e,rootSchema:t})=>{const{hasUsedVariable:o}=useHasUsedVariable();(0,import_react2.useEffect)(()=>{if(import_lodash.default.isEmpty(e.value)&&o("$context",t)){const r=e.value,i=[markRecordAsNew({})];e.value=i,setTimeout(()=>{JSON.stringify(e.value)===JSON.stringify(i)&&(e.value=r)})}},[e,t,o])};function isSubset(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++){const r=e[o],i=t[o];if(!import_lodash.default.isMatch(import_lodash.default.omitBy(i,import_lodash.default.isNil),import_lodash.default.omitBy(r,import_lodash.default.isNil)))return!1}return!0}const checkSchema=(e,t)=>{if(e["x-decorator"]==="FormItem"){const r=e.default;if(r&&typeof r=="string"&&isVariable(r)&&r.includes(t))return!0}let o=!1;return e.mapProperties(r=>{checkSchema(r,t)&&(o=!0)}),o};function useHasUsedVariable(){return{hasUsedVariable:(0,import_react2.useCallback)((e,t)=>checkSchema(t,e),[])}}const BaseVariableContext=import_react2.default.createContext(null),BaseVariableProvider=e=>(0,import_jsx_runtime.jsx)(BaseVariableContext.Provider,{value:e,children:e.children}),getChildren$2=(e,{collectionField:t,uiSchema:o,depth:r,maxDepth:i,noDisabled:n,loadChildren:a,compile:l,isDisabled:c,targetFieldSchema:u,getCollectionField:m,deprecated:d})=>e.map(p=>!p.target||p.target==="chinaRegions"?{key:p.name,value:p.name,label:l(p.title),disabled:d||(n?!1:c({option:p,collectionField:t,uiSchema:o,targetFieldSchema:u,getCollectionField:m})),isLeaf:!0,depth:r}:r>=i?null:{key:p.name,value:p.name,label:l(p.title),isLeaf:!1,field:p,depth:r,disabled:d||(n?!1:c({option:p,collectionField:t,uiSchema:o,targetFieldSchema:u,getCollectionField:m})),loadChildren:a}).filter(Boolean),getLabelWithTooltip=(e,t)=>t?(0,import_jsx_runtime.jsx)(import_antd.Tooltip,{placement:"left",title:t,zIndex:9999,children:(0,import_jsx_runtime.jsx)("span",{style:{position:"relative",display:"inline-block",marginLeft:-14,paddingLeft:14,marginRight:-80,paddingRight:80,zIndex:1},children:e})}):e,useBaseVariable=({collectionField:e,uiSchema:t,targetFieldSchema:o,maxDepth:r=3,name:i,title:n,collectionName:a,noChildren:l=!1,noDisabled:c=!0,dataSource:u,returnFields:m=g=>g,deprecated:d,tooltip:p})=>{const g=useCompile(),h=useGetFilterOptions(),{isDisabled:f}=(0,import_react2.useContext)(BaseVariableContext)||{},_=useCollectionManager(),v=S=>{var C;if(!((C=S.field)!=null&&C.target))return Promise.resolve(void 0);const b=S.field.target;return new Promise(y=>{setTimeout(()=>{const F=(getChildren$2(m(h(b,u,!0),S),{collectionField:e,uiSchema:t,targetFieldSchema:o,depth:S.depth+1,maxDepth:r,noDisabled:c,loadChildren:v,compile:g,isDisabled:f||isDisabledDefault,getCollectionField:_.getCollectionField,deprecated:d})||[]).sort((j,k)=>j.isLeaf&&!k.isLeaf?-1:!j.isLeaf&&k.isLeaf?1:0).sort((j,k)=>j.disabled&&!k.disabled?1:!j.disabled&&k.disabled?-1:0);if(F.length===0){S.disabled=!0,S.isLeaf=!0,y();return}S.children=F,y()},5)})};return(0,import_react2.useMemo)(()=>({label:getLabelWithTooltip(n,p),value:i,key:i,isLeaf:l,field:{target:a},depth:0,loadChildren:v,children:[],disabled:!!d,deprecated:d}),[t==null?void 0:t["x-component"]])};function isDisabledDefault(e){var t,o;const{option:r,collectionField:i,uiSchema:n,targetFieldSchema:a,getCollectionField:l}=e;return!n||!i?!0:i.interface==="json"?!1:!i.target&&["hasMany","belongsToMany"].includes(r.type)?!0:!i.target&&["hasOne","belongsTo"].includes(r.type)||r.target&&isSpecialCaseField({collectionField:i,fieldSchema:a,getCollectionField:l})?!1:["hasOne","belongsTo"].includes(i.type)&&["hasMany","belongsToMany"].includes(r.type)?!0:["hasOne","belongsTo"].includes(i.type)&&["hasOne","belongsTo"].includes(r.type)||["hasMany","belongsToMany"].includes(i.type)&&r.target?!1:["input","markdown","richText","textarea","username"].includes(i.interface)?!["string","number"].includes((t=r.schema)==null?void 0:t.type):i.interface&&r.interface?i.interface!==r.interface:(n==null?void 0:n["x-component"])!==((o=r.schema)==null?void 0:o["x-component"])}const CurrentRecordContext=(0,import_react2.createContext)(null),CurrentRecordContextProvider=e=>{const t=(0,import_react2.useMemo)(()=>({recordData:e.recordData,collectionName:e.collectionName}),[e.recordData,e.collectionName]);return(0,import_jsx_runtime.jsxs)(CurrentRecordContext.Provider,{value:t,children:[" ",e.children," "]})},useCurrentRecord=()=>(0,import_react2.useContext)(CurrentRecordContext),useCurrentRecordContext=()=>{const e=useCurrentRecord(),{name:t}=useBlockContext()||{},o=useCollection(),r=useCollectionRecordData(),{formRecord:i,collectionName:n}=useFormBlockContext();let a=i!=null&&i.data?n:o==null?void 0:o.name;return a=(e==null?void 0:e.collectionName)||a,{currentRecordCtx:(e==null?void 0:e.recordData)||(i==null?void 0:i.data)||r,shouldDisplayCurrentRecord:!import_lodash.default.isEmpty(import_lodash.default.omit(r,["__collectionName","__parent"]))||!!(i!=null&&i.data),collectionName:a,blockType:t,dataSource:o==null?void 0:o.dataSource}},useCurrentRecordVariable=(e={})=>{const{t}=(0,import_react_i18next.useTranslation)(),{currentRecordCtx:o,shouldDisplayCurrentRecord:r,collectionName:i,blockType:n,dataSource:a}=useCurrentRecordContext();return{currentRecordSettings:useBaseVariable({collectionField:e.collectionField,uiSchema:e.schema,name:"$nRecord",title:t("Current record"),collectionName:i,noDisabled:e.noDisabled,targetFieldSchema:e.targetFieldSchema,deprecated:n==="form",tooltip:n==="form"?t('This variable has been deprecated and can be replaced with "Current form"'):"",dataSource:a}),currentRecordCtx:o,shouldDisplayCurrentRecord:r,collectionName:i}},DetailsBlockContext=(0,import_react2.createContext)({});DetailsBlockContext.displayName="DetailsBlockContext";const InternalDetailsBlockProvider=e=>{var t,o,r;const{action:i,readPretty:n}=e,a=(0,import_react.useField)(),l=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)({readPretty:n}),[n]),c=useCollection(),{resource:u,service:m}=useBlockRequestContext(),d=useCollectionParentRecord(),p=(i==="list"?(o=(t=m==null?void 0:m.data)==null?void 0:t.data)==null?void 0:o[0]:(r=m==null?void 0:m.data)==null?void 0:r.data)||{},g=(0,import_react2.useRef)(),h=(0,import_react2.useMemo)(()=>({action:i,form:l,field:a,service:m,resource:u,formBlockRef:g}),[i,a,l,u,m]);return m.loading&&!a.loaded?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(a.loaded=!0,(0,import_jsx_runtime.jsx)(CurrentRecordContextProvider,{recordData:p,collectionName:c==null?void 0:c.name,children:(0,import_jsx_runtime.jsx)(DetailsBlockContext.Provider,{value:h,children:(0,import_jsx_runtime.jsx)("div",{ref:g,children:(0,import_jsx_runtime.jsx)(RecordProvider,{isNew:!1,record:p,parent:d==null?void 0:d.data,children:e.children})})})}))},useCompatDetailsBlockParams=e=>{const t=(0,import_react.useFieldSchema)();let o,r=!1;if(t["x-use-decorator-props"])o=e==null?void 0:e.params,r=e==null?void 0:e.parseVariableLoading;else{const i=useDetailsWithPaginationBlockParams(e);o=i.params,r=i.parseVariableLoading}return{params:o,parseVariableLoading:r}},DetailsBlockProvider=withDynamicSchemaProps(e=>{const{params:t,parseVariableLoading:o}=useCompatDetailsBlockParams(e),r=useCollectionRecordData(),{association:i,dataSource:n}=e,{getCollection:a}=useCollectionManager_deprecated(n),{__collection:l}=r||{},{designable:c}=useDesignable(),u=e.collection||a(i,n).name;let m=!0;!c&&l&&(m=l===u);const d=(0,import_ahooks.useUpdate)();return!m||o?null:(0,import_jsx_runtime.jsx)(TemplateBlockProvider,{onTemplateLoaded:d,children:(0,import_jsx_runtime.jsx)(BlockProvider,P(x({name:"details"},e),{params:t,children:(0,import_jsx_runtime.jsx)(InternalDetailsBlockProvider,x({},e))}))})}),useDetailsBlockContext=()=>(0,import_react2.useContext)(DetailsBlockContext),useDetailsBlockProps=()=>{var e,t;const o=useDetailsBlockContext();return(0,import_react2.useEffect)(()=>{var r,i,n,a,l;if(!o.service.loading){const c=o.action==="list"?(n=(i=(r=o.service)==null?void 0:r.data)==null?void 0:i.data)==null?void 0:n[0]:(l=(a=o.service)==null?void 0:a.data)==null?void 0:l.data;o.form.reset().then(()=>{o.form.setInitialValues(c||{}),o.form.setValues(c||{})}).catch(console.error)}},[o.action,o.form,(t=(e=o.service)==null?void 0:e.data)==null?void 0:t.data,o.service.loading]),{form:o.form}};function useDetailsWithPaginationProps(){return useDetailsBlockProps()}function useDetailsDecoratorProps(e){const t=useParamsFromRecord(e);let o;return e.association&&(o=useDetailsParentRecord(e.association)),{params:t,parentRecord:o}}function useDetailsParentRecord(e){const t=(0,import_react.useFieldSchema)(),o=useCollectionRecordData(),r=useCollectionParentRecordData();if(e)return t["x-is-current"]?r:o}function useDetailsProps(){return useDetailsBlockProps()}const FormItemSchemaToolbar=e=>(0,import_jsx_runtime.jsx)(SchemaToolbar,x({showBorder:!1,showBackground:!0},e)),useHiddenForInherit=e=>{const t=useRecord(),{collection:o,isCusomeizeCreate:r,hidden:i}=e,{__collection:n}=t,a=useCollection(),{designable:l}=useDesignable(),c=useIsDetailBlock();if(!a)return{hidden:i||!1};let u=!1;c&&(u=!0,!l&&n&&(u=n===o));const m=a.name===((o==null?void 0:o.name)||o)&&!c||!a.name||!o;return{hidden:i||!u&&!m&&!r}};function useCreateFormBlockDecoratorProps(e){let t;const{hidden:o}=useHiddenForInherit(e);return e.association&&(t=useParentRecordCommon(e.association)),{parentRecord:t,hidden:o}}function useCreateFormBlockProps(){return useFormBlockProps$1()}function useEditFormBlockDecoratorProps(e){const t=useFormBlockParams();let o;const{hidden:r}=useHiddenForInherit(e);return e.association&&(o=useDetailsParentRecord(e.association)),{params:t,parentRecord:o,hidden:r}}function useFormBlockParams(){return useParamsFromRecord()}function useEditFormBlockProps(){return useFormBlockProps$1()}function useDataFormItemProps(){const e=useCollectionRecordData(),{form:t}=useFormBlockContext(),o=useSubFormValue(),{valueMap:r}=useSatisfiedActionValues({category:"style",formValues:(o==null?void 0:o.formValue)||(t==null?void 0:t.values)||e,form:t});return{wrapperStyle:r}}function useGridCardBlockParams(e){const{params:t}=e,{filter:o,parseVariableLoading:r}=useParsedFilter({filterOption:t==null?void 0:t.filter});return{params:(0,import_react2.useMemo)(()=>P(x({},t),{filter:o}),[o,t]),parseVariableLoading:r}}function useGridCardBlockDecoratorProps(e){const{params:t,parseVariableLoading:o}=useGridCardBlockParams(e);let r;return e.association&&(r=useParentRecordCommon(e.association)),{params:t,parentRecord:r,parseVariableLoading:o}}function useListBlockDecoratorProps(e){let t;return e.association&&(t=useParentRecordCommon(e.association)),{parentRecord:t}}function useTableSelectorDecoratorProps(){}const useStyles$g=genStyleHook("nb-grid-in-css-in-js",e=>{const{componentCls:t}=e,o=e.marginBlock===e.marginLG?" !important":"";return{[t]:{position:"relative",".ColDivider":{flexShrink:0,width:`${e.marginBlock}px${o}`},".DraggableNode":{"&::before":{content:'" "',width:"100%",height:"100%",position:"absolute",cursor:"col-resize"},"&:hover":{"&::before":{background:"var(--colorBgSettingsHover) !important"}},width:`${e.marginBlock}px${o}`,height:"100%",position:"absolute",cursor:"col-resize"},".RowDivider":{height:`${e.marginBlock}px${o}`,width:"100%",position:"absolute",marginTop:`calc(-1 * ${e.marginBlock}px)${o}`},".CardRow":{display:"flex",position:"relative"},".showDivider":{margin:`0 calc(-1 * ${e.marginBlock}px)${o}`},".nb-grid-warp > button:last-child":{marginBottom:`${e.marginBlock}px`},".nb-grid-warp .nb-grid-warp > button:last-child":{marginBottom:`${e.margin}px`}}}}),GridRowContext=(0,import_react2.createContext)({});GridRowContext.displayName="GridRowContext";const GridColContext=(0,import_react2.createContext)({});GridColContext.displayName="GridColContext";const GridContext=(0,import_react2.createContext)({});GridContext.displayName="GridContext";const breakRemoveOnGrid=e=>e["x-component"]==="Grid",breakRemoveOnRow=e=>e["x-component"]==="Grid.Row",ColDivider=e=>{var t,o,r;const{token:i}=useToken(),n=(0,import_react2.useRef)(null),{dn:a,designable:l}=useDesignable(),{isOver:c,setNodeRef:u}=(0,import_core.useDroppable)({id:e.id,data:e.data,disabled:!l}),m=(0,import_react2.useRef)(),d=(0,import_react2.useMemo)(()=>c?{backgroundColor:new import_tinycolor.TinyColor(i.colorSettings).setAlpha(.1).toHex8String()}:{},[c]),p=(r=(o=(t=(0,import_core.useDndContext)().active)==null?void 0:t.data.current)==null?void 0:o.schema)==null?void 0:r.parent,g=(0,import_react2.useMemo)(()=>p?Object.keys(p.properties).length:0,[p]);let h=!0;if(g===1)if(e.first)h=p!==e.cols[0];else{const j=e.cols[e.index],k=e.cols[e.index+1];h=p!==j&&k!==p}const f=e.cols[e.index],_=e.cols[e.index+1],{attributes:v,listeners:S,setNodeRef:C,isDragging:b}=(0,import_core.useDraggable)({disabled:e.first||e.last||!l,id:e.id,data:{dividerRef:m,prevSchema:f,nextSchema:_}}),[y,F]=(0,import_react2.useState)([0,0]);return(0,import_core.useDndMonitor)({onDragStart(j){if(!l||!b)return;n.current=j.active.id;const k=m.current,T=k.previousElementSibling,O=k.nextElementSibling;F([T.clientWidth,O.clientWidth])},onDragMove(j){if(!l||!b)return;n.current===j.active.id&&(n.current=n.current+"_move");const k=m.current,T=k.previousElementSibling,O=k.nextElementSibling;T.style.width=`${y[0]+j.delta.x}px`,O.style.width=`${y[1]-j.delta.x}px`},onDragEnd(j){var k;if(!l||!n.current||(k=n.current)!=null&&k.startsWith(j.active.id)&&!n.current.endsWith("_move")||y[0]<=0||y[1]<=0||(F([0,0]),!f||!_))return;const T=m.current,O=T.previousElementSibling,N=T.nextElementSibling;f["x-component-props"]=f["x-component-props"]||{},_["x-component-props"]=_["x-component-props"]||{};const L=T.clientWidth*(e.cols.length+1)/e.cols.length,D=(100*(O.getBoundingClientRect().width+L)/T.parentElement.clientWidth).toFixed(2),R=(100*(N.getBoundingClientRect().width+L)/T.parentElement.clientWidth).toFixed(2);import_lodash.default.set(f,"x-component-props.width",D),import_lodash.default.set(_,"x-component-props.width",R),a.emit("batchPatch",{schemas:[{"x-uid":f["x-uid"],"x-component-props":x({},f["x-component-props"])},{"x-uid":_["x-uid"],"x-component-props":x({},_["x-component-props"])}]})}}),(0,import_jsx_runtime.jsx)("div",{ref:j=>{h&&(u(j),m.current=j)},className:(0,import_classnames.default)("nb-col-divider","ColDivider"),style:d,children:(0,import_jsx_runtime.jsx)("div",P(x(x({ref:C},S),v),{className:e.first||e.last||!l?null:"DraggableNode"}))})},RowDivider=import_react2.default.memo(e=>{var t,o,r;const{token:i}=useToken(),{designable:n}=useDesignable(),{isOver:a,setNodeRef:l}=(0,import_core.useDroppable)({id:e.id,data:e.data,disabled:!n}),[c,u]=(0,import_react2.useState)(!1),m=(0,import_react2.useMemo)(()=>a?{zIndex:c?1e3:-1,backgroundColor:new import_tinycolor.TinyColor(i.colorSettings).setAlpha(.1).toHex8String()}:{zIndex:c?1e3:-1},[c,a]),d=(0,import_core.useDndContext)(),p=e.rows[e.index],g=(r=(o=(t=d.active)==null?void 0:t.data.current)==null?void 0:o.schema)==null?void 0:r.parent.parent,h=(0,import_react2.useMemo)(()=>g==null?void 0:g.mapProperties(_=>_["x-component"]==="Grid.Col").filter(Boolean).length,[g]);let f=!0;if(h===1)if(e.first)f=g!==e.rows[0];else{const _=e.rows[e.index+1];f=g!==p&&_!==g}return(0,import_core.useDndMonitor)({onDragStart(_){n&&u(!0)},onDragMove(_){},onDragOver(_){},onDragEnd(_){n&&u(!1)},onDragCancel(_){n&&u(!1)}}),(0,import_jsx_runtime.jsx)("span",{ref:f?l:null,className:(0,import_classnames.default)("nb-row-divider","RowDivider"),style:m})});RowDivider.displayName="RowDivider";const wrapRowSchema=e=>{const t=new import_react.Schema({type:"void",name:`row_${(0,import_shared.uid)()}`,"x-uid":(0,import_shared.uid)(),"x-component":"Grid.Row"}),o=t.addProperty((0,import_shared.uid)(),{type:"void","x-uid":(0,import_shared.uid)(),"x-component":"Grid.Col"});return import_react.Schema.isSchemaInstance(e)&&(e.parent=o),o.addProperty(e.name,e),t},wrapColSchema=e=>{const t=new import_react.Schema({type:"void",name:`col_${(0,import_shared.uid)()}`,"x-uid":(0,import_shared.uid)(),"x-component":"Grid.Col"});return import_react.Schema.isSchemaInstance(e)&&(e.parent=t),t.addProperty(e.name,e),t},useRowProperties=()=>{const e=(0,import_react.useFieldSchema)();return(0,import_react2.useMemo)(()=>e.reduceProperties((t,o)=>(o["x-component"]==="Grid.Row"&&!o["x-hidden"]&&t.push(o),t),[]),[e])},useColProperties=()=>{const e=(0,import_react.useFieldSchema)();return(0,import_react2.useMemo)(()=>e.reduceProperties((t,o)=>(o["x-component"]==="Grid.Col"&&!o["x-hidden"]&&t.push(o),t),[]),[e])},DndWrapper=e=>e.dndContext===!1?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):(0,import_jsx_runtime.jsx)(DndContext,P(x({},e.dndContext),{children:e.children})),useGridContext=()=>(0,import_react2.useContext)(GridContext),useGridRowContext=()=>(0,import_react2.useContext)(GridRowContext),getRowDividerData=import_lodash.default.memoize((e,t)=>({breakRemoveOn:breakRemoveOnGrid,wrapSchema:wrapRowSchema,insertAdjacent:t,schema:e})),Grid=(0,import_react.observer)(e=>{const{distributed:t,showDivider:o=!0}=e,r=(0,import_react2.useRef)(null),i=(0,import_react.useField)(),n=(0,import_react.useFieldSchema)(),{render:a}=useSchemaInitializerRender(n["x-initializer"],n["x-initializer-props"]),l=(0,import_react2.useCallback)(S=>a(S),[]),c=i.address.toString(),u=useRowProperties(),{setPrintContent:m}=useFormBlockContext(),{componentCls:d,hashId:p}=useStyles$g(),g=t===void 0?(n==null?void 0:n.parent["x-component"])==="Page"||(n==null?void 0:n.parent["x-component"])==="Tabs.TabPane":t;(0,import_react2.useEffect)(()=>{r.current&&(m==null||m(r.current))},[m]);const h=(0,import_react2.useMemo)(()=>({ref:r,fieldSchema:n,renderSchemaInitializer:a,InitializerComponent:l,showDivider:o}),[n,a,l,o]),f=useRefreshFieldSchema(),_=useRefreshComponent(),v=(0,import_react2.useCallback)(()=>{f==null||f(),_==null||_()},[_,f]);return(0,import_jsx_runtime.jsx)(RefreshComponentProvider,{refresh:v,children:(0,import_jsx_runtime.jsx)(FilterBlockProvider,{children:(0,import_jsx_runtime.jsx)(GridContext.Provider,{value:h,children:(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)("nb-grid-container"),children:(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`nb-grid ${d} ${p}`),ref:r,children:(0,import_jsx_runtime.jsxs)("div",{className:"nb-grid-warp",children:[(0,import_jsx_runtime.jsxs)(DndWrapper,{dndContext:e.dndContext,children:[o?(0,import_jsx_runtime.jsx)(RowDivider,{rows:u,first:!0,id:`${c}_0`,data:getRowDividerData(n,"afterBegin")}):null,u.map((S,C)=>(0,import_jsx_runtime.jsxs)(import_react2.default.Fragment,{children:[g?(0,import_jsx_runtime.jsx)(SchemaComponent,{name:S.name,schema:S,distributed:!0}):(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{name:S.name,schema:S,isUseFormilyField:!0}),o?(0,import_jsx_runtime.jsx)(RowDivider,{rows:u,index:C,id:`${c}_${C+1}`,data:getRowDividerData(S,"afterEnd")}):null]},C))]}),a()]})})})})})})},{displayName:"Grid"});Grid.Row=(0,import_react.observer)(()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),o=e.address.toString(),r=useColProperties(),{showDivider:i}=useGridContext(),n=(0,import_react2.useMemo)(()=>({schema:t,cols:r}),[t,r]);return(0,import_jsx_runtime.jsx)(GridRowContext.Provider,{value:n,children:(0,import_jsx_runtime.jsxs)("div",{className:(0,import_classnames.default)("nb-grid-row","CardRow",{showDivider:i}),children:[i&&(0,import_jsx_runtime.jsx)(ColDivider,{cols:r,first:!0,id:`${o}_0`,data:{breakRemoveOn:breakRemoveOnRow,wrapSchema:wrapColSchema,insertAdjacent:"afterBegin",schema:t}}),r.map((a,l)=>(0,import_jsx_runtime.jsxs)(import_react2.default.Fragment,{children:[(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{name:a.name,schema:a,isUseFormilyField:!0}),i&&(0,import_jsx_runtime.jsx)(ColDivider,{cols:r,index:l,last:l===r.length-1,id:`${o}_${l+1}`,data:{breakRemoveOn:breakRemoveOnRow,wrapSchema:wrapColSchema,insertAdjacent:"afterEnd",schema:a}})]},l))]})})},{displayName:"Grid.Row"});Grid.Col=(0,import_react.observer)(e=>{const{cols:t=[]}=(0,import_react2.useContext)(GridRowContext),{showDivider:o}=useGridContext(),r=(0,import_react.useFieldSchema)(),i=(0,import_react.useField)(),{token:n}=useToken(),{designable:a}=useDesignable(),l=(0,import_react2.useMemo)(()=>{var f;let _="";return t!=null&&t.length&&(_=`calc(${((f=r==null?void 0:r["x-component-props"])==null?void 0:f.width)||100/t.length}% - ${n.marginBlock}px * ${(o?t.length+1:0)/t.length})`),{width:_}},[t.length,r,o,n.marginBlock]),{isOver:c,setNodeRef:u}=(0,import_core.useDroppable)({id:i.address.toString(),data:{insertAdjacent:"beforeEnd",schema:r,wrapSchema:f=>f},disabled:!a}),[m,d]=(0,import_react2.useState)(!1),p=(0,import_react2.useMemo)(()=>c?{background:`linear-gradient(to top, ${new import_tinycolor.TinyColor(n.colorSettings).setAlpha(.1).toHex8String()} 20%, transparent 20%)`,borderTopRightRadius:"10px",borderTopLeftRadius:"10px",height:"100%"}:{height:"100%"},[m,c]);(0,import_core.useDndMonitor)({onDragStart(f){a&&d(!0)},onDragMove(f){},onDragOver(f){},onDragEnd(f){a&&d(!1)},onDragCancel(f){a&&d(!1)}});const g=(0,import_react2.useMemo)(()=>({cols:t,schema:r}),[t,r]),h=(0,import_react2.useMemo)(()=>x(x({},l),p),[p,l]);return(0,import_jsx_runtime.jsx)(GridColContext.Provider,{value:g,children:(0,import_jsx_runtime.jsx)("div",{ref:u,style:h,className:(0,import_classnames.default)("nb-grid-col"),children:e.children})})},{displayName:"Grid.Col"});Grid.wrap=e=>({type:"void","x-component":"Grid.Row",properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"Grid.Col",properties:{[e.name||(0,import_shared.uid)()]:e}}}});const TableColumnSchemaToolbar=import_react2.default.memo(e=>(0,import_jsx_runtime.jsx)(GridRowContext.Provider,{value:null,children:(0,import_jsx_runtime.jsx)(SchemaToolbar,x({initializer:e.initializer||!1,showBorder:!1,showBackground:!0},import_lodash.default.omit(e,"initializer")))}));TableColumnSchemaToolbar.displayName="TableColumnSchemaToolbar";const useTableBlockProps=()=>{var e,t,o,r,i,n;const a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)(),c=useDataBlockResource(),u=useDataBlockRequest(),{getDataBlocks:m}=useFilterBlock(),d=useTableBlockContextBasicValue(),p=(0,import_react2.useRef)(null);p.current={service:u,resource:c};const g=((e=u==null?void 0:u.data)==null?void 0:e.meta)||{},h=useTableElementRef(),f=(0,import_react2.useCallback)(()=>{var S;h!=null&&h.current&&((S=h.current.parentElement)==null||S.scrollIntoView({block:"start"}))},[h]),_=(0,import_react2.useMemo)(()=>({pageSize:g==null?void 0:g.pageSize,total:g==null?void 0:g.count,current:g==null?void 0:g.page,onChange:f}),[g==null?void 0:g.count,g==null?void 0:g.page,g==null?void 0:g.pageSize,f]),v=((t=u==null?void 0:u.data)==null?void 0:t.data)||[];return(0,import_react2.useEffect)(()=>{var S,C;if(!(u!=null&&u.loading)){const b=(C=(S=d.field)==null?void 0:S.data)==null?void 0:C.selectedRowKeys;a.data=a.data||{},(0,import_lodash.isEqual)(a.data.selectedRowKeys,b)||(a.data.selectedRowKeys=b)}},[a,u==null?void 0:u.data,u==null?void 0:u.loading,(r=(o=d.field)==null?void 0:o.data)==null?void 0:r.selectedRowKeys]),{value:v,childrenColumnName:d.childrenColumnName,loading:u==null?void 0:u.loading,showIndex:d.showIndex,dragSort:d.dragSort&&d.dragSortBy,rowKey:d.rowKey||((i=l==null?void 0:l["x-component-props"])==null?void 0:i.rowKey)||"id",pagination:((n=l==null?void 0:l["x-component-props"])==null?void 0:n.pagination)===!1?!1:_,onRowSelectionChange:(0,import_react2.useCallback)((S,C)=>{var b,y,F;d&&(d.field.data=((b=d.field)==null?void 0:b.data)||{},d.field.data.selectedRowKeys=S,d.field.data.selectedRowData=C,(F=(y=d.field)==null?void 0:y.onRowSelect)==null||F.call(y,S))},[]),onRowDragEnd:(0,import_react2.useCallback)(S=>q(void 0,[S],function*({from:C,to:b}){yield p.current.resource.move({sourceId:C[d.rowKey||"id"],targetId:b[d.rowKey||"id"],sortField:d.dragSort&&d.dragSortBy}),p.current.service.refresh()}),[d.rowKey,d.dragSort,d.dragSortBy]),onChange:(0,import_react2.useCallback)(({current:S,pageSize:C},b,y)=>{var F,j,k,T,O,N,L,D,R,$;const w=(k=(j=(F=l.parent)==null?void 0:F["x-decorator-props"])==null?void 0:j.params)==null?void 0:k.sort,I=y.order?y.order==="ascend"?[y.field]:[`-${y.field}`]:w||d.dragSortBy,M=C||((N=(O=(T=l.parent)==null?void 0:T["x-decorator-props"])==null?void 0:O.params)==null?void 0:N.pageSize),B=P(x({},(R=(D=(L=p.current)==null?void 0:L.service)==null?void 0:D.params)==null?void 0:R[0]),{page:S||1,pageSize:M});I&&(B.sort=I),($=p.current)==null||$.service.run(B)},[l.parent]),onClickRow:(0,import_react2.useCallback)((S,C,b)=>{const{targets:y,uid:F}=findFilterTargets(l),j=m();if(!y||!y.some(T=>j.some(O=>O.uid===T.uid))){C(T=>T.length?[]:T);return}const k=j.find(T=>T.uid===l.parent["x-uid"]);j.forEach(T=>{var O,N,L;const D=y.find(B=>B.uid===T.uid);if(!D)return;const R=getSourceKey(k,D.field)||d.rowKey||"id",$=[S[R]],w=((O=T.service.params)==null?void 0:O[0])||{},I=((L=(N=T.service.params)==null?void 0:N[1])==null?void 0:L.filters)||{};if(b.includes(S[d.rowKey])){if(T.dataLoadingMode==="manual")return T.clearData();delete I[F]}else I[F]={$and:[{[D.field||d.rowKey]:{[D.field?"$in":"$eq"]:$}}]};const M=mergeFilter([...Object.values(I).map(B=>removeNullCondition(B)),T.defaultFilter]);return T.doFilter(P(x({},w),{page:1,filter:M}),{filters:I})}),C(T=>T!=null&&T.includes(S[d.rowKey])?[]:[S[d.rowKey]])},[d.rowKey,l,m]),onExpand:(0,import_react2.useCallback)((S,C)=>{var b,y;(y=(b=d.field).onExpandClick)==null||y.call(b,S,C)},[])}};function getSourceKey(e,t){var o,r,i;const n=(o=e==null?void 0:e.associatedFields)==null?void 0:o.find(a=>a.foreignKey===t);return(n==null?void 0:n.sourceKey)||((i=(r=t==null?void 0:t.split)==null?void 0:r.call(t,"."))==null?void 0:i[1])}const CollapseItemSchemaToolbar=e=>(0,import_jsx_runtime.jsx)(SchemaToolbar,x({initializer:!1},e));function useCollapseBlockDecoratorProps(){}function useFilterFormBlockDecoratorProps(){}function useFilterFormBlockProps(){return useFormBlockProps$1()}const NOOP=()=>{},CollectOperatorsContext=(0,import_react2.createContext)(null),CollectOperators=e=>{const t=(0,import_react2.useRef)(e.defaultOperators||{}),o=(0,import_react2.useCallback)((a,l)=>{t.current[a]=l},[]),r=(0,import_react2.useCallback)(()=>x({},t.current),[]),i=(0,import_react2.useCallback)(a=>t.current[a],[]),n=(0,import_react2.useCallback)(a=>{delete t.current[a]},[]);return(0,import_jsx_runtime.jsx)(CollectOperatorsContext.Provider,{value:{collectOperator:o,getOperators:r,getOperator:i,removeOperator:n},children:e.children})},useOperators=()=>{const{getOperator:e=NOOP,getOperators:t=NOOP,collectOperator:o=NOOP,removeOperator:r=NOOP}=import_react2.default.useContext(CollectOperatorsContext)||{};return{getOperator:e,getOperators:t,collectOperator:o,removeOperator:r}},useCollectOperator=()=>{const e=(0,import_react.useFieldSchema)(),{collectOperator:t,removeOperator:o}=useOperators();(0,import_react2.useEffect)(()=>()=>{o(e.name)},[e.name,o]),e["x-filter-operator"]&&t(e.name,e["x-filter-operator"])},useFormItemProps=()=>{useCollectOperator()},isPatternDisabled=e=>{var t;return((t=e==null?void 0:e["x-component-props"])==null?void 0:t["pattern-disable"])==!0},DefaultValueContext=import_react2.default.createContext(null),DefaultValueProvider=e=>{const t=(0,import_react2.useMemo)(()=>({isAllowToSetDefaultValue:e.isAllowToSetDefaultValue}),[e.isAllowToSetDefaultValue]);return(0,import_jsx_runtime.jsx)(DefaultValueContext.Provider,{value:t,children:e.children})},useIsAllowToSetDefaultValue=({form:e,fieldSchema:t,collectionField:o}={})=>{const r=useDataSourceManager(),i=useCollectionManager(),n=useCollection(),{form:a}=useFormBlockContext(),l=(0,import_react.useFieldSchema)(),{type:c}=useFormBlockType(),{isAllowToSetDefaultValue:u=_isAllowToSetDefaultValue}=(0,import_react2.useContext)(DefaultValueContext)||{};return{isAllowToSetDefaultValue:(0,import_react2.useCallback)(m=>{const d=n.getField(l.name)||i.getCollectionField(l["x-collection-field"]);return u({collectionField:o||d,getInterface:r==null?void 0:r.collectionFieldInterfaceManager.getFieldInterface.bind(r==null?void 0:r.collectionFieldInterfaceManager),form:e||a,formBlockType:c,fieldSchema:t||l,isSubTableColumn:m})},[i,n,o,r==null?void 0:r.collectionFieldInterfaceManager,t,e,l,a,u,c])}},interfacesOfUnsupportedDefaultValue=["o2o","oho","obo","o2m","attachment","expression","point","lineString","circle","polygon","sequence","formula"];function _isAllowToSetDefaultValue({collectionField:e,getInterface:t,formBlockType:o,form:r,fieldSchema:i,isSubTableColumn:n}){var a;return n?!interfacesOfUnsupportedDefaultValue.includes(e==null?void 0:e.interface)&&!isSystemField(e,t):!e||e.target&&(a=i["x-component-props"])!=null&&a.mode&&!["Picker","Select"].includes(i["x-component-props"].mode)||o!=="create"?!1:!(r!=null&&r.readPretty)&&!isPatternDisabled(i)&&!interfacesOfUnsupportedDefaultValue.includes(e==null?void 0:e.interface)&&!isSystemField(e,t)}const setFieldProps$1=(e,t,o)=>{(0,import_reactive.untracked)(()=>{e[t]===void 0&&(e[t]=o)})},setRequired$1=(e,t,o)=>{typeof t.required>"u"&&(e.required=!!o.required)},FilterCollectionFieldInternalField=e=>{var t,o,r,i;const n=useCompile(),a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)(),{getInterface:c}=useCollectionManager_deprecated(),{uiSchema:u,defaultValue:m,interface:d}=useCollectionField(),{isAllowToSetDefaultValue:p}=useIsAllowToSetDefaultValue(),g=c(d),h=(o=(t=g==null?void 0:g.filterable)==null?void 0:t.operators)==null?void 0:o.find((S,C)=>S.value===l["x-filter-operator"]||C===0),f=useComponent(((r=h==null?void 0:h.schema)==null?void 0:r["x-component"])||((i=l["x-component-props"])==null?void 0:i.component)||(u==null?void 0:u["x-component"])||"Input"),_=useFormBlockContext(),v=useDynamicComponentProps(u==null?void 0:u["x-use-component-props"],e);return(0,import_react2.useEffect)(()=>{var S;if(!u)return;const C=n(u);if(setFieldProps$1(a,"content",C["x-content"]),setFieldProps$1(a,"title",C.title),setFieldProps$1(a,"description",C.description),_!=null&&_.form){const y=p()?l.default||m:void 0;y!=null&&setFieldProps$1(a,"initialValue",y)}if(!a.validator&&(C["x-validator"]||l["x-validator"])){const y=(0,import_lodash.concat)([],C["x-validator"]||[],l["x-validator"]||[]);a.validator=y}l["x-disabled"]===!0&&(a.disabled=!0),l["x-read-pretty"]===!0&&(a.readPretty=!0),setRequired$1(a,l,C),a.dataSource=C.enum;const b=n(x(x({},((S=h==null?void 0:h.schema)==null?void 0:S["x-component-props"])||{}),C["x-component-props"]||{}))||{};a.componentProps=(0,import_shared.merge)(b,a.componentProps||{},v||{})},[u]),u?(0,import_jsx_runtime.jsx)(f,x(x({},e),v)):null},FilterCollectionField=(0,import_react.connect)(e=>{const t=(0,import_react.useFieldSchema)();return(0,import_react.useField)(),(0,import_jsx_runtime.jsx)(import_react_error_boundary.ErrorBoundary,{FallbackComponent:ErrorFallback.Modal,onError:o=>console.log(o),children:(0,import_jsx_runtime.jsx)(CollectionFieldProvider,{name:t.name,children:(0,import_jsx_runtime.jsx)(FilterCollectionFieldInternalField,x({},e))})})});FilterCollectionField.displayName="FilterCollectionField";const FilterFormBlockProvider=withDynamicSchemaProps(e=>{const t=(0,import_react.useFieldSchema)()["x-filter-operators"]||{};return(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{components:{CollectionField:FilterCollectionField},children:(0,import_jsx_runtime.jsx)(CollectOperators,{defaultOperators:t,children:(0,import_jsx_runtime.jsx)(DatePickerProvider,{value:{utc:!1},children:(0,import_jsx_runtime.jsx)(ActionBarProvider,{forceProps:{style:{overflowX:"auto",maxWidth:"100%",float:"right"}},children:(0,import_jsx_runtime.jsx)(DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:(0,import_jsx_runtime.jsx)(FormBlockProvider,x({name:"filter-form"},e))})})})})})}),FormFieldContext=(0,import_react2.createContext)({});FormFieldContext.displayName="FormFieldContext";const InternalFormFieldProvider=e=>{var t,o,r;const{action:i,readPretty:n,fieldName:a}=e,l=useFormBlockContext(),c=useCollectionParentRecordData();(t=l==null?void 0:l.updateAssociationValues)!=null&&t.includes(a)||(o=l==null?void 0:l.updateAssociationValues)==null||o.push(a);const u=(0,import_react.useField)(),m=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)({effects(){(0,import_core2.onFormValuesChange)(g=>{var h;(h=l==null?void 0:l.form)==null||h.setValuesIn(a,g.values)})},readPretty:n}),[]);(0,import_react2.useEffect)(()=>(0,import_reactive.autorun)(()=>{var g;const h=((g=l==null?void 0:l.form)==null?void 0:g.values[a])||{};m.reset(),(0,import_client.forEach)(h,(f,_)=>{f&&(m.values[_]=f)})}),[]);const{resource:d,service:p}=useBlockRequestContext();return p.loading?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(0,import_jsx_runtime.jsx)(RecordProvider,{record:(r=p==null?void 0:p.data)==null?void 0:r.data,parent:c,children:(0,import_jsx_runtime.jsx)(FormFieldContext.Provider,{value:{action:i,form:m,field:u,service:p,resource:d,fieldName:a},children:e.children})})},WithoutFormFieldResource=(0,import_react2.createContext)(null);WithoutFormFieldResource.displayName="WithoutFormFieldResource";const FormFieldProvider=e=>(0,import_jsx_runtime.jsx)(WithoutFormFieldResource.Provider,{value:!1,children:(0,import_jsx_runtime.jsx)(BlockProvider,P(x({name:"form-field",block:"FormField"},e),{children:(0,import_jsx_runtime.jsx)(InternalFormFieldProvider,x({},e))}))}),useFormFieldContext=()=>(0,import_react2.useContext)(FormFieldContext),useFormFieldProps=()=>{const e=useFormFieldContext();return(0,import_react2.useEffect)(()=>{var t,o,r;(r=e==null?void 0:e.form)==null||r.setInitialValues((o=(t=e.service)==null?void 0:t.data)==null?void 0:o.data)},[]),{form:e.form}},TableFieldContext=(0,import_react2.createContext)({});TableFieldContext.displayName="TableFieldContext";const InternalTableFieldProvider=e=>{var t,o;const{params:r={},showIndex:i,dragSort:n,fieldName:a}=e,l=(0,import_react.useField)(),c=(0,import_react.useFieldSchema)(),{resource:u,service:m}=useBlockRequestContext(),d=useFormBlockContext(),p=useFormFieldContext(),g=p&&p.fieldName?`${p.fieldName}.${a}`:a;return(t=d==null?void 0:d.updateAssociationValues)!=null&&t.includes(g)||(o=d==null?void 0:d.updateAssociationValues)==null||o.push(g),(0,import_jsx_runtime.jsx)(TableFieldContext.Provider,{value:{field:l,fieldSchema:c,service:m,resource:u,params:r,showIndex:i,dragSort:n},children:e.children})};class TableFieldResource{constructor(t){A(this,"field"),A(this,"api"),A(this,"sourceId"),A(this,"resource"),this.field=t.field,this.api=t.api,this.sourceId=t.sourceId,this.resource=this.api.resource(t.resource,this.sourceId)}list(t){return q(this,null,function*(){if(this.field.data=this.field.data||{},this.field.data.changed)return console.log("list.dataSource",this.field.data.dataSource),{data:{data:this.field.data.dataSource}};if(!this.sourceId)return console.log("list.sourceId",this.field.data.dataSource),this.field.data.dataSource=[],{data:{data:[]}};const o=yield this.resource.list(t);return console.log("list",o),this.field.data.dataSource=o.data.data,{data:{data:o.data.data}}})}get(t){return q(this,null,function*(){console.log("get",t);const{filterByTk:o}=t;return{data:{data:this.field.data.dataSource[o]}}})}create(t){return q(this,null,function*(){console.log("create",t);const{values:o}=t;this.field.data.dataSource.push(o),this.field.data.changed=!0})}update(t){return q(this,null,function*(){console.log("update",t);const{filterByTk:o,values:r}=t;this.field.data.dataSource[o]=r,this.field.data.changed=!0})}destroy(t){return q(this,null,function*(){console.log("destroy",t);let{filterByTk:o}=t;Array.isArray(o)||(o=[o]),this.field.data.dataSource=this.field.data.dataSource.filter((r,i)=>!o.includes(i)),this.field.data.changed=!0})}}const WithoutTableFieldResource=(0,import_react2.createContext)(null);WithoutTableFieldResource.displayName="WithoutTableFieldResource";const TableFieldProvider=e=>(0,import_jsx_runtime.jsx)(WithoutTableFieldResource.Provider,{value:!1,children:(0,import_jsx_runtime.jsx)(BlockProvider,P(x({name:"table-field",block:"TableField"},e),{children:(0,import_jsx_runtime.jsx)(InternalTableFieldProvider,x({},e))}))}),useTableFieldContext=()=>(0,import_react2.useContext)(TableFieldContext),useTableFieldProps=()=>{var e,t,o,r,i,n,a,l;const c=(0,import_react.useField)(),u=useTableFieldContext();return(0,import_react2.useEffect)(()=>{var m,d,p,g,h;(m=u==null?void 0:u.service)!=null&&m.loading||(c.value=(p=(d=u==null?void 0:u.service)==null?void 0:d.data)==null?void 0:p.data,c.data=c.data||{},c.data.selectedRowKeys=(h=(g=u==null?void 0:u.field)==null?void 0:g.data)==null?void 0:h.selectedRowKeys)},[(t=(e=u==null?void 0:u.field)==null?void 0:e.data)==null?void 0:t.selectedRowKeys,(r=(o=u==null?void 0:u.service)==null?void 0:o.data)==null?void 0:r.data,(i=u==null?void 0:u.service)==null?void 0:i.loading,c]),{size:"middle",loading:(n=u==null?void 0:u.service)==null?void 0:n.loading,showIndex:u.showIndex,dragSort:u.dragSort,pagination:!1,required:(l=(a=u==null?void 0:u.fieldSchema)==null?void 0:a.parent)==null?void 0:l.required,rowKey:m=>{var d,p;return(p=(d=c.value)==null?void 0:d.indexOf)==null?void 0:p.call(d,m)},onRowSelectionChange(m,d){var p;u.field.data=((p=u==null?void 0:u.field)==null?void 0:p.data)||{},u.field.data.selectedRowKeys=m,u.field.data.selectedRowData=d},onChange({current:m,pageSize:d}){u.service.run({page:m,pageSize:d})}}},TableSelectorContext=(0,import_react2.createContext)({});TableSelectorContext.displayName="TableSelectorContext";const TableSelectorParamsContext=(0,import_react2.createContext)({});TableSelectorParamsContext.displayName="TableSelectorParamsContext";const useTableSelectorParams=()=>(0,import_react2.useContext)(TableSelectorParamsContext),TableSelectorParamsProvider=({params:e,children:t})=>{const o=useTableSelectorParams();try{e.filter=mergeFilter([o.filter,e.filter]),e=x(x({},o),e)}catch(r){console.error(r)}return(0,import_jsx_runtime.jsx)(TableSelectorParamsContext.Provider,{value:e,children:t})},InternalTableSelectorProvider=e=>{const{params:t,rowKey:o,extraFilter:r,expandFlag:i=!1}=e,n=(0,import_react.useField)(),{resource:a,service:l}=useBlockRequestContext(),[c,u]=(0,import_react2.useState)(i),m=useCollectionParentRecordData();return(0,import_jsx_runtime.jsx)(RecordProvider,{record:{},parent:m,children:(0,import_jsx_runtime.jsx)(TableSelectorContext.Provider,{value:{field:n,service:l,resource:a,params:t,extraFilter:r,rowKey:o,expandFlag:c,setExpandFlag:()=>{u(!c)}},children:e.children})})},recursiveParent$1=(e,t)=>e["x-component"]===t?e:e.parent&&(e==null?void 0:e["x-component"])!=="AssociationField.Viewer"?recursiveParent$1(e.parent,t):null,useAssociationNames$1=e=>{const{getCollectionFields:t}=useCollectionManager_deprecated(),o=t(e),r=new Set;for(const n of o)if(n.target){r.add(n.name);const a=t(n.target);for(const l of a)l.target&&r.add(`${n.name}.${l.name}`)}const i=(0,import_react.useFieldSchema)().reduceProperties((n,a)=>a["x-component"]==="TableV2.Selector"?a:n,new import_react.Schema({}));return(0,import_uniq.default)(i.reduceProperties((n,a)=>{if(a["x-component"]==="TableV2.Column"){const l=a.reduceProperties((c,u)=>{const[m]=u.name.split(".");return u["x-collection-field"]&&r.has(m)?u:c},null);if(l){const[c]=l.name.split(".");r.has(l.name)?n.push(l.name):r.has(c)&&n.push(c)}}return n},[]))},TableSelectorProvider=withDynamicSchemaProps(e=>{var t;const o=useTableSelectorParams(),r=(0,import_react.useFieldSchema)(),{getCollectionJoinField:i,getCollectionFields:n}=useCollectionManager_deprecated(),a=useRecord(),{getCollection:l}=useCollectionManager_deprecated(),{treeTable:c}=(r==null?void 0:r["x-decorator-props"])||{},u=recursiveParent$1(r,"CollectionField"),m=i(u==null?void 0:u["x-collection-field"]),d=l(m==null?void 0:m.collectionName),p=d==null?void 0:d.getPrimaryKey(),g=useAssociationNames$1(e.collection);let h=x({},e.params);e.dragSort&&(h.sort=["sort"]),(m==null?void 0:m.target)===(m==null?void 0:m.collectionName)&&d!=null&&d.tree&&c&&(h.tree=!0,u.name==="parent"&&(h.filter=P(x({},(t=h.filter)!=null?t:{}),{id:a[p]&&{$ne:a[p]}}))),Object.keys(h).includes("appends")||(h.appends=g);let f;if(m&&(["oho","o2m"].includes(m.interface)&&!isInFilterFormBlock(r)&&(a!=null&&a[m.sourceKey]?f={$or:[{[m.foreignKey]:{$is:null}},{[m.foreignKey]:{$eq:a==null?void 0:a[m.sourceKey]}}]}:f={[m.foreignKey]:{$is:null}}),["obo"].includes(m.interface)&&!isInFilterFormBlock(r))){const S=n(m.target).find(C=>C.foreignKey&&C.foreignKey===m.foreignKey);S&&(a!=null&&a[m.foreignKey]?f={$or:[{[`${S.name}.${S.foreignKey}`]:{$is:null}},{[`${S.name}.${S.foreignKey}`]:{$eq:a==null?void 0:a[m.foreignKey]}}]}:f={[`${S.name}.${S.foreignKey}`]:{$is:null}})}f&&(h!=null&&h.filter?h.filter={$and:[f,h.filter]}:h.filter=f);try{h.filter=mergeFilter([o.filter,h.filter]),h=x(x({},o),h)}catch(S){console.error(S)}const{filter:_,parseVariableLoading:v}=useParsedFilter({filterOption:h==null?void 0:h.filter});return!import_lodash.default.isEmpty(h==null?void 0:h.filter)&&import_lodash.default.isEmpty(_)||v?null:(h!=null&&h.filter&&(h.filter=_),(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{scope:{treeTable:c},children:(0,import_jsx_runtime.jsx)(BlockProvider,P(x({name:"table-selector"},e),{params:h,children:(0,import_jsx_runtime.jsx)(InternalTableSelectorProvider,P(x({},e),{params:h,extraFilter:f}))}))}))}),useTableSelectorContext=()=>(0,import_react2.useContext)(TableSelectorContext),useTableSelectorProps$4=()=>{var e,t,o,r,i,n,a,l,c,u,m,d,p,g,h,f;const _=(0,import_react.useField)(),v=useTableSelectorContext(),S=(0,import_react.useFieldSchema)(),{getCollectionJoinField:C}=useCollectionManager_deprecated(),b=recursiveParent$1(S,"CollectionField"),y=C(b==null?void 0:b["x-collection-field"]);return(0,import_react2.useEffect)(()=>{var F,j,k,T,O,N,L,D,R,$,w,I,M;if(!((F=v==null?void 0:v.service)!=null&&F.loading)){const B=(k=(j=v==null?void 0:v.service)==null?void 0:j.data)==null?void 0:k.data.map(z=>z);_.value=B,(T=_==null?void 0:_.setInitialValue)==null||T.call(_,B),_.data=_.data||{},_.data.selectedRowKeys=[],_.componentProps.pagination=_.componentProps.pagination||{},_.componentProps.pagination.pageSize=(L=(N=(O=v==null?void 0:v.service)==null?void 0:O.data)==null?void 0:N.meta)==null?void 0:L.pageSize,_.componentProps.pagination.total=($=(R=(D=v==null?void 0:v.service)==null?void 0:D.data)==null?void 0:R.meta)==null?void 0:$.count,_.componentProps.pagination.current=(M=(I=(w=v==null?void 0:v.service)==null?void 0:w.data)==null?void 0:I.meta)==null?void 0:M.page}},[y==null?void 0:y.foreignKey,(t=(e=v==null?void 0:v.field)==null?void 0:e.data)==null?void 0:t.selectedRowKeys,(r=(o=v==null?void 0:v.service)==null?void 0:o.data)==null?void 0:r.data,(a=(n=(i=v==null?void 0:v.service)==null?void 0:i.data)==null?void 0:n.meta)==null?void 0:a.count,(u=(c=(l=v==null?void 0:v.service)==null?void 0:l.data)==null?void 0:c.meta)==null?void 0:u.page,(p=(d=(m=v==null?void 0:v.service)==null?void 0:m.data)==null?void 0:d.meta)==null?void 0:p.pageSize,(g=v==null?void 0:v.service)==null?void 0:g.loading,_]),{loading:(h=v==null?void 0:v.service)==null?void 0:h.loading,showIndex:!1,dragSort:!1,rowKey:v.rowKey||"id",pagination:((f=S==null?void 0:S["x-component-props"])==null?void 0:f.pagination)===!1?!1:_.componentProps.pagination,onRowSelectionChange(F,j){var k;v.field.data=((k=v==null?void 0:v.field)==null?void 0:k.data)||{},v.field.data.selectedRowKeys=F,v.field.data.selectedRowData=j},onRowDragEnd(F){return q(this,arguments,function*({from:j,to:k}){yield v.resource.move({sourceId:j[v.rowKey||"id"],targetId:k[v.rowKey||"id"]}),v.service.refresh()})},onChange({current:F,pageSize:j}){var k;v.service.run(P(x({},(k=v.service.params)==null?void 0:k[0]),{page:F,pageSize:j}))}}},BlockSchemaComponentProvider=e=>(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{components:{TableFieldProvider,TableBlockProvider,TableSelectorProvider,FormBlockProvider,FilterFormBlockProvider,FormFieldProvider,DetailsBlockProvider,RecordLink,Slider:import_antd.Slider},scope:P(x({},bp),{useSourceIdFromRecord,useSourceIdFromParentRecord,useParamsFromRecord,useFormBlockProps:useFormBlockProps$1,useCreateFormBlockProps,useCreateFormBlockDecoratorProps,useEditFormBlockDecoratorProps,useEditFormBlockProps,useFormFieldProps,useDetailsBlockProps,useDetailsProps,useDetailsWithPaginationProps,useDetailsDecoratorProps,useDetailsWithPaginationDecoratorProps,useTableFieldProps,useTableBlockProps,useTableSelectorProps:useTableSelectorProps$4,useTableBlockDecoratorProps,useListBlockDecoratorProps,useTableSelectorDecoratorProps,useCollapseBlockDecoratorProps,useFilterFormBlockProps,useFilterFormBlockDecoratorProps,useGridCardBlockDecoratorProps,useFormItemProps,useDataFormItemProps}),children:e.children});class BlockSchemaComponentPlugin extends Plugin{load(){return q(this,null,function*(){this.addComponents(),this.addScopes()})}addComponents(){this.app.addComponents({TableFieldProvider,TableBlockProvider,TableSelectorProvider,FormBlockProvider,FilterFormBlockProvider,FormFieldProvider,DetailsBlockProvider,RecordLink,BlockSchemaToolbar,ActionSchemaToolbar,FormItemSchemaToolbar,CollapseItemSchemaToolbar,TableColumnSchemaToolbar,Slider:import_antd.Slider})}addScopes(){this.app.addScopes(P(x({},bp),{useSourceIdFromRecord,useSourceIdFromParentRecord,useParamsFromRecord,useFormBlockProps:useFormBlockProps$1,useCreateFormBlockProps,useCreateFormBlockDecoratorProps,useEditFormBlockDecoratorProps,useEditFormBlockProps,useFormFieldProps,useDetailsBlockProps,useDetailsProps,useDetailsWithPaginationProps,useDetailsDecoratorProps,useDetailsWithPaginationDecoratorProps,useTableFieldProps,useTableBlockProps,useTableSelectorProps:useTableSelectorProps$4,useTableBlockDecoratorProps,useListBlockDecoratorProps,useTableSelectorDecoratorProps,useCollapseBlockDecoratorProps,useFilterFormBlockProps,useFilterFormBlockDecoratorProps,useGridCardBlockDecoratorProps,useFormItemProps,useDataFormItemProps}))}}const BlockTemplate=(0,import_react.observer)(e=>{const{templateId:t}=e,{getTemplateById:o}=useSchemaTemplateManager(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n}=useDesignable(),a=(0,import_react2.useMemo)(()=>o(t),[t]),{onTemplateSuccess:l}=useTemplateBlockContext(),c=u=>{var m,d;i["x-linkage-rules"]=((m=u==null?void 0:u.data)==null?void 0:m["x-linkage-rules"])||[],i.setProperties((d=u==null?void 0:u.data)==null?void 0:d.properties),l==null||l()};return a?(0,import_jsx_runtime.jsx)(BlockTemplateProvider,{dn:n,field:r,fieldSchema:i,template:a,children:(0,import_jsx_runtime.jsx)(RemoteSchemaComponent,{noForm:!0,uid:a==null?void 0:a.uid,onSuccess:c})}):(0,import_jsx_runtime.jsx)(CollectionDeletedPlaceholder,{type:"Block template",name:t})},{displayName:"BlockTemplate"}),SchemaTemplateManagerContext=(0,import_react2.createContext)({});SchemaTemplateManagerContext.displayName="SchemaTemplateManagerContext";const regenerateUid=e=>{e.name=e["x-uid"]=(0,import_shared.uid)(),Object.keys(e.properties||{}).forEach(t=>{regenerateUid(e.properties[t])})},useSchemaTemplate=()=>{const{getTemplateBySchema:e}=useSchemaTemplateManager(),t=(0,import_react.useFieldSchema)(),o=t["x-uid"],r=t["x-template-key"];return(0,import_react2.useMemo)(()=>e(t),[o,r])},useSchemaTemplateManager=()=>{const{getInheritCollections:e}=useCollectionManager_deprecated(),{refresh:t,templates:o=[]}=(0,import_react2.useContext)(SchemaTemplateManagerContext),r=useAPIClient();return{templates:o,refresh:t,getTemplateSchemaByMode:(0,import_react2.useCallback)(i=>q(void 0,null,function*(){const{mode:n,template:a}=i;if(n==="copy"){const{data:l}=yield r.request({url:`/uiSchemas:getJsonSchema/${a.uid}?includeAsyncNode=true`}),c=(l==null?void 0:l.data)||{};return regenerateUid(c),(0,import_lodash.cloneDeep)(c)}else if(n==="reference")return{type:"void","x-component":"BlockTemplate","x-component-props":{templateId:a.key}}}),[r]),copyTemplateSchema:(0,import_react2.useCallback)(i=>q(void 0,null,function*(){const{data:n}=yield r.request({url:`/uiSchemas:getJsonSchema/${i.uid}?includeAsyncNode=true`}),a=(n==null?void 0:n.data)||{};return regenerateUid(a),(0,import_lodash.cloneDeep)(a)}),[r]),saveAsTemplate:(0,import_react2.useCallback)(i=>q(void 0,null,function*(){const{uid:n}=i,a=(0,import_shared.uid)();return yield r.resource("uiSchemas").saveAsTemplate({filterByTk:n,values:x({key:a},i)}),yield t(),{key:a}}),[r,t]),getTemplateBySchema:(0,import_react2.useCallback)(i=>{if(!i)return;const n=i["x-template-key"];if(n)return o==null?void 0:o.find(l=>l.key===n);const a=i["x-uid"];if(a)return o==null?void 0:o.find(l=>l.uid===a)},[o]),getTemplateBySchemaId:(0,import_react2.useCallback)(i=>i?o==null?void 0:o.find(n=>n.uid===i):null,[o]),getTemplateById:(0,import_react2.useCallback)(i=>o==null?void 0:o.find(n=>n.key===i),[o]),getTemplatesByCollection:(0,import_react2.useCallback)((i,n)=>{var a;const l=e(n,i).concat([n]);return((a=o==null?void 0:o.filter)==null?void 0:a.call(o,c=>(c.dataSourceKey||DEFAULT_DATA_SOURCE_KEY)===i&&l.includes(c.collectionName)))||[]},[e,o]),getTemplatesByComponentName:(0,import_react2.useCallback)(i=>{var n;return((n=o==null?void 0:o.filter)==null?void 0:n.call(o,a=>a.componentName===i))||[]},[o])}},options={resource:"uiSchemaTemplates",action:"list",params:{paginate:!1},refreshDeps:[]},RemoteSchemaTemplateManagerProvider=e=>{var t;const o=useAPIClient(),r=useRequest(options),i=(0,import_react2.useCallback)(()=>q(void 0,null,function*(){const{data:a}=yield o.request(options);r.mutate(a)}),[o,r]),n=(0,import_react2.useMemo)(()=>{var a;return{templates:(a=r==null?void 0:r.data)==null?void 0:a.data,refresh:i}},[(t=r==null?void 0:r.data)==null?void 0:t.data,i]);return(0,import_jsx_runtime.jsx)(SchemaTemplateManagerContext.Provider,{value:n,children:e.children})};class RemoteSchemaTemplateManagerPlugin extends Plugin{load(){return q(this,null,function*(){this.addRoutes(),this.addComponents()})}addComponents(){this.app.addComponents({BlockTemplate})}addRoutes(){this.app.router.add("admin.plugins.block-templates-key",{path:"/admin/plugins/block-templates/:key",Component:"BlockTemplateDetails"})}}const useUpdateSchemaTemplateActionProps=()=>{const e=useUpdateActionProps(),{__parent:t}=useBlockRequestContext();return{onClick(){return q(this,null,function*(){var o,r;yield e.onClick(),(r=(o=t==null?void 0:t.service)==null?void 0:o.refresh)==null||r.call(o)})}}},useBulkDestroyTemplateProps=()=>{const e=useBulkDestroyActionProps(),t=useSchemaTemplateManager(),{service:o}=useBlockRequestContext();return{onClick(){return q(this,null,function*(){var r;yield e.onClick(),yield t.refresh(),(r=o==null?void 0:o.refresh)==null||r.call(o)})}}},useDestroyTemplateProps=()=>{const e=useDestroyActionProps(),{service:t}=useBlockRequestContext(),o=useSchemaTemplateManager();return{onClick(){return q(this,null,function*(){var r;yield e.onClick(),yield o.refresh(),(r=t==null?void 0:t.refresh)==null||r.call(t)})}}},uiSchemaTemplatesSchema={type:"object",properties:{[(0,import_shared.uid)()]:{type:"void","x-decorator":"TableBlockProvider","x-decorator-props":{collection:uiSchemaTemplatesCollection,resource:"uiSchemaTemplates",action:"list",params:{pageSize:20,sort:["-createdAt"]},rowKey:"key",showIndex:!0,dragSort:!1},"x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action","x-use-component-props":useBulkDestroyTemplateProps,"x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}},[(0,import_shared.uid)()]:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowSelection:{type:"checkbox"}},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined",refreshDataBlockRequest:!1},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{form:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"uiSchemaTemplates",collection:uiSchemaTemplatesCollection,action:"get",useParams:"{{ useParamsFromRecord }}"},"x-component":"CardItem",properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"uiSchemaTemplates.name",required:!0},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":useUpdateSchemaTemplateActionProps,"x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}}}}}}}}},destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":useDestroyTemplateProps,"x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}},column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-collection-field":"uiSchemaTemplates.name","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},column2:{type:"void",title:'{{t("Collection display name")}}',"x-component":"TableV2.Column",properties:{"collection.title":{type:"string","x-component":CollectionTitle,"x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}}}}}}}},BlockTemplatePage=()=>{const{t:e}=(0,import_react_i18next.useTranslation)();return(0,import_jsx_runtime.jsxs)("div",{children:[(0,import_jsx_runtime.jsx)(import_pro_layout.PageHeader,{style:{backgroundColor:"white"},ghost:!1,title:e("Block templates")}),(0,import_jsx_runtime.jsx)("div",{style:{margin:"var(--nb-spacing)"},children:(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:uiSchemaTemplatesSchema})})]})},BlockTemplatesPane=()=>(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:uiSchemaTemplatesSchema}),BlockTemplateContext=(0,import_react2.createContext)({componentNamePrefix:""}),BlockTemplateProvider=e=>(0,import_jsx_runtime.jsx)(BlockTemplateContext.Provider,{value:P(x({},e),{componentNamePrefix:e.componentNamePrefix||""}),children:e.children}),useBlockTemplateContext=()=>(0,import_react2.useContext)(BlockTemplateContext),itemsMerge=e=>e,gridRowColWrap=e=>({type:"void","x-component":"Grid.Row",properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"Grid.Col",properties:{[(e==null?void 0:e.name)||(0,import_shared.uid)()]:e}}}}),removeTableColumn=(e,t)=>{t(e.parent)},removeGridFormItem=(e,t)=>{t(e,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})},useRemoveGridFormItem=()=>{const e=(0,import_react.useForm)();return(t,o)=>{var r;o(t,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}),(r=e.values)==null||delete r[t.name]}},findTableColumn=(e,t,o,r)=>e.reduceProperties((i,n)=>n[t]===o&&(!r||n.name===r)?n:n.reduceProperties((l,c)=>c[t]===o&&(!r||c.name===r)?c:l)||i),quickEditField$1=["attachment","textarea","markdown","json","richText","polygon","circle","point","lineString"];function useTableColumnInitializerFields(){const{name:e,currentFields:t=[]}=useCollection_deprecated(),{getInterface:o,getCollection:r}=useCollectionManager_deprecated(),i=(0,import_react.useFieldSchema)()["x-component"]==="AssociationField.SubTable",n=(0,import_react.useForm)(),a=i?n.readPretty:!0;return t.filter(l=>!l.collectionName||l.collectionName===e).filter(l=>(l==null?void 0:l.interface)&&(l==null?void 0:l.interface)!=="subTable"&&!(l!=null&&l.treeChildren)).map(l=>{var c,u,m,d;const p=o(l.interface),g=(l==null?void 0:l.target)&&((c=r(l==null?void 0:l.target))==null?void 0:c.template)==="file",h=((u=l==null?void 0:l.uiSchema)==null?void 0:u["x-component"])==="Preview",f={name:l.name,"x-collection-field":`${e}.${l.name}`,"x-component":"CollectionField","x-component-props":g?{fieldNames:{label:"preview",value:"id"}}:h?{size:"small"}:{},"x-read-pretty":a||((m=l.uiSchema)==null?void 0:m["x-read-pretty"]),"x-decorator":i?quickEditField$1.includes(l.interface)||g?"QuickEdit":"FormItem":null,"x-decorator-props":{labelStyle:{display:"none"}}};return{type:"item",name:l.name,title:((d=l==null?void 0:l.uiSchema)==null?void 0:d.title)||l.name,Component:"TableCollectionFieldInitializer",find:findTableColumn,remove:removeTableColumn,schemaInitialize:_=>{var v;(v=p==null?void 0:p.schemaInitialize)==null||v.call(p,_,{field:l,readPretty:a,block:"Table",targetCollection:r(l.target)})},field:l,schema:f}})}function useAssociatedTableColumnInitializerFields(){var e;const{fields:t}=useCollection_deprecated(),{t:o}=(0,import_react_i18next.useTranslation)(),{getInterface:r,getCollectionFields:i,getCollection:n}=useCollectionManager_deprecated();return(e=t==null?void 0:t.filter(a=>["o2o","oho","obo","m2o"].includes(a.interface)))==null?void 0:e.map(a=>getGroupItemForTable({getCollectionFields:i,field:a,getInterface:r,getCollection:n,schemaName:a.name,maxDepth:2,depth:1,t:o}))}function getGroupItemForTable({getCollectionFields:e,field:t,getInterface:o,getCollection:r,schemaName:i,maxDepth:n,depth:a,t:l}){var c,u;const m=e(t.target),d=(c=m==null?void 0:m.filter(g=>(g==null?void 0:g.interface)&&!["subTable"].includes(g==null?void 0:g.interface)&&!(g!=null&&g.treeChildren)))==null?void 0:c.map(g=>{var h;const f=o(g.interface),_=`${i}.${g.name}`,v={name:_,"x-component":"CollectionField","x-read-pretty":!0,"x-collection-field":`${t.target}.${g.name}`,"x-component-props":{}};return{type:"item",name:_,title:((h=g==null?void 0:g.uiSchema)==null?void 0:h.title)||g.name,Component:"TableCollectionFieldInitializer",find:findTableColumn,remove:removeTableColumn,schemaInitialize:S=>{var C;(C=f==null?void 0:f.schemaInitialize)==null||C.call(f,S,{field:g,readPretty:!0,block:"Table",targetCollection:r(t.target)})},field:g,schema:v}}),p=[{type:"itemGroup",name:`${i}-displayCollectionFields`,title:l("Display fields"),children:d}];if(a<n){const g=m==null?void 0:m.filter(h=>["o2o","oho","obo","m2o"].includes(h.interface)).map(h=>getGroupItemForTable({getCollectionFields:e,field:h,getInterface:o,getCollection:r,schemaName:`${i}.${h.name}`,maxDepth:n,depth:a+1,t:l}));if(g.length){const h={type:"itemGroup",name:`${i}-associationFields`,title:l("Display association fields"),children:g};p.push(h)}}return{type:"subMenu",name:`${i}`,title:(u=t.uiSchema)==null?void 0:u.title,children:p}}function useInheritsTableColumnInitializerFields(){const{name:e}=useCollection_deprecated(),{getInterface:t,getInheritCollections:o,getCollection:r,getParentCollectionFields:i}=useCollectionManager_deprecated(),n=(0,import_react.useFieldSchema)()["x-component"]==="AssociationField.SubTable",a=(0,import_react.useForm)(),l=n?a.readPretty:!0,c=o(e);return c==null?void 0:c.map(u=>{const m=i(u,e),d=r(u);return{[d==null?void 0:d.title]:m==null?void 0:m.filter(p=>p==null?void 0:p.interface).map(p=>{var g,h,f,_;const v=t(p.interface),S=(p==null?void 0:p.target)&&((g=r(p==null?void 0:p.target))==null?void 0:g.template)==="file",C={name:`${p.name}`,"x-component":"CollectionField","x-read-pretty":l||((h=p.uiSchema)==null?void 0:h["x-read-pretty"]),"x-collection-field":`${e}.${p.name}`,"x-component-props":S?{fieldNames:{label:"preview",value:"id"}}:{},"x-decorator":n?quickEditField$1.includes(p.interface)||S?"QuickEdit":"FormItem":null,"x-decorator-props":{labelStyle:{display:"none"}}};return{name:((f=p==null?void 0:p.uiSchema)==null?void 0:f.title)||p.name,type:"item",title:((_=p==null?void 0:p.uiSchema)==null?void 0:_.title)||p.name,Component:"TableCollectionFieldInitializer",find:findTableColumn,remove:removeTableColumn,schemaInitialize:b=>{var y;(y=v==null?void 0:v.schemaInitialize)==null||y.call(v,b,{field:p,readPretty:!0,block:"Table",targetCollection:r(p==null?void 0:p.target)})},field:p,schema:C}})}})}const useFormItemInitializerFields=e=>{var t,o;const{name:r,currentFields:i}=useCollection_deprecated(),{getInterface:n,getCollection:a}=useCollectionManager_deprecated(),l=(0,import_react.useForm)(),{readPretty:c=l.readPretty,block:u="Form"}=e||{},{fieldSchema:m}=useActionContext(),d=m==null?void 0:m["x-action"];return(o=(t=i.filter(p=>!p.collectionName||p.collectionName===r))==null?void 0:t.filter(p=>(p==null?void 0:p.interface)&&!(p!=null&&p.treeChildren)))==null?void 0:o.map(p=>{var g,h,f,_,v;const S=n(p.interface),C=a(p.target),b=(p==null?void 0:p.target)&&((g=a(p==null?void 0:p.target))==null?void 0:g.template)==="file",y=C,F=(f=(h=p==null?void 0:p.uiSchema)==null?void 0:h["x-component-props"])==null?void 0:f.fieldNames,j={type:"string",name:p.name,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":`${r}.${p.name}`,"x-component-props":b?{fieldNames:{label:"preview",value:"id"}}:y&&F?{fieldNames:P(x({},F),{label:(C==null?void 0:C.titleField)||F.label})}:{},"x-read-pretty":(_=p==null?void 0:p.uiSchema)==null?void 0:_["x-read-pretty"]},k={type:"item",name:p.name,title:((v=p==null?void 0:p.uiSchema)==null?void 0:v.title)||p.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schemaInitialize:T=>{var O;(O=S==null?void 0:S.schemaInitialize)==null||O.call(S,T,{field:p,block:u,readPretty:c,action:d,targetCollection:C})},schema:j};return u=="Kanban"&&(k.find=(T,O,N)=>{const L=findSchema(T,"x-component",u);return findSchema(L,O,N)}),k})},useFilterFormItemInitializerFields=e=>{var t,o;const{name:r,currentFields:i}=useCollection_deprecated(),{getInterface:n,getCollection:a}=useCollectionManager_deprecated(),l=(0,import_react.useForm)(),{readPretty:c=l.readPretty,block:u="FilterForm"}=e||{},{snapshot:m,fieldSchema:d}=useActionContext(),p=d==null?void 0:d["x-action"];return(o=(t=i.filter(g=>!g.collectionName||g.collectionName===r))==null?void 0:t.filter(g=>{var h;return(g==null?void 0:g.interface)&&((h=n(g.interface))==null?void 0:h.filterable)}))==null?void 0:o.map(g=>{var h,f,_;const v=n(g.interface),S=a(g.target);let C={type:"string",name:g.name,required:!1,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FilterFormItem","x-component":"CollectionField","x-decorator":"FormItem","x-use-decorator-props":"useFormItemProps","x-collection-field":`${r}.${g.name}`,"x-component-props":{utc:!1,underFilter:!0}};return isAssocField(g)&&(C={type:"string",name:`${g.name}`,required:!1,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FilterFormItem","x-component":"CollectionField","x-decorator":"FormItem","x-use-decorator-props":"useFormItemProps","x-collection-field":`${r}.${g.name}`,"x-component-props":P(x({},(h=g.uiSchema)==null?void 0:h["x-component-props"]),{utc:!1,underFilter:!0})}),{name:((f=g==null?void 0:g.uiSchema)==null?void 0:f.title)||g.name,type:"item",title:((_=g==null?void 0:g.uiSchema)==null?void 0:_.title)||g.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schemaInitialize:b=>{var y;(y=v==null?void 0:v.schemaInitialize)==null||y.call(v,b,{field:g,block:u,readPretty:c,action:p,targetCollection:S})},schema:C}})},useAssociatedFormItemInitializerFields=e=>{var t;const{name:o,fields:r}=useCollection_deprecated(),{getInterface:i,getCollectionFields:n,getCollection:a}=useCollectionManager_deprecated(),l=(0,import_react.useForm)(),{t:c}=(0,import_react_i18next.useTranslation)(),{readPretty:u=l.readPretty,block:m="Form"}=e||{},d=m==="Form"?["m2o","obo","oho"]:["o2o","oho","obo","m2o"];return(t=r==null?void 0:r.filter(p=>d.includes(p.interface)))==null?void 0:t.map(p=>getGroupItemForForm({getCollectionFields:n,field:p,getInterface:i,getCollection:a,readPretty:u,block:m,schemaName:p.name,maxDepth:2,depth:1,t:c}))},associationFieldToMenu=(e,t,o,r,i)=>{var n,a,l;if(e.target&&e.uiSchema){if(i.includes(e.target)||i.length>=1)return;const u=r(e.target);return u!=null&&u.length?{type:"subMenu",name:t,title:(n=e.uiSchema)==null?void 0:n.title,children:u.map(m=>associationFieldToMenu(m,`${t}.${m.name}`,o,r,[...i,e.target])).filter(Boolean)}:void 0}if(!e.uiSchema)return;const c={type:"string",name:t,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FilterFormItem","x-designer-props":{interface:e.interface},"x-component":"CollectionField","x-component-props":{utc:!1,underFilter:!0},"x-read-pretty":!1,"x-decorator":"FormItem","x-collection-field":`${o}.${t}`};return{name:((a=e.uiSchema)==null?void 0:a.title)||e.name,type:"item",title:((l=e.uiSchema)==null?void 0:l.title)||e.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schema:c}},useFilterAssociatedFormItemInitializerFields=()=>{const{name:e,fields:t}=useCollection_deprecated(),{getCollectionFields:o}=useCollectionManager_deprecated(),r=["o2o","oho","obo","m2o","m2m"];return t==null?void 0:t.filter(i=>i.target&&i.uiSchema&&r.includes(i.interface)).map(i=>associationFieldToMenu(i,i.name,e,o,[])).filter(Boolean)},useInheritsFormItemInitializerFields=e=>{const{name:t}=useCollection_deprecated(),{getInterface:o,getInheritCollections:r,getCollection:i,getParentCollectionFields:n}=useCollectionManager_deprecated(),a=r(t);useActionContext();const l=(0,import_react.useForm)();return a==null?void 0:a.map(c=>{var u;const m=n(c,t),{readPretty:d=l.readPretty,block:p="Form",component:g="CollectionField"}=e||{},h=i(c);return{[h==null?void 0:h.title]:(u=m==null?void 0:m.filter(f=>f==null?void 0:f.interface))==null?void 0:u.map(f=>{var _,v,S,C;const b=o(f.interface),y=i(f.target),F={type:"string",name:f.name,title:((_=f==null?void 0:f.uiSchema)==null?void 0:_.title)||f.name,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem","x-component":g,"x-decorator":"FormItem","x-collection-field":`${t}.${f.name}`,"x-component-props":{},"x-read-pretty":(v=f==null?void 0:f.uiSchema)==null?void 0:v["x-read-pretty"]};return{name:((S=f==null?void 0:f.uiSchema)==null?void 0:S.title)||f.name,type:"item",title:((C=f==null?void 0:f.uiSchema)==null?void 0:C.title)||f.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schemaInitialize:j=>{var k;(k=b==null?void 0:b.schemaInitialize)==null||k.call(b,j,{field:f,block:p,readPretty:d,targetCollection:y})},schema:F}})}})},useFilterInheritsFormItemInitializerFields=e=>{const{name:t}=useCollection_deprecated(),{getInterface:o,getInheritCollections:r,getCollection:i,getParentCollectionFields:n}=useCollectionManager_deprecated(),a=r(t);useActionContext();const l=(0,import_react.useForm)();return a==null?void 0:a.map(c=>{var u;const m=n(c,t),{readPretty:d=l.readPretty,block:p="Form"}={};return{[i(c).title]:(u=m==null?void 0:m.filter(g=>{var h;return(g==null?void 0:g.interface)&&((h=o(g.interface))==null?void 0:h.filterable)}))==null?void 0:u.map(g=>{var h,f,_,v;const S=o(g.interface),C=i(g.target),b={type:"string",name:g.name,title:((h=g==null?void 0:g.uiSchema)==null?void 0:h.title)||g.name,required:!1,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FilterFormItem","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":`${t}.${g.name}`,"x-component-props":{utc:!1,underFilter:!0},"x-read-pretty":(f=g==null?void 0:g.uiSchema)==null?void 0:f["x-read-pretty"]};return{name:((_=g==null?void 0:g.uiSchema)==null?void 0:_.title)||g.name,type:"item",title:((v=g==null?void 0:g.uiSchema)==null?void 0:v.title)||g.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schemaInitialize:y=>{var F;(F=S==null?void 0:S.schemaInitialize)==null||F.call(S,y,{field:g,block:p,readPretty:d,targetCollection:C})},schema:b}})}})},useCustomFormItemInitializerFields=e=>{var t;const{name:o,currentFields:r}=useCollection_deprecated(),{getInterface:i,getCollection:n}=useCollectionManager_deprecated(),a=(0,import_react.useForm)(),{readPretty:l=a.readPretty,block:c="Form"}=e||{},u=useRemoveGridFormItem();return(t=r==null?void 0:r.filter(m=>(m==null?void 0:m.interface)&&m.interface!=="snapshot"&&m.type!=="sequence"))==null?void 0:t.map(m=>{var d,p,g;const h=i(m.interface),f={type:"string",name:m.name,title:((d=m==null?void 0:m.uiSchema)==null?void 0:d.title)||m.name,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem","x-component":"AssignedField","x-decorator":"FormItem","x-collection-field":`${o}.${m.name}`};return{name:((p=m==null?void 0:m.uiSchema)==null?void 0:p.title)||m.name,type:"item",title:((g=m==null?void 0:m.uiSchema)==null?void 0:g.title)||m.name,Component:"CollectionFieldInitializer",remove:u,schemaInitialize:_=>{var v;(v=h==null?void 0:h.schemaInitialize)==null||v.call(h,_,{field:m,block:c,readPretty:l,targetCollection:n(m.target)})},schema:f}})},findSchema=(e,t,o,r)=>import_react.Schema.isSchemaInstance(e)?e.reduceProperties((i,n)=>{if(n[t]===o&&(!r||n.name===r))return n;if(n["x-component"]!=="Action.Container"&&!n["x-component"].includes("AssociationField")){const a=findSchema(n,t,o,r);if(a)return a}return i}):null,removeSchema=(e,t)=>t(e),recursiveParent=e=>e.parent?e.parent["x-initializer"]?e.parent:recursiveParent(e.parent):null,useCurrentSchema=(e,t,o=findSchema,r=removeSchema,i)=>{const{removeActiveFieldName:n}=useFormActiveFields()||{},{form:a}=useFormBlockContext();let l=(0,import_react.useFieldSchema)();if(!(l!=null&&l["x-initializer"])&&(l==null?void 0:l["x-decorator"])==="FormItem"){const m=recursiveParent(l);m&&(l=m)}const{remove:c}=useDesignable(),u=o(l,t,e,i);return{schema:u,exists:!!u,remove(){n==null||n(u.name),a==null||a.query(new RegExp(`${u.parent.name}.${u.name}$`)).forEach(m=>{var d,p;(d=m.setValue)==null||d.call(m,void 0),(p=m.setInitialValue)==null||p.call(m,void 0)}),u&&r(u,c)}}},useRecordCollectionDataSourceItems=(e,t=null,o=null,r=null)=>{const{t:i}=(0,import_react_i18next.useTranslation)(),n=useCollection_deprecated(),{getTemplatesByCollection:a}=useSchemaTemplateManager(),l=a(n.dataSource,o||n.name).filter(u=>e&&u.componentName===e).filter(u=>["FormItem","ReadPrettyFormItem"].includes(e)||u.resourceName===r);if(!l.length)return[];const c=0;return[{key:`${o||e}_table_blank`,type:"item",name:n.name,title:i("Blank block"),item:t},{type:"divider"},{key:`${o||e}_table_subMenu_${c}_copy`,type:"subMenu",name:"copy",title:i("Duplicate template"),children:l.map(u=>{const m=["FormItem","ReadPrettyFormItem"].includes(u==null?void 0:u.componentName)?`${u==null?void 0:u.name} ${i("(Fields only)")}`:u==null?void 0:u.name;return{type:"item",mode:"copy",name:n.name,template:u,item:t,title:m||i("Untitled")}})},{key:`${o||e}_table_subMenu_${c}_ref`,type:"subMenu",name:"ref",title:i("Reference template"),children:l.map(u=>{const m=["FormItem","ReadPrettyFormItem"].includes(u==null?void 0:u.componentName)?`${u==null?void 0:u.name} ${i("(Fields only)")}`:u==null?void 0:u.name;return{type:"item",mode:"reference",name:n.name,template:u,item:t,title:m||i("Untitled")}})}]},useCollectionDataSourceItems=({name:e,componentName:t,filter:o=()=>!0,onlyCurrentDataSource:r=!1,showAssociationFields:i,filterDataSource:n,dataBlockInitializerProps:a,hideOtherRecordsInPopup:l,onClick:c,filterOtherRecordsCollection:u,currentText:m,otherText:d})=>{const{componentNamePrefix:p}=useBlockTemplateContext(),{t:g}=(0,import_react_i18next.useTranslation)(),h=useDataSourceManager(),f=useDataSourceKey(),_=useCollection(),v=useAssociationFields({componentName:p+t,filterCollections:o,showAssociationFields:i,componentNamePrefix:p}),S=useAssociationName();let C=h.getAllCollections({filterCollection:F=>r&&F.dataSource!==f?!1:o({collection:F}),filterDataSource:n});r&&(C=C.filter(F=>F.key===f));const{getTemplatesByCollection:b}=useSchemaTemplateManager(),y=(0,import_react2.useMemo)(()=>C.map(({key:F,displayName:j,collections:k})=>({name:F,label:j,type:"subMenu",children:[...getChildren$1({name:e,association:S,collections:k,componentName:p+t,searchValue:"",dataSource:F,getTemplatesByCollection:b,t:g,componentNamePrefix:p}).sort(T=>{const O=import_lodash.default.toArray((_==null?void 0:_.inherits)||[]);if(T.name===(_==null?void 0:_.name)||O.some(N=>N===T.name))return-1})]})),[C,_==null?void 0:_.inherits,_==null?void 0:_.name,t,b,g]);return i?(0,import_react2.useMemo)(()=>{var F;const j={name:"currentRecord",collectionName:_.name,dataSource:_.dataSource,Component:DataBlockInitializer,onClick(){},componentProps:P(x({},a),{icon:null,title:m||g("Current record"),name:"currentRecord",hideSearch:!1,hideChildrenIfSingleCollection:!0,items:y})},k={name:"associationRecords",Component:DataBlockInitializer,onClick(){},componentProps:P(x({},a),{icon:null,title:g("Associated records"),name:"associationRecords",hideSearch:!1,items:[{name:"associationFields",label:g("Association fields"),type:"subMenu",children:v}]})},T={ReadPrettyFormItem:"Details"},O={name:"otherRecords",Component:DataBlockInitializer,onClick(){},componentProps:P(x({},a),{hideSearch:!1,icon:null,title:d||g("Other records"),name:"otherRecords",showAssociationFields:!1,onlyCurrentDataSource:!1,hideChildrenIfSingleCollection:!1,fromOthersInPopup:!0,componentType:T[t]||t,filter({collection:D,associationField:R}){return u?u(D):!0},onClick(D){c(P(x({},D),{fromOthersInPopup:!0}))}})};let N;const L=v.length?k:null;if(y[0].children.length&&v.length)l?N=[j,L]:N=[j,L,O];else if(y[0].children.length)if(l){if(y[0].children.length<=1)return y[0].children=((F=y[0].children[0])==null?void 0:F.children)||[],y;N=[j]}else N=[j,O];else l?N=[L]:N=[L,O];return[{name:"records",label:g("Records"),type:"subMenu",children:N.filter(Boolean)}]},[v,_.dataSource,_.name,t,a,u,l,y,c,g]):y},createDetailsBlockSchema=e=>{const t=e,{formItemInitializers:o="details:configureFields",actionInitializers:r="detailsWithPaging:configureActions",collection:i,dataSource:n,association:a,template:l,settings:c,action:u="list"}=t,m=K(t,["formItemInitializers","actionInitializers","collection","dataSource","association","template","settings","action"]),d=a||i;return{type:"void","x-acl-action":u==="get"?`${d}:get`:`${d}:view`,"x-decorator":"DetailsBlockProvider","x-decorator-props":x(x({dataSource:n,collection:i,association:a,readPretty:!0,action:u},u==="list"?{params:{pageSize:1}}:{}),m),"x-toolbar":"BlockSchemaToolbar","x-settings":c,"x-component":"CardItem",properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"Details","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:x({[(0,import_shared.uid)()]:{type:"void","x-initializer":r,"x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{}},grid:l||{type:"void","x-component":"Grid","x-initializer":o,properties:{}}},u==="list"?{pagination:{type:"void","x-component":"Pagination","x-use-component-props":"useDetailsPaginationProps"}}:{})}}}},createFormBlockSchema=e=>{const t=e,{formItemInitializers:o="form:configureFields",actionInitializers:r="createForm:configureActions",collection:i,resource:n,dataSource:a,association:l,action:c,actions:u={},"x-designer":m="FormV2.Designer",template:d,title:p,settings:g}=t,h=K(t,["formItemInitializers","actionInitializers","collection","resource","dataSource","association","action","actions","x-designer","template","title","settings"]),f=n||l||i;return P(x({type:"void","x-acl-action-props":{skipScopeCheck:!c},"x-acl-action":c?`${f}:update`:`${f}:create`,"x-decorator":"FormBlockProvider","x-decorator-props":P(x({},h),{action:c,dataSource:a,resource:f,collection:i,association:l}),"x-toolbar":"BlockSchemaToolbar"},g?{"x-settings":g}:{"x-designer":m}),{"x-component":"CardItem","x-component-props":{title:p},properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{grid:d||{type:"void","x-component":"Grid","x-initializer":o,properties:{}},[(0,import_shared.uid)()]:{type:"void","x-initializer":r,"x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:u}}}}})},createReadPrettyFormBlockSchema=e=>{const t=e,{formItemInitializers:o="details:configureFields",actionInitializers:r="details:configureActions",collection:i,association:n,dataSource:a,resource:l,template:c,settings:u}=t,m=K(t,["formItemInitializers","actionInitializers","collection","association","dataSource","resource","template","settings"]),d=l||n||i;return{type:"void","x-acl-action":`${d}:get`,"x-decorator":"FormBlockProvider","x-decorator-props":x({resource:d,collection:i,association:n,dataSource:a,readPretty:!0,action:"get",useParams:"{{ useParamsFromRecord }}"},m),"x-toolbar":"BlockSchemaToolbar","x-settings":u,"x-component":"CardItem",properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps","x-read-pretty":!0,properties:{[(0,import_shared.uid)()]:{type:"void","x-initializer":r,"x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{}},grid:c||{type:"void","x-component":"Grid","x-initializer":o,properties:{}}}}}}},createTableBlockSchema=e=>{const t=e,{collection:o,rowKey:r,tableActionInitializers:i,tableColumnInitializers:n,tableActionColumnInitializers:a,tableBlockProvider:l,disableTemplate:c,dataSource:u,blockType:m,pageSize:d=20}=t,p=K(t,["collection","rowKey","tableActionInitializers","tableColumnInitializers","tableActionColumnInitializers","tableBlockProvider","disableTemplate","dataSource","blockType","pageSize"]);return{type:"void","x-decorator":l??"TableBlockProvider","x-acl-action":`${o}:list`,"x-decorator-props":x({collection:o,dataSource:u,action:"list",params:{pageSize:d},rowKey:r,showIndex:!0,dragSort:!1,disableTemplate:c??!1,blockType:m},p),"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":i??"table:configureActions","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{}},[(0,import_shared.uid)()]:{type:"array","x-initializer":n??"table:configureColumns","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-designer":"TableV2.ActionColumnDesigner","x-initializer":a??"table:configureItemActions",properties:{[(0,import_shared.uid)()]:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{},properties:{}}}}}}}}},getChildren$1=({name:e,association:t,collections:o,dataSource:r,componentName:i,searchValue:n,getTemplatesByCollection:a,t:l,componentNamePrefix:c})=>{var u;return(u=o==null?void 0:o.filter(m=>{if(m.inherit)return!1;if(m.filterTargetKey){if([c+"Kanban",c+"FormItem"].includes(i)&&(m.template==="view"&&!m.writableView||m.template==="sql")||m.template==="file"&&[c+"Kanban",c+"FormItem",c+"Calendar"].includes(i))return!1;{const d=m.title||m.tableName;return d?d.toUpperCase().includes(n.toUpperCase())&&!(m!=null&&m.isThrough&&m!=null&&m.autoCreate):!1}}else return!1}))==null?void 0:u.map((m,d)=>{const p=m.title||m.tableName||m.label,g=a(r,m.name).filter(h=>{var f;const _=e!=="otherRecords"&&t;return _?h.resourceName!==t?!1:i&&h.componentName===i:!_&&(f=h==null?void 0:h.resourceName)!=null&&f.includes(".")?!1:i&&h.componentName===i});return g.length?{key:`${i}_table_subMenu_${d}`,type:"subMenu",name:`${m.name}_${d}`,title:p,dataSource:r,children:[{type:"item",name:m.name,dataSource:r,title:l("Blank block")},{type:"divider"},{key:`${i}_table_subMenu_${d}_copy`,type:"subMenu",name:"copy",dataSource:r,title:l("Duplicate template"),children:g.map(h=>{const f=[c+"FormItem",c+"ReadPrettyFormItem"].includes(h==null?void 0:h.componentName)?`${h==null?void 0:h.name} ${l("(Fields only)")}`:h==null?void 0:h.name;return{type:"item",mode:"copy",name:m.name,template:h,dataSource:r,title:f||l("Untitled")}})},{key:`${i}_table_subMenu_${d}_ref`,type:"subMenu",name:"ref",dataSource:r,title:l("Reference template"),children:g.map(h=>{const f=[c+"FormItem",c+"ReadPrettyFormItem"].includes(h==null?void 0:h.componentName)?`${h==null?void 0:h.name} ${l("(Fields only)")}`:h==null?void 0:h.name;return{type:"item",mode:"reference",name:m.name,template:h,dataSource:r,title:f||l("Untitled")}})}]}:{type:"item",name:m.name,title:p,dataSource:r}})};function getGroupItemForForm({getCollectionFields:e,field:t,getInterface:o,getCollection:r,readPretty:i,block:n,maxDepth:a,depth:l,schemaName:c,t:u}){var m,d;const p=e(t.target),g=(m=p==null?void 0:p.filter(f=>(f==null?void 0:f.interface)&&!["subTable"].includes(f==null?void 0:f.interface)&&!f.treeChildren))==null?void 0:m.map(f=>{var _,v;const S=o(f.interface),C=(t==null?void 0:t.target)&&((_=r(t==null?void 0:t.target))==null?void 0:_.template)==="file",b=`${c}.${f.name}`,y={type:"string",name:b,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem","x-component":"CollectionField","x-read-pretty":i,"x-component-props":{"pattern-disable":n==="Form"&&i,fieldNames:C?{label:"preview",value:"id"}:void 0},"x-decorator":"FormItem","x-collection-field":`${t.target}.${f.name}`};return{name:b,type:"item",title:((v=f==null?void 0:f.uiSchema)==null?void 0:v.title)||f.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schemaInitialize:F=>{var j;(j=S==null?void 0:S.schemaInitialize)==null||j.call(S,F,{field:f,block:n,readPretty:i,targetCollection:r(t.target)})},schema:y}}),h=[{type:"itemGroup",name:`${c}-displayCollectionFields`,title:u("Display fields"),children:g}];if(l<a){const f=p==null?void 0:p.filter(_=>["o2o","oho","obo","m2o"].includes(_.interface)).map(_=>getGroupItemForForm({getCollectionFields:e,field:_,getInterface:o,getCollection:r,schemaName:`${c}.${_.name}`,readPretty:i,block:n,maxDepth:a,depth:l+1,t:u}));if(f.length){const _={type:"itemGroup",name:`${c}-associationFields`,title:u("Display association fields"),children:f};h.push(_)}}return{type:"subMenu",name:`${c}.${t.name}`,title:(d=t.uiSchema)==null?void 0:d.title,children:h}}function useAssociationFields({componentName:e,filterCollections:t,showAssociationFields:o,componentNamePrefix:r}){const i=(0,import_react.useFieldSchema)(),{getCollectionFields:n}=useCollectionManager_deprecated(),a=useCollection_deprecated();useCollectionManager();const l=useDataSourceKey(),{getTemplatesByCollection:c}=useSchemaTemplateManager(),{t:u}=(0,import_react_i18next.useTranslation)(),m=useCompile();return(0,import_react2.useMemo)(()=>{if(!o)return[];let d=[];if(i["x-initializer"])d=a.fields;else{const p=recursiveParent(i.parent);p&&(d=n(p))}return d.filter(p=>["linkTo","subTable","o2m","m2m","obo","oho","o2o","m2o"].includes(p.interface)).filter(p=>t({associationField:p})).map((p,g)=>{const h=m(p.uiSchema.title||p.name),f=c(l,p.target).filter(_=>_.resourceName!==`${p.collectionName}.${p.name}`?!1:e===r+"ReadPrettyFormItem"?["hasOne","belongsTo"].includes(p.type)?_.componentName===r+"ReadPrettyFormItem":_.componentName===r+"Details":_.componentName===e);return f.length?{key:`associationFiled_${e}_table_subMenu_${g}`,type:"subMenu",name:`${p.target}_${g}`,title:h,dataSource:l,children:[{type:"item",name:`${p.collectionName}.${p.name}`,collectionName:p.target,dataSource:l,title:u("Blank block"),associationField:p},{type:"divider"},{key:`associationFiled_${e}_table_subMenu_${g}_copy`,type:"subMenu",name:"copy",dataSource:l,title:u("Duplicate template"),children:f.map(_=>{const v=[r+"FormItem",r+"ReadPrettyFormItem"].includes(_==null?void 0:_.componentName)?`${_==null?void 0:_.name} ${u("(Fields only)")}`:_==null?void 0:_.name;return{type:"item",mode:"copy",name:`${p.collectionName}.${p.name}`,collectionName:p.target,template:_,dataSource:l,title:v||u("Untitled"),associationField:p}})},{key:`associationFiled_${e}_table_subMenu_${g}_ref`,type:"subMenu",name:"ref",dataSource:l,title:u("Reference template"),children:f.map(_=>{const v=[r+"FormItem",r+"ReadPrettyFormItem"].includes(_==null?void 0:_.componentName)?`${_==null?void 0:_.name} ${u("(Fields only)")}`:_==null?void 0:_.name;return{type:"item",mode:"reference",name:`${p.collectionName}.${p.name}`,collectionName:p.target,template:_,dataSource:l,title:v||u("Untitled"),associationField:p}})}]}:{type:"item",name:`${p.collectionName}.${p.name}`,collectionName:p.target,title:h,dataSource:l,associationField:p}})},[a.fields,m,e,l,i,t,n,c,o,u,r])}const useGetAriaLabelOfDesigner=()=>{const e=(0,import_react.useFieldSchema)(),{name:t}=useCollection_deprecated();return{getAriaLabel:(0,import_react2.useCallback)((o,r)=>{if(!e)return"";const i=e["x-component"],n=typeof i=="string"?i:(i==null?void 0:i.displayName)||(i==null?void 0:i.name),a=e["x-designer"]?`-${e["x-designer"]}`:"",l=e["x-settings"]?`-${e["x-settings"]}`:"",c=e["x-collection-field"]?`-${e["x-collection-field"]}`:"",u=t?`-${t}`:"";return r=r?`-${r}`:"",`designer-${o}-${n}${a}${l}${u}${c}${r}`},[e,t])}},useStyles$f=genStyleHook("nb-schema-toolbar",e=>{const{componentCls:t}=e;return{[t]:{position:"absolute",zIndex:999,top:0,left:0,right:0,bottom:0,border:"2px solid var(--colorBorderSettingsHover)",background:"var(--colorBgSettingsHover)",pointerEvents:"none","&.hidden":{transform:"scale(0)",pointerEvents:"none"},"&.hidden-e2e":{display:"none"},".ant-space-item .anticon":{margin:0},".toolbar-title":{pointerEvents:"none",position:"absolute",fontSize:12,padding:0,lineHeight:"16px",height:"16px",borderBottomRightRadius:2,borderRadius:2,top:2,left:2},".toolbar-title-tag":{padding:"0 3px",borderRadius:2,background:"var(--colorSettings)",color:"#fff",display:"block"},".toolbar-icons":{position:"absolute",right:"2px",top:"2px",lineHeight:"16px",pointerEvents:"all",".ant-space-item":{backgroundColor:"var(--colorSettings)",color:"#fff",lineHeight:"16px",width:"16px",paddingLeft:"1px",alignSelf:"stretch"}}}}}),titleCss=import_css.css`
256
+ `),footer:C?(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:p.address,schema:d,onlyRenderProperties:!0,filterProperties:y=>y["x-component"]===o}):!1,children:(0,import_jsx_runtime.jsx)(ActionModalContent,{footerNodeName:o,field:p,schema:d})}))}))})})},{displayName:"ActionModal"}),ActionModal=e=>(0,import_jsx_runtime.jsx)(import_react_error_boundary.ErrorBoundary,{FallbackComponent:ModalErrorFallback,onError:console.log,children:(0,import_jsx_runtime.jsx)(InternalActionModal,x({},e))});ActionModal.Footer=(0,import_react.observer)(()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)();return(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:e.address,schema:t,onlyRenderProperties:!0})},{displayName:"ActionModal.Footer"});const CurrentPopupRecordContext=import_react2.default.createContext(null),CurrentParentPopupRecordContext=import_react2.default.createContext(null),VariablePopupRecordProvider=import_react2.default.memo(e=>{var t,o;const{t:r}=(0,import_react_i18next.useTranslation)(),i=useCollectionRecordData(),n=useCollection(),a=useCurrentPopupRecord();return(0,import_jsx_runtime.jsx)(CurrentParentPopupRecordContext.Provider,{value:{name:"$nParentPopupRecord",title:r("Parent popup record"),value:((t=e.parent)==null?void 0:t.recordData)||(a==null?void 0:a.value),collection:((o=e.parent)==null?void 0:o.collection)||(a==null?void 0:a.collection)},children:(0,import_jsx_runtime.jsx)(CurrentPopupRecordContext.Provider,{value:{name:"$nPopupRecord",title:r("Current popup record"),value:e.recordData||i,collection:e.collection||n},children:e.children})})});VariablePopupRecordProvider.displayName="VariablePopupRecordProvider";const useCurrentPopupRecord=()=>import_react2.default.useContext(CurrentPopupRecordContext),useParentPopupRecord=()=>import_react2.default.useContext(CurrentParentPopupRecordContext),useDef$3=()=>({}),useProps=(e={})=>{const t=e,{useProps:o=useDef$3}=t,r=K(t,["useProps"]);let i=o;typeof o!="function"&&(i=useDef$3);const n=i();return x(x({},r),n)},PopupLevelContext=import_react2.default.createContext(0),ActionContainer=(0,import_react.observer)(e=>{const{getComponentByOpenMode:t,defaultOpenMode:o}=useOpenModeContext()||{},{openMode:r=o}=useActionContext(),i=import_react2.default.useContext(PopupLevelContext)+1,n=t(r)||ActionDrawer;return(0,import_jsx_runtime.jsx)(PopupLevelContext.Provider,{value:i,children:(0,import_jsx_runtime.jsx)(n,x({footerNodeName:"Action.Container.Footer",level:i||1},e))})},{displayName:"ActionContainer"});ActionContainer.Footer=(0,import_react.observer)(()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)();return(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:e.address,schema:t,onlyRenderProperties:!0})},{displayName:"ActionContainer.Footer"});const SchemaToolbarContext=(0,import_react2.createContext)({});SchemaToolbarContext.displayName="SchemaToolbarContext";const SchemaToolbarProvider=e=>{const t=e,{children:o}=t,r=K(t,["children"]);return(0,import_jsx_runtime.jsx)(SchemaToolbarContext.Provider,{value:r,children:o})};function useSchemaToolbar(){return(0,import_react2.useContext)(SchemaToolbarContext)}function useSchemaSettingsRender(e,t){const o=useApp(),r=(0,import_react2.useMemo)(()=>typeof e=="object"?e:o.schemaSettingsManager.get(e),[o.schemaSettingsManager,e]);return e?r?{exists:!0,render:(i={})=>import_react2.default.createElement(SchemaSettingsWrapper,x(x(x({},r.options),t),i))}:(console.error(`[nocobase]: SchemaSettings "${e}" not found`),{exists:!1,render:()=>null}):{exists:!1,render:()=>null}}const EditableTitle=e=>{const[t,o]=(0,import_react2.useState)(e.title),[r,i]=(0,import_react2.useState)(!1),{refresh:n}=useSchemaTemplateManager();useAPIClient();const{run:a}=useRequest({resource:"uiSchemaTemplates",action:"update",params:{filterByTk:e.filterByTk}},{manual:!0,debounceWait:500,onSuccess(){n()}});return(0,import_jsx_runtime.jsx)("div",{children:r?(0,import_jsx_runtime.jsx)(import_antd.Input,{defaultValue:t,size:"large",onBlur:()=>{i(!1)},onChange:l=>{o(l.target.value),a({filterByTk:e.filterByTk,values:{name:l.target.value}})}}):(0,import_jsx_runtime.jsx)("div",{onClick:()=>{i(!0)},children:t||(0,import_jsx_runtime.jsx)("span",{style:{color:"#bbb"},children:"未命名"})})})},BlockTemplateDetails=()=>{var e,t;const o=useNavigateNoUpdate(),r=(0,import_react_router_dom.useParams)(),i=r==null?void 0:r.key,n=(0,import_react2.useContext)(SchemaComponentContext),a=(0,import_react2.useMemo)(()=>P(x({},n),{designable:!0}),[n]),{data:l,loading:c}=useRequest({resource:"uiSchemaTemplates",action:"get",params:{filterByTk:i}});return c?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(0,import_jsx_runtime.jsxs)("div",{children:[(0,import_jsx_runtime.jsx)(import_pro_layout.PageHeader,{style:{backgroundColor:"white"},onBack:()=>{o("/admin/plugins/block-templates")},ghost:!1,title:(0,import_jsx_runtime.jsx)(EditableTitle,{filterByTk:i,title:(e=l==null?void 0:l.data)==null?void 0:e.name})}),(0,import_jsx_runtime.jsx)("div",{style:{margin:"var(--nb-spacing)"},children:(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:a,children:(0,import_jsx_runtime.jsx)(RemoteSchemaComponent,{uid:(t=l==null?void 0:l.data)==null?void 0:t.uid})})})]})},uiSchemaTemplatesCollection={name:"uiSchemaTemplates",filterTargetKey:"key",targetKey:"key",fields:[{type:"integer",name:"name",interface:"input",uiSchema:{title:'{{ t("Template name") }}',type:"number","x-component":"Input",required:!0}}]},CollectionTitle=e=>{const{dataSourceKey:t="main",collectionName:o}=useCollectionRecordData(),r=useDataSourceManager(),i=useCompile(),[n,a]=(0,import_react2.useMemo)(()=>{const l=r.getDataSource(t);if(l){const c=l.collectionManager.getCollection(o);return[l.displayName,(c==null?void 0:c.title)||o]}return[t,null]},[r,t,o]);return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[i(n)," ",">"," ",i(a)]})},ActionSchemaToolbar=e=>(0,import_jsx_runtime.jsx)(SchemaToolbar,x({initializer:!1,showBorder:!1,showBackground:!0},e)),BlockSchemaToolbar=e=>{const{t}=(0,import_react_i18next.useTranslation)(),o=useCollectionManager();let{name:r,title:i}=useCollection()||{};const n=useSchemaTemplate(),{association:a,collection:l}=useDataBlockProps()||{},c=useCompile();if(a){const[g]=a.split("."),{name:h,title:f}=o.getCollection(g);r=h,i=f}const u=o.getCollectionField(a),m=o.getCollection(l||(u==null?void 0:u.target)),d=["FormItem","ReadPrettyFormItem"].includes(n==null?void 0:n.componentName)?`${n==null?void 0:n.name} ${t("(Fields only)")}`:n==null?void 0:n.name,p=(0,import_react2.useMemo)(()=>[getCollectionTitle({collectionTitle:i,collectionName:r,associationField:u,associationCollection:m,compile:c}),d].filter(Boolean),[i,r,u,m,c,d]);return(0,import_jsx_runtime.jsx)(SchemaToolbar,x({title:p},e))};function getCollectionTitle(e){var t;const{collectionTitle:o,collectionName:r,associationField:i,compile:n,associationCollection:a}=e;return i?`${n(o||r)} > ${n(((t=i.uiSchema)==null?void 0:t.title)||i.name)} (${n((a==null?void 0:a.title)||(a==null?void 0:a.name))})`:n(o||r)}const useDetailsWithPaginationBlockParams=e=>{const{params:t}=e,{filter:o,parseVariableLoading:r}=useParsedFilter({filterOption:t==null?void 0:t.filter});return{params:(0,import_react2.useMemo)(()=>P(x({},t),{filter:o}),[JSON.stringify(o)]),parseVariableLoading:r}};function useDetailsWithPaginationDecoratorProps(e){let t;const{params:o,parseVariableLoading:r}=useDetailsWithPaginationBlockParams(e);return e.association&&(t=useParentRecordCommon(e.association)),{parentRecord:t,params:o,parseVariableLoading:r}}const useSpecialCase=()=>{const e=(0,import_react.useForm)(),t=(0,import_react.useFieldSchema)(),{getField:o}=useCollection_deprecated(),{getCollectionField:r}=useCollectionManager_deprecated(),i=(0,import_react2.useMemo)(()=>o(t.name),[t.name,o]),n=(0,import_react2.useCallback)(()=>isSpecialCaseField({collectionField:i,fieldSchema:t,getCollectionField:r}),[i,t,r]),a=(0,import_react2.useCallback)(l=>{const c=getParentFieldSchema(t);if(c){const u=e.query(c.name).take();if(u){const m=import_lodash.default.isEmpty(l)?[]:import_lodash.default.map(transformValue(l,{field:u,subFieldSchema:t}),d=>markRecordAsNew(d));isSubset(m,u.initialValue)||u.setInitialValue(m)}}},[t,e]);return{isSpecialCase:n,setDefaultValue:a}};function getParentFieldSchema(e){for(;e!=null&&e.parent;)if(e=e.parent,isSubMode(e))return e;return e}function isSpecialCaseField({collectionField:e,fieldSchema:t,getCollectionField:o}){if(!t.default||!t.default.includes("$context"))return!1;if(e&&["hasOne","belongsTo"].includes(e.type)&&t){const r=getParentFieldSchema(t);if(r&&r["x-collection-field"]){const i=o(r["x-collection-field"]);if(["hasMany","belongsToMany"].includes(i==null?void 0:i.type))return!0}}return!1}function transformValue(e,t){const{field:o,subFieldSchema:r}=t,i=o.value;let n=null;return Array.isArray(e)?n=e.map(a=>({[r.name]:a})):n=[{[r.name]:e}],import_lodash.default.assignWith([...i],n,(a,l)=>(!a&&l&&(l.__notFromDatabase=!0),import_lodash.default.assign(x({},i[0]),l)))}const useSubTableSpecialCase=({rootField:e,rootSchema:t})=>{const{hasUsedVariable:o}=useHasUsedVariable();(0,import_react2.useEffect)(()=>{if(import_lodash.default.isEmpty(e.value)&&o("$context",t)){const r=e.value,i=[markRecordAsNew({})];e.value=i,setTimeout(()=>{JSON.stringify(e.value)===JSON.stringify(i)&&(e.value=r)})}},[e,t,o])};function isSubset(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++){const r=e[o],i=t[o];if(!import_lodash.default.isMatch(import_lodash.default.omitBy(i,import_lodash.default.isNil),import_lodash.default.omitBy(r,import_lodash.default.isNil)))return!1}return!0}const checkSchema=(e,t)=>{if(e["x-decorator"]==="FormItem"){const r=e.default;if(r&&typeof r=="string"&&isVariable(r)&&r.includes(t))return!0}let o=!1;return e.mapProperties(r=>{checkSchema(r,t)&&(o=!0)}),o};function useHasUsedVariable(){return{hasUsedVariable:(0,import_react2.useCallback)((e,t)=>checkSchema(t,e),[])}}const BaseVariableContext=import_react2.default.createContext(null),BaseVariableProvider=e=>(0,import_jsx_runtime.jsx)(BaseVariableContext.Provider,{value:e,children:e.children}),getChildren$2=(e,{collectionField:t,uiSchema:o,depth:r,maxDepth:i,noDisabled:n,loadChildren:a,compile:l,isDisabled:c,targetFieldSchema:u,getCollectionField:m,deprecated:d})=>e.map(p=>!p.target||p.target==="chinaRegions"?{key:p.name,value:p.name,label:l(p.title),disabled:d||(n?!1:c({option:p,collectionField:t,uiSchema:o,targetFieldSchema:u,getCollectionField:m})),isLeaf:!0,depth:r}:r>=i?null:{key:p.name,value:p.name,label:l(p.title),isLeaf:!1,field:p,depth:r,disabled:d||(n?!1:c({option:p,collectionField:t,uiSchema:o,targetFieldSchema:u,getCollectionField:m})),loadChildren:a}).filter(Boolean),getLabelWithTooltip=(e,t)=>t?(0,import_jsx_runtime.jsx)(import_antd.Tooltip,{placement:"left",title:t,zIndex:9999,children:(0,import_jsx_runtime.jsx)("span",{style:{position:"relative",display:"inline-block",marginLeft:-14,paddingLeft:14,marginRight:-80,paddingRight:80,zIndex:1},children:e})}):e,useBaseVariable=({collectionField:e,uiSchema:t,targetFieldSchema:o,maxDepth:r=3,name:i,title:n,collectionName:a,noChildren:l=!1,noDisabled:c=!0,dataSource:u,returnFields:m=g=>g,deprecated:d,tooltip:p})=>{const g=useCompile(),h=useGetFilterOptions(),{isDisabled:f}=(0,import_react2.useContext)(BaseVariableContext)||{},_=useCollectionManager(),v=S=>{var C;if(!((C=S.field)!=null&&C.target))return Promise.resolve(void 0);const b=S.field.target;return new Promise(y=>{setTimeout(()=>{const F=(getChildren$2(m(h(b,u,!0),S),{collectionField:e,uiSchema:t,targetFieldSchema:o,depth:S.depth+1,maxDepth:r,noDisabled:c,loadChildren:v,compile:g,isDisabled:f||isDisabledDefault,getCollectionField:_.getCollectionField,deprecated:d})||[]).sort((j,k)=>j.isLeaf&&!k.isLeaf?-1:!j.isLeaf&&k.isLeaf?1:0).sort((j,k)=>j.disabled&&!k.disabled?1:!j.disabled&&k.disabled?-1:0);if(F.length===0){S.disabled=!0,S.isLeaf=!0,y();return}S.children=F,y()},5)})};return(0,import_react2.useMemo)(()=>({label:getLabelWithTooltip(n,p),value:i,key:i,isLeaf:l,field:{target:a},depth:0,loadChildren:v,children:[],disabled:!!d,deprecated:d}),[t==null?void 0:t["x-component"]])};function isDisabledDefault(e){var t,o;const{option:r,collectionField:i,uiSchema:n,targetFieldSchema:a,getCollectionField:l}=e;return!n||!i?!0:i.interface==="json"?!1:!i.target&&["hasMany","belongsToMany"].includes(r.type)?!0:!i.target&&["hasOne","belongsTo"].includes(r.type)||r.target&&isSpecialCaseField({collectionField:i,fieldSchema:a,getCollectionField:l})?!1:["hasOne","belongsTo"].includes(i.type)&&["hasMany","belongsToMany"].includes(r.type)?!0:["hasOne","belongsTo"].includes(i.type)&&["hasOne","belongsTo"].includes(r.type)||["hasMany","belongsToMany"].includes(i.type)&&r.target?!1:["input","markdown","richText","textarea","username"].includes(i.interface)?!["string","number"].includes((t=r.schema)==null?void 0:t.type):i.interface&&r.interface?i.interface!==r.interface:(n==null?void 0:n["x-component"])!==((o=r.schema)==null?void 0:o["x-component"])}const CurrentRecordContext=(0,import_react2.createContext)(null),CurrentRecordContextProvider=e=>{const t=(0,import_react2.useMemo)(()=>({recordData:e.recordData,collectionName:e.collectionName}),[e.recordData,e.collectionName]);return(0,import_jsx_runtime.jsxs)(CurrentRecordContext.Provider,{value:t,children:[" ",e.children," "]})},useCurrentRecord=()=>(0,import_react2.useContext)(CurrentRecordContext),useCurrentRecordContext=()=>{const e=useCurrentRecord(),{name:t}=useBlockContext()||{},o=useCollection(),r=useCollectionRecordData(),{formRecord:i,collectionName:n}=useFormBlockContext();let a=i!=null&&i.data?n:o==null?void 0:o.name;return a=(e==null?void 0:e.collectionName)||a,{currentRecordCtx:(e==null?void 0:e.recordData)||(i==null?void 0:i.data)||r,shouldDisplayCurrentRecord:!import_lodash.default.isEmpty(import_lodash.default.omit(r,["__collectionName","__parent"]))||!!(i!=null&&i.data),collectionName:a,blockType:t,dataSource:o==null?void 0:o.dataSource}},useCurrentRecordVariable=(e={})=>{const{t}=(0,import_react_i18next.useTranslation)(),{currentRecordCtx:o,shouldDisplayCurrentRecord:r,collectionName:i,blockType:n,dataSource:a}=useCurrentRecordContext();return{currentRecordSettings:useBaseVariable({collectionField:e.collectionField,uiSchema:e.schema,name:"$nRecord",title:t("Current record"),collectionName:i,noDisabled:e.noDisabled,targetFieldSchema:e.targetFieldSchema,deprecated:n==="form",tooltip:n==="form"?t('This variable has been deprecated and can be replaced with "Current form"'):"",dataSource:a}),currentRecordCtx:o,shouldDisplayCurrentRecord:r,collectionName:i}},DetailsBlockContext=(0,import_react2.createContext)({});DetailsBlockContext.displayName="DetailsBlockContext";const InternalDetailsBlockProvider=e=>{var t,o,r;const{action:i,readPretty:n}=e,a=(0,import_react.useField)(),l=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)({readPretty:n}),[n]),c=useCollection(),{resource:u,service:m}=useBlockRequestContext(),d=useCollectionParentRecord(),p=(i==="list"?(o=(t=m==null?void 0:m.data)==null?void 0:t.data)==null?void 0:o[0]:(r=m==null?void 0:m.data)==null?void 0:r.data)||{},g=(0,import_react2.useRef)(),h=(0,import_react2.useMemo)(()=>({action:i,form:l,field:a,service:m,resource:u,formBlockRef:g}),[i,a,l,u,m]);return m.loading&&!a.loaded?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(a.loaded=!0,(0,import_jsx_runtime.jsx)(CurrentRecordContextProvider,{recordData:p,collectionName:c==null?void 0:c.name,children:(0,import_jsx_runtime.jsx)(DetailsBlockContext.Provider,{value:h,children:(0,import_jsx_runtime.jsx)("div",{ref:g,children:(0,import_jsx_runtime.jsx)(RecordProvider,{isNew:!1,record:p,parent:d==null?void 0:d.data,children:e.children})})})}))},useCompatDetailsBlockParams=e=>{const t=(0,import_react.useFieldSchema)();let o,r=!1;if(t["x-use-decorator-props"])o=e==null?void 0:e.params,r=e==null?void 0:e.parseVariableLoading;else{const i=useDetailsWithPaginationBlockParams(e);o=i.params,r=i.parseVariableLoading}return{params:o,parseVariableLoading:r}},DetailsBlockProvider=withDynamicSchemaProps(e=>{const{params:t,parseVariableLoading:o}=useCompatDetailsBlockParams(e),r=useCollectionRecordData(),{association:i,dataSource:n}=e,{getCollection:a}=useCollectionManager_deprecated(n),{__collection:l}=r||{},{designable:c}=useDesignable(),u=e.collection||a(i,n).name;let m=!0;!c&&l&&(m=l===u);const d=(0,import_ahooks.useUpdate)();return!m||o?null:(0,import_jsx_runtime.jsx)(TemplateBlockProvider,{onTemplateLoaded:d,children:(0,import_jsx_runtime.jsx)(BlockProvider,P(x({name:"details"},e),{params:t,children:(0,import_jsx_runtime.jsx)(InternalDetailsBlockProvider,x({},e))}))})}),useDetailsBlockContext=()=>(0,import_react2.useContext)(DetailsBlockContext),useDetailsBlockProps=()=>{var e,t;const o=useDetailsBlockContext();return(0,import_react2.useEffect)(()=>{var r,i,n,a,l;if(!o.service.loading){const c=o.action==="list"?(n=(i=(r=o.service)==null?void 0:r.data)==null?void 0:i.data)==null?void 0:n[0]:(l=(a=o.service)==null?void 0:a.data)==null?void 0:l.data;o.form.reset().then(()=>{o.form.setInitialValues(c||{}),o.form.setValues(c||{})}).catch(console.error)}},[o.action,o.form,(t=(e=o.service)==null?void 0:e.data)==null?void 0:t.data,o.service.loading]),{form:o.form}};function useDetailsWithPaginationProps(){return useDetailsBlockProps()}function useDetailsDecoratorProps(e){const t=useParamsFromRecord(e);let o;return e.association&&(o=useDetailsParentRecord(e.association)),{params:t,parentRecord:o}}function useDetailsParentRecord(e){const t=(0,import_react.useFieldSchema)(),o=useCollectionRecordData(),r=useCollectionParentRecordData();if(e)return t["x-is-current"]?r:o}function useDetailsProps(){return useDetailsBlockProps()}const FormItemSchemaToolbar=e=>(0,import_jsx_runtime.jsx)(SchemaToolbar,x({showBorder:!1,showBackground:!0},e)),useHiddenForInherit=e=>{const t=useRecord(),{collection:o,isCusomeizeCreate:r,hidden:i}=e,{__collection:n}=t,a=useCollection(),{designable:l}=useDesignable(),c=useIsDetailBlock();if(!a)return{hidden:i||!1};let u=!1;c&&(u=!0,!l&&n&&(u=n===o));const m=a.name===((o==null?void 0:o.name)||o)&&!c||!a.name||!o;return{hidden:i||!u&&!m&&!r}};function useCreateFormBlockDecoratorProps(e){let t;const{hidden:o}=useHiddenForInherit(e);return e.association&&(t=useParentRecordCommon(e.association)),{parentRecord:t,hidden:o}}function useCreateFormBlockProps(){return useFormBlockProps$1()}function useEditFormBlockDecoratorProps(e){const t=useFormBlockParams();let o;const{hidden:r}=useHiddenForInherit(e);return e.association&&(o=useDetailsParentRecord(e.association)),{params:t,parentRecord:o,hidden:r}}function useFormBlockParams(){return useParamsFromRecord()}function useEditFormBlockProps(){return useFormBlockProps$1()}function useDataFormItemProps(){const e=useCollectionRecordData(),{form:t}=useFormBlockContext(),o=useSubFormValue(),{valueMap:r}=useSatisfiedActionValues({category:"style",formValues:(o==null?void 0:o.formValue)||(t==null?void 0:t.values)||e,form:t});return{wrapperStyle:r}}function useGridCardBlockParams(e){const{params:t}=e,{filter:o,parseVariableLoading:r}=useParsedFilter({filterOption:t==null?void 0:t.filter});return{params:(0,import_react2.useMemo)(()=>P(x({},t),{filter:o}),[o,t]),parseVariableLoading:r}}function useGridCardBlockDecoratorProps(e){const{params:t,parseVariableLoading:o}=useGridCardBlockParams(e);let r;return e.association&&(r=useParentRecordCommon(e.association)),{params:t,parentRecord:r,parseVariableLoading:o}}function useListBlockDecoratorProps(e){let t;return e.association&&(t=useParentRecordCommon(e.association)),{parentRecord:t}}function useTableSelectorDecoratorProps(){}const useStyles$g=genStyleHook("nb-grid-in-css-in-js",e=>{const{componentCls:t}=e,o=e.marginBlock===e.marginLG?" !important":"";return{[t]:{position:"relative",".ColDivider":{flexShrink:0,width:`${e.marginBlock}px${o}`},".DraggableNode":{"&::before":{content:'" "',width:"100%",height:"100%",position:"absolute",cursor:"col-resize"},"&:hover":{"&::before":{background:"var(--colorBgSettingsHover) !important"}},width:`${e.marginBlock}px${o}`,height:"100%",position:"absolute",cursor:"col-resize"},".RowDivider":{height:`${e.marginBlock}px${o}`,width:"100%",position:"absolute",marginTop:`calc(-1 * ${e.marginBlock}px)${o}`},".CardRow":{display:"flex",position:"relative"},".showDivider":{margin:`0 calc(-1 * ${e.marginBlock}px)${o}`},".nb-grid-warp > button:last-child":{marginBottom:`${e.marginBlock}px`},".nb-grid-warp .nb-grid-warp > button:last-child":{marginBottom:`${e.margin}px`}}}}),GridRowContext=(0,import_react2.createContext)({});GridRowContext.displayName="GridRowContext";const GridColContext=(0,import_react2.createContext)({});GridColContext.displayName="GridColContext";const GridContext=(0,import_react2.createContext)({});GridContext.displayName="GridContext";const breakRemoveOnGrid=e=>e["x-component"]==="Grid",breakRemoveOnRow=e=>e["x-component"]==="Grid.Row",ColDivider=e=>{var t,o,r;const{token:i}=useToken(),n=(0,import_react2.useRef)(null),{dn:a,designable:l}=useDesignable(),{isOver:c,setNodeRef:u}=(0,import_core.useDroppable)({id:e.id,data:e.data,disabled:!l}),m=(0,import_react2.useRef)(),d=(0,import_react2.useMemo)(()=>c?{backgroundColor:new import_tinycolor.TinyColor(i.colorSettings).setAlpha(.1).toHex8String()}:{},[c]),p=(r=(o=(t=(0,import_core.useDndContext)().active)==null?void 0:t.data.current)==null?void 0:o.schema)==null?void 0:r.parent,g=(0,import_react2.useMemo)(()=>p?Object.keys(p.properties).length:0,[p]);let h=!0;if(g===1)if(e.first)h=p!==e.cols[0];else{const j=e.cols[e.index],k=e.cols[e.index+1];h=p!==j&&k!==p}const f=e.cols[e.index],_=e.cols[e.index+1],{attributes:v,listeners:S,setNodeRef:C,isDragging:b}=(0,import_core.useDraggable)({disabled:e.first||e.last||!l,id:e.id,data:{dividerRef:m,prevSchema:f,nextSchema:_}}),[y,F]=(0,import_react2.useState)([0,0]);return(0,import_core.useDndMonitor)({onDragStart(j){if(!l||!b)return;n.current=j.active.id;const k=m.current,T=k.previousElementSibling,O=k.nextElementSibling;F([T.clientWidth,O.clientWidth])},onDragMove(j){if(!l||!b)return;n.current===j.active.id&&(n.current=n.current+"_move");const k=m.current,T=k.previousElementSibling,O=k.nextElementSibling;T.style.width=`${y[0]+j.delta.x}px`,O.style.width=`${y[1]-j.delta.x}px`},onDragEnd(j){var k;if(!l||!n.current||(k=n.current)!=null&&k.startsWith(j.active.id)&&!n.current.endsWith("_move")||y[0]<=0||y[1]<=0||(F([0,0]),!f||!_))return;const T=m.current,O=T.previousElementSibling,N=T.nextElementSibling;f["x-component-props"]=f["x-component-props"]||{},_["x-component-props"]=_["x-component-props"]||{};const L=T.clientWidth*(e.cols.length+1)/e.cols.length,D=(100*(O.getBoundingClientRect().width+L)/T.parentElement.clientWidth).toFixed(2),R=(100*(N.getBoundingClientRect().width+L)/T.parentElement.clientWidth).toFixed(2);import_lodash.default.set(f,"x-component-props.width",D),import_lodash.default.set(_,"x-component-props.width",R),a.emit("batchPatch",{schemas:[{"x-uid":f["x-uid"],"x-component-props":x({},f["x-component-props"])},{"x-uid":_["x-uid"],"x-component-props":x({},_["x-component-props"])}]})}}),(0,import_jsx_runtime.jsx)("div",{ref:j=>{h&&(u(j),m.current=j)},className:(0,import_classnames.default)("nb-col-divider","ColDivider"),style:d,children:(0,import_jsx_runtime.jsx)("div",P(x(x({ref:C},S),v),{className:e.first||e.last||!l?null:"DraggableNode"}))})},RowDivider=import_react2.default.memo(e=>{var t,o,r;const{token:i}=useToken(),{designable:n}=useDesignable(),{isOver:a,setNodeRef:l}=(0,import_core.useDroppable)({id:e.id,data:e.data,disabled:!n}),[c,u]=(0,import_react2.useState)(!1),m=(0,import_react2.useMemo)(()=>a?{zIndex:c?1e3:-1,backgroundColor:new import_tinycolor.TinyColor(i.colorSettings).setAlpha(.1).toHex8String()}:{zIndex:c?1e3:-1},[c,a]),d=(0,import_core.useDndContext)(),p=e.rows[e.index],g=(r=(o=(t=d.active)==null?void 0:t.data.current)==null?void 0:o.schema)==null?void 0:r.parent.parent,h=(0,import_react2.useMemo)(()=>g==null?void 0:g.mapProperties(_=>_["x-component"]==="Grid.Col").filter(Boolean).length,[g]);let f=!0;if(h===1)if(e.first)f=g!==e.rows[0];else{const _=e.rows[e.index+1];f=g!==p&&_!==g}return(0,import_core.useDndMonitor)({onDragStart(_){n&&u(!0)},onDragMove(_){},onDragOver(_){},onDragEnd(_){n&&u(!1)},onDragCancel(_){n&&u(!1)}}),(0,import_jsx_runtime.jsx)("span",{ref:f?l:null,className:(0,import_classnames.default)("nb-row-divider","RowDivider"),style:m})});RowDivider.displayName="RowDivider";const wrapRowSchema=e=>{const t=new import_react.Schema({type:"void",name:`row_${(0,import_shared.uid)()}`,"x-uid":(0,import_shared.uid)(),"x-component":"Grid.Row"}),o=t.addProperty((0,import_shared.uid)(),{type:"void","x-uid":(0,import_shared.uid)(),"x-component":"Grid.Col"});return import_react.Schema.isSchemaInstance(e)&&(e.parent=o),o.addProperty(e.name,e),t},wrapColSchema=e=>{const t=new import_react.Schema({type:"void",name:`col_${(0,import_shared.uid)()}`,"x-uid":(0,import_shared.uid)(),"x-component":"Grid.Col"});return import_react.Schema.isSchemaInstance(e)&&(e.parent=t),t.addProperty(e.name,e),t},useRowProperties=()=>{const e=(0,import_react.useFieldSchema)();return(0,import_react2.useMemo)(()=>e.reduceProperties((t,o)=>(o["x-component"]==="Grid.Row"&&!o["x-hidden"]&&t.push(o),t),[]),[e])},useColProperties=()=>{const e=(0,import_react.useFieldSchema)();return(0,import_react2.useMemo)(()=>e.reduceProperties((t,o)=>(o["x-component"]==="Grid.Col"&&!o["x-hidden"]&&t.push(o),t),[]),[e])},DndWrapper=e=>e.dndContext===!1?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):(0,import_jsx_runtime.jsx)(DndContext,P(x({},e.dndContext),{children:e.children})),useGridContext=()=>(0,import_react2.useContext)(GridContext),useGridRowContext=()=>(0,import_react2.useContext)(GridRowContext),getRowDividerData=import_lodash.default.memoize((e,t)=>({breakRemoveOn:breakRemoveOnGrid,wrapSchema:wrapRowSchema,insertAdjacent:t,schema:e})),Grid=(0,import_react.observer)(e=>{const{distributed:t,showDivider:o=!0}=e,r=(0,import_react2.useRef)(null),i=(0,import_react.useField)(),n=(0,import_react.useFieldSchema)(),{render:a}=useSchemaInitializerRender(n["x-initializer"],n["x-initializer-props"]),l=(0,import_react2.useCallback)(S=>a(S),[]),c=i.address.toString(),u=useRowProperties(),{setPrintContent:m}=useFormBlockContext(),{componentCls:d,hashId:p}=useStyles$g(),g=t===void 0?(n==null?void 0:n.parent["x-component"])==="Page"||(n==null?void 0:n.parent["x-component"])==="Tabs.TabPane":t;(0,import_react2.useEffect)(()=>{r.current&&(m==null||m(r.current))},[m]);const h=(0,import_react2.useMemo)(()=>({ref:r,fieldSchema:n,renderSchemaInitializer:a,InitializerComponent:l,showDivider:o}),[n,a,l,o]),f=useRefreshFieldSchema(),_=useRefreshComponent(),v=(0,import_react2.useCallback)(()=>{f==null||f(),_==null||_()},[_,f]);return(0,import_jsx_runtime.jsx)(RefreshComponentProvider,{refresh:v,children:(0,import_jsx_runtime.jsx)(FilterBlockProvider,{children:(0,import_jsx_runtime.jsx)(GridContext.Provider,{value:h,children:(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)("nb-grid-container"),children:(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`nb-grid ${d} ${p}`),ref:r,children:(0,import_jsx_runtime.jsxs)("div",{className:"nb-grid-warp",children:[(0,import_jsx_runtime.jsxs)(DndWrapper,{dndContext:e.dndContext,children:[o?(0,import_jsx_runtime.jsx)(RowDivider,{rows:u,first:!0,id:`${c}_0`,data:getRowDividerData(n,"afterBegin")}):null,u.map((S,C)=>(0,import_jsx_runtime.jsxs)(import_react2.default.Fragment,{children:[g?(0,import_jsx_runtime.jsx)(SchemaComponent,{name:S.name,schema:S,distributed:!0}):(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{name:S.name,schema:S,isUseFormilyField:!0}),o?(0,import_jsx_runtime.jsx)(RowDivider,{rows:u,index:C,id:`${c}_${C+1}`,data:getRowDividerData(S,"afterEnd")}):null]},C))]}),a()]})})})})})})},{displayName:"Grid"});Grid.Row=(0,import_react.observer)(()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),o=e.address.toString(),r=useColProperties(),{showDivider:i}=useGridContext(),n=(0,import_react2.useMemo)(()=>({schema:t,cols:r}),[t,r]);return(0,import_jsx_runtime.jsx)(GridRowContext.Provider,{value:n,children:(0,import_jsx_runtime.jsxs)("div",{className:(0,import_classnames.default)("nb-grid-row","CardRow",{showDivider:i}),children:[i&&(0,import_jsx_runtime.jsx)(ColDivider,{cols:r,first:!0,id:`${o}_0`,data:{breakRemoveOn:breakRemoveOnRow,wrapSchema:wrapColSchema,insertAdjacent:"afterBegin",schema:t}}),r.map((a,l)=>(0,import_jsx_runtime.jsxs)(import_react2.default.Fragment,{children:[(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{name:a.name,schema:a,isUseFormilyField:!0}),i&&(0,import_jsx_runtime.jsx)(ColDivider,{cols:r,index:l,last:l===r.length-1,id:`${o}_${l+1}`,data:{breakRemoveOn:breakRemoveOnRow,wrapSchema:wrapColSchema,insertAdjacent:"afterEnd",schema:a}})]},l))]})})},{displayName:"Grid.Row"});Grid.Col=(0,import_react.observer)(e=>{const{cols:t=[]}=(0,import_react2.useContext)(GridRowContext),{showDivider:o}=useGridContext(),r=(0,import_react.useFieldSchema)(),i=(0,import_react.useField)(),{token:n}=useToken(),{designable:a}=useDesignable(),l=(0,import_react2.useMemo)(()=>{var f;let _="";return t!=null&&t.length&&(_=`calc(${((f=r==null?void 0:r["x-component-props"])==null?void 0:f.width)||100/t.length}% - ${n.marginBlock}px * ${(o?t.length+1:0)/t.length})`),{width:_}},[t.length,r,o,n.marginBlock]),{isOver:c,setNodeRef:u}=(0,import_core.useDroppable)({id:i.address.toString(),data:{insertAdjacent:"beforeEnd",schema:r,wrapSchema:f=>f},disabled:!a}),[m,d]=(0,import_react2.useState)(!1),p=(0,import_react2.useMemo)(()=>c?{background:`linear-gradient(to top, ${new import_tinycolor.TinyColor(n.colorSettings).setAlpha(.1).toHex8String()} 20%, transparent 20%)`,borderTopRightRadius:"10px",borderTopLeftRadius:"10px",height:"100%"}:{height:"100%"},[m,c]);(0,import_core.useDndMonitor)({onDragStart(f){a&&d(!0)},onDragMove(f){},onDragOver(f){},onDragEnd(f){a&&d(!1)},onDragCancel(f){a&&d(!1)}});const g=(0,import_react2.useMemo)(()=>({cols:t,schema:r}),[t,r]),h=(0,import_react2.useMemo)(()=>x(x({},l),p),[p,l]);return(0,import_jsx_runtime.jsx)(GridColContext.Provider,{value:g,children:(0,import_jsx_runtime.jsx)("div",{ref:u,style:h,className:(0,import_classnames.default)("nb-grid-col"),children:e.children})})},{displayName:"Grid.Col"});Grid.wrap=e=>({type:"void","x-component":"Grid.Row",properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"Grid.Col",properties:{[e.name||(0,import_shared.uid)()]:e}}}});const TableColumnSchemaToolbar=import_react2.default.memo(e=>(0,import_jsx_runtime.jsx)(GridRowContext.Provider,{value:null,children:(0,import_jsx_runtime.jsx)(SchemaToolbar,x({initializer:e.initializer||!1,showBorder:!1,showBackground:!0},import_lodash.default.omit(e,"initializer")))}));TableColumnSchemaToolbar.displayName="TableColumnSchemaToolbar";const useTableBlockProps=()=>{var e,t,o,r,i,n;const a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)(),c=useDataBlockResource(),u=useDataBlockRequest(),{getDataBlocks:m}=useFilterBlock(),d=useTableBlockContextBasicValue(),p=(0,import_react2.useRef)(null);p.current={service:u,resource:c};const g=((e=u==null?void 0:u.data)==null?void 0:e.meta)||{},h=useTableElementRef(),f=(0,import_react2.useCallback)(()=>{var S;h!=null&&h.current&&((S=h.current.parentElement)==null||S.scrollIntoView({block:"start"}))},[h]),_=(0,import_react2.useMemo)(()=>({pageSize:g==null?void 0:g.pageSize,total:g==null?void 0:g.count,current:g==null?void 0:g.page,onChange:f}),[g==null?void 0:g.count,g==null?void 0:g.page,g==null?void 0:g.pageSize,f]),v=((t=u==null?void 0:u.data)==null?void 0:t.data)||[];return(0,import_react2.useEffect)(()=>{var S,C;if(!(u!=null&&u.loading)){const b=(C=(S=d.field)==null?void 0:S.data)==null?void 0:C.selectedRowKeys;a.data=a.data||{},(0,import_lodash.isEqual)(a.data.selectedRowKeys,b)||(a.data.selectedRowKeys=b)}},[a,u==null?void 0:u.data,u==null?void 0:u.loading,(r=(o=d.field)==null?void 0:o.data)==null?void 0:r.selectedRowKeys]),{value:v,childrenColumnName:d.childrenColumnName,loading:u==null?void 0:u.loading,showIndex:d.showIndex,dragSort:d.dragSort&&d.dragSortBy,rowKey:d.rowKey||((i=l==null?void 0:l["x-component-props"])==null?void 0:i.rowKey)||"id",pagination:((n=l==null?void 0:l["x-component-props"])==null?void 0:n.pagination)===!1?!1:_,onRowSelectionChange:(0,import_react2.useCallback)((S,C)=>{var b,y,F;d&&(d.field.data=((b=d.field)==null?void 0:b.data)||{},d.field.data.selectedRowKeys=S,d.field.data.selectedRowData=C,(F=(y=d.field)==null?void 0:y.onRowSelect)==null||F.call(y,S))},[]),onRowDragEnd:(0,import_react2.useCallback)(S=>q(void 0,[S],function*({from:C,to:b}){yield p.current.resource.move({sourceId:C[d.rowKey||"id"],targetId:b[d.rowKey||"id"],sortField:d.dragSort&&d.dragSortBy}),p.current.service.refresh()}),[d.rowKey,d.dragSort,d.dragSortBy]),onChange:(0,import_react2.useCallback)(({current:S,pageSize:C},b,y)=>{var F,j,k,T,O,N,L,D,R,$;const w=(k=(j=(F=l.parent)==null?void 0:F["x-decorator-props"])==null?void 0:j.params)==null?void 0:k.sort,I=y.order?y.order==="ascend"?[y.field]:[`-${y.field}`]:w||d.dragSortBy,M=C||((N=(O=(T=l.parent)==null?void 0:T["x-decorator-props"])==null?void 0:O.params)==null?void 0:N.pageSize),B=P(x({},(R=(D=(L=p.current)==null?void 0:L.service)==null?void 0:D.params)==null?void 0:R[0]),{page:S||1,pageSize:M});I&&(B.sort=I),($=p.current)==null||$.service.run(B)},[l.parent]),onClickRow:(0,import_react2.useCallback)((S,C,b)=>{const{targets:y,uid:F}=findFilterTargets(l),j=m();if(!y||!y.some(T=>j.some(O=>O.uid===T.uid))){C(T=>T.length?[]:T);return}const k=j.find(T=>T.uid===l.parent["x-uid"]);j.forEach(T=>{var O,N,L;const D=y.find(B=>B.uid===T.uid);if(!D)return;const R=getSourceKey(k,D.field)||d.rowKey||"id",$=[S[R]],w=((O=T.service.params)==null?void 0:O[0])||{},I=((L=(N=T.service.params)==null?void 0:N[1])==null?void 0:L.filters)||{};if(b.includes(S[d.rowKey])){if(T.dataLoadingMode==="manual")return T.clearData();delete I[F]}else I[F]={$and:[{[D.field||d.rowKey]:{[D.field?"$in":"$eq"]:$}}]};const M=mergeFilter([...Object.values(I).map(B=>removeNullCondition(B)),T.defaultFilter]);return T.doFilter(P(x({},w),{page:1,filter:M}),{filters:I})}),C(T=>T!=null&&T.includes(S[d.rowKey])?[]:[S[d.rowKey]])},[d.rowKey,l,m]),onExpand:(0,import_react2.useCallback)((S,C)=>{var b,y;(y=(b=d.field).onExpandClick)==null||y.call(b,S,C)},[])}};function getSourceKey(e,t){var o,r,i;const n=(o=e==null?void 0:e.associatedFields)==null?void 0:o.find(a=>a.foreignKey===t);return(n==null?void 0:n.sourceKey)||((i=(r=t==null?void 0:t.split)==null?void 0:r.call(t,"."))==null?void 0:i[1])}const CollapseItemSchemaToolbar=e=>(0,import_jsx_runtime.jsx)(SchemaToolbar,x({initializer:!1},e));function useCollapseBlockDecoratorProps(){}function useFilterFormBlockDecoratorProps(){}function useFilterFormBlockProps(){return useFormBlockProps$1()}const NOOP=()=>{},CollectOperatorsContext=(0,import_react2.createContext)(null),CollectOperators=e=>{const t=(0,import_react2.useRef)(e.defaultOperators||{}),o=(0,import_react2.useCallback)((a,l)=>{t.current[a]=l},[]),r=(0,import_react2.useCallback)(()=>x({},t.current),[]),i=(0,import_react2.useCallback)(a=>t.current[a],[]),n=(0,import_react2.useCallback)(a=>{delete t.current[a]},[]);return(0,import_jsx_runtime.jsx)(CollectOperatorsContext.Provider,{value:{collectOperator:o,getOperators:r,getOperator:i,removeOperator:n},children:e.children})},useOperators=()=>{const{getOperator:e=NOOP,getOperators:t=NOOP,collectOperator:o=NOOP,removeOperator:r=NOOP}=import_react2.default.useContext(CollectOperatorsContext)||{};return{getOperator:e,getOperators:t,collectOperator:o,removeOperator:r}},useCollectOperator=()=>{const e=(0,import_react.useFieldSchema)(),{collectOperator:t,removeOperator:o}=useOperators();(0,import_react2.useEffect)(()=>()=>{o(e.name)},[e.name,o]),e["x-filter-operator"]&&t(e.name,e["x-filter-operator"])},useFormItemProps=()=>{useCollectOperator()},isPatternDisabled=e=>{var t;return((t=e==null?void 0:e["x-component-props"])==null?void 0:t["pattern-disable"])==!0},DefaultValueContext=import_react2.default.createContext(null),DefaultValueProvider=e=>{const t=(0,import_react2.useMemo)(()=>({isAllowToSetDefaultValue:e.isAllowToSetDefaultValue}),[e.isAllowToSetDefaultValue]);return(0,import_jsx_runtime.jsx)(DefaultValueContext.Provider,{value:t,children:e.children})},useIsAllowToSetDefaultValue=({form:e,fieldSchema:t,collectionField:o}={})=>{const r=useDataSourceManager(),i=useCollectionManager(),n=useCollection(),{form:a}=useFormBlockContext(),l=(0,import_react.useFieldSchema)(),{type:c}=useFormBlockType(),{isAllowToSetDefaultValue:u=_isAllowToSetDefaultValue}=(0,import_react2.useContext)(DefaultValueContext)||{};return{isAllowToSetDefaultValue:(0,import_react2.useCallback)(m=>{const d=n.getField(l.name)||i.getCollectionField(l["x-collection-field"]);return u({collectionField:o||d,getInterface:r==null?void 0:r.collectionFieldInterfaceManager.getFieldInterface.bind(r==null?void 0:r.collectionFieldInterfaceManager),form:e||a,formBlockType:c,fieldSchema:t||l,isSubTableColumn:m})},[i,n,o,r==null?void 0:r.collectionFieldInterfaceManager,t,e,l,a,u,c])}},interfacesOfUnsupportedDefaultValue=["o2o","oho","obo","o2m","attachment","expression","point","lineString","circle","polygon","sequence","formula"];function _isAllowToSetDefaultValue({collectionField:e,getInterface:t,formBlockType:o,form:r,fieldSchema:i,isSubTableColumn:n}){var a;return n?!interfacesOfUnsupportedDefaultValue.includes(e==null?void 0:e.interface)&&!isSystemField(e,t):!e||e.target&&(a=i["x-component-props"])!=null&&a.mode&&!["Picker","Select"].includes(i["x-component-props"].mode)||o!=="create"?!1:!(r!=null&&r.readPretty)&&!isPatternDisabled(i)&&!interfacesOfUnsupportedDefaultValue.includes(e==null?void 0:e.interface)&&!isSystemField(e,t)}const setFieldProps$1=(e,t,o)=>{(0,import_reactive.untracked)(()=>{e[t]===void 0&&(e[t]=o)})},setRequired$1=(e,t,o)=>{typeof t.required>"u"&&(e.required=!!o.required)},FilterCollectionFieldInternalField=e=>{var t,o,r,i,n,a;const l=useCompile(),c=(0,import_react.useField)(),u=(0,import_react.useFieldSchema)(),{getInterface:m}=useCollectionManager_deprecated(),{uiSchema:d,defaultValue:p,interface:g}=useCollectionField(),{isAllowToSetDefaultValue:h}=useIsAllowToSetDefaultValue(),f=m(g),_=((o=(t=f==null?void 0:f.filterable)==null?void 0:t.operators)==null?void 0:o.find((b,y)=>b.value===(u==null?void 0:u["x-filter-operator"])))||((i=(r=f==null?void 0:f.filterable)==null?void 0:r.operators)==null?void 0:i[0]),v=useComponent(((n=_==null?void 0:_.schema)==null?void 0:n["x-component"])||((a=u["x-component-props"])==null?void 0:a.component)||(d==null?void 0:d["x-component"])||"Input"),S=useFormBlockContext(),C=useDynamicComponentProps(d==null?void 0:d["x-use-component-props"],e);return(0,import_react2.useEffect)(()=>{var b;if(!d)return;const y=l(d);if(setFieldProps$1(c,"content",y["x-content"]),setFieldProps$1(c,"title",y.title),setFieldProps$1(c,"description",y.description),S!=null&&S.form){const j=h()?u.default||p:void 0;j!=null&&setFieldProps$1(c,"initialValue",j)}if(!c.validator&&(y["x-validator"]||u["x-validator"])){const j=(0,import_lodash.concat)([],y["x-validator"]||[],u["x-validator"]||[]);c.validator=j}u["x-disabled"]===!0&&(c.disabled=!0),u["x-read-pretty"]===!0&&(c.readPretty=!0),setRequired$1(c,u,y),c.dataSource=y.enum;const F=l(x(x({},((b=_==null?void 0:_.schema)==null?void 0:b["x-component-props"])||{}),y["x-component-props"]||{}))||{};c.componentProps=(0,import_shared.merge)(F,c.componentProps||{},C||{})},[d]),d?(0,import_jsx_runtime.jsx)(v,x(x({},e),C)):null},FilterCollectionField=(0,import_react.connect)(e=>{const t=(0,import_react.useFieldSchema)();return(0,import_react.useField)(),(0,import_jsx_runtime.jsx)(import_react_error_boundary.ErrorBoundary,{FallbackComponent:ErrorFallback.Modal,onError:o=>console.log(o),children:(0,import_jsx_runtime.jsx)(CollectionFieldProvider,{name:t.name,children:(0,import_jsx_runtime.jsx)(FilterCollectionFieldInternalField,x({},e))})})});FilterCollectionField.displayName="FilterCollectionField";const FilterFormBlockProvider=withDynamicSchemaProps(e=>{const t=(0,import_react.useFieldSchema)()["x-filter-operators"]||{};return(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{components:{CollectionField:FilterCollectionField},children:(0,import_jsx_runtime.jsx)(CollectOperators,{defaultOperators:t,children:(0,import_jsx_runtime.jsx)(DatePickerProvider,{value:{utc:!1},children:(0,import_jsx_runtime.jsx)(ActionBarProvider,{forceProps:{style:{overflowX:"auto",maxWidth:"100%",float:"right"}},children:(0,import_jsx_runtime.jsx)(DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:(0,import_jsx_runtime.jsx)(FormBlockProvider,x({name:"filter-form"},e))})})})})})}),FormFieldContext=(0,import_react2.createContext)({});FormFieldContext.displayName="FormFieldContext";const InternalFormFieldProvider=e=>{var t,o,r;const{action:i,readPretty:n,fieldName:a}=e,l=useFormBlockContext(),c=useCollectionParentRecordData();(t=l==null?void 0:l.updateAssociationValues)!=null&&t.includes(a)||(o=l==null?void 0:l.updateAssociationValues)==null||o.push(a);const u=(0,import_react.useField)(),m=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)({effects(){(0,import_core2.onFormValuesChange)(g=>{var h;(h=l==null?void 0:l.form)==null||h.setValuesIn(a,g.values)})},readPretty:n}),[]);(0,import_react2.useEffect)(()=>(0,import_reactive.autorun)(()=>{var g;const h=((g=l==null?void 0:l.form)==null?void 0:g.values[a])||{};m.reset(),(0,import_client.forEach)(h,(f,_)=>{f&&(m.values[_]=f)})}),[]);const{resource:d,service:p}=useBlockRequestContext();return p.loading?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(0,import_jsx_runtime.jsx)(RecordProvider,{record:(r=p==null?void 0:p.data)==null?void 0:r.data,parent:c,children:(0,import_jsx_runtime.jsx)(FormFieldContext.Provider,{value:{action:i,form:m,field:u,service:p,resource:d,fieldName:a},children:e.children})})},WithoutFormFieldResource=(0,import_react2.createContext)(null);WithoutFormFieldResource.displayName="WithoutFormFieldResource";const FormFieldProvider=e=>(0,import_jsx_runtime.jsx)(WithoutFormFieldResource.Provider,{value:!1,children:(0,import_jsx_runtime.jsx)(BlockProvider,P(x({name:"form-field",block:"FormField"},e),{children:(0,import_jsx_runtime.jsx)(InternalFormFieldProvider,x({},e))}))}),useFormFieldContext=()=>(0,import_react2.useContext)(FormFieldContext),useFormFieldProps=()=>{const e=useFormFieldContext();return(0,import_react2.useEffect)(()=>{var t,o,r;(r=e==null?void 0:e.form)==null||r.setInitialValues((o=(t=e.service)==null?void 0:t.data)==null?void 0:o.data)},[]),{form:e.form}},TableFieldContext=(0,import_react2.createContext)({});TableFieldContext.displayName="TableFieldContext";const InternalTableFieldProvider=e=>{var t,o;const{params:r={},showIndex:i,dragSort:n,fieldName:a}=e,l=(0,import_react.useField)(),c=(0,import_react.useFieldSchema)(),{resource:u,service:m}=useBlockRequestContext(),d=useFormBlockContext(),p=useFormFieldContext(),g=p&&p.fieldName?`${p.fieldName}.${a}`:a;return(t=d==null?void 0:d.updateAssociationValues)!=null&&t.includes(g)||(o=d==null?void 0:d.updateAssociationValues)==null||o.push(g),(0,import_jsx_runtime.jsx)(TableFieldContext.Provider,{value:{field:l,fieldSchema:c,service:m,resource:u,params:r,showIndex:i,dragSort:n},children:e.children})};class TableFieldResource{constructor(t){A(this,"field"),A(this,"api"),A(this,"sourceId"),A(this,"resource"),this.field=t.field,this.api=t.api,this.sourceId=t.sourceId,this.resource=this.api.resource(t.resource,this.sourceId)}list(t){return q(this,null,function*(){if(this.field.data=this.field.data||{},this.field.data.changed)return console.log("list.dataSource",this.field.data.dataSource),{data:{data:this.field.data.dataSource}};if(!this.sourceId)return console.log("list.sourceId",this.field.data.dataSource),this.field.data.dataSource=[],{data:{data:[]}};const o=yield this.resource.list(t);return console.log("list",o),this.field.data.dataSource=o.data.data,{data:{data:o.data.data}}})}get(t){return q(this,null,function*(){console.log("get",t);const{filterByTk:o}=t;return{data:{data:this.field.data.dataSource[o]}}})}create(t){return q(this,null,function*(){console.log("create",t);const{values:o}=t;this.field.data.dataSource.push(o),this.field.data.changed=!0})}update(t){return q(this,null,function*(){console.log("update",t);const{filterByTk:o,values:r}=t;this.field.data.dataSource[o]=r,this.field.data.changed=!0})}destroy(t){return q(this,null,function*(){console.log("destroy",t);let{filterByTk:o}=t;Array.isArray(o)||(o=[o]),this.field.data.dataSource=this.field.data.dataSource.filter((r,i)=>!o.includes(i)),this.field.data.changed=!0})}}const WithoutTableFieldResource=(0,import_react2.createContext)(null);WithoutTableFieldResource.displayName="WithoutTableFieldResource";const TableFieldProvider=e=>(0,import_jsx_runtime.jsx)(WithoutTableFieldResource.Provider,{value:!1,children:(0,import_jsx_runtime.jsx)(BlockProvider,P(x({name:"table-field",block:"TableField"},e),{children:(0,import_jsx_runtime.jsx)(InternalTableFieldProvider,x({},e))}))}),useTableFieldContext=()=>(0,import_react2.useContext)(TableFieldContext),useTableFieldProps=()=>{var e,t,o,r,i,n,a,l;const c=(0,import_react.useField)(),u=useTableFieldContext();return(0,import_react2.useEffect)(()=>{var m,d,p,g,h;(m=u==null?void 0:u.service)!=null&&m.loading||(c.value=(p=(d=u==null?void 0:u.service)==null?void 0:d.data)==null?void 0:p.data,c.data=c.data||{},c.data.selectedRowKeys=(h=(g=u==null?void 0:u.field)==null?void 0:g.data)==null?void 0:h.selectedRowKeys)},[(t=(e=u==null?void 0:u.field)==null?void 0:e.data)==null?void 0:t.selectedRowKeys,(r=(o=u==null?void 0:u.service)==null?void 0:o.data)==null?void 0:r.data,(i=u==null?void 0:u.service)==null?void 0:i.loading,c]),{size:"middle",loading:(n=u==null?void 0:u.service)==null?void 0:n.loading,showIndex:u.showIndex,dragSort:u.dragSort,pagination:!1,required:(l=(a=u==null?void 0:u.fieldSchema)==null?void 0:a.parent)==null?void 0:l.required,rowKey:m=>{var d,p;return(p=(d=c.value)==null?void 0:d.indexOf)==null?void 0:p.call(d,m)},onRowSelectionChange(m,d){var p;u.field.data=((p=u==null?void 0:u.field)==null?void 0:p.data)||{},u.field.data.selectedRowKeys=m,u.field.data.selectedRowData=d},onChange({current:m,pageSize:d}){u.service.run({page:m,pageSize:d})}}},TableSelectorContext=(0,import_react2.createContext)({});TableSelectorContext.displayName="TableSelectorContext";const TableSelectorParamsContext=(0,import_react2.createContext)({});TableSelectorParamsContext.displayName="TableSelectorParamsContext";const useTableSelectorParams=()=>(0,import_react2.useContext)(TableSelectorParamsContext),TableSelectorParamsProvider=({params:e,children:t})=>{const o=useTableSelectorParams();try{e.filter=mergeFilter([o.filter,e.filter]),e=x(x({},o),e)}catch(r){console.error(r)}return(0,import_jsx_runtime.jsx)(TableSelectorParamsContext.Provider,{value:e,children:t})},InternalTableSelectorProvider=e=>{const{params:t,rowKey:o,extraFilter:r,expandFlag:i=!1}=e,n=(0,import_react.useField)(),{resource:a,service:l}=useBlockRequestContext(),[c,u]=(0,import_react2.useState)(i),m=useCollectionParentRecordData();return(0,import_jsx_runtime.jsx)(RecordProvider,{record:{},parent:m,children:(0,import_jsx_runtime.jsx)(TableSelectorContext.Provider,{value:{field:n,service:l,resource:a,params:t,extraFilter:r,rowKey:o,expandFlag:c,setExpandFlag:()=>{u(!c)}},children:e.children})})},recursiveParent$1=(e,t)=>e["x-component"]===t?e:e.parent&&(e==null?void 0:e["x-component"])!=="AssociationField.Viewer"?recursiveParent$1(e.parent,t):null,useAssociationNames$1=e=>{const{getCollectionFields:t}=useCollectionManager_deprecated(),o=t(e),r=new Set;for(const n of o)if(n.target){r.add(n.name);const a=t(n.target);for(const l of a)l.target&&r.add(`${n.name}.${l.name}`)}const i=(0,import_react.useFieldSchema)().reduceProperties((n,a)=>a["x-component"]==="TableV2.Selector"?a:n,new import_react.Schema({}));return(0,import_uniq.default)(i.reduceProperties((n,a)=>{if(a["x-component"]==="TableV2.Column"){const l=a.reduceProperties((c,u)=>{const[m]=u.name.split(".");return u["x-collection-field"]&&r.has(m)?u:c},null);if(l){const[c]=l.name.split(".");r.has(l.name)?n.push(l.name):r.has(c)&&n.push(c)}}return n},[]))},TableSelectorProvider=withDynamicSchemaProps(e=>{var t;const o=useTableSelectorParams(),r=(0,import_react.useFieldSchema)(),{getCollectionJoinField:i,getCollectionFields:n}=useCollectionManager_deprecated(),a=useRecord(),{getCollection:l}=useCollectionManager_deprecated(),{treeTable:c}=(r==null?void 0:r["x-decorator-props"])||{},u=recursiveParent$1(r,"CollectionField"),m=i(u==null?void 0:u["x-collection-field"]),d=l(m==null?void 0:m.collectionName),p=d==null?void 0:d.getPrimaryKey(),g=useAssociationNames$1(e.collection);let h=x({},e.params);e.dragSort&&(h.sort=["sort"]),(m==null?void 0:m.target)===(m==null?void 0:m.collectionName)&&d!=null&&d.tree&&c&&(h.tree=!0,u.name==="parent"&&(h.filter=P(x({},(t=h.filter)!=null?t:{}),{id:a[p]&&{$ne:a[p]}}))),Object.keys(h).includes("appends")||(h.appends=g);let f;if(m&&(["oho","o2m"].includes(m.interface)&&!isInFilterFormBlock(r)&&(a!=null&&a[m.sourceKey]?f={$or:[{[m.foreignKey]:{$is:null}},{[m.foreignKey]:{$eq:a==null?void 0:a[m.sourceKey]}}]}:f={[m.foreignKey]:{$is:null}}),["obo"].includes(m.interface)&&!isInFilterFormBlock(r))){const S=n(m.target).find(C=>C.foreignKey&&C.foreignKey===m.foreignKey);S&&(a!=null&&a[m.foreignKey]?f={$or:[{[`${S.name}.${S.foreignKey}`]:{$is:null}},{[`${S.name}.${S.foreignKey}`]:{$eq:a==null?void 0:a[m.foreignKey]}}]}:f={[`${S.name}.${S.foreignKey}`]:{$is:null}})}f&&(h!=null&&h.filter?h.filter={$and:[f,h.filter]}:h.filter=f);try{h.filter=mergeFilter([o.filter,h.filter]),h=x(x({},o),h)}catch(S){console.error(S)}const{filter:_,parseVariableLoading:v}=useParsedFilter({filterOption:h==null?void 0:h.filter});return!import_lodash.default.isEmpty(h==null?void 0:h.filter)&&import_lodash.default.isEmpty(_)||v?null:(h!=null&&h.filter&&(h.filter=_),(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{scope:{treeTable:c},children:(0,import_jsx_runtime.jsx)(BlockProvider,P(x({name:"table-selector"},e),{params:h,children:(0,import_jsx_runtime.jsx)(InternalTableSelectorProvider,P(x({},e),{params:h,extraFilter:f}))}))}))}),useTableSelectorContext=()=>(0,import_react2.useContext)(TableSelectorContext),useTableSelectorProps$4=()=>{var e,t,o,r,i,n,a,l,c,u,m,d,p,g,h,f;const _=(0,import_react.useField)(),v=useTableSelectorContext(),S=(0,import_react.useFieldSchema)(),{getCollectionJoinField:C}=useCollectionManager_deprecated(),b=recursiveParent$1(S,"CollectionField"),y=C(b==null?void 0:b["x-collection-field"]);return(0,import_react2.useEffect)(()=>{var F,j,k,T,O,N,L,D,R,$,w,I,M;if(!((F=v==null?void 0:v.service)!=null&&F.loading)){const B=(k=(j=v==null?void 0:v.service)==null?void 0:j.data)==null?void 0:k.data.map(z=>z);_.value=B,(T=_==null?void 0:_.setInitialValue)==null||T.call(_,B),_.data=_.data||{},_.data.selectedRowKeys=[],_.componentProps.pagination=_.componentProps.pagination||{},_.componentProps.pagination.pageSize=(L=(N=(O=v==null?void 0:v.service)==null?void 0:O.data)==null?void 0:N.meta)==null?void 0:L.pageSize,_.componentProps.pagination.total=($=(R=(D=v==null?void 0:v.service)==null?void 0:D.data)==null?void 0:R.meta)==null?void 0:$.count,_.componentProps.pagination.current=(M=(I=(w=v==null?void 0:v.service)==null?void 0:w.data)==null?void 0:I.meta)==null?void 0:M.page}},[y==null?void 0:y.foreignKey,(t=(e=v==null?void 0:v.field)==null?void 0:e.data)==null?void 0:t.selectedRowKeys,(r=(o=v==null?void 0:v.service)==null?void 0:o.data)==null?void 0:r.data,(a=(n=(i=v==null?void 0:v.service)==null?void 0:i.data)==null?void 0:n.meta)==null?void 0:a.count,(u=(c=(l=v==null?void 0:v.service)==null?void 0:l.data)==null?void 0:c.meta)==null?void 0:u.page,(p=(d=(m=v==null?void 0:v.service)==null?void 0:m.data)==null?void 0:d.meta)==null?void 0:p.pageSize,(g=v==null?void 0:v.service)==null?void 0:g.loading,_]),{loading:(h=v==null?void 0:v.service)==null?void 0:h.loading,showIndex:!1,dragSort:!1,rowKey:v.rowKey||"id",pagination:((f=S==null?void 0:S["x-component-props"])==null?void 0:f.pagination)===!1?!1:_.componentProps.pagination,onRowSelectionChange(F,j){var k;v.field.data=((k=v==null?void 0:v.field)==null?void 0:k.data)||{},v.field.data.selectedRowKeys=F,v.field.data.selectedRowData=j},onRowDragEnd(F){return q(this,arguments,function*({from:j,to:k}){yield v.resource.move({sourceId:j[v.rowKey||"id"],targetId:k[v.rowKey||"id"]}),v.service.refresh()})},onChange({current:F,pageSize:j}){var k;v.service.run(P(x({},(k=v.service.params)==null?void 0:k[0]),{page:F,pageSize:j}))}}},BlockSchemaComponentProvider=e=>(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{components:{TableFieldProvider,TableBlockProvider,TableSelectorProvider,FormBlockProvider,FilterFormBlockProvider,FormFieldProvider,DetailsBlockProvider,RecordLink,Slider:import_antd.Slider},scope:P(x({},bp),{useSourceIdFromRecord,useSourceIdFromParentRecord,useParamsFromRecord,useFormBlockProps:useFormBlockProps$1,useCreateFormBlockProps,useCreateFormBlockDecoratorProps,useEditFormBlockDecoratorProps,useEditFormBlockProps,useFormFieldProps,useDetailsBlockProps,useDetailsProps,useDetailsWithPaginationProps,useDetailsDecoratorProps,useDetailsWithPaginationDecoratorProps,useTableFieldProps,useTableBlockProps,useTableSelectorProps:useTableSelectorProps$4,useTableBlockDecoratorProps,useListBlockDecoratorProps,useTableSelectorDecoratorProps,useCollapseBlockDecoratorProps,useFilterFormBlockProps,useFilterFormBlockDecoratorProps,useGridCardBlockDecoratorProps,useFormItemProps,useDataFormItemProps}),children:e.children});class BlockSchemaComponentPlugin extends Plugin{load(){return q(this,null,function*(){this.addComponents(),this.addScopes()})}addComponents(){this.app.addComponents({TableFieldProvider,TableBlockProvider,TableSelectorProvider,FormBlockProvider,FilterFormBlockProvider,FormFieldProvider,DetailsBlockProvider,RecordLink,BlockSchemaToolbar,ActionSchemaToolbar,FormItemSchemaToolbar,CollapseItemSchemaToolbar,TableColumnSchemaToolbar,Slider:import_antd.Slider})}addScopes(){this.app.addScopes(P(x({},bp),{useSourceIdFromRecord,useSourceIdFromParentRecord,useParamsFromRecord,useFormBlockProps:useFormBlockProps$1,useCreateFormBlockProps,useCreateFormBlockDecoratorProps,useEditFormBlockDecoratorProps,useEditFormBlockProps,useFormFieldProps,useDetailsBlockProps,useDetailsProps,useDetailsWithPaginationProps,useDetailsDecoratorProps,useDetailsWithPaginationDecoratorProps,useTableFieldProps,useTableBlockProps,useTableSelectorProps:useTableSelectorProps$4,useTableBlockDecoratorProps,useListBlockDecoratorProps,useTableSelectorDecoratorProps,useCollapseBlockDecoratorProps,useFilterFormBlockProps,useFilterFormBlockDecoratorProps,useGridCardBlockDecoratorProps,useFormItemProps,useDataFormItemProps}))}}const BlockTemplate=(0,import_react.observer)(e=>{const{templateId:t}=e,{getTemplateById:o}=useSchemaTemplateManager(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n}=useDesignable(),a=(0,import_react2.useMemo)(()=>o(t),[t]),{onTemplateSuccess:l}=useTemplateBlockContext(),c=u=>{var m,d;i["x-linkage-rules"]=((m=u==null?void 0:u.data)==null?void 0:m["x-linkage-rules"])||[],i.setProperties((d=u==null?void 0:u.data)==null?void 0:d.properties),l==null||l()};return a?(0,import_jsx_runtime.jsx)(BlockTemplateProvider,{dn:n,field:r,fieldSchema:i,template:a,children:(0,import_jsx_runtime.jsx)(RemoteSchemaComponent,{noForm:!0,uid:a==null?void 0:a.uid,onSuccess:c})}):(0,import_jsx_runtime.jsx)(CollectionDeletedPlaceholder,{type:"Block template",name:t})},{displayName:"BlockTemplate"}),SchemaTemplateManagerContext=(0,import_react2.createContext)({});SchemaTemplateManagerContext.displayName="SchemaTemplateManagerContext";const regenerateUid=e=>{e.name=e["x-uid"]=(0,import_shared.uid)(),Object.keys(e.properties||{}).forEach(t=>{regenerateUid(e.properties[t])})},useSchemaTemplate=()=>{const{getTemplateBySchema:e}=useSchemaTemplateManager(),t=(0,import_react.useFieldSchema)(),o=t["x-uid"],r=t["x-template-key"];return(0,import_react2.useMemo)(()=>e(t),[o,r])},useSchemaTemplateManager=()=>{const{getInheritCollections:e}=useCollectionManager_deprecated(),{refresh:t,templates:o=[]}=(0,import_react2.useContext)(SchemaTemplateManagerContext),r=useAPIClient();return{templates:o,refresh:t,getTemplateSchemaByMode:(0,import_react2.useCallback)(i=>q(void 0,null,function*(){const{mode:n,template:a}=i;if(n==="copy"){const{data:l}=yield r.request({url:`/uiSchemas:getJsonSchema/${a.uid}?includeAsyncNode=true`}),c=(l==null?void 0:l.data)||{};return regenerateUid(c),(0,import_lodash.cloneDeep)(c)}else if(n==="reference")return{type:"void","x-component":"BlockTemplate","x-component-props":{templateId:a.key}}}),[r]),copyTemplateSchema:(0,import_react2.useCallback)(i=>q(void 0,null,function*(){const{data:n}=yield r.request({url:`/uiSchemas:getJsonSchema/${i.uid}?includeAsyncNode=true`}),a=(n==null?void 0:n.data)||{};return regenerateUid(a),(0,import_lodash.cloneDeep)(a)}),[r]),saveAsTemplate:(0,import_react2.useCallback)(i=>q(void 0,null,function*(){const{uid:n}=i,a=(0,import_shared.uid)();return yield r.resource("uiSchemas").saveAsTemplate({filterByTk:n,values:x({key:a},i)}),yield t(),{key:a}}),[r,t]),getTemplateBySchema:(0,import_react2.useCallback)(i=>{if(!i)return;const n=i["x-template-key"];if(n)return o==null?void 0:o.find(l=>l.key===n);const a=i["x-uid"];if(a)return o==null?void 0:o.find(l=>l.uid===a)},[o]),getTemplateBySchemaId:(0,import_react2.useCallback)(i=>i?o==null?void 0:o.find(n=>n.uid===i):null,[o]),getTemplateById:(0,import_react2.useCallback)(i=>o==null?void 0:o.find(n=>n.key===i),[o]),getTemplatesByCollection:(0,import_react2.useCallback)((i,n)=>{var a;const l=e(n,i).concat([n]);return((a=o==null?void 0:o.filter)==null?void 0:a.call(o,c=>(c.dataSourceKey||DEFAULT_DATA_SOURCE_KEY)===i&&l.includes(c.collectionName)))||[]},[e,o]),getTemplatesByComponentName:(0,import_react2.useCallback)(i=>{var n;return((n=o==null?void 0:o.filter)==null?void 0:n.call(o,a=>a.componentName===i))||[]},[o])}},options={resource:"uiSchemaTemplates",action:"list",params:{paginate:!1},refreshDeps:[]},RemoteSchemaTemplateManagerProvider=e=>{var t;const o=useAPIClient(),r=useRequest(options),i=(0,import_react2.useCallback)(()=>q(void 0,null,function*(){const{data:a}=yield o.request(options);r.mutate(a)}),[o,r]),n=(0,import_react2.useMemo)(()=>{var a;return{templates:(a=r==null?void 0:r.data)==null?void 0:a.data,refresh:i}},[(t=r==null?void 0:r.data)==null?void 0:t.data,i]);return(0,import_jsx_runtime.jsx)(SchemaTemplateManagerContext.Provider,{value:n,children:e.children})};class RemoteSchemaTemplateManagerPlugin extends Plugin{load(){return q(this,null,function*(){this.addRoutes(),this.addComponents()})}addComponents(){this.app.addComponents({BlockTemplate})}addRoutes(){this.app.router.add("admin.plugins.block-templates-key",{path:"/admin/plugins/block-templates/:key",Component:"BlockTemplateDetails"})}}const useUpdateSchemaTemplateActionProps=()=>{const e=useUpdateActionProps(),{__parent:t}=useBlockRequestContext();return{onClick(){return q(this,null,function*(){var o,r;yield e.onClick(),(r=(o=t==null?void 0:t.service)==null?void 0:o.refresh)==null||r.call(o)})}}},useBulkDestroyTemplateProps=()=>{const e=useBulkDestroyActionProps(),t=useSchemaTemplateManager(),{service:o}=useBlockRequestContext();return{onClick(){return q(this,null,function*(){var r;yield e.onClick(),yield t.refresh(),(r=o==null?void 0:o.refresh)==null||r.call(o)})}}},useDestroyTemplateProps=()=>{const e=useDestroyActionProps(),{service:t}=useBlockRequestContext(),o=useSchemaTemplateManager();return{onClick(){return q(this,null,function*(){var r;yield e.onClick(),yield o.refresh(),(r=t==null?void 0:t.refresh)==null||r.call(t)})}}},uiSchemaTemplatesSchema={type:"object",properties:{[(0,import_shared.uid)()]:{type:"void","x-decorator":"TableBlockProvider","x-decorator-props":{collection:uiSchemaTemplatesCollection,resource:"uiSchemaTemplates",action:"list",params:{pageSize:20,sort:["-createdAt"]},rowKey:"key",showIndex:!0,dragSort:!1},"x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action","x-use-component-props":useBulkDestroyTemplateProps,"x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}},[(0,import_shared.uid)()]:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowSelection:{type:"checkbox"}},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined",refreshDataBlockRequest:!1},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{form:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"uiSchemaTemplates",collection:uiSchemaTemplatesCollection,action:"get",useParams:"{{ useParamsFromRecord }}"},"x-component":"CardItem",properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"uiSchemaTemplates.name",required:!0},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":useUpdateSchemaTemplateActionProps,"x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}}}}}}}}},destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":useDestroyTemplateProps,"x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}},column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-collection-field":"uiSchemaTemplates.name","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},column2:{type:"void",title:'{{t("Collection display name")}}',"x-component":"TableV2.Column",properties:{"collection.title":{type:"string","x-component":CollectionTitle,"x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}}}}}}}},BlockTemplatePage=()=>{const{t:e}=(0,import_react_i18next.useTranslation)();return(0,import_jsx_runtime.jsxs)("div",{children:[(0,import_jsx_runtime.jsx)(import_pro_layout.PageHeader,{style:{backgroundColor:"white"},ghost:!1,title:e("Block templates")}),(0,import_jsx_runtime.jsx)("div",{style:{margin:"var(--nb-spacing)"},children:(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:uiSchemaTemplatesSchema})})]})},BlockTemplatesPane=()=>(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:uiSchemaTemplatesSchema}),BlockTemplateContext=(0,import_react2.createContext)({componentNamePrefix:""}),BlockTemplateProvider=e=>(0,import_jsx_runtime.jsx)(BlockTemplateContext.Provider,{value:P(x({},e),{componentNamePrefix:e.componentNamePrefix||""}),children:e.children}),useBlockTemplateContext=()=>(0,import_react2.useContext)(BlockTemplateContext),itemsMerge=e=>e,gridRowColWrap=e=>({type:"void","x-component":"Grid.Row",properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"Grid.Col",properties:{[(e==null?void 0:e.name)||(0,import_shared.uid)()]:e}}}}),removeTableColumn=(e,t)=>{t(e.parent)},removeGridFormItem=(e,t)=>{t(e,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})},useRemoveGridFormItem=()=>{const e=(0,import_react.useForm)();return(t,o)=>{var r;o(t,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}),(r=e.values)==null||delete r[t.name]}},findTableColumn=(e,t,o,r)=>e.reduceProperties((i,n)=>n[t]===o&&(!r||n.name===r)?n:n.reduceProperties((l,c)=>c[t]===o&&(!r||c.name===r)?c:l)||i),quickEditField$1=["attachment","textarea","markdown","json","richText","polygon","circle","point","lineString"];function useTableColumnInitializerFields(){const{name:e,currentFields:t=[]}=useCollection_deprecated(),{getInterface:o,getCollection:r}=useCollectionManager_deprecated(),i=(0,import_react.useFieldSchema)()["x-component"]==="AssociationField.SubTable",n=(0,import_react.useForm)(),a=i?n.readPretty:!0;return t.filter(l=>!l.collectionName||l.collectionName===e).filter(l=>(l==null?void 0:l.interface)&&(l==null?void 0:l.interface)!=="subTable"&&!(l!=null&&l.treeChildren)).map(l=>{var c,u,m,d;const p=o(l.interface),g=(l==null?void 0:l.target)&&((c=r(l==null?void 0:l.target))==null?void 0:c.template)==="file",h=((u=l==null?void 0:l.uiSchema)==null?void 0:u["x-component"])==="Preview",f={name:l.name,"x-collection-field":`${e}.${l.name}`,"x-component":"CollectionField","x-component-props":g?{fieldNames:{label:"preview",value:"id"}}:h?{size:"small"}:{},"x-read-pretty":a||((m=l.uiSchema)==null?void 0:m["x-read-pretty"]),"x-decorator":i?quickEditField$1.includes(l.interface)||g?"QuickEdit":"FormItem":null,"x-decorator-props":{labelStyle:{display:"none"}}};return{type:"item",name:l.name,title:((d=l==null?void 0:l.uiSchema)==null?void 0:d.title)||l.name,Component:"TableCollectionFieldInitializer",find:findTableColumn,remove:removeTableColumn,schemaInitialize:_=>{var v;(v=p==null?void 0:p.schemaInitialize)==null||v.call(p,_,{field:l,readPretty:a,block:"Table",targetCollection:r(l.target)})},field:l,schema:f}})}function useAssociatedTableColumnInitializerFields(){var e;const{fields:t}=useCollection_deprecated(),{t:o}=(0,import_react_i18next.useTranslation)(),{getInterface:r,getCollectionFields:i,getCollection:n}=useCollectionManager_deprecated();return(e=t==null?void 0:t.filter(a=>["o2o","oho","obo","m2o"].includes(a.interface)))==null?void 0:e.map(a=>getGroupItemForTable({getCollectionFields:i,field:a,getInterface:r,getCollection:n,schemaName:a.name,maxDepth:2,depth:1,t:o}))}function getGroupItemForTable({getCollectionFields:e,field:t,getInterface:o,getCollection:r,schemaName:i,maxDepth:n,depth:a,t:l}){var c,u;const m=e(t.target),d=(c=m==null?void 0:m.filter(g=>(g==null?void 0:g.interface)&&!["subTable"].includes(g==null?void 0:g.interface)&&!(g!=null&&g.treeChildren)))==null?void 0:c.map(g=>{var h;const f=o(g.interface),_=`${i}.${g.name}`,v={name:_,"x-component":"CollectionField","x-read-pretty":!0,"x-collection-field":`${t.target}.${g.name}`,"x-component-props":{}};return{type:"item",name:_,title:((h=g==null?void 0:g.uiSchema)==null?void 0:h.title)||g.name,Component:"TableCollectionFieldInitializer",find:findTableColumn,remove:removeTableColumn,schemaInitialize:S=>{var C;(C=f==null?void 0:f.schemaInitialize)==null||C.call(f,S,{field:g,readPretty:!0,block:"Table",targetCollection:r(t.target)})},field:g,schema:v}}),p=[{type:"itemGroup",name:`${i}-displayCollectionFields`,title:l("Display fields"),children:d}];if(a<n){const g=m==null?void 0:m.filter(h=>["o2o","oho","obo","m2o"].includes(h.interface)).map(h=>getGroupItemForTable({getCollectionFields:e,field:h,getInterface:o,getCollection:r,schemaName:`${i}.${h.name}`,maxDepth:n,depth:a+1,t:l}));if(g.length){const h={type:"itemGroup",name:`${i}-associationFields`,title:l("Display association fields"),children:g};p.push(h)}}return{type:"subMenu",name:`${i}`,title:(u=t.uiSchema)==null?void 0:u.title,children:p}}function useInheritsTableColumnInitializerFields(){const{name:e}=useCollection_deprecated(),{getInterface:t,getInheritCollections:o,getCollection:r,getParentCollectionFields:i}=useCollectionManager_deprecated(),n=(0,import_react.useFieldSchema)()["x-component"]==="AssociationField.SubTable",a=(0,import_react.useForm)(),l=n?a.readPretty:!0,c=o(e);return c==null?void 0:c.map(u=>{const m=i(u,e),d=r(u);return{[d==null?void 0:d.title]:m==null?void 0:m.filter(p=>p==null?void 0:p.interface).map(p=>{var g,h,f,_;const v=t(p.interface),S=(p==null?void 0:p.target)&&((g=r(p==null?void 0:p.target))==null?void 0:g.template)==="file",C={name:`${p.name}`,"x-component":"CollectionField","x-read-pretty":l||((h=p.uiSchema)==null?void 0:h["x-read-pretty"]),"x-collection-field":`${e}.${p.name}`,"x-component-props":S?{fieldNames:{label:"preview",value:"id"}}:{},"x-decorator":n?quickEditField$1.includes(p.interface)||S?"QuickEdit":"FormItem":null,"x-decorator-props":{labelStyle:{display:"none"}}};return{name:((f=p==null?void 0:p.uiSchema)==null?void 0:f.title)||p.name,type:"item",title:((_=p==null?void 0:p.uiSchema)==null?void 0:_.title)||p.name,Component:"TableCollectionFieldInitializer",find:findTableColumn,remove:removeTableColumn,schemaInitialize:b=>{var y;(y=v==null?void 0:v.schemaInitialize)==null||y.call(v,b,{field:p,readPretty:!0,block:"Table",targetCollection:r(p==null?void 0:p.target)})},field:p,schema:C}})}})}const useFormItemInitializerFields=e=>{var t,o;const{name:r,currentFields:i}=useCollection_deprecated(),{getInterface:n,getCollection:a}=useCollectionManager_deprecated(),l=(0,import_react.useForm)(),{readPretty:c=l.readPretty,block:u="Form"}=e||{},{fieldSchema:m}=useActionContext(),d=m==null?void 0:m["x-action"];return(o=(t=i.filter(p=>!p.collectionName||p.collectionName===r))==null?void 0:t.filter(p=>(p==null?void 0:p.interface)&&!(p!=null&&p.treeChildren)))==null?void 0:o.map(p=>{var g,h,f,_,v;const S=n(p.interface),C=a(p.target),b=(p==null?void 0:p.target)&&((g=a(p==null?void 0:p.target))==null?void 0:g.template)==="file",y=C,F=(f=(h=p==null?void 0:p.uiSchema)==null?void 0:h["x-component-props"])==null?void 0:f.fieldNames,j={type:"string",name:p.name,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":`${r}.${p.name}`,"x-component-props":b?{fieldNames:{label:"preview",value:"id"}}:y&&F?{fieldNames:P(x({},F),{label:(C==null?void 0:C.titleField)||F.label})}:{},"x-read-pretty":(_=p==null?void 0:p.uiSchema)==null?void 0:_["x-read-pretty"]},k={type:"item",name:p.name,title:((v=p==null?void 0:p.uiSchema)==null?void 0:v.title)||p.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schemaInitialize:T=>{var O;(O=S==null?void 0:S.schemaInitialize)==null||O.call(S,T,{field:p,block:u,readPretty:c,action:d,targetCollection:C})},schema:j};return u=="Kanban"&&(k.find=(T,O,N)=>{const L=findSchema(T,"x-component",u);return findSchema(L,O,N)}),k})},useFilterFormItemInitializerFields=e=>{var t,o;const{name:r,currentFields:i}=useCollection_deprecated(),{getInterface:n,getCollection:a}=useCollectionManager_deprecated(),l=(0,import_react.useForm)(),{readPretty:c=l.readPretty,block:u="FilterForm"}=e||{},{snapshot:m,fieldSchema:d}=useActionContext(),p=d==null?void 0:d["x-action"];return(o=(t=i.filter(g=>!g.collectionName||g.collectionName===r))==null?void 0:t.filter(g=>{var h;return(g==null?void 0:g.interface)&&((h=n(g.interface))==null?void 0:h.filterable)}))==null?void 0:o.map(g=>{var h,f,_;const v=n(g.interface),S=a(g.target);let C={type:"string",name:g.name,required:!1,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FilterFormItem","x-component":"CollectionField","x-decorator":"FormItem","x-use-decorator-props":"useFormItemProps","x-collection-field":`${r}.${g.name}`,"x-component-props":{utc:!1,underFilter:!0}};return isAssocField(g)&&(C={type:"string",name:`${g.name}`,required:!1,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FilterFormItem","x-component":"CollectionField","x-decorator":"FormItem","x-use-decorator-props":"useFormItemProps","x-collection-field":`${r}.${g.name}`,"x-component-props":P(x({},(h=g.uiSchema)==null?void 0:h["x-component-props"]),{utc:!1,underFilter:!0})}),{name:((f=g==null?void 0:g.uiSchema)==null?void 0:f.title)||g.name,type:"item",title:((_=g==null?void 0:g.uiSchema)==null?void 0:_.title)||g.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schemaInitialize:b=>{var y;(y=v==null?void 0:v.schemaInitialize)==null||y.call(v,b,{field:g,block:u,readPretty:c,action:p,targetCollection:S})},schema:C}})},useAssociatedFormItemInitializerFields=e=>{var t;const{name:o,fields:r}=useCollection_deprecated(),{getInterface:i,getCollectionFields:n,getCollection:a}=useCollectionManager_deprecated(),l=(0,import_react.useForm)(),{t:c}=(0,import_react_i18next.useTranslation)(),{readPretty:u=l.readPretty,block:m="Form"}=e||{},d=m==="Form"?["m2o","obo","oho"]:["o2o","oho","obo","m2o"];return(t=r==null?void 0:r.filter(p=>d.includes(p.interface)))==null?void 0:t.map(p=>getGroupItemForForm({getCollectionFields:n,field:p,getInterface:i,getCollection:a,readPretty:u,block:m,schemaName:p.name,maxDepth:2,depth:1,t:c}))},associationFieldToMenu=(e,t,o,r,i)=>{var n,a,l;if(e.target&&e.uiSchema){if(i.includes(e.target)||i.length>=1)return;const u=r(e.target);return u!=null&&u.length?{type:"subMenu",name:t,title:(n=e.uiSchema)==null?void 0:n.title,children:u.map(m=>associationFieldToMenu(m,`${t}.${m.name}`,o,r,[...i,e.target])).filter(Boolean)}:void 0}if(!e.uiSchema)return;const c={type:"string",name:t,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FilterFormItem","x-designer-props":{interface:e.interface},"x-component":"CollectionField","x-component-props":{utc:!1,underFilter:!0},"x-read-pretty":!1,"x-decorator":"FormItem","x-collection-field":`${o}.${t}`};return{name:((a=e.uiSchema)==null?void 0:a.title)||e.name,type:"item",title:((l=e.uiSchema)==null?void 0:l.title)||e.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schema:c}},useFilterAssociatedFormItemInitializerFields=()=>{const{name:e,fields:t}=useCollection_deprecated(),{getCollectionFields:o}=useCollectionManager_deprecated(),r=["o2o","oho","obo","m2o","m2m"];return t==null?void 0:t.filter(i=>i.target&&i.uiSchema&&r.includes(i.interface)).map(i=>associationFieldToMenu(i,i.name,e,o,[])).filter(Boolean)},useInheritsFormItemInitializerFields=e=>{const{name:t}=useCollection_deprecated(),{getInterface:o,getInheritCollections:r,getCollection:i,getParentCollectionFields:n}=useCollectionManager_deprecated(),a=r(t);useActionContext();const l=(0,import_react.useForm)();return a==null?void 0:a.map(c=>{var u;const m=n(c,t),{readPretty:d=l.readPretty,block:p="Form",component:g="CollectionField"}=e||{},h=i(c);return{[h==null?void 0:h.title]:(u=m==null?void 0:m.filter(f=>f==null?void 0:f.interface))==null?void 0:u.map(f=>{var _,v,S,C;const b=o(f.interface),y=i(f.target),F={type:"string",name:f.name,title:((_=f==null?void 0:f.uiSchema)==null?void 0:_.title)||f.name,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem","x-component":g,"x-decorator":"FormItem","x-collection-field":`${t}.${f.name}`,"x-component-props":{},"x-read-pretty":(v=f==null?void 0:f.uiSchema)==null?void 0:v["x-read-pretty"]};return{name:((S=f==null?void 0:f.uiSchema)==null?void 0:S.title)||f.name,type:"item",title:((C=f==null?void 0:f.uiSchema)==null?void 0:C.title)||f.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schemaInitialize:j=>{var k;(k=b==null?void 0:b.schemaInitialize)==null||k.call(b,j,{field:f,block:p,readPretty:d,targetCollection:y})},schema:F}})}})},useFilterInheritsFormItemInitializerFields=e=>{const{name:t}=useCollection_deprecated(),{getInterface:o,getInheritCollections:r,getCollection:i,getParentCollectionFields:n}=useCollectionManager_deprecated(),a=r(t);useActionContext();const l=(0,import_react.useForm)();return a==null?void 0:a.map(c=>{var u;const m=n(c,t),{readPretty:d=l.readPretty,block:p="Form"}={};return{[i(c).title]:(u=m==null?void 0:m.filter(g=>{var h;return(g==null?void 0:g.interface)&&((h=o(g.interface))==null?void 0:h.filterable)}))==null?void 0:u.map(g=>{var h,f,_,v;const S=o(g.interface),C=i(g.target),b={type:"string",name:g.name,title:((h=g==null?void 0:g.uiSchema)==null?void 0:h.title)||g.name,required:!1,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FilterFormItem","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":`${t}.${g.name}`,"x-component-props":{utc:!1,underFilter:!0},"x-read-pretty":(f=g==null?void 0:g.uiSchema)==null?void 0:f["x-read-pretty"]};return{name:((_=g==null?void 0:g.uiSchema)==null?void 0:_.title)||g.name,type:"item",title:((v=g==null?void 0:g.uiSchema)==null?void 0:v.title)||g.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schemaInitialize:y=>{var F;(F=S==null?void 0:S.schemaInitialize)==null||F.call(S,y,{field:g,block:p,readPretty:d,targetCollection:C})},schema:b}})}})},useCustomFormItemInitializerFields=e=>{var t;const{name:o,currentFields:r}=useCollection_deprecated(),{getInterface:i,getCollection:n}=useCollectionManager_deprecated(),a=(0,import_react.useForm)(),{readPretty:l=a.readPretty,block:c="Form"}=e||{},u=useRemoveGridFormItem();return(t=r==null?void 0:r.filter(m=>(m==null?void 0:m.interface)&&m.interface!=="snapshot"&&m.type!=="sequence"))==null?void 0:t.map(m=>{var d,p,g;const h=i(m.interface),f={type:"string",name:m.name,title:((d=m==null?void 0:m.uiSchema)==null?void 0:d.title)||m.name,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem","x-component":"AssignedField","x-decorator":"FormItem","x-collection-field":`${o}.${m.name}`};return{name:((p=m==null?void 0:m.uiSchema)==null?void 0:p.title)||m.name,type:"item",title:((g=m==null?void 0:m.uiSchema)==null?void 0:g.title)||m.name,Component:"CollectionFieldInitializer",remove:u,schemaInitialize:_=>{var v;(v=h==null?void 0:h.schemaInitialize)==null||v.call(h,_,{field:m,block:c,readPretty:l,targetCollection:n(m.target)})},schema:f}})},findSchema=(e,t,o,r)=>import_react.Schema.isSchemaInstance(e)?e.reduceProperties((i,n)=>{if(n[t]===o&&(!r||n.name===r))return n;if(n["x-component"]!=="Action.Container"&&!n["x-component"].includes("AssociationField")){const a=findSchema(n,t,o,r);if(a)return a}return i}):null,removeSchema=(e,t)=>t(e),recursiveParent=e=>e.parent?e.parent["x-initializer"]?e.parent:recursiveParent(e.parent):null,useCurrentSchema=(e,t,o=findSchema,r=removeSchema,i)=>{const{removeActiveFieldName:n}=useFormActiveFields()||{},{form:a}=useFormBlockContext();let l=(0,import_react.useFieldSchema)();if(!(l!=null&&l["x-initializer"])&&(l==null?void 0:l["x-decorator"])==="FormItem"){const m=recursiveParent(l);m&&(l=m)}const{remove:c}=useDesignable(),u=o(l,t,e,i);return{schema:u,exists:!!u,remove(){n==null||n(u.name),a==null||a.query(new RegExp(`${u.parent.name}.${u.name}$`)).forEach(m=>{var d,p;(d=m.setValue)==null||d.call(m,void 0),(p=m.setInitialValue)==null||p.call(m,void 0)}),u&&r(u,c)}}},useRecordCollectionDataSourceItems=(e,t=null,o=null,r=null)=>{const{t:i}=(0,import_react_i18next.useTranslation)(),n=useCollection_deprecated(),{getTemplatesByCollection:a}=useSchemaTemplateManager(),l=a(n.dataSource,o||n.name).filter(u=>e&&u.componentName===e).filter(u=>["FormItem","ReadPrettyFormItem"].includes(e)||u.resourceName===r);if(!l.length)return[];const c=0;return[{key:`${o||e}_table_blank`,type:"item",name:n.name,title:i("Blank block"),item:t},{type:"divider"},{key:`${o||e}_table_subMenu_${c}_copy`,type:"subMenu",name:"copy",title:i("Duplicate template"),children:l.map(u=>{const m=["FormItem","ReadPrettyFormItem"].includes(u==null?void 0:u.componentName)?`${u==null?void 0:u.name} ${i("(Fields only)")}`:u==null?void 0:u.name;return{type:"item",mode:"copy",name:n.name,template:u,item:t,title:m||i("Untitled")}})},{key:`${o||e}_table_subMenu_${c}_ref`,type:"subMenu",name:"ref",title:i("Reference template"),children:l.map(u=>{const m=["FormItem","ReadPrettyFormItem"].includes(u==null?void 0:u.componentName)?`${u==null?void 0:u.name} ${i("(Fields only)")}`:u==null?void 0:u.name;return{type:"item",mode:"reference",name:n.name,template:u,item:t,title:m||i("Untitled")}})}]},useCollectionDataSourceItems=({name:e,componentName:t,filter:o=()=>!0,onlyCurrentDataSource:r=!1,showAssociationFields:i,filterDataSource:n,dataBlockInitializerProps:a,hideOtherRecordsInPopup:l,onClick:c,filterOtherRecordsCollection:u,currentText:m,otherText:d})=>{const{componentNamePrefix:p}=useBlockTemplateContext(),{t:g}=(0,import_react_i18next.useTranslation)(),h=useDataSourceManager(),f=useDataSourceKey(),_=useCollection(),v=useAssociationFields({componentName:p+t,filterCollections:o,showAssociationFields:i,componentNamePrefix:p}),S=useAssociationName();let C=h.getAllCollections({filterCollection:F=>r&&F.dataSource!==f?!1:o({collection:F}),filterDataSource:n});r&&(C=C.filter(F=>F.key===f));const{getTemplatesByCollection:b}=useSchemaTemplateManager(),y=(0,import_react2.useMemo)(()=>C.map(({key:F,displayName:j,collections:k})=>({name:F,label:j,type:"subMenu",children:[...getChildren$1({name:e,association:S,collections:k,componentName:p+t,searchValue:"",dataSource:F,getTemplatesByCollection:b,t:g,componentNamePrefix:p}).sort(T=>{const O=import_lodash.default.toArray((_==null?void 0:_.inherits)||[]);if(T.name===(_==null?void 0:_.name)||O.some(N=>N===T.name))return-1})]})),[C,_==null?void 0:_.inherits,_==null?void 0:_.name,t,b,g]);return i?(0,import_react2.useMemo)(()=>{var F;const j={name:"currentRecord",collectionName:_.name,dataSource:_.dataSource,Component:DataBlockInitializer,onClick(){},componentProps:P(x({},a),{icon:null,title:m||g("Current record"),name:"currentRecord",hideSearch:!1,hideChildrenIfSingleCollection:!0,items:y})},k={name:"associationRecords",Component:DataBlockInitializer,onClick(){},componentProps:P(x({},a),{icon:null,title:g("Associated records"),name:"associationRecords",hideSearch:!1,items:[{name:"associationFields",label:g("Association fields"),type:"subMenu",children:v}]})},T={ReadPrettyFormItem:"Details"},O={name:"otherRecords",Component:DataBlockInitializer,onClick(){},componentProps:P(x({},a),{hideSearch:!1,icon:null,title:d||g("Other records"),name:"otherRecords",showAssociationFields:!1,onlyCurrentDataSource:!1,hideChildrenIfSingleCollection:!1,fromOthersInPopup:!0,componentType:T[t]||t,filter({collection:D,associationField:R}){return u?u(D):!0},onClick(D){c(P(x({},D),{fromOthersInPopup:!0}))}})};let N;const L=v.length?k:null;if(y[0].children.length&&v.length)l?N=[j,L]:N=[j,L,O];else if(y[0].children.length)if(l){if(y[0].children.length<=1)return y[0].children=((F=y[0].children[0])==null?void 0:F.children)||[],y;N=[j]}else N=[j,O];else l?N=[L]:N=[L,O];return[{name:"records",label:g("Records"),type:"subMenu",children:N.filter(Boolean)}]},[v,_.dataSource,_.name,t,a,u,l,y,c,g]):y},createDetailsBlockSchema=e=>{const t=e,{formItemInitializers:o="details:configureFields",actionInitializers:r="detailsWithPaging:configureActions",collection:i,dataSource:n,association:a,template:l,settings:c,action:u="list"}=t,m=K(t,["formItemInitializers","actionInitializers","collection","dataSource","association","template","settings","action"]),d=a||i;return{type:"void","x-acl-action":u==="get"?`${d}:get`:`${d}:view`,"x-decorator":"DetailsBlockProvider","x-decorator-props":x(x({dataSource:n,collection:i,association:a,readPretty:!0,action:u},u==="list"?{params:{pageSize:1}}:{}),m),"x-toolbar":"BlockSchemaToolbar","x-settings":c,"x-component":"CardItem",properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"Details","x-use-component-props":"useDetailsBlockProps","x-read-pretty":!0,properties:x({[(0,import_shared.uid)()]:{type:"void","x-initializer":r,"x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{}},grid:l||{type:"void","x-component":"Grid","x-initializer":o,properties:{}}},u==="list"?{pagination:{type:"void","x-component":"Pagination","x-use-component-props":"useDetailsPaginationProps"}}:{})}}}},createFormBlockSchema=e=>{const t=e,{formItemInitializers:o="form:configureFields",actionInitializers:r="createForm:configureActions",collection:i,resource:n,dataSource:a,association:l,action:c,actions:u={},"x-designer":m="FormV2.Designer",template:d,title:p,settings:g}=t,h=K(t,["formItemInitializers","actionInitializers","collection","resource","dataSource","association","action","actions","x-designer","template","title","settings"]),f=n||l||i;return P(x({type:"void","x-acl-action-props":{skipScopeCheck:!c},"x-acl-action":c?`${f}:update`:`${f}:create`,"x-decorator":"FormBlockProvider","x-decorator-props":P(x({},h),{action:c,dataSource:a,resource:f,collection:i,association:l}),"x-toolbar":"BlockSchemaToolbar"},g?{"x-settings":g}:{"x-designer":m}),{"x-component":"CardItem","x-component-props":{title:p},properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{grid:d||{type:"void","x-component":"Grid","x-initializer":o,properties:{}},[(0,import_shared.uid)()]:{type:"void","x-initializer":r,"x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:u}}}}})},createReadPrettyFormBlockSchema=e=>{const t=e,{formItemInitializers:o="details:configureFields",actionInitializers:r="details:configureActions",collection:i,association:n,dataSource:a,resource:l,template:c,settings:u}=t,m=K(t,["formItemInitializers","actionInitializers","collection","association","dataSource","resource","template","settings"]),d=l||n||i;return{type:"void","x-acl-action":`${d}:get`,"x-decorator":"FormBlockProvider","x-decorator-props":x({resource:d,collection:i,association:n,dataSource:a,readPretty:!0,action:"get",useParams:"{{ useParamsFromRecord }}"},m),"x-toolbar":"BlockSchemaToolbar","x-settings":u,"x-component":"CardItem",properties:{[(0,import_shared.uid)()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps","x-read-pretty":!0,properties:{[(0,import_shared.uid)()]:{type:"void","x-initializer":r,"x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{}},grid:c||{type:"void","x-component":"Grid","x-initializer":o,properties:{}}}}}}},createTableBlockSchema=e=>{const t=e,{collection:o,rowKey:r,tableActionInitializers:i,tableColumnInitializers:n,tableActionColumnInitializers:a,tableBlockProvider:l,disableTemplate:c,dataSource:u,blockType:m,pageSize:d=20}=t,p=K(t,["collection","rowKey","tableActionInitializers","tableColumnInitializers","tableActionColumnInitializers","tableBlockProvider","disableTemplate","dataSource","blockType","pageSize"]);return{type:"void","x-decorator":l??"TableBlockProvider","x-acl-action":`${o}:list`,"x-decorator-props":x({collection:o,dataSource:u,action:"list",params:{pageSize:d},rowKey:r,showIndex:!0,dragSort:!1,disableTemplate:c??!1,blockType:m},p),"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":i??"table:configureActions","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{}},[(0,import_shared.uid)()]:{type:"array","x-initializer":n??"table:configureColumns","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-designer":"TableV2.ActionColumnDesigner","x-initializer":a??"table:configureItemActions",properties:{[(0,import_shared.uid)()]:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{},properties:{}}}}}}}}},getChildren$1=({name:e,association:t,collections:o,dataSource:r,componentName:i,searchValue:n,getTemplatesByCollection:a,t:l,componentNamePrefix:c})=>{var u;return(u=o==null?void 0:o.filter(m=>{if(m.inherit)return!1;if(m.filterTargetKey){if([c+"Kanban",c+"FormItem"].includes(i)&&(m.template==="view"&&!m.writableView||m.template==="sql")||m.template==="file"&&[c+"Kanban",c+"FormItem",c+"Calendar"].includes(i))return!1;{const d=m.title||m.tableName;return d?d.toUpperCase().includes(n.toUpperCase())&&!(m!=null&&m.isThrough&&m!=null&&m.autoCreate):!1}}else return!1}))==null?void 0:u.map((m,d)=>{const p=m.title||m.tableName||m.label,g=a(r,m.name).filter(h=>{var f;const _=e!=="otherRecords"&&t;return _?h.resourceName!==t?!1:i&&h.componentName===i:!_&&(f=h==null?void 0:h.resourceName)!=null&&f.includes(".")?!1:i&&h.componentName===i});return g.length?{key:`${i}_table_subMenu_${d}`,type:"subMenu",name:`${m.name}_${d}`,title:p,dataSource:r,children:[{type:"item",name:m.name,dataSource:r,title:l("Blank block")},{type:"divider"},{key:`${i}_table_subMenu_${d}_copy`,type:"subMenu",name:"copy",dataSource:r,title:l("Duplicate template"),children:g.map(h=>{const f=[c+"FormItem",c+"ReadPrettyFormItem"].includes(h==null?void 0:h.componentName)?`${h==null?void 0:h.name} ${l("(Fields only)")}`:h==null?void 0:h.name;return{type:"item",mode:"copy",name:m.name,template:h,dataSource:r,title:f||l("Untitled")}})},{key:`${i}_table_subMenu_${d}_ref`,type:"subMenu",name:"ref",dataSource:r,title:l("Reference template"),children:g.map(h=>{const f=[c+"FormItem",c+"ReadPrettyFormItem"].includes(h==null?void 0:h.componentName)?`${h==null?void 0:h.name} ${l("(Fields only)")}`:h==null?void 0:h.name;return{type:"item",mode:"reference",name:m.name,template:h,dataSource:r,title:f||l("Untitled")}})}]}:{type:"item",name:m.name,title:p,dataSource:r}})};function getGroupItemForForm({getCollectionFields:e,field:t,getInterface:o,getCollection:r,readPretty:i,block:n,maxDepth:a,depth:l,schemaName:c,t:u}){var m,d;const p=e(t.target),g=(m=p==null?void 0:p.filter(f=>(f==null?void 0:f.interface)&&!["subTable"].includes(f==null?void 0:f.interface)&&!f.treeChildren))==null?void 0:m.map(f=>{var _,v;const S=o(f.interface),C=(t==null?void 0:t.target)&&((_=r(t==null?void 0:t.target))==null?void 0:_.template)==="file",b=`${c}.${f.name}`,y={type:"string",name:b,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem","x-component":"CollectionField","x-read-pretty":i,"x-component-props":{"pattern-disable":n==="Form"&&i,fieldNames:C?{label:"preview",value:"id"}:void 0},"x-decorator":"FormItem","x-collection-field":`${t.target}.${f.name}`};return{name:b,type:"item",title:((v=f==null?void 0:f.uiSchema)==null?void 0:v.title)||f.name,Component:"CollectionFieldInitializer",remove:removeGridFormItem,schemaInitialize:F=>{var j;(j=S==null?void 0:S.schemaInitialize)==null||j.call(S,F,{field:f,block:n,readPretty:i,targetCollection:r(t.target)})},schema:y}}),h=[{type:"itemGroup",name:`${c}-displayCollectionFields`,title:u("Display fields"),children:g}];if(l<a){const f=p==null?void 0:p.filter(_=>["o2o","oho","obo","m2o"].includes(_.interface)).map(_=>getGroupItemForForm({getCollectionFields:e,field:_,getInterface:o,getCollection:r,schemaName:`${c}.${_.name}`,readPretty:i,block:n,maxDepth:a,depth:l+1,t:u}));if(f.length){const _={type:"itemGroup",name:`${c}-associationFields`,title:u("Display association fields"),children:f};h.push(_)}}return{type:"subMenu",name:`${c}.${t.name}`,title:(d=t.uiSchema)==null?void 0:d.title,children:h}}function useAssociationFields({componentName:e,filterCollections:t,showAssociationFields:o,componentNamePrefix:r}){const i=(0,import_react.useFieldSchema)(),{getCollectionFields:n}=useCollectionManager_deprecated(),a=useCollection_deprecated();useCollectionManager();const l=useDataSourceKey(),{getTemplatesByCollection:c}=useSchemaTemplateManager(),{t:u}=(0,import_react_i18next.useTranslation)(),m=useCompile();return(0,import_react2.useMemo)(()=>{if(!o)return[];let d=[];if(i["x-initializer"])d=a.fields;else{const p=recursiveParent(i.parent);p&&(d=n(p))}return d.filter(p=>["linkTo","subTable","o2m","m2m","obo","oho","o2o","m2o"].includes(p.interface)).filter(p=>t({associationField:p})).map((p,g)=>{const h=m(p.uiSchema.title||p.name),f=c(l,p.target).filter(_=>_.resourceName!==`${p.collectionName}.${p.name}`?!1:e===r+"ReadPrettyFormItem"?["hasOne","belongsTo"].includes(p.type)?_.componentName===r+"ReadPrettyFormItem":_.componentName===r+"Details":_.componentName===e);return f.length?{key:`associationFiled_${e}_table_subMenu_${g}`,type:"subMenu",name:`${p.target}_${g}`,title:h,dataSource:l,children:[{type:"item",name:`${p.collectionName}.${p.name}`,collectionName:p.target,dataSource:l,title:u("Blank block"),associationField:p},{type:"divider"},{key:`associationFiled_${e}_table_subMenu_${g}_copy`,type:"subMenu",name:"copy",dataSource:l,title:u("Duplicate template"),children:f.map(_=>{const v=[r+"FormItem",r+"ReadPrettyFormItem"].includes(_==null?void 0:_.componentName)?`${_==null?void 0:_.name} ${u("(Fields only)")}`:_==null?void 0:_.name;return{type:"item",mode:"copy",name:`${p.collectionName}.${p.name}`,collectionName:p.target,template:_,dataSource:l,title:v||u("Untitled"),associationField:p}})},{key:`associationFiled_${e}_table_subMenu_${g}_ref`,type:"subMenu",name:"ref",dataSource:l,title:u("Reference template"),children:f.map(_=>{const v=[r+"FormItem",r+"ReadPrettyFormItem"].includes(_==null?void 0:_.componentName)?`${_==null?void 0:_.name} ${u("(Fields only)")}`:_==null?void 0:_.name;return{type:"item",mode:"reference",name:`${p.collectionName}.${p.name}`,collectionName:p.target,template:_,dataSource:l,title:v||u("Untitled"),associationField:p}})}]}:{type:"item",name:`${p.collectionName}.${p.name}`,collectionName:p.target,title:h,dataSource:l,associationField:p}})},[a.fields,m,e,l,i,t,n,c,o,u,r])}const useGetAriaLabelOfDesigner=()=>{const e=(0,import_react.useFieldSchema)(),{name:t}=useCollection_deprecated();return{getAriaLabel:(0,import_react2.useCallback)((o,r)=>{if(!e)return"";const i=e["x-component"],n=typeof i=="string"?i:(i==null?void 0:i.displayName)||(i==null?void 0:i.name),a=e["x-designer"]?`-${e["x-designer"]}`:"",l=e["x-settings"]?`-${e["x-settings"]}`:"",c=e["x-collection-field"]?`-${e["x-collection-field"]}`:"",u=t?`-${t}`:"";return r=r?`-${r}`:"",`designer-${o}-${n}${a}${l}${u}${c}${r}`},[e,t])}},useStyles$f=genStyleHook("nb-schema-toolbar",e=>{const{componentCls:t}=e;return{[t]:{position:"absolute",zIndex:999,top:0,left:0,right:0,bottom:0,border:"2px solid var(--colorBorderSettingsHover)",background:"var(--colorBgSettingsHover)",pointerEvents:"none","&.hidden":{transform:"scale(0)",pointerEvents:"none"},"&.hidden-e2e":{display:"none"},".ant-space-item .anticon":{margin:0},".toolbar-title":{pointerEvents:"none",position:"absolute",fontSize:12,padding:0,lineHeight:"16px",height:"16px",borderBottomRightRadius:2,borderRadius:2,top:2,left:2},".toolbar-title-tag":{padding:"0 3px",borderRadius:2,background:"var(--colorSettings)",color:"#fff",display:"block"},".toolbar-icons":{position:"absolute",right:"2px",top:"2px",lineHeight:"16px",pointerEvents:"all",".ant-space-item":{backgroundColor:"var(--colorSettings)",color:"#fff",lineHeight:"16px",width:"16px",paddingLeft:"1px",alignSelf:"stretch"}}}}}),titleCss=import_css.css`
257
257
  pointer-events: none;
258
258
  position: absolute;
259
259
  font-size: 12px;
@@ -296,7 +296,7 @@ ${JSON.stringify(B,null,2)}`)},[u,c,l,i,r,j,t,a,n,h,o,f,C,k,b,y,g]),O=(0,import_
296
296
  return false;
297
297
  }
298
298
  }}}`,message:'{{t("Invalid JSON format")}}'},requestSettingsSchema={type:"object",properties:{url:{type:"string",title:'{{t("Request URL")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},method:{type:"string",title:'{{t("Request method")}}',"x-decorator":"FormItem","x-component":"Select",default:"POST",enum:[{label:"POST",value:"POST"},{label:"GET",value:"GET"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}]},headers:{type:"string",title:'{{t("Request headers")}}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-validator":validateJSON$1},params:{type:"string",title:'{{t("Request query parameters")}}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-validator":validateJSON$1},data:{type:"string",title:'{{t("Request body")}}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-validator":validateJSON$1}}},linkageAction=e=>q(void 0,[e],function*({operator:t,field:o,condition:r,variables:i,localVariables:n}){var a,l,c;const u=((a=o==null?void 0:o.stateOfLinkageRules)==null?void 0:a.disabled)||[!1],m=((l=o==null?void 0:o.stateOfLinkageRules)==null?void 0:l.display)||["visible"];switch(t){case ActionType.Visible:(yield conditionAnalyses({ruleGroup:r,variables:i,localVariables:n}))&&(m.push(t),o.data=o.data||{},o.data.hidden=!1),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{display:m}),o.display=(0,import_lodash.last)(m);break;case ActionType.Hidden:(yield conditionAnalyses({ruleGroup:r,variables:i,localVariables:n}))?(o.data=o.data||{},o.data.hidden=!0):(o.data=o.data||{},o.data.hidden=!1);break;case ActionType.Disabled:(yield conditionAnalyses({ruleGroup:r,variables:i,localVariables:n}))&&u.push(!0),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{disabled:u}),o.disabled=(0,import_lodash.last)(u),o.componentProps.disabled=(0,import_lodash.last)(u);break;case ActionType.Active:(yield conditionAnalyses({ruleGroup:r,variables:i,localVariables:n}))?u.push(!1):u.push(!!((c=o.componentProps)!=null&&c.disabled)),o.stateOfLinkageRules=P(x({},o.stateOfLinkageRules),{disabled:u}),o.disabled=(0,import_lodash.last)(u),o.componentProps.disabled=(0,import_lodash.last)(u);break;default:return null}}),setInitialActionState=e=>{e.data=e.data||{},e.display="visible",e.disabled=!1,e.data.hidden=!1,e.componentProps.disabled=!1},MenuGroup=e=>e.children;function ButtonEditor$1(e){var t,o,r,i;const n=(0,import_react.useField)(),a=(0,import_react.useFieldSchema)(),{dn:l}=useDesignable(),{t:c}=(0,import_react_i18next.useTranslation)(),u=(e==null?void 0:e.isLink)||a["x-component"]==="Action.Link";return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:c("Edit button"),schema:{type:"object",title:c("Edit button"),properties:{title:{"x-decorator":"FormItem","x-component":"Input",title:c("Button title"),default:a.title,"x-component-props":{}},icon:{"x-decorator":"FormItem","x-component":"IconPicker",title:c("Button icon"),default:(t=a==null?void 0:a["x-component-props"])==null?void 0:t.icon,"x-component-props":{},"x-visible":!u},iconColor:{title:c("Color"),required:!0,default:((o=a==null?void 0:a["x-component-props"])==null?void 0:o.iconColor)||"#1677FF","x-hidden":!e.hasIconColor,"x-component":"ColorPicker","x-decorator":"FormItem"},type:{"x-decorator":"FormItem","x-component":"Radio.Group",title:c("Button background color"),default:(r=a==null?void 0:a["x-component-props"])!=null&&r.danger?"danger":((i=a==null?void 0:a["x-component-props"])==null?void 0:i.type)==="primary"?"primary":"default",enum:[{value:"default",label:'{{t("Default")}}'},{value:"primary",label:'{{t("Highlight")}}'},{value:"danger",label:'{{t("Danger red")}}'}],"x-visible":!e.hasIconColor&&!u}}},onSubmit:({title:m,icon:d,type:p,iconColor:g})=>{n.address.toString()===a.name?(n.title=m,n.componentProps.iconColor=g,n.componentProps.icon=d,n.componentProps.danger=p==="danger",n.componentProps.type=p||n.componentProps.type):n.form.query(new RegExp(`.${a.name}$`)).forEach(h=>{h.title=m,h.componentProps.iconColor=g,h.componentProps.icon=d,h.componentProps.danger=p==="danger",h.componentProps.type=p||h.componentProps.type}),a.title=m,a["x-component-props"]=a["x-component-props"]||{},a["x-component-props"].iconColor=g,a["x-component-props"].icon=d,a["x-component-props"].danger=p==="danger",a["x-component-props"].type=p||n.componentProps.type,l.emit("patch",{schema:{"x-uid":a["x-uid"],title:m,"x-component-props":x({},a["x-component-props"])}}),l.refresh()}})}function AssignedFieldValues(){var e,t,o;const{dn:r}=useDesignable(),{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useFieldSchema)(),a={type:"void","x-uid":(0,import_shared.uid)(),"x-component":"Grid","x-initializer":"assignFieldValuesForm:configureFields"},l={"customize:update":i("After clicking the custom button, the following fields of the current record will be saved according to the following form."),"customize:save":i("After clicking the custom button, the following fields of the current record will be saved according to the following form.")},c=(e=n["x-action"])!=null?e:"",u=(0,import_react2.useCallback)(m=>{n["x-action-settings"].assignedValues=m,r.emit("patch",{schema:{"x-uid":n["x-uid"],"x-action-settings":n["x-action-settings"]}})},[r,n]);return(0,import_jsx_runtime.jsx)(FlagProvider,{isInAssignFieldValues:!0,children:(0,import_jsx_runtime.jsx)(DefaultValueProvider,{isAllowToSetDefaultValue:()=>!1,children:(0,import_jsx_runtime.jsx)(SchemaSettingsActionModalItem,{title:i("Assign field values"),initialSchema:a,initialValues:(t=n==null?void 0:n["x-action-settings"])==null?void 0:t.assignedValues,modalTip:l[c],uid:(o=n==null?void 0:n["x-action-settings"])==null?void 0:o.schemaUid,onSubmit:u})})})}function RequestSettings(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)();return(0,import_jsx_runtime.jsx)(SchemaSettingsActionModalItem,{title:o("Request settings"),schema:requestSettingsSchema,initialValues:(e=r==null?void 0:r["x-action-settings"])==null?void 0:e.requestSettings,onSubmit:i=>{r["x-action-settings"].requestSettings=i,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-action-settings":r["x-action-settings"]}}),t.refresh()}})}function SkipValidation(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)();return(0,import_jsx_runtime.jsx)(SchemaSettingsSwitchItem,{title:o("Skip required validation"),checked:!!((e=r==null?void 0:r["x-action-settings"])!=null&&e.skipValidator),onChange:i=>{r["x-action-settings"].skipValidator=i,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-action-settings":x({},r["x-action-settings"])}})}})}function AfterSuccess(){const{dn:e}=useDesignable(),{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useFieldSchema)(),{onSuccess:r}=(o==null?void 0:o["x-action-settings"])||{};return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:t("After successful submission"),initialValues:r?x({actionAfterSuccess:r!=null&&r.redirecting?"redirect":"previous"},r):{manualClose:!1,redirecting:!1,successMessage:'{{t("Saved successfully")}}',actionAfterSuccess:"previous"},schema:{type:"object",title:t("After successful submission"),properties:{successMessage:{title:t("Popup message"),"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}},manualClose:{title:t("Message popup close method"),enum:[{label:t("Automatic close"),value:!1},{label:t("Manually close"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{}},redirecting:{title:t("Then"),"x-hidden":!0,enum:[{label:t("Stay on current page"),value:!1},{label:t("Redirect to"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{},"x-reactions":{target:"redirectTo",fulfill:{state:{visible:"{{!!$self.value}}"}}}},actionAfterSuccess:{title:t("Action after successful submission"),enum:[{label:t("Stay on the current popup or page"),value:"stay"},{label:t("Return to the previous popup or page"),value:"previous"},{label:t("Redirect to"),value:"redirect"}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{},"x-reactions":{target:"redirectTo",fulfill:{state:{visible:"{{$self.value==='redirect'}}"}}}},redirectTo:{title:t("Link"),"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:i=>{o["x-action-settings"].onSuccess=i,e.emit("patch",{schema:{"x-uid":o["x-uid"],"x-action-settings":o["x-action-settings"]}})}})}function RemoveButton(e={}){const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useFieldSchema)();return(o==null?void 0:o.parent["x-component"])!=="CollectionField"&&(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)(SchemaSettingsDivider,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:r=>r["x-component"]==="Space"||r["x-component"].endsWith("ActionBar"),disabled:e.disabled,confirm:{title:t("Delete action"),onOk:e.onConfirmOk}})]})}function WorkflowSelect(e){var t=e,{formAction:o,buttonAction:r,actionType:i}=t,n=K(t,["formAction","buttonAction","actionType"]);const{t:a}=(0,import_react_i18next.useTranslation)(),l=import_antd_v5.ArrayTable.useIndex(),{setValuesIn:c}=(0,import_react.useForm)(),u=useCollection_deprecated(),{getCollection:m}=useCollectionManager_deprecated(),d=useDataSourceKey(),[p,g]=(0,import_react2.useState)(joinCollectionName(d,u.name)),h=useCompile(),f=usePlugin("workflow"),_=f.useTriggersOptions(),v=(0,import_react2.useMemo)(()=>_.filter(C=>typeof C.options.isActionTriggerable=="function"||C.options.isActionTriggerable===!0).map(C=>C.value),[_]);(0,import_react.useFormEffects)(()=>{(0,import_core2.onFieldValueChange)(`group[${l}].context`,C=>{let b=u;if(C.value){const y=C.value.split(".");for(let F=0;F<y.length&&b;F++){const j=y[F],k=b.fields.find(T=>T.name===j);k&&(b=m(k.target,d))}}g(joinCollectionName(d,b.name)),c(`group[${l}].workflowKey`,null)})});const S=(0,import_react2.useCallback)(({key:C,type:b,config:y})=>{if(C===n.value)return!0;const F=f.triggers.get(b);return F.isActionTriggerable===!0?!0:typeof F.isActionTriggerable=="function"?F.isActionTriggerable(y,{action:i,formAction:o,buttonAction:r,direct:r==="customize:triggerWorkflows"}):!1},[n.value,f.triggers,o,r,i]);return(0,import_jsx_runtime.jsx)(DataSourceProvider,{dataSource:"main",children:(0,import_jsx_runtime.jsx)(RemoteSelect,x({manual:!1,placeholder:a("Select workflow",{ns:"workflow"}),fieldNames:{label:"title",value:"key"},service:{resource:"workflows",action:"list",params:{filter:{type:v,enabled:!0,"config.collection":p}}},optionFilter:S,optionRender:({label:C,data:b})=>{const y=_.find(F=>F.value===b.type);return y?(0,import_jsx_runtime.jsxs)(import_antd.Flex,{justify:"space-between",children:[(0,import_jsx_runtime.jsx)("span",{children:C}),(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:y.color,children:h(y.label)})]}):C}},n))})}function WorkflowConfig(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)(),i=useCollection_deprecated(),n=useFormBlockContext(),a=(n==null?void 0:n.type)||r["x-action"],l=n==null?void 0:n.type,c=r["x-action"],u={submit:o("Support pre-action event (local mode), post-action event (local mode), and approval event here.",{ns:"workflow"}),"customize:save":o("Support pre-action event (local mode), post-action event (local mode), and approval event here.",{ns:"workflow"}),"customize:update":o("Support pre-action event (local mode), post-action event (local mode), and approval event here.",{ns:"workflow"}),"customize:triggerWorkflows":o('Workflow will be triggered directly once the button clicked, without data saving. Only supports to be bound with "Custom action event".',{ns:"@nocobase/plugin-workflow-custom-action-trigger"}),"customize:triggerWorkflows_deprecated":o('"Submit to workflow" to "Post-action event" is deprecated, please use "Custom action event" instead.',{ns:"workflow"}),destroy:o("Workflow will be triggered before deleting succeeded (only supports pre-action event in local mode).",{ns:"workflow"})}[r==null?void 0:r["x-action"]];return(0,import_jsx_runtime.jsx)(SchemaSettingsActionModalItem,{title:o("Bind workflows",{ns:"workflow"}),scope:{fieldFilter(m){return["belongsTo","hasOne"].includes(m.type)}},components:{Alert:import_antd.Alert,ArrayTable:import_antd_v5.ArrayTable,WorkflowSelect},schema:{type:"void",title:o("Bind workflows",{ns:"workflow"}),properties:{description:u&&{type:"void","x-component":"Alert","x-component-props":{message:u,style:{marginBottom:"1em"}}},group:{type:"array","x-component":"ArrayTable","x-decorator":"FormItem",items:{type:"object",properties:{sort:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:50,title:"",align:"center"},properties:{sort:{type:"void","x-component":"ArrayTable.SortHandle"}}},context:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:o("Trigger data context",{ns:"workflow"}),width:200},properties:{context:{type:"string","x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{placeholder:o("Select context",{ns:"workflow"}),popupMatchSelectWidth:!1,collection:`${i.dataSource&&i.dataSource!=="main"?`${i.dataSource}:`:""}${i.name}`,filter:"{{ fieldFilter }}",rootOption:{label:o("Full form data",{ns:"workflow"}),value:""},allowClear:!1,loadData:c==="destroy"?null:void 0},default:""}}},workflowKey:{type:"void","x-component":"ArrayTable.Column","x-component-props":{title:o("Workflow",{ns:"workflow"})},properties:{workflowKey:{type:"number","x-decorator":"FormItem","x-component":"WorkflowSelect","x-component-props":{placeholder:o("Select workflow",{ns:"workflow"}),actionType:a,formAction:l,buttonAction:c},required:!0}}},operations:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:32},properties:{remove:{type:"void","x-component":"ArrayTable.Remove"}}}}},properties:{add:{type:"void",title:o("Add workflow",{ns:"workflow"}),"x-component":"ArrayTable.Addition"}}}}},initialValues:{group:(e=r==null?void 0:r["x-action-settings"])==null?void 0:e.triggerWorkflows},onSubmit:({group:m})=>{r["x-action-settings"].triggerWorkflows=m,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-action-settings":r["x-action-settings"]}})}})}const actionSettingsItems=[{name:"Customize",Component:MenuGroup,children:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:e=>(0,import_jsx_runtime.jsx)(SchemaSettingsLinkageRules,x({},e)),useVisible(){const e=useLinkageAction(),{linkageAction:t}=useSchemaToolbar();return t||e},useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"openMode",Component:SchemaSettingOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=useOpenModeContext(),t=(0,import_react.useFieldSchema)(),o=["create","update","view","customize:popup","duplicate","customize:create"].includes(t["x-action"]||"");return{openMode:o&&!e,openSize:o&&!e}}},{name:"secondConFirm",Component:SecondConFirm,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return!["create","update","view","customize:popup","duplicate","customize:create"].includes(t["x-action"]||"")&&!((e=t==null?void 0:t["x-action-settings"])!=null&&e.disableSecondConFirm)}},{name:"assignFieldValues",Component:AssignedFieldValues,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.assignedValues)}},{name:"requestSettings",Component:RequestSettings,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.requestSettings)}},{name:"skipValidator",Component:SkipValidation,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.skipValidator)}},{name:"afterSuccess",Component:AfterSuccess,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.onSuccess)}},{name:"workflowConfig",Component:WorkflowConfig,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.triggerWorkflows)}},{name:"saveMode",Component:SaveMode,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return t["x-action"]==="submit"&&isInitializersSame((e=t.parent)==null?void 0:e["x-initializer"],"createForm:configureActions")}},{name:"enableChildCollections",Component:SchemaSettingsEnableChildCollections,useVisible(){const e=(0,import_react.useFieldSchema)(),{name:t}=useCollection_deprecated(),{getChildrenCollections:o}=useCollectionManager_deprecated();return o(t).length>0&&e["x-action"]==="create"},useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"refreshDataBlockRequest",Component:RefreshDataBlockRequest,useComponentProps(){return{isPopupAction:!1}},useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.triggerWorkflows)}},{type:"switch",name:"clearDefaultValue",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable();return{title:t("Clear default value"),checked:(e=o==null?void 0:o["x-component-props"])==null?void 0:e.clearDefaultValue,onChange:i=>{r.deepMerge({"x-uid":o["x-uid"],"x-component-props":{clearDefaultValue:i}})}}},useVisible(){return(0,import_react.useFieldSchema)()["x-use-component-props"]==="useResetBlockActionProps"}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e},useVisible(){var e;const t=(0,import_react.useFieldSchema)();return((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.removable)!==!1}}]}];function SecondConFirm(){var e,t,o,r,i,n,a,l;const{dn:c}=useDesignable(),u=(0,import_react.useFieldSchema)(),{t:m}=(0,import_react_i18next.useTranslation)(),d=(0,import_react.useField)(),p=useCompile();return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:m("Secondary confirmation"),initialValues:{title:p((t=(e=u==null?void 0:u["x-component-props"])==null?void 0:e.confirm)==null?void 0:t.title)||m("Perform the {{title}}",{title:p(u.title)}),content:p((r=(o=u==null?void 0:u["x-component-props"])==null?void 0:o.confirm)==null?void 0:r.content)||m("Are you sure you want to perform the {{title}} action?",{title:p(u.title)})},schema:{type:"object",title:m("Secondary confirmation"),properties:{enable:{"x-decorator":"FormItem","x-component":"Checkbox","x-content":m("Enable secondary confirmation"),default:((n=(i=u==null?void 0:u["x-component-props"])==null?void 0:i.confirm)==null?void 0:n.enable)!==!1&&!!((l=(a=u==null?void 0:u["x-component-props"])==null?void 0:a.confirm)!=null&&l.content),"x-component-props":{}},title:{"x-decorator":"FormItem","x-component":"Input.TextArea",title:m("Title"),"x-reactions":{dependencies:["enable"],fulfill:{state:{required:"{{$deps[0]}}"}}}},content:{"x-decorator":"FormItem","x-component":"Input.TextArea",title:m("Content"),"x-reactions":{dependencies:["enable"],fulfill:{state:{required:"{{$deps[0]}}"}}}}}},onSubmit:({enable:g,title:h,content:f})=>{var _;u["x-component-props"]=u["x-component-props"]||{},u["x-component-props"].confirm={},u["x-component-props"].confirm.enable=g,u["x-component-props"].confirm.title=h,u["x-component-props"].confirm.content=f,d.componentProps.confirm=x({},(_=u["x-component-props"])==null?void 0:_.confirm),c.emit("patch",{schema:{"x-uid":u["x-uid"],"x-component-props":x({},u["x-component-props"])}}),c.refresh()}})}const actionSettings=new SchemaSettings({name:"ActionSettings",items:actionSettingsItems}),ActionDesigner=e=>{const t=e,{modalTip:o,linkageAction:r,removeButtonProps:i,buttonEditorProps:n,linkageRulesProps:a,schemaSettings:l="ActionSettings",enableDrag:c=!0}=t,u=K(t,["modalTip","linkageAction","removeButtonProps","buttonEditorProps","linkageRulesProps","schemaSettings","enableDrag"]),m=useApp(),d=(0,import_react.useFieldSchema)(),p=(d==null?void 0:d.parent["x-component"])!=="CollectionField"&&c,g=`ActionSettings:${d["x-action"]}`,h=l||"ActionSettings",f=m.schemaSettingsManager.has(g);return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,P(x({schemaSettings:f?g:h,contextValue:{modalTip:o,linkageAction:r,removeButtonProps:i,buttonEditorProps:n,linkageRulesProps:a}},u),{disableInitializer:!0,draggable:p}))};function RefreshDataBlockRequest(e){const{dn:t}=useDesignable(),o=(0,import_react.useFieldSchema)(),{t:r}=(0,import_react_i18next.useTranslation)(),{refreshDataBlockRequest:i}=(o==null?void 0:o["x-component-props"])||{};return(0,import_jsx_runtime.jsx)(SchemaSettingsSwitchItem,{title:r("Refresh data on action"),checked:i!==!1,onChange:n=>{o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].refreshDataBlockRequest=n,t.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":x({},o["x-component-props"])}})}})}ActionDesigner.ButtonEditor=ButtonEditor$1;ActionDesigner.RemoveButton=RemoveButton;const ActionLink=withDynamicSchemaProps((0,import_react.observer)(e=>(0,import_jsx_runtime.jsx)(Action$1,P(x({},e),{component:e.component||"a",className:(0,import_classnames.default)("nb-action-link",e.className)}))),{displayName:"ActionLink"}),useStyles$e=genStyleHook("nb-action",e=>{const{componentCls:t}=e;return{[t]:{position:"relative","&:hover":{"> .general-schema-designer":{display:"block"}},"&.nb-action-link":{margin:"-12px",padding:"12px",".nb-action-title":{marginInlineStart:"0px"}},"> .general-schema-designer":{position:"absolute",zIndex:999,top:"0",bottom:"0",left:"0",right:"0",display:"none",background:"var(--colorBgSettingsHover)",border:"0",pointerEvents:"none","> .general-schema-designer-icons":{position:"absolute",right:"2px",top:"2px",lineHeight:"16px",pointerEvents:"all",".ant-space-item":{backgroundColor:e.colorSettings,color:"#fff",lineHeight:"16px",width:"16px",paddingLeft:"1px",alignSelf:"stretch"}}},".ant-btn-icon":{marginInlineEnd:"0px !important"},".nb-action-title":{marginInlineStart:`${e.controlPaddingHorizontalSM}px`}}}}),useGetAriaLabelOfAction=e=>{const t=useRecord(),o=useRecordIndex(),r=(0,import_react.useFieldSchema)(),i=useCompile(),n=r["x-component"],a=typeof n=="string"?n:(n==null?void 0:n.displayName)||(n==null?void 0:n.name);let l=(t==null?void 0:t.name)||(t==null?void 0:t.title)||(o!=null?String(o):""),c=r["x-action"],{name:u}=useCollection_deprecated(),{name:m}=useBlockContext()||{};const d=e||i(r.title);return u=u?`-${u}`:"",m=m?`-${m}`:"",c=c?`-${c}`:"",l=l?`-${l}`:"",{getAriaLabel:(0,import_react2.useCallback)(p=>(p=p?`-${p}`:"",`action-${a}-${d}${c}${u}${m}${l}${p}`),[c,d,m,u,a,l])}},useA=()=>({run(){return q(this,null,function*(){})}}),handleError=console.log,Action=withDynamicSchemaProps(import_react2.default.memo(e=>{var t;const o=useProps(e),{popover:r,containerRefKey:i,component:n,useAction:a=useA,className:l,icon:c,title:u,onClick:m,style:d,loading:p,openSize:g,disabled:h,actionCallback:f,confirm:_,addChild:v,onMouseEnter:S,refreshDataBlockRequest:C,confirmTitle:b}=o,y=K(o,["popover","containerRefKey","component","useAction","className","icon","title","onClick","style","loading","openSize","disabled","actionCallback","confirm","addChild","onMouseEnter","refreshDataBlockRequest","confirmTitle"]),F=useDesigner(),j=(0,import_react.useField)(),k=(0,import_react.useFieldSchema)(),T=useCompile(),O=useCollectionRecordData(),N=T((t=k["x-component-props"])==null?void 0:t.confirm)||_,L=(0,import_react2.useMemo)(()=>(k==null?void 0:k["x-linkage-rules"])||[],[k==null?void 0:k["x-linkage-rules"]]),{designable:D}=useDesignable(),R=useComponent(n)||n,$=useVariables$1(),w=useLocalVariables$1({currentForm:{values:O,readPretty:!1}}),{visibleWithURL:I,setVisibleWithURL:M}=usePopupUtils(),{setSubmitted:B}=useActionContext(),{getAriaLabel:z}=useGetAriaLabelOfAction(u),E=useCollectionParentRecordData();(0,import_react2.useEffect)(()=>{j.stateOfLinkageRules&&setInitialActionState(j),j.stateOfLinkageRules={},L.filter(U=>!U.disabled).forEach(U=>{var G;(G=U.actions)==null||G.forEach(W=>{linkageAction({operator:W.operator,field:j,condition:U.condition,variables:$,localVariables:w})})})},[j,L,w,$]);const V=(0,import_react2.useCallback)(U=>{S==null||S(U)},[S]);return(0,import_jsx_runtime.jsx)(InternalAction,x({containerRefKey:i,fieldSchema:k,designable:D,field:j,icon:c,loading:p,handleMouseEnter:V,tarComponent:R,className:l,type:e.type,Designer:F,onClick:m,confirm:N,confirmTitle:b,popover:r,addChild:v,recordData:O,title:u,style:d,propsDisabled:h,useAction:a,visibleWithURL:I,setVisibleWithURL:M,setSubmitted:B,getAriaLabel:z,parentRecordData:E,actionCallback:f},y))}),{displayName:"Action"}),InternalAction=(0,import_react.observer)(function(e){var t,o,r,i,n;const a=e,{containerRefKey:l,fieldSchema:c,designable:u,field:m,icon:d,loading:p,handleMouseEnter:g,tarComponent:h,className:f,type:_,Designer:v,onClick:S,confirm:C,confirmTitle:b,popover:y,addChild:F,recordData:j,title:k,style:T,propsDisabled:O,useAction:N,actionCallback:L,visibleWithURL:D,setVisibleWithURL:R,setSubmitted:$,getAriaLabel:w,parentRecordData:I}=a,M=K(a,["containerRefKey","fieldSchema","designable","field","icon","loading","handleMouseEnter","tarComponent","className","type","Designer","onClick","confirm","confirmTitle","popover","addChild","recordData","title","style","propsDisabled","useAction","actionCallback","visibleWithURL","setVisibleWithURL","setSubmitted","getAriaLabel","parentRecordData"]),[B,z]=(0,import_react2.useState)(!1),{wrapSSR:E,componentCls:V,hashId:U}=useStyles$e(),[G,W]=(0,import_react2.useState)(!1),Y=c["x-toolbar-props"]||c["x-designer-props"],H=(t=c==null?void 0:c["x-component-props"])==null?void 0:t.openMode,J=(o=c==null?void 0:c["x-component-props"])==null?void 0:o.openSize,X=(r=c==null?void 0:c["x-component-props"])==null?void 0:r.refreshDataBlockRequest,{modal:Q}=import_antd.App.useApp(),ee=(0,import_react.useForm)(),te=useACLActionParamsContext(),{run:ne,element:ae,disabled:xe}=(N==null?void 0:N(L))||{},de=ee.disabled||m.disabled||((i=m.data)==null?void 0:i.disabled)||O||xe,ue=(0,import_react2.useMemo)(()=>{var se;return P(x({},T),{opacity:u&&(((se=m==null?void 0:m.data)==null?void 0:se.hidden)||!te)&&.1,color:de?"rgba(0, 0, 0, 0.25)":T==null?void 0:T.color})},[te,u,(n=m==null?void 0:m.data)==null?void 0:n.hidden,T,de]),he={designable:u,field:m,aclCtx:te,icon:d,loading:p,disabled:de,buttonStyle:ue,handleMouseEnter:g,tarComponent:h,designerProps:Y,componentCls:V,hashId:U,className:f,others:M,getAriaLabel:w,type:_,Designer:v,onClick:S,refreshDataBlockRequest:X,fieldSchema:c,setVisible:z,run:ne,confirm:C,modal:Q,setSubmitted:$,confirmTitle:b,title:k},ge=(0,import_react2.useCallback)(se=>{z==null||z(se),R==null||R(se)},[R]);let me=(0,import_jsx_runtime.jsx)(PopupVisibleProvider,{visible:!1,children:(0,import_jsx_runtime.jsxs)(ActionContextProvider,{button:RenderButton(he),visible:B||D,setVisible:ge,formValueChanged:G,setFormValueChanged:W,openMode:H,openSize:J,containerRefKey:l,fieldSchema:c,setSubmitted:$,children:[y&&(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:m.address,onlyRenderProperties:!0,schema:c}),!y&&(0,import_jsx_runtime.jsx)(RenderButton,x({},he)),(0,import_jsx_runtime.jsx)(VariablePopupRecordProvider,{children:!y&&e.children}),ae]})});return isBulkEditAction(c)&&(me=(0,import_jsx_runtime.jsx)(TabsContextProvider,{children:me})),E(F?(0,import_jsx_runtime.jsx)(RecordProvider,{record:null,parent:I,children:(0,import_jsx_runtime.jsx)(TreeRecordProvider,{parent:j,children:me})}):me)});InternalAction.displayName="InternalAction";Action.Popover=function(e){const{button:t,visible:o,setVisible:r}=useActionContext(),i=(0,import_jsx_runtime.jsx)(import_react_error_boundary.ErrorBoundary,{FallbackComponent:ErrorFallback,onError:handleError,children:e.children});return(0,import_jsx_runtime.jsx)(StablePopover,P(x({},e),{destroyTooltipOnHide:!0,open:o,onOpenChange:n=>{r(n)},content:i,children:t}))};Action.Popover.displayName="Action.Popover";Action.Popover.Footer=e=>(0,import_jsx_runtime.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",width:"100%"},children:e.children});Action.Popover.Footer.displayName="Action.Popover.Footer";Action.Link=ActionLink;Action.Designer=ActionDesigner;Action.Drawer=ActionDrawer;Action.Modal=ActionModal;Action.Container=ActionContainer;Action.Page=ActionPage;const Action$1=Action;function isBulkEditAction(e){return e["x-action"]==="customize:bulkEdit"}const RenderButton=({designable:e,field:t,aclCtx:o,icon:r,loading:i,disabled:n,buttonStyle:a,handleMouseEnter:l,tarComponent:c,designerProps:u,componentCls:m,hashId:d,className:p,others:g,getAriaLabel:h,type:f,Designer:_,onClick:v,refreshDataBlockRequest:S,fieldSchema:C,setVisible:b,run:y,confirm:F,modal:j,setSubmitted:k,confirmTitle:T,title:O})=>{const{getDataBlockRequest:N}=useDataBlockRequestGetter(),{t:L}=(0,import_react_i18next.useTranslation)(),{isPopupVisibleControlledByURL:D}=usePopupSettings(),{openPopup:R}=usePopupUtils(),$=(0,import_react2.useRef)(null);$.current=R;const w=(0,import_react2.useCallback)((I,M=!0)=>{if(!(M&&(0,import_client.isPortalInBody)(I.target))&&(I.preventDefault(),I.stopPropagation(),!n&&o)){const B=()=>{v?v(I,()=>{var z,E;S!==!1&&(k==null||k(!0),(E=(z=N())==null?void 0:z.refresh)==null||E.call(z))}):isBulkEditAction(C)||!D()?(b(!0),y==null||y()):["view","update","create","customize:popup"].includes(C["x-action"])&&C["x-uid"]?$.current():(b(!0),y==null||y())};(F==null?void 0:F.enable)!==!1&&F!=null&&F.content?j.confirm({title:L(F.title,{title:T||O||(t==null?void 0:t.title)}),content:L(F.content,{title:T||O||(t==null?void 0:t.title)}),onOk:B}):B()}},[o,F==null?void 0:F.content,F==null?void 0:F.enable,F==null?void 0:F.title,T,n,t,C,D,j,v,S,y,k,b,L,O,N]);return(0,import_jsx_runtime.jsx)(RenderButtonInner,x({designable:e,field:t,aclCtx:o,icon:r,loading:i,disabled:n,buttonStyle:a,handleMouseEnter:l,getAriaLabel:h,handleButtonClick:w,tarComponent:c,componentCls:m,hashId:d,className:p,type:f,Designer:_,designerProps:u,title:O},g))};RenderButton.displayName="RenderButton";const RenderButtonInner=(0,import_react.observer)(e=>{var t,o;const r=e,{designable:i,field:n,aclCtx:a,icon:l,loading:c,disabled:u,buttonStyle:m,handleMouseEnter:d,getAriaLabel:p,handleButtonClick:g,tarComponent:h,componentCls:f,hashId:_,className:v,type:S,Designer:C,designerProps:b,title:y}=r,F=K(r,["designable","field","aclCtx","icon","loading","disabled","buttonStyle","handleMouseEnter","getAriaLabel","handleButtonClick","tarComponent","componentCls","hashId","className","type","Designer","designerProps","title"]);if(!i&&((t=n==null?void 0:n.data)!=null&&t.hidden||!a))return null;const j=y||(n==null?void 0:n.title);return(0,import_jsx_runtime.jsxs)(SortableItem,P(x({role:"button","aria-label":p()},F),{onMouseEnter:d,loading:((o=n==null?void 0:n.data)==null?void 0:o.loading)||c,icon:typeof l=="string"?(0,import_jsx_runtime.jsx)(Icon,{type:l}):l,disabled:u,style:m,onClick:g,component:h||import_antd.Button,className:(0,import_classnames.default)(f,_,v,"nb-action"),type:S==="danger"?void 0:S,children:[j&&(0,import_jsx_runtime.jsx)("span",{className:l?"nb-action-title":null,children:j}),(0,import_jsx_runtime.jsx)(C,x({},b))]}))});RenderButtonInner.displayName="RenderButtonInner";const ActionBarContext=import_react2.default.createContext({container:null}),ActionBarProvider=e=>{var t=e,{children:o}=t,r=K(t,["children"]);return(0,import_jsx_runtime.jsx)(ActionBarContext.Provider,{value:r,children:o})},useActionBarContext=()=>(0,import_react2.useContext)(ActionBarContext),Portal=e=>{const t=(0,import_react.useFieldSchema)(),{container:o,parentComponents:r=["BlockItem","CardItem"]}=useActionBarContext();return(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:o&&r.includes(t.parent["x-component"])?(0,import_react_dom.createPortal)(e.children,o):e.children})},InternalActionBar=e=>{var t;const{forceProps:o={}}=useActionBarContext(),r=x(x({},useProps(e)),o),{layout:i="two-columns",style:n,spaceProps:a}=r,l=K(r,["layout","style","spaceProps"]),c=(0,import_react.useFieldSchema)(),{render:u}=useSchemaInitializerRender(c["x-initializer"],c["x-initializer-props"]),{designable:m}=useDesignable();if(i==="one-column")return(0,import_jsx_runtime.jsx)(Portal,{children:(0,import_jsx_runtime.jsx)(DndContext,{children:(0,import_jsx_runtime.jsxs)("div",P(x({style:P(x({display:"flex",alignItems:"center",gap:8},n),{marginTop:0})},l),{className:(0,import_css.cx)(l.className,"nb-action-bar"),children:[e.children&&(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsx)(import_antd.Space,P(x({},a),{style:x({flexWrap:"wrap"},(a==null?void 0:a.style)||{}),children:c.mapProperties((p,g)=>(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{name:g,schema:p},g))}))}),u({style:{margin:"0 !important"}})]}))})});const d=Object.keys((t=c.properties)!=null?t:{}).length>0;return(0,import_jsx_runtime.jsxs)("div",P(x({style:!m&&!d?void 0:x({display:"flex",justifyContent:"space-between",alignItems:"center",overflowX:"auto",flexShrink:0,gap:"8px"},n)},l),{className:(0,import_css.cx)(l.className,"nb-action-bar"),children:[(0,import_jsx_runtime.jsx)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",overflow:"hidden",flexWrap:"wrap",gap:"8px"},children:(0,import_jsx_runtime.jsxs)(DndContext,{children:[(0,import_jsx_runtime.jsx)(import_antd.Space,P(x({},a),{style:{flexWrap:"wrap"},children:c.mapProperties((p,g)=>p["x-align"]!=="left"?null:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{name:g,schema:p},g))})),(0,import_jsx_runtime.jsx)(import_antd.Space,P(x({},a),{style:x({flexWrap:"wrap"},(a==null?void 0:a.style)||{}),children:c.mapProperties((p,g)=>p["x-align"]==="left"?null:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{name:g,schema:p},g))}))]})}),u()]}))},ActionBar=withDynamicSchemaProps(e=>(0,import_jsx_runtime.jsx)(InternalActionBar,x({},e)),{displayName:"ActionBar"}),useGetAriaLabelOfPopover=()=>{const e=(0,import_react.useFieldSchema)(),t=e["x-component"],o=typeof t=="string"?t:(t==null?void 0:t.displayName)||(t==null?void 0:t.name),r=useCompile();let{name:i}=useCollection_deprecated(),n=r(e.title);return i=i?`-${i}`:"",n=n?`-${n}`:"",{getAriaLabel:(0,import_react2.useCallback)(a=>(a=a?`-${a}`:"",`popover-${o}${i}${n}${a}`),[i,o,n])}},useBackButton=()=>{const{setVisible:e}=useActionContext();return{goBack:(0,import_react2.useCallback)(()=>{e==null||e(!1)},[e])}},BackButtonUsedInSubPage=()=>{const{token:e}=useToken$1(),{goBack:t}=useBackButton(),o=32,r=(0,import_react2.useMemo)(()=>({width:"auto",height:"auto",lineHeight:1,padding:e.paddingXS,marginRight:o-e.paddingXS}),[e.paddingXS]);return(0,import_jsx_runtime.jsx)(import_antd.Button,{"aria-label":"back-button",type:"text",icon:(0,import_jsx_runtime.jsx)(import_icons.ArrowLeftOutlined,{}),style:r,onClick:t})},useActionPageStyle=genStyleHook("nb-action-page",e=>{const{componentCls:t}=e;return{[t]:{position:"absolute !important",top:"var(--nb-header-height)",left:0,right:0,bottom:0,backgroundColor:e.colorBgLayout,overflow:"auto",".ant-tabs-nav":{background:e.colorBgContainer,padding:`0 ${e.paddingPageVertical}px`,marginBottom:0},".ant-tabs-content-holder":{padding:`${e.paddingPageVertical}px`,paddingBottom:"0px"}}}}),usePopupOrSubpagesContainerDOM=()=>{const e=(0,import_react2.useMemo)(()=>document.querySelector(".nb-subpages-slot-without-header-and-side"),[]);return{getContainerDOM:(0,import_react2.useCallback)(()=>e,[e])}},ActionPageContent=import_react2.default.memo(({schema:e})=>{const[t,o]=(0,import_react2.useState)(!1);return(0,import_react2.useEffect)(()=>{(0,import_react2.startTransition)(()=>{o(!0)})},[]),t?(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{schema:e,onlyRenderProperties:!0}):null});function ActionPage({level:e}){const t=(0,import_react.useFieldSchema)(),o=useActionContext(),{getContainerDOM:r}=usePopupOrSubpagesContainerDOM(),{componentCls:i,hashId:n}=useActionPageStyle(),a=useTabsContext(),l=useZIndexContext(),c=(0,import_react2.useMemo)(()=>({zIndex:l+(e||0)}),[l,e]);if(!o.visible)return null;const u=(0,import_jsx_runtime.jsx)("div",{className:`${i} ${n}`,style:c,children:(0,import_jsx_runtime.jsx)(ActionContextNoRerender,{children:(0,import_jsx_runtime.jsx)(TabsContextProvider,P(x({},a),{tabBarExtraContent:(0,import_jsx_runtime.jsx)(BackButtonUsedInSubPage,{}),children:(0,import_jsx_runtime.jsx)(zIndexContext.Provider,{value:c.zIndex,children:(0,import_jsx_runtime.jsx)(ActionPageContent,{schema:t})})}))})}),m=r();return(0,import_react_dom.createPortal)(u,m||document.body)}ActionPage.Footer=(0,import_react.observer)(()=>null,{displayName:"ActionPage.Footer"});const defaultContext={defaultOpenMode:"drawer",openModeToComponent:{drawer:ActionDrawer,page:ActionPage,modal:ActionModal},hideOpenMode:!1},OpenModeContext=import_react2.default.createContext(null),OpenModeProvider=e=>{const t=(0,import_react2.useMemo)(()=>{const i=x({},defaultContext);return e.defaultOpenMode!==void 0&&(i.defaultOpenMode=e.defaultOpenMode),e.openModeToComponent!==void 0&&(i.openModeToComponent=e.openModeToComponent),e.hideOpenMode!==void 0&&(i.hideOpenMode=e.hideOpenMode),e.isMobile&&(i.isMobile=e.isMobile),i},[e.defaultOpenMode,e.openModeToComponent,e.hideOpenMode]),o=(0,import_react2.useCallback)(i=>{const n=t.openModeToComponent[i];return n||console.error(`OpenModeProvider: openModeToComponent[${i}] is not defined`),n},[t]),r=(0,import_react2.useMemo)(()=>({defaultOpenMode:t.defaultOpenMode,hideOpenMode:t.hideOpenMode,getComponentByOpenMode:o,isMobile:t.isMobile}),[t.defaultOpenMode,t.hideOpenMode,o,t.isMobile]);return(0,import_jsx_runtime.jsx)(OpenModeContext.Provider,{value:r,children:e.children})},useOpenModeContext=()=>import_react2.default.useContext(OpenModeContext),SchemaInitializerItem=(0,import_react2.memo)(import_react2.default.forwardRef((e,t)=>{const{style:o,closeInitializerMenuWhenClick:r=!0,name:i=(0,import_shared.uid)(),applyMenuStyle:n=!0,className:a,disabled:l,items:c,icon:u,title:m,onClick:d,children:p}=e,g=useCompile(),h=useSchemaInitializerMenuItems(c,i,d),{componentCls:f,hashId:_}=useSchemaInitializerStyles(),{attribute:v}=useAriaAttributeOfMenuItem(),{setVisible:S}=useSchemaInitializer(),C=(0,import_react2.useMemo)(()=>{if(c&&c.length>0)return[{key:i,style:o,className:a,label:p||g(m),onClick:b=>{b.key===i&&(r&&(S==null||S(!1)),d==null||d(P(x({},b),{item:e})))},icon:typeof u=="string"?(0,import_jsx_runtime.jsx)(Icon,{type:u}):u,children:h}]},[i,o,a,p,m,d,u,h]);return c&&c.length>0?(0,import_jsx_runtime.jsx)(SchemaInitializerMenu,{items:C}):(0,import_jsx_runtime.jsx)("div",{ref:t,onClick:b=>{b.stopPropagation(),r&&(S==null||S(!1)),d==null||d({event:b,item:e})},children:(0,import_jsx_runtime.jsx)("div",P(x({},v),{className:(0,import_classnames.default)({[`${f}-menu-item`]:n,[`${f}-menu-item-disabled`]:l},a),style:o,children:p||(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[typeof u=="string"?(0,import_jsx_runtime.jsx)(Icon,{type:u}):u,(0,import_jsx_runtime.jsx)("span",{className:(0,import_classnames.default)({[`${_} ${f}-item-content`]:!!u}),children:g(m)})]})}))})}));SchemaInitializerItem.displayName="SchemaInitializerItem";const SchemaInitializerItemInternal=()=>{const e=useSchemaInitializerItem();return(0,import_jsx_runtime.jsx)(SchemaInitializerItem,x({},e))},switchStyle={marginLeft:20},itemStyle={display:"flex",alignItems:"center",justifyContent:"space-between"},SchemaInitializerSwitch=e=>{const t=e,{title:o,checked:r}=t,i=K(t,["title","checked"]),n=useCompile();return(0,import_jsx_runtime.jsx)(SchemaInitializerItem,P(x({},i),{closeInitializerMenuWhenClick:!1,children:(0,import_jsx_runtime.jsxs)("div",{style:itemStyle,children:[n(o),(0,import_jsx_runtime.jsx)(import_antd.Switch,{disabled:e.disabled,style:switchStyle,size:"small",checked:r})]})}))},SchemaInitializerSwitchInternal=()=>{const e=useSchemaInitializerItem();return(0,import_jsx_runtime.jsx)(SchemaInitializerSwitch,x({},e))},SchemaInitializerChildren=e=>{const{children:t}=e;return t?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:t.sort((o,r)=>(o.sort||0)-(r.sort||0)).map((o,r)=>(0,import_jsx_runtime.jsx)(SchemaInitializerChild,x({},o),o.name||o.key||r))}):null},typeComponentMap$1={item:"SchemaInitializerItemInternal",itemGroup:"SchemaInitializerItemGroupInternal",divider:"SchemaInitializerDivider",switch:"SchemaInitializerSwitchInternal",subMenu:"SchemaInitializerSubMenuInternal",actionModal:"SchemaInitializerActionModalInternal"},useChildrenDefault$1=()=>{},useVisibleDefault$1=()=>!0,useComponentPropsDefault$1=()=>{},SchemaInitializerChild=(0,import_react2.memo)(e=>{const t=e,{type:o,Component:r,component:i,children:n,useVisible:a=useVisibleDefault$1,useChildren:l=useChildrenDefault$1,useComponentProps:c=useComponentPropsDefault$1,hideIfNoChildren:u,componentProps:m,sort:d}=t,p=K(t,["type","Component","component","children","useVisible","useChildren","useComponentProps","hideIfNoChildren","componentProps","sort"]),g=l(),h=c(),f=useFindComponent(),_=r||i,v=!_&&o&&typeComponentMap$1[o],S=(0,import_react2.useMemo)(()=>{const y=[...g||[],...n||[]];return y.length===0?void 0:y},[g,n]),C=(0,import_react2.useMemo)(()=>P(x(x(x({},p),v?h:{}),v?m:{}),{children:S}),[p,v,h,m,S]);if(!a()||!o&&!_)return null;const b=f(v?typeComponentMap$1[o]:_);return!b||u&&!S?null:(0,import_jsx_runtime.jsx)(SchemaInitializerItemContext.Provider,{value:C,children:(0,import_jsx_runtime.jsx)(b,P(x(x({},m),h),{children:S}))})});SchemaInitializerChild.displayName="SchemaInitializerChild";const SchemaInitializerDivider=()=>{const{token:e}=import_antd.theme.useToken();return(0,import_jsx_runtime.jsx)(import_antd.Divider,{style:{marginTop:e.marginXXS,marginBottom:e.marginXXS}})};function getPrefixAndCompare(e,t){const o=e.replace(/-displayCollectionFields$/,""),r=t.replace(/-displayCollectionFields$/,"");return!o.includes(r)}const SearchFields=({value:e,onChange:t,name:o})=>{const{t:r}=(0,import_react_i18next.useTranslation)(),[i,n]=(0,import_react2.useState)(e),a=(0,import_react2.useRef)(""),l=(0,import_react2.useRef)(`${o||Math.random().toString(10).substr(2,9)}`);(0,import_react2.useEffect)(()=>{n(e)},[e]),(0,import_react2.useEffect)(()=>{var d;const p=()=>{var h,f;a.current&&((h=document.activeElement)==null?void 0:h.id)!==a.current.input.id&&getPrefixAndCompare((f=document.activeElement)==null?void 0:f.id,a.current.input.id)&&a.current.focus()},g=new IntersectionObserver(h=>{h.some(f=>f.isIntersecting)&&p()});return(d=a.current)!=null&&d.input&&(a.current.input.id=l.current,g.observe(a.current.input)),()=>{g.disconnect()}},[]);const c=(0,import_react2.useRef)(!1),u=d=>{c.current||(t(d.target.value),n(d.target.value))},m=d=>{d.type==="compositionend"?(c.current=!1,u(d)):c.current=!0};return(0,import_jsx_runtime.jsxs)("div",{onClick:d=>d.stopPropagation(),children:[(0,import_jsx_runtime.jsx)(import_antd.Input,{ref:a,allowClear:!0,style:{padding:"0 4px 6px 16px",boxShadow:"none"},bordered:!1,placeholder:r("Search"),defaultValue:i,onClick:d=>{d.stopPropagation()},onChange:u,onCompositionStart:m,onCompositionEnd:m,onCompositionUpdate:m}),(0,import_jsx_runtime.jsx)(import_antd.Divider,{style:{margin:0}})]})};let currentName=null;const useMenuSearch$1=e=>{const{children:t,showType:o,hideSearch:r,name:i}=e,n=useCompile(),[a,l]=(0,import_react2.useState)(null),c=(d,p)=>{if(!a||a===""||currentName&&currentName!==p)return d;const g=a.toLocaleLowerCase();return d.filter(h=>(h.title||h.label)&&String(n(h.title||h.label)).toLocaleLowerCase().includes(g))},u=(d,p,g=new Set)=>{var h;const f=[];return!r&&(d.length>10||a)&&!["subMenu","itemGroup"].includes((h=d[0])==null?void 0:h.type)&&f.push(x({key:`search-${(0,import_shared.uid)()}`,Component:()=>(0,import_jsx_runtime.jsx)(SearchFields,{name:p,value:!currentName||currentName===p?a:"",onChange:_=>{currentName=p,l(_)}}),onClick({domEvent:_}){_.stopPropagation()}},o?{isMenuType:!0}:{})),d.forEach(_=>{if(!g.has(_))if(g.add(_),["subMenu","itemGroup"].includes(_.type)){const v=!currentName||currentName===_.name?c(_.children.concat(),_.name):_.children,S=u(v,_.name,g);f.push(P(x({},_),{children:S}))}else f.push(_)}),d.length===0&&f.push(x({key:"empty",style:{height:150},Component:()=>(0,import_jsx_runtime.jsx)("div",{onClick:_=>_.stopPropagation(),children:(0,import_jsx_runtime.jsx)(import_antd.Empty,{image:import_antd.Empty.PRESENTED_IMAGE_SIMPLE})})},o?{isMenuType:!0}:{})),f},m=u(c((t==null?void 0:t.concat())||[],i),i);return t?m:void 0},SchemaInitializerItemGroup=({children:e,items:t,title:o,divider:r})=>{const i=useCompile(),{componentCls:n}=useSchemaInitializerStyles(),{token:a}=import_antd.theme.useToken();return(0,import_jsx_runtime.jsxs)("div",{style:{marginInline:a.marginXXS},children:[r&&(0,import_jsx_runtime.jsx)(SchemaInitializerDivider,{}),(0,import_jsx_runtime.jsx)("div",{className:`${n}-group-title`,children:i(o)}),(0,import_jsx_runtime.jsx)(SchemaInitializerChildren,{children:t||e})]})},SchemaInitializerItemGroupInternal=()=>{const e=useSchemaInitializerItem(),t=useMenuSearch$1(e);return e.name&&e.name!=="displayFields"?(0,import_jsx_runtime.jsx)(SchemaInitializerItemGroup,x({},e)):(0,import_jsx_runtime.jsx)(SchemaInitializerItemGroup,P(x({},e),{children:t}))},SchemaInitializerItems=e=>{const{items:t}=e;return t.length===0?null:(0,import_jsx_runtime.jsx)(SchemaInitializerChildren,{children:t})},SchemaInitializerActionModalItemComponent=import_react2.default.forwardRef((e,t)=>{const o=e,{onClick:r}=o,i=K(o,["onClick"]);return(0,import_jsx_runtime.jsx)(SchemaInitializerItem,P(x({ref:t},i),{onClick:n=>r==null?void 0:r(n.event,!1)}))}),SchemaInitializerActionModal=e=>{const{title:t,icon:o,width:r,schema:i,buttonText:n,btnStyles:a,isItem:l,component:c,onCancel:u,onSubmit:m}=e,{setVisible:d}=useSchemaInitializer(),p=(0,import_react2.useCallback)(()=>{const v=(0,import_react.useForm)(),S=useActionContext();return{run(){return q(this,null,function*(){yield u==null?void 0:u(),S.setVisible(!1),v.reset()})}}},[u]),g=(0,import_react2.useCallback)(()=>{const v=(0,import_react.useForm)(),S=useActionContext();return{run(){return q(this,null,function*(){yield v.validate();try{yield m==null?void 0:m(v.values),S.setVisible(!1),v.reset()}catch(C){console.error(C)}})}}},[m]),h=(0,import_react2.useMemo)(()=>import_react2.default.forwardRef(({onClick:v},S)=>(0,import_jsx_runtime.jsx)(SchemaInitializerActionModalItemComponent,{onClick:v,ref:S,title:n,icon:o})),[n,o]),f=(0,import_react2.useMemo)(()=>(0,import_shared.uid)(),[]),_=(0,import_react2.useMemo)(()=>({type:"void",properties:{[f]:{type:"void","x-component":"Action","x-component-props":c?{component:c,icon:o}:l?{component:h}:{icon:o||"PlusOutlined",style:x({borderColor:"var(--colorSettings)",color:"var(--colorSettings)"},a||{}),title:n,type:"dashed"},properties:{drawer1:{"x-decorator":"Form","x-component":"Action.Modal","x-component-props":{width:r,style:{maxWidth:r||"520px",width:"100%"},afterOpenChange:()=>{d(!1)}},type:"void",title:t,properties:P(x({},(i==null?void 0:i.properties)||i),{footer:{"x-component":"Action.Modal.Footer",type:"void",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:p}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:g}}}}})}}}}}),[n,c,f,i,t,p,g]);return(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:_})},SchemaInitializerActionModalInternal=()=>{const e=useSchemaInitializerItem();return(0,import_jsx_runtime.jsx)(SchemaInitializerActionModal,x({},e))},SchemaInitializerSelect=e=>{const t=e,{title:o,options:r,value:i,onChange:n,openOnHover:a,onClick:l}=t,c=K(t,["title","options","value","onChange","openOnHover","onClick"]),[u,m]=(0,import_react2.useState)(!1),d=(0,import_react2.useCallback)((...h)=>{m(!1),l==null||l(...h)},[m,l]),p=(0,import_react2.useCallback)(()=>m(!0),[]),g=(0,import_react2.useMemo)(()=>a?{onMouseEnter:p,open:u}:{},[p,u,a]);return(0,import_jsx_runtime.jsx)(SchemaInitializerItem,P(x({closeInitializerMenuWhenClick:!1},c),{children:(0,import_jsx_runtime.jsxs)("div",{style:{alignItems:"center",display:"flex",justifyContent:"space-between"},children:[o,(0,import_jsx_runtime.jsx)(import_antd.Select,x({"data-testid":"antd-select",popupMatchSelectWidth:!1,bordered:!1,defaultValue:i,onChange:(...h)=>(m(!1),n(...h)),options:r,style:{textAlign:"right",minWidth:100},onClick:d},g))]})}))},SchemaInitializerSelectInternal=()=>{const e=useSchemaInitializerItem();return(0,import_jsx_runtime.jsx)(SchemaInitializerSelect,x({},e))},schemaInitializerComponents=Object.freeze(Object.defineProperty({__proto__:null,SchemaInitializerActionModal,SchemaInitializerActionModalInternal,SchemaInitializerChild,SchemaInitializerChildren,SchemaInitializerDivider,SchemaInitializerItem,SchemaInitializerItemGroup,SchemaInitializerItemGroupInternal,SchemaInitializerItemInternal,SchemaInitializerItems,SchemaInitializerMenu,SchemaInitializerMenuProvider,SchemaInitializerSelect,SchemaInitializerSelectInternal,SchemaInitializerSubMenu,SchemaInitializerSubMenuInternal,SchemaInitializerSwitch,SchemaInitializerSwitchInternal,useSchemaInitializerStyles,useSchemaInitializerSubMenuContext},Symbol.toStringTag,{value:"Module"})),useGetAriaLabelOfSchemaInitializer=()=>{const e=(0,import_react.useFieldSchema)(),{name:t}=useCollection()||{};return{getAriaLabel:(0,import_react2.useCallback)(o=>{if(!e)return"";const r=e["x-component"],i=typeof r=="string"?r:(r==null?void 0:r.displayName)||r.name,n=e["x-initializer"]?`-${e["x-initializer"]}`:"",a=t?`-${t}`:"";return o=o?`-${o}`:"",`schema-initializer-${i}${n}${a}${o}`},[e,t])}},SchemaInitializerButton=import_react2.default.memo(e=>{const t=e,{style:o,options:r}=t,i=K(t,["style","options"]),n=useCompile(),{getAriaLabel:a}=useGetAriaLabelOfSchemaInitializer();return(0,import_jsx_runtime.jsx)(import_antd.Button,P(x({"data-testid":r["data-testid"],"aria-label":a(),"aria-disabled":"false",type:"dashed",style:x({borderColor:"var(--colorSettings)",color:"var(--colorSettings)",flex:"none"},o),icon:typeof r.icon=="string"?(0,import_jsx_runtime.jsx)(Icon,{type:r.icon}):r.icon},i),{children:r.title&&(0,import_jsx_runtime.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"inline-block",width:r.icon?"calc(100% - 14px)":"100%",verticalAlign:"bottom"},children:n(r.title)})}))});SchemaInitializerButton.displayName="SchemaInitializerButton(memo)";const InitializerComponent=e=>{const t=e.Component||SchemaInitializerButton,o=e.ItemsComponent||SchemaInitializerItems,r=P(x({},e.itemsComponentProps),{options:e,items:e.items,style:e.itemsComponentStyle}),i=(0,import_react2.useMemo)(()=>withInitializer(t),[t]);return import_react2.default.createElement(i,e,import_react2.default.createElement(o,r))};InitializerComponent.displayName="InitializerComponent";function useSchemaInitializerRender(e,t){const o=useApp(),{isMobile:r}=useOpenModeContext()||{};e==="popup:common:addBlock"&&o.schemaInitializerManager.has("mobile:popup:common:addBlock")&&r&&(e="mobile:popup:common:addBlock");const i=(0,import_react2.useMemo)(()=>typeof e=="object"?e:o.schemaInitializerManager.get(e),[o.schemaInitializerManager,e]);return(0,import_react2.useMemo)(()=>e?i?{exists:!0,render:n=>import_react2.default.createElement(InitializerComponent,x(x(x({},i.options),t),n))}:(console.error(`[nocobase]: SchemaInitializer "${e}" not found`),{exists:!1,render:()=>null}):{exists:!1,render:()=>null},[i,e,t])}function useSchemaInitializerMenuItems(e,t,o){const r=useGetSchemaInitializerMenuItems(o);return(0,import_react2.useMemo)(()=>r(e,t),[r,e,t])}function useGetSchemaInitializerMenuItems(e){const t=useCompile(),o=(0,import_react2.useCallback)((r,i)=>r!=null&&r.length?r.map((n,a)=>{var l,c;const u=n.component||n.Component;let m;const d=n.title||n.label?t(n.title||n.label):void 0;if(u&&(m=import_react2.default.createElement(SchemaInitializerChild,P(x({},n),{title:d}))),n.type==="divider")return{type:"divider",key:n.key||`divider-${a}`};if(n.type==="item"&&u)return n.key||(n.key=`${d}-${a}`),n.associationField?{key:n.key,label:m,associationField:n.associationField}:{key:n.key,label:m};if(n.type==="itemGroup"){const f=typeof d=="string"?d:n.title,_=n.key||`${i}-item-group-${a}`;return{type:"group",key:_,label:f,children:(l=n==null?void 0:n.children)!=null&&l.length?o(n.children,_):[]}}if(n.type==="subMenu"){const f=d,_=n.key||n.name||`${i}-sub-menu-${a}`;return{key:_,label:f,children:(c=n==null?void 0:n.children)!=null&&c.length?o(n.children,_):[]}}if(n.isMenuType)return K(n,["isMenuType"]);const p=m||d,g=n.key||`${i}-${d}-${a}`,h=f=>{f.domEvent.stopPropagation(),f.key===g&&(n.onClick?n.onClick(P(x({},f),{item:n})):e==null||e(P(x({},f),{item:n})))};return n.associationField?{key:g,label:p,associationField:n.associationField,onClick:h}:{style:n.style,key:g,label:p,onClick:h}}):[],[t,e]);return o}class SchemaInitializer{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 r=t.split("."),i=r[r.length-1],n=P(x({},o),{name:i}),a=(u,m)=>{const d=this.items.findIndex(p=>p.name===u);d===-1?this.items.push(m):this.items[d]=m};if(r.length===1){a(i,n);return}const l=r.slice(0,-1).join("."),c=this.get(l);if(c){c.children||(c.children=[]);const u=t.replace(`${c.name}.`,""),m=c.children.findIndex(d=>d.name===u);m===-1?c.children.push(n):c.children[m]=n}else a(i,n)}get(t){var o;if(!t)return;const r=t.split(".");let i={children:this.items};for(let n=0;n<r.length;n++){const a=r[n],l=(o=i.children)==null?void 0:o.find(c=>c.name===a);if(l&&(i=l),n===r.length-1)return l}}remove(t){const o=t.split(".");if(o.length===1){const i=this.items.findIndex(n=>n.name===o[0]);i!==-1&&this.items.splice(i,1);return}const r=this.get(o.slice(0,-1).join("."));if(r&&r.children){const i=o[o.length-1],n=r.children.findIndex(a=>a.name===i);n!==-1&&r.children.splice(n,1)}}}class CompatibleSchemaInitializer extends SchemaInitializer{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 oldToNewNameMap={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 isInitializersSame(e,t){return e===t||oldToNewNameMap[e]===t}class SchemaInitializerManager{constructor(t=[],o){A(this,"schemaInitializers",{}),A(this,"actionList",{}),this._schemaInitializers=t,this.app=o,this.app=o,this.add(...t)}add(...t){t.forEach(o=>{this.schemaInitializers[o.name]=o,Array.isArray(this.actionList[o.name])&&(this.actionList[o.name].forEach(r=>{o[r.type](r.itemName,r.data)}),this.actionList[o.name]=void 0)})}addItem(t,o,r){const i=this.get(t);i?i.add(o,r):(this.actionList[t]||(this.actionList[t]=[]),this.actionList[t].push({type:"add",itemName:o,data:r}))}get(t){return this.schemaInitializers[t]}getAll(){return this.schemaInitializers}has(t){return!!this.get(t)}remove(t){delete this.schemaInitializers[t]}removeItem(t,o){const r=this.get(t);r?r.remove(o):(this.actionList[t]||(this.actionList[t]=[]),this.actionList[t].push({type:"remove",itemName:o}))}}function normalizeContainer(e){if(!e)return console.warn("Failed to mount app: mount target should not be null or undefined."),null;if(typeof e=="string"){const t=document.querySelector(e);return t||console.warn(`Failed to mount app: mount target selector "${e}" returned null.`),t}return window.ShadowRoot&&e instanceof window.ShadowRoot&&e.mode==="closed"&&console.warn('mounting on a ShadowRoot with `{mode: "closed"}` may lead to unpredictable bugs'),e}const compose=(...e)=>{const t=e.reduce((o,r)=>{const[i,n]=r,a=({children:l})=>(0,import_jsx_runtime.jsx)(o,{children:(0,import_jsx_runtime.jsx)(i,P(x({},n),{children:l}))});return a.displayName=`compose(${i.displayName||i.name})`,a},BlankComponent);return o=>r=>(0,import_jsx_runtime.jsx)(t,{children:o&&(0,import_jsx_runtime.jsx)(o,x({},r))})};function defineGlobalDeps(e){e.define("react",()=>import_react2.default),e.define("react-dom",()=>import_react_dom.default),e.define("react/jsx-runtime",()=>import_jsx_runtime.default),e.define("react-router",()=>ReactRouter),e.define("react-router-dom",()=>ReactRouterDom),e.define("antd",()=>antd),e.define("antd-style",()=>antdStyle),e.define("@ant-design/icons",()=>antIcons),e.define("@ant-design/cssinjs",()=>antdCssinjs),e.define("i18next",()=>i18next),e.define("react-i18next",()=>reactI18next),e.define("@formily/antd-v5",()=>formilyAntdV5),e.define("@formily/core",()=>formilyCore),e.define("@formily/react",()=>formilyReact),e.define("@formily/shared",()=>formilyShared),e.define("@formily/json-schema",()=>formilyJsonSchema),e.define("@formily/reactive",()=>formilyJsonReactive),e.define("@formily/path",()=>formilyPath),e.define("@formily/validator",()=>formilyValidator),e.define("@formily/reactive-react",()=>formilyReactiveReact),e.define("@nocobase/utils",()=>nocobaseClientUtils),e.define("@nocobase/utils/client",()=>nocobaseClientUtils),e.define("@nocobase/client",()=>nocobaseClient),e.define("@nocobase/client/client",()=>nocobaseClient),e.define("@nocobase/evaluators",()=>nocobaseEvaluators),e.define("@nocobase/evaluators/client",()=>nocobaseEvaluators),e.define("@nocobase/sdk",()=>nocobaseSDK),e.define("@dnd-kit/accessibility",()=>dndKitAccessibility),e.define("@dnd-kit/core",()=>dndKitCore),e.define("@dnd-kit/modifiers",()=>dndKitModifiers),e.define("@dnd-kit/sortable",()=>dndKitSortable),e.define("@dnd-kit/utilities",()=>dndKitUtilities),e.define("axios",()=>import_axios.default),e.define("dayjs",()=>import_client.dayjs),e.define("lodash",()=>import_lodash.default),e.define("ahooks",()=>ahooks),e.define("@emotion/css",()=>emotionCss),e.define("file-saver",()=>FileSaver)}/* istanbul ignore file -- @preserve */function getRequireJs(){var requirejs,require,define,req,s,head,baseElement,dataMain,src,interactiveScript,currentlyAddingScript,mainScript,subPath,version="2.3.6",commentRegExp=/\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/mg,cjsRequireRegExp=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,jsSuffixRegExp=/\.js$/,currDirRegExp=/^\.\//,op=Object.prototype,ostring=op.toString,hasOwn=op.hasOwnProperty,isBrowser=!!(typeof window<"u"&&typeof navigator<"u"&&window.document),isWebWorker=!isBrowser&&typeof importScripts<"u",readyRegExp=isBrowser&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,defContextName="_",isOpera=typeof opera<"u"&&opera.toString()==="[object Opera]",contexts={},cfg={},globalDefQueue=[],useInteractive=!1;function commentReplace(e,t){return t||""}function isFunction(e){return ostring.call(e)==="[object Function]"}function isArray(e){return ostring.call(e)==="[object Array]"}function each(e,t){if(e){var o;for(o=0;o<e.length&&!(e[o]&&t(e[o],o,e));o+=1);}}function eachReverse(e,t){if(e){var o;for(o=e.length-1;o>-1&&!(e[o]&&t(e[o],o,e));o-=1);}}function hasProp(e,t){return hasOwn.call(e,t)}function getOwn(e,t){return hasProp(e,t)&&e[t]}function eachProp(e,t){var o;for(o in e)if(hasProp(e,o)&&t(e[o],o))break}function mixin(e,t,o,r){return t&&eachProp(t,function(i,n){(o||!hasProp(e,n))&&(r&&typeof i=="object"&&i&&!isArray(i)&&!isFunction(i)&&!(i instanceof RegExp)?(e[n]||(e[n]={}),mixin(e[n],i,o,r)):e[n]=i)}),e}function bind(e,t){return function(){return t.apply(e,arguments)}}function scripts(){return document.getElementsByTagName("script")}function defaultOnError(e){throw e}function getGlobal(e){if(!e)return e;var t=global;return each(e.split("."),function(o){t=t[o]}),t}function makeError(e,t,o,r){var i=new Error(t+`
299
- https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModules=r,o&&(i.originalError=o),i}if(typeof define<"u")return;if(typeof requirejs<"u"){if(isFunction(requirejs))return;cfg=requirejs,requirejs=void 0}typeof require<"u"&&!isFunction(require)&&(cfg=require,require=void 0);function newContext(e){var t,o,r,i,n,a={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},l={},c={},u={},m=[],d={},p={},g={},h=1,f=1;function _(I){var M,B;for(M=0;M<I.length;M++)if(B=I[M],B===".")I.splice(M,1),M-=1;else if(B===".."){if(M===0||M===1&&I[2]===".."||I[M-1]==="..")continue;M>0&&(I.splice(M-1,2),M-=2)}}function v(I,M,B){var z,E,V,U,G,W,Y,H,J,X,Q,ee,te=M&&M.split("/"),ne=a.map,ae=ne&&ne["*"];if(I&&(I=I.split("/"),Y=I.length-1,a.nodeIdCompat&&jsSuffixRegExp.test(I[Y])&&(I[Y]=I[Y].replace(jsSuffixRegExp,"")),I[0].charAt(0)==="."&&te&&(ee=te.slice(0,te.length-1),I=ee.concat(I)),_(I),I=I.join("/")),B&&ne&&(te||ae)){V=I.split("/");e:for(U=V.length;U>0;U-=1){if(W=V.slice(0,U).join("/"),te){for(G=te.length;G>0;G-=1)if(E=getOwn(ne,te.slice(0,G).join("/")),E&&(E=getOwn(E,W),E)){H=E,J=U;break e}}!X&&ae&&getOwn(ae,W)&&(X=getOwn(ae,W),Q=U)}!H&&X&&(H=X,J=Q),H&&(V.splice(0,J,H),I=V.join("/"))}return z=getOwn(a.pkgs,I),z||I}function S(I){isBrowser&&each(scripts(),function(M){if(M.getAttribute("data-requiremodule")===I&&M.getAttribute("data-requirecontext")===r.contextName)return M.parentNode.removeChild(M),!0})}function C(I){var M=getOwn(a.paths,I);if(M&&isArray(M)&&M.length>1)return M.shift(),r.require.undef(I),r.makeRequire(null,{skipMap:!0})([I]),!0}function b(I){var M,B=I?I.indexOf("!"):-1;return B>-1&&(M=I.substring(0,B),I=I.substring(B+1,I.length)),[M,I]}function y(I,M,B,z){var E,V,U,G,W=null,Y=M?M.name:null,H=I,J=!0,X="";return I||(J=!1,I="_@r"+(h+=1)),G=b(I),W=G[0],I=G[1],W&&(W=v(W,Y,z),V=getOwn(d,W)),I&&(W?B?X=I:V&&V.normalize?X=V.normalize(I,function(Q){return v(Q,Y,z)}):X=I.indexOf("!")===-1?v(I,Y,z):I:(X=v(I,Y,z),G=b(X),W=G[0],X=G[1],B=!0,E=r.nameToUrl(X))),U=W&&!V&&!B?"_unnormalized"+(f+=1):"",{prefix:W,name:X,parentMap:M,unnormalized:!!U,url:E,originalName:H,isDefine:J,id:(W?W+"!"+X:X)+U}}function F(I){var M=I.id,B=getOwn(l,M);return B||(B=l[M]=new r.Module(I)),B}function j(I,M,B){var z=I.id,E=getOwn(l,z);hasProp(d,z)&&(!E||E.defineEmitComplete)?M==="defined"&&B(d[z]):(E=F(I),E.error&&M==="error"?B(E.error):E.on(M,B))}function k(I,M){var B=I.requireModules,z=!1;M?M(I):(each(B,function(E){var V=getOwn(l,E);V&&(V.error=I,V.events.error&&(z=!0,V.emit("error",I)))}),z||req.onError(I))}function T(){globalDefQueue.length&&(each(globalDefQueue,function(I){var M=I[0];typeof M=="string"&&(r.defQueueMap[M]=!0),m.push(I)}),globalDefQueue=[])}i={require:function(I){return I.require?I.require:I.require=r.makeRequire(I.map)},exports:function(I){if(I.usingExports=!0,I.map.isDefine)return I.exports?d[I.map.id]=I.exports:I.exports=d[I.map.id]={}},module:function(I){return I.module?I.module:I.module={id:I.map.id,uri:I.map.url,config:function(){return getOwn(a.config,I.map.id)||{}},exports:I.exports||(I.exports={})}}};function O(I){delete l[I],delete c[I]}function N(I,M,B){var z=I.map.id;I.error?I.emit("error",I.error):(M[z]=!0,each(I.depMaps,function(E,V){var U=E.id,G=getOwn(l,U);G&&!I.depMatched[V]&&!B[U]&&(getOwn(M,U)?(I.defineDep(V,d[U]),I.check()):N(G,M,B))}),B[z]=!0)}function L(){var I,M,B=a.waitSeconds*1e3,z=B&&r.startTime+B<new Date().getTime(),E=[],V=[],U=!1,G=!0;if(!t){if(t=!0,eachProp(c,function(W){var Y=W.map,H=Y.id;if(W.enabled&&(Y.isDefine||V.push(W),!W.error)){if(!W.inited&&z)C(H)?(M=!0,U=!0):(E.push(H),S(H));else if(!W.inited&&W.fetched&&Y.isDefine&&(U=!0,!Y.prefix))return G=!1}}),z&&E.length)return I=makeError("timeout","Load timeout for modules: "+E,null,E),I.contextName=r.contextName,k(I);G&&each(V,function(W){N(W,{},{})}),(!z||M)&&U&&(isBrowser||isWebWorker)&&!n&&(n=setTimeout(function(){n=0,L()},50)),t=!1}}o=function(I){this.events=getOwn(u,I.id)||{},this.map=I,this.shim=getOwn(a.shim,I.id),this.depExports=[],this.depMaps=[],this.depMatched=[],this.pluginMaps={},this.depCount=0},o.prototype={init:function(I,M,B,z){z=z||{},!this.inited&&(this.factory=M,B?this.on("error",B):this.events.error&&(B=bind(this,function(E){this.emit("error",E)})),this.depMaps=I&&I.slice(0),this.errback=B,this.inited=!0,this.ignore=z.ignore,z.enabled||this.enabled?this.enable():this.check())},defineDep:function(I,M){this.depMatched[I]||(this.depMatched[I]=!0,this.depCount-=1,this.depExports[I]=M)},fetch:function(){if(!this.fetched){this.fetched=!0,r.startTime=new Date().getTime();var I=this.map;if(this.shim)r.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],bind(this,function(){return I.prefix?this.callPlugin():this.load()}));else return I.prefix?this.callPlugin():this.load()}},load:function(){var I=this.map.url;p[I]||(p[I]=!0,r.load(this.map.id,I))},check:function(){if(!(!this.enabled||this.enabling)){var I,M,B=this.map.id,z=this.depExports,E=this.exports,V=this.factory;if(!this.inited)hasProp(r.defQueueMap,B)||this.fetch();else if(this.error)this.emit("error",this.error);else if(!this.defining){if(this.defining=!0,this.depCount<1&&!this.defined){if(isFunction(V)){if(this.events.error&&this.map.isDefine||req.onError!==defaultOnError)try{E=r.execCb(B,V,z,E)}catch(G){I=G}else E=r.execCb(B,V,z,E);if(this.map.isDefine&&E===void 0&&(M=this.module,M?E=M.exports:this.usingExports&&(E=this.exports)),I)return I.requireMap=this.map,I.requireModules=this.map.isDefine?[this.map.id]:null,I.requireType=this.map.isDefine?"define":"require",k(this.error=I)}else E=V;if(this.exports=E,this.map.isDefine&&!this.ignore&&(d[B]=E,req.onResourceLoad)){var U=[];each(this.depMaps,function(G){U.push(G.normalizedMap||G)}),req.onResourceLoad(r,this.map,U)}O(B),this.defined=!0}this.defining=!1,this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}},callPlugin:function(){var I=this.map,M=I.id,B=y(I.prefix);this.depMaps.push(B),j(B,"defined",bind(this,function(z){var E,V,U,G=getOwn(g,this.map.id),W=this.map.name,Y=this.map.parentMap?this.map.parentMap.name:null,H=r.makeRequire(I.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){z.normalize&&(W=z.normalize(W,function(J){return v(J,Y,!0)})||""),V=y(I.prefix+"!"+W,this.map.parentMap,!0),j(V,"defined",bind(this,function(J){this.map.normalizedMap=V,this.init([],function(){return J},null,{enabled:!0,ignore:!0})})),U=getOwn(l,V.id),U&&(this.depMaps.push(V),this.events.error&&U.on("error",bind(this,function(J){this.emit("error",J)})),U.enable());return}if(G){this.map.url=r.nameToUrl(G),this.load();return}E=bind(this,function(J){this.init([],function(){return J},null,{enabled:!0})}),E.error=bind(this,function(J){this.inited=!0,this.error=J,J.requireModules=[M],eachProp(l,function(X){X.map.id.indexOf(M+"_unnormalized")===0&&O(X.map.id)}),k(J)}),E.fromText=bind(this,function(J,X){var Q=I.name,ee=y(Q),te=useInteractive;X&&(J=X),te&&(useInteractive=!1),F(ee),hasProp(a.config,M)&&(a.config[Q]=a.config[M]);try{req.exec(J)}catch(ne){return k(makeError("fromtexteval","fromText eval for "+M+" failed: "+ne,ne,[M]))}te&&(useInteractive=!0),this.depMaps.push(ee),r.completeLoad(Q),H([Q],E)}),z.load(I.name,H,E,a)})),r.enable(B,this),this.pluginMaps[B.id]=B},enable:function(){c[this.map.id]=this,this.enabled=!0,this.enabling=!0,each(this.depMaps,bind(this,function(I,M){var B,z,E;if(typeof I=="string"){if(I=y(I,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[M]=I,E=getOwn(i,I.id),E){this.depExports[M]=E(this);return}this.depCount+=1,j(I,"defined",bind(this,function(V){this.undefed||(this.defineDep(M,V),this.check())})),this.errback?j(I,"error",bind(this,this.errback)):this.events.error&&j(I,"error",bind(this,function(V){this.emit("error",V)}))}B=I.id,z=l[B],!hasProp(i,B)&&z&&!z.enabled&&r.enable(I,this)})),eachProp(this.pluginMaps,bind(this,function(I){var M=getOwn(l,I.id);M&&!M.enabled&&r.enable(I,this)})),this.enabling=!1,this.check()},on:function(I,M){var B=this.events[I];B||(B=this.events[I]=[]),B.push(M)},emit:function(I,M){each(this.events[I],function(B){B(M)}),I==="error"&&delete this.events[I]}};function D(I){hasProp(d,I[0])||F(y(I[0],null,!0)).init(I[1],I[2])}function R(I,M,B,z){I.detachEvent&&!isOpera?z&&I.detachEvent(z,M):I.removeEventListener(B,M,!1)}function $(I){var M=I.currentTarget||I.srcElement;return R(M,r.onScriptLoad,"load","onreadystatechange"),R(M,r.onScriptError,"error"),{node:M,id:M&&M.getAttribute("data-requiremodule")}}function w(){var I;for(T();m.length;){if(I=m.shift(),I[0]===null)return k(makeError("mismatch","Mismatched anonymous define() module: "+I[I.length-1]));D(I)}r.defQueueMap={}}return r={config:a,contextName:e,registry:l,defined:d,urlFetched:p,defQueue:m,defQueueMap:{},Module:o,makeModuleMap:y,nextTick:req.nextTick,onError:k,configure:function(I){if(I.baseUrl&&I.baseUrl.charAt(I.baseUrl.length-1)!=="/"&&(I.baseUrl+="/"),typeof I.urlArgs=="string"){var M=I.urlArgs;I.urlArgs=function(E,V){return(V.indexOf("?")===-1?"?":"&")+M}}var B=a.shim,z={paths:!0,bundles:!0,config:!0,map:!0};eachProp(I,function(E,V){z[V]?(a[V]||(a[V]={}),mixin(a[V],E,!0,!0)):a[V]=E}),I.bundles&&eachProp(I.bundles,function(E,V){each(E,function(U){U!==V&&(g[U]=V)})}),I.shim&&(eachProp(I.shim,function(E,V){isArray(E)&&(E={deps:E}),(E.exports||E.init)&&!E.exportsFn&&(E.exportsFn=r.makeShimExports(E)),B[V]=E}),a.shim=B),I.packages&&each(I.packages,function(E){var V,U;E=typeof E=="string"?{name:E}:E,U=E.name,V=E.location,V&&(a.paths[U]=E.location),a.pkgs[U]=E.name+"/"+(E.main||"main").replace(currDirRegExp,"").replace(jsSuffixRegExp,"")}),eachProp(l,function(E,V){!E.inited&&!E.map.unnormalized&&(E.map=y(V,null,!0))}),(I.deps||I.callback)&&r.require(I.deps||[],I.callback)},makeShimExports:function(I){function M(){var B;return I.init&&(B=I.init.apply(global,arguments)),B||I.exports&&getGlobal(I.exports)}return M},makeRequire:function(I,M){M=M||{};function B(z,E,V){var U,G,W;return M.enableBuildCallback&&E&&isFunction(E)&&(E.__requireJsBuild=!0),typeof z=="string"?isFunction(E)?k(makeError("requireargs","Invalid require call"),V):I&&hasProp(i,z)?i[z](l[I.id]):req.get?req.get(r,z,I,B):(G=y(z,I,!1,!0),U=G.id,hasProp(d,U)?d[U]:k(makeError("notloaded",'Module name "'+U+'" has not been loaded yet for context: '+e+(I?"":". Use require([])")))):(w(),r.nextTick(function(){w(),W=F(y(null,I)),W.skipMap=M.skipMap,W.init(z,E,V,{enabled:!0}),L()}),B)}return mixin(B,{isBrowser,toUrl:function(z){var E,V=z.lastIndexOf("."),U=z.split("/")[0],G=U==="."||U==="..";return V!==-1&&(!G||V>1)&&(E=z.substring(V,z.length),z=z.substring(0,V)),r.nameToUrl(v(z,I&&I.id,!0),E,!0)},defined:function(z){return hasProp(d,y(z,I,!1,!0).id)},specified:function(z){return z=y(z,I,!1,!0).id,hasProp(d,z)||hasProp(l,z)}}),I||(B.undef=function(z){T();var E=y(z,I,!0),V=getOwn(l,z);V.undefed=!0,S(z),delete d[z],delete p[E.url],delete u[z],eachReverse(m,function(U,G){U[0]===z&&m.splice(G,1)}),delete r.defQueueMap[z],V&&(V.events.defined&&(u[z]=V.events),O(z))}),B},enable:function(I){var M=getOwn(l,I.id);M&&F(I).enable()},completeLoad:function(I){var M,B,z,E=getOwn(a.shim,I)||{},V=E.exports;for(T();m.length;){if(B=m.shift(),B[0]===null){if(B[0]=I,M)break;M=!0}else B[0]===I&&(M=!0);D(B)}if(r.defQueueMap={},z=getOwn(l,I),!M&&!hasProp(d,I)&&z&&!z.inited){if(a.enforceDefine&&(!V||!getGlobal(V)))return C(I)?void 0:k(makeError("nodefine","No define call for "+I,null,[I]));D([I,E.deps||[],E.exportsFn])}L()},nameToUrl:function(I,M,B){var z,E,V,U,G,W,Y,H=getOwn(a.pkgs,I);if(H&&(I=H),Y=getOwn(g,I),Y)return r.nameToUrl(Y,M,B);if(req.jsExtRegExp.test(I))G=I+(M||"");else{for(z=a.paths,E=I.split("/"),V=E.length;V>0;V-=1)if(U=E.slice(0,V).join("/"),W=getOwn(z,U),W){isArray(W)&&(W=W[0]),E.splice(0,V,W);break}G=E.join("/"),G+=M||(/^data\:|^blob\:|\?/.test(G)||B?"":".js"),G=(G.charAt(0)==="/"||G.match(/^[\w\+\.\-]+:/)?"":a.baseUrl)+G}return a.urlArgs&&!/^blob\:/.test(G)?G+a.urlArgs(I,G):G},load:function(I,M){req.load(r,I,M)},execCb:function(I,M,B,z){return M.apply(z,B)},onScriptLoad:function(I){if(I.type==="load"||readyRegExp.test((I.currentTarget||I.srcElement).readyState)){interactiveScript=null;var M=$(I);r.completeLoad(M.id)}},onScriptError:function(I){var M=$(I);if(!C(M.id)){var B=[];return eachProp(l,function(z,E){E.indexOf("_@r")!==0&&each(z.depMaps,function(V){if(V.id===M.id)return B.push(E),!0})}),k(makeError("scripterror",'Script error for "'+M.id+(B.length?'", needed by: '+B.join(", "):'"'),I,[M.id]))}}},r.require=r.makeRequire(),r}req=requirejs=function(e,t,o,r){var i,n,a=defContextName;return!isArray(e)&&typeof e!="string"&&(n=e,isArray(t)?(e=t,t=o,o=r):e=[]),n&&n.context&&(a=n.context),i=getOwn(contexts,a),i||(i=contexts[a]=req.s.newContext(a)),n&&i.configure(n),i.require(e,t,o)},req.config=function(e){return req(e)},req.nextTick=typeof setTimeout<"u"?function(e){setTimeout(e,4)}:function(e){e()},require||(require=req),req.version=version,req.jsExtRegExp=/^\/|:|\?|\.js$/,req.isBrowser=isBrowser,s=req.s={contexts,newContext},req({}),each(["toUrl","undef","defined","specified"],function(e){req[e]=function(){var t=contexts[defContextName];return t.require[e].apply(t,arguments)}}),isBrowser&&(head=s.head=document.getElementsByTagName("head")[0],baseElement=document.getElementsByTagName("base")[0],baseElement&&(head=s.head=baseElement.parentNode)),req.onError=defaultOnError,req.createNode=function(e,t,o){var r=e.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");return r.type=e.scriptType||"text/javascript",r.charset="utf-8",r.async=!0,r},req.load=function(e,t,o){var r=e&&e.config||{},i;if(isBrowser)return i=req.createNode(r,t,o),i.setAttribute("data-requirecontext",e.contextName),i.setAttribute("data-requiremodule",t),i.attachEvent&&!(i.attachEvent.toString&&i.attachEvent.toString().indexOf("[native code")<0)&&!isOpera?(useInteractive=!0,i.attachEvent("onreadystatechange",e.onScriptLoad)):(i.addEventListener("load",e.onScriptLoad,!1),i.addEventListener("error",e.onScriptError,!1)),i.src=o,r.onNodeCreated&&r.onNodeCreated(i,r,t,o),currentlyAddingScript=i,baseElement?head.insertBefore(i,baseElement):head.appendChild(i),currentlyAddingScript=null,i;if(isWebWorker)try{setTimeout(function(){},0),importScripts(o),e.completeLoad(t)}catch(n){e.onError(makeError("importscripts","importScripts failed for "+t+" at "+o,n,[t]))}};function getInteractiveScript(){return interactiveScript&&interactiveScript.readyState==="interactive"||eachReverse(scripts(),function(e){if(e.readyState==="interactive")return interactiveScript=e}),interactiveScript}return isBrowser&&!cfg.skipDataMain&&eachReverse(scripts(),function(e){if(head||(head=e.parentNode),dataMain=e.getAttribute("data-main"),dataMain)return mainScript=dataMain,!cfg.baseUrl&&mainScript.indexOf("!")===-1&&(src=mainScript.split("/"),mainScript=src.pop(),subPath=src.length?src.join("/")+"/":"./",cfg.baseUrl=subPath),mainScript=mainScript.replace(jsSuffixRegExp,""),req.jsExtRegExp.test(mainScript)&&(mainScript=dataMain),cfg.deps=cfg.deps?cfg.deps.concat(mainScript):[mainScript],!0}),define=function(e,t,o){var r,i;typeof e!="string"&&(o=t,t=e,e=null),isArray(t)||(o=t,t=null),!t&&isFunction(o)&&(t=[],o.length&&(o.toString().replace(commentRegExp,commentReplace).replace(cjsRequireRegExp,function(n,a){t.push(a)}),t=(o.length===1?["require"]:["require","exports","module"]).concat(t))),useInteractive&&(r=currentlyAddingScript||getInteractiveScript(),r&&(e||(e=r.getAttribute("data-requiremodule")),i=contexts[r.getAttribute("data-requirecontext")])),i?(i.defQueue.push([e,t,o]),i.defQueueMap[e]=!0):globalDefQueue.push([e,t,o])},define.amd={jQuery:!0},req.exec=function(text){return eval(text)},req(cfg),{requirejs,require,define}}const setFieldProps=(e,t,o)=>{(0,import_reactive.untracked)(()=>{e[t]===void 0&&(e[t]=o)})},setRequired=(e,t,o)=>{typeof t.required>"u"&&(e.required=!!o.required)},CollectionFieldInternalField_deprecated=e=>{var t;const o=useCompile(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{uiSchema:n,defaultValue:a}=useCollectionField(),{isAllowToSetDefaultValue:l}=useIsAllowToSetDefaultValue(),c=useComponent(((t=i["x-component-props"])==null?void 0:t.component)||(n==null?void 0:n["x-component"])||"Input"),u=useFormBlockContext(),m=useDynamicComponentProps(n==null?void 0:n["x-use-component-props"],e);return(0,import_react2.useEffect)(()=>{if(!n)return;const d=o(n);if(setFieldProps(r,"content",d["x-content"]),setFieldProps(r,"title",d.title),setFieldProps(r,"description",d.description),u!=null&&u.form){const g=l()?i.default||a:void 0;g!=null&&setFieldProps(r,"initialValue",g)}if(!r.validator&&(d["x-validator"]||i["x-validator"])){const g=(0,import_lodash.concat)([],d["x-validator"]||[],i["x-validator"]||[]);r.validator=g}i["x-disabled"]===!0&&(r.disabled=!0),i["x-read-pretty"]===!0&&(r.readPretty=!0),setRequired(r,i,d),r.dataSource=d.enum;const p=o(d["x-component-props"])||{};r.componentProps=(0,import_shared.merge)(p,r.componentProps||{},m||{})},[n]),n?(0,import_jsx_runtime.jsx)(c,x(x({},e),m)):null},CollectionFieldInternalField=e=>{var t;const o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{uiSchema:i}=useCollectionFieldUISchema(),n=useComponent(((t=r["x-component-props"])==null?void 0:t.component)||(i==null?void 0:i["x-component"])||"Input"),a=useDynamicComponentProps(i==null?void 0:i["x-use-component-props"],e);return(0,import_react2.useEffect)(()=>{r["x-read-pretty"]===!0&&!o.readPretty&&(o.readPretty=!0)},[o,r]),i?(0,import_jsx_runtime.jsx)(n,x(x({},e),a)):null},CollectionField$1=(0,import_react.connect)(e=>{const t=(0,import_react.useFieldSchema)(),o=useIsInNocoBaseRecursionFieldContext();return(0,import_jsx_runtime.jsx)(CollectionFieldProvider,{name:t.name,children:o?(0,import_jsx_runtime.jsx)(CollectionFieldInternalField,x({},e)):(0,import_jsx_runtime.jsx)(CollectionFieldInternalField_deprecated,x({},e))})});CollectionField$1.displayName="CollectionField";const DataSourceApplicationProvider=e=>{var t=e,{children:o,dataSourceManager:r}=t,i=K(t,["children","dataSourceManager"]);return(0,import_jsx_runtime.jsx)(DataSourceManagerProvider,{dataSourceManager:r,children:(0,import_jsx_runtime.jsx)(CollectionManagerProvider,P(x({},i),{children:o}))})},getKeyByName=e=>e?`nocobase_${e}_designable`.toUpperCase():"nocobase_designable".toUpperCase(),SchemaComponentProviderWithLocalStorageState=e=>{const[t,o]=(0,import_ahooks.useLocalStorageState)(getKeyByName(e.appName),{defaultValue:!!e.designable});return(0,import_jsx_runtime.jsx)(SchemaComponentProvider,P(x({},e),{designable:t,onDesignableChange:r=>{o(r)}}))},AppSchemaComponentProvider=e=>typeof e.designable=="boolean"?(0,import_jsx_runtime.jsx)(SchemaComponentProvider,x({},e)):(0,import_jsx_runtime.jsx)(SchemaComponentProviderWithLocalStorageState,x({},e));class Application{constructor(t={}){A(this,"eventBus",new EventTarget),A(this,"providers",[]),A(this,"router"),A(this,"scopes",{}),A(this,"i18n"),A(this,"ws"),A(this,"apiClient"),A(this,"components",P(x(x({DataBlockProvider},defaultAppComponents),schemaInitializerComponents),{CollectionField:CollectionField$1})),A(this,"pluginManager"),A(this,"pluginSettingsManager"),A(this,"devDynamicImport"),A(this,"requirejs"),A(this,"notification"),A(this,"schemaInitializerManager"),A(this,"schemaSettingsManager"),A(this,"dataSourceManager"),A(this,"name"),A(this,"loading",!0),A(this,"maintained",!1),A(this,"maintaining",!1),A(this,"error",null),A(this,"hasLoadError",!1),A(this,"wsAuthorized",!1),this.options=t,this.initRequireJs(),(0,import_reactive.define)(this,{maintained:import_reactive.observable.ref,loading:import_reactive.observable.ref,maintaining:import_reactive.observable.ref,error:import_reactive.observable.ref}),this.devDynamicImport=t.devDynamicImport,this.scopes=(0,import_merge.default)(this.scopes,t.scopes),this.components=(0,import_merge.default)(this.components,t.components),this.apiClient=t.apiClient instanceof APIClient?t.apiClient:new APIClient(t.apiClient),this.apiClient.app=this,this.i18n=t.i18n||i18n,this.router=new RouterManager(t.router,this),this.schemaSettingsManager=new SchemaSettingsManager(t.schemaSettings,this),this.pluginManager=new PluginManager$1(t.plugins,t.loadRemotePlugins,this),this.schemaInitializerManager=new SchemaInitializerManager(t.schemaInitializers,this),this.dataSourceManager=new DataSourceManager(t.dataSourceManager,this),this.addDefaultProviders(),this.addReactRouterComponents(),this.addProviders(t.providers||[]),this.ws=new WebSocketClient(t.ws),this.ws.app=this,this.pluginSettingsManager=new PluginSettingsManager(t.pluginSettings,this),this.addRoutes(),this.name=this.options.name||(0,import_sdk.getSubAppName)(t.publicPath)||"main",this.i18n.on("languageChanged",o=>{this.apiClient.auth.locale=o}),this.initListeners()}get pm(){return this.pluginManager}get disableAcl(){return this.options.disableAcl}get isWsAuthorized(){return this.wsAuthorized}setWsAuthorized(t){this.wsAuthorized=t}initListeners(){this.eventBus.addEventListener("auth:tokenChanged",t=>{this.setTokenInWebSocket(t.detail)}),this.eventBus.addEventListener("maintaining:end",()=>{this.apiClient.auth.token&&this.setTokenInWebSocket({token:this.apiClient.auth.token,authenticator:this.apiClient.auth.getAuthenticator()})})}setTokenInWebSocket(t){const{token:o,authenticator:r}=t;this.maintaining||this.ws.send(JSON.stringify({type:"auth:token",payload:{token:o,authenticator:r}}))}setMaintaining(t){this.maintaining!==t&&(this.maintaining=t,t||this.eventBus.dispatchEvent(new Event("maintaining:end")))}initRequireJs(){this.requirejs=getRequireJs(),defineGlobalDeps(this.requirejs),window.define=this.requirejs.define}addDefaultProviders(){this.use(APIClientProvider,{apiClient:this.apiClient}),this.use(import_react_i18next.I18nextProvider,{i18n:this.i18n}),this.use(GlobalThemeProvider),this.use(CSSVariableProvider),this.use(AppSchemaComponentProvider,{designable:this.options.designable,appName:this.name,components:this.components,scope:this.scopes}),this.use(AntdAppProvider),this.use(DataSourceApplicationProvider,{dataSourceManager:this.dataSourceManager}),this.use(OpenModeProvider)}addReactRouterComponents(){this.addComponents({Link:import_react_router_dom.Link,Navigate:import_react_router_dom.Navigate,NavLink:import_react_router_dom.NavLink})}addRoutes(){this.router.add("not-found",{path:"*",Component:this.components.AppNotFound})}getOptions(){return this.options}getName(){return(0,import_sdk.getSubAppName)(this.getPublicPath())||null}getPublicPath(){let t=this.options.publicPath||"/";return t.endsWith("/")||(t+="/"),t}getApiUrl(t=""){let o=this.apiClient.axios.defaults.baseURL;if(!o.startsWith("http://")&&!o.startsWith("https://")){const{protocol:r,host:i}=window.location;o=`${r}//${i}${o}`}return o.replace(/\/$/g,"")+"/"+t.replace(/^\//g,"")}getRouteUrl(t){return this.getPublicPath()+t.replace(/^\//g,"")}getHref(t){const o=this.name;return o&&o!=="main"?this.getPublicPath()+"apps/"+o+"/"+t.replace(/^\//g,""):this.getPublicPath()+t.replace(/^\//g,"")}getCollectionManager(t){var o;return(o=this.dataSourceManager.getDataSource(t))==null?void 0:o.collectionManager}getComposeProviders(){const t=compose(...this.providers)(BlankComponent);return t.displayName="Providers",t}use(t,o){return this.addProvider(t,o)}addProvider(t,o){return this.providers.push([t,o])}addProviders(t){t.forEach(o=>{Array.isArray(o)?this.addProvider(o[0],o[1]):this.addProvider(o)})}load(){return q(this,null,function*(){try{this.loading=!0,yield this.loadWebSocket(),yield this.pm.load()}catch(t){this.hasLoadError=!0,this.ws.enabled&&(yield new Promise(r=>{setTimeout(()=>r(null),1e3)}));const o=r=>{var i,n,a,l,c,u,m,d,p,g,h,f;if(typeof((i=r==null?void 0:r.response)==null?void 0:i.data)=="string"){const _=document.createElement("div");return _.innerHTML=(n=r==null?void 0:r.response)==null?void 0:n.data,{message:_.textContent||_.innerText}}return(l=(a=r==null?void 0:r.response)==null?void 0:a.data)!=null&&l.error?(u=(c=r==null?void 0:r.response)==null?void 0:c.data)==null?void 0:u.error:(p=(d=(m=r==null?void 0:r.response)==null?void 0:m.data)==null?void 0:d.errors)!=null&&p[0]?(f=(h=(g=r==null?void 0:r.response)==null?void 0:g.data)==null?void 0:h.errors)==null?void 0:f[0]:{message:r==null?void 0:r.message}};this.error=x({code:"LOAD_ERROR"},o(t)),console.error(t,this.error)}this.loading=!1})}loadWebSocket(){return q(this,null,function*(){this.eventBus.addEventListener("ws:message:authorized",()=>{this.setWsAuthorized(!0)}),this.ws.on("message",t=>{var o,r,i;const n=JSON.parse(t.data);if((o=n==null?void 0:n.payload)!=null&&o.refresh){window.location.reload();return}if(n.type==="notification"){this.notification[((r=n.payload)==null?void 0:r.type)||"info"]({message:(i=n.payload)==null?void 0:i.message});return}if(n.type==="maintaining"&&n.payload.code!=="APP_RUNNING")this.setMaintaining(!0),this.error=n.payload;else{this.hasLoadError&&window.location.reload(),this.setMaintaining(!1),this.maintained=!0,this.error=null;const a=n.type;if(!a)return;const l=`ws:message:${a}`;this.eventBus.dispatchEvent(new CustomEvent(l,{detail:n.payload}))}}),this.ws.on("serverDown",()=>{this.maintaining=!0,this.maintained=!1}),this.ws.on("open",()=>{const t=this.apiClient.auth.token;t&&this.setTokenInWebSocket({token:t,authenticator:this.apiClient.auth.getAuthenticator()})}),this.ws.connect()})}getComponent(t,o=!0){const r=i=>o&&console.error(i);if(!t){r(`getComponent called with ${t}`);return}if(typeof t=="function")return t;if(typeof t=="string"){const i=(0,import_get.default)(this.components,t);if(!i){r(`Component ${t} not found`);return}return i}r(`Component ${t} should be a string or a React component`)}renderComponent(t,o,r){return import_react2.default.createElement(this.getComponent(t),o,r)}addComponent(t,o){const r=o||t.displayName||t.name;if(!r){console.error("Component must have a displayName or pass name as second argument");return}(0,import_set.default)(this.components,r,t)}addComponents(t){Object.keys(t).forEach(o=>{this.addComponent(t[o],o)})}addScopes(t){this.scopes=(0,import_merge.default)(this.scopes,t)}getRootComponent(){return({children:t})=>(0,import_jsx_runtime.jsx)(AppComponent,{app:this,children:t})}mount(t){const o=normalizeContainer(t);if(!o)return;const r=this.getRootComponent(),i=(0,import_client3.createRoot)(o);return i.render((0,import_jsx_runtime.jsx)(r,{})),i}addFieldInterfaces(t=[]){return this.dataSourceManager.collectionFieldInterfaceManager.addFieldInterfaces(t)}addFieldInterfaceComponentOption(t,o){return this.dataSourceManager.collectionFieldInterfaceManager.addFieldInterfaceComponentOption(t,o)}}function getNewSchema(e){const{fieldSchema:t,schemaKey:o,parentSchemaKey:r,value:i,valueKeys:n}=e;if(o)import_lodash.default.set(t,o,i);else if(r){if(i==null)return t;typeof i=="object"?Object.keys(i).forEach(a=>{n&&!n.includes(a)||import_lodash.default.set(t,`${r}.${a}`,i[a])}):console.error("value must be object")}return t}const useHookDefault=e=>e,useSchemaByType=(e="common")=>{const t=(0,import_react.useFieldSchema)(),{fieldSchema:o}=useColumnSchema$1()||{};return e==="field"&&o||t};function createModalSettingsItem(e){const{name:t,parentSchemaKey:o,valueKeys:r,schema:i,title:n,useSubmit:a=useHookDefault,useVisible:l,defaultValue:c,useDefaultValue:u=useHookDefault,width:m,type:d="common"}=e;return{name:t,type:"actionModal",useVisible:l,useComponentProps(){const p=useSchemaByType(d),{dn:g}=useDesignable(),h=u(c),f=o?import_lodash.default.get(p,o):void 0,_=useCompile(),{t:v}=(0,import_react_i18next.useTranslation)(),S=a(),{fieldSchema:C}=useColumnSchema$1()||{};return{title:typeof n=="function"?n(v):_(n),width:m,schema:i(x(x({},h),f)),onSubmit(b){const y=getNewSchema({fieldSchema:p,parentSchemaKey:o,value:b,valueKeys:r});return C?(g.emit("patch",{schema:y}),g.refresh()):g.deepMerge(y),S==null?void 0:S(b)}}}}}const createSelectSchemaSettingsItem=e=>{const{name:t,title:o,options:r,useOptions:i=useHookDefault,schemaKey:n,useVisible:a,type:l="common",defaultValue:c,useDefaultValue:u=useHookDefault}=e;return{name:t,type:"select",useVisible:a,useComponentProps(){const m=useSchemaByType(l),{fieldSchema:d}=useColumnSchema$1()||{},{dn:p}=useDesignable(),g=i(r),h=u(c),f=useCompile(),{t:_}=(0,import_react_i18next.useTranslation)();return{title:typeof o=="function"?o(_):f(o),options:g,value:import_lodash.default.get(m,n,h),onChange(v){const S=getNewSchema({fieldSchema:m,schemaKey:n,value:v});d?(p.emit("patch",{schema:S}),p.refresh()):p.deepMerge(S)}}}}};function createSwitchSettingsItem(e){const{name:t,useVisible:o,schemaKey:r,title:i,type:n="common",defaultValue:a,useDefaultValue:l=useHookDefault}=e;return{name:t,useVisible:o,type:"switch",useComponentProps(){const c=useSchemaByType(n),{dn:u}=useDesignable(),m=l(a),d=useCompile(),{t:p}=(0,import_react_i18next.useTranslation)(),{fieldSchema:g}=useColumnSchema$1()||{};return{title:typeof i=="function"?i(p):d(i),checked:!!import_lodash.default.get(c,r,m),onChange(h){const f=getNewSchema({fieldSchema:c,schemaKey:r,value:h});g?(u.emit("patch",{schema:f}),u.refresh()):u.deepMerge(f)}}}}}function createTextSettingsItem(e){const{name:t,useVisible:o,title:r,useTextClick:i=useHookDefault}=e;return{name:t,type:"item",useVisible:o,useComponentProps(){const n=useCompile(),{t:a}=(0,import_react_i18next.useTranslation)(),l=i();return{title:typeof r=="function"?r(a):n(r),onClick:l}}}}const SchemaSettingItemContext=(0,import_react2.createContext)({});SchemaSettingItemContext.displayName="SchemaSettingItemContext";function useSchemaSettingsItem(){return(0,import_react2.useContext)(SchemaSettingItemContext)}const useCollectionManager_deprecated=e=>{const t=useDataSourceManager(),o=useDataSource(),r=useCollectionManager(),i=e||(o==null?void 0:o.key)||void 0,[n,a]=(0,import_react2.useState)((0,import_shared.uid)()),{refresh:l}=useSchemaComponentContext(),c=(0,import_react2.useMemo)(()=>{var R;return(R=t==null?void 0:t.collectionFieldInterfaceManager)==null?void 0:R.getFieldInterfaces().reduce(($,w)=>($[w.name]=w,$),{})},[t,n]),u=(0,import_react2.useMemo)(()=>t==null?void 0:t.collectionTemplateManager.getCollectionTemplates(),[t,n]),m=(0,import_react2.useCallback)(()=>{var R,$;return($=(R=t==null?void 0:t.getDataSource(i))==null?void 0:R.collectionManager)==null?void 0:$.getCollections().map(w=>w.getOptions())},[t,o]),d=(0,import_react2.useCallback)(R=>{var $;return r&&!R?r:($=t==null?void 0:t.getDataSource(R||i))==null?void 0:$.collectionManager},[r,t,i]),p=(0,import_react2.useMemo)(()=>{var R,$;return($=(R=t==null?void 0:t.getDataSource(DEFAULT_DATA_SOURCE_KEY))==null?void 0:R.collectionManager)==null?void 0:$.getCollections()},[t,n]),g=(0,import_react2.useCallback)(()=>t==null?void 0:t.getDataSource(DEFAULT_DATA_SOURCE_KEY).reload().then(()=>{l(),a((0,import_shared.uid)())}),[t]),h=(0,import_react2.useCallback)(()=>t==null?void 0:t.getDataSource(DEFAULT_DATA_SOURCE_KEY).reload().then(()=>{l(),a((0,import_shared.uid)())}),[t]),f=useCompile(),_=(0,import_react2.useCallback)((R,$)=>{var w,I;return((I=(w=d($))==null?void 0:w.getCollection(R))==null?void 0:I.getInheritedFields())||[]},[t,d]),v=(0,import_react2.useCallback)((R,$)=>{var w,I;if(!R)return[];const M=(w=d($))==null?void 0:w.getCollection(R);return((I=M==null?void 0:M.getAllFields)==null?void 0:I.call(M))||(M==null?void 0:M.getFields())||[]},[t,d]),S=(0,import_react2.useCallback)((R,$)=>{var w;if(!(!R||R.split(".").length<2))return(w=d($))==null?void 0:w.getCollectionField(R)},[t,d]),C=(0,import_react2.useCallback)((R,$)=>{var w,I;return R?((I=(w=d($))==null?void 0:w.getCollection(R))==null?void 0:I.getParentCollectionsName())||[]:[]},[t,d]),b=(0,import_react2.useCallback)((R,$=!1,w)=>{var I;if(!R)return[];const M=(I=d(w))==null?void 0:I.getCollection(R);return(M==null?void 0:M.getChildrenCollections($))||[]},[t,d]),y=(0,import_react2.useCallback)((R,$)=>{var w,I;return R?((I=(w=d($))==null?void 0:w.getCollection(R))==null?void 0:I.getCurrentFields())||[]:[]},[t,d]),F=(0,import_react2.useCallback)((R,$="string",w)=>{var I;const{association:M=!1,cached:B={},collectionNames:z=[R],maxDepth:E=1,allowAllTypes:V=!1,exceptInterfaces:U=[],prefixFieldValue:G="",usePrefix:W=!1,dataSource:Y}=w||{};if(z.length-1>E)return;if(B[R])return import_lodash.default.cloneDeep(B[R]);typeof $=="string"&&($=[$]);const H=v(R,Y),J=(I=H==null?void 0:H.filter(X=>X.interface&&!U.includes(X.interface)&&(V||$.includes(X.type)||(M&&X.target&&X.target!==R&&Array.isArray(M)?M.includes(X.interface):!1))))==null?void 0:I.map(X=>{var Q,ee;const te=x({value:W&&G?`${G}.${X.name}`:X.name,label:f((Q=X==null?void 0:X.uiSchema)==null?void 0:Q.title)||X.name},X);return M&&X.target&&(te.children=z.includes(X.target)?[]:F(X.target,$,P(x({},w),{cached:B,dataSource:Y,collectionNames:[...z,X.target],prefixFieldValue:W?G?`${G}.${X.name}`:X.name:"",usePrefix:W})),!((ee=te.children)!=null&&ee.length))?null:te}).filter(Boolean);return B[R]=J,J},[v]),j=(0,import_react2.useCallback)((R,$)=>{var w;return(w=d($))==null?void 0:w.getCollection(R)},[t,d]),k=(0,import_react2.useCallback)((R,$)=>{var w,I;return(I=(w=d($))==null?void 0:w.getCollection(R))==null?void 0:I.getAllCollectionsInheritChain()},[t,d]),T=(0,import_react2.useCallback)((R,$)=>()=>{var w,I;return(I=(w=d($))==null?void 0:w.getCollection(R))==null?void 0:I.getInheritCollectionsChain()},[t,d]),O=(0,import_react2.useCallback)(R=>t==null?void 0:t.collectionFieldInterfaceManager.getFieldInterface(R),[t]),N=(0,import_react2.useCallback)(R=>{var $;return($=O(R.interface))==null?void 0:$.titleUsable},[O]),L=(0,import_react2.useCallback)((R,$,w)=>{var I,M;return(M=(I=d(w))==null?void 0:I.getCollection($))==null?void 0:M.getParentCollectionFields(R)},[t,d]),D=(0,import_react2.useCallback)((R="general")=>t==null?void 0:t.collectionTemplateManager.getCollectionTemplate(R),[t]);return{service:g,interfaces:c,collections:p,templates:u,getTemplate:D,getInterface:O,getCollections:m,getParentCollectionFields:L,getInheritCollections:C,getChildrenCollections:b,refreshCM:h,get:j,getInheritedFields:_,getCollectionField:S,getCollectionFields:v,getCollectionFieldsOptions:F,getCurrentCollectionFields:y,getCollection:j,getCollectionJoinField:S,getAllCollectionsInheritChain:k,getInheritCollectionsChain:T,isTitleField:N}},GetMenuItemContext=(0,import_react2.createContext)(null);GetMenuItemContext.displayName="GetMenuItemContext";const GetMenuItemsContext=(0,import_react2.createContext)(null);GetMenuItemsContext.displayName="GetMenuItemsContext";const useCollectMenuItem=()=>(0,import_react2.useContext)(GetMenuItemContext)||{},useCollectMenuItems=()=>(0,import_react2.useContext)(GetMenuItemsContext)||{},useMenuItem=()=>{const e=(0,import_react2.useRef)([]),t=(0,import_react2.useRef)(null),o=(0,import_react2.useRef)(!1),r=(0,import_react2.useCallback)(({limitCount:l})=>o.current?(o.current=!1,t.current?t.current():l&&e.current.length>l?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.current.slice(0,l).map((c,u)=>(0,import_jsx_runtime.jsx)(c,{},u))}):(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.current.map((c,u)=>(0,import_jsx_runtime.jsx)(c,{},u))})):null,[]),i=(0,import_react2.useCallback)(l=>{const c=[],u=m=>{c.push(m),c.sort((d,p)=>(d.order||0)-(p.order||0))};return o.current=!0,t.current=()=>{const m=c.filter(d=>d.notdelete).map(d=>import_lodash.default.omit(d,"notdelete"));return c.length=0,c.push(...m),(0,import_jsx_runtime.jsx)(GetMenuItemsContext.Provider,{value:{pushMenuItem:u},children:l()})},c},[]),n=(0,import_react2.useCallback)(l=>{const c={},u=m=>{Object.assign(c,m)};return o.current=!0,e.current.push(()=>(0,import_jsx_runtime.jsx)(GetMenuItemContext.Provider,{value:{collectMenuItem:u},children:l()})),c},[]),a=(0,import_react2.useCallback)(()=>{e.current=[]},[]);return{Component:r,getMenuItems:i,getMenuItem:n,clean:a}},isModalTitle=e=>(0,import_shared.isNum)(e)||(0,import_shared.isStr)(e)||(0,import_shared.isBool)(e)||import_react2.default.isValidElement(e),getModelProps=e=>isModalTitle(e)?{title:e}:e;function FormDialog(e,t,o,r){((0,import_shared.isFn)(t)||import_react2.default.isValidElement(t))&&(r=o,o=t,t="form-dialog");const i={host:document.createElement("div"),form:null,promise:null,openMiddlewares:[],confirmMiddlewares:[],cancelMiddlewares:[]},n=createPortalRoot(i.host,t),a=getModelProps(e),l=P(x({},a),{afterClose:()=>{var d;(d=a==null?void 0:a.afterClose)==null||d.call(a),n.unmount()}}),c=(0,import_react.observer)(()=>(0,import_jsx_runtime.jsx)(import_react2.Fragment,{children:(0,import_shared.isFn)(o)?o(i.form):o}),{displayName:"DialogContent"}),u=(d=!0,p,g)=>{const{form:h}=i;return h?(0,import_jsx_runtime.jsx)(GlobalThemeProvider,{theme:r,children:(0,import_jsx_runtime.jsx)(import_react.Observer,{children:()=>{const{token:f}=useToken();return(0,import_jsx_runtime.jsx)(import_antd.Modal,P(x({zIndex:f.zIndexPopupBase+1e3},l),{open:d,confirmLoading:h.submitting,onCancel:_=>{var v;((v=l==null?void 0:l.onCancel)==null?void 0:v.call(l,_))!==!1&&(g==null||g())},onOk:_=>q(this,null,function*(){var v;((v=l==null?void 0:l.onOk)==null?void 0:v.call(l,_))!==!1&&(p==null||p())}),children:(0,import_jsx_runtime.jsx)(import_react.FormProvider,{form:h,children:(0,import_jsx_runtime.jsx)(c,{})})}))}})}):null};document.body.appendChild(i.host);const m={forOpen:d=>((0,import_shared.isFn)(d)&&i.openMiddlewares.push(d),m),forConfirm:d=>((0,import_shared.isFn)(d)&&i.confirmMiddlewares.push(d),m),forCancel:d=>((0,import_shared.isFn)(d)&&i.cancelMiddlewares.push(d),m),open:d=>q(this,null,function*(){return i.promise||(i.promise=new Promise((p,g)=>q(this,null,function*(){try{d=yield loading$1(l.loadingText,()=>(0,import_shared.applyMiddleware)(d,i.openMiddlewares)),i.form=i.form||(0,import_core2.createForm)(d)}catch(h){g(h)}n.render(()=>u(!0,()=>{var h;(h=i.form)==null||h.submit(()=>q(this,null,function*(){yield(0,import_shared.applyMiddleware)(i.form,i.confirmMiddlewares),(0,import_reactive.untracked)(()=>{var f;p(x({},(f=i.form)==null?void 0:f.values))}),m.close()})).catch(()=>{})},()=>q(this,null,function*(){yield loading$1(l.loadingText,()=>(0,import_shared.applyMiddleware)(i.form,i.cancelMiddlewares)),m.close()})))}))),i.promise}),close:()=>{i.host&&n.render(()=>u(!1))}};return m}const DialogFooter=e=>{const t=(0,import_react2.useRef)(null),[o,r]=(0,import_react2.useState)(),i=(0,import_react2.useRef)(),n=usePrefixCls("modal");return(0,import_react2.useLayoutEffect)(()=>{var a;const l=(a=t.current)==null?void 0:a.closest(`.${n}-content`);l&&(i.current||(i.current=l.querySelector(`.${n}-footer`),i.current||(i.current=document.createElement("div"),i.current.classList.add(`${n}-footer`),l.appendChild(i.current))),r(i.current))},[n]),i.current=o,(0,import_jsx_runtime.jsx)("div",{ref:t,style:{display:"none"},children:o&&(0,import_react_dom.createPortal)(e.children,o)})};FormDialog.Footer=DialogFooter;FormDialog.Portal=createPortalProvider("form-dialog");const useAPITokenVariable=({noDisabled:e}={})=>{var t;const o=useAPIClient();return{apiTokenSettings:useBaseVariable({name:"$nToken",title:"API token",noDisabled:e,noChildren:!0}),apiTokenCtx:(t=o.auth)==null?void 0:t.token}},popupSchema={type:"void","x-component":"Action.Container","x-action":"view",title:'{{ t("View record") }}',"x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}},useInsertSchema=()=>{const e=(0,import_react.useFieldSchema)(),{insertAfterBegin:t}=useDesignable();return(0,import_react2.useCallback)(o=>{e.reduceProperties((r,i)=>i["x-component"]==="Action.Container"?i:r,null)||t((0,import_lodash.cloneDeep)(o))},[e,t])},filterProperties=e=>e["x-component"]==="Action.Container";function withPopupWrapper(e){return t=>{const[o,r]=(0,import_react2.useState)(!1),[i,n]=(0,import_react2.useState)(!1),a=useInsertSchema(),l=useCollection(),c=useActionContext(),u=(0,import_react.useField)(),m=(0,import_react.useFieldSchema)(),{enableLink:d,openMode:p,openSize:g}=(m==null?void 0:m["x-component-props"])||{},{visibleWithURL:h,setVisibleWithURL:f}=usePopupUtils(),{openPopup:_}=usePopupUtils(),v=(0,import_react2.useRef)(!1),S=(0,import_react2.useRef)(m);S.current=m;const C=(0,import_react2.useCallback)(()=>S.current,[]),b=(0,import_react2.useCallback)(()=>{m.properties||(a(popupSchema),v.current=!0),v.current?(setTimeout(()=>{_({customActionSchema:C()})}),v.current=!1):m.properties&&_()},[m,a,_,C]),{setSubmitted:y}=c,F=(0,import_react2.useCallback)(j=>{r==null||r(j),f==null||f(j)},[f]);return d?(0,import_jsx_runtime.jsx)(PopupVisibleProvider,{visible:!1,children:(0,import_jsx_runtime.jsxs)(ActionContextProvider,{button:(0,import_jsx_runtime.jsx)(e,x({},t)),visible:o||h,setVisible:F,formValueChanged:i,setFormValueChanged:n,openMode:p,openSize:g,containerRefKey:"field-popup",fieldSchema:m,setSubmitted:y,children:[(0,import_jsx_runtime.jsx)(CollectionProvider,{name:l.name,children:(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{children:(0,import_jsx_runtime.jsx)(VariablePopupRecordProvider,{children:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{onlyRenderProperties:!0,basePath:u==null?void 0:u.address,schema:m,filterProperties})})})}),(0,import_jsx_runtime.jsx)("a",{onClick:b,children:(0,import_jsx_runtime.jsx)(e,x({},t))})]})}):(0,import_jsx_runtime.jsx)(e,x({},t))}}const ReadPretty$d=()=>null;ReadPretty$d.DatePicker=function e(t){const{value:o,picker:r="date"}=t,i=(0,import_builtins.usePrefixCls)("description-date-picker",t);if(!o)return(0,import_jsx_runtime.jsx)("div",{});const n=()=>{const a=(0,import_client.getDefaultFormat)(t),l=(0,import_client.str2moment)(o,t),c=import_dayjs.default.isDayjs(l)?l.format(a):"";return(0,import_shared.isArr)(c)?c.join("~"):c};return(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(i,t.className),children:n()})};ReadPretty$d.DateRangePicker=function e(t){const o=(0,import_builtins.usePrefixCls)("description-text",t),r=(0,import_client.getDefaultFormat)(t),i=()=>{const n=(0,import_client.str2moment)(t.value,t);if(!n)return"";const a=n.map(l=>l.format(r));return(0,import_shared.isArr)(a)?a.join("~"):a};return(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(o,t.className),style:t.style,children:i()})};ReadPretty$d.DatePicker=withPopupWrapper(ReadPretty$d.DatePicker);const DatePickerContext=import_react2.default.createContext({utc:!0}),useDatePickerContext=()=>import_react2.default.useContext(DatePickerContext),DatePickerProvider=DatePickerContext.Provider,InternalDatePicker=(0,import_react.connect)(import_antd.DatePicker,(0,import_react.mapProps)(mapDatePicker()),(0,import_react.mapReadPretty)(ReadPretty$d.DatePicker)),InternalRangePicker=(0,import_react.connect)(import_antd.DatePicker.RangePicker,(0,import_react.mapProps)(mapRangePicker()),(0,import_react.mapReadPretty)(ReadPretty$d.DateRangePicker)),DatePicker=e=>{const{utc:t=!0}=useDatePickerContext(),o=Array.isArray(e.value)?e.value[0]:e.value,{parseVariable:r}=useVariables$1()||{},i=useLocalVariables$1(),[n,a]=(0,import_react2.useState)(null),[l,c]=(0,import_react2.useState)(null),u=(0,import_react2.useRef)(null);(0,import_react2.useEffect)(()=>(u.current&&u.current(),u.current=(0,import_reactive.autorun)(()=>{m()}),()=>{u.current()}),[e._maxDate,e._minDate,i,r]);const m=()=>q(void 0,null,function*(){let p=e._minDate?Promise.resolve((0,import_dayjs.default)(e._minDate)):Promise.resolve(null),g=e._maxDate?Promise.resolve((0,import_dayjs.default)(e._maxDate)):Promise.resolve(null);isVariable(e._maxDate)&&(g=r(e._maxDate,i).then(C=>(0,import_dayjs.default)(C.value))),isVariable(e._minDate)&&(p=r(e._minDate,i).then(C=>(0,import_dayjs.default)(C.value)));const[h,f]=yield Promise.all([p,g]),_=Array.from({length:60},(C,b)=>b),v=C=>{if(!C||!h&&!f)return!1;const b=(0,import_dayjs.default)(C);return b.isBefore(h,"minute")||b.isAfter(f,"minute")},S=C=>{if(!C||!h&&!f)return{disabledHours:()=>[],disabledMinutes:()=>[],disabledSeconds:()=>[]};const b=(0,import_dayjs.default)(C),y=b.isSame(h,"day"),F=b.isSame(f,"day");return{disabledHours:()=>{const j=[];return y&&j.push(...Array.from({length:h.hour()},(k,T)=>T)),F&&j.push(...Array.from({length:24-f.hour()},(k,T)=>T+f.hour()+1)),j},disabledMinutes:j=>y&&j===h.hour()?_.filter(k=>k<h.minute()):F&&j===f.hour()?_.filter(k=>k>f.minute()):[],disabledSeconds:(j,k)=>y&&j===h.hour()&&k===h.minute()?_.filter(T=>T<h.second()):F&&j===f.hour()&&k===f.minute()?_.filter(T=>T>f.second()):[]}};a(()=>v),c(()=>S)}),d=P(x({utc:t},e),{disabledDate:n,disabledTime:l,showTime:e.showTime?{defaultValue:(0,import_dayjs.default)("00:00:00","HH:mm:ss")}:!1});return(0,import_jsx_runtime.jsx)(InternalDatePicker,P(x({},d),{value:o}))};DatePicker.ReadPretty=ReadPretty$d.DatePicker;DatePicker.RangePicker=function e(t){const{value:o,picker:r="date",format:i,showTime:n,timeFormat:a}=t,{t:l}=(0,import_react_i18next.useTranslation)(),c=(0,import_react.useFieldSchema)(),u=(0,import_react.useField)(),{utc:m=!0}=useDatePickerContext(),d=getDateRanges(),p=useCompile(),g=!c["x-filter-operator"],h=[{label:l("Today"),value:d.today},{label:l("Last week"),value:d.lastWeek},{label:l("This week"),value:d.thisWeek},{label:l("Next week"),value:d.nextWeek},{label:l("Last month"),value:d.lastMonth},{label:l("This month"),value:d.thisMonth},{label:l("Next month"),value:d.nextMonth},{label:l("Last quarter"),value:d.lastQuarter},{label:l("This quarter"),value:d.thisQuarter},{label:l("Next quarter"),value:d.nextQuarter},{label:l("Last year"),value:d.lastYear},{label:l("This year"),value:d.thisYear},{label:l("Next year"),value:d.nextYear},{label:l("Last 7 days"),value:d.last7Days},{label:l("Next 7 days"),value:d.next7Days},{label:l("Last 30 days"),value:d.last30Days},{label:l("Next 30 days"),value:d.next30Days},{label:l("Last 90 days"),value:d.last90Days},{label:l("Next 90 days"),value:d.next90Days}],f=o?inferPickerType(o==null?void 0:o[0]):r,_=(0,import_client.getPickerFormat)(f)||i,v=P(x({utc:m,presets:h},t),{format:(0,import_client.getDateTimeFormat)(f,_,n,a),picker:f,showTime:n?{defaultValue:[(0,import_dayjs.default)("00:00:00","HH:mm:ss"),(0,import_dayjs.default)("23:59:59","HH:mm:ss")]}:!1}),[S,C]=(0,import_react2.useState)(v);return g?(0,import_jsx_runtime.jsxs)(import_antd.Space.Compact,{children:[(0,import_jsx_runtime.jsx)(import_antd.Select,{role:"button","data-testid":"select-picker",style:{width:"100px"},popupMatchSelectWidth:!1,defaultValue:f,options:p([{label:'{{t("Date")}}',value:"date"},{label:'{{t("Month")}}',value:"month"},{label:'{{t("Quarter")}}',value:"quarter"},{label:'{{t("Year")}}',value:"year"}]),onChange:b=>{const y=(0,import_client.getPickerFormat)(b),F=(0,import_client.getDateTimeFormat)(b,y,n,a);u.setComponentProps({picker:b,format:y}),v.picker=b,v.format=F,C(v),c["x-component-props"]=P(x({},t),{picker:b,format:F}),u.value=void 0}}),(0,import_jsx_runtime.jsx)(InternalRangePicker,P(x({},S),{value:o}))]}):(0,import_jsx_runtime.jsx)(InternalRangePicker,x({},v))};DatePicker.FilterWithPicker=function e(t){const{picker:o="date",format:r,showTime:i,timeFormat:n}=t,a=isMobile(),{utc:l=!0}=useDatePickerContext(),c=Array.isArray(t.value)?t.value[0]:t.value,u=useCompile(),m=(0,import_react.useFieldSchema)(),d=c?inferPickerType(c):o,p=(0,import_client.getPickerFormat)(d)||r,g=P(x({utc:l,inputReadOnly:a},t),{underFilter:!0,showTime:i?{defaultValue:(0,import_dayjs.default)("00:00:00","HH:mm:ss")}:!1,format:(0,import_client.getDateTimeFormat)(d,p,i,n),picker:d,onChange:v=>{t.onChange(void 0),setTimeout(()=>{t.onChange(v)})}}),h=(0,import_react.useField)(),[f,_]=(0,import_react2.useState)(g);return(0,import_jsx_runtime.jsxs)(import_antd.Space.Compact,{children:[(0,import_jsx_runtime.jsx)(import_antd.Select,{role:"button","data-testid":"select-picker",style:{width:"100px"},popupMatchSelectWidth:!1,defaultValue:d,options:u([{label:'{{t("Date")}}',value:"date"},{label:'{{t("Month")}}',value:"month"},{label:'{{t("Quarter")}}',value:"quarter"},{label:'{{t("Year")}}',value:"year"}]),onChange:v=>{const S=(0,import_client.getPickerFormat)(v),C=(0,import_client.getDateTimeFormat)(v,S,i,n);h.setComponentProps({picker:v,format:S}),g.picker=v,g.format=C,_(g),m["x-component-props"]=P(x({},t),{picker:v,format:C}),h.value=null}}),(0,import_jsx_runtime.jsx)(InternalDatePicker,P(x({},f),{value:c}))]})};const useDateVariable=({operator:e,schema:t,noDisabled:o})=>{const{t:r}=(0,import_react_i18next.useTranslation)(),i=(e==null?void 0:e.value)||"",n=o?!1:!["DatePicker","DatePicker.RangePicker"].includes(t==null?void 0:t["x-component"]),a=[{key:"now",value:"now",label:r("Current time"),disabled:o?!1:(t==null?void 0:t["x-component"])!=="DatePicker"||i==="$dateBetween"},{key:"yesterday",value:"yesterday",label:r("Yesterday"),disabled:n},{key:"today",value:"today",label:r("Today"),disabled:n},{key:"tomorrow",value:"tomorrow",label:r("Tomorrow"),disabled:n},{key:"lastIsoWeek",value:"lastIsoWeek",label:r("Last week"),disabled:n},{key:"thisIsoWeek",value:"thisIsoWeek",label:r("This week"),disabled:n},{key:"nextIsoWeek",value:"nextIsoWeek",label:r("Next week"),disabled:n},{key:"lastMonth",value:"lastMonth",label:r("Last month"),disabled:n},{key:"thisMonth",value:"thisMonth",label:r("This month"),disabled:n},{key:"nextMonth",value:"nextMonth",label:r("Next month"),disabled:n},{key:"lastQuarter",value:"lastQuarter",label:r("Last quarter"),disabled:n},{key:"thisQuarter",value:"thisQuarter",label:r("This quarter"),disabled:n},{key:"nextQuarter",value:"nextQuarter",label:r("Next quarter"),disabled:n},{key:"lastYear",value:"lastYear",label:r("Last year"),disabled:n},{key:"thisYear",value:"thisYear",label:r("This year"),disabled:n},{key:"nextYear",value:"nextYear",label:r("Next year"),disabled:n},{key:"last7Days",value:"last7Days",label:r("Last 7 days"),disabled:n},{key:"next7Days",value:"next7Days",label:r("Next 7 days"),disabled:n},{key:"last30Days",value:"last30Days",label:r("Last 30 days"),disabled:n},{key:"next30Days",value:"next30Days",label:r("Next 30 days"),disabled:n},{key:"last90Days",value:"last90Days",label:r("Last 90 days"),disabled:n},{key:"next90Days",value:"next90Days",label:r("Next 90 days"),disabled:n}],l=(0,import_react2.useMemo)(()=>({label:r("Date variables"),value:"$nDate",key:"$nDate",disabled:a.every(c=>c.disabled),children:a}),[t==null?void 0:t["x-component"]]);return t?l:null},useDatetimeVariableContext=()=>{const{utc:e=!0}=useDatePickerContext();return{datetimeCtx:(0,import_react2.useMemo)(()=>getDateRanges({shouldBeString:!0,utc:e}),[e])}},useDatetimeVariable=({operator:e,schema:t,noDisabled:o,targetFieldSchema:r}={})=>{const{t:i}=(0,import_react_i18next.useTranslation)(),{getOperator:n}=useOperators(),a=(0,import_react2.useMemo)(()=>{const c=(e==null?void 0:e.value)||n(r==null?void 0:r.name)||"",u=o?!1:!["DatePicker.RangePicker"].includes(t==null?void 0:t["x-component"])&&!c,m=[{key:"now",value:"now",label:i("Current time"),disabled:o?!1:(t==null?void 0:t["x-component"])!=="DatePicker"||c==="$dateBetween"},{key:"yesterday",value:"yesterday",label:i("Yesterday"),disabled:u},{key:"today",value:"today",label:i("Today"),disabled:u},{key:"tomorrow",value:"tomorrow",label:i("Tomorrow"),disabled:u},{key:"lastIsoWeek",value:"lastIsoWeek",label:i("Last week"),disabled:u},{key:"thisIsoWeek",value:"thisIsoWeek",label:i("This week"),disabled:u},{key:"nextIsoWeek",value:"nextIsoWeek",label:i("Next week"),disabled:u},{key:"lastMonth",value:"lastMonth",label:i("Last month"),disabled:u},{key:"thisMonth",value:"thisMonth",label:i("This month"),disabled:u},{key:"nextMonth",value:"nextMonth",label:i("Next month"),disabled:u},{key:"lastQuarter",value:"lastQuarter",label:i("Last quarter"),disabled:u},{key:"thisQuarter",value:"thisQuarter",label:i("This quarter"),disabled:u},{key:"nextQuarter",value:"nextQuarter",label:i("Next quarter"),disabled:u},{key:"lastYear",value:"lastYear",label:i("Last year"),disabled:u},{key:"thisYear",value:"thisYear",label:i("This year"),disabled:u},{key:"nextYear",value:"nextYear",label:i("Next year"),disabled:u},{key:"last7Days",value:"last7Days",label:i("Last 7 days"),disabled:u},{key:"next7Days",value:"next7Days",label:i("Next 7 days"),disabled:u},{key:"last30Days",value:"last30Days",label:i("Last 30 days"),disabled:u},{key:"next30Days",value:"next30Days",label:i("Next 30 days"),disabled:u},{key:"last90Days",value:"last90Days",label:i("Last 90 days"),disabled:u},{key:"next90Days",value:"next90Days",label:i("Next 90 days"),disabled:u}];return{label:i("Date variables"),value:"$nDate",key:"$nDate",disabled:m.every(d=>d.disabled),children:m}},[t==null?void 0:t["x-component"],r]),{datetimeCtx:l}=useDatetimeVariableContext();return{datetimeSettings:a,datetimeCtx:l}},useRoleVariable=({collectionField:e,uiSchema:t,noDisabled:o,targetFieldSchema:r,maxDepth:i=0})=>{const{t:n}=(0,import_react_i18next.useTranslation)();return useBaseVariable({collectionField:e,uiSchema:t,maxDepth:i,name:"$nRole",title:n("Current role"),collectionName:"roles",noDisabled:o,targetFieldSchema:r,noChildren:!0})},useCurrentRoleVariable=({collectionField:e,uiSchema:t,noDisabled:o,targetFieldSchema:r,maxDepth:i=0}={})=>{var n;const{t:a}=(0,import_react_i18next.useTranslation)(),l=useAPIClient();return{currentRoleSettings:useBaseVariable({collectionField:e,uiSchema:t,maxDepth:i,name:"$nRole",title:a("Current role"),collectionName:"roles",noDisabled:o,targetFieldSchema:r,noChildren:!0}),currentRoleCtx:(n=l.auth)==null?void 0:n.role}},getURLSearchParams=e=>(e.startsWith("?")&&(e=e.slice(1)),import_qs.default.parse(e)||{}),getURLSearchParamsChildren=e=>Object.keys(e).map(t=>({label:t,value:t,key:t,isLeaf:!0})),useURLSearchParamsCtx=e=>{const[t]=(0,import_react2.useState)(()=>(0,import_reactive.observable)({}));return(0,import_react2.useMemo)(()=>{const o=getURLSearchParams(e);return(0,import_reactive.untracked)(()=>{Object.assign(t,o),Object.keys(t).forEach(r=>{o[r]===void 0&&delete t[r]})}),t},[t,e])},useURLSearchParamsVariable=(e={})=>{const t="$nURLSearchParams",{t:o}=(0,import_react_i18next.useTranslation)(),r=useLocationSearch(),{isVariableParsedInOtherContext:i}=useFlag(),n=useURLSearchParamsCtx(r),a=(0,import_react2.useMemo)(()=>import_lodash.default.isEmpty(n),[n]),l=(0,import_react2.useMemo)(()=>({label:getLabelWithTooltip(o("URL search params"),a?o("The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string."):""),value:t,key:t,isLeaf:!1,disabled:a,loadChildren:(c,u)=>q(void 0,null,function*(){const m=u?{[u]:void 0}:{};c.children=getURLSearchParamsChildren(x(x({},m),n))})}),[a,o,n]);return{name:t,urlSearchParamsSettings:l,urlSearchParamsCtx:n,defaultValue:void 0,shouldDisplay:!i}},useUserVariable=({collectionField:e,uiSchema:t,noDisabled:o,targetFieldSchema:r,maxDepth:i=3})=>{const{t:n}=(0,import_react_i18next.useTranslation)();return useBaseVariable({collectionField:e,uiSchema:t,maxDepth:i,name:"$user",title:n("Current user"),collectionName:"users",dataSource:DEFAULT_DATA_SOURCE_KEY,noDisabled:o,targetFieldSchema:r})},useCurrentUserVariable=({collectionField:e,uiSchema:t,noDisabled:o,targetFieldSchema:r,maxDepth:i=3}={})=>{var n;const{t:a}=(0,import_react_i18next.useTranslation)(),l=useCurrentUserContext();return{currentUserSettings:useBaseVariable({collectionField:e,uiSchema:t,maxDepth:i,name:"$user",title:a("Current user"),collectionName:"users",noDisabled:o,targetFieldSchema:r,dataSource:DEFAULT_DATA_SOURCE_KEY}),currentUserCtx:(n=l==null?void 0:l.data)==null?void 0:n.data}},useCurrentFormContext=({form:e}={})=>{const{form:t}=useFormBlockContext(),{isVariableParsedInOtherContext:o}=useFlag(),r=e||t;return{currentFormCtx:r==null?void 0:r.values,shouldDisplayCurrentForm:r&&!r.readPretty&&!o}},useCurrentFormVariable=({collectionField:e,schema:t,noDisabled:o,targetFieldSchema:r,form:i}={})=>{const{currentFormCtx:n,shouldDisplayCurrentForm:a}=useCurrentFormContext({form:i}),{t:l}=(0,import_react_i18next.useTranslation)(),{collectionName:c}=useFormBlockContext(),u=useDataSource();return{currentFormSettings:useBaseVariable({collectionField:e,uiSchema:t,targetFieldSchema:r,maxDepth:4,name:"$nForm",title:l("Current form"),collectionName:c,noDisabled:o,dataSource:u==null?void 0:u.key,returnFields:(m,d)=>m}),currentFormCtx:n,shouldDisplayCurrentForm:a}},useCurrentObjectContext=()=>{const{isInSubForm:e,isInSubTable:t}=useFlag()||{},{formValue:o,collection:r}=useSubFormValue();return{shouldDisplayCurrentObject:e||t,currentObjectCtx:o,collectionOfCurrentObject:r}},useCurrentObjectVariable=({collectionField:e,schema:t,noDisabled:o,targetFieldSchema:r}={})=>{const i=useCollection(),{t:n}=(0,import_react_i18next.useTranslation)(),{shouldDisplayCurrentObject:a,currentObjectCtx:l,collectionOfCurrentObject:c}=useCurrentObjectContext(),u=useBaseVariable({collectionField:e,uiSchema:t,targetFieldSchema:r,maxDepth:4,name:"$iteration",title:n("Current object"),collectionName:(c==null?void 0:c.name)||(i==null?void 0:i.name),noDisabled:o,dataSource:i==null?void 0:i.dataSource,returnFields:(m,d)=>m});return{shouldDisplayCurrentObject:a,currentObjectCtx:l,currentObjectSettings:u}},useParentObjectContext=()=>{const{parent:e}=useSubFormValue(),{value:t,collection:o}=e||{},{isInSubForm:r,isInSubTable:i}=useFlag()||{};return{shouldDisplayParentObject:(r||i)&&!!o,parentObjectCtx:t,collectionName:o==null?void 0:o.name,dataSource:o==null?void 0:o.dataSource}},useParentObjectVariable=({collectionField:e,schema:t,noDisabled:o,targetFieldSchema:r}={})=>{const{t:i}=(0,import_react_i18next.useTranslation)(),{shouldDisplayParentObject:n,parentObjectCtx:a,collectionName:l,dataSource:c}=useParentObjectContext();return{parentObjectSettings:useBaseVariable({collectionField:e,uiSchema:t,targetFieldSchema:r,maxDepth:4,name:"$nParentIteration",title:i("Parent object"),collectionName:l,noDisabled:o,dataSource:c,returnFields:(u,m)=>u}),shouldDisplayParentObject:n,parentObjectCtx:a,collectionName:l}},useParentPopupVariableContext=()=>{const{value:e,title:t,collection:o}=useParentPopupRecord()||{},{isVariableParsedInOtherContext:r}=useFlag();return{parentPopupRecordCtx:e,shouldDisplayParentPopupRecord:!!e&&!r,collectionName:o==null?void 0:o.name,dataSource:o==null?void 0:o.dataSource,defaultValue:void 0,title:t}},useParentPopupVariable=(e={})=>{const{parentPopupRecordCtx:t,shouldDisplayParentPopupRecord:o,collectionName:r,dataSource:i,defaultValue:n,title:a}=useParentPopupVariableContext();return{settings:useBaseVariable({collectionField:e.collectionField,uiSchema:e.schema,name:"$nParentPopupRecord",title:a,collectionName:r,noDisabled:e.noDisabled,targetFieldSchema:e.targetFieldSchema,dataSource:i}),parentPopupRecordCtx:t,shouldDisplayParentPopupRecord:o,collectionName:r,dataSource:i,defaultValue:n}},ParentCollectionContext=(0,import_react2.createContext)(null);ParentCollectionContext.displayName="ParentCollectionContext";const ParentCollectionProvider=e=>{const t=useCollection();return(0,import_jsx_runtime.jsx)(ParentCollectionContext.Provider,{value:t,children:e.children})},useParentCollection=()=>(0,import_react2.useContext)(ParentCollectionContext),AssociationProvider=e=>{const{name:t,children:o}=e,r=useCollectionManager().getCollectionName(t);return r?(0,import_jsx_runtime.jsx)(CollectionProvider,{name:String(t).split(".")[0],children:(0,import_jsx_runtime.jsx)(ParentCollectionProvider,{children:(0,import_jsx_runtime.jsx)(CollectionFieldProvider,{name:t,children:(0,import_jsx_runtime.jsx)(CollectionProvider,{name:r,children:o})})})}):(0,import_jsx_runtime.jsx)(CollectionDeletedPlaceholder,{type:"Collection",name:t})},useAssociationName=()=>{const e=useCollectionField();return e&&["belongsToMany","belongsTo","hasMany","hasOne"].includes(e.type)?`${e.collectionName}.${e.name}`:null},useCurrentParentRecordContext=()=>{var e,t;const o=useCollectionRecord(),{name:r,dataSource:i}=useParentCollection()||{},n=useCollection(),{isInSubForm:a,isInSubTable:l}=useFlag()||{},c=r?i:n==null?void 0:n.dataSource,u=useCollectionField();return{currentParentRecordCtx:((e=o==null?void 0:o.parentRecord)==null?void 0:e.data)||(o==null?void 0:o.data),shouldDisplayCurrentParentRecord:!!((t=o==null?void 0:o.parentRecord)!=null&&t.data)&&!a&&!l&&u,collectionName:r||(n==null?void 0:n.name),dataSource:c}},useCurrentParentRecordVariable=(e={})=>{const{t}=(0,import_react_i18next.useTranslation)(),{currentParentRecordCtx:o,shouldDisplayCurrentParentRecord:r,collectionName:i,dataSource:n}=useCurrentParentRecordContext();return{currentParentRecordSettings:useBaseVariable({collectionField:e.collectionField,uiSchema:e.schema,name:"$nParentRecord",title:t("Parent record"),collectionName:i,noDisabled:e.noDisabled,targetFieldSchema:e.targetFieldSchema,dataSource:n}),currentParentRecordCtx:o,shouldDisplayCurrentParentRecord:r,collectionName:i,dataSource:n}},usePopupVariableContext=()=>{const{value:e,title:t,collection:o}=useCurrentPopupRecord()||{},{isVariableParsedInOtherContext:r}=useFlag();return{popupRecordCtx:e,shouldDisplayPopupRecord:!!e&&!r,collectionName:o==null?void 0:o.name,dataSource:o==null?void 0:o.dataSource,defaultValue:void 0,title:t}},usePopupVariable=(e={})=>{const{popupRecordCtx:t,shouldDisplayPopupRecord:o,collectionName:r,dataSource:i,defaultValue:n,title:a}=usePopupVariableContext();return{settings:useBaseVariable({collectionField:e.collectionField,uiSchema:e.schema,name:"$nPopupRecord",title:a,collectionName:r,noDisabled:e.noDisabled,targetFieldSchema:e.targetFieldSchema,dataSource:i}),popupRecordCtx:t,shouldDisplayPopupRecord:o,collectionName:r,dataSource:i,defaultValue:n}},useVariableOptions=({collectionField:e,form:t,uiSchema:o,operator:r,noDisabled:i,targetFieldSchema:n,record:a})=>{var l;const{filterVariables:c=()=>!0}=useVariables$1()||{},u=(l=a==null?void 0:a.__parent)==null?void 0:l.__collectionName,{currentUserSettings:m}=useCurrentUserVariable({maxDepth:3,uiSchema:o,collectionField:e,noDisabled:i,targetFieldSchema:n}),{currentRoleSettings:d}=useCurrentRoleVariable({uiSchema:o,collectionField:e,noDisabled:i,targetFieldSchema:n}),{apiTokenSettings:p}=useAPITokenVariable({noDisabled:i}),{datetimeSettings:g}=useDatetimeVariable({operator:r,schema:o,noDisabled:!0,targetFieldSchema:n}),{currentFormSettings:h,shouldDisplayCurrentForm:f}=useCurrentFormVariable({schema:o,collectionField:e,noDisabled:i,targetFieldSchema:n,form:t}),{currentObjectSettings:_,shouldDisplayCurrentObject:v}=useCurrentObjectVariable({collectionField:e,schema:o,noDisabled:i,targetFieldSchema:n}),{parentObjectSettings:S,shouldDisplayParentObject:C}=useParentObjectVariable({collectionField:e,schema:o,noDisabled:i,targetFieldSchema:n}),{currentRecordSettings:b,shouldDisplayCurrentRecord:y}=useCurrentRecordVariable({schema:o,collectionField:e,noDisabled:i,targetFieldSchema:n}),{settings:F,shouldDisplayPopupRecord:j}=usePopupVariable({schema:o,collectionField:e,noDisabled:i,targetFieldSchema:n}),{settings:k,shouldDisplayParentPopupRecord:T}=useParentPopupVariable({schema:o,collectionField:e,noDisabled:i,targetFieldSchema:n}),{currentParentRecordSettings:O,shouldDisplayCurrentParentRecord:N}=useCurrentParentRecordVariable({schema:o,collectionName:u,collectionField:e,noDisabled:i,targetFieldSchema:n}),{urlSearchParamsSettings:L,shouldDisplay:D}=useURLSearchParamsVariable();return(0,import_react2.useMemo)(()=>[m,d,p,g,f&&h,v&&_,C&&S,y&&b,N&&O,j&&F,T&&k,D&&L].filter(Boolean).filter(c),[m,d,p,g,f,h,v,_,C,S,y,b,N,O,j,F,D,L])},RemoveConditionContext=(0,import_react2.createContext)(null);RemoveConditionContext.displayName="RemoveConditionContext";const FilterContext$1=(0,import_react2.createContext)(null);FilterContext$1.displayName="FilterContext";const FilterLogicContext=(0,import_react2.createContext)(null);FilterLogicContext.displayName="FilterLogicContext";const findOption$1=(e=[],t)=>{var o;let r=t,i;return(o=e==null?void 0:e.forEach)==null||o.call(e,n=>{const a=r.find(l=>l.name===n);a&&(i=a),r=(a==null?void 0:a.children)||[]}),i},useValues$1=()=>{const{name:e}=useCollection_deprecated(),{getCollectionJoinField:t}=useCollectionManager_deprecated(),o=(0,import_react.useField)(),{options:r,collectionName:i,field:n}=(0,import_react2.useContext)(FilterContext$1)||{},a=(0,import_flat.default)(o.value||{}),l=Object.keys(a).shift()||"",c=(0,import_react2.useMemo)(()=>{const[g=""]=l.split(".$");return t(`${i||e}.${g}`)},[e,l]),u=(0,import_react2.useCallback)(()=>{var g,h,f,_;o.value=import_flat.default.unflatten({[`${(g=o.data.dataIndex)==null?void 0:g.join(".")}.${(f=(h=o.data)==null?void 0:h.operator)==null?void 0:f.value}`]:(_=o.data)==null?void 0:_.value})},[o]);(0,import_react2.useEffect)(()=>{var g;if(o.data=o.data||{},!l||!r)return;const[h="",f=""]=l.split(".$"),[_]=f.split(".",2),v=h.split("."),S=findOption$1(v,r),C=S==null?void 0:S.operators,b=(g=C==null?void 0:C.find)==null?void 0:g.call(C,y=>y.value===`$${_}`);if(o.data.dataIndex=v,(v==null?void 0:v.length)>1){const y=v.concat();y.pop();const F=t(`${e}.${y.join(".")}`);n.collectionName=F==null?void 0:F.target}else n.collectionName=null;o.data.operators=C,o.data.operator=b,o.data.schema=(0,import_shared.merge)(S==null?void 0:S.schema,b==null?void 0:b.schema),o.data.value=(0,import_get.default)((0,import_flat.unflatten)(o.value),`${h}.$${_}`)},[o.path]);const m=(0,import_react2.useCallback)(g=>{var h;const f=findOption$1(g,r),_=(h=f==null?void 0:f.operators)==null?void 0:h[0];o.data=o.data||{},o.data.operators=f==null?void 0:f.operators,o.data.operator=_;const v=(0,import_cloneDeep.default)(f==null?void 0:f.schema),S=(0,import_cloneDeep.default)(_==null?void 0:_.schema);if(o.data.schema=(0,import_shared.merge)(v,S),o.data.dataIndex=g,(g==null?void 0:g.length)>1){const C=g.concat();C.pop();const b=t(`${e}.${C.join(".")}`);n.collectionName=b==null?void 0:b.target}else n.collectionName=null;o.data.value=_!=null&&_.noValue?_.default||!0:void 0,u()},[u,o,r]),d=(0,import_react2.useCallback)(g=>{var h,f,_;const v=(_=(f=(h=o.data)==null?void 0:h.operators)==null?void 0:f.find)==null?void 0:_.call(f,y=>y.value===g);o.data.operator=v;const S=findOption$1(o.data.dataIndex,r),C=(0,import_cloneDeep.default)(S==null?void 0:S.schema),b=(0,import_cloneDeep.default)(v==null?void 0:v.schema);o.data.schema=(0,import_shared.merge)(C,b),o.data.value=v.noValue?v.default||!0:void 0,u()},[u,o.data,r]),p=(0,import_react2.useCallback)(g=>{o.data.value=g,u()},[u,o.data]);return P(x({fields:r},(o==null?void 0:o.data)||{}),{collectionField:c,setDataIndex:m,setOperator:d,setValue:p})},useBlockCollection=()=>{const e=useDataBlockProps();return{name:(e==null?void 0:e.collection)||(e==null?void 0:e.resource)}},useIsSameOrChildCollection=()=>{const{getChildrenCollections:e}=useCollectionManager_deprecated();return(t,o)=>{if(t===o)return!0;const r=e(o);return r==null?void 0:r.some(i=>i.name===t)}},getChildren=(e,{schema:t,depth:o,maxDepth:r,loadChildren:i,compile:n},a,l)=>e.map(c=>{const u=!l(c.target,a==null?void 0:a.target);return c.target?o>=r?null:{key:c.name,value:c.name,label:n(c.title),disabled:u,isLeaf:!0,field:c,depth:o,loadChildren:i}:{key:c.name,value:c.name,label:n(c.title),disabled:u,isLeaf:!0,depth:o}}).filter(Boolean),useContextAssociationFields=({schema:e,maxDepth:t=3,contextCollectionName:o,collectionField:r})=>{const{t:i}=(0,import_react_i18next.useTranslation)(),n=useCompile(),a=useGetFilterOptions(),l=useIsSameOrChildCollection(),c=u=>{var m;if(!((m=u.field)!=null&&m.target))return new Promise(p=>{(0,import_client.error)("Must be set field target"),u.children=[],p(void 0)});const d=u.field.target;return new Promise(p=>{setTimeout(()=>{const g=getChildren(a(d).filter(h=>["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(h.type)),{schema:e,depth:u.depth+1,maxDepth:t,loadChildren:c,compile:n},r,l)||[];if(g.length===0){u.disabled=!0,u.children=[],p();return}u.children=g,p()},5)})};return(0,import_react2.useMemo)(()=>({label:i("Table selected records"),value:"$context",key:"$context",isLeaf:!1,field:{target:o},depth:0,loadChildren:c}),[e==null?void 0:e["x-component"]])},VariableInput=e=>{const{value:t,onChange:o,renderSchemaComponent:r,style:i,schema:n,className:a,contextCollectionName:l,collectionField:c,shouldChange:u,form:m,record:d,returnScope:p=import_lodash.default.identity,targetFieldSchema:g,noDisabled:h,hideVariableButton:f}=e,{name:_}=useBlockCollection(),v=useVariableScope(),{operator:S,schema:C=c==null?void 0:c.uiSchema}=useValues$1(),b=useVariableOptions({collectionField:c,form:m,record:d,operator:S,uiSchema:C,targetFieldSchema:g,noDisabled:h}),y=useContextAssociationFields({schema:n,maxDepth:2,contextCollectionName:l,collectionField:c}),{compatOldVariables:F}=useCompatOldVariables({collectionField:c,uiSchema:C,targetFieldSchema:g,blockCollectionName:_});l&&b.every(k=>k.value!==y.value)&&b.push(y);const j=(0,import_react2.useCallback)((k,T)=>{if(!u)return o(k);setTimeout(()=>q(void 0,null,function*(){(yield u(k,T))&&o(k)}))},[o,u]);return(0,import_jsx_runtime.jsx)(Variable.Input,{className:a,value:t,onChange:j,scope:p(F(import_lodash.default.isEmpty(v)?b:v,{value:t})),style:i,changeOnSelect:!0,hideVariableButton:f,children:(0,import_jsx_runtime.jsx)(r,{value:t,onChange:o})})},getShouldChange=({collectionField:e,variables:t,localVariables:o,getAllCollectionsInheritChain:r})=>{const i=e?r(e.target):[];return(n,a)=>q(void 0,null,function*(){if(import_lodash.default.isString(n)&&n.includes("$nRole")||!isVariable(n)||!t||!e||e.interface==="json")return!0;const l=a[a.length-1];if(l&&import_lodash.default.isEmpty(l.children)&&!l.loadChildren)return!0;const c=yield t.getCollectionField(n,o);return!(!e||["o2o","o2m","oho"].includes(c==null?void 0:c.interface)||e.target&&c!=null&&c.target&&!i.includes(c==null?void 0:c.target))})};function useCompatOldVariables(e){const{uiSchema:t,collectionField:o,noDisabled:r,targetFieldSchema:i,blockCollectionName:n}=e,{t:a}=(0,import_react_i18next.useTranslation)(),{currentUserSettings:l}=useCurrentUserVariable({maxDepth:1,uiSchema:t,collectionField:o,noDisabled:r,targetFieldSchema:i}),{currentRecordSettings:c}=useCurrentRecordVariable({schema:t,collectionField:o,noDisabled:r,targetFieldSchema:i});return{compatOldVariables:(0,import_react2.useCallback)((u,{value:m})=>{if(!isVariable(m))return u;u=[...u];const d={value:"$system",key:"$system",label:a("System variables"),isLeaf:!1,children:[{value:"now",key:"now",label:a("Current time"),isLeaf:!0,depth:1}],depth:0},p={value:"currentTime",label:a("Current time"),children:null};if(m.includes("$system")&&u.push(d),m.includes(`${n}.`)){const g=u.find(h=>h.value==="$nForm"||h.value==="$nRecord");g&&(g.value=n)}if(m.includes("$form")){const g=u.find(h=>h.value==="$nForm");g&&(g.value="$form")}if(m.includes("currentUser")){const g=u.find(h=>h.value==="$user");g?g.value="currentUser":u.unshift(P(x({},l),{value:"currentUser"}))}if(m.includes("currentRecord")){const g=u.find(h=>h.value==="$nRecord");g?g.value="currentRecord":u.unshift(P(x({},c),{value:"currentRecord"}))}if(m.includes("currentTime")&&u.push(p),m.includes("$date")){const g=u.find(h=>h.value==="$nDate");g&&(g.value="$date")}return u},[n])}}const AsDefaultTemplate=import_react2.default.forwardRef((e,t)=>{var o;const r=import_antd_v5.ArrayBase.useArray(),i=import_antd_v5.ArrayBase.useIndex(e.index),{t:n}=(0,import_react_i18next.useTranslation)();return(0,import_jsx_runtime.jsx)(import_antd.Switch,P(x({},e),{checkedChildren:n("Default"),unCheckedChildren:n("Default"),checked:(o=r==null?void 0:r.field)==null?void 0:o.value[i].default,style:{transition:"all 0.25s ease-in-out",color:"rgba(0, 0, 0, 0.8)",fontSize:16,marginLeft:6,marginBottom:3},onChange:(a,l)=>{var c;l.stopPropagation(),r.field.value.splice(i,1,P(x({},(c=r==null?void 0:r.field)==null?void 0:c.value[i]),{default:a})),r.field.value.forEach((u,m)=>{var d;m!==i&&r.field.value.splice(m,1,P(x({},(d=r==null?void 0:r.field)==null?void 0:d.value[m]),{default:!1}))})},onClick:(a,l)=>{l.stopPropagation()}}))});AsDefaultTemplate.displayName="AsDefaultTemplate";const useStyles$d=genStyleHook("nb-array-collapse",e=>{const{componentCls:t}=e;return{[t]:{marginBottom:"10px"}}}),DataTemplateTitle=(0,import_react.observer)(e=>{var t;const o=import_antd_v5.ArrayBase.useArray(),r=import_antd_v5.ArrayBase.useIndex(e.index),{t:i}=(0,import_react_i18next.useTranslation)(),n=(t=o==null?void 0:o.field)==null?void 0:t.value[r];return(0,import_react2.useEffect)(()=>{var a,l;n.key||(n.key=(0,import_shared.uid)()),n.title||(n.title=`${i("Template name")} ${(l=(a=o==null?void 0:o.field)==null?void 0:a.value)==null?void 0:l.length}`)},[]),(0,import_jsx_runtime.jsx)(import_antd.Input.TextArea,{value:n.title,placeholder:i("Template name"),onChange:a=>{a.stopPropagation(),n.title=a.target.value},onBlur:a=>{a.stopPropagation(),n.title=a.target.value},autoSize:!0,style:{width:"70%",border:"none"},onClick:a=>{a.stopPropagation()}})}),isAdditionComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"Addition"))>-1},isIndexComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"Index"))>-1},isRemoveComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"Remove"))>-1},isMoveUpComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"MoveUp"))>-1},isMoveDownComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"MoveDown"))>-1},isCopyComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"Copy"))>-1},isOperationComponent$1=e=>isAdditionComponent$1(e)||isRemoveComponent$1(e)||isMoveDownComponent$1(e)||isMoveUpComponent$1(e)||isCopyComponent$1(e),range$1=e=>Array.from({length:e}).map((t,o)=>o),takeDefaultActiveKeys$1=(e,t)=>e<t?range$1(e):range$1(t),insertActiveKeys$1=(e,t)=>e.length<=t?e.concat(t):e.reduce((o,r)=>r<t?o.concat(r):r===t?o.concat([r,r+1]):o.concat(r+1),[]),ArrayCollapse$1=(0,import_react.observer)(e=>{const{componentCls:t,hashId:o}=useStyles$d(),r=(0,import_react.useField)(),i=Array.isArray(r.value)?r.value:[],[n,a]=(0,import_react2.useState)(takeDefaultActiveKeys$1(i.length,e.defaultOpenPanelCount)),l=(0,import_react.useFieldSchema)();if((0,import_react2.useEffect)(()=>{!r.modified&&i.length&&a(takeDefaultActiveKeys$1(i.length,e.defaultOpenPanelCount))},[i.length,r]),!l)throw new Error("can not found schema object");const c=()=>l.reduceProperties((d,p,g)=>isAdditionComponent$1(p)?(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:p,name:g}):d,null),u=()=>{if(!i.length)return(0,import_jsx_runtime.jsx)(import_antd.Card,{className:(0,import_classnames.default)(t,o,e.className),children:(0,import_jsx_runtime.jsx)(import_antd.Empty,{})})},m=()=>(0,import_jsx_runtime.jsx)(import_antd.Collapse,P(x({},e),{activeKey:n,onChange:d=>a((0,import_shared.toArr)(d).map(Number)),className:(0,import_classnames.default)(t,o,e.className),children:i.map((d,p)=>{const g=Array.isArray(l.items)?l.items[p]||l.items[0]:l.items,h=r.query(`${r.address}.${p}`).get("componentProps"),f=g["x-component-props"],_=()=>{const C=`${(h==null?void 0:h.header)||f.header||r.title}`,b=r.address.concat(p),y=r.form.queryFeedbacks({type:"error",address:`${b}.**`});return(0,import_jsx_runtime.jsxs)(import_antd_v5.ArrayBase.Item,{index:p,record:()=>{var F;return(F=r.value)==null?void 0:F[p]},children:[(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:g,name:p,filterProperties:F=>!!isIndexComponent$1(F),onlyRenderProperties:!0}),y.length?(0,import_jsx_runtime.jsx)(import_antd.Badge,{size:"small",className:"errors-badge",count:y.length,children:C}):(0,import_jsx_runtime.jsx)(DataTemplateTitle,{item:d.initialValue||d,index:p})]})},v=(0,import_jsx_runtime.jsxs)(import_antd_v5.ArrayBase.Item,{index:p,record:d,children:[(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:g,name:p,filterProperties:C=>!!isOperationComponent$1(C),onlyRenderProperties:!0}),h==null?void 0:h.extra]}),S=(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:g,name:p,filterProperties:C=>!(isIndexComponent$1(C)||isOperationComponent$1(C))});return(0,import_react2.createElement)(import_antd.Collapse.Panel,P(x(x({},f),h),{forceRender:!0,key:p,header:_(),extra:v}),(0,import_jsx_runtime.jsx)(import_antd_v5.ArrayBase.Item,{index:p,record:d,children:S},p))})}));return(0,import_jsx_runtime.jsxs)(import_antd_v5.ArrayBase,{onAdd:d=>{a(insertActiveKeys$1(n,d))},onRemove:()=>{r.initialValue=r.value},children:[u(),m(),c()]})},{displayName:"ArrayCollapse"}),CollapsePanel$1=({children:e})=>(0,import_jsx_runtime.jsx)(import_react2.Fragment,{children:e});CollapsePanel$1.displayName="CollapsePanel";ArrayCollapse$1.defaultProps={defaultOpenPanelCount:5};ArrayCollapse$1.displayName="ArrayCollapse";ArrayCollapse$1.CollapsePanel=CollapsePanel$1;import_antd_v5.ArrayBase.mixin(ArrayCollapse$1);ArrayCollapse$1.Copy=import_react2.default.forwardRef((e,t)=>{var o;const r=(0,import_react.useField)(),i=import_antd_v5.ArrayBase.useArray(),n=import_antd_v5.ArrayBase.useIndex(e.index);return!i||((o=i.field)==null?void 0:o.pattern)!=="editable"?null:(0,import_jsx_runtime.jsx)(import_icons.CopyOutlined,P(x({},e),{style:{transition:"all 0.25s ease-in-out",color:"rgba(0, 0, 0, 0.8)",fontSize:"16px",marginLeft:6},ref:t,onClick:a=>{var l,c;if(r!=null&&r.disabled||(a.stopPropagation(),(l=i.props)!=null&&l.disabled))return;const u=(0,import_lodash.clone)((c=i==null?void 0:i.field)==null?void 0:c.value[n]);i.field.push(u),e.onClick&&e.onClick(a)}}))});ArrayCollapse$1.Copy.displayName="ArrayCollapse.Copy";const SchemaSettingsDataScope=function e(t){const{t:o}=(0,import_react_i18next.useTranslation)(),{getFields:r}=useCollectionFilterOptionsV2(t.collectionName),i=useRecord(),{form:n}=useFormBlockContext(),a=useVariables$1(),l=useLocalVariables$1(),{getAllCollectionsInheritChain:c}=useCollectionManager_deprecated(),{isInSubForm:u,isInSubTable:m}=useFlag()||{},d=(0,import_react2.useCallback)(g=>(0,import_jsx_runtime.jsx)(DatePickerProvider,{value:{utc:!1},children:(0,import_jsx_runtime.jsx)(VariableInput,P(x({},g),{form:n,record:i,noDisabled:!0,shouldChange:getShouldChange({collectionField:g.collectionField,variables:a,localVariables:l,getAllCollectionsInheritChain:c})}))}),[n,c,l,i,a]),p=()=>({type:"object",title:o("Set the data scope"),properties:{filter:{enum:t.collectionFilterOption||r(),"x-decorator":g=>(0,import_jsx_runtime.jsx)(BaseVariableProvider,P(x({},g),{children:(0,import_jsx_runtime.jsx)(FlagProvider,{isInSubForm:u,isInSubTable:m,children:g.children})})),"x-decorator-props":{isDisabled},"x-component":"Filter","x-component-props":{collectionName:t.collectionName,dynamicComponent:t.dynamicComponent||d}}}});return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:o("Set the data scope"),initialValues:{filter:t.defaultFilter},schema:p,onSubmit:t.onSubmit,noRecord:t.noRecord})};function isDisabled(e){var t,o;const{option:r,collectionField:i,uiSchema:n}=e;return!n||!i?!0:i.interface==="json"||r.target?!1:["input","markdown","richText","textarea","username"].includes(i.interface)?!["string","number"].includes((t=r.schema)==null?void 0:t.type):i.interface&&r.interface?i.interface!==r.interface:(n==null?void 0:n["x-component"])!==((o=r.schema)==null?void 0:o["x-component"])}(0,import_react.observer)(()=>{const{getCollectionFields:e,getCollectionField:t,getCollection:o,isTitleField:r}=useCollectionManager_deprecated(),i=(0,import_react.useField)(),n=(0,import_react.useFieldSchema)(),{t:a}=(0,import_react_i18next.useTranslation)(),{dn:l}=useDesignable(),c=useCompile(),{formSchema:u,data:m}=n["x-designer-props"],{form:d}=useFormBlockContext(),p=i.componentProps.service.resource,g=o(p),h=e(p);if(!m)return(0,import_client.error)("data is required"),null;const f=()=>{var b,y;return((y=(b=m.config)==null?void 0:b[p])==null?void 0:y.filter)||{}},_=b=>{try{import_lodash.default.set(m,`config.${p}.filter`,removeNullCondition(b))}catch(y){(0,import_client.error)(y)}},v=()=>{var b,y;return((y=(b=m.config)==null?void 0:b[p])==null?void 0:y.titleField)||(g==null?void 0:g.titleField)||"id"},S=b=>{try{import_lodash.default.set(m,`config.${p}.titleField`,b)}catch(y){(0,import_client.error)(y)}},C=h.filter(b=>r(b)).map(b=>{var y;return{value:b==null?void 0:b.name,label:c((y=b==null?void 0:b.uiSchema)==null?void 0:y.title)||(b==null?void 0:b.name)}});return(0,import_jsx_runtime.jsxs)(GeneralSchemaDesigner,{draggable:!1,children:[(0,import_jsx_runtime.jsx)(SchemaSettingsDataScope,{collectionName:p,defaultFilter:f(),form:d,onSubmit:({filter:b})=>{_(b);try{i.query("fieldReaction.items.*.layout.dataId").forEach(y=>{y.componentProps.service.resource===p&&(y.componentProps.service.params={filter:import_lodash.default.isEmpty(b)?{}:removeNullCondition(mergeFilter([b,getSelectedIdFilter(i.value)],"$or"))})})}catch(y){(0,import_client.error)(y)}u["x-data-templates"]=m,l.emit("patch",{schema:{"x-uid":u["x-uid"],"x-data-templates":m}}),l.refresh()}}),(0,import_jsx_runtime.jsx)(SelectItem,{title:a("Title field"),options:C,value:v(),onChange:b=>{S(b);try{i.query("fieldReaction.items.*.layout.dataId").forEach(F=>{F.componentProps.service.resource===p&&(F.componentProps.fieldNames.label=b,F.componentProps.targetField=t(`${p}.${b||(g==null?void 0:g.titleField)||"id"}`))})}catch(F){console.error(F)}u["x-data-templates"]=m;const y={"x-uid":u["x-uid"],"x-data-templates":m};l.emit("patch",{schema:y}),l.refresh()}},"title-field")]})},{displayName:"Designer"});function getSelectedIdFilter(e){return e?{id:{$eq:e}}:null}function SelectItem(e){const t=e,{title:o,options:r,value:i,onChange:n}=t,a=K(t,["title","options","value","onChange"]);return(0,import_jsx_runtime.jsx)(SchemaSettingsItem,P(x({title:o},a),{children:(0,import_jsx_runtime.jsxs)("div",{style:{alignItems:"center",display:"flex",justifyContent:"space-between"},children:[o,(0,import_jsx_runtime.jsx)(import_antd.Select,x({popupMatchSelectWidth:!1,bordered:!1,value:i,onChange:n,options:r,style:{textAlign:"right",minWidth:100}},a))]})}))}const Tree=(0,import_react.connect)(import_antd.Tree,(0,import_react.mapProps)({value:"checkedKeys",dataSource:"treeData"}));Tree.displayName="Tree";const compatibleDataId=(e,t)=>e==null?void 0:e.map(o=>{var r;const i=o,{dataId:n}=i,a=K(i,["dataId"]),l=x({},a);return n&&(l.dataScope={$and:[{id:{$eq:n}}]},l.titleField=(l==null?void 0:l.titleField)||((r=t==null?void 0:t[o.collection])==null?void 0:r.titleField)||"id"),l}),FormDataTemplates=withDynamicSchemaProps((0,import_react.observer)(e=>{const{formSchema:t,designerCtx:o,defaultValues:r,collectionName:i}=useProps(e),{collectionList:n,getEnableFieldTree:a,getOnLoadData:l,getOnCheck:c,getScopeDataSource:u,useTitleFieldDataSource:m}=useCollectionState(i),{getCollection:d,getCollectionField:p}=useCollectionManager_deprecated(),{t:g}=(0,import_react_i18next.useTranslation)(),h=(0,import_react2.useMemo)(()=>(0,import_reactive.observable)(P(x({},r),{items:compatibleDataId((r==null?void 0:r.items)||[],r==null?void 0:r.config)})),[]),f=y=>{var F;const j=d(y);return p(`${y}.${((F=h==null?void 0:h.config[y])==null?void 0:F.titleField)||(j==null?void 0:j.titleField)||"id"}`)},_=y=>{var F,j;const k=d(y);return{label:getLabel(((j=(F=h.config)==null?void 0:F[y])==null?void 0:j.titleField)||(k==null?void 0:k.titleField)||"id"),value:"id"}},v=(y,F)=>{var j,k;const T=(k=(j=h.config)==null?void 0:j[y])==null?void 0:k.filter;return import_lodash.default.isEmpty(T)?{}:removeNullCondition(mergeFilter([T,getSelectedIdFilter(F)],"$or"))},S=(0,import_react2.useMemo)(()=>({ArrayCollapse:ArrayCollapse$1}),[]),C=(0,import_react2.useMemo)(()=>({getEnableFieldTree:a,getTargetField:f,getFieldNames:_,getFilter:v,getResource,getOnLoadData:l,getOnCheck:c,collectionName:i,getScopeDataSource:u,useTitleFieldDataSource:m}),[]),b=(0,import_react2.useMemo)(()=>({type:"object",properties:{items:{type:"array",default:h==null?void 0:h.items,"x-component":"ArrayCollapse","x-decorator":"FormItem","x-component-props":{accordion:!0},items:{type:"object","x-component":"ArrayCollapse.CollapsePanel","x-component-props":{extra:[(0,import_jsx_runtime.jsx)(AsDefaultTemplate,{},"0")]},properties:{layout:{type:"void","x-component":"FormLayout","x-component-props":{layout:"vertical"},properties:{collection:{type:"string",title:'{{ t("Collection") }}',required:!0,description:g("If collection inherits, choose inherited collections as templates"),default:"{{ collectionName }}","x-display":n.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:n}},dataScope:{type:"object",title:'{{ t("Filter out a single piece or a group of records as a template") }}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{dynamicComponent:VariableInput},"x-decorator-props":{style:{marginBottom:"0px"}},required:!0,"x-reactions":[{dependencies:[".collection"],fulfill:{state:{disabled:"{{ !$deps[0] }}"},schema:{enum:"{{ getScopeDataSource($deps[0]) }}"}}}]},titleField:{type:"string","x-decorator":"FormItem",title:'{{ t("Title field") }}',"x-decorator-props":{tooltip:'{{t("The title field is used to identify the template record")}}'},"x-component":"Select",required:!0,"x-reactions":"{{useTitleFieldDataSource}}"},syncFromForm:{type:"void",title:'{{ t("Sync from form fields") }}',"x-component":"Action.Link","x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:()=>useSyncFromForm(t)}},fields:{type:"array",title:'{{ t("Template fields") }}',"x-decorator-props":{tooltip:'{{t("The selected fields will automatically populate the form")}}'},required:!0,description:g("Only the selected fields will be used as the initialization data for the form"),"x-decorator":"FormItem","x-component":Tree,"x-component-props":{treeData:[],checkable:!0,checkStrictly:!0,selectable:!1,loadData:"{{ getOnLoadData($self) }}",onCheck:"{{ getOnCheck($self) }}",rootStyle:{padding:"8px 0",border:"1px solid #d9d9d9",borderRadius:"2px",maxHeight:"30vh",overflow:"auto",margin:"2px 0"}},"x-reactions":[{dependencies:[".collection"],fulfill:{state:{disabled:"{{ !$deps[0] }}",componentProps:{treeData:"{{ getEnableFieldTree($deps[0], $self) }}"}}}}]}}},remove:{type:"void","x-component":"ArrayCollapse.Remove"},moveUp:{type:"void","x-component":"ArrayCollapse.MoveUp"},moveDown:{type:"void","x-component":"ArrayCollapse.MoveDown"}}},properties:{add:{type:"void",title:'{{ t("Add template") }}',"x-component":"ArrayCollapse.Addition"}}},display:{type:"boolean","x-content":'{{ t("Enable form data template") }}',default:(h==null?void 0:h.display)!==!1,"x-decorator":"FormItem","x-component":"Checkbox"}}}),[]);return(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:P(x({},o),{designable:!0}),children:(0,import_jsx_runtime.jsx)(SchemaComponent,{components:S,scope:C,schema:b})})}),{displayName:"FormDataTemplates"});function getLabel(e){return e||"label"}function getResource(e,t){return e!==t.componentProps.service.resource&&(t.value=void 0),e}const EnableChildCollections=withDynamicSchemaProps((0,import_react.observer)(e=>{const{defaultValues:t,collectionName:o}=useProps(e),r=(0,import_react.useForm)(),i=useCompile(),{getChildrenCollections:n}=useCollectionManager_deprecated(),a=n(o),l=u=>(m,d)=>{m.loading=!0,u(m,d).then(import_reactive.action.bound(p=>{m.dataSource=p,m.loading=!1,m.initialValue&&(m.disabled=!0)}))},c=u=>q(void 0,null,function*(){var m,d;const{childrenCollections:p}=((m=r.values)==null?void 0:m.enableChildren)||{};return(d=a.filter(g=>!p.find(h=>h.collection===g.name)||u.initialValue||g.name===u.value))==null?void 0:d.map(g=>({label:i(g.title),value:g.name}))});return(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:{type:"object",properties:{childrenCollections:{type:"array",default:t==null?void 0:t.filter(u=>a.find(m=>m.name===u.collection)),"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},collection:{type:"string","x-decorator":"FormItem",required:!0,"x-component":"Select","x-component-props":{style:{width:260}},"x-reactions":["{{useAsyncDataSource(loadData)}}"]},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{style:{width:235}}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add collection") }}',"x-component":"ArrayItems.Addition"}}}}},scope:{useAsyncDataSource:l,loadData:c}})}),{displayName:"EnableChildCollections"}),ChildDynamicComponent=(0,import_react.observer)(e=>{const{rootCollection:t,onChange:o,value:r,collectionField:i}=e,n=(0,import_react.useFieldSchema)(),{currentFormSettings:a}=useCurrentFormVariable({collectionName:t,collectionField:i}),{currentObjectSettings:l}=useCurrentObjectVariable({schema:i==null?void 0:i.uiSchema,collectionField:i}),c=useCompile(),u=(0,import_react2.useMemo)(()=>[a,l].filter(Boolean),[a,l]),m=c(u);return(0,import_react2.useEffect)(()=>{o(n.default)},[]),(0,import_jsx_runtime.jsx)(Variable.Input,{value:r,onChange:d=>o(d),scope:m,style:{minWidth:"400px",marginRight:15},className:import_css.css`
299
+ https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModules=r,o&&(i.originalError=o),i}if(typeof define<"u")return;if(typeof requirejs<"u"){if(isFunction(requirejs))return;cfg=requirejs,requirejs=void 0}typeof require<"u"&&!isFunction(require)&&(cfg=require,require=void 0);function newContext(e){var t,o,r,i,n,a={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},l={},c={},u={},m=[],d={},p={},g={},h=1,f=1;function _(I){var M,B;for(M=0;M<I.length;M++)if(B=I[M],B===".")I.splice(M,1),M-=1;else if(B===".."){if(M===0||M===1&&I[2]===".."||I[M-1]==="..")continue;M>0&&(I.splice(M-1,2),M-=2)}}function v(I,M,B){var z,E,V,U,G,W,Y,H,J,X,Q,ee,te=M&&M.split("/"),ne=a.map,ae=ne&&ne["*"];if(I&&(I=I.split("/"),Y=I.length-1,a.nodeIdCompat&&jsSuffixRegExp.test(I[Y])&&(I[Y]=I[Y].replace(jsSuffixRegExp,"")),I[0].charAt(0)==="."&&te&&(ee=te.slice(0,te.length-1),I=ee.concat(I)),_(I),I=I.join("/")),B&&ne&&(te||ae)){V=I.split("/");e:for(U=V.length;U>0;U-=1){if(W=V.slice(0,U).join("/"),te){for(G=te.length;G>0;G-=1)if(E=getOwn(ne,te.slice(0,G).join("/")),E&&(E=getOwn(E,W),E)){H=E,J=U;break e}}!X&&ae&&getOwn(ae,W)&&(X=getOwn(ae,W),Q=U)}!H&&X&&(H=X,J=Q),H&&(V.splice(0,J,H),I=V.join("/"))}return z=getOwn(a.pkgs,I),z||I}function S(I){isBrowser&&each(scripts(),function(M){if(M.getAttribute("data-requiremodule")===I&&M.getAttribute("data-requirecontext")===r.contextName)return M.parentNode.removeChild(M),!0})}function C(I){var M=getOwn(a.paths,I);if(M&&isArray(M)&&M.length>1)return M.shift(),r.require.undef(I),r.makeRequire(null,{skipMap:!0})([I]),!0}function b(I){var M,B=I?I.indexOf("!"):-1;return B>-1&&(M=I.substring(0,B),I=I.substring(B+1,I.length)),[M,I]}function y(I,M,B,z){var E,V,U,G,W=null,Y=M?M.name:null,H=I,J=!0,X="";return I||(J=!1,I="_@r"+(h+=1)),G=b(I),W=G[0],I=G[1],W&&(W=v(W,Y,z),V=getOwn(d,W)),I&&(W?B?X=I:V&&V.normalize?X=V.normalize(I,function(Q){return v(Q,Y,z)}):X=I.indexOf("!")===-1?v(I,Y,z):I:(X=v(I,Y,z),G=b(X),W=G[0],X=G[1],B=!0,E=r.nameToUrl(X))),U=W&&!V&&!B?"_unnormalized"+(f+=1):"",{prefix:W,name:X,parentMap:M,unnormalized:!!U,url:E,originalName:H,isDefine:J,id:(W?W+"!"+X:X)+U}}function F(I){var M=I.id,B=getOwn(l,M);return B||(B=l[M]=new r.Module(I)),B}function j(I,M,B){var z=I.id,E=getOwn(l,z);hasProp(d,z)&&(!E||E.defineEmitComplete)?M==="defined"&&B(d[z]):(E=F(I),E.error&&M==="error"?B(E.error):E.on(M,B))}function k(I,M){var B=I.requireModules,z=!1;M?M(I):(each(B,function(E){var V=getOwn(l,E);V&&(V.error=I,V.events.error&&(z=!0,V.emit("error",I)))}),z||req.onError(I))}function T(){globalDefQueue.length&&(each(globalDefQueue,function(I){var M=I[0];typeof M=="string"&&(r.defQueueMap[M]=!0),m.push(I)}),globalDefQueue=[])}i={require:function(I){return I.require?I.require:I.require=r.makeRequire(I.map)},exports:function(I){if(I.usingExports=!0,I.map.isDefine)return I.exports?d[I.map.id]=I.exports:I.exports=d[I.map.id]={}},module:function(I){return I.module?I.module:I.module={id:I.map.id,uri:I.map.url,config:function(){return getOwn(a.config,I.map.id)||{}},exports:I.exports||(I.exports={})}}};function O(I){delete l[I],delete c[I]}function N(I,M,B){var z=I.map.id;I.error?I.emit("error",I.error):(M[z]=!0,each(I.depMaps,function(E,V){var U=E.id,G=getOwn(l,U);G&&!I.depMatched[V]&&!B[U]&&(getOwn(M,U)?(I.defineDep(V,d[U]),I.check()):N(G,M,B))}),B[z]=!0)}function L(){var I,M,B=a.waitSeconds*1e3,z=B&&r.startTime+B<new Date().getTime(),E=[],V=[],U=!1,G=!0;if(!t){if(t=!0,eachProp(c,function(W){var Y=W.map,H=Y.id;if(W.enabled&&(Y.isDefine||V.push(W),!W.error)){if(!W.inited&&z)C(H)?(M=!0,U=!0):(E.push(H),S(H));else if(!W.inited&&W.fetched&&Y.isDefine&&(U=!0,!Y.prefix))return G=!1}}),z&&E.length)return I=makeError("timeout","Load timeout for modules: "+E,null,E),I.contextName=r.contextName,k(I);G&&each(V,function(W){N(W,{},{})}),(!z||M)&&U&&(isBrowser||isWebWorker)&&!n&&(n=setTimeout(function(){n=0,L()},50)),t=!1}}o=function(I){this.events=getOwn(u,I.id)||{},this.map=I,this.shim=getOwn(a.shim,I.id),this.depExports=[],this.depMaps=[],this.depMatched=[],this.pluginMaps={},this.depCount=0},o.prototype={init:function(I,M,B,z){z=z||{},!this.inited&&(this.factory=M,B?this.on("error",B):this.events.error&&(B=bind(this,function(E){this.emit("error",E)})),this.depMaps=I&&I.slice(0),this.errback=B,this.inited=!0,this.ignore=z.ignore,z.enabled||this.enabled?this.enable():this.check())},defineDep:function(I,M){this.depMatched[I]||(this.depMatched[I]=!0,this.depCount-=1,this.depExports[I]=M)},fetch:function(){if(!this.fetched){this.fetched=!0,r.startTime=new Date().getTime();var I=this.map;if(this.shim)r.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],bind(this,function(){return I.prefix?this.callPlugin():this.load()}));else return I.prefix?this.callPlugin():this.load()}},load:function(){var I=this.map.url;p[I]||(p[I]=!0,r.load(this.map.id,I))},check:function(){if(!(!this.enabled||this.enabling)){var I,M,B=this.map.id,z=this.depExports,E=this.exports,V=this.factory;if(!this.inited)hasProp(r.defQueueMap,B)||this.fetch();else if(this.error)this.emit("error",this.error);else if(!this.defining){if(this.defining=!0,this.depCount<1&&!this.defined){if(isFunction(V)){if(this.events.error&&this.map.isDefine||req.onError!==defaultOnError)try{E=r.execCb(B,V,z,E)}catch(G){I=G}else E=r.execCb(B,V,z,E);if(this.map.isDefine&&E===void 0&&(M=this.module,M?E=M.exports:this.usingExports&&(E=this.exports)),I)return I.requireMap=this.map,I.requireModules=this.map.isDefine?[this.map.id]:null,I.requireType=this.map.isDefine?"define":"require",k(this.error=I)}else E=V;if(this.exports=E,this.map.isDefine&&!this.ignore&&(d[B]=E,req.onResourceLoad)){var U=[];each(this.depMaps,function(G){U.push(G.normalizedMap||G)}),req.onResourceLoad(r,this.map,U)}O(B),this.defined=!0}this.defining=!1,this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}},callPlugin:function(){var I=this.map,M=I.id,B=y(I.prefix);this.depMaps.push(B),j(B,"defined",bind(this,function(z){var E,V,U,G=getOwn(g,this.map.id),W=this.map.name,Y=this.map.parentMap?this.map.parentMap.name:null,H=r.makeRequire(I.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){z.normalize&&(W=z.normalize(W,function(J){return v(J,Y,!0)})||""),V=y(I.prefix+"!"+W,this.map.parentMap,!0),j(V,"defined",bind(this,function(J){this.map.normalizedMap=V,this.init([],function(){return J},null,{enabled:!0,ignore:!0})})),U=getOwn(l,V.id),U&&(this.depMaps.push(V),this.events.error&&U.on("error",bind(this,function(J){this.emit("error",J)})),U.enable());return}if(G){this.map.url=r.nameToUrl(G),this.load();return}E=bind(this,function(J){this.init([],function(){return J},null,{enabled:!0})}),E.error=bind(this,function(J){this.inited=!0,this.error=J,J.requireModules=[M],eachProp(l,function(X){X.map.id.indexOf(M+"_unnormalized")===0&&O(X.map.id)}),k(J)}),E.fromText=bind(this,function(J,X){var Q=I.name,ee=y(Q),te=useInteractive;X&&(J=X),te&&(useInteractive=!1),F(ee),hasProp(a.config,M)&&(a.config[Q]=a.config[M]);try{req.exec(J)}catch(ne){return k(makeError("fromtexteval","fromText eval for "+M+" failed: "+ne,ne,[M]))}te&&(useInteractive=!0),this.depMaps.push(ee),r.completeLoad(Q),H([Q],E)}),z.load(I.name,H,E,a)})),r.enable(B,this),this.pluginMaps[B.id]=B},enable:function(){c[this.map.id]=this,this.enabled=!0,this.enabling=!0,each(this.depMaps,bind(this,function(I,M){var B,z,E;if(typeof I=="string"){if(I=y(I,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[M]=I,E=getOwn(i,I.id),E){this.depExports[M]=E(this);return}this.depCount+=1,j(I,"defined",bind(this,function(V){this.undefed||(this.defineDep(M,V),this.check())})),this.errback?j(I,"error",bind(this,this.errback)):this.events.error&&j(I,"error",bind(this,function(V){this.emit("error",V)}))}B=I.id,z=l[B],!hasProp(i,B)&&z&&!z.enabled&&r.enable(I,this)})),eachProp(this.pluginMaps,bind(this,function(I){var M=getOwn(l,I.id);M&&!M.enabled&&r.enable(I,this)})),this.enabling=!1,this.check()},on:function(I,M){var B=this.events[I];B||(B=this.events[I]=[]),B.push(M)},emit:function(I,M){each(this.events[I],function(B){B(M)}),I==="error"&&delete this.events[I]}};function D(I){hasProp(d,I[0])||F(y(I[0],null,!0)).init(I[1],I[2])}function R(I,M,B,z){I.detachEvent&&!isOpera?z&&I.detachEvent(z,M):I.removeEventListener(B,M,!1)}function $(I){var M=I.currentTarget||I.srcElement;return R(M,r.onScriptLoad,"load","onreadystatechange"),R(M,r.onScriptError,"error"),{node:M,id:M&&M.getAttribute("data-requiremodule")}}function w(){var I;for(T();m.length;){if(I=m.shift(),I[0]===null)return k(makeError("mismatch","Mismatched anonymous define() module: "+I[I.length-1]));D(I)}r.defQueueMap={}}return r={config:a,contextName:e,registry:l,defined:d,urlFetched:p,defQueue:m,defQueueMap:{},Module:o,makeModuleMap:y,nextTick:req.nextTick,onError:k,configure:function(I){if(I.baseUrl&&I.baseUrl.charAt(I.baseUrl.length-1)!=="/"&&(I.baseUrl+="/"),typeof I.urlArgs=="string"){var M=I.urlArgs;I.urlArgs=function(E,V){return(V.indexOf("?")===-1?"?":"&")+M}}var B=a.shim,z={paths:!0,bundles:!0,config:!0,map:!0};eachProp(I,function(E,V){z[V]?(a[V]||(a[V]={}),mixin(a[V],E,!0,!0)):a[V]=E}),I.bundles&&eachProp(I.bundles,function(E,V){each(E,function(U){U!==V&&(g[U]=V)})}),I.shim&&(eachProp(I.shim,function(E,V){isArray(E)&&(E={deps:E}),(E.exports||E.init)&&!E.exportsFn&&(E.exportsFn=r.makeShimExports(E)),B[V]=E}),a.shim=B),I.packages&&each(I.packages,function(E){var V,U;E=typeof E=="string"?{name:E}:E,U=E.name,V=E.location,V&&(a.paths[U]=E.location),a.pkgs[U]=E.name+"/"+(E.main||"main").replace(currDirRegExp,"").replace(jsSuffixRegExp,"")}),eachProp(l,function(E,V){!E.inited&&!E.map.unnormalized&&(E.map=y(V,null,!0))}),(I.deps||I.callback)&&r.require(I.deps||[],I.callback)},makeShimExports:function(I){function M(){var B;return I.init&&(B=I.init.apply(global,arguments)),B||I.exports&&getGlobal(I.exports)}return M},makeRequire:function(I,M){M=M||{};function B(z,E,V){var U,G,W;return M.enableBuildCallback&&E&&isFunction(E)&&(E.__requireJsBuild=!0),typeof z=="string"?isFunction(E)?k(makeError("requireargs","Invalid require call"),V):I&&hasProp(i,z)?i[z](l[I.id]):req.get?req.get(r,z,I,B):(G=y(z,I,!1,!0),U=G.id,hasProp(d,U)?d[U]:k(makeError("notloaded",'Module name "'+U+'" has not been loaded yet for context: '+e+(I?"":". Use require([])")))):(w(),r.nextTick(function(){w(),W=F(y(null,I)),W.skipMap=M.skipMap,W.init(z,E,V,{enabled:!0}),L()}),B)}return mixin(B,{isBrowser,toUrl:function(z){var E,V=z.lastIndexOf("."),U=z.split("/")[0],G=U==="."||U==="..";return V!==-1&&(!G||V>1)&&(E=z.substring(V,z.length),z=z.substring(0,V)),r.nameToUrl(v(z,I&&I.id,!0),E,!0)},defined:function(z){return hasProp(d,y(z,I,!1,!0).id)},specified:function(z){return z=y(z,I,!1,!0).id,hasProp(d,z)||hasProp(l,z)}}),I||(B.undef=function(z){T();var E=y(z,I,!0),V=getOwn(l,z);V.undefed=!0,S(z),delete d[z],delete p[E.url],delete u[z],eachReverse(m,function(U,G){U[0]===z&&m.splice(G,1)}),delete r.defQueueMap[z],V&&(V.events.defined&&(u[z]=V.events),O(z))}),B},enable:function(I){var M=getOwn(l,I.id);M&&F(I).enable()},completeLoad:function(I){var M,B,z,E=getOwn(a.shim,I)||{},V=E.exports;for(T();m.length;){if(B=m.shift(),B[0]===null){if(B[0]=I,M)break;M=!0}else B[0]===I&&(M=!0);D(B)}if(r.defQueueMap={},z=getOwn(l,I),!M&&!hasProp(d,I)&&z&&!z.inited){if(a.enforceDefine&&(!V||!getGlobal(V)))return C(I)?void 0:k(makeError("nodefine","No define call for "+I,null,[I]));D([I,E.deps||[],E.exportsFn])}L()},nameToUrl:function(I,M,B){var z,E,V,U,G,W,Y,H=getOwn(a.pkgs,I);if(H&&(I=H),Y=getOwn(g,I),Y)return r.nameToUrl(Y,M,B);if(req.jsExtRegExp.test(I))G=I+(M||"");else{for(z=a.paths,E=I.split("/"),V=E.length;V>0;V-=1)if(U=E.slice(0,V).join("/"),W=getOwn(z,U),W){isArray(W)&&(W=W[0]),E.splice(0,V,W);break}G=E.join("/"),G+=M||(/^data\:|^blob\:|\?/.test(G)||B?"":".js"),G=(G.charAt(0)==="/"||G.match(/^[\w\+\.\-]+:/)?"":a.baseUrl)+G}return a.urlArgs&&!/^blob\:/.test(G)?G+a.urlArgs(I,G):G},load:function(I,M){req.load(r,I,M)},execCb:function(I,M,B,z){return M.apply(z,B)},onScriptLoad:function(I){if(I.type==="load"||readyRegExp.test((I.currentTarget||I.srcElement).readyState)){interactiveScript=null;var M=$(I);r.completeLoad(M.id)}},onScriptError:function(I){var M=$(I);if(!C(M.id)){var B=[];return eachProp(l,function(z,E){E.indexOf("_@r")!==0&&each(z.depMaps,function(V){if(V.id===M.id)return B.push(E),!0})}),k(makeError("scripterror",'Script error for "'+M.id+(B.length?'", needed by: '+B.join(", "):'"'),I,[M.id]))}}},r.require=r.makeRequire(),r}req=requirejs=function(e,t,o,r){var i,n,a=defContextName;return!isArray(e)&&typeof e!="string"&&(n=e,isArray(t)?(e=t,t=o,o=r):e=[]),n&&n.context&&(a=n.context),i=getOwn(contexts,a),i||(i=contexts[a]=req.s.newContext(a)),n&&i.configure(n),i.require(e,t,o)},req.config=function(e){return req(e)},req.nextTick=typeof setTimeout<"u"?function(e){setTimeout(e,4)}:function(e){e()},require||(require=req),req.version=version,req.jsExtRegExp=/^\/|:|\?|\.js$/,req.isBrowser=isBrowser,s=req.s={contexts,newContext},req({}),each(["toUrl","undef","defined","specified"],function(e){req[e]=function(){var t=contexts[defContextName];return t.require[e].apply(t,arguments)}}),isBrowser&&(head=s.head=document.getElementsByTagName("head")[0],baseElement=document.getElementsByTagName("base")[0],baseElement&&(head=s.head=baseElement.parentNode)),req.onError=defaultOnError,req.createNode=function(e,t,o){var r=e.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");return r.type=e.scriptType||"text/javascript",r.charset="utf-8",r.async=!0,r},req.load=function(e,t,o){var r=e&&e.config||{},i;if(isBrowser)return i=req.createNode(r,t,o),i.setAttribute("data-requirecontext",e.contextName),i.setAttribute("data-requiremodule",t),i.attachEvent&&!(i.attachEvent.toString&&i.attachEvent.toString().indexOf("[native code")<0)&&!isOpera?(useInteractive=!0,i.attachEvent("onreadystatechange",e.onScriptLoad)):(i.addEventListener("load",e.onScriptLoad,!1),i.addEventListener("error",e.onScriptError,!1)),i.src=o,r.onNodeCreated&&r.onNodeCreated(i,r,t,o),currentlyAddingScript=i,baseElement?head.insertBefore(i,baseElement):head.appendChild(i),currentlyAddingScript=null,i;if(isWebWorker)try{setTimeout(function(){},0),importScripts(o),e.completeLoad(t)}catch(n){e.onError(makeError("importscripts","importScripts failed for "+t+" at "+o,n,[t]))}};function getInteractiveScript(){return interactiveScript&&interactiveScript.readyState==="interactive"||eachReverse(scripts(),function(e){if(e.readyState==="interactive")return interactiveScript=e}),interactiveScript}return isBrowser&&!cfg.skipDataMain&&eachReverse(scripts(),function(e){if(head||(head=e.parentNode),dataMain=e.getAttribute("data-main"),dataMain)return mainScript=dataMain,!cfg.baseUrl&&mainScript.indexOf("!")===-1&&(src=mainScript.split("/"),mainScript=src.pop(),subPath=src.length?src.join("/")+"/":"./",cfg.baseUrl=subPath),mainScript=mainScript.replace(jsSuffixRegExp,""),req.jsExtRegExp.test(mainScript)&&(mainScript=dataMain),cfg.deps=cfg.deps?cfg.deps.concat(mainScript):[mainScript],!0}),define=function(e,t,o){var r,i;typeof e!="string"&&(o=t,t=e,e=null),isArray(t)||(o=t,t=null),!t&&isFunction(o)&&(t=[],o.length&&(o.toString().replace(commentRegExp,commentReplace).replace(cjsRequireRegExp,function(n,a){t.push(a)}),t=(o.length===1?["require"]:["require","exports","module"]).concat(t))),useInteractive&&(r=currentlyAddingScript||getInteractiveScript(),r&&(e||(e=r.getAttribute("data-requiremodule")),i=contexts[r.getAttribute("data-requirecontext")])),i?(i.defQueue.push([e,t,o]),i.defQueueMap[e]=!0):globalDefQueue.push([e,t,o])},define.amd={jQuery:!0},req.exec=function(text){return eval(text)},req(cfg),{requirejs,require,define}}const setFieldProps=(e,t,o)=>{(0,import_reactive.untracked)(()=>{e[t]===void 0&&(e[t]=o)})},setRequired=(e,t,o)=>{typeof t.required>"u"&&(e.required=!!o.required)},CollectionFieldInternalField_deprecated=e=>{var t;const o=useCompile(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{uiSchema:n,defaultValue:a}=useCollectionField(),{isAllowToSetDefaultValue:l}=useIsAllowToSetDefaultValue(),c=useComponent(((t=i["x-component-props"])==null?void 0:t.component)||(n==null?void 0:n["x-component"])||"Input"),u=useFormBlockContext(),m=useDynamicComponentProps(n==null?void 0:n["x-use-component-props"],e);return(0,import_react2.useEffect)(()=>{if(!n)return;const d=o(n);if(setFieldProps(r,"content",d["x-content"]),setFieldProps(r,"title",d.title),setFieldProps(r,"description",d.description),u!=null&&u.form){const g=l()?i.default||a:void 0;g!=null&&setFieldProps(r,"initialValue",g)}if(!r.validator&&(d["x-validator"]||i["x-validator"])){const g=(0,import_lodash.concat)([],d["x-validator"]||[],i["x-validator"]||[]);r.validator=g}i["x-disabled"]===!0&&(r.disabled=!0),i["x-read-pretty"]===!0&&(r.readPretty=!0),setRequired(r,i,d),r.dataSource=d.enum;const p=o(d["x-component-props"])||{};r.componentProps=(0,import_shared.merge)(p,r.componentProps||{},m||{})},[n]),n?(0,import_jsx_runtime.jsx)(c,x(x({},e),m)):null},CollectionFieldInternalField=e=>{var t;const o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{uiSchema:i}=useCollectionFieldUISchema(),n=useComponent(((t=r["x-component-props"])==null?void 0:t.component)||(i==null?void 0:i["x-component"])||"Input"),a=useDynamicComponentProps(i==null?void 0:i["x-use-component-props"],e);return(0,import_react2.useEffect)(()=>{r["x-read-pretty"]===!0&&!o.readPretty&&(o.readPretty=!0)},[o,r]),i?(0,import_jsx_runtime.jsx)(n,x(x({},e),a)):null},CollectionField$1=(0,import_react.connect)(e=>{const t=(0,import_react.useFieldSchema)(),o=useIsInNocoBaseRecursionFieldContext();return(0,import_jsx_runtime.jsx)(CollectionFieldProvider,{name:t.name,children:o?(0,import_jsx_runtime.jsx)(CollectionFieldInternalField,x({},e)):(0,import_jsx_runtime.jsx)(CollectionFieldInternalField_deprecated,x({},e))})});CollectionField$1.displayName="CollectionField";const DataSourceApplicationProvider=e=>{var t=e,{children:o,dataSourceManager:r}=t,i=K(t,["children","dataSourceManager"]);return(0,import_jsx_runtime.jsx)(DataSourceManagerProvider,{dataSourceManager:r,children:(0,import_jsx_runtime.jsx)(CollectionManagerProvider,P(x({},i),{children:o}))})},getKeyByName=e=>e?`nocobase_${e}_designable`.toUpperCase():"nocobase_designable".toUpperCase(),SchemaComponentProviderWithLocalStorageState=e=>{const[t,o]=(0,import_ahooks.useLocalStorageState)(getKeyByName(e.appName),{defaultValue:!!e.designable});return(0,import_jsx_runtime.jsx)(SchemaComponentProvider,P(x({},e),{designable:t,onDesignableChange:r=>{o(r)}}))},AppSchemaComponentProvider=e=>typeof e.designable=="boolean"?(0,import_jsx_runtime.jsx)(SchemaComponentProvider,x({},e)):(0,import_jsx_runtime.jsx)(SchemaComponentProviderWithLocalStorageState,x({},e));class Application{constructor(t={}){A(this,"eventBus",new EventTarget),A(this,"providers",[]),A(this,"router"),A(this,"scopes",{}),A(this,"i18n"),A(this,"ws"),A(this,"apiClient"),A(this,"components",P(x(x({DataBlockProvider},defaultAppComponents),schemaInitializerComponents),{CollectionField:CollectionField$1})),A(this,"pluginManager"),A(this,"pluginSettingsManager"),A(this,"devDynamicImport"),A(this,"requirejs"),A(this,"notification"),A(this,"schemaInitializerManager"),A(this,"schemaSettingsManager"),A(this,"dataSourceManager"),A(this,"name"),A(this,"loading",!0),A(this,"maintained",!1),A(this,"maintaining",!1),A(this,"error",null),A(this,"hasLoadError",!1),A(this,"wsAuthorized",!1),this.options=t,this.initRequireJs(),(0,import_reactive.define)(this,{maintained:import_reactive.observable.ref,loading:import_reactive.observable.ref,maintaining:import_reactive.observable.ref,error:import_reactive.observable.ref}),this.devDynamicImport=t.devDynamicImport,this.scopes=(0,import_merge.default)(this.scopes,t.scopes),this.components=(0,import_merge.default)(this.components,t.components),this.apiClient=t.apiClient instanceof APIClient?t.apiClient:new APIClient(t.apiClient),this.apiClient.app=this,this.i18n=t.i18n||i18n,this.router=new RouterManager(t.router,this),this.schemaSettingsManager=new SchemaSettingsManager(t.schemaSettings,this),this.pluginManager=new PluginManager$1(t.plugins,t.loadRemotePlugins,this),this.schemaInitializerManager=new SchemaInitializerManager(t.schemaInitializers,this),this.dataSourceManager=new DataSourceManager(t.dataSourceManager,this),this.addDefaultProviders(),this.addReactRouterComponents(),this.addProviders(t.providers||[]),this.ws=new WebSocketClient(t.ws),this.ws.app=this,this.pluginSettingsManager=new PluginSettingsManager(t.pluginSettings,this),this.addRoutes(),this.name=this.options.name||(0,import_sdk.getSubAppName)(t.publicPath)||"main",this.i18n.on("languageChanged",o=>{this.apiClient.auth.locale=o}),this.initListeners()}get pm(){return this.pluginManager}get disableAcl(){return this.options.disableAcl}get isWsAuthorized(){return this.wsAuthorized}setWsAuthorized(t){this.wsAuthorized=t}initListeners(){this.eventBus.addEventListener("auth:tokenChanged",t=>{this.setTokenInWebSocket(t.detail)}),this.eventBus.addEventListener("maintaining:end",()=>{this.apiClient.auth.token&&this.setTokenInWebSocket({token:this.apiClient.auth.token,authenticator:this.apiClient.auth.getAuthenticator()})})}setTokenInWebSocket(t){const{token:o,authenticator:r}=t;this.maintaining||this.ws.send(JSON.stringify({type:"auth:token",payload:{token:o,authenticator:r}}))}setMaintaining(t){this.maintaining!==t&&(this.maintaining=t,t||this.eventBus.dispatchEvent(new Event("maintaining:end")))}initRequireJs(){this.requirejs=getRequireJs(),defineGlobalDeps(this.requirejs),window.define=this.requirejs.define}addDefaultProviders(){this.use(APIClientProvider,{apiClient:this.apiClient}),this.use(import_react_i18next.I18nextProvider,{i18n:this.i18n}),this.use(GlobalThemeProvider),this.use(CSSVariableProvider),this.use(AppSchemaComponentProvider,{designable:this.options.designable,appName:this.name,components:this.components,scope:this.scopes}),this.use(AntdAppProvider),this.use(DataSourceApplicationProvider,{dataSourceManager:this.dataSourceManager}),this.use(OpenModeProvider)}addReactRouterComponents(){this.addComponents({Link:import_react_router_dom.Link,Navigate:import_react_router_dom.Navigate,NavLink:import_react_router_dom.NavLink})}addRoutes(){this.router.add("not-found",{path:"*",Component:this.components.AppNotFound})}getOptions(){return this.options}getName(){return(0,import_sdk.getSubAppName)(this.getPublicPath())||null}getPublicPath(){let t=this.options.publicPath||"/";return t.endsWith("/")||(t+="/"),t}getApiUrl(t=""){let o=this.apiClient.axios.defaults.baseURL;if(!o.startsWith("http://")&&!o.startsWith("https://")){const{protocol:r,host:i}=window.location;o=`${r}//${i}${o}`}return o.replace(/\/$/g,"")+"/"+t.replace(/^\//g,"")}getRouteUrl(t){return this.getPublicPath()+t.replace(/^\//g,"")}getHref(t){const o=this.name;return o&&o!=="main"?this.getPublicPath()+"apps/"+o+"/"+t.replace(/^\//g,""):this.getPublicPath()+t.replace(/^\//g,"")}getCollectionManager(t){var o;return(o=this.dataSourceManager.getDataSource(t))==null?void 0:o.collectionManager}getComposeProviders(){const t=compose(...this.providers)(BlankComponent);return t.displayName="Providers",t}use(t,o){return this.addProvider(t,o)}addProvider(t,o){return this.providers.push([t,o])}addProviders(t){t.forEach(o=>{Array.isArray(o)?this.addProvider(o[0],o[1]):this.addProvider(o)})}load(){return q(this,null,function*(){try{this.loading=!0,yield this.loadWebSocket(),yield this.pm.load()}catch(t){this.hasLoadError=!0,this.ws.enabled&&(yield new Promise(r=>{setTimeout(()=>r(null),1e3)}));const o=r=>{var i,n,a,l,c,u,m,d,p,g,h,f;if(typeof((i=r==null?void 0:r.response)==null?void 0:i.data)=="string"){const _=document.createElement("div");return _.innerHTML=(n=r==null?void 0:r.response)==null?void 0:n.data,{message:_.textContent||_.innerText}}return(l=(a=r==null?void 0:r.response)==null?void 0:a.data)!=null&&l.error?(u=(c=r==null?void 0:r.response)==null?void 0:c.data)==null?void 0:u.error:(p=(d=(m=r==null?void 0:r.response)==null?void 0:m.data)==null?void 0:d.errors)!=null&&p[0]?(f=(h=(g=r==null?void 0:r.response)==null?void 0:g.data)==null?void 0:h.errors)==null?void 0:f[0]:{message:r==null?void 0:r.message}};this.error=x({code:"LOAD_ERROR"},o(t)),console.error(t,this.error)}this.loading=!1})}loadWebSocket(){return q(this,null,function*(){this.eventBus.addEventListener("ws:message:authorized",()=>{this.setWsAuthorized(!0)}),this.ws.on("message",t=>{var o,r,i;const n=JSON.parse(t.data);if((o=n==null?void 0:n.payload)!=null&&o.refresh){window.location.reload();return}if(n.type==="notification"){this.notification[((r=n.payload)==null?void 0:r.type)||"info"]({message:(i=n.payload)==null?void 0:i.message});return}if(n.type==="maintaining"&&n.payload.code!=="APP_RUNNING")this.setMaintaining(!0),this.error=n.payload;else{this.hasLoadError&&window.location.reload(),this.setMaintaining(!1),this.maintained=!0,this.error=null;const a=n.type;if(!a)return;const l=`ws:message:${a}`;this.eventBus.dispatchEvent(new CustomEvent(l,{detail:n.payload}))}}),this.ws.on("serverDown",()=>{this.maintaining=!0,this.maintained=!1}),this.ws.on("open",()=>{const t=this.apiClient.auth.token;t&&this.setTokenInWebSocket({token:t,authenticator:this.apiClient.auth.getAuthenticator()})}),this.ws.connect()})}getComponent(t,o=!0){const r=i=>o&&console.error(i);if(!t){r(`getComponent called with ${t}`);return}if(typeof t=="function")return t;if(typeof t=="string"){const i=(0,import_get.default)(this.components,t);if(!i){r(`Component ${t} not found`);return}return i}r(`Component ${t} should be a string or a React component`)}renderComponent(t,o,r){return import_react2.default.createElement(this.getComponent(t),o,r)}addComponent(t,o){const r=o||t.displayName||t.name;if(!r){console.error("Component must have a displayName or pass name as second argument");return}(0,import_set.default)(this.components,r,t)}addComponents(t){Object.keys(t).forEach(o=>{this.addComponent(t[o],o)})}addScopes(t){this.scopes=(0,import_merge.default)(this.scopes,t)}getRootComponent(){return({children:t})=>(0,import_jsx_runtime.jsx)(AppComponent,{app:this,children:t})}mount(t){const o=normalizeContainer(t);if(!o)return;const r=this.getRootComponent(),i=(0,import_client3.createRoot)(o);return i.render((0,import_jsx_runtime.jsx)(r,{})),i}addFieldInterfaces(t=[]){return this.dataSourceManager.collectionFieldInterfaceManager.addFieldInterfaces(t)}addFieldInterfaceComponentOption(t,o){return this.dataSourceManager.collectionFieldInterfaceManager.addFieldInterfaceComponentOption(t,o)}}function getNewSchema(e){const{fieldSchema:t,schemaKey:o,parentSchemaKey:r,value:i,valueKeys:n}=e;if(o)import_lodash.default.set(t,o,i);else if(r){if(i==null)return t;typeof i=="object"?Object.keys(i).forEach(a=>{n&&!n.includes(a)||import_lodash.default.set(t,`${r}.${a}`,i[a])}):console.error("value must be object")}return t}const useHookDefault=e=>e,useSchemaByType=(e="common")=>{const t=(0,import_react.useFieldSchema)(),{fieldSchema:o}=useColumnSchema$1()||{};return e==="field"&&o||t};function createModalSettingsItem(e){const{name:t,parentSchemaKey:o,valueKeys:r,schema:i,title:n,useSubmit:a=useHookDefault,useVisible:l,defaultValue:c,useDefaultValue:u=useHookDefault,width:m,type:d="common"}=e;return{name:t,type:"actionModal",useVisible:l,useComponentProps(){const p=useSchemaByType(d),{dn:g}=useDesignable(),h=u(c),f=o?import_lodash.default.get(p,o):void 0,_=useCompile(),{t:v}=(0,import_react_i18next.useTranslation)(),S=a(),{fieldSchema:C}=useColumnSchema$1()||{};return{title:typeof n=="function"?n(v):_(n),width:m,schema:i(x(x({},h),f)),onSubmit(b){const y=getNewSchema({fieldSchema:p,parentSchemaKey:o,value:b,valueKeys:r});return C?(g.emit("patch",{schema:y}),g.refresh()):g.deepMerge(y),S==null?void 0:S(b)}}}}}const createSelectSchemaSettingsItem=e=>{const{name:t,title:o,options:r,useOptions:i=useHookDefault,schemaKey:n,useVisible:a,type:l="common",defaultValue:c,useDefaultValue:u=useHookDefault}=e;return{name:t,type:"select",useVisible:a,useComponentProps(){const m=useSchemaByType(l),{fieldSchema:d}=useColumnSchema$1()||{},{dn:p}=useDesignable(),g=i(r),h=u(c),f=useCompile(),{t:_}=(0,import_react_i18next.useTranslation)();return{title:typeof o=="function"?o(_):f(o),options:g,value:import_lodash.default.get(m,n,h),onChange(v){const S=getNewSchema({fieldSchema:m,schemaKey:n,value:v});d?(p.emit("patch",{schema:S}),p.refresh()):p.deepMerge(S)}}}}};function createSwitchSettingsItem(e){const{name:t,useVisible:o,schemaKey:r,title:i,type:n="common",defaultValue:a,useDefaultValue:l=useHookDefault}=e;return{name:t,useVisible:o,type:"switch",useComponentProps(){const c=useSchemaByType(n),{dn:u}=useDesignable(),m=l(a),d=useCompile(),{t:p}=(0,import_react_i18next.useTranslation)(),{fieldSchema:g}=useColumnSchema$1()||{};return{title:typeof i=="function"?i(p):d(i),checked:!!import_lodash.default.get(c,r,m),onChange(h){const f=getNewSchema({fieldSchema:c,schemaKey:r,value:h});g?(u.emit("patch",{schema:f}),u.refresh()):u.deepMerge(f)}}}}}function createTextSettingsItem(e){const{name:t,useVisible:o,title:r,useTextClick:i=useHookDefault}=e;return{name:t,type:"item",useVisible:o,useComponentProps(){const n=useCompile(),{t:a}=(0,import_react_i18next.useTranslation)(),l=i();return{title:typeof r=="function"?r(a):n(r),onClick:l}}}}const SchemaSettingItemContext=(0,import_react2.createContext)({});SchemaSettingItemContext.displayName="SchemaSettingItemContext";function useSchemaSettingsItem(){return(0,import_react2.useContext)(SchemaSettingItemContext)}const useCollectionManager_deprecated=e=>{const t=useDataSourceManager(),o=useDataSource(),r=useCollectionManager(),i=e||(o==null?void 0:o.key)||void 0,[n,a]=(0,import_react2.useState)((0,import_shared.uid)()),{refresh:l}=useSchemaComponentContext(),c=(0,import_react2.useMemo)(()=>{var R;return(R=t==null?void 0:t.collectionFieldInterfaceManager)==null?void 0:R.getFieldInterfaces().reduce(($,w)=>($[w.name]=w,$),{})},[t,n]),u=(0,import_react2.useMemo)(()=>t==null?void 0:t.collectionTemplateManager.getCollectionTemplates(),[t,n]),m=(0,import_react2.useCallback)(()=>{var R,$;return($=(R=t==null?void 0:t.getDataSource(i))==null?void 0:R.collectionManager)==null?void 0:$.getCollections().map(w=>w.getOptions())},[t,o]),d=(0,import_react2.useCallback)(R=>{var $;return r&&!R?r:($=t==null?void 0:t.getDataSource(R||i))==null?void 0:$.collectionManager},[r,t,i]),p=(0,import_react2.useMemo)(()=>{var R,$;return($=(R=t==null?void 0:t.getDataSource(DEFAULT_DATA_SOURCE_KEY))==null?void 0:R.collectionManager)==null?void 0:$.getCollections()},[t,n]),g=(0,import_react2.useCallback)(()=>t==null?void 0:t.getDataSource(DEFAULT_DATA_SOURCE_KEY).reload().then(()=>{l(),a((0,import_shared.uid)())}),[t]),h=(0,import_react2.useCallback)(()=>t==null?void 0:t.getDataSource(DEFAULT_DATA_SOURCE_KEY).reload().then(()=>{l(),a((0,import_shared.uid)())}),[t]),f=useCompile(),_=(0,import_react2.useCallback)((R,$)=>{var w,I;return((I=(w=d($))==null?void 0:w.getCollection(R))==null?void 0:I.getInheritedFields())||[]},[t,d]),v=(0,import_react2.useCallback)((R,$)=>{var w,I;if(!R)return[];const M=(w=d($))==null?void 0:w.getCollection(R);return((I=M==null?void 0:M.getAllFields)==null?void 0:I.call(M))||(M==null?void 0:M.getFields())||[]},[t,d]),S=(0,import_react2.useCallback)((R,$)=>{var w;if(!(!R||R.split(".").length<2))return(w=d($))==null?void 0:w.getCollectionField(R)},[t,d]),C=(0,import_react2.useCallback)((R,$)=>{var w,I;return R?((I=(w=d($))==null?void 0:w.getCollection(R))==null?void 0:I.getParentCollectionsName())||[]:[]},[t,d]),b=(0,import_react2.useCallback)((R,$=!1,w)=>{var I;if(!R)return[];const M=(I=d(w))==null?void 0:I.getCollection(R);return(M==null?void 0:M.getChildrenCollections($))||[]},[t,d]),y=(0,import_react2.useCallback)((R,$)=>{var w,I;return R?((I=(w=d($))==null?void 0:w.getCollection(R))==null?void 0:I.getCurrentFields())||[]:[]},[t,d]),F=(0,import_react2.useCallback)((R,$="string",w)=>{var I;const{association:M=!1,cached:B={},collectionNames:z=[R],maxDepth:E=1,allowAllTypes:V=!1,exceptInterfaces:U=[],prefixFieldValue:G="",usePrefix:W=!1,dataSource:Y}=w||{};if(z.length-1>E)return;if(B[R])return import_lodash.default.cloneDeep(B[R]);typeof $=="string"&&($=[$]);const H=v(R,Y),J=(I=H==null?void 0:H.filter(X=>X.interface&&!U.includes(X.interface)&&(V||$.includes(X.type)||(M&&X.target&&X.target!==R&&Array.isArray(M)?M.includes(X.interface):!1))))==null?void 0:I.map(X=>{var Q,ee;const te=x({value:W&&G?`${G}.${X.name}`:X.name,label:f((Q=X==null?void 0:X.uiSchema)==null?void 0:Q.title)||X.name},X);return M&&X.target&&(te.children=z.includes(X.target)?[]:F(X.target,$,P(x({},w),{cached:B,dataSource:Y,collectionNames:[...z,X.target],prefixFieldValue:W?G?`${G}.${X.name}`:X.name:"",usePrefix:W})),!((ee=te.children)!=null&&ee.length))?null:te}).filter(Boolean);return B[R]=J,J},[v]),j=(0,import_react2.useCallback)((R,$)=>{var w;return(w=d($))==null?void 0:w.getCollection(R)},[t,d]),k=(0,import_react2.useCallback)((R,$)=>{var w,I;return(I=(w=d($))==null?void 0:w.getCollection(R))==null?void 0:I.getAllCollectionsInheritChain()},[t,d]),T=(0,import_react2.useCallback)((R,$)=>()=>{var w,I;return(I=(w=d($))==null?void 0:w.getCollection(R))==null?void 0:I.getInheritCollectionsChain()},[t,d]),O=(0,import_react2.useCallback)(R=>t==null?void 0:t.collectionFieldInterfaceManager.getFieldInterface(R),[t]),N=(0,import_react2.useCallback)(R=>{var $;return($=O(R.interface))==null?void 0:$.titleUsable},[O]),L=(0,import_react2.useCallback)((R,$,w)=>{var I,M;return(M=(I=d(w))==null?void 0:I.getCollection($))==null?void 0:M.getParentCollectionFields(R)},[t,d]),D=(0,import_react2.useCallback)((R="general")=>t==null?void 0:t.collectionTemplateManager.getCollectionTemplate(R),[t]);return{service:g,interfaces:c,collections:p,templates:u,getTemplate:D,getInterface:O,getCollections:m,getParentCollectionFields:L,getInheritCollections:C,getChildrenCollections:b,refreshCM:h,get:j,getInheritedFields:_,getCollectionField:S,getCollectionFields:v,getCollectionFieldsOptions:F,getCurrentCollectionFields:y,getCollection:j,getCollectionJoinField:S,getAllCollectionsInheritChain:k,getInheritCollectionsChain:T,isTitleField:N}},GetMenuItemContext=(0,import_react2.createContext)(null);GetMenuItemContext.displayName="GetMenuItemContext";const GetMenuItemsContext=(0,import_react2.createContext)(null);GetMenuItemsContext.displayName="GetMenuItemsContext";const useCollectMenuItem=()=>(0,import_react2.useContext)(GetMenuItemContext)||{},useCollectMenuItems=()=>(0,import_react2.useContext)(GetMenuItemsContext)||{},useMenuItem=()=>{const e=(0,import_react2.useRef)([]),t=(0,import_react2.useRef)(null),o=(0,import_react2.useRef)(!1),r=(0,import_react2.useCallback)(({limitCount:l})=>o.current?(o.current=!1,t.current?t.current():l&&e.current.length>l?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.current.slice(0,l).map((c,u)=>(0,import_jsx_runtime.jsx)(c,{},u))}):(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.current.map((c,u)=>(0,import_jsx_runtime.jsx)(c,{},u))})):null,[]),i=(0,import_react2.useCallback)(l=>{const c=[],u=m=>{c.push(m),c.sort((d,p)=>(d.order||0)-(p.order||0))};return o.current=!0,t.current=()=>{const m=c.filter(d=>d.notdelete).map(d=>import_lodash.default.omit(d,"notdelete"));return c.length=0,c.push(...m),(0,import_jsx_runtime.jsx)(GetMenuItemsContext.Provider,{value:{pushMenuItem:u},children:l()})},c},[]),n=(0,import_react2.useCallback)(l=>{const c={},u=m=>{Object.assign(c,m)};return o.current=!0,e.current.push(()=>(0,import_jsx_runtime.jsx)(GetMenuItemContext.Provider,{value:{collectMenuItem:u},children:l()})),c},[]),a=(0,import_react2.useCallback)(()=>{e.current=[]},[]);return{Component:r,getMenuItems:i,getMenuItem:n,clean:a}},isModalTitle=e=>(0,import_shared.isNum)(e)||(0,import_shared.isStr)(e)||(0,import_shared.isBool)(e)||import_react2.default.isValidElement(e),getModelProps=e=>isModalTitle(e)?{title:e}:e;function FormDialog(e,t,o,r){((0,import_shared.isFn)(t)||import_react2.default.isValidElement(t))&&(r=o,o=t,t="form-dialog");const i={host:document.createElement("div"),form:null,promise:null,openMiddlewares:[],confirmMiddlewares:[],cancelMiddlewares:[]},n=createPortalRoot(i.host,t),a=getModelProps(e),l=P(x({},a),{afterClose:()=>{var d;(d=a==null?void 0:a.afterClose)==null||d.call(a),n.unmount()}}),c=(0,import_react.observer)(()=>(0,import_jsx_runtime.jsx)(import_react2.Fragment,{children:(0,import_shared.isFn)(o)?o(i.form):o}),{displayName:"DialogContent"}),u=(d=!0,p,g)=>{const{form:h}=i;return h?(0,import_jsx_runtime.jsx)(GlobalThemeProvider,{theme:r,children:(0,import_jsx_runtime.jsx)(import_react.Observer,{children:()=>{const{token:f}=useToken();return(0,import_jsx_runtime.jsx)(import_antd.Modal,P(x({zIndex:f.zIndexPopupBase+1e3},l),{open:d,confirmLoading:h.submitting,onCancel:_=>{var v;((v=l==null?void 0:l.onCancel)==null?void 0:v.call(l,_))!==!1&&(g==null||g())},onOk:_=>q(this,null,function*(){var v;((v=l==null?void 0:l.onOk)==null?void 0:v.call(l,_))!==!1&&(p==null||p())}),children:(0,import_jsx_runtime.jsx)(import_react.FormProvider,{form:h,children:(0,import_jsx_runtime.jsx)(c,{})})}))}})}):null};document.body.appendChild(i.host);const m={forOpen:d=>((0,import_shared.isFn)(d)&&i.openMiddlewares.push(d),m),forConfirm:d=>((0,import_shared.isFn)(d)&&i.confirmMiddlewares.push(d),m),forCancel:d=>((0,import_shared.isFn)(d)&&i.cancelMiddlewares.push(d),m),open:d=>q(this,null,function*(){return i.promise||(i.promise=new Promise((p,g)=>q(this,null,function*(){try{d=yield loading$1(l.loadingText,()=>(0,import_shared.applyMiddleware)(d,i.openMiddlewares)),i.form=i.form||(0,import_core2.createForm)(d)}catch(h){g(h)}n.render(()=>u(!0,()=>{var h;(h=i.form)==null||h.submit(()=>q(this,null,function*(){yield(0,import_shared.applyMiddleware)(i.form,i.confirmMiddlewares),(0,import_reactive.untracked)(()=>{var f;p(x({},(f=i.form)==null?void 0:f.values))}),m.close()})).catch(()=>{})},()=>q(this,null,function*(){yield loading$1(l.loadingText,()=>(0,import_shared.applyMiddleware)(i.form,i.cancelMiddlewares)),m.close()})))}))),i.promise}),close:()=>{i.host&&n.render(()=>u(!1))}};return m}const DialogFooter=e=>{const t=(0,import_react2.useRef)(null),[o,r]=(0,import_react2.useState)(),i=(0,import_react2.useRef)(),n=usePrefixCls("modal");return(0,import_react2.useLayoutEffect)(()=>{var a;const l=(a=t.current)==null?void 0:a.closest(`.${n}-content`);l&&(i.current||(i.current=l.querySelector(`.${n}-footer`),i.current||(i.current=document.createElement("div"),i.current.classList.add(`${n}-footer`),l.appendChild(i.current))),r(i.current))},[n]),i.current=o,(0,import_jsx_runtime.jsx)("div",{ref:t,style:{display:"none"},children:o&&(0,import_react_dom.createPortal)(e.children,o)})};FormDialog.Footer=DialogFooter;FormDialog.Portal=createPortalProvider("form-dialog");const useAPITokenVariable=({noDisabled:e}={})=>{var t;const o=useAPIClient();return{apiTokenSettings:useBaseVariable({name:"$nToken",title:"API token",noDisabled:e,noChildren:!0}),apiTokenCtx:(t=o.auth)==null?void 0:t.token}},popupSchema={type:"void","x-component":"Action.Container","x-action":"view",title:'{{ t("View record") }}',"x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}},useInsertSchema=()=>{const e=(0,import_react.useFieldSchema)(),{insertAfterBegin:t}=useDesignable();return(0,import_react2.useCallback)(o=>{e.reduceProperties((r,i)=>i["x-component"]==="Action.Container"?i:r,null)||t((0,import_lodash.cloneDeep)(o))},[e,t])},filterProperties=e=>e["x-component"]==="Action.Container";function withPopupWrapper(e){return t=>{const[o,r]=(0,import_react2.useState)(!1),[i,n]=(0,import_react2.useState)(!1),a=useInsertSchema(),l=useCollection(),c=useActionContext(),u=(0,import_react.useField)(),m=(0,import_react.useFieldSchema)(),{enableLink:d,openMode:p,openSize:g}=(m==null?void 0:m["x-component-props"])||{},{visibleWithURL:h,setVisibleWithURL:f}=usePopupUtils(),{openPopup:_}=usePopupUtils(),v=(0,import_react2.useRef)(!1),S=(0,import_react2.useRef)(m);S.current=m;const C=(0,import_react2.useCallback)(()=>S.current,[]),b=(0,import_react2.useCallback)(()=>{m.properties||(a(popupSchema),v.current=!0),v.current?(setTimeout(()=>{_({customActionSchema:C()})}),v.current=!1):m.properties&&_()},[m,a,_,C]),{setSubmitted:y}=c,F=(0,import_react2.useCallback)(j=>{r==null||r(j),f==null||f(j)},[f]);return d?(0,import_jsx_runtime.jsx)(PopupVisibleProvider,{visible:!1,children:(0,import_jsx_runtime.jsxs)(ActionContextProvider,{button:(0,import_jsx_runtime.jsx)(e,x({},t)),visible:o||h,setVisible:F,formValueChanged:i,setFormValueChanged:n,openMode:p,openSize:g,containerRefKey:"field-popup",fieldSchema:m,setSubmitted:y,children:[(0,import_jsx_runtime.jsx)(CollectionProvider,{name:l.name,children:(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{children:(0,import_jsx_runtime.jsx)(VariablePopupRecordProvider,{children:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{onlyRenderProperties:!0,basePath:u==null?void 0:u.address,schema:m,filterProperties})})})}),(0,import_jsx_runtime.jsx)("a",{onClick:b,children:(0,import_jsx_runtime.jsx)(e,x({},t))})]})}):(0,import_jsx_runtime.jsx)(e,x({},t))}}const ReadPretty$d=()=>null;ReadPretty$d.DatePicker=function e(t){const{value:o,picker:r="date"}=t,i=(0,import_builtins.usePrefixCls)("description-date-picker",t);if(!o)return(0,import_jsx_runtime.jsx)("div",{});const n=()=>{const a=(0,import_client.getDefaultFormat)(t),l=(0,import_client.str2moment)(o,t),c=import_dayjs.default.isDayjs(l)?l.format(a):"";return(0,import_shared.isArr)(c)?c.join("~"):c};return(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(i,t.className),children:n()})};ReadPretty$d.DateRangePicker=function e(t){const o=(0,import_builtins.usePrefixCls)("description-text",t),r=(0,import_client.getDefaultFormat)(t),i=()=>{const n=(0,import_client.str2moment)(t.value,t);if(!n)return"";const a=n.map(l=>l.format(r));return(0,import_shared.isArr)(a)?a.join("~"):a};return(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(o,t.className),style:t.style,children:i()})};ReadPretty$d.DatePicker=withPopupWrapper(ReadPretty$d.DatePicker);const DatePickerContext=import_react2.default.createContext({utc:!0}),useDatePickerContext=()=>import_react2.default.useContext(DatePickerContext),DatePickerProvider=DatePickerContext.Provider,InternalDatePicker=(0,import_react.connect)(import_antd.DatePicker,(0,import_react.mapProps)(mapDatePicker()),(0,import_react.mapReadPretty)(ReadPretty$d.DatePicker)),InternalRangePicker=(0,import_react.connect)(import_antd.DatePicker.RangePicker,(0,import_react.mapProps)(mapRangePicker()),(0,import_react.mapReadPretty)(ReadPretty$d.DateRangePicker)),DatePicker=e=>{const{utc:t=!0}=useDatePickerContext(),o=Array.isArray(e.value)?e.value[0]:e.value,{parseVariable:r}=useVariables$1()||{},i=useLocalVariables$1(),[n,a]=(0,import_react2.useState)(null),[l,c]=(0,import_react2.useState)(null),u=(0,import_react2.useRef)(null);(0,import_react2.useEffect)(()=>(u.current&&u.current(),u.current=(0,import_reactive.autorun)(()=>{m()}),()=>{u.current()}),[e._maxDate,e._minDate,i,r]);const m=()=>q(void 0,null,function*(){let p=e._minDate?Promise.resolve((0,import_dayjs.default)(e._minDate)):Promise.resolve(null),g=e._maxDate?Promise.resolve((0,import_dayjs.default)(e._maxDate)):Promise.resolve(null);isVariable(e._maxDate)&&(g=r(e._maxDate,i).then(C=>(0,import_dayjs.default)(C.value))),isVariable(e._minDate)&&(p=r(e._minDate,i).then(C=>(0,import_dayjs.default)(C.value)));const[h,f]=yield Promise.all([p,g]),_=Array.from({length:60},(C,b)=>b),v=C=>{if(!C||!h&&!f)return!1;const b=(0,import_dayjs.default)(C);return b.isBefore(h,"minute")||b.isAfter(f,"minute")},S=C=>{if(!C||!h&&!f)return{disabledHours:()=>[],disabledMinutes:()=>[],disabledSeconds:()=>[]};const b=(0,import_dayjs.default)(C),y=b.isSame(h,"day"),F=b.isSame(f,"day");return{disabledHours:()=>{const j=[];return y&&j.push(...Array.from({length:h.hour()},(k,T)=>T)),F&&j.push(...Array.from({length:24-f.hour()},(k,T)=>T+f.hour()+1)),j},disabledMinutes:j=>y&&j===h.hour()?_.filter(k=>k<h.minute()):F&&j===f.hour()?_.filter(k=>k>f.minute()):[],disabledSeconds:(j,k)=>y&&j===h.hour()&&k===h.minute()?_.filter(T=>T<h.second()):F&&j===f.hour()&&k===f.minute()?_.filter(T=>T>f.second()):[]}};a(()=>v),c(()=>S)}),d=P(x({utc:t},e),{disabledDate:n,disabledTime:l,showTime:e.showTime?{defaultValue:(0,import_dayjs.default)("00:00:00","HH:mm:ss")}:!1});return(0,import_jsx_runtime.jsx)(InternalDatePicker,P(x({},d),{value:o}))};DatePicker.ReadPretty=ReadPretty$d.DatePicker;DatePicker.RangePicker=function e(t){const{value:o,picker:r="date",format:i,showTime:n,timeFormat:a}=t,{t:l}=(0,import_react_i18next.useTranslation)(),c=(0,import_react.useFieldSchema)(),u=(0,import_react.useField)(),{utc:m=!0}=useDatePickerContext(),d=getDateRanges(),p=useCompile(),g=!c["x-filter-operator"],h=[{label:l("Today"),value:d.today},{label:l("Last week"),value:d.lastWeek},{label:l("This week"),value:d.thisWeek},{label:l("Next week"),value:d.nextWeek},{label:l("Last month"),value:d.lastMonth},{label:l("This month"),value:d.thisMonth},{label:l("Next month"),value:d.nextMonth},{label:l("Last quarter"),value:d.lastQuarter},{label:l("This quarter"),value:d.thisQuarter},{label:l("Next quarter"),value:d.nextQuarter},{label:l("Last year"),value:d.lastYear},{label:l("This year"),value:d.thisYear},{label:l("Next year"),value:d.nextYear},{label:l("Last 7 days"),value:d.last7Days},{label:l("Next 7 days"),value:d.next7Days},{label:l("Last 30 days"),value:d.last30Days},{label:l("Next 30 days"),value:d.next30Days},{label:l("Last 90 days"),value:d.last90Days},{label:l("Next 90 days"),value:d.next90Days}],f=o?inferPickerType(o==null?void 0:o[0]):r,_=(0,import_client.getPickerFormat)(f)||i,v=P(x({utc:m,presets:h},t),{format:(0,import_client.getDateTimeFormat)(f,_,n,a),picker:f,showTime:n?{defaultValue:[(0,import_dayjs.default)("00:00:00","HH:mm:ss"),(0,import_dayjs.default)("23:59:59","HH:mm:ss")]}:!1}),[S,C]=(0,import_react2.useState)(v);return g?(0,import_jsx_runtime.jsxs)(import_antd.Space.Compact,{children:[(0,import_jsx_runtime.jsx)(import_antd.Select,{role:"button","data-testid":"select-picker",style:{width:"100px"},popupMatchSelectWidth:!1,defaultValue:f,options:p([{label:'{{t("Date")}}',value:"date"},{label:'{{t("Month")}}',value:"month"},{label:'{{t("Quarter")}}',value:"quarter"},{label:'{{t("Year")}}',value:"year"}]),onChange:b=>{const y=(0,import_client.getPickerFormat)(b),F=(0,import_client.getDateTimeFormat)(b,y,n,a);u.setComponentProps({picker:b,format:y}),v.picker=b,v.format=F,C(v),c["x-component-props"]=P(x({},t),{picker:b,format:F}),u.value=void 0}}),(0,import_jsx_runtime.jsx)(InternalRangePicker,P(x({},S),{value:o}))]}):(0,import_jsx_runtime.jsx)(InternalRangePicker,x({},v))};DatePicker.FilterWithPicker=function e(t){const{picker:o="date",format:r,showTime:i,timeFormat:n}=t,a=isMobile(),{utc:l=!0}=useDatePickerContext(),c=Array.isArray(t.value)?t.value[0]:t.value,u=useCompile(),m=(0,import_react.useFieldSchema)(),d=c?inferPickerType(c):o,p=(0,import_client.getPickerFormat)(d)||r,g=P(x({utc:l,inputReadOnly:a},t),{underFilter:!0,showTime:i?{defaultValue:(0,import_dayjs.default)("00:00:00","HH:mm:ss")}:!1,format:(0,import_client.getDateTimeFormat)(d,p,i,n),picker:d,onChange:v=>{t.onChange(void 0),setTimeout(()=>{t.onChange(v)})}}),h=(0,import_react.useField)(),[f,_]=(0,import_react2.useState)(g);return(0,import_jsx_runtime.jsxs)(import_antd.Space.Compact,{style:{width:"100%"},children:[(0,import_jsx_runtime.jsx)(import_antd.Select,{role:"button","data-testid":"select-picker",style:{width:"100px"},popupMatchSelectWidth:!1,defaultValue:d,options:u([{label:'{{t("Date")}}',value:"date"},{label:'{{t("Month")}}',value:"month"},{label:'{{t("Quarter")}}',value:"quarter"},{label:'{{t("Year")}}',value:"year"}]),onChange:v=>{const S=(0,import_client.getPickerFormat)(v),C=(0,import_client.getDateTimeFormat)(v,S,i,n);h.setComponentProps({picker:v,format:S}),g.picker=v,g.format=C,_(g),m["x-component-props"]=P(x({},t),{picker:v,format:C}),h.value=null}}),(0,import_jsx_runtime.jsx)(InternalDatePicker,P(x({},f),{value:c}))]})};const useDateVariable=({operator:e,schema:t,noDisabled:o})=>{const{t:r}=(0,import_react_i18next.useTranslation)(),i=(e==null?void 0:e.value)||"",n=o?!1:!["DatePicker","DatePicker.RangePicker"].includes(t==null?void 0:t["x-component"]),a=[{key:"now",value:"now",label:r("Current time"),disabled:o?!1:(t==null?void 0:t["x-component"])!=="DatePicker"||i==="$dateBetween"},{key:"yesterday",value:"yesterday",label:r("Yesterday"),disabled:n},{key:"today",value:"today",label:r("Today"),disabled:n},{key:"tomorrow",value:"tomorrow",label:r("Tomorrow"),disabled:n},{key:"lastIsoWeek",value:"lastIsoWeek",label:r("Last week"),disabled:n},{key:"thisIsoWeek",value:"thisIsoWeek",label:r("This week"),disabled:n},{key:"nextIsoWeek",value:"nextIsoWeek",label:r("Next week"),disabled:n},{key:"lastMonth",value:"lastMonth",label:r("Last month"),disabled:n},{key:"thisMonth",value:"thisMonth",label:r("This month"),disabled:n},{key:"nextMonth",value:"nextMonth",label:r("Next month"),disabled:n},{key:"lastQuarter",value:"lastQuarter",label:r("Last quarter"),disabled:n},{key:"thisQuarter",value:"thisQuarter",label:r("This quarter"),disabled:n},{key:"nextQuarter",value:"nextQuarter",label:r("Next quarter"),disabled:n},{key:"lastYear",value:"lastYear",label:r("Last year"),disabled:n},{key:"thisYear",value:"thisYear",label:r("This year"),disabled:n},{key:"nextYear",value:"nextYear",label:r("Next year"),disabled:n},{key:"last7Days",value:"last7Days",label:r("Last 7 days"),disabled:n},{key:"next7Days",value:"next7Days",label:r("Next 7 days"),disabled:n},{key:"last30Days",value:"last30Days",label:r("Last 30 days"),disabled:n},{key:"next30Days",value:"next30Days",label:r("Next 30 days"),disabled:n},{key:"last90Days",value:"last90Days",label:r("Last 90 days"),disabled:n},{key:"next90Days",value:"next90Days",label:r("Next 90 days"),disabled:n}],l=(0,import_react2.useMemo)(()=>({label:r("Date variables"),value:"$nDate",key:"$nDate",disabled:a.every(c=>c.disabled),children:a}),[t==null?void 0:t["x-component"]]);return t?l:null},useDatetimeVariableContext=()=>{const{utc:e=!0}=useDatePickerContext();return{datetimeCtx:(0,import_react2.useMemo)(()=>getDateRanges({shouldBeString:!0,utc:e}),[e])}},useDatetimeVariable=({operator:e,schema:t,noDisabled:o,targetFieldSchema:r}={})=>{const{t:i}=(0,import_react_i18next.useTranslation)(),{getOperator:n}=useOperators(),a=(0,import_react2.useMemo)(()=>{const c=(e==null?void 0:e.value)||n(r==null?void 0:r.name)||"",u=o?!1:!["DatePicker.RangePicker"].includes(t==null?void 0:t["x-component"])&&!c,m=[{key:"now",value:"now",label:i("Current time"),disabled:o?!1:(t==null?void 0:t["x-component"])!=="DatePicker"||c==="$dateBetween"},{key:"yesterday",value:"yesterday",label:i("Yesterday"),disabled:u},{key:"today",value:"today",label:i("Today"),disabled:u},{key:"tomorrow",value:"tomorrow",label:i("Tomorrow"),disabled:u},{key:"lastIsoWeek",value:"lastIsoWeek",label:i("Last week"),disabled:u},{key:"thisIsoWeek",value:"thisIsoWeek",label:i("This week"),disabled:u},{key:"nextIsoWeek",value:"nextIsoWeek",label:i("Next week"),disabled:u},{key:"lastMonth",value:"lastMonth",label:i("Last month"),disabled:u},{key:"thisMonth",value:"thisMonth",label:i("This month"),disabled:u},{key:"nextMonth",value:"nextMonth",label:i("Next month"),disabled:u},{key:"lastQuarter",value:"lastQuarter",label:i("Last quarter"),disabled:u},{key:"thisQuarter",value:"thisQuarter",label:i("This quarter"),disabled:u},{key:"nextQuarter",value:"nextQuarter",label:i("Next quarter"),disabled:u},{key:"lastYear",value:"lastYear",label:i("Last year"),disabled:u},{key:"thisYear",value:"thisYear",label:i("This year"),disabled:u},{key:"nextYear",value:"nextYear",label:i("Next year"),disabled:u},{key:"last7Days",value:"last7Days",label:i("Last 7 days"),disabled:u},{key:"next7Days",value:"next7Days",label:i("Next 7 days"),disabled:u},{key:"last30Days",value:"last30Days",label:i("Last 30 days"),disabled:u},{key:"next30Days",value:"next30Days",label:i("Next 30 days"),disabled:u},{key:"last90Days",value:"last90Days",label:i("Last 90 days"),disabled:u},{key:"next90Days",value:"next90Days",label:i("Next 90 days"),disabled:u}];return{label:i("Date variables"),value:"$nDate",key:"$nDate",disabled:m.every(d=>d.disabled),children:m}},[t==null?void 0:t["x-component"],r]),{datetimeCtx:l}=useDatetimeVariableContext();return{datetimeSettings:a,datetimeCtx:l}},useRoleVariable=({collectionField:e,uiSchema:t,noDisabled:o,targetFieldSchema:r,maxDepth:i=0})=>{const{t:n}=(0,import_react_i18next.useTranslation)();return useBaseVariable({collectionField:e,uiSchema:t,maxDepth:i,name:"$nRole",title:n("Current role"),collectionName:"roles",noDisabled:o,targetFieldSchema:r,noChildren:!0})},useCurrentRoleVariable=({collectionField:e,uiSchema:t,noDisabled:o,targetFieldSchema:r,maxDepth:i=0}={})=>{var n;const{t:a}=(0,import_react_i18next.useTranslation)(),l=useAPIClient();return{currentRoleSettings:useBaseVariable({collectionField:e,uiSchema:t,maxDepth:i,name:"$nRole",title:a("Current role"),collectionName:"roles",noDisabled:o,targetFieldSchema:r,noChildren:!0}),currentRoleCtx:(n=l.auth)==null?void 0:n.role}},getURLSearchParams=e=>(e.startsWith("?")&&(e=e.slice(1)),import_qs.default.parse(e)||{}),getURLSearchParamsChildren=e=>Object.keys(e).map(t=>({label:t,value:t,key:t,isLeaf:!0})),useURLSearchParamsCtx=e=>{const[t]=(0,import_react2.useState)(()=>(0,import_reactive.observable)({}));return(0,import_react2.useMemo)(()=>{const o=getURLSearchParams(e);return(0,import_reactive.untracked)(()=>{Object.assign(t,o),Object.keys(t).forEach(r=>{o[r]===void 0&&delete t[r]})}),t},[t,e])},useURLSearchParamsVariable=(e={})=>{const t="$nURLSearchParams",{t:o}=(0,import_react_i18next.useTranslation)(),r=useLocationSearch(),{isVariableParsedInOtherContext:i}=useFlag(),n=useURLSearchParamsCtx(r),a=(0,import_react2.useMemo)(()=>import_lodash.default.isEmpty(n),[n]),l=(0,import_react2.useMemo)(()=>({label:getLabelWithTooltip(o("URL search params"),a?o("The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string."):""),value:t,key:t,isLeaf:!1,disabled:a,loadChildren:(c,u)=>q(void 0,null,function*(){const m=u?{[u]:void 0}:{};c.children=getURLSearchParamsChildren(x(x({},m),n))})}),[a,o,n]);return{name:t,urlSearchParamsSettings:l,urlSearchParamsCtx:n,defaultValue:void 0,shouldDisplay:!i}},useUserVariable=({collectionField:e,uiSchema:t,noDisabled:o,targetFieldSchema:r,maxDepth:i=3})=>{const{t:n}=(0,import_react_i18next.useTranslation)();return useBaseVariable({collectionField:e,uiSchema:t,maxDepth:i,name:"$user",title:n("Current user"),collectionName:"users",dataSource:DEFAULT_DATA_SOURCE_KEY,noDisabled:o,targetFieldSchema:r})},useCurrentUserVariable=({collectionField:e,uiSchema:t,noDisabled:o,targetFieldSchema:r,maxDepth:i=3}={})=>{var n;const{t:a}=(0,import_react_i18next.useTranslation)(),l=useCurrentUserContext();return{currentUserSettings:useBaseVariable({collectionField:e,uiSchema:t,maxDepth:i,name:"$user",title:a("Current user"),collectionName:"users",noDisabled:o,targetFieldSchema:r,dataSource:DEFAULT_DATA_SOURCE_KEY}),currentUserCtx:(n=l==null?void 0:l.data)==null?void 0:n.data}},useCurrentFormContext=({form:e}={})=>{const{form:t}=useFormBlockContext(),{isVariableParsedInOtherContext:o}=useFlag(),r=e||t;return{currentFormCtx:r==null?void 0:r.values,shouldDisplayCurrentForm:r&&!r.readPretty&&!o}},useCurrentFormVariable=({collectionField:e,schema:t,noDisabled:o,targetFieldSchema:r,form:i}={})=>{const{currentFormCtx:n,shouldDisplayCurrentForm:a}=useCurrentFormContext({form:i}),{t:l}=(0,import_react_i18next.useTranslation)(),{collectionName:c}=useFormBlockContext(),u=useDataSource();return{currentFormSettings:useBaseVariable({collectionField:e,uiSchema:t,targetFieldSchema:r,maxDepth:4,name:"$nForm",title:l("Current form"),collectionName:c,noDisabled:o,dataSource:u==null?void 0:u.key,returnFields:(m,d)=>m}),currentFormCtx:n,shouldDisplayCurrentForm:a}},useCurrentObjectContext=()=>{const{isInSubForm:e,isInSubTable:t}=useFlag()||{},{formValue:o,collection:r}=useSubFormValue();return{shouldDisplayCurrentObject:e||t,currentObjectCtx:o,collectionOfCurrentObject:r}},useCurrentObjectVariable=({collectionField:e,schema:t,noDisabled:o,targetFieldSchema:r}={})=>{const i=useCollection(),{t:n}=(0,import_react_i18next.useTranslation)(),{shouldDisplayCurrentObject:a,currentObjectCtx:l,collectionOfCurrentObject:c}=useCurrentObjectContext(),u=useBaseVariable({collectionField:e,uiSchema:t,targetFieldSchema:r,maxDepth:4,name:"$iteration",title:n("Current object"),collectionName:(c==null?void 0:c.name)||(i==null?void 0:i.name),noDisabled:o,dataSource:i==null?void 0:i.dataSource,returnFields:(m,d)=>m});return{shouldDisplayCurrentObject:a,currentObjectCtx:l,currentObjectSettings:u}},useParentObjectContext=()=>{const{parent:e}=useSubFormValue(),{value:t,collection:o}=e||{},{isInSubForm:r,isInSubTable:i}=useFlag()||{};return{shouldDisplayParentObject:(r||i)&&!!o,parentObjectCtx:t,collectionName:o==null?void 0:o.name,dataSource:o==null?void 0:o.dataSource}},useParentObjectVariable=({collectionField:e,schema:t,noDisabled:o,targetFieldSchema:r}={})=>{const{t:i}=(0,import_react_i18next.useTranslation)(),{shouldDisplayParentObject:n,parentObjectCtx:a,collectionName:l,dataSource:c}=useParentObjectContext();return{parentObjectSettings:useBaseVariable({collectionField:e,uiSchema:t,targetFieldSchema:r,maxDepth:4,name:"$nParentIteration",title:i("Parent object"),collectionName:l,noDisabled:o,dataSource:c,returnFields:(u,m)=>u}),shouldDisplayParentObject:n,parentObjectCtx:a,collectionName:l}},useParentPopupVariableContext=()=>{const{value:e,title:t,collection:o}=useParentPopupRecord()||{},{isVariableParsedInOtherContext:r}=useFlag();return{parentPopupRecordCtx:e,shouldDisplayParentPopupRecord:!!e&&!r,collectionName:o==null?void 0:o.name,dataSource:o==null?void 0:o.dataSource,defaultValue:void 0,title:t}},useParentPopupVariable=(e={})=>{const{parentPopupRecordCtx:t,shouldDisplayParentPopupRecord:o,collectionName:r,dataSource:i,defaultValue:n,title:a}=useParentPopupVariableContext();return{settings:useBaseVariable({collectionField:e.collectionField,uiSchema:e.schema,name:"$nParentPopupRecord",title:a,collectionName:r,noDisabled:e.noDisabled,targetFieldSchema:e.targetFieldSchema,dataSource:i}),parentPopupRecordCtx:t,shouldDisplayParentPopupRecord:o,collectionName:r,dataSource:i,defaultValue:n}},ParentCollectionContext=(0,import_react2.createContext)(null);ParentCollectionContext.displayName="ParentCollectionContext";const ParentCollectionProvider=e=>{const t=useCollection();return(0,import_jsx_runtime.jsx)(ParentCollectionContext.Provider,{value:t,children:e.children})},useParentCollection=()=>(0,import_react2.useContext)(ParentCollectionContext),AssociationProvider=e=>{const{name:t,children:o}=e,r=useCollectionManager().getCollectionName(t);return r?(0,import_jsx_runtime.jsx)(CollectionProvider,{name:String(t).split(".")[0],children:(0,import_jsx_runtime.jsx)(ParentCollectionProvider,{children:(0,import_jsx_runtime.jsx)(CollectionFieldProvider,{name:t,children:(0,import_jsx_runtime.jsx)(CollectionProvider,{name:r,children:o})})})}):(0,import_jsx_runtime.jsx)(CollectionDeletedPlaceholder,{type:"Collection",name:t})},useAssociationName=()=>{const e=useCollectionField();return e!=null&&e.target?`${e.collectionName}.${e.name}`:null},useCurrentParentRecordContext=()=>{var e,t;const o=useCollectionRecord(),{name:r,dataSource:i}=useParentCollection()||{},n=useCollection(),{isInSubForm:a,isInSubTable:l}=useFlag()||{},c=r?i:n==null?void 0:n.dataSource,u=useCollectionField();return{currentParentRecordCtx:((e=o==null?void 0:o.parentRecord)==null?void 0:e.data)||(o==null?void 0:o.data),shouldDisplayCurrentParentRecord:!!((t=o==null?void 0:o.parentRecord)!=null&&t.data)&&!a&&!l&&u,collectionName:r||(n==null?void 0:n.name),dataSource:c}},useCurrentParentRecordVariable=(e={})=>{const{t}=(0,import_react_i18next.useTranslation)(),{currentParentRecordCtx:o,shouldDisplayCurrentParentRecord:r,collectionName:i,dataSource:n}=useCurrentParentRecordContext();return{currentParentRecordSettings:useBaseVariable({collectionField:e.collectionField,uiSchema:e.schema,name:"$nParentRecord",title:t("Parent record"),collectionName:i,noDisabled:e.noDisabled,targetFieldSchema:e.targetFieldSchema,dataSource:n}),currentParentRecordCtx:o,shouldDisplayCurrentParentRecord:r,collectionName:i,dataSource:n}},usePopupVariableContext=()=>{const{value:e,title:t,collection:o}=useCurrentPopupRecord()||{},{isVariableParsedInOtherContext:r}=useFlag();return{popupRecordCtx:e,shouldDisplayPopupRecord:!!e&&!r,collectionName:o==null?void 0:o.name,dataSource:o==null?void 0:o.dataSource,defaultValue:void 0,title:t}},usePopupVariable=(e={})=>{const{popupRecordCtx:t,shouldDisplayPopupRecord:o,collectionName:r,dataSource:i,defaultValue:n,title:a}=usePopupVariableContext();return{settings:useBaseVariable({collectionField:e.collectionField,uiSchema:e.schema,name:"$nPopupRecord",title:a,collectionName:r,noDisabled:e.noDisabled,targetFieldSchema:e.targetFieldSchema,dataSource:i}),popupRecordCtx:t,shouldDisplayPopupRecord:o,collectionName:r,dataSource:i,defaultValue:n}},useVariableOptions=({collectionField:e,form:t,uiSchema:o,operator:r,noDisabled:i,targetFieldSchema:n,record:a})=>{var l;const{filterVariables:c=()=>!0}=useVariables$1()||{},u=(l=a==null?void 0:a.__parent)==null?void 0:l.__collectionName,{currentUserSettings:m}=useCurrentUserVariable({maxDepth:3,uiSchema:o,collectionField:e,noDisabled:i,targetFieldSchema:n}),{currentRoleSettings:d}=useCurrentRoleVariable({uiSchema:o,collectionField:e,noDisabled:i,targetFieldSchema:n}),{apiTokenSettings:p}=useAPITokenVariable({noDisabled:i}),{datetimeSettings:g}=useDatetimeVariable({operator:r,schema:o,noDisabled:!0,targetFieldSchema:n}),{currentFormSettings:h,shouldDisplayCurrentForm:f}=useCurrentFormVariable({schema:o,collectionField:e,noDisabled:i,targetFieldSchema:n,form:t}),{currentObjectSettings:_,shouldDisplayCurrentObject:v}=useCurrentObjectVariable({collectionField:e,schema:o,noDisabled:i,targetFieldSchema:n}),{parentObjectSettings:S,shouldDisplayParentObject:C}=useParentObjectVariable({collectionField:e,schema:o,noDisabled:i,targetFieldSchema:n}),{currentRecordSettings:b,shouldDisplayCurrentRecord:y}=useCurrentRecordVariable({schema:o,collectionField:e,noDisabled:i,targetFieldSchema:n}),{settings:F,shouldDisplayPopupRecord:j}=usePopupVariable({schema:o,collectionField:e,noDisabled:i,targetFieldSchema:n}),{settings:k,shouldDisplayParentPopupRecord:T}=useParentPopupVariable({schema:o,collectionField:e,noDisabled:i,targetFieldSchema:n}),{currentParentRecordSettings:O,shouldDisplayCurrentParentRecord:N}=useCurrentParentRecordVariable({schema:o,collectionName:u,collectionField:e,noDisabled:i,targetFieldSchema:n}),{urlSearchParamsSettings:L,shouldDisplay:D}=useURLSearchParamsVariable();return(0,import_react2.useMemo)(()=>[m,d,p,g,f&&h,v&&_,C&&S,y&&b,N&&O,j&&F,T&&k,D&&L].filter(Boolean).filter(c),[m,d,p,g,f,h,v,_,C,S,y,b,N,O,j,F,D,L])},RemoveConditionContext=(0,import_react2.createContext)(null);RemoveConditionContext.displayName="RemoveConditionContext";const FilterContext$1=(0,import_react2.createContext)(null);FilterContext$1.displayName="FilterContext";const FilterLogicContext=(0,import_react2.createContext)(null);FilterLogicContext.displayName="FilterLogicContext";const findOption$1=(e=[],t)=>{var o;let r=t,i;return(o=e==null?void 0:e.forEach)==null||o.call(e,n=>{const a=r.find(l=>l.name===n);a&&(i=a),r=(a==null?void 0:a.children)||[]}),i},useValues$1=()=>{const{name:e}=useCollection_deprecated(),{getCollectionJoinField:t}=useCollectionManager_deprecated(),o=(0,import_react.useField)(),{options:r,collectionName:i,field:n}=(0,import_react2.useContext)(FilterContext$1)||{},a=(0,import_flat.default)(o.value||{}),l=Object.keys(a).shift()||"",c=(0,import_react2.useMemo)(()=>{const[g=""]=l.split(".$");return t(`${i||e}.${g}`)},[e,l]),u=(0,import_react2.useCallback)(()=>{var g,h,f,_;o.value=import_flat.default.unflatten({[`${(g=o.data.dataIndex)==null?void 0:g.join(".")}.${(f=(h=o.data)==null?void 0:h.operator)==null?void 0:f.value}`]:(_=o.data)==null?void 0:_.value})},[o]);(0,import_react2.useEffect)(()=>{var g;if(o.data=o.data||{},!l||!r)return;const[h="",f=""]=l.split(".$"),[_]=f.split(".",2),v=h.split("."),S=findOption$1(v,r),C=S==null?void 0:S.operators,b=(g=C==null?void 0:C.find)==null?void 0:g.call(C,y=>y.value===`$${_}`);if(o.data.dataIndex=v,(v==null?void 0:v.length)>1){const y=v.concat();y.pop();const F=t(`${e}.${y.join(".")}`);n.collectionName=F==null?void 0:F.target}else n.collectionName=null;o.data.operators=C,o.data.operator=b,o.data.schema=(0,import_shared.merge)(S==null?void 0:S.schema,b==null?void 0:b.schema),o.data.value=(0,import_get.default)((0,import_flat.unflatten)(o.value),`${h}.$${_}`)},[o.path]);const m=(0,import_react2.useCallback)(g=>{var h;const f=findOption$1(g,r),_=(h=f==null?void 0:f.operators)==null?void 0:h[0];o.data=o.data||{},o.data.operators=f==null?void 0:f.operators,o.data.operator=_;const v=(0,import_cloneDeep.default)(f==null?void 0:f.schema),S=(0,import_cloneDeep.default)(_==null?void 0:_.schema);if(o.data.schema=(0,import_shared.merge)(v,S),o.data.dataIndex=g,(g==null?void 0:g.length)>1){const C=g.concat();C.pop();const b=t(`${e}.${C.join(".")}`);n.collectionName=b==null?void 0:b.target}else n.collectionName=null;o.data.value=_!=null&&_.noValue?_.default||!0:void 0,u()},[u,o,r]),d=(0,import_react2.useCallback)(g=>{var h,f,_;const v=(_=(f=(h=o.data)==null?void 0:h.operators)==null?void 0:f.find)==null?void 0:_.call(f,y=>y.value===g);o.data.operator=v;const S=findOption$1(o.data.dataIndex,r),C=(0,import_cloneDeep.default)(S==null?void 0:S.schema),b=(0,import_cloneDeep.default)(v==null?void 0:v.schema);o.data.schema=(0,import_shared.merge)(C,b),o.data.value=v.noValue?v.default||!0:void 0,u()},[u,o.data,r]),p=(0,import_react2.useCallback)(g=>{o.data.value=g,u()},[u,o.data]);return P(x({fields:r},(o==null?void 0:o.data)||{}),{collectionField:c,setDataIndex:m,setOperator:d,setValue:p})},useBlockCollection=()=>{const e=useDataBlockProps();return{name:(e==null?void 0:e.collection)||(e==null?void 0:e.resource)}},useIsSameOrChildCollection=()=>{const{getChildrenCollections:e}=useCollectionManager_deprecated();return(t,o)=>{if(t===o)return!0;const r=e(o);return r==null?void 0:r.some(i=>i.name===t)}},getChildren=(e,{schema:t,depth:o,maxDepth:r,loadChildren:i,compile:n},a,l)=>e.map(c=>{const u=!l(c.target,a==null?void 0:a.target);return c.target?o>=r?null:{key:c.name,value:c.name,label:n(c.title),disabled:u,isLeaf:!0,field:c,depth:o,loadChildren:i}:{key:c.name,value:c.name,label:n(c.title),disabled:u,isLeaf:!0,depth:o}}).filter(Boolean),useContextAssociationFields=({schema:e,maxDepth:t=3,contextCollectionName:o,collectionField:r})=>{const{t:i}=(0,import_react_i18next.useTranslation)(),n=useCompile(),a=useGetFilterOptions(),l=useIsSameOrChildCollection(),c=u=>{var m;if(!((m=u.field)!=null&&m.target))return new Promise(p=>{(0,import_client.error)("Must be set field target"),u.children=[],p(void 0)});const d=u.field.target;return new Promise(p=>{setTimeout(()=>{const g=getChildren(a(d).filter(h=>["hasOne","hasMany","belongsTo","belongsToMany","belongsToArray"].includes(h.type)),{schema:e,depth:u.depth+1,maxDepth:t,loadChildren:c,compile:n},r,l)||[];if(g.length===0){u.disabled=!0,u.children=[],p();return}u.children=g,p()},5)})};return(0,import_react2.useMemo)(()=>({label:i("Table selected records"),value:"$context",key:"$context",isLeaf:!1,field:{target:o},depth:0,loadChildren:c}),[e==null?void 0:e["x-component"]])},VariableInput=e=>{const{value:t,onChange:o,renderSchemaComponent:r,style:i,schema:n,className:a,contextCollectionName:l,collectionField:c,shouldChange:u,form:m,record:d,returnScope:p=import_lodash.default.identity,targetFieldSchema:g,noDisabled:h,hideVariableButton:f}=e,{name:_}=useBlockCollection(),v=useVariableScope(),{operator:S,schema:C=c==null?void 0:c.uiSchema}=useValues$1(),b=useVariableOptions({collectionField:c,form:m,record:d,operator:S,uiSchema:C,targetFieldSchema:g,noDisabled:h}),y=useContextAssociationFields({schema:n,maxDepth:2,contextCollectionName:l,collectionField:c}),{compatOldVariables:F}=useCompatOldVariables({collectionField:c,uiSchema:C,targetFieldSchema:g,blockCollectionName:_});l&&b.every(k=>k.value!==y.value)&&b.push(y);const j=(0,import_react2.useCallback)((k,T)=>{if(!u)return o(k);setTimeout(()=>q(void 0,null,function*(){(yield u(k,T))&&o(k)}))},[o,u]);return(0,import_jsx_runtime.jsx)(Variable.Input,{className:a,value:t,onChange:j,scope:p(F(import_lodash.default.isEmpty(v)?b:v,{value:t})),style:i,changeOnSelect:!0,hideVariableButton:f,children:(0,import_jsx_runtime.jsx)(r,{value:t,onChange:o})})},getShouldChange=({collectionField:e,variables:t,localVariables:o,getAllCollectionsInheritChain:r})=>{const i=e?r(e.target):[];return(n,a)=>q(void 0,null,function*(){if(import_lodash.default.isString(n)&&n.includes("$nRole")||!isVariable(n)||!t||!e||e.interface==="json")return!0;const l=a[a.length-1];if(l&&import_lodash.default.isEmpty(l.children)&&!l.loadChildren)return!0;const c=yield t.getCollectionField(n,o);return!(!e||["o2o","o2m","oho"].includes(c==null?void 0:c.interface)||e.target&&c!=null&&c.target&&!i.includes(c==null?void 0:c.target))})};function useCompatOldVariables(e){const{uiSchema:t,collectionField:o,noDisabled:r,targetFieldSchema:i,blockCollectionName:n}=e,{t:a}=(0,import_react_i18next.useTranslation)(),{currentUserSettings:l}=useCurrentUserVariable({maxDepth:1,uiSchema:t,collectionField:o,noDisabled:r,targetFieldSchema:i}),{currentRecordSettings:c}=useCurrentRecordVariable({schema:t,collectionField:o,noDisabled:r,targetFieldSchema:i});return{compatOldVariables:(0,import_react2.useCallback)((u,{value:m})=>{if(!isVariable(m))return u;u=[...u];const d={value:"$system",key:"$system",label:a("System variables"),isLeaf:!1,children:[{value:"now",key:"now",label:a("Current time"),isLeaf:!0,depth:1}],depth:0},p={value:"currentTime",label:a("Current time"),children:null};if(m.includes("$system")&&u.push(d),m.includes(`${n}.`)){const g=u.find(h=>h.value==="$nForm"||h.value==="$nRecord");g&&(g.value=n)}if(m.includes("$form")){const g=u.find(h=>h.value==="$nForm");g&&(g.value="$form")}if(m.includes("currentUser")){const g=u.find(h=>h.value==="$user");g?g.value="currentUser":u.unshift(P(x({},l),{value:"currentUser"}))}if(m.includes("currentRecord")){const g=u.find(h=>h.value==="$nRecord");g?g.value="currentRecord":u.unshift(P(x({},c),{value:"currentRecord"}))}if(m.includes("currentTime")&&u.push(p),m.includes("$date")){const g=u.find(h=>h.value==="$nDate");g&&(g.value="$date")}return u},[n])}}const AsDefaultTemplate=import_react2.default.forwardRef((e,t)=>{var o;const r=import_antd_v5.ArrayBase.useArray(),i=import_antd_v5.ArrayBase.useIndex(e.index),{t:n}=(0,import_react_i18next.useTranslation)();return(0,import_jsx_runtime.jsx)(import_antd.Switch,P(x({},e),{checkedChildren:n("Default"),unCheckedChildren:n("Default"),checked:(o=r==null?void 0:r.field)==null?void 0:o.value[i].default,style:{transition:"all 0.25s ease-in-out",color:"rgba(0, 0, 0, 0.8)",fontSize:16,marginLeft:6,marginBottom:3},onChange:(a,l)=>{var c;l.stopPropagation(),r.field.value.splice(i,1,P(x({},(c=r==null?void 0:r.field)==null?void 0:c.value[i]),{default:a})),r.field.value.forEach((u,m)=>{var d;m!==i&&r.field.value.splice(m,1,P(x({},(d=r==null?void 0:r.field)==null?void 0:d.value[m]),{default:!1}))})},onClick:(a,l)=>{l.stopPropagation()}}))});AsDefaultTemplate.displayName="AsDefaultTemplate";const useStyles$d=genStyleHook("nb-array-collapse",e=>{const{componentCls:t}=e;return{[t]:{marginBottom:"10px"}}}),DataTemplateTitle=(0,import_react.observer)(e=>{var t;const o=import_antd_v5.ArrayBase.useArray(),r=import_antd_v5.ArrayBase.useIndex(e.index),{t:i}=(0,import_react_i18next.useTranslation)(),n=(t=o==null?void 0:o.field)==null?void 0:t.value[r];return(0,import_react2.useEffect)(()=>{var a,l;n.key||(n.key=(0,import_shared.uid)()),n.title||(n.title=`${i("Template name")} ${(l=(a=o==null?void 0:o.field)==null?void 0:a.value)==null?void 0:l.length}`)},[]),(0,import_jsx_runtime.jsx)(import_antd.Input.TextArea,{value:n.title,placeholder:i("Template name"),onChange:a=>{a.stopPropagation(),n.title=a.target.value},onBlur:a=>{a.stopPropagation(),n.title=a.target.value},autoSize:!0,style:{width:"70%",border:"none"},onClick:a=>{a.stopPropagation()}})}),isAdditionComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"Addition"))>-1},isIndexComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"Index"))>-1},isRemoveComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"Remove"))>-1},isMoveUpComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"MoveUp"))>-1},isMoveDownComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"MoveDown"))>-1},isCopyComponent$1=e=>{var t,o;return((o=(t=e["x-component"])==null?void 0:t.indexOf)==null?void 0:o.call(t,"Copy"))>-1},isOperationComponent$1=e=>isAdditionComponent$1(e)||isRemoveComponent$1(e)||isMoveDownComponent$1(e)||isMoveUpComponent$1(e)||isCopyComponent$1(e),range$1=e=>Array.from({length:e}).map((t,o)=>o),takeDefaultActiveKeys$1=(e,t)=>e<t?range$1(e):range$1(t),insertActiveKeys$1=(e,t)=>e.length<=t?e.concat(t):e.reduce((o,r)=>r<t?o.concat(r):r===t?o.concat([r,r+1]):o.concat(r+1),[]),ArrayCollapse$1=(0,import_react.observer)(e=>{const{componentCls:t,hashId:o}=useStyles$d(),r=(0,import_react.useField)(),i=Array.isArray(r.value)?r.value:[],[n,a]=(0,import_react2.useState)(takeDefaultActiveKeys$1(i.length,e.defaultOpenPanelCount)),l=(0,import_react.useFieldSchema)();if((0,import_react2.useEffect)(()=>{!r.modified&&i.length&&a(takeDefaultActiveKeys$1(i.length,e.defaultOpenPanelCount))},[i.length,r]),!l)throw new Error("can not found schema object");const c=()=>l.reduceProperties((d,p,g)=>isAdditionComponent$1(p)?(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:p,name:g}):d,null),u=()=>{if(!i.length)return(0,import_jsx_runtime.jsx)(import_antd.Card,{className:(0,import_classnames.default)(t,o,e.className),children:(0,import_jsx_runtime.jsx)(import_antd.Empty,{})})},m=()=>(0,import_jsx_runtime.jsx)(import_antd.Collapse,P(x({},e),{activeKey:n,onChange:d=>a((0,import_shared.toArr)(d).map(Number)),className:(0,import_classnames.default)(t,o,e.className),children:i.map((d,p)=>{const g=Array.isArray(l.items)?l.items[p]||l.items[0]:l.items,h=r.query(`${r.address}.${p}`).get("componentProps"),f=g["x-component-props"],_=()=>{const C=`${(h==null?void 0:h.header)||f.header||r.title}`,b=r.address.concat(p),y=r.form.queryFeedbacks({type:"error",address:`${b}.**`});return(0,import_jsx_runtime.jsxs)(import_antd_v5.ArrayBase.Item,{index:p,record:()=>{var F;return(F=r.value)==null?void 0:F[p]},children:[(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:g,name:p,filterProperties:F=>!!isIndexComponent$1(F),onlyRenderProperties:!0}),y.length?(0,import_jsx_runtime.jsx)(import_antd.Badge,{size:"small",className:"errors-badge",count:y.length,children:C}):(0,import_jsx_runtime.jsx)(DataTemplateTitle,{item:d.initialValue||d,index:p})]})},v=(0,import_jsx_runtime.jsxs)(import_antd_v5.ArrayBase.Item,{index:p,record:d,children:[(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:g,name:p,filterProperties:C=>!!isOperationComponent$1(C),onlyRenderProperties:!0}),h==null?void 0:h.extra]}),S=(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:g,name:p,filterProperties:C=>!(isIndexComponent$1(C)||isOperationComponent$1(C))});return(0,import_react2.createElement)(import_antd.Collapse.Panel,P(x(x({},f),h),{forceRender:!0,key:p,header:_(),extra:v}),(0,import_jsx_runtime.jsx)(import_antd_v5.ArrayBase.Item,{index:p,record:d,children:S},p))})}));return(0,import_jsx_runtime.jsxs)(import_antd_v5.ArrayBase,{onAdd:d=>{a(insertActiveKeys$1(n,d))},onRemove:()=>{r.initialValue=r.value},children:[u(),m(),c()]})},{displayName:"ArrayCollapse"}),CollapsePanel$1=({children:e})=>(0,import_jsx_runtime.jsx)(import_react2.Fragment,{children:e});CollapsePanel$1.displayName="CollapsePanel";ArrayCollapse$1.defaultProps={defaultOpenPanelCount:5};ArrayCollapse$1.displayName="ArrayCollapse";ArrayCollapse$1.CollapsePanel=CollapsePanel$1;import_antd_v5.ArrayBase.mixin(ArrayCollapse$1);ArrayCollapse$1.Copy=import_react2.default.forwardRef((e,t)=>{var o;const r=(0,import_react.useField)(),i=import_antd_v5.ArrayBase.useArray(),n=import_antd_v5.ArrayBase.useIndex(e.index);return!i||((o=i.field)==null?void 0:o.pattern)!=="editable"?null:(0,import_jsx_runtime.jsx)(import_icons.CopyOutlined,P(x({},e),{style:{transition:"all 0.25s ease-in-out",color:"rgba(0, 0, 0, 0.8)",fontSize:"16px",marginLeft:6},ref:t,onClick:a=>{var l,c;if(r!=null&&r.disabled||(a.stopPropagation(),(l=i.props)!=null&&l.disabled))return;const u=(0,import_lodash.clone)((c=i==null?void 0:i.field)==null?void 0:c.value[n]);i.field.push(u),e.onClick&&e.onClick(a)}}))});ArrayCollapse$1.Copy.displayName="ArrayCollapse.Copy";const SchemaSettingsDataScope=function e(t){const{t:o}=(0,import_react_i18next.useTranslation)(),{getFields:r}=useCollectionFilterOptionsV2(t.collectionName),i=useRecord(),{form:n}=useFormBlockContext(),a=useVariables$1(),l=useLocalVariables$1(),{getAllCollectionsInheritChain:c}=useCollectionManager_deprecated(),{isInSubForm:u,isInSubTable:m}=useFlag()||{},d=(0,import_react2.useCallback)(g=>(0,import_jsx_runtime.jsx)(DatePickerProvider,{value:{utc:!1},children:(0,import_jsx_runtime.jsx)(VariableInput,P(x({},g),{form:n,record:i,noDisabled:!0,shouldChange:getShouldChange({collectionField:g.collectionField,variables:a,localVariables:l,getAllCollectionsInheritChain:c})}))}),[n,c,l,i,a]),p=()=>({type:"object",title:o("Set the data scope"),properties:{filter:{enum:t.collectionFilterOption||r(),"x-decorator":g=>(0,import_jsx_runtime.jsx)(BaseVariableProvider,P(x({},g),{children:(0,import_jsx_runtime.jsx)(FlagProvider,{isInSubForm:u,isInSubTable:m,children:g.children})})),"x-decorator-props":{isDisabled},"x-component":"Filter","x-component-props":{collectionName:t.collectionName,dynamicComponent:t.dynamicComponent||d}}}});return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:o("Set the data scope"),initialValues:{filter:t.defaultFilter},schema:p,onSubmit:t.onSubmit,noRecord:t.noRecord})};function isDisabled(e){var t,o;const{option:r,collectionField:i,uiSchema:n}=e;return!n||!i?!0:i.interface==="json"||r.target?!1:["input","markdown","richText","textarea","username"].includes(i.interface)?!["string","number"].includes((t=r.schema)==null?void 0:t.type):i.interface&&r.interface?i.interface!==r.interface:(n==null?void 0:n["x-component"])!==((o=r.schema)==null?void 0:o["x-component"])}(0,import_react.observer)(()=>{const{getCollectionFields:e,getCollectionField:t,getCollection:o,isTitleField:r}=useCollectionManager_deprecated(),i=(0,import_react.useField)(),n=(0,import_react.useFieldSchema)(),{t:a}=(0,import_react_i18next.useTranslation)(),{dn:l}=useDesignable(),c=useCompile(),{formSchema:u,data:m}=n["x-designer-props"],{form:d}=useFormBlockContext(),p=i.componentProps.service.resource,g=o(p),h=e(p);if(!m)return(0,import_client.error)("data is required"),null;const f=()=>{var b,y;return((y=(b=m.config)==null?void 0:b[p])==null?void 0:y.filter)||{}},_=b=>{try{import_lodash.default.set(m,`config.${p}.filter`,removeNullCondition(b))}catch(y){(0,import_client.error)(y)}},v=()=>{var b,y;return((y=(b=m.config)==null?void 0:b[p])==null?void 0:y.titleField)||(g==null?void 0:g.titleField)||"id"},S=b=>{try{import_lodash.default.set(m,`config.${p}.titleField`,b)}catch(y){(0,import_client.error)(y)}},C=h.filter(b=>r(b)).map(b=>{var y;return{value:b==null?void 0:b.name,label:c((y=b==null?void 0:b.uiSchema)==null?void 0:y.title)||(b==null?void 0:b.name)}});return(0,import_jsx_runtime.jsxs)(GeneralSchemaDesigner,{draggable:!1,children:[(0,import_jsx_runtime.jsx)(SchemaSettingsDataScope,{collectionName:p,defaultFilter:f(),form:d,onSubmit:({filter:b})=>{_(b);try{i.query("fieldReaction.items.*.layout.dataId").forEach(y=>{y.componentProps.service.resource===p&&(y.componentProps.service.params={filter:import_lodash.default.isEmpty(b)?{}:removeNullCondition(mergeFilter([b,getSelectedIdFilter(i.value)],"$or"))})})}catch(y){(0,import_client.error)(y)}u["x-data-templates"]=m,l.emit("patch",{schema:{"x-uid":u["x-uid"],"x-data-templates":m}}),l.refresh()}}),(0,import_jsx_runtime.jsx)(SelectItem,{title:a("Title field"),options:C,value:v(),onChange:b=>{S(b);try{i.query("fieldReaction.items.*.layout.dataId").forEach(F=>{F.componentProps.service.resource===p&&(F.componentProps.fieldNames.label=b,F.componentProps.targetField=t(`${p}.${b||(g==null?void 0:g.titleField)||"id"}`))})}catch(F){console.error(F)}u["x-data-templates"]=m;const y={"x-uid":u["x-uid"],"x-data-templates":m};l.emit("patch",{schema:y}),l.refresh()}},"title-field")]})},{displayName:"Designer"});function getSelectedIdFilter(e){return e?{id:{$eq:e}}:null}function SelectItem(e){const t=e,{title:o,options:r,value:i,onChange:n}=t,a=K(t,["title","options","value","onChange"]);return(0,import_jsx_runtime.jsx)(SchemaSettingsItem,P(x({title:o},a),{children:(0,import_jsx_runtime.jsxs)("div",{style:{alignItems:"center",display:"flex",justifyContent:"space-between"},children:[o,(0,import_jsx_runtime.jsx)(import_antd.Select,x({popupMatchSelectWidth:!1,bordered:!1,value:i,onChange:n,options:r,style:{textAlign:"right",minWidth:100}},a))]})}))}const Tree=(0,import_react.connect)(import_antd.Tree,(0,import_react.mapProps)({value:"checkedKeys",dataSource:"treeData"}));Tree.displayName="Tree";const compatibleDataId=(e,t)=>e==null?void 0:e.map(o=>{var r;const i=o,{dataId:n}=i,a=K(i,["dataId"]),l=x({},a);return n&&(l.dataScope={$and:[{id:{$eq:n}}]},l.titleField=(l==null?void 0:l.titleField)||((r=t==null?void 0:t[o.collection])==null?void 0:r.titleField)||"id"),l}),FormDataTemplates=withDynamicSchemaProps((0,import_react.observer)(e=>{const{formSchema:t,designerCtx:o,defaultValues:r,collectionName:i}=useProps(e),{collectionList:n,getEnableFieldTree:a,getOnLoadData:l,getOnCheck:c,getScopeDataSource:u,useTitleFieldDataSource:m}=useCollectionState(i),{getCollection:d,getCollectionField:p}=useCollectionManager_deprecated(),{t:g}=(0,import_react_i18next.useTranslation)(),h=(0,import_react2.useMemo)(()=>(0,import_reactive.observable)(P(x({},r),{items:compatibleDataId((r==null?void 0:r.items)||[],r==null?void 0:r.config)})),[]),f=y=>{var F;const j=d(y);return p(`${y}.${((F=h==null?void 0:h.config[y])==null?void 0:F.titleField)||(j==null?void 0:j.titleField)||"id"}`)},_=y=>{var F,j;const k=d(y);return{label:getLabel(((j=(F=h.config)==null?void 0:F[y])==null?void 0:j.titleField)||(k==null?void 0:k.titleField)||"id"),value:"id"}},v=(y,F)=>{var j,k;const T=(k=(j=h.config)==null?void 0:j[y])==null?void 0:k.filter;return import_lodash.default.isEmpty(T)?{}:removeNullCondition(mergeFilter([T,getSelectedIdFilter(F)],"$or"))},S=(0,import_react2.useMemo)(()=>({ArrayCollapse:ArrayCollapse$1}),[]),C=(0,import_react2.useMemo)(()=>({getEnableFieldTree:a,getTargetField:f,getFieldNames:_,getFilter:v,getResource,getOnLoadData:l,getOnCheck:c,collectionName:i,getScopeDataSource:u,useTitleFieldDataSource:m}),[]),b=(0,import_react2.useMemo)(()=>({type:"object",properties:{items:{type:"array",default:h==null?void 0:h.items,"x-component":"ArrayCollapse","x-decorator":"FormItem","x-component-props":{accordion:!0},items:{type:"object","x-component":"ArrayCollapse.CollapsePanel","x-component-props":{extra:[(0,import_jsx_runtime.jsx)(AsDefaultTemplate,{},"0")]},properties:{layout:{type:"void","x-component":"FormLayout","x-component-props":{layout:"vertical"},properties:{collection:{type:"string",title:'{{ t("Collection") }}',required:!0,description:g("If collection inherits, choose inherited collections as templates"),default:"{{ collectionName }}","x-display":n.length>1?"visible":"hidden","x-decorator":"FormItem","x-component":"Select","x-component-props":{options:n}},dataScope:{type:"object",title:'{{ t("Filter out a single piece or a group of records as a template") }}',"x-decorator":"FormItem","x-component":"Filter","x-component-props":{dynamicComponent:VariableInput},"x-decorator-props":{style:{marginBottom:"0px"}},required:!0,"x-reactions":[{dependencies:[".collection"],fulfill:{state:{disabled:"{{ !$deps[0] }}"},schema:{enum:"{{ getScopeDataSource($deps[0]) }}"}}}]},titleField:{type:"string","x-decorator":"FormItem",title:'{{ t("Title field") }}',"x-decorator-props":{tooltip:'{{t("The title field is used to identify the template record")}}'},"x-component":"Select",required:!0,"x-reactions":"{{useTitleFieldDataSource}}"},syncFromForm:{type:"void",title:'{{ t("Sync from form fields") }}',"x-component":"Action.Link","x-component-props":{type:"primary",style:{float:"right",position:"relative",zIndex:1200},useAction:()=>useSyncFromForm(t)}},fields:{type:"array",title:'{{ t("Template fields") }}',"x-decorator-props":{tooltip:'{{t("The selected fields will automatically populate the form")}}'},required:!0,description:g("Only the selected fields will be used as the initialization data for the form"),"x-decorator":"FormItem","x-component":Tree,"x-component-props":{treeData:[],checkable:!0,checkStrictly:!0,selectable:!1,loadData:"{{ getOnLoadData($self) }}",onCheck:"{{ getOnCheck($self) }}",rootStyle:{padding:"8px 0",border:"1px solid #d9d9d9",borderRadius:"2px",maxHeight:"30vh",overflow:"auto",margin:"2px 0"}},"x-reactions":[{dependencies:[".collection"],fulfill:{state:{disabled:"{{ !$deps[0] }}",componentProps:{treeData:"{{ getEnableFieldTree($deps[0], $self) }}"}}}}]}}},remove:{type:"void","x-component":"ArrayCollapse.Remove"},moveUp:{type:"void","x-component":"ArrayCollapse.MoveUp"},moveDown:{type:"void","x-component":"ArrayCollapse.MoveDown"}}},properties:{add:{type:"void",title:'{{ t("Add template") }}',"x-component":"ArrayCollapse.Addition"}}},display:{type:"boolean","x-content":'{{ t("Enable form data template") }}',default:(h==null?void 0:h.display)!==!1,"x-decorator":"FormItem","x-component":"Checkbox"}}}),[]);return(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:P(x({},o),{designable:!0}),children:(0,import_jsx_runtime.jsx)(SchemaComponent,{components:S,scope:C,schema:b})})}),{displayName:"FormDataTemplates"});function getLabel(e){return e||"label"}function getResource(e,t){return e!==t.componentProps.service.resource&&(t.value=void 0),e}const EnableChildCollections=withDynamicSchemaProps((0,import_react.observer)(e=>{const{defaultValues:t,collectionName:o}=useProps(e),r=(0,import_react.useForm)(),i=useCompile(),{getChildrenCollections:n}=useCollectionManager_deprecated(),a=n(o),l=u=>(m,d)=>{m.loading=!0,u(m,d).then(import_reactive.action.bound(p=>{m.dataSource=p,m.loading=!1,m.initialValue&&(m.disabled=!0)}))},c=u=>q(void 0,null,function*(){var m,d;const{childrenCollections:p}=((m=r.values)==null?void 0:m.enableChildren)||{};return(d=a.filter(g=>!p.find(h=>h.collection===g.name)||u.initialValue||g.name===u.value))==null?void 0:d.map(g=>({label:i(g.title),value:g.name}))});return(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:{type:"object",properties:{childrenCollections:{type:"array",default:t==null?void 0:t.filter(u=>a.find(m=>m.name===u.collection)),"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},collection:{type:"string","x-decorator":"FormItem",required:!0,"x-component":"Select","x-component-props":{style:{width:260}},"x-reactions":["{{useAsyncDataSource(loadData)}}"]},title:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{style:{width:235}}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{ t("Add collection") }}',"x-component":"ArrayItems.Addition"}}}}},scope:{useAsyncDataSource:l,loadData:c}})}),{displayName:"EnableChildCollections"}),ChildDynamicComponent=(0,import_react.observer)(e=>{const{rootCollection:t,onChange:o,value:r,collectionField:i}=e,n=(0,import_react.useFieldSchema)(),{currentFormSettings:a}=useCurrentFormVariable({collectionName:t,collectionField:i}),{currentObjectSettings:l}=useCurrentObjectVariable({schema:i==null?void 0:i.uiSchema,collectionField:i}),c=useCompile(),u=(0,import_react2.useMemo)(()=>[a,l].filter(Boolean),[a,l]),m=c(u);return(0,import_react2.useEffect)(()=>{o(n.default)},[]),(0,import_jsx_runtime.jsx)(Variable.Input,{value:r,onChange:d=>o(d),scope:m,style:{minWidth:"400px",marginRight:15},className:import_css.css`
300
300
  .ant-input {
301
301
  width: 100% !important;
302
302
  }
@@ -413,7 +413,7 @@ https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModu
413
413
  `,popupMatchSelectWidth:!1,value:c==null?void 0:c.value,options:o(a),onChange:v,placeholder:t("Comparision")}),c!=null&&c.noValue?null:(0,import_jsx_runtime.jsx)(DynamicComponent,{value:d,schema:i,collectionField:g,onChange:p}),!e.disabled&&(0,import_jsx_runtime.jsx)("a",{role:"button","aria-label":"icon-close",children:(0,import_jsx_runtime.jsx)(import_icons.CloseCircleOutlined,{onClick:r,style:S})})]})})},{displayName:"FilterItem"}),FilterItems=(0,import_react.observer)(e=>{var t;const o=(0,import_react.useField)();return(0,import_jsx_runtime.jsx)("div",{children:(t=o==null?void 0:o.value)==null?void 0:t.filter(Boolean).map((r,i)=>(0,import_jsx_runtime.jsx)(RemoveConditionContext.Provider,{value:()=>o.remove(i),children:(0,import_jsx_runtime.jsx)(import_react.ObjectField,{name:i,component:[r.$and||r.$or?FilterGroup:FilterItem]})},i))})},{displayName:"FilterItems"}),FilterGroup=(0,import_react.connect)(e=>{const{bordered:t=!0,disabled:o}=e,r=(0,import_react.useField)(),i=(0,import_react2.useContext)(RemoveConditionContext),{t:n}=(0,import_react_i18next.useTranslation)(),{token:a}=useToken(),l=Object.keys(r.value||{}).includes("$or")?"$or":"$and",c=m=>{const d=r.value||{};r.value={[m]:[...d[l]||[]]}},u=o||r.disabled;return(0,import_jsx_runtime.jsx)(FilterLogicContext.Provider,{value:l,children:(0,import_jsx_runtime.jsxs)("div",{style:t?{position:"relative",border:`1px dashed ${a.colorBorder}`,padding:a.paddingSM,marginBottom:a.marginXS}:{position:"relative",marginBottom:a.marginXS},children:[i&&!u&&(0,import_jsx_runtime.jsx)("a",{role:"button","aria-label":"icon-close",children:(0,import_jsx_runtime.jsx)(import_icons.CloseCircleOutlined,{style:{position:"absolute",right:10,top:10,color:"#bfbfbf"},onClick:()=>i()})}),(0,import_jsx_runtime.jsx)("div",{style:{marginBottom:8,color:a.colorText},children:(0,import_jsx_runtime.jsxs)(import_react_i18next.Trans,{children:["Meet ",(0,import_jsx_runtime.jsxs)(import_antd.Select,{role:"button","data-testid":"filter-select-all-or-any",style:{width:"auto"},value:l,onChange:m=>{c(m)},children:[(0,import_jsx_runtime.jsx)(import_antd.Select.Option,{value:"$and",children:"All"}),(0,import_jsx_runtime.jsx)(import_antd.Select.Option,{value:"$or",children:"Any"})]})," conditions in the group"]})}),(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsx)(import_react.ArrayField,{name:l,component:[FilterItems],disabled:u})}),!u&&(0,import_jsx_runtime.jsxs)(import_antd.Space,{size:16,style:{marginTop:8,marginBottom:8},children:[(0,import_jsx_runtime.jsx)("a",{onClick:()=>{const m=(r.value||{})[l]||[];m.push({}),r.value={[l]:m},r.initialValue={[l]:m}},children:n("Add condition")}),(0,import_jsx_runtime.jsx)("a",{onClick:()=>{const m=(r.value||{})[l]||[];m.push({$and:[{}]}),r.value={[l]:m}},children:n("Add condition group")})]})]})})}),SaveDefaultValue=e=>{const{t}=(0,import_react_i18next.useTranslation)(),{designable:o,dn:r,refresh:i}=useDesignable(),n=(0,import_react.useFieldSchema)(),a=(0,import_react.useForm)();return o?(0,import_jsx_runtime.jsx)(import_antd.Button,{className:import_css.css`
414
414
  border-color: var(--colorSettings);
415
415
  color: var(--colorSettings);
416
- `,type:"dashed",onClick:()=>{var l,c,u,m;const d=(m=(u=(c=(l=n==null?void 0:n.parent)==null?void 0:l.parent)==null?void 0:c.parent)==null?void 0:u.properties)==null?void 0:m.filter;if(!d)return;const p=a.values.filter;r.emit("patch",{schema:{"x-uid":d["x-uid"],default:p}}),r.refresh(),d.default=p,console.log("filterSchema",p)},children:t("Save conditions")}):null},useDef$2=e=>{const t=(0,import_react.useField)();return useRequest(()=>Promise.resolve({data:t.dataSource}),e)},Filter=withDynamicSchemaProps((0,import_react.observer)(e=>{const{useDataSource:t=useDef$2}=e,{options:o,dynamicComponent:r,className:i,collectionName:n}=useProps(e),a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)();return t({onSuccess(c){a.dataSource=(c==null?void 0:c.data)||[]}}),(0,import_react2.useEffect)(()=>{l.defaultValue&&(a.initialValue=l.defaultValue)},[l.defaultValue]),(0,import_jsx_runtime.jsx)("div",{className:i,children:(0,import_jsx_runtime.jsx)(FilterContext$1.Provider,{value:{field:a,fieldSchema:l,dynamicComponent:r,options:o||a.dataSource||[],disabled:e.disabled,collectionName:n},children:(0,import_jsx_runtime.jsx)(FilterGroup,P(x({},e),{bordered:!1}))})})}),{displayName:"Filter"});Filter.SaveDefaultValue=SaveDefaultValue;Filter.Action=FilterAction;Filter.Action.Designer=FilterActionDesigner;const useGetFilterOptions=()=>{const e=useDataSourceManager(),t=useGetFilterFieldOptions();return(o,r,i)=>{var n;const a=(n=e==null?void 0:e.getDataSource(r))==null?void 0:n.collectionManager,l=a==null?void 0:a.getCollectionFields(o);return t(l,i)}},useFilterOptions=e=>{const t=useCollectionManager(),o=t==null?void 0:t.getCollectionFields(e);return useFilterFieldOptions(o)},useGetFilterFieldOptions=()=>{var e;const t=(0,import_react.useFieldSchema)(),o=((e=t==null?void 0:t["x-component-props"])==null?void 0:e.nonfilterable)||[],r=useCollectionManager(),i=useDataSourceManager(),n=(l,c,u)=>{var m,d;if(o.length&&c===1&&o.includes(l.name)||!l.interface)return;const p=i==null?void 0:i.collectionFieldInterfaceManager.getFieldInterface(l.interface);if(!(p!=null&&p.filterable)&&!u)return;const{nested:g,children:h,operators:f}=(p==null?void 0:p.filterable)||{},_={name:l.name,type:l.type,target:l.target,title:((m=l==null?void 0:l.uiSchema)==null?void 0:m.title)||l.name,schema:l==null?void 0:l.uiSchema,interface:l.interface,operators:((d=f==null?void 0:f.filter)==null?void 0:d.call(f,v=>!(v!=null&&v.visible)||v.visible(l)))||[]};if(!(l.target&&c>2)){if(c>2)return _;if(h!=null&&h.length&&(_.children=h),g){const v=r==null?void 0:r.getCollectionFields(l.target),S=a(v,c+1).filter(Boolean);_.children=_.children||[],_.children.push(...S)}return _}},a=(l,c,u)=>{const m=[];return l.forEach(d=>{const p=n(d,c,u);p&&m.push(p)}),m};return(l,c)=>a(l,1,c)},field2option=(e,t,o,r,i)=>{var n,a;if(o.length&&t===1&&o.includes(e.name)||!e.interface||e.filterable===!1)return;const l=r==null?void 0:r.collectionFieldInterfaceManager.getFieldInterface(e.interface);if(!(l!=null&&l.filterable))return;const{nested:c,children:u,operators:m}=l.filterable,d={name:e.name,type:e.type,target:e.target,title:((n=e==null?void 0:e.uiSchema)==null?void 0:n.title)||e.name,schema:e==null?void 0:e.uiSchema,operators:((a=m==null?void 0:m.filter)==null?void 0:a.call(m,p=>!(p!=null&&p.visible)||p.visible(e)))||[]};if(!(e.target&&t>2)){if(t>2)return d;if(u!=null&&u.length&&(d.children=u),c){const p=i==null?void 0:i.getCollectionFields(e.target),g=getOptions$1(p,t+1,o,r,i).filter(Boolean);d.children=d.children||[],d.children.push(...g)}return d}},getOptions$1=(e,t,o,r,i)=>{const n=[];return e.forEach(a=>{const l=field2option(a,t,o,r,i);l&&n.push(l)}),n},useFilterFieldOptions=e=>{var t;const o=(0,import_react.useFieldSchema)(),r=((t=o==null?void 0:o["x-component-props"])==null?void 0:t.nonfilterable)||[],i=useCollectionManager(),n=useDataSourceManager();return getOptions$1(e,1,r,n,i)},isEmpty=e=>Array.isArray(e)&&e.length===0||e&&Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype,removeNullCondition=(e,t=import_flat.default)=>{const o=t(e||{}),r={};for(const i in o){const n=o[i];n!=null&&!isEmpty(n)&&(r[i]=n)}return t.unflatten(r)},useFilterActionProps$1=()=>{const e=useCollection(),t=useFilterOptions(e==null?void 0:e.name);console.log(t);const o=useDataBlockProps();return useFilterFieldProps({options:t,params:o==null?void 0:o.params})},useFilterFieldProps=({options:e,service:t,params:o})=>{const{getDataBlockRequest:r}=useDataBlockRequestGetter(),{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useField)(),a=useDataLoadingMode(),l=(0,import_react.useFieldSchema)(),c=useCompile(),u=(0,import_react2.useCallback)(d=>{var p,g,h,f,_;const v=t||r(),S=(o||((g=(p=v.state)==null?void 0:p.params)==null?void 0:g[0])||v.params).filter,C=removeNullCondition(d==null?void 0:d.filter);if(a==="manual"&&import_lodash.default.isEmpty(C))return v==null?void 0:v.mutate(void 0);const b=((f=(h=v==null?void 0:v.params)==null?void 0:h[1])==null?void 0:f.filters)||{};b.filterAction=C,v==null||v.run(P(x({},(_=v==null?void 0:v.params)==null?void 0:_[0]),{page:1,filter:mergeFilter([...Object.values(b),S])}),{filters:b});const y=(C==null?void 0:C.$and)||(C==null?void 0:C.$or);y!=null&&y.length?n.title=i("{{count}} filter items",{count:(y==null?void 0:y.length)||0}):n.title=c(l.title)||i("Filter")},[a,n,r,o,t,i,l.title]),m=(0,import_react2.useCallback)(()=>{var d,p,g,h,f;const _=t||r(),v=(o||((p=(d=_.state)==null?void 0:d.params)==null?void 0:p[0])||_.params).filter,S=((h=(g=_==null?void 0:_.params)==null?void 0:g[1])==null?void 0:h.filters)||{};delete S.filterAction;const C=[P(x({},(f=_==null?void 0:_.params)==null?void 0:f[0]),{filter:mergeFilter([...Object.values(S),v]),page:1}),{filters:S}];if(n.title=c(l.title)||i("Filter"),a==="manual")return _.params=C,_==null?void 0:_.mutate(void 0);_==null||_.run(...C)},[a,n,r,o,t,i,l.title]);return{options:e,onSubmit:u,onReset:m}},useLabelFields$1=e=>{var t,o,r;const i=useCompile(),{getCollectionFields:n}=useCollectionManager_deprecated();if(!e)return[];const a=n(e);return(r=(o=(t=a==null?void 0:a.filter)==null?void 0:t.call(a,l=>(l==null?void 0:l.interface)&&!(l!=null&&l.target)&&l.type!=="boolean"))==null?void 0:o.map)==null?void 0:r.call(o,l=>{var c;return{value:l.name,label:i(((c=l==null?void 0:l.uiSchema)==null?void 0:c.title)||l.name)}})},useColorFields=e=>{var t,o,r;const i=useCompile(),{getCollectionFields:n}=useCollectionManager_deprecated();if(!e)return[];const a=n(e);return(r=(o=(t=a==null?void 0:a.filter)==null?void 0:t.call(a,l=>(l==null?void 0:l.interface)==="color"))==null?void 0:o.map)==null?void 0:r.call(o,l=>{var c;return{value:l.name,label:i(((c=l==null?void 0:l.uiSchema)==null?void 0:c.title)||l.name)}})},TableColumnDesigner$1=e=>{var t,o,r,i,n,a,l,c,u,m,d,p;const{uiSchema:g,fieldSchema:h,collectionField:f}=e,{form:_}=useFormBlockContext(),{getInterface:v,getCollection:S}=useCollectionManager_deprecated(),C=(0,import_react.useField)(),{t:b}=(0,import_react_i18next.useTranslation)(),y=(0,import_react.useFieldSchema)(),{dn:F}=useDesignable(),j=((t=h==null?void 0:h["x-component-props"])==null?void 0:t.fieldNames)||((o=g==null?void 0:g["x-component-props"])==null?void 0:o.fieldNames),k=useLabelFields$1((r=f==null?void 0:f.target)!=null?r:f==null?void 0:f.targetCollection),T=useColorFields((i=f==null?void 0:f.target)!=null?i:f==null?void 0:f.targetCollection),O=v(f==null?void 0:f.interface),N=S(f==null?void 0:f.target),L=isFileCollection$2(N),D=["QuickEdit","FormItem"].includes(h["x-decorator"]),{currentMode:R}=useAssociationFieldContext(),{isAllowToSetDefaultValue:$}=useIsAllowToSetDefaultValue({collectionField:f,fieldSchema:h}),w=["datetime","createdAt","updatedAt"].includes(f==null?void 0:f.interface),I=["obo","oho","o2o","o2m","m2m","m2o","snapshot"].includes(f==null?void 0:f.interface),M=useFieldModeOptions({fieldSchema:h}),B=((n=h==null?void 0:h["x-component-props"])==null?void 0:n.mode)||"Select";let z="editable";h["x-disabled"]===!0&&(z="readonly"),h["x-read-pretty"]===!0&&(z="read-pretty");const E=I&&B==="Select",V=()=>{const{name:U}=useCollection(),{linkageRulesProps:G}=useSchemaToolbar();return(0,import_jsx_runtime.jsx)(SchemaSettingsLinkageRules,x({category:"style"},P(x({},G),{collectionName:U})))};return(0,import_jsx_runtime.jsxs)(GeneralSchemaDesigner,{disableInitializer:!0,children:[(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:b("Custom column title"),schema:{type:"object",title:b("Custom column title"),properties:{title:{title:b("Column title"),default:y==null?void 0:y.title,description:`${b("Original field title: ")}${((a=f==null?void 0:f.uiSchema)==null?void 0:a.title)||(h==null?void 0:h.title)}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:U})=>{U&&(C.title=U,y.title=U,F.emit("patch",{schema:{"x-uid":y["x-uid"],title:y.title}})),F.refresh()}}),E&&!C.readPretty&&!(g!=null&&g["x-read-pretty"])&&D&&(0,import_jsx_runtime.jsx)(SchemaSettingsDataScope,{collectionName:f==null?void 0:f.target,defaultFilter:((u=(c=(l=h==null?void 0:h["x-component-props"])==null?void 0:l.service)==null?void 0:c.params)==null?void 0:u.filter)||{},form:_,onSubmit:({filter:U})=>{var G,W;U=removeNullCondition(U),(0,import_lodash.set)(C.componentProps,"service.params.filter",U),h["x-component-props"]=C.componentProps;const Y=(W=C.path)==null?void 0:W.splice(((G=C.path)==null?void 0:G.length)-1,1);C.form.query(`${Y.concat("*."+h.name)}`).forEach(H=>{H.componentProps.service=H.componentProps.service||{params:{}},H.componentProps.service.params.filter=U}),F.emit("patch",{schema:{"x-uid":h["x-uid"],"x-component-props":C.componentProps}})}}),(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:b("Column width"),schema:{type:"object",title:b("Column width"),properties:{width:{default:((m=y==null?void 0:y["x-component-props"])==null?void 0:m.width)||100,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{}}}},onSubmit:({width:U})=>{const G=y["x-component-props"]||{};G.width=U;const W={"x-uid":y["x-uid"]};W["x-component-props"]=G,y["x-component-props"]=G,C.componentProps.width=U,F.emit("patch",{schema:W}),F.refresh()}}),(0,import_jsx_runtime.jsx)(V,{}),O&&O.sortable===!0&&!R&&(0,import_jsx_runtime.jsx)(SchemaSettingsSwitchItem,{title:b("Sortable"),checked:C.componentProps.sorter,onChange:U=>{const G={"x-uid":y["x-uid"]};y["x-component-props"]=P(x({},y["x-component-props"]),{sorter:U}),G["x-component-props"]=y["x-component-props"],C.componentProps.sorter=U,F.emit("patch",{schema:G}),F.refresh()}}),["linkTo","m2m","m2o","o2m","obo","oho","snapshot","createdBy","updatedBy"].includes(f==null?void 0:f.interface)&&!L&&(z==="read-pretty"||C.readPretty||C.readOnly)&&(0,import_jsx_runtime.jsx)(SchemaSettingsSwitchItem,{title:b("Enable link"),checked:((d=h["x-component-props"])==null?void 0:d.enableLink)!==!1,onChange:U=>{h["x-component-props"]=P(x({},h==null?void 0:h["x-component-props"]),{enableLink:U}),C.componentProps=P(x({},h==null?void 0:h["x-component-props"]),{enableLink:U}),F.emit("patch",{schema:{"x-uid":h["x-uid"],"x-component-props":x({},h==null?void 0:h["x-component-props"])}}),F.refresh()}}),["linkTo","m2m","m2o","o2m","obo","oho","snapshot"].includes(f==null?void 0:f.interface)&&(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:b("Title field"),options:k,value:j==null?void 0:j.label,onChange:U=>{var G,W,Y,H,J;const X=P(x(x({},(W=(G=f==null?void 0:f.uiSchema)==null?void 0:G["x-component-props"])==null?void 0:W.fieldNames),(Y=h==null?void 0:h["x-component-props"])==null?void 0:Y.fieldNames),{label:U});import_lodash.default.set(h,"x-component-props.fieldNames",X);const Q=(J=C.path)==null?void 0:J.splice(((H=C.path)==null?void 0:H.length)-1,1);C.form.query(`${Q.concat("*."+h.name)}`).forEach(ee=>{ee.componentProps.fieldNames=X}),F.emit("patch",{schema:{"x-uid":h["x-uid"],"x-component-props":x({},h["x-component-props"])}}),F.refresh()}}),I&&(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:b("Field component"),options:z==="read-pretty"?[{label:b("Title"),value:"Select"},L&&{label:b("File manager"),value:"FileManager"},{label:b("Tag"),value:"Tag"}].filter(Boolean):M,value:B,onChange:U=>{const G={"x-uid":h["x-uid"]};h["x-component-props"]=h["x-component-props"]||{},h["x-component-props"].mode=U,G["x-component-props"]=h["x-component-props"],C.componentProps=C.componentProps||{},C.componentProps.mode=U,F.emit("patch",{schema:G}),F.refresh()}},"field-mode"),["Tag"].includes(B)&&(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:b("Tag color field"),options:T,value:(p=h==null?void 0:h["x-component-props"])==null?void 0:p.tagColorField,onChange:U=>{const G={"x-uid":h["x-uid"]};h["x-component-props"]=h["x-component-props"]||{},h["x-component-props"].tagColorField=U,G["x-component-props"]=h["x-component-props"],C.componentProps.tagColorField=U,F.emit("patch",{schema:G}),F.refresh()}},"title-field"),D&&!C.readPretty&&!(g!=null&&g["x-read-pretty"])&&(0,import_jsx_runtime.jsx)(SchemaSettingsSwitchItem,{title:b("Required"),checked:h.required,onChange:U=>{var G,W;const Y={"x-uid":h["x-uid"]};h.required=U,Y.required=U;const H=(W=C.path)==null?void 0:W.splice(((G=C.path)==null?void 0:G.length)-1,1);C.form.query(`${H.concat("*."+h.name)}`).forEach(J=>{J.required=U}),F.emit("patch",{schema:Y}),F.refresh()}},"required"),D&&!(C!=null&&C.readPretty)&&(f==null?void 0:f.interface)!=="o2m"&&!isPatternDisabled(h)&&(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:b("Pattern"),options:[{label:b("Editable"),value:"editable"},{label:b("Readonly"),value:"readonly"},{label:b("Easy-reading"),value:"read-pretty"}],value:z,onChange:U=>{var G,W;const Y={"x-uid":h["x-uid"]},H=(W=C.path)==null?void 0:W.splice(((G=C.path)==null?void 0:G.length)-1,1);switch(U){case"readonly":{h["x-read-pretty"]=!1,h["x-disabled"]=!0,Y["x-read-pretty"]=!1,Y["x-disabled"]=!0,C.form.query(`${H.concat("*."+h.name)}`).forEach(J=>{J.readonly=!0,J.disabled=!0});break}case"read-pretty":{h["x-read-pretty"]=!0,h["x-disabled"]=!1,Y["x-read-pretty"]=!0,Y["x-disabled"]=!1,C.form.query(`${H.concat("*."+h.name)}`).forEach(J=>{J.readPretty=!0});break}default:{h["x-read-pretty"]=!1,h["x-disabled"]=!1,Y["x-read-pretty"]=!1,Y["x-disabled"]=!1,C.form.query(`${H.concat("*."+h.name)}`).forEach(J=>{J.readPretty=!1,J.disabled+!1});break}}F.emit("patch",{schema:Y}),F.refresh()}},"pattern"),w&&(0,import_jsx_runtime.jsx)(SchemaSettingsDateFormat,{fieldSchema:h}),D&&!(C!=null&&C.readPretty)&&["obo","oho","o2o","o2m","m2m","m2o"].includes(f==null?void 0:f.interface)&&(0,import_jsx_runtime.jsx)(SchemaSettingsSortingRule,{fieldSchema:h,onSubmitCallBack:U=>{var G,W;const Y=(W=C.path)==null?void 0:W.splice(((G=C.path)==null?void 0:G.length)-1,1);C.form.query(`${Y.concat("*."+h.name)}`).forEach(H=>{H.componentProps.service=H.componentProps.service||{params:{}},H.componentProps.service.params.sort=U})}}),$(D)&&(0,import_jsx_runtime.jsx)(SchemaSettingsDefaultValue,{fieldSchema:h}),(0,import_jsx_runtime.jsx)(SchemaSettingsDivider,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsRemove,{removeParentsIfNoChildren:!D,breakRemoveOn:{"x-component":"Grid"},confirm:{title:b("Delete table column")}})]})};function isFileCollection$2(e){return(e==null?void 0:e.template)==="file"}const allowAddNew={name:"allowAddNew",type:"switch",useVisible(){const e=useFlag(),t=useIsFieldReadPretty(),o=useIsAssociationField(),r=useFieldMode();return!(e!=null&&e.isInSubTable)&&!t&&o&&["Picker"].includes(r)},useComponentProps(){const{defaultOpenMode:e}=useOpenModeContext(),{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n,insertAdjacent:a}=useDesignable();return{title:t("Allow add new data"),checked:r["x-add-new"],onChange(l){r.reduceProperties((u,m)=>m["x-component"]==="Action"?m:u,null)||a("afterBegin",{"x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-toolbar":"ActionSchemaToolbar","x-toolbar-props":{draggable:!1},"x-settings":"actionSettings:addNew","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:e,type:"default",component:"CreateRecordAction"}});const c={"x-uid":r["x-uid"]};o["x-add-new"]=l,r["x-add-new"]=l,c["x-add-new"]=l,i.emit("patch",{schema:c}),n()}}}},formItemSettings=new SchemaSettings({name:"FormItemSettings",items:[...generalSettingsItems,{name:"allowAddNewData",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useIsAssociationField(),o=useFieldMode();return!e&&t&&["SubTable"].includes(o)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow add new"),checked:((e=r["x-component-props"])==null?void 0:e.allowAddnew)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.allowAddnew=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].allowAddnew=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"allowSelectExistingRecord",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useIsAssociationField(),o=useFieldMode();return!e&&t&&["SubTable"].includes(o)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow selection of existing records"),checked:(e=r["x-component-props"])==null?void 0:e.allowSelectExistingRecord,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.allowSelectExistingRecord=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].allowSelectExistingRecord=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"quickUpload",type:"switch",useVisible(){const e=useIsFileField();return!useIsFormReadPretty()&&e},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Quick upload"),checked:((e=r["x-component-props"])==null?void 0:e.quickUpload)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.quickUpload=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].quickUpload=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"selectFile",type:"switch",useVisible(){const e=useIsFileField();return!useIsFormReadPretty()&&e},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Select file"),checked:((e=r["x-component-props"])==null?void 0:e.selectFile)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.selectFile=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].selectFile=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"validationRules",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r,refresh:i}=useDesignable(),n=useValidateSchema(),{getCollectionJoinField:a}=useCollectionManager_deprecated(),{getField:l}=useCollection_deprecated(),c=l(o.name)||a(o["x-collection-field"]);return{title:e("Set validation rules"),components:{ArrayCollapse:import_antd_v5.ArrayCollapse,FormLayout:import_antd_v5.FormLayout},schema:{type:"object",title:e("Set validation rules"),properties:{rules:{type:"array",default:o==null?void 0:o["x-validator"],"x-component":"ArrayCollapse","x-decorator":"FormItem","x-component-props":{accordion:!0},maxItems:3,items:{type:"object","x-component":"ArrayCollapse.CollapsePanel","x-component-props":{header:'{{ t("Validation rule") }}'},properties:{index:{type:"void","x-component":"ArrayCollapse.Index"},layout:{type:"void","x-component":"FormLayout","x-component-props":{labelStyle:{marginTop:"6px"},labelCol:8,wrapperCol:16},properties:P(x({},n),{message:{type:"string",title:'{{ t("Error message") }}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:2,maxRows:2}}}})},remove:{type:"void","x-component":"ArrayCollapse.Remove"},moveUp:{type:"void","x-component":"ArrayCollapse.MoveUp"},moveDown:{type:"void","x-component":"ArrayCollapse.MoveDown"}}},properties:{add:{type:"void",title:'{{ t("Add validation rule") }}',"x-component":"ArrayCollapse.Addition","x-reactions":{dependencies:["rules"],fulfill:{state:{disabled:"{{$deps[0].length >= 3}}"}}}}}}}},onSubmit(u){var m;const d=[];for(const h of u.rules)d.push(import_lodash.default.pickBy(h,import_lodash.default.identity));const p={"x-uid":o["x-uid"]};if(["percent"].includes(c==null?void 0:c.interface))for(const h of d)(h.maxValue||h.minValue)&&(h.percentMode=!0),h.percentFormat&&(h.percentFormats=!0);const g=import_lodash.default.concat([],((m=c==null?void 0:c.uiSchema)==null?void 0:m["x-validator"])||[],d);t.validator=g,o["x-validator"]=d,p["x-validator"]=d,r.emit("patch",{schema:p}),i()}}},useVisible(){const{form:e}=useFormBlockContext(),t=useIsFormReadPretty(),o=useValidateSchema();return e&&!t&&o}},{name:"defaultValue",Component:SchemaSettingsDefaultValue,useVisible(){const{isAllowToSetDefaultValue:e}=useIsAllowToSetDefaultValue();return e()}},{name:"dataScope",Component:SchemaSettingsDataScope,useVisible(){const e=useIsSelectFieldMode(),t=useIsFormReadPretty();return e&&!t},useComponentProps(){var e,t,o;const{getCollectionJoinField:r,getAllCollectionsInheritChain:i}=useCollectionManager_deprecated(),{getField:n}=useCollection_deprecated(),{form:a}=useFormBlockContext(),l=useRecord(),c=(0,import_react.useField)(),u=(0,import_react.useFieldSchema)(),m=n(u.name)||r(u["x-collection-field"]),d=useVariables$1(),p=useLocalVariables$1(),{dn:g}=useDesignable();return{collectionName:m==null?void 0:m.target,defaultFilter:((o=(t=(e=u==null?void 0:u["x-component-props"])==null?void 0:e.service)==null?void 0:t.params)==null?void 0:o.filter)||{},form:a,dynamicComponent:h=>(0,import_jsx_runtime.jsx)(VariableInput,P(x({},h),{form:a,collectionField:h.collectionField,record:l,shouldChange:getShouldChange({collectionField:h.collectionField,variables:d,localVariables:p,getAllCollectionsInheritChain:i})})),onSubmit:({filter:h})=>{h=removeNullCondition(h),import_lodash.default.set(c.componentProps,"service.params.filter",h),u["x-component-props"]=c.componentProps,g.emit("patch",{schema:{"x-uid":u["x-uid"],"x-component-props":c.componentProps}})}}}},{name:"sortingRule",Component:SchemaSettingsSortingRule,useVisible(){const e=useIsSelectFieldMode(),t=useIsFormReadPretty();return e&&!t}},{name:"fieldMode",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable(),i=useFieldModeOptions(),n=useIsAddNewForm(),a=useFieldMode();return{title:e("Field component"),options:i,value:a,onChange(l){const c={"x-uid":o["x-uid"]};o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].mode=l,c["x-component-props"]=o["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=l,isSubMode(o)&&n&&(c.default=null,o.default=null,t.setInitialValue(null),t.setValue(null)),r.emit("patch",{schema:c}),r.refresh()}}},useVisible:useShowFieldMode},{name:"popupSize",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n}=useDesignable();return{title:o("Popup size"),options:[{label:o("Small"),value:"small"},{label:o("Middle"),value:"middle"},{label:o("Large"),value:"large"}],value:(t=(e=i==null?void 0:i["x-component-props"])==null?void 0:e.openSize)!=null?t:"middle",onChange:a=>{r.componentProps.openSize=a,i["x-component-props"]=r.componentProps,n.emit("patch",{schema:{"x-uid":i["x-uid"],"x-component-props":i["x-component-props"]}}),n.refresh()}}},useVisible(){var e;const t=useShowFieldMode(),o=((e=(0,import_react.useFieldSchema)()["x-component-props"])==null?void 0:e.mode)==="Picker";return t&&o}},allowAddNew,{name:"addMode",type:"select",useVisible(){const e=useIsFieldReadPretty(),t=useIsAssociationField(),o=useFieldMode();return!e&&t&&["Select"].includes(o)},useComponentProps(){var e;const{defaultOpenMode:t}=useOpenModeContext(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n,insertAdjacent:a}=useDesignable();return{title:o("Quick create"),options:[{label:o("None"),value:"none"},{label:o("Dropdown"),value:"quickAdd"},{label:o("Pop-up"),value:"modalAdd"}],value:((e=r.componentProps)==null?void 0:e.addMode)||"none",onChange(l){l==="modalAdd"&&(i.reduceProperties((u,m)=>m["x-component"]==="Action"?m:u,null)||a("afterBegin",{"x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:addNew","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:t,type:"default",component:"CreateRecordAction"}}));const c={"x-uid":i["x-uid"]};i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].addMode=l,c["x-component-props"]=i["x-component-props"],r.componentProps=r.componentProps||{},r.componentProps.addMode=l,n.emit("patch",{schema:c}),n.refresh()}}}},{name:"multiple",type:"switch",useVisible(){const e=useIsAssociationField(),t=useIsShowMultipleSwitch();return e&&t()},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow multiple"),checked:((e=r["x-component-props"])==null?void 0:e.multiple)===void 0?!0:r["x-component-props"].multiple,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].multiple=a,o.componentProps.multiple=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"allowDissociate",type:"switch",useVisible(){var e;const t=useIsShowMultipleSwitch();return((e=(0,import_react.useFieldSchema)()["x-component-props"])==null?void 0:e.mode)==="Nester"&&t()},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow dissociate"),checked:((e=r["x-component-props"])==null?void 0:e.allowDissociate)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].allowDissociate=a,o.componentProps.allowDissociate=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"enableLink",type:"switch",useVisible(){const e=useTitleFieldOptions(),t=useIsFieldReadPretty(),o=useIsFileField(),r=(0,import_react.useFieldSchema)();return t&&e.length>0&&!o&&r["x-component"]==="CollectionField"},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Enable link"),checked:((e=r["x-component-props"])==null?void 0:e.enableLink)!==!1,onChange(n){r["x-component-props"]=P(x({},r==null?void 0:r["x-component-props"]),{enableLink:n}),o.componentProps.enableLink=n,i.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":x({},r==null?void 0:r["x-component-props"])}}),i.refresh()}}}},{name:"pattern",type:"select",useVisible(){const{form:e}=useFormBlockContext(),t=(0,import_react.useFieldSchema)();return e&&!(e!=null&&e.readPretty)&&!isPatternDisabled(t)},useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable();let i="editable";return o["x-disabled"]===!0&&(i="readonly"),o["x-read-pretty"]===!0&&(i="read-pretty"),{title:e("Pattern"),options:[{label:e("Editable"),value:"editable"},{label:e("Readonly"),value:"readonly"},{label:e("Easy-reading"),value:"read-pretty"}],value:i,onChange(n){const a={"x-uid":o["x-uid"]};switch(n){case"readonly":{o["x-read-pretty"]=!1,o["x-disabled"]=!0,a["x-read-pretty"]=!1,a["x-disabled"]=!0,t.readPretty=!1,t.disabled=!0,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.ReadOnly));break}case"read-pretty":{o["x-read-pretty"]=!0,o["x-disabled"]=!1,a["x-read-pretty"]=!0,a["x-disabled"]=!1,t.readPretty=!0,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.ReadPretty));break}default:{o["x-read-pretty"]=!1,o["x-disabled"]=!1,a["x-read-pretty"]=!1,a["x-disabled"]=!1,t.readPretty=!1,t.disabled=!1,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.Editable));break}}r.emit("patch",{schema:a}),r.refresh()}}}},{name:"titleField",type:"select",useVisible(){const e=useTitleFieldOptions(),t=useIsAssociationField(),o=useFieldMode();return e.length>0&&t&&o!=="SubTable"},useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n}=useDesignable(),a=useTitleFieldOptions(),l=useCollectionField_deprecated();return{title:o("Title field"),options:a,value:(t=(e=r==null?void 0:r.componentProps)==null?void 0:e.fieldNames)==null?void 0:t.label,onChange(c){var u,m;const d={"x-uid":i["x-uid"]},p=P(x(x({},(m=(u=l==null?void 0:l.uiSchema)==null?void 0:u["x-component-props"])==null?void 0:m.fieldNames),r.componentProps.fieldNames),{label:c});i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].fieldNames=p,d["x-component-props"]=i["x-component-props"],r.componentProps.fieldNames=i["x-component-props"].fieldNames,n.emit("patch",{schema:d}),n.refresh()}}}},{name:"dateFormat",Component:SchemaSettingsDateFormat,useVisible(){const e=useFormItemCollectionField();return["datetime","createdAt","updatedAt"].includes(e==null?void 0:e.interface)},useComponentProps(){return{fieldSchema:(0,import_react.useFieldSchema)()}}},{name:"size",type:"select",useVisible(){const e=useIsFieldReadPretty(),t=useFormItemCollectionField(),{getCollection:o}=useCollectionManager_deprecated(),r=o(t==null?void 0:t.target),i=["attachment"].includes(t==null?void 0:t.interface)||(r==null?void 0:r.template)==="file";return e&&i},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Size"),options:[{label:t("Large"),value:"large"},{label:t("Default"),value:"default"},{label:t("Small"),value:"small"}],value:((e=o==null?void 0:o.componentProps)==null?void 0:e.size)||"default",onChange(n){const a={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].size=n,a["x-component-props"]=r["x-component-props"],o.componentProps=o.componentProps||{},o.componentProps.size=n,i.emit("patch",{schema:a}),i.refresh()}}}},{name:"tagColor",type:"select",useVisible(){const e=useIsAssociationField(),t=useFieldMode();return e&&["Tag"].includes(t)},useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n}=useDesignable(),a=useFormItemCollectionField(),l=useColorFields((e=a==null?void 0:a.target)!=null?e:a==null?void 0:a.targetCollection);return{title:o("Tag color field"),options:l,value:(t=r==null?void 0:r.componentProps)==null?void 0:t.tagColorField,onChange(c){const u={"x-uid":i["x-uid"]};i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].tagColorField=c,u["x-component-props"]=i["x-component-props"],r.componentProps.tagColorField=c,n.emit("patch",{schema:u}),n.refresh()}}}},{name:"divider",type:"divider",useVisible(){return!!useFormItemCollectionField()}},{name:"remove",type:"remove",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!0,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]});function useIsAddNewForm(){const e=useRecord();return import_lodash.default.isEmpty(import_lodash.default.omit(e,["__parent","__collectionName"]))}function isFileCollection$1(e){return(e==null?void 0:e.template)==="file"}function useIsFormReadPretty(){const{form:e}=useFormBlockContext();return!!(e!=null&&e.readPretty)}function useIsFieldReadPretty(){const{fieldSchema:e}=useColumnSchema$1();return(0,import_react.useField)().readPretty||(e==null?void 0:e["x-read-pretty"])}function useFormItemCollectionField(){const{getCollectionJoinField:e}=useCollectionManager_deprecated(),{getField:t}=useCollection_deprecated(),o=(0,import_react.useFieldSchema)(),{collectionField:r}=useColumnSchema$1(),i=o?t(o.name)||e(o["x-collection-field"]):null;return o?i||r:null}function useIsAssociationField(){const e=useFormItemCollectionField();return["obo","oho","o2o","o2m","m2m","m2o","updatedBy","createdBy","mbm"].includes(e==null?void 0:e.interface)}function useIsFileField(){const e=useCollectionManager(),t=useFormItemCollectionField(),o=e.getCollection(t==null?void 0:t.target);return isFileCollection$1(o)}function useFieldMode(){var e;const t=(0,import_react.useField)(),o=useIsFileField();return((e=t==null?void 0:t.componentProps)==null?void 0:e.mode)||(o?"FileManager":"Select")}function useIsSelectFieldMode(){const e=useFieldMode();return useIsAssociationField()&&e==="Select"}function useValidateSchema(){var e;const{getInterface:t}=useCollectionManager_deprecated(),o=(0,import_react.useFieldSchema)(),r=useFormItemCollectionField(),i=t(r==null?void 0:r.interface);return(e=i==null?void 0:i.validateSchema)==null?void 0:e.call(i,o)}function useShowFieldMode(){const e=(0,import_react.useFieldSchema)(),t=useFieldModeOptions(),o=e["x-component"]==="TableField";return useIsAssociationField()&&t&&!o}function useTitleFieldOptions(){var e;const{getCollectionFields:t,isTitleField:o}=useCollectionManager_deprecated(),r=useCompile(),i=useFormItemCollectionField();return(i!=null&&i.target?t(i==null?void 0:i.target):(e=t(i==null?void 0:i.targetCollection))!=null?e:[]).filter(n=>o(n)).map(n=>{var a;return{value:n==null?void 0:n.name,label:r((a=n==null?void 0:n.uiSchema)==null?void 0:a.title)||(n==null?void 0:n.name)}})}function useFieldComponentName(){var e,t,o,r;const{fieldSchema:i,collectionField:n}=useColumnSchema$1(),a=(0,import_react.useField)(),l=useIsFileField(),c=(0,import_react.useFieldSchema)(),u=useCollectionField(),m=i||c,d=n||u,p={AssociationField:"Select"},g=((e=m==null?void 0:m["x-component-props"])==null?void 0:e.mode)||((t=a==null?void 0:a.componentProps)==null?void 0:t.mode)||(l?"FileManager":"")||((o=m==null?void 0:m["x-component-props"])==null?void 0:o.component)||((r=d==null?void 0:d.uiSchema)==null?void 0:r["x-component"]);return p[g]||g}const CurrentUserContext=(0,import_react2.createContext)(null);CurrentUserContext.displayName="CurrentUserContext";const useCurrentUserContext=()=>(0,import_react2.useContext)(CurrentUserContext),useCurrentRoles=()=>{var e;const{allowAnonymous:t}=useACLRoleContext(),{data:o}=useCurrentUserContext(),r=useCompile();return(0,import_react2.useMemo)(()=>{var i;const n=(((i=o==null?void 0:o.data)==null?void 0:i.roles)||[]).map(({name:a,title:l})=>({name:a,title:r(l)}));return t&&n.push({title:"Anonymous",name:"anonymous"}),n},[t,(e=o==null?void 0:o.data)==null?void 0:e.roles])},CurrentUserProvider=e=>{const{render:t}=useAppSpin(),o=useRequest({url:"auth:check"});return o.loading?t():(0,import_jsx_runtime.jsx)(CurrentUserContext.Provider,{value:o,children:e.children})},NavigateToSigninWithRedirect=()=>{const{pathname:e,search:t}=useLocationNoUpdate(),o=`?redirect=${e}${t}`;return(0,import_jsx_runtime.jsx)(import_react_router_dom.Navigate,{replace:!0,to:`/signin${o}`})},NavigateIfNotSignIn=({children:e})=>{var t,o;const r=useCurrentUserContext();return r.loading===!1&&!((o=(t=r.data)==null?void 0:t.data)!=null&&o.id)?(0,import_jsx_runtime.jsx)(NavigateToSigninWithRedirect,{}):(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e})},useSwitchRole=()=>{const e=useAPIClient(),t=useCurrentRoles(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react2.useMemo)(()=>({key:"role",eventKey:"SwitchRole",label:(0,import_jsx_runtime.jsx)(SelectWithTitle,{title:o("Switch role"),fieldNames:{label:"title",value:"name"},options:t,defaultValue:e.auth.role,onChange:i=>q(void 0,null,function*(){e.auth.setRole(i),yield e.resource("users").setDefaultRole({values:{roleName:i}}),location.reload(),window.location.reload()})})}),[e,t,o]);return t.length<=1?null:r},useNickname=()=>{var e,t,o;const{data:r}=useCurrentUserContext(),{token:i}=useToken$1();return(0,import_react2.useMemo)(()=>{var n,a,l;return{key:"nickname",disabled:!0,label:(0,import_jsx_runtime.jsx)("span",{"aria-disabled":"false",style:{cursor:"text",color:i.colorTextDescription},children:((n=r==null?void 0:r.data)==null?void 0:n.nickname)||((a=r==null?void 0:r.data)==null?void 0:a.username)||((l=r==null?void 0:r.data)==null?void 0:l.email)})}},[(e=r==null?void 0:r.data)==null?void 0:e.email,(t=r==null?void 0:r.data)==null?void 0:t.nickname,(o=r==null?void 0:r.data)==null?void 0:o.username,r==null?void 0:r.data.version,i.colorTextDescription])},SettingsMenu$1=e=>{const{addMenuItem:t,getMenuItems:o}=useCurrentUserSettingsMenu(),{redirectUrl:r=""}=e,{allowAll:i,snippets:n}=useACLRoleContext(),a=i||(n==null?void 0:n.includes("app")),l=useNavigateNoUpdate(),c=useAPIClient(),{t:u}=(0,import_react_i18next.useTranslation)(),m=useAPIClient(),d=(0,import_react2.useCallback)(()=>q(void 0,null,function*(){return yield new Promise(C=>{const b=setInterval(()=>{m.silent().resource("app").getInfo().then(y=>((y==null?void 0:y.status)===200&&(C("ok"),clearInterval(b)),y)).catch(y=>{(0,import_client.error)(y)})},3e3)})}),[m]),p=useNickname(),g=useEditProfile(),h=useChangePassword(),f=useSwitchRole(),_=useLanguageSettings(),{modal:v}=import_antd.App.useApp(),S=(0,import_react2.useMemo)(()=>a?[{key:"cache",label:u("Clear cache"),onClick:()=>q(void 0,null,function*(){yield c.resource("app").clearCache(),window.location.reload()})},{key:"reboot",label:u("Restart application"),onClick:()=>q(void 0,null,function*(){v.confirm({title:u("Restart application"),okText:u("Restart"),okButtonProps:{danger:!0},onOk:()=>q(void 0,null,function*(){yield c.resource("app").restart()})})})},{key:"divider_4",type:"divider"}]:[],[c,a,d,v,u]);return(0,import_react2.useMemo)(()=>{[p,{key:"divider_1",type:"divider"},g,h,(g||h)&&{key:"divider_2",type:"divider"},f,{key:"divider_3",type:"divider"},...S,{key:"signout",label:u("Sign out"),onClick:()=>q(void 0,null,function*(){var C;const{data:b}=yield c.auth.signOut();(C=b==null?void 0:b.data)!=null&&C.redirect?window.location.href=b.data.redirect:l(`/signin?redirect=${encodeURIComponent(r)}`)})}].forEach(C=>{C&&t(C)}),_&&t(_,{before:"divider_3"})},[t,c.auth,h,S,g,_,l,r,f,u,p]),(0,import_jsx_runtime.jsx)(import_antd.Menu,{items:o()})},DropdownVisibleContext=(0,import_react2.createContext)(null);DropdownVisibleContext.displayName="DropdownVisibleContext";const CurrentUser=()=>{const[e,t]=(0,import_react2.useState)(!1),{token:o}=useToken$1();return(0,import_jsx_runtime.jsx)("div",{className:import_css.css`
416
+ `,type:"dashed",onClick:()=>{var l,c,u,m;const d=(m=(u=(c=(l=n==null?void 0:n.parent)==null?void 0:l.parent)==null?void 0:c.parent)==null?void 0:u.properties)==null?void 0:m.filter;if(!d)return;const p=a.values.filter;r.emit("patch",{schema:{"x-uid":d["x-uid"],default:p}}),r.refresh(),d.default=p,console.log("filterSchema",p)},children:t("Save conditions")}):null},useDef$2=e=>{const t=(0,import_react.useField)();return useRequest(()=>Promise.resolve({data:t.dataSource}),e)},Filter=withDynamicSchemaProps((0,import_react.observer)(e=>{const{useDataSource:t=useDef$2}=e,{options:o,dynamicComponent:r,className:i,collectionName:n}=useProps(e),a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)();return t({onSuccess(c){a.dataSource=(c==null?void 0:c.data)||[]}}),(0,import_react2.useEffect)(()=>{l.defaultValue&&(a.initialValue=l.defaultValue)},[l.defaultValue]),(0,import_jsx_runtime.jsx)("div",{className:i,children:(0,import_jsx_runtime.jsx)(FilterContext$1.Provider,{value:{field:a,fieldSchema:l,dynamicComponent:r,options:o||a.dataSource||[],disabled:e.disabled,collectionName:n},children:(0,import_jsx_runtime.jsx)(FilterGroup,P(x({},e),{bordered:!1}))})})}),{displayName:"Filter"});Filter.SaveDefaultValue=SaveDefaultValue;Filter.Action=FilterAction;Filter.Action.Designer=FilterActionDesigner;const useGetFilterOptions=()=>{const e=useDataSourceManager(),t=useGetFilterFieldOptions();return(o,r,i)=>{var n;const a=(n=e==null?void 0:e.getDataSource(r))==null?void 0:n.collectionManager,l=a==null?void 0:a.getCollectionFields(o);return t(l,i)}},useFilterOptions=e=>{const t=useCollectionManager(),o=t==null?void 0:t.getCollectionFields(e);return useFilterFieldOptions(o)},useGetFilterFieldOptions=()=>{var e;const t=(0,import_react.useFieldSchema)(),o=((e=t==null?void 0:t["x-component-props"])==null?void 0:e.nonfilterable)||[],r=useCollectionManager(),i=useDataSourceManager(),n=(l,c,u)=>{var m,d;if(o.length&&c===1&&o.includes(l.name)||!l.interface)return;const p=i==null?void 0:i.collectionFieldInterfaceManager.getFieldInterface(l.interface);if(!(p!=null&&p.filterable)&&!u)return;const{nested:g,children:h,operators:f}=(p==null?void 0:p.filterable)||{},_={name:l.name,type:l.type,target:l.target,title:((m=l==null?void 0:l.uiSchema)==null?void 0:m.title)||l.name,schema:l==null?void 0:l.uiSchema,interface:l.interface,operators:((d=f==null?void 0:f.filter)==null?void 0:d.call(f,v=>!(v!=null&&v.visible)||v.visible(l)))||[]};if(!(l.target&&c>2)){if(c>2)return _;if(h!=null&&h.length&&(_.children=h),g){const v=r==null?void 0:r.getCollectionFields(l.target),S=a(v,c+1).filter(Boolean);_.children=_.children||[],_.children.push(...S)}return _}},a=(l,c,u)=>{const m=[];return l.forEach(d=>{const p=n(d,c,u);p&&m.push(p)}),m};return(l,c)=>a(l,1,c)},field2option=(e,t,o,r,i)=>{var n,a;if(o.length&&t===1&&o.includes(e.name)||!e.interface||e.filterable===!1)return;const l=r==null?void 0:r.collectionFieldInterfaceManager.getFieldInterface(e.interface);if(!(l!=null&&l.filterable))return;const{nested:c,children:u,operators:m}=l.filterable,d={name:e.name,type:e.type,target:e.target,title:((n=e==null?void 0:e.uiSchema)==null?void 0:n.title)||e.name,schema:e==null?void 0:e.uiSchema,operators:((a=m==null?void 0:m.filter)==null?void 0:a.call(m,p=>!(p!=null&&p.visible)||p.visible(e)))||[]};if(!(e.target&&t>2)){if(t>2)return d;if(u!=null&&u.length&&(d.children=u),c){const p=i==null?void 0:i.getCollectionFields(e.target),g=getOptions$1(p,t+1,o,r,i).filter(Boolean);d.children=d.children||[],d.children.push(...g)}return d}},getOptions$1=(e,t,o,r,i)=>{const n=[];return e.forEach(a=>{const l=field2option(a,t,o,r,i);l&&n.push(l)}),n},useFilterFieldOptions=e=>{var t;const o=(0,import_react.useFieldSchema)(),r=((t=o==null?void 0:o["x-component-props"])==null?void 0:t.nonfilterable)||[],i=useCollectionManager(),n=useDataSourceManager();return getOptions$1(e,1,r,n,i)},isEmpty=e=>Array.isArray(e)&&e.length===0||e&&Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype,removeNullCondition=(e,t=import_flat.default)=>{const o=t(e||{}),r={};for(const i in o){const n=o[i];n!=null&&!isEmpty(n)&&(r[i]=n)}return t.unflatten(r)},useFilterActionProps$1=()=>{const e=useCollection(),t=useFilterOptions(e==null?void 0:e.name),o=useDataBlockProps();return useFilterFieldProps({options:t,params:o==null?void 0:o.params})},useFilterFieldProps=({options:e,service:t,params:o})=>{const{getDataBlockRequest:r}=useDataBlockRequestGetter(),{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useField)(),a=useDataLoadingMode(),l=(0,import_react.useFieldSchema)(),c=useCompile(),u=(0,import_react2.useCallback)(d=>{var p,g,h,f,_;const v=t||r(),S=(o||((g=(p=v.state)==null?void 0:p.params)==null?void 0:g[0])||v.params).filter,C=removeNullCondition(d==null?void 0:d.filter);if(a==="manual"&&import_lodash.default.isEmpty(C))return v==null?void 0:v.mutate(void 0);const b=((f=(h=v==null?void 0:v.params)==null?void 0:h[1])==null?void 0:f.filters)||{};b.filterAction=C,v==null||v.run(P(x({},(_=v==null?void 0:v.params)==null?void 0:_[0]),{page:1,filter:mergeFilter([...Object.values(b),S])}),{filters:b});const y=(C==null?void 0:C.$and)||(C==null?void 0:C.$or);y!=null&&y.length?n.title=i("{{count}} filter items",{count:(y==null?void 0:y.length)||0}):n.title=c(l.title)||i("Filter")},[a,n,r,o,t,i,l.title]),m=(0,import_react2.useCallback)(()=>{var d,p,g,h,f;const _=t||r(),v=(o||((p=(d=_.state)==null?void 0:d.params)==null?void 0:p[0])||_.params).filter,S=((h=(g=_==null?void 0:_.params)==null?void 0:g[1])==null?void 0:h.filters)||{};delete S.filterAction;const C=[P(x({},(f=_==null?void 0:_.params)==null?void 0:f[0]),{filter:mergeFilter([...Object.values(S),v]),page:1}),{filters:S}];if(n.title=c(l.title)||i("Filter"),a==="manual")return _.params=C,_==null?void 0:_.mutate(void 0);_==null||_.run(...C)},[a,n,r,o,t,i,l.title]);return{options:e,onSubmit:u,onReset:m}},useLabelFields$1=e=>{var t,o,r;const i=useCompile(),{getCollectionFields:n}=useCollectionManager_deprecated();if(!e)return[];const a=n(e);return(r=(o=(t=a==null?void 0:a.filter)==null?void 0:t.call(a,l=>(l==null?void 0:l.interface)&&!(l!=null&&l.target)&&l.type!=="boolean"))==null?void 0:o.map)==null?void 0:r.call(o,l=>{var c;return{value:l.name,label:i(((c=l==null?void 0:l.uiSchema)==null?void 0:c.title)||l.name)}})},useColorFields=e=>{var t,o,r;const i=useCompile(),{getCollectionFields:n}=useCollectionManager_deprecated();if(!e)return[];const a=n(e);return(r=(o=(t=a==null?void 0:a.filter)==null?void 0:t.call(a,l=>(l==null?void 0:l.interface)==="color"))==null?void 0:o.map)==null?void 0:r.call(o,l=>{var c;return{value:l.name,label:i(((c=l==null?void 0:l.uiSchema)==null?void 0:c.title)||l.name)}})},TableColumnDesigner$1=e=>{var t,o,r,i,n,a,l,c,u,m,d,p;const{uiSchema:g,fieldSchema:h,collectionField:f}=e,{form:_}=useFormBlockContext(),{getInterface:v,getCollection:S}=useCollectionManager_deprecated(),C=(0,import_react.useField)(),{t:b}=(0,import_react_i18next.useTranslation)(),y=(0,import_react.useFieldSchema)(),{dn:F}=useDesignable(),j=((t=h==null?void 0:h["x-component-props"])==null?void 0:t.fieldNames)||((o=g==null?void 0:g["x-component-props"])==null?void 0:o.fieldNames),k=useLabelFields$1((r=f==null?void 0:f.target)!=null?r:f==null?void 0:f.targetCollection),T=useColorFields((i=f==null?void 0:f.target)!=null?i:f==null?void 0:f.targetCollection),O=v(f==null?void 0:f.interface),N=S(f==null?void 0:f.target),L=isFileCollection$2(N),D=["QuickEdit","FormItem"].includes(h["x-decorator"]),{currentMode:R}=useAssociationFieldContext(),{isAllowToSetDefaultValue:$}=useIsAllowToSetDefaultValue({collectionField:f,fieldSchema:h}),w=["datetime","createdAt","updatedAt"].includes(f==null?void 0:f.interface),I=["obo","oho","o2o","o2m","m2m","m2o","snapshot"].includes(f==null?void 0:f.interface),M=useFieldModeOptions({fieldSchema:h}),B=((n=h==null?void 0:h["x-component-props"])==null?void 0:n.mode)||"Select";let z="editable";h["x-disabled"]===!0&&(z="readonly"),h["x-read-pretty"]===!0&&(z="read-pretty");const E=I&&B==="Select",V=()=>{const{name:U}=useCollection(),{linkageRulesProps:G}=useSchemaToolbar();return(0,import_jsx_runtime.jsx)(SchemaSettingsLinkageRules,x({category:"style"},P(x({},G),{collectionName:U})))};return(0,import_jsx_runtime.jsxs)(GeneralSchemaDesigner,{disableInitializer:!0,children:[(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:b("Custom column title"),schema:{type:"object",title:b("Custom column title"),properties:{title:{title:b("Column title"),default:y==null?void 0:y.title,description:`${b("Original field title: ")}${((a=f==null?void 0:f.uiSchema)==null?void 0:a.title)||(h==null?void 0:h.title)}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:U})=>{U&&(C.title=U,y.title=U,F.emit("patch",{schema:{"x-uid":y["x-uid"],title:y.title}})),F.refresh()}}),E&&!C.readPretty&&!(g!=null&&g["x-read-pretty"])&&D&&(0,import_jsx_runtime.jsx)(SchemaSettingsDataScope,{collectionName:f==null?void 0:f.target,defaultFilter:((u=(c=(l=h==null?void 0:h["x-component-props"])==null?void 0:l.service)==null?void 0:c.params)==null?void 0:u.filter)||{},form:_,onSubmit:({filter:U})=>{var G,W;U=removeNullCondition(U),(0,import_lodash.set)(C.componentProps,"service.params.filter",U),h["x-component-props"]=C.componentProps;const Y=(W=C.path)==null?void 0:W.splice(((G=C.path)==null?void 0:G.length)-1,1);C.form.query(`${Y.concat("*."+h.name)}`).forEach(H=>{H.componentProps.service=H.componentProps.service||{params:{}},H.componentProps.service.params.filter=U}),F.emit("patch",{schema:{"x-uid":h["x-uid"],"x-component-props":C.componentProps}})}}),(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:b("Column width"),schema:{type:"object",title:b("Column width"),properties:{width:{default:((m=y==null?void 0:y["x-component-props"])==null?void 0:m.width)||100,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{}}}},onSubmit:({width:U})=>{const G=y["x-component-props"]||{};G.width=U;const W={"x-uid":y["x-uid"]};W["x-component-props"]=G,y["x-component-props"]=G,C.componentProps.width=U,F.emit("patch",{schema:W}),F.refresh()}}),(0,import_jsx_runtime.jsx)(V,{}),O&&O.sortable===!0&&!R&&(0,import_jsx_runtime.jsx)(SchemaSettingsSwitchItem,{title:b("Sortable"),checked:C.componentProps.sorter,onChange:U=>{const G={"x-uid":y["x-uid"]};y["x-component-props"]=P(x({},y["x-component-props"]),{sorter:U}),G["x-component-props"]=y["x-component-props"],C.componentProps.sorter=U,F.emit("patch",{schema:G}),F.refresh()}}),["linkTo","m2m","m2o","o2m","obo","oho","snapshot","createdBy","updatedBy"].includes(f==null?void 0:f.interface)&&!L&&(z==="read-pretty"||C.readPretty||C.readOnly)&&(0,import_jsx_runtime.jsx)(SchemaSettingsSwitchItem,{title:b("Enable link"),checked:((d=h["x-component-props"])==null?void 0:d.enableLink)!==!1,onChange:U=>{h["x-component-props"]=P(x({},h==null?void 0:h["x-component-props"]),{enableLink:U}),C.componentProps=P(x({},h==null?void 0:h["x-component-props"]),{enableLink:U}),F.emit("patch",{schema:{"x-uid":h["x-uid"],"x-component-props":x({},h==null?void 0:h["x-component-props"])}}),F.refresh()}}),["linkTo","m2m","m2o","o2m","obo","oho","snapshot"].includes(f==null?void 0:f.interface)&&(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:b("Title field"),options:k,value:j==null?void 0:j.label,onChange:U=>{var G,W,Y,H,J;const X=P(x(x({},(W=(G=f==null?void 0:f.uiSchema)==null?void 0:G["x-component-props"])==null?void 0:W.fieldNames),(Y=h==null?void 0:h["x-component-props"])==null?void 0:Y.fieldNames),{label:U});import_lodash.default.set(h,"x-component-props.fieldNames",X);const Q=(J=C.path)==null?void 0:J.splice(((H=C.path)==null?void 0:H.length)-1,1);C.form.query(`${Q.concat("*."+h.name)}`).forEach(ee=>{ee.componentProps.fieldNames=X}),F.emit("patch",{schema:{"x-uid":h["x-uid"],"x-component-props":x({},h["x-component-props"])}}),F.refresh()}}),I&&(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:b("Field component"),options:z==="read-pretty"?[{label:b("Title"),value:"Select"},L&&{label:b("File manager"),value:"FileManager"},{label:b("Tag"),value:"Tag"}].filter(Boolean):M,value:B,onChange:U=>{const G={"x-uid":h["x-uid"]};h["x-component-props"]=h["x-component-props"]||{},h["x-component-props"].mode=U,G["x-component-props"]=h["x-component-props"],C.componentProps=C.componentProps||{},C.componentProps.mode=U,F.emit("patch",{schema:G}),F.refresh()}},"field-mode"),["Tag"].includes(B)&&(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:b("Tag color field"),options:T,value:(p=h==null?void 0:h["x-component-props"])==null?void 0:p.tagColorField,onChange:U=>{const G={"x-uid":h["x-uid"]};h["x-component-props"]=h["x-component-props"]||{},h["x-component-props"].tagColorField=U,G["x-component-props"]=h["x-component-props"],C.componentProps.tagColorField=U,F.emit("patch",{schema:G}),F.refresh()}},"title-field"),D&&!C.readPretty&&!(g!=null&&g["x-read-pretty"])&&(0,import_jsx_runtime.jsx)(SchemaSettingsSwitchItem,{title:b("Required"),checked:h.required,onChange:U=>{var G,W;const Y={"x-uid":h["x-uid"]};h.required=U,Y.required=U;const H=(W=C.path)==null?void 0:W.splice(((G=C.path)==null?void 0:G.length)-1,1);C.form.query(`${H.concat("*."+h.name)}`).forEach(J=>{J.required=U}),F.emit("patch",{schema:Y}),F.refresh()}},"required"),D&&!(C!=null&&C.readPretty)&&(f==null?void 0:f.interface)!=="o2m"&&!isPatternDisabled(h)&&(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:b("Pattern"),options:[{label:b("Editable"),value:"editable"},{label:b("Readonly"),value:"readonly"},{label:b("Easy-reading"),value:"read-pretty"}],value:z,onChange:U=>{var G,W;const Y={"x-uid":h["x-uid"]},H=(W=C.path)==null?void 0:W.splice(((G=C.path)==null?void 0:G.length)-1,1);switch(U){case"readonly":{h["x-read-pretty"]=!1,h["x-disabled"]=!0,Y["x-read-pretty"]=!1,Y["x-disabled"]=!0,C.form.query(`${H.concat("*."+h.name)}`).forEach(J=>{J.readonly=!0,J.disabled=!0});break}case"read-pretty":{h["x-read-pretty"]=!0,h["x-disabled"]=!1,Y["x-read-pretty"]=!0,Y["x-disabled"]=!1,C.form.query(`${H.concat("*."+h.name)}`).forEach(J=>{J.readPretty=!0});break}default:{h["x-read-pretty"]=!1,h["x-disabled"]=!1,Y["x-read-pretty"]=!1,Y["x-disabled"]=!1,C.form.query(`${H.concat("*."+h.name)}`).forEach(J=>{J.readPretty=!1,J.disabled+!1});break}}F.emit("patch",{schema:Y}),F.refresh()}},"pattern"),w&&(0,import_jsx_runtime.jsx)(SchemaSettingsDateFormat,{fieldSchema:h}),D&&!(C!=null&&C.readPretty)&&["obo","oho","o2o","o2m","m2m","m2o"].includes(f==null?void 0:f.interface)&&(0,import_jsx_runtime.jsx)(SchemaSettingsSortingRule,{fieldSchema:h,onSubmitCallBack:U=>{var G,W;const Y=(W=C.path)==null?void 0:W.splice(((G=C.path)==null?void 0:G.length)-1,1);C.form.query(`${Y.concat("*."+h.name)}`).forEach(H=>{H.componentProps.service=H.componentProps.service||{params:{}},H.componentProps.service.params.sort=U})}}),$(D)&&(0,import_jsx_runtime.jsx)(SchemaSettingsDefaultValue,{fieldSchema:h}),(0,import_jsx_runtime.jsx)(SchemaSettingsDivider,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsRemove,{removeParentsIfNoChildren:!D,breakRemoveOn:{"x-component":"Grid"},confirm:{title:b("Delete table column")}})]})};function isFileCollection$2(e){return(e==null?void 0:e.template)==="file"}const allowAddNew={name:"allowAddNew",type:"switch",useVisible(){const e=useFlag(),t=useIsFieldReadPretty(),o=useIsAssociationField(),r=useFieldMode();return!(e!=null&&e.isInSubTable)&&!t&&o&&["Picker"].includes(r)},useComponentProps(){const{defaultOpenMode:e}=useOpenModeContext(),{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n,insertAdjacent:a}=useDesignable();return{title:t("Allow add new data"),checked:r["x-add-new"],onChange(l){r.reduceProperties((u,m)=>m["x-component"]==="Action"?m:u,null)||a("afterBegin",{"x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-toolbar":"ActionSchemaToolbar","x-toolbar-props":{draggable:!1},"x-settings":"actionSettings:addNew","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:e,type:"default",component:"CreateRecordAction"}});const c={"x-uid":r["x-uid"]};o["x-add-new"]=l,r["x-add-new"]=l,c["x-add-new"]=l,i.emit("patch",{schema:c}),n()}}}},formItemSettings=new SchemaSettings({name:"FormItemSettings",items:[...generalSettingsItems,{name:"allowAddNewData",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useIsAssociationField(),o=useFieldMode();return!e&&t&&["SubTable"].includes(o)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow add new"),checked:((e=r["x-component-props"])==null?void 0:e.allowAddnew)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.allowAddnew=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].allowAddnew=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"allowSelectExistingRecord",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useIsAssociationField(),o=useFieldMode();return!e&&t&&["SubTable"].includes(o)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow selection of existing records"),checked:(e=r["x-component-props"])==null?void 0:e.allowSelectExistingRecord,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.allowSelectExistingRecord=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].allowSelectExistingRecord=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"quickUpload",type:"switch",useVisible(){const e=useIsFileField();return!useIsFormReadPretty()&&e},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Quick upload"),checked:((e=r["x-component-props"])==null?void 0:e.quickUpload)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.quickUpload=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].quickUpload=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"selectFile",type:"switch",useVisible(){const e=useIsFileField();return!useIsFormReadPretty()&&e},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Select file"),checked:((e=r["x-component-props"])==null?void 0:e.selectFile)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.selectFile=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].selectFile=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"validationRules",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r,refresh:i}=useDesignable(),n=useValidateSchema(),{getCollectionJoinField:a}=useCollectionManager_deprecated(),{getField:l}=useCollection_deprecated(),c=l(o.name)||a(o["x-collection-field"]);return{title:e("Set validation rules"),components:{ArrayCollapse:import_antd_v5.ArrayCollapse,FormLayout:import_antd_v5.FormLayout},schema:{type:"object",title:e("Set validation rules"),properties:{rules:{type:"array",default:o==null?void 0:o["x-validator"],"x-component":"ArrayCollapse","x-decorator":"FormItem","x-component-props":{accordion:!0},maxItems:3,items:{type:"object","x-component":"ArrayCollapse.CollapsePanel","x-component-props":{header:'{{ t("Validation rule") }}'},properties:{index:{type:"void","x-component":"ArrayCollapse.Index"},layout:{type:"void","x-component":"FormLayout","x-component-props":{labelStyle:{marginTop:"6px"},labelCol:8,wrapperCol:16},properties:P(x({},n),{message:{type:"string",title:'{{ t("Error message") }}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:2,maxRows:2}}}})},remove:{type:"void","x-component":"ArrayCollapse.Remove"},moveUp:{type:"void","x-component":"ArrayCollapse.MoveUp"},moveDown:{type:"void","x-component":"ArrayCollapse.MoveDown"}}},properties:{add:{type:"void",title:'{{ t("Add validation rule") }}',"x-component":"ArrayCollapse.Addition","x-reactions":{dependencies:["rules"],fulfill:{state:{disabled:"{{$deps[0].length >= 3}}"}}}}}}}},onSubmit(u){var m;const d=[];for(const h of u.rules)d.push(import_lodash.default.pickBy(h,import_lodash.default.identity));const p={"x-uid":o["x-uid"]};if(["percent"].includes(c==null?void 0:c.interface))for(const h of d)(h.maxValue||h.minValue)&&(h.percentMode=!0),h.percentFormat&&(h.percentFormats=!0);const g=import_lodash.default.concat([],((m=c==null?void 0:c.uiSchema)==null?void 0:m["x-validator"])||[],d);t.validator=g,o["x-validator"]=d,p["x-validator"]=d,r.emit("patch",{schema:p}),i()}}},useVisible(){const{form:e}=useFormBlockContext(),t=useIsFormReadPretty(),o=useValidateSchema();return e&&!t&&o}},{name:"defaultValue",Component:SchemaSettingsDefaultValue,useVisible(){const{isAllowToSetDefaultValue:e}=useIsAllowToSetDefaultValue();return e()}},{name:"dataScope",Component:SchemaSettingsDataScope,useVisible(){const e=useIsSelectFieldMode(),t=useIsFormReadPretty();return e&&!t},useComponentProps(){var e,t,o;const{getCollectionJoinField:r,getAllCollectionsInheritChain:i}=useCollectionManager_deprecated(),{getField:n}=useCollection_deprecated(),{form:a}=useFormBlockContext(),l=useRecord(),c=(0,import_react.useField)(),u=(0,import_react.useFieldSchema)(),m=n(u.name)||r(u["x-collection-field"]),d=useVariables$1(),p=useLocalVariables$1(),{dn:g}=useDesignable();return{collectionName:m==null?void 0:m.target,defaultFilter:((o=(t=(e=u==null?void 0:u["x-component-props"])==null?void 0:e.service)==null?void 0:t.params)==null?void 0:o.filter)||{},form:a,dynamicComponent:h=>(0,import_jsx_runtime.jsx)(VariableInput,P(x({},h),{form:a,collectionField:h.collectionField,record:l,shouldChange:getShouldChange({collectionField:h.collectionField,variables:d,localVariables:p,getAllCollectionsInheritChain:i})})),onSubmit:({filter:h})=>{h=removeNullCondition(h),import_lodash.default.set(c.componentProps,"service.params.filter",h),u["x-component-props"]=c.componentProps,g.emit("patch",{schema:{"x-uid":u["x-uid"],"x-component-props":c.componentProps}})}}}},{name:"sortingRule",Component:SchemaSettingsSortingRule,useVisible(){const e=useIsSelectFieldMode(),t=useIsFormReadPretty();return e&&!t}},{name:"fieldMode",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable(),i=useFieldModeOptions(),n=useIsAddNewForm(),a=useFieldMode();return{title:e("Field component"),options:i,value:a,onChange(l){const c={"x-uid":o["x-uid"]};o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].mode=l,c["x-component-props"]=o["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=l,isSubMode(o)&&n&&(c.default=null,o.default=null,t.setInitialValue(null),t.setValue(null)),r.emit("patch",{schema:c}),r.refresh()}}},useVisible:useShowFieldMode},{name:"popupSize",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n}=useDesignable();return{title:o("Popup size"),options:[{label:o("Small"),value:"small"},{label:o("Middle"),value:"middle"},{label:o("Large"),value:"large"}],value:(t=(e=i==null?void 0:i["x-component-props"])==null?void 0:e.openSize)!=null?t:"middle",onChange:a=>{r.componentProps.openSize=a,i["x-component-props"]=r.componentProps,n.emit("patch",{schema:{"x-uid":i["x-uid"],"x-component-props":i["x-component-props"]}}),n.refresh()}}},useVisible(){var e;const t=useShowFieldMode(),o=((e=(0,import_react.useFieldSchema)()["x-component-props"])==null?void 0:e.mode)==="Picker";return t&&o}},allowAddNew,{name:"addMode",type:"select",useVisible(){const e=useIsFieldReadPretty(),t=useIsAssociationField(),o=useFieldMode();return!e&&t&&["Select"].includes(o)},useComponentProps(){var e;const{defaultOpenMode:t}=useOpenModeContext(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n,insertAdjacent:a}=useDesignable();return{title:o("Quick create"),options:[{label:o("None"),value:"none"},{label:o("Dropdown"),value:"quickAdd"},{label:o("Pop-up"),value:"modalAdd"}],value:((e=r.componentProps)==null?void 0:e.addMode)||"none",onChange(l){l==="modalAdd"&&(i.reduceProperties((u,m)=>m["x-component"]==="Action"?m:u,null)||a("afterBegin",{"x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:addNew","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:t,type:"default",component:"CreateRecordAction"}}));const c={"x-uid":i["x-uid"]};i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].addMode=l,c["x-component-props"]=i["x-component-props"],r.componentProps=r.componentProps||{},r.componentProps.addMode=l,n.emit("patch",{schema:c}),n.refresh()}}}},{name:"multiple",type:"switch",useVisible(){const e=useIsAssociationField(),t=useIsShowMultipleSwitch();return e&&t()},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow multiple"),checked:((e=r["x-component-props"])==null?void 0:e.multiple)===void 0?!0:r["x-component-props"].multiple,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].multiple=a,o.componentProps.multiple=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"allowDissociate",type:"switch",useVisible(){var e;const t=useIsShowMultipleSwitch();return((e=(0,import_react.useFieldSchema)()["x-component-props"])==null?void 0:e.mode)==="Nester"&&t()},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow dissociate"),checked:((e=r["x-component-props"])==null?void 0:e.allowDissociate)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].allowDissociate=a,o.componentProps.allowDissociate=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},{name:"enableLink",type:"switch",useVisible(){const e=useTitleFieldOptions(),t=useIsFieldReadPretty(),o=useIsFileField(),r=(0,import_react.useFieldSchema)();return t&&e.length>0&&!o&&r["x-component"]==="CollectionField"},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Enable link"),checked:((e=r["x-component-props"])==null?void 0:e.enableLink)!==!1,onChange(n){r["x-component-props"]=P(x({},r==null?void 0:r["x-component-props"]),{enableLink:n}),o.componentProps.enableLink=n,i.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":x({},r==null?void 0:r["x-component-props"])}}),i.refresh()}}}},{name:"pattern",type:"select",useVisible(){const{form:e}=useFormBlockContext(),t=(0,import_react.useFieldSchema)();return e&&!(e!=null&&e.readPretty)&&!isPatternDisabled(t)},useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable();let i="editable";return o["x-disabled"]===!0&&(i="readonly"),o["x-read-pretty"]===!0&&(i="read-pretty"),{title:e("Pattern"),options:[{label:e("Editable"),value:"editable"},{label:e("Readonly"),value:"readonly"},{label:e("Easy-reading"),value:"read-pretty"}],value:i,onChange(n){const a={"x-uid":o["x-uid"]};switch(n){case"readonly":{o["x-read-pretty"]=!1,o["x-disabled"]=!0,a["x-read-pretty"]=!1,a["x-disabled"]=!0,t.readPretty=!1,t.disabled=!0,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.ReadOnly));break}case"read-pretty":{o["x-read-pretty"]=!0,o["x-disabled"]=!1,a["x-read-pretty"]=!0,a["x-disabled"]=!1,t.readPretty=!0,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.ReadPretty));break}default:{o["x-read-pretty"]=!1,o["x-disabled"]=!1,a["x-read-pretty"]=!1,a["x-disabled"]=!1,t.readPretty=!1,t.disabled=!1,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.Editable));break}}r.emit("patch",{schema:a}),r.refresh()}}}},{name:"titleField",type:"select",useVisible(){const e=useTitleFieldOptions(),t=useIsAssociationField(),o=useFieldMode();return e.length>0&&t&&o!=="SubTable"},useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n}=useDesignable(),a=useTitleFieldOptions(),l=useCollectionField_deprecated();return{title:o("Title field"),options:a,value:(t=(e=r==null?void 0:r.componentProps)==null?void 0:e.fieldNames)==null?void 0:t.label,onChange(c){var u,m;const d={"x-uid":i["x-uid"]},p=P(x(x({},(m=(u=l==null?void 0:l.uiSchema)==null?void 0:u["x-component-props"])==null?void 0:m.fieldNames),r.componentProps.fieldNames),{label:c});i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].fieldNames=p,d["x-component-props"]=i["x-component-props"],r.componentProps.fieldNames=i["x-component-props"].fieldNames,n.emit("patch",{schema:d}),n.refresh()}}}},{name:"dateFormat",Component:SchemaSettingsDateFormat,useVisible(){const e=useFormItemCollectionField();return["datetime","createdAt","updatedAt"].includes(e==null?void 0:e.interface)},useComponentProps(){return{fieldSchema:(0,import_react.useFieldSchema)()}}},{name:"size",type:"select",useVisible(){const e=useIsFieldReadPretty(),t=useFormItemCollectionField(),{getCollection:o}=useCollectionManager_deprecated(),r=o(t==null?void 0:t.target),i=["attachment"].includes(t==null?void 0:t.interface)||(r==null?void 0:r.template)==="file";return e&&i},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Size"),options:[{label:t("Large"),value:"large"},{label:t("Default"),value:"default"},{label:t("Small"),value:"small"}],value:((e=o==null?void 0:o.componentProps)==null?void 0:e.size)||"default",onChange(n){const a={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].size=n,a["x-component-props"]=r["x-component-props"],o.componentProps=o.componentProps||{},o.componentProps.size=n,i.emit("patch",{schema:a}),i.refresh()}}}},{name:"tagColor",type:"select",useVisible(){const e=useIsAssociationField(),t=useFieldMode();return e&&["Tag"].includes(t)},useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n}=useDesignable(),a=useFormItemCollectionField(),l=useColorFields((e=a==null?void 0:a.target)!=null?e:a==null?void 0:a.targetCollection);return{title:o("Tag color field"),options:l,value:(t=r==null?void 0:r.componentProps)==null?void 0:t.tagColorField,onChange(c){const u={"x-uid":i["x-uid"]};i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].tagColorField=c,u["x-component-props"]=i["x-component-props"],r.componentProps.tagColorField=c,n.emit("patch",{schema:u}),n.refresh()}}}},{name:"divider",type:"divider",useVisible(){return!!useFormItemCollectionField()}},{name:"remove",type:"remove",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!0,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]});function useIsAddNewForm(){const e=useRecord();return import_lodash.default.isEmpty(import_lodash.default.omit(e,["__parent","__collectionName"]))}function isFileCollection$1(e){return(e==null?void 0:e.template)==="file"}function useIsFormReadPretty(){const{form:e}=useFormBlockContext();return!!(e!=null&&e.readPretty)}function useIsFieldReadPretty(){const{fieldSchema:e}=useColumnSchema$1();return(0,import_react.useField)().readPretty||(e==null?void 0:e["x-read-pretty"])}function useFormItemCollectionField(){const{getCollectionJoinField:e}=useCollectionManager_deprecated(),{getField:t}=useCollection_deprecated(),o=(0,import_react.useFieldSchema)(),{collectionField:r}=useColumnSchema$1(),i=o?t(o.name)||e(o["x-collection-field"]):null;return o?i||r:null}function useIsAssociationField(){const e=useFormItemCollectionField();return["obo","oho","o2o","o2m","m2m","m2o","updatedBy","createdBy","mbm"].includes(e==null?void 0:e.interface)}function useIsFileField(){const e=useCollectionManager(),t=useFormItemCollectionField(),o=e.getCollection(t==null?void 0:t.target);return isFileCollection$1(o)}function useFieldMode(){var e;const t=(0,import_react.useField)(),o=useIsFileField();return((e=t==null?void 0:t.componentProps)==null?void 0:e.mode)||(o?"FileManager":"Select")}function useIsSelectFieldMode(){const e=useFieldMode();return useIsAssociationField()&&e==="Select"}function useValidateSchema(){var e;const{getInterface:t}=useCollectionManager_deprecated(),o=(0,import_react.useFieldSchema)(),r=useFormItemCollectionField(),i=t(r==null?void 0:r.interface);return(e=i==null?void 0:i.validateSchema)==null?void 0:e.call(i,o)}function useShowFieldMode(){const e=(0,import_react.useFieldSchema)(),t=useFieldModeOptions(),o=e["x-component"]==="TableField";return useIsAssociationField()&&t&&!o}function useTitleFieldOptions(){var e;const{getCollectionFields:t,isTitleField:o}=useCollectionManager_deprecated(),r=useCompile(),i=useFormItemCollectionField();return(i!=null&&i.target?t(i==null?void 0:i.target):(e=t(i==null?void 0:i.targetCollection))!=null?e:[]).filter(n=>o(n)).map(n=>{var a;return{value:n==null?void 0:n.name,label:r((a=n==null?void 0:n.uiSchema)==null?void 0:a.title)||(n==null?void 0:n.name)}})}function useFieldComponentName(){var e,t,o,r;const{fieldSchema:i,collectionField:n}=useColumnSchema$1(),a=(0,import_react.useField)(),l=useIsFileField(),c=(0,import_react.useFieldSchema)(),u=useCollectionField(),m=i||c,d=n||u,p={AssociationField:"Select"},g=((e=m==null?void 0:m["x-component-props"])==null?void 0:e.mode)||((t=a==null?void 0:a.componentProps)==null?void 0:t.mode)||(l?"FileManager":"")||((o=m==null?void 0:m["x-component-props"])==null?void 0:o.component)||((r=d==null?void 0:d.uiSchema)==null?void 0:r["x-component"]);return p[g]||g}const CurrentUserContext=(0,import_react2.createContext)(null);CurrentUserContext.displayName="CurrentUserContext";const useCurrentUserContext=()=>(0,import_react2.useContext)(CurrentUserContext),useCurrentRoles=()=>{var e;const{allowAnonymous:t}=useACLRoleContext(),{data:o}=useCurrentUserContext(),r=useCompile();return(0,import_react2.useMemo)(()=>{var i;const n=(((i=o==null?void 0:o.data)==null?void 0:i.roles)||[]).map(({name:a,title:l})=>({name:a,title:r(l)}));return t&&n.push({title:"Anonymous",name:"anonymous"}),n},[t,(e=o==null?void 0:o.data)==null?void 0:e.roles])},CurrentUserProvider=e=>{const{render:t}=useAppSpin(),o=useRequest({url:"auth:check"});return o.loading?t():(0,import_jsx_runtime.jsx)(CurrentUserContext.Provider,{value:o,children:e.children})},NavigateToSigninWithRedirect=()=>{const{pathname:e,search:t}=useLocationNoUpdate(),o=`?redirect=${e}${t}`;return(0,import_jsx_runtime.jsx)(import_react_router_dom.Navigate,{replace:!0,to:`/signin${o}`})},NavigateIfNotSignIn=({children:e})=>{var t,o;const r=useCurrentUserContext();return r.loading===!1&&!((o=(t=r.data)==null?void 0:t.data)!=null&&o.id)?(0,import_jsx_runtime.jsx)(NavigateToSigninWithRedirect,{}):(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e})},useSwitchRole=()=>{const e=useAPIClient(),t=useCurrentRoles(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react2.useMemo)(()=>({key:"role",eventKey:"SwitchRole",label:(0,import_jsx_runtime.jsx)(SelectWithTitle,{title:o("Switch role"),fieldNames:{label:"title",value:"name"},options:t,defaultValue:e.auth.role,onChange:i=>q(void 0,null,function*(){e.auth.setRole(i),yield e.resource("users").setDefaultRole({values:{roleName:i}}),location.reload(),window.location.reload()})})}),[e,t,o]);return t.length<=1?null:r},useNickname=()=>{var e,t,o;const{data:r}=useCurrentUserContext(),{token:i}=useToken$1();return(0,import_react2.useMemo)(()=>{var n,a,l;return{key:"nickname",disabled:!0,label:(0,import_jsx_runtime.jsx)("span",{"aria-disabled":"false",style:{cursor:"text",color:i.colorTextDescription},children:((n=r==null?void 0:r.data)==null?void 0:n.nickname)||((a=r==null?void 0:r.data)==null?void 0:a.username)||((l=r==null?void 0:r.data)==null?void 0:l.email)})}},[(e=r==null?void 0:r.data)==null?void 0:e.email,(t=r==null?void 0:r.data)==null?void 0:t.nickname,(o=r==null?void 0:r.data)==null?void 0:o.username,r==null?void 0:r.data.version,i.colorTextDescription])},SettingsMenu$1=e=>{const{addMenuItem:t,getMenuItems:o}=useCurrentUserSettingsMenu(),{redirectUrl:r=""}=e,{allowAll:i,snippets:n}=useACLRoleContext(),a=i||(n==null?void 0:n.includes("app")),l=useNavigateNoUpdate(),c=useAPIClient(),{t:u}=(0,import_react_i18next.useTranslation)(),m=useAPIClient(),d=(0,import_react2.useCallback)(()=>q(void 0,null,function*(){return yield new Promise(C=>{const b=setInterval(()=>{m.silent().resource("app").getInfo().then(y=>((y==null?void 0:y.status)===200&&(C("ok"),clearInterval(b)),y)).catch(y=>{(0,import_client.error)(y)})},3e3)})}),[m]),p=useNickname(),g=useEditProfile(),h=useChangePassword(),f=useSwitchRole(),_=useLanguageSettings(),{modal:v}=import_antd.App.useApp(),S=(0,import_react2.useMemo)(()=>a?[{key:"cache",label:u("Clear cache"),onClick:()=>q(void 0,null,function*(){yield c.resource("app").clearCache(),window.location.reload()})},{key:"reboot",label:u("Restart application"),onClick:()=>q(void 0,null,function*(){v.confirm({title:u("Restart application"),okText:u("Restart"),okButtonProps:{danger:!0},onOk:()=>q(void 0,null,function*(){yield c.resource("app").restart()})})})},{key:"divider_4",type:"divider"}]:[],[c,a,d,v,u]);return(0,import_react2.useMemo)(()=>{[p,{key:"divider_1",type:"divider"},g,h,(g||h)&&{key:"divider_2",type:"divider"},f,{key:"divider_3",type:"divider"},...S,{key:"signout",label:u("Sign out"),onClick:()=>q(void 0,null,function*(){var C;const{data:b}=yield c.auth.signOut();(C=b==null?void 0:b.data)!=null&&C.redirect?window.location.href=b.data.redirect:l(`/signin?redirect=${encodeURIComponent(r)}`)})}].forEach(C=>{C&&t(C)}),_&&t(_,{before:"divider_3"})},[t,c.auth,h,S,g,_,l,r,f,u,p]),(0,import_jsx_runtime.jsx)(import_antd.Menu,{items:o()})},DropdownVisibleContext=(0,import_react2.createContext)(null);DropdownVisibleContext.displayName="DropdownVisibleContext";const CurrentUser=()=>{const[e,t]=(0,import_react2.useState)(!1),{token:o}=useToken$1();return(0,import_jsx_runtime.jsx)("div",{className:import_css.css`
417
417
  display: inline-block;
418
418
  vertical-align: top;
419
419
  width: 46px;
@@ -553,7 +553,7 @@ https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModu
553
553
  & > .ant-space-item:last-child {
554
554
  flex-shrink: 0;
555
555
  }
556
- `},properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":t,"x-component-props":{placeholder:'{{t("Value")}}',useTypedConstant:!0,changeOnSelect:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}},properties:{add:{type:"void",title:'{{t("Add parameter")}}',"x-component":"ArrayItems.Addition"}}}),[t]),a=(0,import_react2.useMemo)(()=>({type:"boolean","x-content":e("Open in new window"),"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}}}),[e]);return{urlSchema:o,paramsSchema:n,openInNewWindowSchema:a,modeSchema:r,htmlSchema:i}},SchemaSettingsActionLinkItem=()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),{dn:o}=useDesignable(),{t:r}=(0,import_react_i18next.useTranslation)(),{urlSchema:i,paramsSchema:n,openInNewWindowSchema:a}=useURLAndHTMLSchema(),l=t["x-component-props"]||{},c={url:l.url,params:l.params||[{}],openInNewWindow:l.openInNewWindow};return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:r("Edit link"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:r("Edit link"),properties:{url:P(x({},i),{required:!0}),params:n,openInNewWindow:a}},onSubmit:({url:u,params:m,openInNewWindow:d})=>{l.url=u,l.params=m,l.openInNewWindow=d,t["x-component-props"]=l,e.componentProps.url=u,e.componentProps.params=m,e.componentProps.openInNewWindow=d,o.emit("patch",{schema:{"x-uid":t["x-uid"],"x-component-props":l}}),o.refresh()},initialValues:c})},customizeLinkActionSettings=new SchemaSettings({name:"actionSettings:link",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"editLink",Component:SchemaSettingsActionLinkItem},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useVisible(){const e=useCollectionRecord();return!import_lodash.default.isEmpty(e==null?void 0:e.data)},useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),refreshActionSettings=new SchemaSettings({name:"actionSettings:refresh",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"secondConFirm",Component:SecondConFirm},{name:"delete",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),customizeSaveRecordActionSettings=new SchemaSettings({name:"actionSettings:saveRecord",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"secondConfirmation",Component:SecondConFirm},{name:"assignFieldValues",Component:AssignedFieldValues},{name:"skipRequiredValidation",Component:SkipValidation},{name:"afterSuccessfulSubmission",Component:AfterSuccess},{name:"bindWorkflow",Component:WorkflowConfig},{name:"refreshDataBlockRequest",Component:RefreshDataBlockRequest,useComponentProps(){return{isPopupAction:!1}}},{name:"delete",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),updateSubmitActionSettings=new SchemaSettings({name:"actionSettings:updateSubmit",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})},useVisible(){return!(0,import_react.useFieldSchema)().parent["x-initializer"].includes("bulkEditForm")}},{name:"secondConfirmation",Component:SecondConFirm},{name:"workflowConfig",Component:WorkflowConfig,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.triggerWorkflows)}},{name:"assignFieldValues",Component:AssignedFieldValues,useVisible(){return!(0,import_react.useFieldSchema)().parent["x-initializer"].includes("bulkEditForm")}},{name:"skipRequiredValidation",Component:SkipValidation,useVisible(){return!(0,import_react.useFieldSchema)().parent["x-initializer"].includes("bulkEditForm")}},{name:"afterSuccessfulSubmission",Component:AfterSuccess},{name:"refreshDataBlockRequest",Component:RefreshDataBlockRequest,useComponentProps(){return{isPopupAction:!1}}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),submitActionSettings=new SchemaSettings({name:"actionSettings:submit",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"secondConfirmation",Component:SecondConFirm},{name:"workflowConfig",Component:WorkflowConfig,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.triggerWorkflows)}},{name:"saveMode",Component:SaveMode,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return t["x-action"]==="submit"&&isInitializersSame((e=t.parent)==null?void 0:e["x-initializer"],"createForm:configureActions")}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),customizeUpdateRecordActionSettings=new SchemaSettings({name:"actionSettings:updateRecord",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"secondConFirm",Component:SecondConFirm},{name:"assignFieldValues",Component:AssignedFieldValues},{name:"afterSuccessfulSubmission",Component:AfterSuccess},{name:"workflowConfig",Component:WorkflowConfig,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.triggerWorkflows)}},{name:"refreshDataBlockRequest",Component:RefreshDataBlockRequest,useComponentProps(){return{isPopupAction:!1}}},{name:"delete",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),customizePopupActionSettings=new SchemaSettings({name:"actionSettings:popup",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})},useVisible(){const{collection:e}=useCurrentPopupRecord()||{},t=useCollection();return!e||(e==null?void 0:e.name)===(t==null?void 0:t.name)}},{name:"openMode",Component:SchemaSettingOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=useOpenModeContext();return{openMode:!e,openSize:!e}}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),editActionSettings=new SchemaSettings({name:"actionSettings:edit",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"openMode",Component:SchemaSettingOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=useOpenModeContext();return{openMode:!e,openSize:!e}}},{name:"delete",type:"remove"}]}),viewActionSettings=new SchemaSettings({name:"actionSettings:view",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"openMode",Component:SchemaSettingOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=useOpenModeContext();return{openMode:!e,openSize:!e}}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),commonItems$1=[{name:"title",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e,readPretty:!0}}},{name:"dataScope",Component:SchemaSettingsDataScope,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{form:i}=useFormBlockContext(),n=(0,import_react.useField)(),{dn:a}=useDesignable(),{service:l}=useDetailsBlockContext();return{collectionName:o,defaultFilter:((t=(e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.filter)||{},form:i,noRecord:!0,onSubmit:({filter:c})=>{c=removeNullCondition(c);const u=n.decoratorProps.params||{};u.filter=c,n.decoratorProps.params=u,r["x-decorator-props"].params=u,a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}}),l.params[0].page=1}}}},{name:"sortingRules",type:"modal",useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),{t:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_react.useFieldSchema)(),n=(0,import_react.useField)(),{service:a}=useDetailsBlockContext(),{dn:l}=useDesignable(),c=useSortFields(o),u=((t=(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.sort)||[],m=u==null?void 0:u.map(d=>d.startsWith("-")?{field:d.substring(1),direction:"desc"}:{field:d,direction:"asc"});return{title:r("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:r("Set default sorting rules"),properties:{sort:{type:"array",default:m,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:c,required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:r("ASC"),value:"asc"},{label:r("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:r("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit({sort:d}){var p;const g=d.map(f=>f.direction==="desc"?`-${f.field}`:f.field),h=n.decoratorProps.params||{};h.sort=g,n.decoratorProps.params=h,i["x-decorator-props"].params=h,l.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}}),a.run(P(x({},(p=a.params)==null?void 0:p[0]),{sort:g}))}}}},setDataLoadingModeSettingsItem,{name:"template",Component:SchemaSettingsTemplate,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{componentName:`${i}Details`,collectionName:o,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}],multiDataDetailsBlockSettings=new SchemaSettings({name:"blockSettings:multiDataDetails",items:commonItems$1}),detailsWithPaginationSettings=new SchemaSettings({name:"blockSettings:detailsWithPagination",items:commonItems$1}),commonItems=[{name:"title",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection();return{collectionName:e,readPretty:!0}}},{name:"formItemTemplate",Component:SchemaSettingsFormItemTemplate,useComponentProps(){var e,t;const{name:o}=useCollection(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{insertAdjacentPosition:"beforeEnd",componentName:`${i}ReadPrettyFormItem`,collectionName:o,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}],singleDataDetailsBlockSettings=new SchemaSettings({name:"blockSettings:singleDataDetails",items:commonItems}),detailsBlockSettings=new SchemaSettings({name:"blockSettings:details",items:commonItems}),createFormBlockSettings=new SchemaSettings({name:"blockSettings:createForm",items:[{name:"title",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"dataTemplates",Component:SchemaSettingsDataTemplates,useVisible(){const{action:e}=useFormBlockContext(),t=(0,import_react.useFieldSchema)();return!e&&(t==null?void 0:t["x-acl-action"].includes("create"))},useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"divider",type:"divider"},{name:"formItemTemplate",Component:SchemaSettingsFormItemTemplate,useComponentProps(){var e,t;const{componentNamePrefix:o}=useBlockTemplateContext(),{name:r}=useCollection(),i=(0,import_react.useFieldSchema)(),n=((e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.resource)||((t=i==null?void 0:i["x-decorator-props"])==null?void 0:t.association);return{componentName:`${o}FormItem`,collectionName:r,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),editFormBlockSettings=new SchemaSettings({name:"blockSettings:editForm",items:[{name:"title",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"dataTemplates",Component:SchemaSettingsDataTemplates,useVisible(){const{action:e}=useFormBlockContext();return!e},useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"divider",type:"divider"},{name:"formItemTemplate",Component:SchemaSettingsFormItemTemplate,useComponentProps(){var e,t;const{componentNamePrefix:o}=useBlockTemplateContext(),{name:r}=useCollection(),i=(0,import_react.useFieldSchema)(),n=((e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.resource)||((t=i==null?void 0:i["x-decorator-props"])==null?void 0:t.association);return{componentName:`${o}FormItem`,collectionName:r,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),fieldComponentSettingsItem={name:"fieldComponent",type:"select",useVisible(){const e=useCollectionField(),t=useDataSourceManager();if(!e)return!1;const o=t.collectionFieldInterfaceManager.getFieldInterface(e==null?void 0:e.interface);return Array.isArray(o==null?void 0:o.componentOptions)&&o.componentOptions.length>1&&o.componentOptions.filter(r=>!r.useVisible||r.useVisible()).length>1},useComponentProps(){var e,t,o,r;const{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useField)(),a=(0,import_react.useFieldSchema)(),l=useCollectionField(),c=useDataSourceManager().collectionFieldInterfaceManager.getFieldInterface(l==null?void 0:l.interface),{fieldSchema:u}=useColumnSchema$1(),m=u||a,{dn:d}=useDesignable(),p=useCompile(),g=((t=(e=c==null?void 0:c.componentOptions)==null?void 0:e.filter(h=>!h.useVisible||h.useVisible()))==null?void 0:t.map(h=>({label:p(h.label),value:h.value,useProps:h.useProps})))||[];return{title:i("Field component"),options:g,value:((o=m["x-component-props"])==null?void 0:o.component)||((r=g[0])==null?void 0:r.value),onChange(h){var f;const _=g.find(S=>S.value===h),v=x({component:h},((f=_==null?void 0:_.useProps)==null?void 0:f.call(_))||{});import_lodash.default.set(m,"x-component-props",v),n.componentProps=v,d.emit("patch",{schema:{"x-uid":m["x-uid"],"x-component-props":v}})}}}},fieldSettingsFormItem=new SchemaSettings({name:"fieldSettings:FormItem",items:[{name:"decoratorOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Generic properties")}},useChildren(){return[{name:"editFieldTitle",type:"modal",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),{dn:o}=useDesignable(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),n=useCompile(),{getCollectionJoinField:a}=useCollectionManager_deprecated(),{getField:l}=useCollection_deprecated(),c=l(i.name)||a(i["x-collection-field"]);return{title:t("Edit field title"),schema:{type:"object",title:t("Edit field title"),properties:{title:{title:t("Field title"),default:r==null?void 0:r.title,description:`${t("Original field title: ")}${(e=c==null?void 0:c.uiSchema)==null?void 0:e.title}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit({title:u}){var m;const d=u.trim()===""?(m=c==null?void 0:c.uiSchema)==null?void 0:m.title:u;r.title=n(d),i.title=d,o.emit("patch",{schema:{"x-uid":i["x-uid"],title:i.title}}),o.refresh()}}}},{name:"displayTitle",type:"switch",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),{dn:o}=useDesignable(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)();return{title:t("Display title"),checked:(e=r.decoratorProps.showTitle)!=null?e:!0,onChange(n){i["x-decorator-props"]=i["x-decorator-props"]||{},i["x-decorator-props"].showTitle=n,r.decoratorProps.showTitle=n,o.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":P(x({},i["x-decorator-props"]),{showTitle:n})}}),o.refresh()}}}},{name:"editDescription",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),{dn:t}=useDesignable(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)();return{title:e("Edit description"),schema:{type:"object",title:e("Edit description"),properties:{description:{default:o==null?void 0:o.description,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}}}},onSubmit({description:i}){o.description=i,r.description=i,t.emit("patch",{schema:{"x-uid":r["x-uid"],description:r.description}})}}}},{name:"editTooltip",type:"modal",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),{dn:o}=useDesignable(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)();return{title:t("Edit tooltip"),schema:{type:"object",title:t("Edit tooltip"),properties:{tooltip:{default:(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.tooltip,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}}}},onSubmit({tooltip:n}){r.decoratorProps.tooltip=n,i["x-decorator-props"]=i["x-decorator-props"]||{},i["x-decorator-props"].tooltip=n,o.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}}),o.refresh()}}}},{name:"required",type:"switch",useVisible(){const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),{required:o=!0}=useSchemaToolbar();return!e.readPretty&&t["x-component"]!=="FormField"&&o},useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r,refresh:i}=useDesignable();return{title:e("Required"),checked:t.required,onChange(n){const a={"x-uid":o["x-uid"]};t.required=n,o.required=n,a.required=n,r.emit("patch",{schema:a}),i()}}}},{name:"setDefaultValue",useVisible(){const{isAllowToSetDefaultValue:e}=useIsAllowToSetDefaultValue();return e()},Component:SchemaSettingsDefaultValue},{name:"pattern",type:"select",useVisible(){const{form:e}=useFormBlockContext(),t=(0,import_react.useFieldSchema)();return e&&!(e!=null&&e.readPretty)&&!isPatternDisabled(t)},useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable();let i="editable";return o["x-disabled"]===!0&&(i="readonly"),o["x-read-pretty"]===!0&&(i="read-pretty"),{title:e("Pattern"),options:[{label:e("Editable"),value:"editable"},{label:e("Readonly"),value:"readonly"},{label:e("Easy-reading"),value:"read-pretty"}],value:i,onChange(n){const a={"x-uid":o["x-uid"]};switch(n){case"readonly":{o["x-read-pretty"]=!1,o["x-disabled"]=!0,a["x-read-pretty"]=!1,a["x-disabled"]=!0,t.readPretty=!1,t.disabled=!0,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.ReadOnly));break}case"read-pretty":{o["x-read-pretty"]=!0,o["x-disabled"]=!1,a["x-read-pretty"]=!0,a["x-disabled"]=!1,t.readPretty=!0,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.ReadPretty));break}default:{o["x-read-pretty"]=!1,o["x-disabled"]=!1,a["x-read-pretty"]=!1,a["x-disabled"]=!1,t.readPretty=!1,t.disabled=!1,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.Editable));break}}r.emit("patch",{schema:a}),r.refresh()}}}},{name:"setValidationRules",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r,refresh:i}=useDesignable(),n=useValidateSchema(),{getCollectionJoinField:a}=useCollectionManager_deprecated(),{getField:l}=useCollection_deprecated(),c=l(o.name)||a(o["x-collection-field"]),u=m=>m!=null&&!Number.isNaN(m);return{title:e("Set validation rules"),components:{ArrayCollapse:import_antd_v5.ArrayCollapse,FormLayout:import_antd_v5.FormLayout},schema:{type:"object",title:e("Set validation rules"),properties:{rules:{type:"array",default:o==null?void 0:o["x-validator"],"x-component":"ArrayCollapse","x-decorator":"FormItem","x-component-props":{accordion:!0},maxItems:3,items:{type:"object","x-component":"ArrayCollapse.CollapsePanel","x-component-props":{header:'{{ t("Validation rule") }}'},properties:{index:{type:"void","x-component":"ArrayCollapse.Index"},layout:{type:"void","x-component":"FormLayout","x-component-props":{labelStyle:{marginTop:"6px"},labelCol:8,wrapperCol:16},properties:P(x({},n),{message:{type:"string",title:'{{ t("Error message") }}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:2,maxRows:2}}}})},remove:{type:"void","x-component":"ArrayCollapse.Remove"},moveUp:{type:"void","x-component":"ArrayCollapse.MoveUp"},moveDown:{type:"void","x-component":"ArrayCollapse.MoveDown"}}},properties:{add:{type:"void",title:'{{ t("Add validation rule") }}',"x-component":"ArrayCollapse.Addition","x-reactions":{dependencies:["rules"],fulfill:{state:{disabled:"{{$deps[0].length >= 3}}"}}}}}}}},onSubmit(m){var d;const p=[];for(const f of m.rules)p.push(import_lodash.default.pickBy(f,u));const g={"x-uid":o["x-uid"]};if(["percent"].includes(c==null?void 0:c.interface))for(const f of p)(f.maxValue||f.minValue)&&(f.percentMode=!0),f.percentFormat&&(f.percentFormats=!0);const h=import_lodash.default.concat([],((d=c==null?void 0:c.uiSchema)==null?void 0:d["x-validator"])||[],p);t.validator=h,t.required=o.required,o["x-validator"]=p,g["x-validator"]=p,r.emit("patch",{schema:g}),i()}}},useVisible(){const{form:e}=useFormBlockContext(),t=useIsFormReadPretty(),o=useValidateSchema();return e&&!t&&o}},{name:"style",Component:e=>{const t=P(x({},e),{category:"style"});return(0,import_jsx_runtime.jsx)(SchemaSettingsLinkageRules,x({},t))},useVisible(){return useIsFieldReadPretty()},useComponentProps(){const{name:e}=useCollection(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},fieldComponentSettingsItem]}},{name:"componentOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Specific properties")}},useChildren(){const e=useApp(),t=useFieldComponentName(),o=e.schemaSettingsManager.get(`fieldSettings:component:${t}`);return(o==null?void 0:o.items)||[]}},{name:"divider",type:"divider"},{name:"delete",type:"remove",sort:100,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!0,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]}),pageSizeOptions$2=[12,24,60,96,120],gridSizes=["xs","md","lg","xxl"],screenSizeTitleMaps={xs:"Phone device",md:"Tablet device",lg:"Desktop device",xxl:"Large screen device"},screenSizeMaps={xs:"< 768",md:"≥ 768",lg:"≥ 992",xxl:"≥ 1600"},defaultColumnCount={xs:1,md:2,lg:3,xxl:4},columnCountMarks=[1,2,3,4,6,8,12,24].reduce((e,t)=>(e[t]=t,e),{}),GridCardDesigner=()=>{var e,t,o,r,i,n,a,l;const{name:c,title:u}=useCollection_deprecated(),m=useSchemaTemplate(),{t:d}=(0,import_react_i18next.useTranslation)(),p=(0,import_react.useFieldSchema)(),{form:g}=useFormBlockContext(),h=(0,import_react.useField)(),{dn:f}=useDesignable(),_=useSortFields(c),{componentNamePrefix:v}=useBlockTemplateContext(),S=((t=(e=p==null?void 0:p["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.sort)||[],C=((o=p==null?void 0:p["x-decorator-props"])==null?void 0:o.resource)||((r=p==null?void 0:p["x-decorator-props"])==null?void 0:r.association),b=S==null?void 0:S.map(y=>y.startsWith("-")?{field:y.substring(1),direction:"desc"}:{field:y,direction:"asc"});return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,{template:m,title:u||c,children:(0,import_jsx_runtime.jsxs)(SchemaComponentOptions,{components:{Slider:import_antd.Slider},children:[(0,import_jsx_runtime.jsx)(SetTheCountOfColumnsDisplayedInARow,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsDataScope,{collectionName:c,defaultFilter:((n=(i=p==null?void 0:p["x-decorator-props"])==null?void 0:i.params)==null?void 0:n.filter)||{},form:g,onSubmit:({filter:y})=>{y=removeNullCondition(y),import_lodash.default.set(p,"x-decorator-props.params.filter",y),h.decoratorProps.params=x({},p["x-decorator-props"].params),f.emit("patch",{schema:{"x-uid":p["x-uid"],"x-decorator-props":p["x-decorator-props"]}})}}),(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:d("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:d("Set default sorting rules"),properties:{sort:{type:"array",default:b,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:_,required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:d("ASC"),value:"asc"},{label:d("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:d("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit:({sort:y})=>{const F=y.map(j=>j.direction==="desc"?`-${j.field}`:j.field);import_lodash.default.set(p,"x-decorator-props.params.sort",F),h.decoratorProps.params=x({},p["x-decorator-props"].params),f.emit("patch",{schema:{"x-uid":p["x-uid"],"x-decorator-props":p["x-decorator-props"]}})}}),(0,import_jsx_runtime.jsx)(SetDataLoadingMode,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:d("Records per page"),value:((l=(a=h.decoratorProps)==null?void 0:a.params)==null?void 0:l.pageSize)||20,options:pageSizeOptions$2.map(y=>({value:y})),onChange:y=>{import_lodash.default.set(p,"x-decorator-props.params.pageSize",y),h.decoratorProps.params=P(x({},p["x-decorator-props"].params),{page:1}),f.emit("patch",{schema:{"x-uid":p["x-uid"],"x-decorator-props":p["x-decorator-props"]}})}}),(0,import_jsx_runtime.jsx)(SchemaSettingsTemplate,{componentName:`${v}GridCard`,collectionName:c,resourceName:C}),(0,import_jsx_runtime.jsx)(SchemaSettingsDivider,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})})};function SetTheCountOfColumnsDisplayedInARow(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useFieldSchema)(),o=(0,import_react.useField)(),{dn:r}=useDesignable(),i=o.decoratorProps.columnCount||defaultColumnCount,n=(0,import_react2.useMemo)(()=>({"x-component":"Slider","x-decorator":"FormItem","x-component-props":{min:1,max:24,marks:columnCountMarks,tooltip:{formatter:l=>`${l}${e("Column")}`},step:null}}),[e]),a=(0,import_react2.useMemo)(()=>gridSizes.reduce((l,c)=>(l[c]=P(x({},n),{title:e(screenSizeTitleMaps[c]),description:`${e("Screen size")} ${screenSizeMaps[c]} ${e("pixels")}`}),l),{}),[n,e]);return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:e("Set the count of columns displayed in a row"),initialValues:i,schema:{type:"object",title:e("Set the count of columns displayed in a row"),properties:a},onSubmit:l=>{import_lodash.default.set(t,"x-decorator-props.columnCount",l),o.decoratorProps.columnCount=l,r.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":t["x-decorator-props"]}})}})}const gridCardBlockSettings=new SchemaSettings({name:"blockSettings:gridCard",items:[{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"SetTheCountOfColumnsDisplayedInARow",Component:SetTheCountOfColumnsDisplayedInARow},{name:"SetTheDataScope",Component:SchemaSettingsDataScope,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{form:i}=useFormBlockContext(),n=(0,import_react.useField)(),{dn:a}=useDesignable();return{collectionName:o,defaultFilter:((t=(e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.filter)||{},form:i,onSubmit:({filter:l})=>{l=removeNullCondition(l),import_lodash.default.set(r,"x-decorator-props.params.filter",l),n.decoratorProps.params=x({},r["x-decorator-props"].params),a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"SetDefaultSortingRules",type:"modal",useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),{t:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_react.useFieldSchema)(),n=(0,import_react.useField)(),{dn:a}=useDesignable(),l=useSortFields(o),c=((t=(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.sort)||[],u=c==null?void 0:c.map(m=>m.startsWith("-")?{field:m.substring(1),direction:"desc"}:{field:m,direction:"asc"});return{title:r("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:r("Set default sorting rules"),properties:{sort:{type:"array",default:u,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:l,required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:r("ASC"),value:"asc"},{label:r("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:r("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit:({sort:m})=>{const d=m.map(p=>p.direction==="desc"?`-${p.field}`:p.field);import_lodash.default.set(i,"x-decorator-props.params.sort",d),n.decoratorProps.params=x({},i["x-decorator-props"].params),a.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}})}}}},setDataLoadingModeSettingsItem,{name:"RecordsPerPage",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)(),i=(0,import_react.useField)(),{dn:n}=useDesignable();return{title:o("Records per page"),value:((t=(e=i.decoratorProps)==null?void 0:e.params)==null?void 0:t.pageSize)||20,options:pageSizeOptions$2.map(a=>({value:a})),onChange:a=>{import_lodash.default.set(r,"x-decorator-props.params.pageSize",a),i.decoratorProps.params=P(x({},r["x-decorator-props"].params),{page:1}),n.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"ConvertReferenceToDuplicate",Component:SchemaSettingsTemplate,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{componentName:`${i}GridCard`,collectionName:o,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),listBlockSettings=new SchemaSettings({name:"blockSettings:list",items:[{name:"EditBlockTitle",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"SetTheDataScope",Component:SchemaSettingsDataScope,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{form:i}=useFormBlockContext(),n=(0,import_react.useField)(),{dn:a}=useDesignable();return{collectionName:o,defaultFilter:((t=(e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.filter)||{},form:i,onSubmit:({filter:l})=>{l=removeNullCondition(l),import_lodash.default.set(r,"x-decorator-props.params.filter",l),n.decoratorProps.params=P(x({},r["x-decorator-props"].params),{page:1}),a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"SetDefaultSortingRules",type:"modal",useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),{t:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_react.useFieldSchema)(),n=(0,import_react.useField)(),{dn:a}=useDesignable(),l=useSortFields(o),c=((t=(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.sort)||[],u=c==null?void 0:c.map(m=>m.startsWith("-")?{field:m.substring(1),direction:"desc"}:{field:m,direction:"asc"});return{title:r("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:r("Set default sorting rules"),properties:{sort:{type:"array",default:u,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:l,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:r("ASC"),value:"asc"},{label:r("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:r("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit:({sort:m})=>{const d=m.map(p=>p.direction==="desc"?`-${p.field}`:p.field);import_lodash.default.set(i,"x-decorator-props.params.sort",d),n.decoratorProps.params=P(x({},i["x-decorator-props"].params),{page:1}),a.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}})}}}},setDataLoadingModeSettingsItem,{name:"RecordsPerPage",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)(),i=(0,import_react.useField)(),{dn:n}=useDesignable();return{title:o("Records per page"),value:((t=(e=i.decoratorProps)==null?void 0:e.params)==null?void 0:t.pageSize)||20,options:[{label:"5",value:5},{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100},{label:"200",value:200}],onChange:a=>{import_lodash.default.set(r,"x-decorator-props.params.pageSize",a),i.decoratorProps.params=P(x({},r["x-decorator-props"].params),{page:1}),n.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"ConvertReferenceToDuplicate",Component:SchemaSettingsTemplate,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{componentName:`${i}List`,collectionName:o,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),tableSelectorBlockSettings=new SchemaSettings({name:"blockSettings:tableSelector",items:[{name:"SetTheDataScope",Component:SchemaSettingsDataScope,useComponentProps:()=>{var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{form:n}=useFormBlockContext(),{service:a,extraFilter:l}=useTableSelectorContext(),{dn:c}=useDesignable(),u=useDataLoadingMode(),m=(0,import_react2.useCallback)(({filter:d})=>{d=removeNullCondition(d);const p=r.decoratorProps.params||{};p.filter=d,r.decoratorProps.params=p,i["x-decorator-props"].params=p,(0,import_lodash.cloneDeep)(d),c.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}})},[r.decoratorProps,i,l,u,c,a]);return{collectionName:o,defaultFilter:((t=(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.filter)||{},form:n,onSubmit:m}}},{name:"treeTable",type:"switch",useComponentProps:()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),{service:o}=useTableSelectorContext(),{t:r}=(0,import_react_i18next.useTranslation)(),{dn:i}=useDesignable();return{title:r("Tree table"),defaultChecked:!0,checked:e.decoratorProps.treeTable,onChange:n=>{var a;e.form.clearFormGraph(`${e.address}.*`),e.decoratorProps.treeTable=n,t["x-decorator-props"].treeTable=n;const l=P(x({},(a=o.params)==null?void 0:a[0]),{tree:n?!0:null});i.emit("patch",{schema:t}),i.refresh(),o.run(l)}}},useVisible:()=>{const{getCollectionJoinField:e}=useCollectionManager_deprecated(),t=(0,import_react.useFieldSchema)(),o=useCollection_deprecated(),r=recursiveParent$1(t,"CollectionField"),i=e(r==null?void 0:r["x-collection-field"]);return(o==null?void 0:o.tree)&&(i==null?void 0:i.target)===(i==null?void 0:i.collectionName)}},{name:"SetDefaultSortingRules",type:"modal",useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),n=useSortFields(o),{service:a}=useTableSelectorContext(),{t:l}=(0,import_react_i18next.useTranslation)(),{dn:c}=useDesignable(),u=((t=(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.sort)||[],m=u==null?void 0:u.map(d=>d.startsWith("-")?{field:d.substring(1),direction:"desc"}:{field:d,direction:"asc"});return{title:l("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:l("Set default sorting rules"),properties:{sort:{type:"array",default:m,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:n,required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:l("ASC"),value:"asc"},{label:l("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:l("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit:({sort:d})=>{var p;const g=d.map(f=>f.direction==="desc"?`-${f.field}`:f.field),h=r.decoratorProps.params||{};h.sort=g,r.decoratorProps.params=h,i["x-decorator-props"].params=h,c.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}}),a.run(P(x({},(p=a.params)==null?void 0:p[0]),{sort:g}))}}},useVisible(){const e=(0,import_react.useField)(),{dragSort:t}=e.decoratorProps;return!t}},setDataLoadingModeSettingsItem,{name:"RecordsPerPage",type:"select",useComponentProps(){var e,t;const o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{service:i}=useTableSelectorContext(),{t:n}=(0,import_react_i18next.useTranslation)(),{dn:a}=useDesignable();return{title:n("Records per page"),value:((t=(e=o.decoratorProps)==null?void 0:e.params)==null?void 0:t.pageSize)||20,options:[{label:"5",value:5},{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100},{label:"200",value:200}],onChange:l=>{var c;const u=o.decoratorProps.params||{};u.pageSize=l,o.decoratorProps.params=u,r["x-decorator-props"].params=u,i.run(P(x({},(c=i.params)==null?void 0:c[0]),{pageSize:l,page:1})),a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),useCollection_deprecated=()=>{var e;const t=useCollection(),o=useAPIClient(),r=o==null?void 0:o.resource(t==null?void 0:t.name),i=(0,import_react2.useMemo)(()=>(t==null?void 0:t.fields)||[],[t]),n=(0,import_react2.useMemo)(()=>{var d;return((d=t==null?void 0:t.getInheritedFields)==null?void 0:d.call(t))||[]},[t]),a=(0,import_react2.useMemo)(()=>{var d,p;return((d=t==null?void 0:t.getAllFields)==null?void 0:d.call(t))||((p=t==null?void 0:t.getFields)==null?void 0:p.call(t))||[]},[t]),l=(0,import_react2.useMemo)(()=>{var d;return((d=t==null?void 0:t.getForeignKeyFields)==null?void 0:d.call(t))||[]},[t]),c=(0,import_react2.useCallback)(()=>a==null?void 0:a.find(d=>d.treeParent),[a]),u=(0,import_react2.useCallback)(d=>{var p;return(p=t==null?void 0:t.getField)==null?void 0:p.call(t,d)},[t]),m=(0,import_react2.useCallback)(()=>t==null?void 0:t.getPrimaryKey(),[t]);return P(x({},(e=t==null?void 0:t.getOptions)==null?void 0:e.call(t)),{resource:r,getTreeParentField:c,fields:a,getField:u,getPrimaryKey:m,currentFields:i,inheritedFields:n,foreignKeyFields:l})};function SchemaSettingsSortField(){const{fields:e}=useCollection_deprecated(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{t:r}=(0,import_react_i18next.useTranslation)(),{dn:i}=useDesignable(),n=useCompile(),{service:a,association:l}=useTableBlockContext(),{getCollectionJoinField:c}=useCollectionManager_deprecated(),u=c(l),m=e.filter(d=>!(d!=null&&d.target)&&d.interface==="sort").map(d=>{var p;return{value:d==null?void 0:d.name,label:n((p=d==null?void 0:d.uiSchema)==null?void 0:p.title)||(d==null?void 0:d.name),disabled:(d==null?void 0:d.scopeKey)&&(u==null?void 0:u.foreignKey)!==d.scopeKey}});return(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:r("Drag and drop sorting field"),options:m,value:t.decoratorProps.dragSortBy,onChange:d=>{var p;o["x-decorator-props"].dragSortBy=d,a.run(P(x({},(p=a.params)==null?void 0:p[0]),{sort:d})),t.decoratorProps.dragSortBy=d,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}}),i.refresh()}},"sort-field")}const tableBlockSettings=new SchemaSettings({name:"blockSettings:table",items:[{name:"editBlockTitle",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"treeTable",type:"switch",useComponentProps:()=>{var e;const{getCollectionField:t,getCollection:o}=useCollectionManager_deprecated(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{service:n}=useTableBlockContext(),{t:a}=(0,import_react_i18next.useTranslation)(),{dn:l}=useDesignable(),c=useCollection_deprecated(),{resource:u}=r.decoratorProps,m=u&&t(u),d=u!=null&&u.includes(".")?(e=o(m==null?void 0:m.target))==null?void 0:e.tree:!!(c!=null&&c.tree);return{title:a("Tree table"),defaultChecked:!0,checked:d?r.decoratorProps.treeTable:!1,onChange:p=>{var g;r.decoratorProps.treeTable=p,i["x-decorator-props"].treeTable=p,p===!1&&(i["x-decorator-props"].expandFlag=!1);const h=P(x({},(g=n.params)==null?void 0:g[0]),{tree:p?!0:null});l.emit("patch",{schema:i}),l.refresh(),n.run(h)}}},useVisible:()=>{const{getCollectionField:e}=useCollectionManager_deprecated(),t=(0,import_react.useField)(),o=useCollection_deprecated(),{resource:r}=t.decoratorProps,i=r&&e(r);return(o==null?void 0:o.tree)&&(i==null?void 0:i.collectionName)===(i==null?void 0:i.target)}},createSwitchSettingsItem({name:"expandFlag",title:e=>e("Expand All"),defaultValue:!1,schemaKey:"x-decorator-props.expandFlag",useVisible(){return(0,import_react.useField)().decoratorProps.treeTable}}),{name:"enableDragAndDropSorting",type:"switch",useComponentProps:()=>{const{getCollectionField:e}=useCollectionManager_deprecated(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{service:r}=useTableBlockContext(),{t:i}=(0,import_react_i18next.useTranslation)(),{dn:n}=useDesignable(),{resource:a}=t.decoratorProps,l=a&&e(a),c=useAPIClient();return{title:i("Enable drag and drop sorting"),checked:t.decoratorProps.dragSort,onChange:u=>q(void 0,null,function*(){var m,d,p;if(u&&l){const{data:g}=yield c.resource("collections.fields",l.collectionName).update({filterByTk:l.name,values:{sortable:!0}}),h=(d=(m=g==null?void 0:g.data)==null?void 0:m[0])==null?void 0:d.sortBy;o["x-decorator-props"].dragSortBy=h}t.decoratorProps.dragSort=u,o["x-decorator-props"].dragSort=u,r.run(P(x({},(p=r.params)==null?void 0:p[0]),{sort:o["x-decorator-props"].dragSortBy})),n.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})})}}},{name:"SortField",Component:SchemaSettingsSortField,useVisible(){return(0,import_react.useField)().decoratorProps.dragSort}},setTheDataScopeSchemaSettingsItem,setDefaultSortingRulesSchemaSettingsItem,setDataLoadingModeSettingsItem,{name:"RecordsPerPage",type:"select",useComponentProps(){var e,t;const o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{service:i}=useTableBlockContext(),{t:n}=(0,import_react_i18next.useTranslation)(),{dn:a}=useDesignable();return{title:n("Records per page"),value:((t=(e=o.decoratorProps)==null?void 0:e.params)==null?void 0:t.pageSize)||20,options:[{label:"5",value:5},{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100},{label:"200",value:200}],onChange:l=>{var c;const u=o.decoratorProps.params||{};u.pageSize=l,o.decoratorProps.params=u,r["x-decorator-props"].params=u,i.run(P(x({},(c=i.params)==null?void 0:c[0]),{pageSize:l,page:1})),a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"tableSize",type:"select",useComponentProps(){var e;(0,import_react.useField)();const t=(0,import_react.useFieldSchema)(),{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable(),i=t.reduceProperties((n,a)=>{if(a["x-component"]==="TableV2")return a},null);return{title:o("Table size"),value:((e=i==null?void 0:i["x-component-props"])==null?void 0:e.size)||"small",options:[{label:o("Large"),value:"large"},{label:o("Middle"),value:"middle"},{label:o("Small"),value:"small"}],onChange:n=>{i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].size=n,r.emit("patch",{schema:{"x-uid":i["x-uid"],"x-component-props":i["x-component-props"]}})}}}},{name:"ConnectDataBlocks",Component:SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{type:FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider",sort:7e3,useVisible:()=>{var e;const t=(0,import_react.useFieldSchema)();return!((e=t==null?void 0:t["x-decorator-props"])!=null&&e.disableTemplate)}},{name:"ConvertReferenceToDuplicate",sort:8e3,Component:SchemaSettingsTemplate,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{componentName:`${i}Table`,collectionName:o,resourceName:n}},useVisible:()=>{var e;const t=(0,import_react.useFieldSchema)();return!((e=t==null?void 0:t["x-decorator-props"])!=null&&e.disableTemplate)}},{name:"divider2",type:"divider",sort:9e3},{name:"delete",type:"remove",sort:1e4,useComponentProps:()=>({removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})}]}),tableColumnSettings=new SchemaSettings({name:"fieldSettings:TableColumn",items:[{name:"decoratorOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Generic properties")}},children:[{name:"customColumnTitle",type:"modal",useComponentProps(){var e;const{fieldSchema:t,collectionField:o}=useColumnSchema$1(),r=(0,import_react.useField)(),{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useFieldSchema)(),{dn:a}=useDesignable();return{title:i("Custom column title"),schema:{type:"object",title:i("Custom column title"),properties:{title:{title:i("Column title"),default:n==null?void 0:n.title,description:`${i("Original field title: ")}${((e=o==null?void 0:o.uiSchema)==null?void 0:e.title)||(t==null?void 0:t.title)}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:l})=>{r.title=l,n.title=l,a.emit("patch",{schema:{"x-uid":n["x-uid"],title:n.title}}),a.refresh()}}}},{name:"style",Component:e=>{const t=P(x({},e),{category:"style"});return(0,import_jsx_runtime.jsx)(SchemaSettingsLinkageRules,x({},t))},useVisible(){var e,t;const{fieldSchema:o}=useColumnSchema$1(),{isInSubTable:r}=useFlag(),i=(0,import_react.useField)();if(!r)return!0;const n=(t=i.path)==null?void 0:t.splice(((e=i.path)==null?void 0:e.length)-1,1);return o?i.form.query(`${n.concat("*."+o.name)}`).get("readPretty"):!1},useComponentProps(){const{name:e}=useCollection(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"columnWidth",type:"modal",useComponentProps(){var e;const t=(0,import_react.useField)(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:o("Column width"),schema:{type:"object",title:o("Column width"),properties:{width:{default:((e=r==null?void 0:r["x-component-props"])==null?void 0:e.width)||100,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{}}}},onSubmit:({width:n})=>{const a=r["x-component-props"]||{};a.width=n;const l={"x-uid":r["x-uid"]};l["x-component-props"]=a,r["x-component-props"]=a,t.componentProps.width=n,i.emit("patch",{schema:l}),i.refresh()}}}},{name:"sortable",type:"switch",useVisible(){const e=useCollection(),{collectionField:t}=useColumnSchema$1(),{getInterface:o}=useCollectionManager_deprecated(),r=o(t==null?void 0:t.interface),{currentMode:i}=useAssociationFieldContext();return(r==null?void 0:r.sortable)===!0&&!i&&((e==null?void 0:e.name)===(t==null?void 0:t.collectionName)||!(t!=null&&t.collectionName))},useComponentProps(){const e=(0,import_react.useField)(),{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable();return{title:t("Sortable"),checked:e.componentProps.sorter,onChange:i=>{const n={"x-uid":o["x-uid"]};o["x-component-props"]=P(x({},o["x-component-props"]),{sorter:i}),n["x-component-props"]=o["x-component-props"],e.componentProps.sorter=i,r.emit("patch",{schema:n}),r.refresh()}}}},{name:"setDefaultValue",useVisible(){const{fieldSchema:e}=useColumnSchema$1();return e?!(e!=null&&e["x-read-pretty"]):!1},Component:SchemaSettingsDefaultValue,useComponentProps(){const{fieldSchema:e}=useColumnSchema$1();return{fieldSchema:e}}},{name:"required",type:"switch",useVisible(){const{uiSchema:e,fieldSchema:t}=useColumnSchema$1(),o=(0,import_react.useField)();return t?["QuickEdit","FormItem"].includes(t["x-decorator"])&&!o.readPretty&&!(e!=null&&e["x-read-pretty"]):!1},useComponentProps(){const{fieldSchema:e}=useColumnSchema$1(),t=(0,import_react.useField)(),{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable();return{key:"required",title:o("Required"),checked:e==null?void 0:e.required,onChange:i=>{var n,a;if(!e)return console.error("fieldSchema is required");const l={"x-uid":e["x-uid"]};e.required=i,l.required=i;const c=(a=t.path)==null?void 0:a.splice(((n=t.path)==null?void 0:n.length)-1,1);t.form.query(`${c.concat("*."+e.name)}`).forEach(u=>{u.required=i}),r.emit("patch",{schema:l}),r.refresh()}}}},{name:"pattern",type:"select",useVisible(){const{fieldSchema:e,collectionField:t}=useColumnSchema$1(),o=(0,import_react.useField)();return e?["QuickEdit","FormItem"].includes(e["x-decorator"])&&!(o!=null&&o.readPretty)&&(t==null?void 0:t.interface)!=="o2m"&&!isPatternDisabled(e):!1},useComponentProps(){const{fieldSchema:e}=useColumnSchema$1(),t=(0,import_react.useField)(),{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable();let i="editable";return e?(e["x-disabled"]===!0&&(i="readonly"),e["x-read-pretty"]===!0&&(i="read-pretty"),{key:"pattern",title:o("Pattern"),options:[{label:o("Editable"),value:"editable"},{label:o("Readonly"),value:"readonly"},{label:o("Easy-reading"),value:"read-pretty"}],value:i,onChange:n=>{var a,l;const c={"x-uid":e["x-uid"]},u=(l=t.path)==null?void 0:l.splice(((a=t.path)==null?void 0:a.length)-1,1);switch(n){case"readonly":{e["x-read-pretty"]=!1,e["x-disabled"]=!0,c["x-read-pretty"]=!1,c["x-disabled"]=!0,t.form.query(`${u.concat("*."+e.name)}`).forEach(m=>{m.readonly=!0,m.disabled=!0});break}case"read-pretty":{e["x-read-pretty"]=!0,e["x-disabled"]=!1,c["x-read-pretty"]=!0,c["x-disabled"]=!1,t.form.query(`${u.concat("*."+e.name)}`).forEach(m=>{m.readPretty=!0});break}default:{e["x-read-pretty"]=!1,e["x-disabled"]=!1,c["x-read-pretty"]=!1,c["x-disabled"]=!1,t.form.query(`${u.concat("*."+e.name)}`).forEach(m=>{m.readPretty=!1,m.disabled+!1});break}}r.emit("patch",{schema:c}),r.refresh()}}):console.error("fieldSchema is required")}},{name:"fixed",type:"select",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Fixed"),options:[{label:t("Not fixed"),value:"none"},{label:t("Left fixed"),value:"left"},{label:t("Right fixed"),value:"right"}],value:((e=o.componentProps)==null?void 0:e.fixed)||"none",onChange(n){const a={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].fixed=n,a["x-component-props"]=r["x-component-props"],o.componentProps=o.componentProps||{},o.componentProps.fixed=n,i.emit("patch",{schema:a}),i.refresh()}}}},{name:"hidden",type:"switch",useComponentProps(){const e=(0,import_react.useField)(),{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable();return{title:(0,import_jsx_runtime.jsxs)("span",{children:[t("Hide column"),(0,import_jsx_runtime.jsx)(import_antd.Tooltip,{title:t("In configuration mode, the entire column becomes transparent. In non-configuration mode, the entire column will be hidden. Even if the entire column is hidden, its configured default values and other settings will still take effect."),children:(0,import_jsx_runtime.jsx)(import_icons.QuestionCircleOutlined,{style:{marginLeft:4,opacity:.65}})})]}),checked:e.componentProps.columnHidden,onChange:i=>{const n={"x-uid":o["x-uid"]};o["x-component-props"]=P(x({},o["x-component-props"]),{columnHidden:i}),n["x-component-props"]=o["x-component-props"],e.componentProps.columnHidden=i,r.emit("patch",{schema:n}),r.refresh()}}}},fieldComponentSettingsItem]},{name:"componentOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Specific properties")}},useChildren(){const e=useApp(),t=useFieldComponentName(),o={Select:"Select",DatePicker:"DatePicker",Nester:"Nester",SubTable:"SubTable",Picker:"Picker",PopoverNester:"PopoverNester",Tag:"Tag"},r=e.schemaSettingsManager.get(`fieldSettings:component:${o[t]||t}`);return(r==null?void 0:r.items)||[]}},{name:"divider",type:"divider"},{name:"delete",type:"remove",sort:100,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!1,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]}),filterCollapseBlockSettings=new SchemaSettings({name:"blockSettings:filterCollapse",items:[{name:"EditBlockTitle",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"ConvertReferenceToDuplicate",Component:SchemaSettingsTemplate,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{componentName:`${i}FilterCollapse`,collectionName:o,resourceName:n}}},{name:"ConnectDataBlocks",Component:SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{type:FilterBlockType.COLLAPSE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),filterCollapseItemFieldSettings=new SchemaSettings({name:"fieldSettings:FilterCollapseItem",items:[{name:"decoratorOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Generic properties")}},useChildren(){return[{name:"customTitle",type:"modal",useComponentProps(){var e;const t=(0,import_react.useFieldSchema)(),{t:o}=(0,import_react_i18next.useTranslation)(),{getCollectionJoinField:r}=useCollectionManager_deprecated(),{getField:i}=useCollection_deprecated(),n=i(t.name)||r(t["x-collection-field"]),{dn:a}=useDesignable();return{title:o("Custom title"),schema:{type:"object",title:o("Custom title"),properties:{title:{default:t==null?void 0:t.title,description:`${o("Original title: ")}${((e=n==null?void 0:n.uiSchema)==null?void 0:e.title)||(t==null?void 0:t.title)}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:l})=>{l&&(t.title=l,a.emit("patch",{schema:{"x-uid":t["x-uid"],title:t.title}})),a.refresh()}}}},{name:"defaultCollapse",type:"switch",useComponentProps(){const e=(0,import_react.useFieldSchema)(),t=(0,import_react.useField)(),{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable();return{title:o("Default collapse"),checked:t.componentProps.defaultCollapse,onChange:i=>{t.componentProps.defaultCollapse=i,import_lodash.default.set(e,"x-component-props.defaultCollapse",i),r.emit("patch",{schema:{"x-uid":e["x-uid"],"x-component-props":e["x-component-props"]}}),r.refresh()}}}},{name:"setTheDataScope",Component:SchemaSettingsDataScope,useComponentProps(){var e,t;const o=(0,import_react.useFieldSchema)(),{form:r}=useFormBlockContext(),i=(0,import_react.useField)(),{getCollectionJoinField:n}=useCollectionManager_deprecated(),{getField:a}=useCollection_deprecated(),l=a(o.name)||n(o["x-collection-field"]),{dn:c}=useDesignable();return{collectionName:l==null?void 0:l.target,defaultFilter:((t=(e=o==null?void 0:o["x-component-props"])==null?void 0:e.params)==null?void 0:t.filter)||{},form:r,onSubmit:({filter:u})=>{var m;import_lodash.default.set(i.componentProps,"params",P(x({},(m=i.componentProps)==null?void 0:m.params),{filter:u})),o["x-component-props"].params=i.componentProps.params,c.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}})}}},useVisible(){const e=(0,import_react.useFieldSchema)(),t=useCollection().getField(e.name);return!!(t!=null&&t.target)}},{name:"setDefaultSortingRules",Component:SchemaSettingsDefaultSortingRules,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{getCollectionJoinField:t}=useCollectionManager_deprecated(),{getField:o}=useCollection_deprecated(),r=o(e.name)||t(e["x-collection-field"]);return{name:r==null?void 0:r.target}},useVisible(){const e=(0,import_react.useFieldSchema)(),t=useCollection().getField(e.name);return!!(t!=null&&t.target)}},{name:"titleField",type:"select",useComponentProps(){var e,t;const o=(0,import_react.useFieldSchema)(),{t:r}=(0,import_react_i18next.useTranslation)(),{getCollectionJoinField:i}=useCollectionManager_deprecated(),{getField:n}=useCollection_deprecated(),a=n(o.name)||i(o["x-collection-field"]),l=useCollectionManager(),c=useCompile(),{dn:u}=useDesignable(),m=(a!=null&&a.target?l.getCollectionFields(a==null?void 0:a.target):[]).filter(p=>!(p!=null&&p.target)&&p.type!=="boolean").map(p=>{var g;return{value:p==null?void 0:p.name,label:c((g=p==null?void 0:p.uiSchema)==null?void 0:g.title)||(p==null?void 0:p.name)}}),d=p=>{var g,h,f;const _={"x-uid":o["x-uid"]},v=P(x(x({},(h=(g=a==null?void 0:a.uiSchema)==null?void 0:g["x-component-props"])==null?void 0:h.fieldNames),(f=o["x-component-props"])==null?void 0:f.fieldNames),{label:p});o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].fieldNames=v,_["x-component-props"]=o["x-component-props"],u.emit("patch",{schema:_}),u.refresh()};return{key:"title-field",title:r("Title field"),options:m,value:(t=(e=o["x-component-props"])==null?void 0:e.fieldNames)==null?void 0:t.label,onChange:d}},useVisible(){const e=(0,import_react.useFieldSchema)(),t=useCollection().getField(e.name);return!!(t!=null&&t.target)}},{name:"setDefaultValue",Component:SchemaSettingsDefaultValue,componentProps:{hideVariableButton:!0}}]}},{name:"divider",type:"divider"},{name:"delete",type:"remove",sort:100,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!0,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]}),filterFormBlockSettings=new SchemaSettings({name:"blockSettings:filterForm",items:[{name:"title",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"formItemTemplate",Component:SchemaSettingsFormItemTemplate,useComponentProps(){var e,t;const{componentNamePrefix:o}=useBlockTemplateContext(),{name:r}=useCollection(),i=(0,import_react.useFieldSchema)(),n=((e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.resource)||((t=i==null?void 0:i["x-decorator-props"])==null?void 0:t.association);return{componentName:`${o}FilterFormItem`,collectionName:r,resourceName:n}}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"connectDataBlocks",Component:SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{type:FilterBlockType.FORM,emptyDescription:e("No blocks to connect")}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),fieldComponentNameMap=e=>e==="Select"?"FilterSelect":e,filterFormItemFieldSettings=new SchemaSettings({name:"fieldSettings:FilterFormItem",items:[{name:"decoratorOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Generic properties")}},useChildren(){return[{name:"editFieldTitle",type:"modal",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),{dn:o}=useDesignable(),r=(0,import_react.useField)(),i=useCompile(),n=(0,import_react.useFieldSchema)(),{getCollectionJoinField:a}=useCollectionManager_deprecated(),{getField:l}=useCollection_deprecated(),c=l(n.name)||a(n["x-collection-field"]);return{title:t("Edit field title"),schema:{type:"object",title:t("Edit field title"),properties:{title:{title:t("Field title"),default:r==null?void 0:r.title,description:`${t("Original field title: ")}${(e=c==null?void 0:c.uiSchema)==null?void 0:e.title}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit({title:u}){var m;const d=u.trim()===""?(m=c==null?void 0:c.uiSchema)==null?void 0:m.title:u;r.title=i(d),n.title=d,o.emit("patch",{schema:{"x-uid":n["x-uid"],title:n.title}}),o.refresh()}}}},{name:"displayTitle",type:"switch",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable(),i=(0,import_react.useField)(),n=(0,import_react.useFieldSchema)();return{title:o("Display title"),checked:(t=(e=n["x-decorator-props"])==null?void 0:e.showTitle)!=null?t:!0,onChange(a){n["x-decorator-props"]=n["x-decorator-props"]||{},n["x-decorator-props"].showTitle=a,i.decoratorProps.showTitle=a,r.emit("patch",{schema:{"x-uid":n["x-uid"],"x-decorator-props":P(x({},n["x-decorator-props"]),{showTitle:a})}}),r.refresh()}}}},{name:"editDescription",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),{dn:t}=useDesignable(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)();return{title:e("Edit description"),schema:{type:"object",title:e("Edit description"),properties:{description:{default:o==null?void 0:o.description,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}}}},onSubmit({description:i}){o.description=i,r.description=i,t.emit("patch",{schema:{"x-uid":r["x-uid"],description:r.description}}),t.refresh()}}}},{name:"editTooltip",type:"modal",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),{dn:o}=useDesignable(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)();return{title:t("Edit tooltip"),schema:{type:"object",title:t("Edit tooltip"),properties:{tooltip:{default:(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.tooltip,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}}}},onSubmit({tooltip:n}){r.decoratorProps.tooltip=n,i["x-decorator-props"]=i["x-decorator-props"]||{},i["x-decorator-props"].tooltip=n,o.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}}),o.refresh()}}}},{name:"setDefaultValue",Component:SchemaSettingsDefaultValue},{name:"setValidationRules",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r,refresh:i}=useDesignable(),n=useValidateSchema(),{getCollectionJoinField:a}=useCollectionManager_deprecated(),{getField:l}=useCollection_deprecated(),c=l(o.name)||a(o["x-collection-field"]),u=m=>m!=null&&!Number.isNaN(m);return{title:e("Set validation rules"),components:{ArrayCollapse:import_antd_v5.ArrayCollapse,FormLayout:import_antd_v5.FormLayout},schema:{type:"object",title:e("Set validation rules"),properties:{rules:{type:"array",default:o==null?void 0:o["x-validator"],"x-component":"ArrayCollapse","x-decorator":"FormItem","x-component-props":{accordion:!0},maxItems:3,items:{type:"object","x-component":"ArrayCollapse.CollapsePanel","x-component-props":{header:'{{ t("Validation rule") }}'},properties:{index:{type:"void","x-component":"ArrayCollapse.Index"},layout:{type:"void","x-component":"FormLayout","x-component-props":{labelStyle:{marginTop:"6px"},labelCol:8,wrapperCol:16},properties:P(x({},n),{message:{type:"string",title:'{{ t("Error message") }}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:2,maxRows:2}}}})},remove:{type:"void","x-component":"ArrayCollapse.Remove"},moveUp:{type:"void","x-component":"ArrayCollapse.MoveUp"},moveDown:{type:"void","x-component":"ArrayCollapse.MoveDown"}}},properties:{add:{type:"void",title:'{{ t("Add validation rule") }}',"x-component":"ArrayCollapse.Addition","x-reactions":{dependencies:["rules"],fulfill:{state:{disabled:"{{$deps[0].length >= 3}}"}}}}}}}},onSubmit(m){var d;const p=[];for(const f of m.rules)p.push(import_lodash.default.pickBy(f,u));const g={"x-uid":o["x-uid"]};if(["percent"].includes(c==null?void 0:c.interface))for(const f of p)(f.maxValue||f.minValue)&&(f.percentMode=!0),f.percentFormat&&(f.percentFormats=!0);const h=import_lodash.default.concat([],((d=c==null?void 0:c.uiSchema)==null?void 0:d["x-validator"])||[],p);t.validator=h,t.required=o.required,o["x-validator"]=p,g["x-validator"]=p,r.emit("patch",{schema:g}),i()}}},useVisible(){return!!useValidateSchema()}},{name:"operator",Component:EditOperator},fieldComponentSettingsItem]}},{name:"componentOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Specific properties")}},useChildren(){const e=useApp(),t=useFieldComponentName(),o=e.schemaSettingsManager.get(`fieldSettings:component:${fieldComponentNameMap(t)}`);return(o==null?void 0:o.items)||[]}},{name:"divider",type:"divider"},{name:"delete",type:"remove",sort:100,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!0,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]}),markdownBlockSettings=new SchemaSettings({name:"blockSettings:markdown",items:[{name:"EditMarkdown",type:"item",useComponentProps(){const e=(0,import_react.useField)(),{t}=(0,import_react_i18next.useTranslation)();return{title:t("Edit markdown"),onClick:()=>{e.editable=!0}}}},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"setBlockTemplate",Component:SchemaSettingsRenderEngine},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),ellipsisSettingsItem={name:"ellipsis",type:"switch",useComponentProps(){var e;const{fieldSchema:t}=useColumnSchema$1(),o=useTableFieldInstanceList(),r=(0,import_react.useFieldSchema)(),i=(0,import_react.useField)(),{dn:n}=useDesignable(),{t:a}=(0,import_react_i18next.useTranslation)(),l=t||r,c=t?o[0]?!o[0].readPretty:!t["x-read-pretty"]:!i.readPretty;return{title:a("Ellipsis overflow content"),checked:!!((e=l["x-component-props"])!=null&&e.ellipsis),hidden:c,onChange:u=>q(this,null,function*(){t&&o?(o.forEach(m=>{m.componentProps.ellipsis=u}),l["x-component-props"].ellipsis=u):i.componentProps.ellipsis=u,yield n.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":P(x({},l["x-component-props"]),{ellipsis:u})}})})}}},enableLinkSettingsItem={name:"enableLink",type:"switch",useVisible(){const e=(0,import_react.useField)(),{fieldSchema:t}=useColumnSchema$1(),o=(0,import_react.useFieldSchema)(),r=t||o,{name:i}=useBlockContext();return i!=="kanban"&&((r==null?void 0:r["x-read-pretty"])||e.readPretty)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),{fieldSchema:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=r||i,{dn:a}=useDesignable();return{title:t("Enable link"),checked:(e=n==null?void 0:n["x-component-props"])==null?void 0:e.enableLink,onChange(l){n["x-component-props"]=P(x({},n==null?void 0:n["x-component-props"]),{enableLink:l}),o.componentProps.enableLink=l,a.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n==null?void 0:n["x-component-props"])}})}}}},openModeSettingsItem={name:"openMode",Component:SchemaSettingOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=useOpenModeContext(),{fieldSchema:t}=useColumnSchema$1(),o=(0,import_react.useFieldSchema)();return{openMode:!e,openSize:!e,targetSchema:t||o}},useVisible(){var e;const t=(0,import_react.useField)(),{fieldSchema:o}=useColumnSchema$1(),r=(0,import_react.useFieldSchema)(),i=o||r;return((i==null?void 0:i["x-read-pretty"])||t.readPretty)&&((e=i==null?void 0:i["x-component-props"])==null?void 0:e.enableLink)}},inputComponentSettings=new SchemaSettings({name:"fieldSettings:component:Input",items:[ellipsisSettingsItem,enableLinkSettingsItem,openModeSettingsItem]}),fieldComponent$7={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),r=useFieldModeOptions(),i=useIsAddNewForm(),n=useFieldComponentName(),{dn:a}=useDesignable();return{title:e("Field component"),options:r,value:n,onChange(l){const c={"x-uid":o["x-uid"]};o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].mode=l,c["x-component-props"]=o["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=l,isSubMode(o)&&i&&(c.default=null,o.default=null,t.setInitialValue(null),t.setValue(null)),a.emit("patch",{schema:c}),a.refresh()}}}},titleField$2={name:"titleField",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n}=useDesignable(),a=useTitleFieldOptions(),l=useCollectionField();return{title:o("Title field"),options:a,value:(t=(e=r==null?void 0:r.componentProps)==null?void 0:e.fieldNames)==null?void 0:t.label,onChange(c){var u,m;const d={"x-uid":i["x-uid"]},p=P(x(x({},(m=(u=l==null?void 0:l.uiSchema)==null?void 0:u["x-component-props"])==null?void 0:m.fieldNames),r.componentProps.fieldNames),{label:c});i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].fieldNames=p,d["x-component-props"]=i["x-component-props"],r.componentProps.fieldNames=i["x-component-props"].fieldNames,n.emit("patch",{schema:d}),n.refresh()}}}},cascadeSelectComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:CascadeSelect",items:[fieldComponent$7,titleField$2,ellipsisSettingsItem]}),SchemaSettingsDateRange=function e(t){var o,r,i,n,a,l,c,u,m,d,p,g,h,f,_,v;const{fieldSchema:S}=t,C=(0,import_react.useField)(),{dn:b}=useDesignable(),{t:y}=(0,import_react_i18next.useTranslation)(),{getCollectionJoinField:F}=useCollectionManager_deprecated(),{isInSubForm:j,isInSubTable:k}=useFlag()||{},T=F(S==null?void 0:S["x-collection-field"])||{},O=((o=S==null?void 0:S["x-component-props"])==null?void 0:o.showTime)||((i=(r=T==null?void 0:T.uiSchema)==null?void 0:r["x-component-props"])==null?void 0:i.showTime)||!1,N=((n=S==null?void 0:S["x-component-props"])==null?void 0:n.dateFormat)||((l=(a=T==null?void 0:T.uiSchema)==null?void 0:a["x-component-props"])==null?void 0:l.dateFormat)||"YYYY-MM-DD",L=((c=S==null?void 0:S["x-component-props"])==null?void 0:c.timeFormat)||((m=(u=T==null?void 0:T.uiSchema)==null?void 0:u["x-component-props"])==null?void 0:m.timeFormat)||"HH:mm:ss",D=((d=S==null?void 0:S["x-component-props"])==null?void 0:d.picker)||((g=(p=T==null?void 0:T.uiSchema)==null?void 0:p["x-component-props"])==null?void 0:g.picker)||"date";S["x-read-pretty"]||C.readOnly||C.readPretty;const R=(h=S==null?void 0:S["x-component-props"])==null?void 0:h._minDate,$=(f=S==null?void 0:S["x-component-props"])==null?void 0:f._maxDate,w=((_=T==null?void 0:T.uiSchema)==null?void 0:_["x-component-props"].gmt)||!1,I=((v=T==null?void 0:T.uiSchema)==null?void 0:v["x-component-props"].utc)||!1,M=useRecord(),{form:B}=useFormBlockContext(),z=(0,import_react2.useCallback)(U=>(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:{"x-component":"DatePicker","x-component-props":{dateFormat:N,timeFormat:L,gmt:w,utc:I,picker:D,showTime:O,placeholder:'{{t("Please select time or variable")}}',style:{minWidth:385}},name:"value","x-read-pretty":!1,"x-validator":void 0,"x-decorator":void 0}}),[N,w,D,O,L,I]),E=(0,import_react2.useCallback)(U=>(0,import_jsx_runtime.jsx)(VariableInput,P(x({},U),{form:B,record:M,noDisabled:!0,renderSchemaComponent:z})),[S,B,M,z]);function V(U){if(U!=null){if(typeof U=="string")return U;if(typeof U=="object"&&Object.prototype.hasOwnProperty.call(U,"value"))return V(U.value)}}return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:y("Date range limit"),schema:{type:"object","x-decorator":"",properties:{_minDate:{type:"string",title:'{{t("MinDate")}}',"x-decorator":"FormItem","x-component":E,"x-component-props":{name:"_minDate"},default:isVariable(R)?R:{value:R}},_maxDate:{type:"string",title:'{{t("MaxDate")}}',"x-decorator":"FormItem","x-component":E,"x-component-props":{name:"_maxDate"},default:isVariable($)?$:{value:$}}}},onSubmit:U=>{const G={"x-uid":S["x-uid"]};G["x-component-props"]=C.componentProps||{},S["x-component-props"]=P(x({},C.componentProps||{}),{_maxDate:V(U==null?void 0:U._maxDate),_minDate:V(U==null?void 0:U._minDate)}),G["x-component-props"]=S["x-component-props"],C.componentProps=S["x-component-props"];const W=C.path.entire.split(".");W.pop();const Y=W.join(".");C.query(`${Y}.*[0:].${S.name}`).forEach(H=>{H.props.name===S.name&&H.setComponentProps({_maxDate:V(U==null?void 0:U._maxDate),_minDate:V(U==null?void 0:U._minDate)})}),b.emit("patch",{schema:G}),b.refresh()},ModalContextProvider:U=>(0,import_jsx_runtime.jsx)(FlagProvider,{isInSubForm:j,isInSubTable:k,isInFormDataTemplate:!0,children:U.children})})},datePickerComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:DatePicker",items:[{name:"dateDisplayFormat",Component:SchemaSettingsDateFormat,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{fieldSchema:t}=useColumnSchema$1();return{fieldSchema:t||e}}},{name:"dateScopeSelect",Component:SchemaSettingsDateRange,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{fieldSchema:t}=useColumnSchema$1();return{fieldSchema:t||e}},useVisible(){const{fieldSchema:e}=useColumnSchema$1(),t=(0,import_react.useFieldSchema)(),o=e||t;return!(o!=null&&o["x-read-pretty"])}},ellipsisSettingsItem,enableLinkSettingsItem,openModeSettingsItem]}),rangePickerPickerComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:DatePicker.RangePicker",items:[{name:"dateDisplayFormat",Component:SchemaSettingsDateFormat,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{fieldSchema:t}=useColumnSchema$1();return{fieldSchema:t||e}}},ellipsisSettingsItem]}),enableLink$1={name:"enableLink",type:"switch",useVisible(){return(0,import_react.useField)().readPretty},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),{fieldSchema:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=r||i,{dn:a}=useDesignable();return{title:t("Enable link"),checked:((e=n["x-component-props"])==null?void 0:e.enableLink)!==!1,onChange(l){n["x-component-props"]=P(x({},n==null?void 0:n["x-component-props"]),{enableLink:l}),o.componentProps.enableLink=l,a.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n==null?void 0:n["x-component-props"])}})}}}},titleField$1={name:"titleField",type:"select",useComponentProps(){var e,t,o,r;const{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useField)(),{dn:a}=useDesignable(),l=useTitleFieldOptions(),{uiSchema:c,fieldSchema:u,collectionField:m}=useColumnSchema$1(),d=(0,import_react.useFieldSchema)(),p=u||d,g=useCollectionField(),h=m||g,f=x(x(x({},(t=(e=h==null?void 0:h.uiSchema)==null?void 0:e["x-component-props"])==null?void 0:t.fieldNames),(o=n==null?void 0:n.componentProps)==null?void 0:o.fieldNames),(r=p==null?void 0:p["x-component-props"])==null?void 0:r.fieldNames);return{title:i("Title field"),options:l,value:f==null?void 0:f.label,onChange(_){var v,S,C,b,y;const F={"x-uid":p["x-uid"]},j=P(x(x({},(S=(v=h==null?void 0:h.uiSchema)==null?void 0:v["x-component-props"])==null?void 0:S.fieldNames),(C=p["x-component-props"])==null?void 0:C.fieldNames),{label:_});p["x-component-props"]=p["x-component-props"]||{},p["x-component-props"].fieldNames=j,F["x-component-props"]=p["x-component-props"],n.componentProps.fieldNames=p["x-component-props"].fieldNames;const k=(y=n.path)==null?void 0:y.splice(((b=n.path)==null?void 0:b.length)-1,1);n.form.query(`${k.concat("*."+p.name)}`).forEach(T=>{T.componentProps.fieldNames=f}),a.emit("patch",{schema:F}),a.refresh()}}}},getAllowMultiple=e=>{const t=(e==null?void 0:e.title)||"Allow multiple";return{name:"allowMultiple",type:"switch",useComponentProps(){var o;const{t:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_react.useField)(),{fieldSchema:n}=useColumnSchema$1(),a=(0,import_react.useFieldSchema)(),l=n||a,{dn:c,refresh:u}=useDesignable();return{title:r(t),checked:((o=l["x-component-props"])==null?void 0:o.multiple)===void 0?!0:l["x-component-props"].multiple,onChange(m){const d={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},i.componentProps=i.componentProps||{},l["x-component-props"].multiple=m,i.componentProps.multiple=m,d["x-component-props"]=l["x-component-props"],c.emit("patch",{schema:d}),u()}}}}},quickCreate={name:"quickCreate",type:"select",useComponentProps(){var e;const{defaultOpenMode:t}=useOpenModeContext(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n,insertAdjacent:a}=useDesignable();return{title:o("Quick create"),options:[{label:o("None"),value:"none"},{label:o("Dropdown"),value:"quickAdd"},{label:o("Pop-up"),value:"modalAdd"}],value:((e=r.componentProps)==null?void 0:e.addMode)||"none",onChange(l){l==="modalAdd"&&(i.reduceProperties((u,m)=>m["x-component"]==="Action"?m:u,null)||a("afterBegin",{"x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-toolbar":"ActionSchemaToolbar","x-toolbar-props":{draggable:!1},"x-settings":"actionSettings:addNew","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:t,type:"default",component:"CreateRecordAction"}}));const c={"x-uid":i["x-uid"]};i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].addMode=l,c["x-component-props"]=i["x-component-props"],r.componentProps=r.componentProps||{},r.componentProps.addMode=l,n.emit("patch",{schema:c}),n.refresh()}}}},setDefaultSortingRules$1={name:"setDefaultSortingRules",Component:SchemaSettingsSortingRule},setTheDataScope={name:"setTheDataScope",Component:SchemaSettingsDataScope,useComponentProps(){var e,t,o;const{getCollectionJoinField:r,getAllCollectionsInheritChain:i}=useCollectionManager_deprecated(),{getField:n}=useCollection_deprecated(),{form:a}=useFormBlockContext(),l=useRecord(),c=(0,import_react.useField)(),{fieldSchema:u,collectionField:m}=useColumnSchema$1(),d=(0,import_react.useFieldSchema)(),p=u||d,g=m||n(p.name)||r(p["x-collection-field"]),h=useVariables$1(),f=useLocalVariables$1(),{dn:_}=useDesignable();return{collectionName:g==null?void 0:g.target,defaultFilter:((o=(t=(e=p==null?void 0:p["x-component-props"])==null?void 0:e.service)==null?void 0:t.params)==null?void 0:o.filter)||{},form:a,dynamicComponent:v=>(0,import_jsx_runtime.jsx)(VariableInput,P(x({},v),{form:a,collectionField:v.collectionField,record:l,shouldChange:getShouldChange({collectionField:v.collectionField,variables:h,localVariables:f,getAllCollectionsInheritChain:i})})),onSubmit:({filter:v})=>{v=removeNullCondition(v),import_lodash.default.set(p["x-component-props"],"service.params.filter",v),import_lodash.default.set(c.componentProps,"service.params.filter",v),_.emit("patch",{schema:{"x-uid":p["x-uid"],"x-component-props":p["x-component-props"]}})}}}},fieldComponent$6={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),{fieldSchema:o,collectionField:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=o||i,a=useFieldModeOptions({fieldSchema:o,collectionField:r}),l=useIsAddNewForm(),c=useFieldComponentName(),{dn:u}=useDesignable();return{title:e("Field component"),options:a,value:c,onChange(m){var d,p;const g={"x-uid":n["x-uid"]};n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].mode=m,g["x-component-props"]=n["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=m,isSubMode(n)&&l&&(g.default=null,n.default=null,(d=t==null?void 0:t.setInitialValue)==null||d.call(t,null),(p=t==null?void 0:t.setValue)==null||p.call(t,null)),u.emit("patch",{schema:g}),u.refresh()}}}},selectComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Select",items:[P(x({},fieldComponent$6),{useVisible:useIsAssociationField}),P(x({},setTheDataScope),{useVisible(){const e=useIsSelectFieldMode(),t=useIsFieldReadPretty();return e&&!t}}),P(x({},setDefaultSortingRules$1),{useComponentProps(){const{fieldSchema:e}=useColumnSchema$1();return{fieldSchema:e}},useVisible(){const e=useIsSelectFieldMode(),t=useIsFieldReadPretty();return e&&!t}}),P(x({},quickCreate),{useVisible(){const e=useIsAssociationField(),t=useIsFieldReadPretty(),{fieldSchema:o}=useColumnSchema$1(),{type:r}=useDataBlockProps()||{};return e&&!o&&!t&&r!=="publicForm"}}),P(x({},getAllowMultiple()),{useVisible(){const e=useIsFieldReadPretty(),t=useIsAssociationField(),o=useIsShowMultipleSwitch();return!e&&t&&o()}}),P(x({},titleField$1),{useVisible:useIsAssociationField}),P(x({},enableLink$1),{useVisible(){const e=useIsFieldReadPretty();return useIsAssociationField()&&e}}),ellipsisSettingsItem,P(x({},enableLinkSettingsItem),{useVisible(){const e=useCollectionField(),t=useIsFieldReadPretty();return!useIsAssociationField()&&t&&e.interface!=="multipleSelect"}}),P(x({},openModeSettingsItem),{useVisible(){var e,t;const o=(0,import_react.useField)(),r=useIsAssociationField(),{fieldSchema:i}=useColumnSchema$1(),n=(0,import_react.useFieldSchema)(),a=i||n;return((a==null?void 0:a["x-read-pretty"])||o.readPretty)&&(((e=a==null?void 0:a["x-component-props"])==null?void 0:e.enableLink)||r&&((t=a==null?void 0:a["x-component-props"])==null?void 0:t.enableLink)!==!1)}})]}),filterSelectComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:FilterSelect",items:[P(x({},fieldComponent$6),{useVisible:useIsAssociationField}),P(x({},setTheDataScope),{useVisible(){const e=useIsSelectFieldMode(),t=useIsFieldReadPretty();return e&&!t}}),P(x({},setDefaultSortingRules$1),{useComponentProps(){const{fieldSchema:e}=useColumnSchema$1();return{fieldSchema:e}},useVisible(){const e=useIsSelectFieldMode(),t=useIsFieldReadPretty();return e&&!t}}),P(x({},getAllowMultiple({title:"Allow multiple selection"})),{useVisible(){return(0,import_react.useField)().componentProps.multiple!==!1}}),P(x({},titleField$1),{useVisible:useIsAssociationField}),P(x({},enableLink$1),{useVisible(){const e=useIsFieldReadPretty();return useIsAssociationField()&&e}})]}),fieldComponent$5={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=useIsAddNewForm(),r=useFieldComponentName(),{fieldSchema:i,collectionField:n}=useColumnSchema$1(),a=(0,import_react.useFieldSchema)(),l=i||a,c=useFieldModeOptions({fieldSchema:i,collectionField:n}),{dn:u}=useDesignable();return{title:e("Field component"),options:c,value:r,onChange(m){const d={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].mode=m,d["x-component-props"]=l["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=m,isSubMode(l)&&o&&(d.default=null,l.default=null,t.setInitialValue(null),t.setValue(null)),u.emit("patch",{schema:d}),u.refresh()}}}},fileManagerComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:FileManager",items:[fieldComponent$5,{name:"quickUpload",type:"switch",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),{fieldSchema:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=r||i,{dn:a,refresh:l}=useDesignable();return{title:t("Quick upload"),checked:((e=n["x-component-props"])==null?void 0:e.quickUpload)!==!1,onChange(c){const u={"x-uid":n["x-uid"]};o.componentProps.quickUpload=c,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].quickUpload=c,u["x-component-props"]=n["x-component-props"],a.emit("patch",{schema:u}),l()}}},useVisible(){const{fieldSchema:e}=useColumnSchema$1(),t=(0,import_react.useField)(),o=(0,import_react.useForm)();return!(e!=null&&e["x-read-pretty"]||t.readPretty||o.readPretty)}},{name:"selectFile",type:"switch",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),{fieldSchema:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=r||i,{dn:a,refresh:l}=useDesignable();return{title:t("Select file"),checked:((e=n["x-component-props"])==null?void 0:e.selectFile)!==!1,onChange(c){const u={"x-uid":n["x-uid"]};o.componentProps.selectFile=c,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].selectFile=c,u["x-component-props"]=n["x-component-props"],a.emit("patch",{schema:u}),l()}}},useVisible(){const{fieldSchema:e}=useColumnSchema$1(),t=(0,import_react.useField)(),o=(0,import_react.useForm)();return!(e!=null&&e["x-read-pretty"]||t.readPretty||o.readPretty)}},{name:"size",type:"select",useVisible(){const e=useIsFieldReadPretty(),{fieldSchema:t}=useColumnSchema$1();return e&&!t},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Size"),options:[{label:t("Large"),value:"large"},{label:t("Default"),value:"default"},{label:t("Small"),value:"small"}],value:((e=o==null?void 0:o.componentProps)==null?void 0:e.size)||"default",onChange(n){const a={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].size=n,a["x-component-props"]=r["x-component-props"],o.componentProps=o.componentProps||{},o.componentProps.size=n,i.emit("patch",{schema:a}),i.refresh()}}}},P(x({},getAllowMultiple()),{useVisible(){const e=useIsAssociationField(),t=useIsShowMultipleSwitch();return e&&t()}})]}),designerCss$3=import_css.css`
556
+ `},properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":t,"x-component-props":{placeholder:'{{t("Value")}}',useTypedConstant:!0,changeOnSelect:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}},properties:{add:{type:"void",title:'{{t("Add parameter")}}',"x-component":"ArrayItems.Addition"}}}),[t]),a=(0,import_react2.useMemo)(()=>({type:"boolean","x-content":e("Open in new window"),"x-decorator":"FormItem","x-component":"Checkbox","x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}}}),[e]);return{urlSchema:o,paramsSchema:n,openInNewWindowSchema:a,modeSchema:r,htmlSchema:i}},SchemaSettingsActionLinkItem=()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),{dn:o}=useDesignable(),{t:r}=(0,import_react_i18next.useTranslation)(),{urlSchema:i,paramsSchema:n,openInNewWindowSchema:a}=useURLAndHTMLSchema(),l=t["x-component-props"]||{},c={url:l.url,params:l.params||[{}],openInNewWindow:l.openInNewWindow};return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:r("Edit link"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:r("Edit link"),properties:{url:P(x({},i),{required:!0}),params:n,openInNewWindow:a}},onSubmit:({url:u,params:m,openInNewWindow:d})=>{l.url=u,l.params=m,l.openInNewWindow=d,t["x-component-props"]=l,e.componentProps.url=u,e.componentProps.params=m,e.componentProps.openInNewWindow=d,o.emit("patch",{schema:{"x-uid":t["x-uid"],"x-component-props":l}}),o.refresh()},initialValues:c})},customizeLinkActionSettings=new SchemaSettings({name:"actionSettings:link",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"editLink",Component:SchemaSettingsActionLinkItem},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useVisible(){const e=useCollectionRecord();return!import_lodash.default.isEmpty(e==null?void 0:e.data)},useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),refreshActionSettings=new SchemaSettings({name:"actionSettings:refresh",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"secondConFirm",Component:SecondConFirm},{name:"delete",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),customizeSaveRecordActionSettings=new SchemaSettings({name:"actionSettings:saveRecord",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"secondConfirmation",Component:SecondConFirm},{name:"assignFieldValues",Component:AssignedFieldValues},{name:"skipRequiredValidation",Component:SkipValidation},{name:"afterSuccessfulSubmission",Component:AfterSuccess},{name:"bindWorkflow",Component:WorkflowConfig},{name:"refreshDataBlockRequest",Component:RefreshDataBlockRequest,useComponentProps(){return{isPopupAction:!1}}},{name:"delete",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),updateSubmitActionSettings=new SchemaSettings({name:"actionSettings:updateSubmit",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})},useVisible(){return!(0,import_react.useFieldSchema)().parent["x-initializer"].includes("bulkEditForm")}},{name:"secondConfirmation",Component:SecondConFirm},{name:"workflowConfig",Component:WorkflowConfig,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.triggerWorkflows)}},{name:"assignFieldValues",Component:AssignedFieldValues,useVisible(){return!(0,import_react.useFieldSchema)().parent["x-initializer"].includes("bulkEditForm")}},{name:"skipRequiredValidation",Component:SkipValidation,useVisible(){return!(0,import_react.useFieldSchema)().parent["x-initializer"].includes("bulkEditForm")}},{name:"afterSuccessfulSubmission",Component:AfterSuccess},{name:"refreshDataBlockRequest",Component:RefreshDataBlockRequest,useComponentProps(){return{isPopupAction:!1}}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),submitActionSettings=new SchemaSettings({name:"actionSettings:submit",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"secondConfirmation",Component:SecondConFirm},{name:"workflowConfig",Component:WorkflowConfig,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.triggerWorkflows)}},{name:"saveMode",Component:SaveMode,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return t["x-action"]==="submit"&&isInitializersSame((e=t.parent)==null?void 0:e["x-initializer"],"createForm:configureActions")}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),customizeUpdateRecordActionSettings=new SchemaSettings({name:"actionSettings:updateRecord",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"secondConFirm",Component:SecondConFirm},{name:"assignFieldValues",Component:AssignedFieldValues},{name:"afterSuccessfulSubmission",Component:AfterSuccess},{name:"workflowConfig",Component:WorkflowConfig,useVisible(){var e;const t=(0,import_react.useFieldSchema)();return(0,import_shared.isValid)((e=t==null?void 0:t["x-action-settings"])==null?void 0:e.triggerWorkflows)}},{name:"refreshDataBlockRequest",Component:RefreshDataBlockRequest,useComponentProps(){return{isPopupAction:!1}}},{name:"delete",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),customizePopupActionSettings=new SchemaSettings({name:"actionSettings:popup",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})},useVisible(){const{collection:e}=useCurrentPopupRecord()||{},t=useCollection();return!e||(e==null?void 0:e.name)===(t==null?void 0:t.name)}},{name:"openMode",Component:SchemaSettingOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=useOpenModeContext();return{openMode:!e,openSize:!e}}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),editActionSettings=new SchemaSettings({name:"actionSettings:edit",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"openMode",Component:SchemaSettingOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=useOpenModeContext();return{openMode:!e,openSize:!e}}},{name:"delete",type:"remove"}]}),viewActionSettings=new SchemaSettings({name:"actionSettings:view",items:[{name:"editButton",Component:ButtonEditor$1,useComponentProps(){const{buttonEditorProps:e}=useSchemaToolbar();return e}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"openMode",Component:SchemaSettingOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=useOpenModeContext();return{openMode:!e,openSize:!e}}},{name:"remove",sort:100,Component:RemoveButton,useComponentProps(){const{removeButtonProps:e}=useSchemaToolbar();return e}}]}),commonItems$1=[{name:"title",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e,readPretty:!0}}},{name:"dataScope",Component:SchemaSettingsDataScope,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{form:i}=useFormBlockContext(),n=(0,import_react.useField)(),{dn:a}=useDesignable(),{service:l}=useDetailsBlockContext();return{collectionName:o,defaultFilter:((t=(e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.filter)||{},form:i,noRecord:!0,onSubmit:({filter:c})=>{c=removeNullCondition(c);const u=n.decoratorProps.params||{};u.filter=c,n.decoratorProps.params=u,r["x-decorator-props"].params=u,a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}}),l.params[0].page=1}}}},{name:"sortingRules",type:"modal",useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),{t:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_react.useFieldSchema)(),n=(0,import_react.useField)(),{service:a}=useDetailsBlockContext(),{dn:l}=useDesignable(),c=useSortFields(o),u=((t=(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.sort)||[],m=u==null?void 0:u.map(d=>d.startsWith("-")?{field:d.substring(1),direction:"desc"}:{field:d,direction:"asc"});return{title:r("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:r("Set default sorting rules"),properties:{sort:{type:"array",default:m,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:c,required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:r("ASC"),value:"asc"},{label:r("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:r("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit({sort:d}){var p;const g=d.map(f=>f.direction==="desc"?`-${f.field}`:f.field),h=n.decoratorProps.params||{};h.sort=g,n.decoratorProps.params=h,i["x-decorator-props"].params=h,l.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}}),a.run(P(x({},(p=a.params)==null?void 0:p[0]),{sort:g}))}}}},setDataLoadingModeSettingsItem,{name:"template",Component:SchemaSettingsTemplate,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{componentName:`${i}Details`,collectionName:o,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}],multiDataDetailsBlockSettings=new SchemaSettings({name:"blockSettings:multiDataDetails",items:commonItems$1}),detailsWithPaginationSettings=new SchemaSettings({name:"blockSettings:detailsWithPagination",items:commonItems$1}),commonItems=[{name:"title",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection();return{collectionName:e,readPretty:!0}}},{name:"formItemTemplate",Component:SchemaSettingsFormItemTemplate,useComponentProps(){var e,t;const{name:o}=useCollection(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{insertAdjacentPosition:"beforeEnd",componentName:`${i}ReadPrettyFormItem`,collectionName:o,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}],singleDataDetailsBlockSettings=new SchemaSettings({name:"blockSettings:singleDataDetails",items:commonItems}),detailsBlockSettings=new SchemaSettings({name:"blockSettings:details",items:commonItems}),createFormBlockSettings=new SchemaSettings({name:"blockSettings:createForm",items:[{name:"title",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"dataTemplates",Component:SchemaSettingsDataTemplates,useVisible(){const{action:e}=useFormBlockContext(),t=(0,import_react.useFieldSchema)();return!e&&(t==null?void 0:t["x-acl-action"].includes("create"))},useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"divider",type:"divider"},{name:"formItemTemplate",Component:SchemaSettingsFormItemTemplate,useComponentProps(){var e,t;const{componentNamePrefix:o}=useBlockTemplateContext(),{name:r}=useCollection(),i=(0,import_react.useFieldSchema)(),n=((e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.resource)||((t=i==null?void 0:i["x-decorator-props"])==null?void 0:t.association);return{componentName:`${o}FormItem`,collectionName:r,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),editFormBlockSettings=new SchemaSettings({name:"blockSettings:editForm",items:[{name:"title",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"dataTemplates",Component:SchemaSettingsDataTemplates,useVisible(){const{action:e}=useFormBlockContext();return!e},useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"divider",type:"divider"},{name:"formItemTemplate",Component:SchemaSettingsFormItemTemplate,useComponentProps(){var e,t;const{componentNamePrefix:o}=useBlockTemplateContext(),{name:r}=useCollection(),i=(0,import_react.useFieldSchema)(),n=((e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.resource)||((t=i==null?void 0:i["x-decorator-props"])==null?void 0:t.association);return{componentName:`${o}FormItem`,collectionName:r,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),fieldComponentSettingsItem={name:"fieldComponent",type:"select",useVisible(){const e=useCollectionField(),t=useDataSourceManager();if(!e)return!1;const o=t.collectionFieldInterfaceManager.getFieldInterface(e==null?void 0:e.interface);return Array.isArray(o==null?void 0:o.componentOptions)&&o.componentOptions.length>1&&o.componentOptions.filter(r=>!r.useVisible||r.useVisible()).length>1},useComponentProps(){var e,t,o,r;const{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useField)(),a=(0,import_react.useFieldSchema)(),l=useCollectionField(),c=useDataSourceManager().collectionFieldInterfaceManager.getFieldInterface(l==null?void 0:l.interface),{fieldSchema:u}=useColumnSchema$1(),m=u||a,{dn:d}=useDesignable(),p=useCompile(),g=((t=(e=c==null?void 0:c.componentOptions)==null?void 0:e.filter(h=>!h.useVisible||h.useVisible()))==null?void 0:t.map(h=>({label:p(h.label),value:h.value,useProps:h.useProps})))||[];return{title:i("Field component"),options:g,value:((o=m["x-component-props"])==null?void 0:o.component)||((r=g[0])==null?void 0:r.value),onChange(h){var f;const _=g.find(S=>S.value===h),v=x({component:h},((f=_==null?void 0:_.useProps)==null?void 0:f.call(_))||{});import_lodash.default.set(m,"x-component-props",v),n.componentProps=v,d.emit("patch",{schema:{"x-uid":m["x-uid"],"x-component-props":v}})}}}},fieldSettingsFormItem=new SchemaSettings({name:"fieldSettings:FormItem",items:[{name:"decoratorOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Generic properties")}},useChildren(){return[{name:"editFieldTitle",type:"modal",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),{dn:o}=useDesignable(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),n=useCompile(),{getCollectionJoinField:a}=useCollectionManager_deprecated(),{getField:l}=useCollection_deprecated(),c=l(i.name)||a(i["x-collection-field"]);return{title:t("Edit field title"),schema:{type:"object",title:t("Edit field title"),properties:{title:{title:t("Field title"),default:r==null?void 0:r.title,description:`${t("Original field title: ")}${(e=c==null?void 0:c.uiSchema)==null?void 0:e.title}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit({title:u}){var m;const d=u.trim()===""?(m=c==null?void 0:c.uiSchema)==null?void 0:m.title:u;r.title=n(d),i.title=d,o.emit("patch",{schema:{"x-uid":i["x-uid"],title:i.title}}),o.refresh()}}}},{name:"displayTitle",type:"switch",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),{dn:o}=useDesignable(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)();return{title:t("Display title"),checked:(e=r.decoratorProps.showTitle)!=null?e:!0,onChange(n){i["x-decorator-props"]=i["x-decorator-props"]||{},i["x-decorator-props"].showTitle=n,r.decoratorProps.showTitle=n,o.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":P(x({},i["x-decorator-props"]),{showTitle:n})}}),o.refresh()}}}},{name:"editDescription",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),{dn:t}=useDesignable(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)();return{title:e("Edit description"),schema:{type:"object",title:e("Edit description"),properties:{description:{default:o==null?void 0:o.description,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}}}},onSubmit({description:i}){o.description=i,r.description=i,t.emit("patch",{schema:{"x-uid":r["x-uid"],description:r.description}})}}}},{name:"editTooltip",type:"modal",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),{dn:o}=useDesignable(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)();return{title:t("Edit tooltip"),schema:{type:"object",title:t("Edit tooltip"),properties:{tooltip:{default:(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.tooltip,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}}}},onSubmit({tooltip:n}){r.decoratorProps.tooltip=n,i["x-decorator-props"]=i["x-decorator-props"]||{},i["x-decorator-props"].tooltip=n,o.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}}),o.refresh()}}}},{name:"required",type:"switch",useVisible(){const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),{required:o=!0}=useSchemaToolbar();return!e.readPretty&&t["x-component"]!=="FormField"&&o},useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r,refresh:i}=useDesignable();return{title:e("Required"),checked:t.required,onChange(n){const a={"x-uid":o["x-uid"]};t.required=n,o.required=n,a.required=n,r.emit("patch",{schema:a}),i()}}}},{name:"setDefaultValue",useVisible(){const{isAllowToSetDefaultValue:e}=useIsAllowToSetDefaultValue();return e()},Component:SchemaSettingsDefaultValue},{name:"pattern",type:"select",useVisible(){const{form:e}=useFormBlockContext(),t=(0,import_react.useFieldSchema)();return e&&!(e!=null&&e.readPretty)&&!isPatternDisabled(t)},useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable();let i="editable";return o["x-disabled"]===!0&&(i="readonly"),o["x-read-pretty"]===!0&&(i="read-pretty"),{title:e("Pattern"),options:[{label:e("Editable"),value:"editable"},{label:e("Readonly"),value:"readonly"},{label:e("Easy-reading"),value:"read-pretty"}],value:i,onChange(n){const a={"x-uid":o["x-uid"]};switch(n){case"readonly":{o["x-read-pretty"]=!1,o["x-disabled"]=!0,a["x-read-pretty"]=!1,a["x-disabled"]=!0,t.readPretty=!1,t.disabled=!0,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.ReadOnly));break}case"read-pretty":{o["x-read-pretty"]=!0,o["x-disabled"]=!1,a["x-read-pretty"]=!0,a["x-disabled"]=!1,t.readPretty=!0,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.ReadPretty));break}default:{o["x-read-pretty"]=!1,o["x-disabled"]=!1,a["x-read-pretty"]=!1,a["x-disabled"]=!1,t.readPretty=!1,t.disabled=!1,import_lodash.default.set(t,"initStateOfLinkageRules.pattern",getTempFieldState(!0,ActionType.Editable));break}}r.emit("patch",{schema:a}),r.refresh()}}}},{name:"setValidationRules",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r,refresh:i}=useDesignable(),n=useValidateSchema(),{getCollectionJoinField:a}=useCollectionManager_deprecated(),{getField:l}=useCollection_deprecated(),c=l(o.name)||a(o["x-collection-field"]),u=m=>m!=null&&!Number.isNaN(m);return{title:e("Set validation rules"),components:{ArrayCollapse:import_antd_v5.ArrayCollapse,FormLayout:import_antd_v5.FormLayout},schema:{type:"object",title:e("Set validation rules"),properties:{rules:{type:"array",default:o==null?void 0:o["x-validator"],"x-component":"ArrayCollapse","x-decorator":"FormItem","x-component-props":{accordion:!0},maxItems:3,items:{type:"object","x-component":"ArrayCollapse.CollapsePanel","x-component-props":{header:'{{ t("Validation rule") }}'},properties:{index:{type:"void","x-component":"ArrayCollapse.Index"},layout:{type:"void","x-component":"FormLayout","x-component-props":{labelStyle:{marginTop:"6px"},labelCol:8,wrapperCol:16},properties:P(x({},n),{message:{type:"string",title:'{{ t("Error message") }}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:2,maxRows:2}}}})},remove:{type:"void","x-component":"ArrayCollapse.Remove"},moveUp:{type:"void","x-component":"ArrayCollapse.MoveUp"},moveDown:{type:"void","x-component":"ArrayCollapse.MoveDown"}}},properties:{add:{type:"void",title:'{{ t("Add validation rule") }}',"x-component":"ArrayCollapse.Addition","x-reactions":{dependencies:["rules"],fulfill:{state:{disabled:"{{$deps[0].length >= 3}}"}}}}}}}},onSubmit(m){var d;const p=[];for(const f of m.rules)p.push(import_lodash.default.pickBy(f,u));const g={"x-uid":o["x-uid"]};if(["percent"].includes(c==null?void 0:c.interface))for(const f of p)(f.maxValue||f.minValue)&&(f.percentMode=!0),f.percentFormat&&(f.percentFormats=!0);const h=import_lodash.default.concat([],((d=c==null?void 0:c.uiSchema)==null?void 0:d["x-validator"])||[],p);t.validator=h,t.required=o.required,o["x-validator"]=p,g["x-validator"]=p,r.emit("patch",{schema:g}),i()}}},useVisible(){const{form:e}=useFormBlockContext(),t=useIsFormReadPretty(),o=useValidateSchema();return e&&!t&&o}},{name:"style",Component:e=>{const t=P(x({},e),{category:"style"});return(0,import_jsx_runtime.jsx)(SchemaSettingsLinkageRules,x({},t))},useVisible(){return useIsFieldReadPretty()},useComponentProps(){const{name:e}=useCollection(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},fieldComponentSettingsItem]}},{name:"componentOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Specific properties")}},useChildren(){const e=useApp(),t=useFieldComponentName(),o=e.schemaSettingsManager.get(`fieldSettings:component:${t}`);return(o==null?void 0:o.items)||[]}},{name:"divider",type:"divider"},{name:"delete",type:"remove",sort:100,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!0,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]}),pageSizeOptions$2=[12,24,60,96,120],gridSizes=["xs","md","lg","xxl"],screenSizeTitleMaps={xs:"Phone device",md:"Tablet device",lg:"Desktop device",xxl:"Large screen device"},screenSizeMaps={xs:"< 768",md:"≥ 768",lg:"≥ 992",xxl:"≥ 1600"},defaultColumnCount={xs:1,md:2,lg:3,xxl:4},columnCountMarks=[1,2,3,4,6,8,12,24].reduce((e,t)=>(e[t]=t,e),{}),GridCardDesigner=()=>{var e,t,o,r,i,n,a,l;const{name:c,title:u}=useCollection_deprecated(),m=useSchemaTemplate(),{t:d}=(0,import_react_i18next.useTranslation)(),p=(0,import_react.useFieldSchema)(),{form:g}=useFormBlockContext(),h=(0,import_react.useField)(),{dn:f}=useDesignable(),_=useSortFields(c),{componentNamePrefix:v}=useBlockTemplateContext(),S=((t=(e=p==null?void 0:p["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.sort)||[],C=((o=p==null?void 0:p["x-decorator-props"])==null?void 0:o.resource)||((r=p==null?void 0:p["x-decorator-props"])==null?void 0:r.association),b=S==null?void 0:S.map(y=>y.startsWith("-")?{field:y.substring(1),direction:"desc"}:{field:y,direction:"asc"});return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,{template:m,title:u||c,children:(0,import_jsx_runtime.jsxs)(SchemaComponentOptions,{components:{Slider:import_antd.Slider},children:[(0,import_jsx_runtime.jsx)(SetTheCountOfColumnsDisplayedInARow,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsDataScope,{collectionName:c,defaultFilter:((n=(i=p==null?void 0:p["x-decorator-props"])==null?void 0:i.params)==null?void 0:n.filter)||{},form:g,onSubmit:({filter:y})=>{y=removeNullCondition(y),import_lodash.default.set(p,"x-decorator-props.params.filter",y),h.decoratorProps.params=x({},p["x-decorator-props"].params),f.emit("patch",{schema:{"x-uid":p["x-uid"],"x-decorator-props":p["x-decorator-props"]}})}}),(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:d("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:d("Set default sorting rules"),properties:{sort:{type:"array",default:b,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:_,required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:d("ASC"),value:"asc"},{label:d("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:d("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit:({sort:y})=>{const F=y.map(j=>j.direction==="desc"?`-${j.field}`:j.field);import_lodash.default.set(p,"x-decorator-props.params.sort",F),h.decoratorProps.params=x({},p["x-decorator-props"].params),f.emit("patch",{schema:{"x-uid":p["x-uid"],"x-decorator-props":p["x-decorator-props"]}})}}),(0,import_jsx_runtime.jsx)(SetDataLoadingMode,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:d("Records per page"),value:((l=(a=h.decoratorProps)==null?void 0:a.params)==null?void 0:l.pageSize)||20,options:pageSizeOptions$2.map(y=>({value:y})),onChange:y=>{import_lodash.default.set(p,"x-decorator-props.params.pageSize",y),h.decoratorProps.params=P(x({},p["x-decorator-props"].params),{page:1}),f.emit("patch",{schema:{"x-uid":p["x-uid"],"x-decorator-props":p["x-decorator-props"]}})}}),(0,import_jsx_runtime.jsx)(SchemaSettingsTemplate,{componentName:`${v}GridCard`,collectionName:c,resourceName:C}),(0,import_jsx_runtime.jsx)(SchemaSettingsDivider,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})})};function SetTheCountOfColumnsDisplayedInARow(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useFieldSchema)(),o=(0,import_react.useField)(),{dn:r}=useDesignable(),i=o.decoratorProps.columnCount||defaultColumnCount,n=(0,import_react2.useMemo)(()=>({"x-component":"Slider","x-decorator":"FormItem","x-component-props":{min:1,max:24,marks:columnCountMarks,tooltip:{formatter:l=>`${l}${e("Column")}`},step:null}}),[e]),a=(0,import_react2.useMemo)(()=>gridSizes.reduce((l,c)=>(l[c]=P(x({},n),{title:e(screenSizeTitleMaps[c]),description:`${e("Screen size")} ${screenSizeMaps[c]} ${e("pixels")}`}),l),{}),[n,e]);return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:e("Set the count of columns displayed in a row"),initialValues:i,schema:{type:"object",title:e("Set the count of columns displayed in a row"),properties:a},onSubmit:l=>{import_lodash.default.set(t,"x-decorator-props.columnCount",l),o.decoratorProps.columnCount=l,r.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":t["x-decorator-props"]}})}})}const gridCardBlockSettings=new SchemaSettings({name:"blockSettings:gridCard",items:[{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"SetTheCountOfColumnsDisplayedInARow",Component:SetTheCountOfColumnsDisplayedInARow},{name:"SetTheDataScope",Component:SchemaSettingsDataScope,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{form:i}=useFormBlockContext(),n=(0,import_react.useField)(),{dn:a}=useDesignable();return{collectionName:o,defaultFilter:((t=(e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.filter)||{},form:i,onSubmit:({filter:l})=>{l=removeNullCondition(l),import_lodash.default.set(r,"x-decorator-props.params.filter",l),n.decoratorProps.params=x({},r["x-decorator-props"].params),a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"SetDefaultSortingRules",type:"modal",useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),{t:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_react.useFieldSchema)(),n=(0,import_react.useField)(),{dn:a}=useDesignable(),l=useSortFields(o),c=((t=(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.sort)||[],u=c==null?void 0:c.map(m=>m.startsWith("-")?{field:m.substring(1),direction:"desc"}:{field:m,direction:"asc"});return{title:r("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:r("Set default sorting rules"),properties:{sort:{type:"array",default:u,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:l,required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:r("ASC"),value:"asc"},{label:r("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:r("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit:({sort:m})=>{const d=m.map(p=>p.direction==="desc"?`-${p.field}`:p.field);import_lodash.default.set(i,"x-decorator-props.params.sort",d),n.decoratorProps.params=x({},i["x-decorator-props"].params),a.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}})}}}},setDataLoadingModeSettingsItem,{name:"RecordsPerPage",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)(),i=(0,import_react.useField)(),{dn:n}=useDesignable();return{title:o("Records per page"),value:((t=(e=i.decoratorProps)==null?void 0:e.params)==null?void 0:t.pageSize)||20,options:pageSizeOptions$2.map(a=>({value:a})),onChange:a=>{import_lodash.default.set(r,"x-decorator-props.params.pageSize",a),i.decoratorProps.params=P(x({},r["x-decorator-props"].params),{page:1}),n.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"ConvertReferenceToDuplicate",Component:SchemaSettingsTemplate,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{componentName:`${i}GridCard`,collectionName:o,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),listBlockSettings=new SchemaSettings({name:"blockSettings:list",items:[{name:"EditBlockTitle",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"SetTheDataScope",Component:SchemaSettingsDataScope,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{form:i}=useFormBlockContext(),n=(0,import_react.useField)(),{dn:a}=useDesignable();return{collectionName:o,defaultFilter:((t=(e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.filter)||{},form:i,onSubmit:({filter:l})=>{l=removeNullCondition(l),import_lodash.default.set(r,"x-decorator-props.params.filter",l),n.decoratorProps.params=P(x({},r["x-decorator-props"].params),{page:1}),a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"SetDefaultSortingRules",type:"modal",useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),{t:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_react.useFieldSchema)(),n=(0,import_react.useField)(),{dn:a}=useDesignable(),l=useSortFields(o),c=((t=(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.sort)||[],u=c==null?void 0:c.map(m=>m.startsWith("-")?{field:m.substring(1),direction:"desc"}:{field:m,direction:"asc"});return{title:r("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:r("Set default sorting rules"),properties:{sort:{type:"array",default:u,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:l,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:r("ASC"),value:"asc"},{label:r("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:r("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit:({sort:m})=>{const d=m.map(p=>p.direction==="desc"?`-${p.field}`:p.field);import_lodash.default.set(i,"x-decorator-props.params.sort",d),n.decoratorProps.params=P(x({},i["x-decorator-props"].params),{page:1}),a.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}})}}}},setDataLoadingModeSettingsItem,{name:"RecordsPerPage",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)(),i=(0,import_react.useField)(),{dn:n}=useDesignable();return{title:o("Records per page"),value:((t=(e=i.decoratorProps)==null?void 0:e.params)==null?void 0:t.pageSize)||20,options:[{label:"5",value:5},{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100},{label:"200",value:200}],onChange:a=>{import_lodash.default.set(r,"x-decorator-props.params.pageSize",a),i.decoratorProps.params=P(x({},r["x-decorator-props"].params),{page:1}),n.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"ConvertReferenceToDuplicate",Component:SchemaSettingsTemplate,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{componentName:`${i}List`,collectionName:o,resourceName:n}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),tableSelectorBlockSettings=new SchemaSettings({name:"blockSettings:tableSelector",items:[{name:"SetTheDataScope",Component:SchemaSettingsDataScope,useComponentProps:()=>{var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{form:n}=useFormBlockContext(),{service:a,extraFilter:l}=useTableSelectorContext(),{dn:c}=useDesignable(),u=useDataLoadingMode(),m=(0,import_react2.useCallback)(({filter:d})=>{d=removeNullCondition(d);const p=r.decoratorProps.params||{};p.filter=d,r.decoratorProps.params=p,i["x-decorator-props"].params=p,(0,import_lodash.cloneDeep)(d),c.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}})},[r.decoratorProps,i,l,u,c,a]);return{collectionName:o,defaultFilter:((t=(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.filter)||{},form:n,onSubmit:m}}},{name:"treeTable",type:"switch",useComponentProps:()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),{service:o}=useTableSelectorContext(),{t:r}=(0,import_react_i18next.useTranslation)(),{dn:i}=useDesignable();return{title:r("Tree table"),defaultChecked:!0,checked:e.decoratorProps.treeTable,onChange:n=>{var a;e.form.clearFormGraph(`${e.address}.*`),e.decoratorProps.treeTable=n,t["x-decorator-props"].treeTable=n;const l=P(x({},(a=o.params)==null?void 0:a[0]),{tree:n?!0:null});i.emit("patch",{schema:t}),i.refresh(),o.run(l)}}},useVisible:()=>{const{getCollectionJoinField:e}=useCollectionManager_deprecated(),t=(0,import_react.useFieldSchema)(),o=useCollection_deprecated(),r=recursiveParent$1(t,"CollectionField"),i=e(r==null?void 0:r["x-collection-field"]);return(o==null?void 0:o.tree)&&(i==null?void 0:i.target)===(i==null?void 0:i.collectionName)}},{name:"SetDefaultSortingRules",type:"modal",useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),n=useSortFields(o),{service:a}=useTableSelectorContext(),{t:l}=(0,import_react_i18next.useTranslation)(),{dn:c}=useDesignable(),u=((t=(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.params)==null?void 0:t.sort)||[],m=u==null?void 0:u.map(d=>d.startsWith("-")?{field:d.substring(1),direction:"desc"}:{field:d,direction:"asc"});return{title:l("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:l("Set default sorting rules"),properties:{sort:{type:"array",default:m,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:n,required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:l("ASC"),value:"asc"},{label:l("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:l("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit:({sort:d})=>{var p;const g=d.map(f=>f.direction==="desc"?`-${f.field}`:f.field),h=r.decoratorProps.params||{};h.sort=g,r.decoratorProps.params=h,i["x-decorator-props"].params=h,c.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}}),a.run(P(x({},(p=a.params)==null?void 0:p[0]),{sort:g}))}}},useVisible(){const e=(0,import_react.useField)(),{dragSort:t}=e.decoratorProps;return!t}},setDataLoadingModeSettingsItem,{name:"RecordsPerPage",type:"select",useComponentProps(){var e,t;const o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{service:i}=useTableSelectorContext(),{t:n}=(0,import_react_i18next.useTranslation)(),{dn:a}=useDesignable();return{title:n("Records per page"),value:((t=(e=o.decoratorProps)==null?void 0:e.params)==null?void 0:t.pageSize)||20,options:[{label:"5",value:5},{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100},{label:"200",value:200}],onChange:l=>{var c;const u=o.decoratorProps.params||{};u.pageSize=l,o.decoratorProps.params=u,r["x-decorator-props"].params=u,i.run(P(x({},(c=i.params)==null?void 0:c[0]),{pageSize:l,page:1})),a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),useCollection_deprecated=()=>{var e;const t=useCollection(),o=useAPIClient(),r=o==null?void 0:o.resource(t==null?void 0:t.name),i=(0,import_react2.useMemo)(()=>(t==null?void 0:t.fields)||[],[t]),n=(0,import_react2.useMemo)(()=>{var d;return((d=t==null?void 0:t.getInheritedFields)==null?void 0:d.call(t))||[]},[t]),a=(0,import_react2.useMemo)(()=>{var d,p;return((d=t==null?void 0:t.getAllFields)==null?void 0:d.call(t))||((p=t==null?void 0:t.getFields)==null?void 0:p.call(t))||[]},[t]),l=(0,import_react2.useMemo)(()=>{var d;return((d=t==null?void 0:t.getForeignKeyFields)==null?void 0:d.call(t))||[]},[t]),c=(0,import_react2.useCallback)(()=>a==null?void 0:a.find(d=>d.treeParent),[a]),u=(0,import_react2.useCallback)(d=>{var p;return(p=t==null?void 0:t.getField)==null?void 0:p.call(t,d)},[t]),m=(0,import_react2.useCallback)(()=>t==null?void 0:t.getPrimaryKey(),[t]);return P(x({},(e=t==null?void 0:t.getOptions)==null?void 0:e.call(t)),{resource:r,getTreeParentField:c,fields:a,getField:u,getPrimaryKey:m,currentFields:i,inheritedFields:n,foreignKeyFields:l})};function SchemaSettingsSortField(){const{fields:e}=useCollection_deprecated(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{t:r}=(0,import_react_i18next.useTranslation)(),{dn:i}=useDesignable(),n=useCompile(),{service:a,association:l}=useTableBlockContext(),{getCollectionJoinField:c}=useCollectionManager_deprecated(),u=c(l),m=e.filter(d=>!(d!=null&&d.target)&&d.interface==="sort").map(d=>{var p;return{value:d==null?void 0:d.name,label:n((p=d==null?void 0:d.uiSchema)==null?void 0:p.title)||(d==null?void 0:d.name),disabled:(d==null?void 0:d.scopeKey)&&(u==null?void 0:u.foreignKey)!==d.scopeKey}});return(0,import_jsx_runtime.jsx)(SchemaSettingsSelectItem,{title:r("Drag and drop sorting field"),options:m,value:t.decoratorProps.dragSortBy,onChange:d=>{var p;o["x-decorator-props"].dragSortBy=d,a.run(P(x({},(p=a.params)==null?void 0:p[0]),{sort:d})),t.decoratorProps.dragSortBy=d,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}}),i.refresh()}},"sort-field")}const tableBlockSettings=new SchemaSettings({name:"blockSettings:table",items:[{name:"editBlockTitle",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"treeTable",type:"switch",useComponentProps:()=>{var e;const{getCollectionField:t,getCollection:o}=useCollectionManager_deprecated(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{service:n}=useTableBlockContext(),{t:a}=(0,import_react_i18next.useTranslation)(),{dn:l}=useDesignable(),c=useCollection_deprecated(),{resource:u}=r.decoratorProps,m=u&&t(u),d=u!=null&&u.includes(".")?(e=o(m==null?void 0:m.target))==null?void 0:e.tree:!!(c!=null&&c.tree);return{title:a("Tree table"),defaultChecked:!0,checked:d?r.decoratorProps.treeTable:!1,onChange:p=>{var g;r.decoratorProps.treeTable=p,i["x-decorator-props"].treeTable=p,p===!1&&(i["x-decorator-props"].expandFlag=!1);const h=P(x({},(g=n.params)==null?void 0:g[0]),{tree:p?!0:null});l.emit("patch",{schema:i}),l.refresh(),n.run(h)}}},useVisible:()=>{const{getCollectionField:e}=useCollectionManager_deprecated(),t=(0,import_react.useField)(),o=useCollection_deprecated(),{resource:r}=t.decoratorProps,i=r&&e(r);return(o==null?void 0:o.tree)&&(i==null?void 0:i.collectionName)===(i==null?void 0:i.target)}},createSwitchSettingsItem({name:"expandFlag",title:e=>e("Expand All"),defaultValue:!1,schemaKey:"x-decorator-props.expandFlag",useVisible(){return(0,import_react.useField)().decoratorProps.treeTable}}),{name:"enableDragAndDropSorting",type:"switch",useComponentProps:()=>{const{getCollectionField:e}=useCollectionManager_deprecated(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{service:r}=useTableBlockContext(),{t:i}=(0,import_react_i18next.useTranslation)(),{dn:n}=useDesignable(),{resource:a}=t.decoratorProps,l=a&&e(a),c=useAPIClient();return{title:i("Enable drag and drop sorting"),checked:t.decoratorProps.dragSort,onChange:u=>q(void 0,null,function*(){var m,d,p;if(u&&l){const{data:g}=yield c.resource("collections.fields",l.collectionName).update({filterByTk:l.name,values:{sortable:!0}}),h=(d=(m=g==null?void 0:g.data)==null?void 0:m[0])==null?void 0:d.sortBy;o["x-decorator-props"].dragSortBy=h}t.decoratorProps.dragSort=u,o["x-decorator-props"].dragSort=u,r.run(P(x({},(p=r.params)==null?void 0:p[0]),{sort:o["x-decorator-props"].dragSortBy})),n.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})})}}},{name:"SortField",Component:SchemaSettingsSortField,useVisible(){return(0,import_react.useField)().decoratorProps.dragSort}},setTheDataScopeSchemaSettingsItem,setDefaultSortingRulesSchemaSettingsItem,setDataLoadingModeSettingsItem,{name:"RecordsPerPage",type:"select",useComponentProps(){var e,t;const o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{service:i}=useTableBlockContext(),{t:n}=(0,import_react_i18next.useTranslation)(),{dn:a}=useDesignable();return{title:n("Records per page"),value:((t=(e=o.decoratorProps)==null?void 0:e.params)==null?void 0:t.pageSize)||20,options:[{label:"5",value:5},{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100},{label:"200",value:200}],onChange:l=>{var c;const u=o.decoratorProps.params||{};u.pageSize=l,o.decoratorProps.params=u,r["x-decorator-props"].params=u,i.run(P(x({},(c=i.params)==null?void 0:c[0]),{pageSize:l,page:1})),a.emit("patch",{schema:{"x-uid":r["x-uid"],"x-decorator-props":r["x-decorator-props"]}})}}}},{name:"tableSize",type:"select",useComponentProps(){var e;(0,import_react.useField)();const t=(0,import_react.useFieldSchema)(),{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable(),i=t.reduceProperties((n,a)=>{if(a["x-component"]==="TableV2")return a},null);return{title:o("Table size"),value:((e=i==null?void 0:i["x-component-props"])==null?void 0:e.size)||"small",options:[{label:o("Large"),value:"large"},{label:o("Middle"),value:"middle"},{label:o("Small"),value:"small"}],onChange:n=>{i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].size=n,r.emit("patch",{schema:{"x-uid":i["x-uid"],"x-component-props":i["x-component-props"]}})}}}},{name:"ConnectDataBlocks",Component:SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{type:FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider",sort:7e3,useVisible:()=>{var e;const t=(0,import_react.useFieldSchema)();return!((e=t==null?void 0:t["x-decorator-props"])!=null&&e.disableTemplate)}},{name:"ConvertReferenceToDuplicate",sort:8e3,Component:SchemaSettingsTemplate,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{componentName:`${i}Table`,collectionName:o,resourceName:n}},useVisible:()=>{var e;const t=(0,import_react.useFieldSchema)();return!((e=t==null?void 0:t["x-decorator-props"])!=null&&e.disableTemplate)}},{name:"divider2",type:"divider",sort:9e3},{name:"delete",type:"remove",sort:1e4,useComponentProps:()=>({removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})}]}),tableColumnSettings=new SchemaSettings({name:"fieldSettings:TableColumn",items:[{name:"decoratorOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Generic properties")}},children:[{name:"customColumnTitle",type:"modal",useComponentProps(){var e;const{fieldSchema:t,collectionField:o}=useColumnSchema$1(),r=(0,import_react.useField)(),{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useFieldSchema)(),{dn:a}=useDesignable();return{title:i("Custom column title"),schema:{type:"object",title:i("Custom column title"),properties:{title:{title:i("Column title"),default:n==null?void 0:n.title,description:`${i("Original field title: ")}${((e=o==null?void 0:o.uiSchema)==null?void 0:e.title)||(t==null?void 0:t.title)}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:l})=>{r.title=l,n.title=l,a.emit("patch",{schema:{"x-uid":n["x-uid"],title:n.title}}),a.refresh()}}}},{name:"style",Component:e=>{const t=P(x({},e),{category:"style"});return(0,import_jsx_runtime.jsx)(SchemaSettingsLinkageRules,x({},t))},useVisible(){var e,t;const{fieldSchema:o}=useColumnSchema$1(),{isInSubTable:r}=useFlag(),i=(0,import_react.useField)();if(!r)return!0;const n=(t=i.path)==null?void 0:t.splice(((e=i.path)==null?void 0:e.length)-1,1);return o?i.form.query(`${n.concat("*."+o.name)}`).get("readPretty"):!1},useComponentProps(){const{name:e}=useCollection(),{linkageRulesProps:t}=useSchemaToolbar();return P(x({},t),{collectionName:e})}},{name:"columnWidth",type:"modal",useComponentProps(){var e;const t=(0,import_react.useField)(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:o("Column width"),schema:{type:"object",title:o("Column width"),properties:{width:{default:((e=r==null?void 0:r["x-component-props"])==null?void 0:e.width)||100,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{}}}},onSubmit:({width:n})=>{const a=r["x-component-props"]||{};a.width=n;const l={"x-uid":r["x-uid"]};l["x-component-props"]=a,r["x-component-props"]=a,t.componentProps.width=n,i.emit("patch",{schema:l}),i.refresh()}}}},{name:"sortable",type:"switch",useVisible(){const e=useCollection(),{collectionField:t}=useColumnSchema$1(),{getInterface:o}=useCollectionManager_deprecated(),r=o(t==null?void 0:t.interface),{currentMode:i}=useAssociationFieldContext();return(r==null?void 0:r.sortable)===!0&&!i&&((e==null?void 0:e.name)===(t==null?void 0:t.collectionName)||!(t!=null&&t.collectionName))},useComponentProps(){const e=(0,import_react.useField)(),{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable();return{title:t("Sortable"),checked:e.componentProps.sorter,onChange:i=>{const n={"x-uid":o["x-uid"]};o["x-component-props"]=P(x({},o["x-component-props"]),{sorter:i}),n["x-component-props"]=o["x-component-props"],e.componentProps.sorter=i,r.emit("patch",{schema:n}),r.refresh()}}}},{name:"setDefaultValue",useVisible(){const{fieldSchema:e}=useColumnSchema$1();return e?!(e!=null&&e["x-read-pretty"]):!1},Component:SchemaSettingsDefaultValue,useComponentProps(){const{fieldSchema:e}=useColumnSchema$1();return{fieldSchema:e}}},{name:"required",type:"switch",useVisible(){const{uiSchema:e,fieldSchema:t}=useColumnSchema$1(),o=(0,import_react.useField)();return t?["QuickEdit","FormItem"].includes(t["x-decorator"])&&!o.readPretty&&!(e!=null&&e["x-read-pretty"]):!1},useComponentProps(){const{fieldSchema:e}=useColumnSchema$1(),t=(0,import_react.useField)(),{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable();return{key:"required",title:o("Required"),checked:e==null?void 0:e.required,onChange:i=>{var n,a;if(!e)return console.error("fieldSchema is required");const l={"x-uid":e["x-uid"]};e.required=i,l.required=i;const c=(a=t.path)==null?void 0:a.splice(((n=t.path)==null?void 0:n.length)-1,1);t.form.query(`${c.concat("*."+e.name)}`).forEach(u=>{u.required=i}),r.emit("patch",{schema:l}),r.refresh()}}}},{name:"pattern",type:"select",useVisible(){const{fieldSchema:e,collectionField:t}=useColumnSchema$1(),o=(0,import_react.useField)();return e?["QuickEdit","FormItem"].includes(e["x-decorator"])&&!(o!=null&&o.readPretty)&&(t==null?void 0:t.interface)!=="o2m"&&!isPatternDisabled(e):!1},useComponentProps(){const{fieldSchema:e}=useColumnSchema$1(),t=(0,import_react.useField)(),{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable();let i="editable";return e?(e["x-disabled"]===!0&&(i="readonly"),e["x-read-pretty"]===!0&&(i="read-pretty"),{key:"pattern",title:o("Pattern"),options:[{label:o("Editable"),value:"editable"},{label:o("Readonly"),value:"readonly"},{label:o("Easy-reading"),value:"read-pretty"}],value:i,onChange:n=>{var a,l;const c={"x-uid":e["x-uid"]},u=(l=t.path)==null?void 0:l.splice(((a=t.path)==null?void 0:a.length)-1,1);switch(n){case"readonly":{e["x-read-pretty"]=!1,e["x-disabled"]=!0,c["x-read-pretty"]=!1,c["x-disabled"]=!0,t.form.query(`${u.concat("*."+e.name)}`).forEach(m=>{m.readonly=!0,m.disabled=!0});break}case"read-pretty":{e["x-read-pretty"]=!0,e["x-disabled"]=!1,c["x-read-pretty"]=!0,c["x-disabled"]=!1,t.form.query(`${u.concat("*."+e.name)}`).forEach(m=>{m.readPretty=!0});break}default:{e["x-read-pretty"]=!1,e["x-disabled"]=!1,c["x-read-pretty"]=!1,c["x-disabled"]=!1,t.form.query(`${u.concat("*."+e.name)}`).forEach(m=>{m.readPretty=!1,m.disabled+!1});break}}r.emit("patch",{schema:c}),r.refresh()}}):console.error("fieldSchema is required")}},{name:"fixed",type:"select",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Fixed"),options:[{label:t("Not fixed"),value:"none"},{label:t("Left fixed"),value:"left"},{label:t("Right fixed"),value:"right"}],value:((e=o.componentProps)==null?void 0:e.fixed)||"none",onChange(n){const a={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].fixed=n,a["x-component-props"]=r["x-component-props"],o.componentProps=o.componentProps||{},o.componentProps.fixed=n,i.emit("patch",{schema:a}),i.refresh()}}}},{name:"hidden",type:"switch",useComponentProps(){const e=(0,import_react.useField)(),{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable();return{title:(0,import_jsx_runtime.jsxs)("span",{children:[t("Hide column"),(0,import_jsx_runtime.jsx)(import_antd.Tooltip,{title:t("In configuration mode, the entire column becomes transparent. In non-configuration mode, the entire column will be hidden. Even if the entire column is hidden, its configured default values and other settings will still take effect."),children:(0,import_jsx_runtime.jsx)(import_icons.QuestionCircleOutlined,{style:{marginLeft:4,opacity:.65}})})]}),checked:e.componentProps.columnHidden,onChange:i=>{const n={"x-uid":o["x-uid"]};o["x-component-props"]=P(x({},o["x-component-props"]),{columnHidden:i}),n["x-component-props"]=o["x-component-props"],e.componentProps.columnHidden=i,r.emit("patch",{schema:n}),r.refresh()}}}},fieldComponentSettingsItem]},{name:"componentOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Specific properties")}},useChildren(){const e=useApp(),t=useFieldComponentName(),o={Select:"Select",DatePicker:"DatePicker",Nester:"Nester",SubTable:"SubTable",Picker:"Picker",PopoverNester:"PopoverNester",Tag:"Tag"},r=e.schemaSettingsManager.get(`fieldSettings:component:${o[t]||t}`);return(r==null?void 0:r.items)||[]}},{name:"divider",type:"divider"},{name:"delete",type:"remove",sort:100,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!1,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]}),filterCollapseBlockSettings=new SchemaSettings({name:"blockSettings:filterCollapse",items:[{name:"EditBlockTitle",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"ConvertReferenceToDuplicate",Component:SchemaSettingsTemplate,useComponentProps(){var e,t;const{name:o}=useCollection_deprecated(),r=(0,import_react.useFieldSchema)(),{componentNamePrefix:i}=useBlockTemplateContext(),n=((e=r==null?void 0:r["x-decorator-props"])==null?void 0:e.resource)||((t=r==null?void 0:r["x-decorator-props"])==null?void 0:t.association);return{componentName:`${i}FilterCollapse`,collectionName:o,resourceName:n}}},{name:"ConnectDataBlocks",Component:SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{type:FilterBlockType.COLLAPSE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),filterCollapseItemFieldSettings=new SchemaSettings({name:"fieldSettings:FilterCollapseItem",items:[{name:"decoratorOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Generic properties")}},useChildren(){return[{name:"customTitle",type:"modal",useComponentProps(){var e;const t=(0,import_react.useFieldSchema)(),{t:o}=(0,import_react_i18next.useTranslation)(),{getCollectionJoinField:r}=useCollectionManager_deprecated(),{getField:i}=useCollection_deprecated(),n=i(t.name)||r(t["x-collection-field"]),{dn:a}=useDesignable();return{title:o("Custom title"),schema:{type:"object",title:o("Custom title"),properties:{title:{default:t==null?void 0:t.title,description:`${o("Original title: ")}${((e=n==null?void 0:n.uiSchema)==null?void 0:e.title)||(t==null?void 0:t.title)}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit:({title:l})=>{l&&(t.title=l,a.emit("patch",{schema:{"x-uid":t["x-uid"],title:t.title}})),a.refresh()}}}},{name:"defaultCollapse",type:"switch",useComponentProps(){const e=(0,import_react.useFieldSchema)(),t=(0,import_react.useField)(),{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable();return{title:o("Default collapse"),checked:t.componentProps.defaultCollapse,onChange:i=>{t.componentProps.defaultCollapse=i,import_lodash.default.set(e,"x-component-props.defaultCollapse",i),r.emit("patch",{schema:{"x-uid":e["x-uid"],"x-component-props":e["x-component-props"]}}),r.refresh()}}}},{name:"setTheDataScope",Component:SchemaSettingsDataScope,useComponentProps(){var e,t;const o=(0,import_react.useFieldSchema)(),{form:r}=useFormBlockContext(),i=(0,import_react.useField)(),{getCollectionJoinField:n}=useCollectionManager_deprecated(),{getField:a}=useCollection_deprecated(),l=a(o.name)||n(o["x-collection-field"]),{dn:c}=useDesignable();return{collectionName:l==null?void 0:l.target,defaultFilter:((t=(e=o==null?void 0:o["x-component-props"])==null?void 0:e.params)==null?void 0:t.filter)||{},form:r,onSubmit:({filter:u})=>{var m;import_lodash.default.set(i.componentProps,"params",P(x({},(m=i.componentProps)==null?void 0:m.params),{filter:u})),o["x-component-props"].params=i.componentProps.params,c.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}})}}},useVisible(){const e=(0,import_react.useFieldSchema)(),t=useCollection().getField(e.name);return!!(t!=null&&t.target)}},{name:"setDefaultSortingRules",Component:SchemaSettingsDefaultSortingRules,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{getCollectionJoinField:t}=useCollectionManager_deprecated(),{getField:o}=useCollection_deprecated(),r=o(e.name)||t(e["x-collection-field"]);return{name:r==null?void 0:r.target}},useVisible(){const e=(0,import_react.useFieldSchema)(),t=useCollection().getField(e.name);return!!(t!=null&&t.target)}},{name:"titleField",type:"select",useComponentProps(){var e,t;const o=(0,import_react.useFieldSchema)(),{t:r}=(0,import_react_i18next.useTranslation)(),{getCollectionJoinField:i}=useCollectionManager_deprecated(),{getField:n}=useCollection_deprecated(),a=n(o.name)||i(o["x-collection-field"]),l=useCollectionManager(),c=useCompile(),{dn:u}=useDesignable(),m=(a!=null&&a.target?l.getCollectionFields(a==null?void 0:a.target):[]).filter(p=>!(p!=null&&p.target)&&p.type!=="boolean").map(p=>{var g;return{value:p==null?void 0:p.name,label:c((g=p==null?void 0:p.uiSchema)==null?void 0:g.title)||(p==null?void 0:p.name)}}),d=p=>{var g,h,f;const _={"x-uid":o["x-uid"]},v=P(x(x({},(h=(g=a==null?void 0:a.uiSchema)==null?void 0:g["x-component-props"])==null?void 0:h.fieldNames),(f=o["x-component-props"])==null?void 0:f.fieldNames),{label:p});o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].fieldNames=v,_["x-component-props"]=o["x-component-props"],u.emit("patch",{schema:_}),u.refresh()};return{key:"title-field",title:r("Title field"),options:m,value:(t=(e=o["x-component-props"])==null?void 0:e.fieldNames)==null?void 0:t.label,onChange:d}},useVisible(){const e=(0,import_react.useFieldSchema)(),t=useCollection().getField(e.name);return!!(t!=null&&t.target)}},{name:"setDefaultValue",Component:SchemaSettingsDefaultValue,componentProps:{hideVariableButton:!0}}]}},{name:"divider",type:"divider"},{name:"delete",type:"remove",sort:100,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!0,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]}),filterFormBlockSettings=new SchemaSettings({name:"blockSettings:filterForm",items:[{name:"title",Component:SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"formItemTemplate",Component:SchemaSettingsFormItemTemplate,useComponentProps(){var e,t;const{componentNamePrefix:o}=useBlockTemplateContext(),{name:r}=useCollection(),i=(0,import_react.useFieldSchema)(),n=((e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.resource)||((t=i==null?void 0:i["x-decorator-props"])==null?void 0:t.association);return{componentName:`${o}FilterFormItem`,collectionName:r,resourceName:n}}},{name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const{name:e}=useCollection_deprecated();return{collectionName:e}}},{name:"connectDataBlocks",Component:SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{type:FilterBlockType.FORM,emptyDescription:e("No blocks to connect")}}},{name:"setBlockLayout",Component:SchemaSettingsLayoutItem},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),fieldComponentNameMap=e=>e==="Select"?"FilterSelect":e,filterFormItemFieldSettings=new SchemaSettings({name:"fieldSettings:FilterFormItem",items:[{name:"decoratorOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Generic properties")}},useChildren(){return[{name:"editFieldTitle",type:"modal",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),{dn:o}=useDesignable(),r=(0,import_react.useField)(),i=useCompile(),n=(0,import_react.useFieldSchema)(),{getCollectionJoinField:a}=useCollectionManager_deprecated(),{getField:l}=useCollection_deprecated(),c=l(n.name)||a(n["x-collection-field"]);return{title:t("Edit field title"),schema:{type:"object",title:t("Edit field title"),properties:{title:{title:t("Field title"),default:r==null?void 0:r.title,description:`${t("Original field title: ")}${(e=c==null?void 0:c.uiSchema)==null?void 0:e.title}`,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},onSubmit({title:u}){var m;const d=u.trim()===""?(m=c==null?void 0:c.uiSchema)==null?void 0:m.title:u;r.title=i(d),n.title=d,o.emit("patch",{schema:{"x-uid":n["x-uid"],title:n.title}}),o.refresh()}}}},{name:"displayTitle",type:"switch",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable(),i=(0,import_react.useField)(),n=(0,import_react.useFieldSchema)();return{title:o("Display title"),checked:(t=(e=n["x-decorator-props"])==null?void 0:e.showTitle)!=null?t:!0,onChange(a){n["x-decorator-props"]=n["x-decorator-props"]||{},n["x-decorator-props"].showTitle=a,i.decoratorProps.showTitle=a,r.emit("patch",{schema:{"x-uid":n["x-uid"],"x-decorator-props":P(x({},n["x-decorator-props"]),{showTitle:a})}}),r.refresh()}}}},{name:"editDescription",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),{dn:t}=useDesignable(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)();return{title:e("Edit description"),schema:{type:"object",title:e("Edit description"),properties:{description:{default:o==null?void 0:o.description,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}}}},onSubmit({description:i}){o.description=i,r.description=i,t.emit("patch",{schema:{"x-uid":r["x-uid"],description:r.description}}),t.refresh()}}}},{name:"editTooltip",type:"modal",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),{dn:o}=useDesignable(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)();return{title:t("Edit tooltip"),schema:{type:"object",title:t("Edit tooltip"),properties:{tooltip:{default:(e=i==null?void 0:i["x-decorator-props"])==null?void 0:e.tooltip,"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{}}}},onSubmit({tooltip:n}){r.decoratorProps.tooltip=n,i["x-decorator-props"]=i["x-decorator-props"]||{},i["x-decorator-props"].tooltip=n,o.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}}),o.refresh()}}}},{name:"setDefaultValue",Component:SchemaSettingsDefaultValue},{name:"setValidationRules",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r,refresh:i}=useDesignable(),n=useValidateSchema(),{getCollectionJoinField:a}=useCollectionManager_deprecated(),{getField:l}=useCollection_deprecated(),c=l(o.name)||a(o["x-collection-field"]),u=m=>m!=null&&!Number.isNaN(m);return{title:e("Set validation rules"),components:{ArrayCollapse:import_antd_v5.ArrayCollapse,FormLayout:import_antd_v5.FormLayout},schema:{type:"object",title:e("Set validation rules"),properties:{rules:{type:"array",default:o==null?void 0:o["x-validator"],"x-component":"ArrayCollapse","x-decorator":"FormItem","x-component-props":{accordion:!0},maxItems:3,items:{type:"object","x-component":"ArrayCollapse.CollapsePanel","x-component-props":{header:'{{ t("Validation rule") }}'},properties:{index:{type:"void","x-component":"ArrayCollapse.Index"},layout:{type:"void","x-component":"FormLayout","x-component-props":{labelStyle:{marginTop:"6px"},labelCol:8,wrapperCol:16},properties:P(x({},n),{message:{type:"string",title:'{{ t("Error message") }}',"x-decorator":"FormItem","x-component":"Input.TextArea","x-component-props":{autoSize:{minRows:2,maxRows:2}}}})},remove:{type:"void","x-component":"ArrayCollapse.Remove"},moveUp:{type:"void","x-component":"ArrayCollapse.MoveUp"},moveDown:{type:"void","x-component":"ArrayCollapse.MoveDown"}}},properties:{add:{type:"void",title:'{{ t("Add validation rule") }}',"x-component":"ArrayCollapse.Addition","x-reactions":{dependencies:["rules"],fulfill:{state:{disabled:"{{$deps[0].length >= 3}}"}}}}}}}},onSubmit(m){var d;const p=[];for(const f of m.rules)p.push(import_lodash.default.pickBy(f,u));const g={"x-uid":o["x-uid"]};if(["percent"].includes(c==null?void 0:c.interface))for(const f of p)(f.maxValue||f.minValue)&&(f.percentMode=!0),f.percentFormat&&(f.percentFormats=!0);const h=import_lodash.default.concat([],((d=c==null?void 0:c.uiSchema)==null?void 0:d["x-validator"])||[],p);t.validator=h,t.required=o.required,o["x-validator"]=p,g["x-validator"]=p,r.emit("patch",{schema:g}),i()}}},useVisible(){return!!useValidateSchema()}},{name:"operator",Component:EditOperator},fieldComponentSettingsItem]}},{name:"componentOptions",type:"itemGroup",hideIfNoChildren:!0,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{title:e("Specific properties")}},useChildren(){const e=useApp(),t=useFieldComponentName(),o=e.schemaSettingsManager.get(`fieldSettings:component:${fieldComponentNameMap(t)}`);return(o==null?void 0:o.items)||[]}},{name:"divider",type:"divider"},{name:"delete",type:"remove",sort:100,useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!0,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]}),markdownBlockSettings=new SchemaSettings({name:"blockSettings:markdown",items:[{name:"EditMarkdown",type:"item",useComponentProps(){const e=(0,import_react.useField)(),{t}=(0,import_react_i18next.useTranslation)();return{title:t("Edit markdown"),onClick:()=>{e.editable=!0}}}},{name:"setTheBlockHeight",Component:SchemaSettingsBlockHeightItem},{name:"setBlockTemplate",Component:SchemaSettingsRenderEngine},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),ellipsisSettingsItem={name:"ellipsis",type:"switch",useComponentProps(){var e;const{fieldSchema:t}=useColumnSchema$1(),o=useTableFieldInstanceList(),r=(0,import_react.useFieldSchema)(),i=(0,import_react.useField)(),{dn:n}=useDesignable(),{t:a}=(0,import_react_i18next.useTranslation)(),l=t||r,c=t?o[0]?!o[0].readPretty:!t["x-read-pretty"]:!i.readPretty;return{title:a("Ellipsis overflow content"),checked:!!((e=l["x-component-props"])!=null&&e.ellipsis),hidden:c,onChange:u=>q(this,null,function*(){t&&o?(o.forEach(m=>{m.componentProps.ellipsis=u}),l["x-component-props"].ellipsis=u):i.componentProps.ellipsis=u,yield n.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":P(x({},l["x-component-props"]),{ellipsis:u})}})})}}},enableLinkSettingsItem={name:"enableLink",type:"switch",useVisible(){const e=(0,import_react.useField)(),{fieldSchema:t}=useColumnSchema$1(),o=(0,import_react.useFieldSchema)(),r=t||o,{name:i}=useBlockContext()||{};return i!=="kanban"&&((r==null?void 0:r["x-read-pretty"])||e.readPretty)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),{fieldSchema:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=r||i,{dn:a}=useDesignable();return{title:t("Enable link"),checked:(e=n==null?void 0:n["x-component-props"])==null?void 0:e.enableLink,onChange(l){n["x-component-props"]=P(x({},n==null?void 0:n["x-component-props"]),{enableLink:l}),o.componentProps.enableLink=l,a.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n==null?void 0:n["x-component-props"])}})}}}},openModeSettingsItem={name:"openMode",Component:SchemaSettingOpenModeSchemaItems,useComponentProps(){const{hideOpenMode:e}=useOpenModeContext(),{fieldSchema:t}=useColumnSchema$1(),o=(0,import_react.useFieldSchema)();return{openMode:!e,openSize:!e,targetSchema:t||o}},useVisible(){var e;const t=(0,import_react.useField)(),{fieldSchema:o}=useColumnSchema$1(),r=(0,import_react.useFieldSchema)(),i=o||r;return((i==null?void 0:i["x-read-pretty"])||t.readPretty)&&((e=i==null?void 0:i["x-component-props"])==null?void 0:e.enableLink)}},inputComponentSettings=new SchemaSettings({name:"fieldSettings:component:Input",items:[ellipsisSettingsItem,enableLinkSettingsItem,openModeSettingsItem]}),fieldComponent$7={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),r=useFieldModeOptions(),i=useIsAddNewForm(),n=useFieldComponentName(),{dn:a}=useDesignable();return{title:e("Field component"),options:r,value:n,onChange(l){const c={"x-uid":o["x-uid"]};o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].mode=l,c["x-component-props"]=o["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=l,isSubMode(o)&&i&&(c.default=null,o.default=null,t.setInitialValue(null),t.setValue(null)),a.emit("patch",{schema:c}),a.refresh()}}}},titleField$2={name:"titleField",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n}=useDesignable(),a=useTitleFieldOptions(),l=useCollectionField();return{title:o("Title field"),options:a,value:(t=(e=r==null?void 0:r.componentProps)==null?void 0:e.fieldNames)==null?void 0:t.label,onChange(c){var u,m;const d={"x-uid":i["x-uid"]},p=P(x(x({},(m=(u=l==null?void 0:l.uiSchema)==null?void 0:u["x-component-props"])==null?void 0:m.fieldNames),r.componentProps.fieldNames),{label:c});i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].fieldNames=p,d["x-component-props"]=i["x-component-props"],r.componentProps.fieldNames=i["x-component-props"].fieldNames,n.emit("patch",{schema:d}),n.refresh()}}}},cascadeSelectComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:CascadeSelect",items:[fieldComponent$7,titleField$2,ellipsisSettingsItem]}),SchemaSettingsDateRange=function e(t){var o,r,i,n,a,l,c,u,m,d,p,g,h,f,_,v;const{fieldSchema:S}=t,C=(0,import_react.useField)(),{dn:b}=useDesignable(),{t:y}=(0,import_react_i18next.useTranslation)(),{getCollectionJoinField:F}=useCollectionManager_deprecated(),{isInSubForm:j,isInSubTable:k}=useFlag()||{},T=F(S==null?void 0:S["x-collection-field"])||{},O=((o=S==null?void 0:S["x-component-props"])==null?void 0:o.showTime)||((i=(r=T==null?void 0:T.uiSchema)==null?void 0:r["x-component-props"])==null?void 0:i.showTime)||!1,N=((n=S==null?void 0:S["x-component-props"])==null?void 0:n.dateFormat)||((l=(a=T==null?void 0:T.uiSchema)==null?void 0:a["x-component-props"])==null?void 0:l.dateFormat)||"YYYY-MM-DD",L=((c=S==null?void 0:S["x-component-props"])==null?void 0:c.timeFormat)||((m=(u=T==null?void 0:T.uiSchema)==null?void 0:u["x-component-props"])==null?void 0:m.timeFormat)||"HH:mm:ss",D=((d=S==null?void 0:S["x-component-props"])==null?void 0:d.picker)||((g=(p=T==null?void 0:T.uiSchema)==null?void 0:p["x-component-props"])==null?void 0:g.picker)||"date";S["x-read-pretty"]||C.readOnly||C.readPretty;const R=(h=S==null?void 0:S["x-component-props"])==null?void 0:h._minDate,$=(f=S==null?void 0:S["x-component-props"])==null?void 0:f._maxDate,w=((_=T==null?void 0:T.uiSchema)==null?void 0:_["x-component-props"].gmt)||!1,I=((v=T==null?void 0:T.uiSchema)==null?void 0:v["x-component-props"].utc)||!1,M=useRecord(),{form:B}=useFormBlockContext(),z=(0,import_react2.useCallback)(U=>(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:{"x-component":"DatePicker","x-component-props":{dateFormat:N,timeFormat:L,gmt:w,utc:I,picker:D,showTime:O,placeholder:'{{t("Please select time or variable")}}',style:{minWidth:385}},name:"value","x-read-pretty":!1,"x-validator":void 0,"x-decorator":void 0}}),[N,w,D,O,L,I]),E=(0,import_react2.useCallback)(U=>(0,import_jsx_runtime.jsx)(VariableInput,P(x({},U),{form:B,record:M,noDisabled:!0,renderSchemaComponent:z})),[S,B,M,z]);function V(U){if(U!=null){if(typeof U=="string")return U;if(typeof U=="object"&&Object.prototype.hasOwnProperty.call(U,"value"))return V(U.value)}}return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:y("Date range limit"),schema:{type:"object","x-decorator":"",properties:{_minDate:{type:"string",title:'{{t("MinDate")}}',"x-decorator":"FormItem","x-component":E,"x-component-props":{name:"_minDate"},default:isVariable(R)?R:{value:R}},_maxDate:{type:"string",title:'{{t("MaxDate")}}',"x-decorator":"FormItem","x-component":E,"x-component-props":{name:"_maxDate"},default:isVariable($)?$:{value:$}}}},onSubmit:U=>{const G={"x-uid":S["x-uid"]};G["x-component-props"]=C.componentProps||{},S["x-component-props"]=P(x({},C.componentProps||{}),{_maxDate:V(U==null?void 0:U._maxDate),_minDate:V(U==null?void 0:U._minDate)}),G["x-component-props"]=S["x-component-props"],C.componentProps=S["x-component-props"];const W=C.path.entire.split(".");W.pop();const Y=W.join(".");C.query(`${Y}.*[0:].${S.name}`).forEach(H=>{H.props.name===S.name&&H.setComponentProps({_maxDate:V(U==null?void 0:U._maxDate),_minDate:V(U==null?void 0:U._minDate)})}),b.emit("patch",{schema:G}),b.refresh()},ModalContextProvider:U=>(0,import_jsx_runtime.jsx)(FlagProvider,{isInSubForm:j,isInSubTable:k,isInFormDataTemplate:!0,children:U.children})})},datePickerComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:DatePicker",items:[{name:"dateDisplayFormat",Component:SchemaSettingsDateFormat,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{fieldSchema:t}=useColumnSchema$1();return{fieldSchema:t||e}}},{name:"dateScopeSelect",Component:SchemaSettingsDateRange,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{fieldSchema:t}=useColumnSchema$1();return{fieldSchema:t||e}},useVisible(){const{fieldSchema:e}=useColumnSchema$1(),t=(0,import_react.useFieldSchema)(),o=e||t;return!(o!=null&&o["x-read-pretty"])}},ellipsisSettingsItem,enableLinkSettingsItem,openModeSettingsItem]}),rangePickerPickerComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:DatePicker.RangePicker",items:[{name:"dateDisplayFormat",Component:SchemaSettingsDateFormat,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{fieldSchema:t}=useColumnSchema$1();return{fieldSchema:t||e}}},ellipsisSettingsItem]}),enableLink$1={name:"enableLink",type:"switch",useVisible(){return(0,import_react.useField)().readPretty},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),{fieldSchema:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=r||i,{dn:a}=useDesignable();return{title:t("Enable link"),checked:((e=n["x-component-props"])==null?void 0:e.enableLink)!==!1,onChange(l){n["x-component-props"]=P(x({},n==null?void 0:n["x-component-props"]),{enableLink:l}),o.componentProps.enableLink=l,a.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n==null?void 0:n["x-component-props"])}})}}}},titleField$1={name:"titleField",type:"select",useComponentProps(){var e,t,o,r;const{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useField)(),{dn:a}=useDesignable(),l=useTitleFieldOptions(),{uiSchema:c,fieldSchema:u,collectionField:m}=useColumnSchema$1(),d=(0,import_react.useFieldSchema)(),p=u||d,g=useCollectionField(),h=m||g,f=x(x(x({},(t=(e=h==null?void 0:h.uiSchema)==null?void 0:e["x-component-props"])==null?void 0:t.fieldNames),(o=n==null?void 0:n.componentProps)==null?void 0:o.fieldNames),(r=p==null?void 0:p["x-component-props"])==null?void 0:r.fieldNames);return{title:i("Title field"),options:l,value:f==null?void 0:f.label,onChange(_){var v,S,C,b,y;const F={"x-uid":p["x-uid"]},j=P(x(x({},(S=(v=h==null?void 0:h.uiSchema)==null?void 0:v["x-component-props"])==null?void 0:S.fieldNames),(C=p["x-component-props"])==null?void 0:C.fieldNames),{label:_});p["x-component-props"]=p["x-component-props"]||{},p["x-component-props"].fieldNames=j,F["x-component-props"]=p["x-component-props"],n.componentProps.fieldNames=p["x-component-props"].fieldNames;const k=(y=n.path)==null?void 0:y.splice(((b=n.path)==null?void 0:b.length)-1,1);n.form.query(`${k.concat("*."+p.name)}`).forEach(T=>{T.componentProps.fieldNames=f}),a.emit("patch",{schema:F}),a.refresh()}}}},getAllowMultiple=e=>{const t=(e==null?void 0:e.title)||"Allow multiple";return{name:"allowMultiple",type:"switch",useComponentProps(){var o;const{t:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_react.useField)(),{fieldSchema:n}=useColumnSchema$1(),a=(0,import_react.useFieldSchema)(),l=n||a,{dn:c,refresh:u}=useDesignable();return{title:r(t),checked:((o=l["x-component-props"])==null?void 0:o.multiple)===void 0?!0:l["x-component-props"].multiple,onChange(m){const d={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},i.componentProps=i.componentProps||{},l["x-component-props"].multiple=m,i.componentProps.multiple=m,d["x-component-props"]=l["x-component-props"],c.emit("patch",{schema:d}),u()}}}}},quickCreate={name:"quickCreate",type:"select",useComponentProps(){var e;const{defaultOpenMode:t}=useOpenModeContext(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{dn:n,insertAdjacent:a}=useDesignable();return{title:o("Quick create"),options:[{label:o("None"),value:"none"},{label:o("Dropdown"),value:"quickAdd"},{label:o("Pop-up"),value:"modalAdd"}],value:((e=r.componentProps)==null?void 0:e.addMode)||"none",onChange(l){l==="modalAdd"&&(i.reduceProperties((u,m)=>m["x-component"]==="Action"?m:u,null)||a("afterBegin",{"x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-toolbar":"ActionSchemaToolbar","x-toolbar-props":{draggable:!1},"x-settings":"actionSettings:addNew","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:t,type:"default",component:"CreateRecordAction"}}));const c={"x-uid":i["x-uid"]};i["x-component-props"]=i["x-component-props"]||{},i["x-component-props"].addMode=l,c["x-component-props"]=i["x-component-props"],r.componentProps=r.componentProps||{},r.componentProps.addMode=l,n.emit("patch",{schema:c}),n.refresh()}}}},setDefaultSortingRules$1={name:"setDefaultSortingRules",Component:SchemaSettingsSortingRule},setTheDataScope={name:"setTheDataScope",Component:SchemaSettingsDataScope,useComponentProps(){var e,t,o;const{getCollectionJoinField:r,getAllCollectionsInheritChain:i}=useCollectionManager_deprecated(),{getField:n}=useCollection_deprecated(),{form:a}=useFormBlockContext(),l=useRecord(),c=(0,import_react.useField)(),{fieldSchema:u,collectionField:m}=useColumnSchema$1(),d=(0,import_react.useFieldSchema)(),p=u||d,g=m||n(p.name)||r(p["x-collection-field"]),h=useVariables$1(),f=useLocalVariables$1(),{dn:_}=useDesignable();return{collectionName:g==null?void 0:g.target,defaultFilter:((o=(t=(e=p==null?void 0:p["x-component-props"])==null?void 0:e.service)==null?void 0:t.params)==null?void 0:o.filter)||{},form:a,dynamicComponent:v=>(0,import_jsx_runtime.jsx)(VariableInput,P(x({},v),{form:a,collectionField:v.collectionField,record:l,shouldChange:getShouldChange({collectionField:v.collectionField,variables:h,localVariables:f,getAllCollectionsInheritChain:i})})),onSubmit:({filter:v})=>{v=removeNullCondition(v),import_lodash.default.set(p["x-component-props"],"service.params.filter",v),import_lodash.default.set(c.componentProps,"service.params.filter",v),_.emit("patch",{schema:{"x-uid":p["x-uid"],"x-component-props":p["x-component-props"]}})}}}},fieldComponent$6={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),{fieldSchema:o,collectionField:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=o||i,a=useFieldModeOptions({fieldSchema:o,collectionField:r}),l=useIsAddNewForm(),c=useFieldComponentName(),{dn:u}=useDesignable();return{title:e("Field component"),options:a,value:c,onChange(m){var d,p;const g={"x-uid":n["x-uid"]};n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].mode=m,g["x-component-props"]=n["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=m,isSubMode(n)&&l&&(g.default=null,n.default=null,(d=t==null?void 0:t.setInitialValue)==null||d.call(t,null),(p=t==null?void 0:t.setValue)==null||p.call(t,null)),u.emit("patch",{schema:g}),u.refresh()}}}},selectComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Select",items:[P(x({},fieldComponent$6),{useVisible:useIsAssociationField}),P(x({},setTheDataScope),{useVisible(){const e=useIsSelectFieldMode(),t=useIsFieldReadPretty();return e&&!t}}),P(x({},setDefaultSortingRules$1),{useComponentProps(){const{fieldSchema:e}=useColumnSchema$1();return{fieldSchema:e}},useVisible(){const e=useIsSelectFieldMode(),t=useIsFieldReadPretty();return e&&!t}}),P(x({},quickCreate),{useVisible(){const e=useIsAssociationField(),t=useIsFieldReadPretty(),{fieldSchema:o}=useColumnSchema$1(),{type:r}=useDataBlockProps()||{};return e&&!o&&!t&&r!=="publicForm"}}),P(x({},getAllowMultiple()),{useVisible(){const e=useIsFieldReadPretty(),t=useIsAssociationField(),o=useIsShowMultipleSwitch();return!e&&t&&o()}}),P(x({},titleField$1),{useVisible:useIsAssociationField}),P(x({},enableLink$1),{useVisible(){const e=useIsFieldReadPretty();return useIsAssociationField()&&e}}),ellipsisSettingsItem,P(x({},enableLinkSettingsItem),{useVisible(){const e=useCollectionField(),t=useIsFieldReadPretty();return!useIsAssociationField()&&t&&e.interface!=="multipleSelect"}}),P(x({},openModeSettingsItem),{useVisible(){var e,t;const o=(0,import_react.useField)(),r=useIsAssociationField(),{fieldSchema:i}=useColumnSchema$1(),n=(0,import_react.useFieldSchema)(),a=i||n;return((a==null?void 0:a["x-read-pretty"])||o.readPretty)&&(((e=a==null?void 0:a["x-component-props"])==null?void 0:e.enableLink)||r&&((t=a==null?void 0:a["x-component-props"])==null?void 0:t.enableLink)!==!1)}})]}),filterSelectComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:FilterSelect",items:[P(x({},fieldComponent$6),{useVisible:useIsAssociationField}),P(x({},setTheDataScope),{useVisible(){const e=useIsSelectFieldMode(),t=useIsFieldReadPretty();return e&&!t}}),P(x({},setDefaultSortingRules$1),{useComponentProps(){const{fieldSchema:e}=useColumnSchema$1();return{fieldSchema:e}},useVisible(){const e=useIsSelectFieldMode(),t=useIsFieldReadPretty();return e&&!t}}),getAllowMultiple({title:"Allow multiple selection"}),P(x({},titleField$1),{useVisible:useIsAssociationField}),P(x({},enableLink$1),{useVisible(){const e=useIsFieldReadPretty();return useIsAssociationField()&&e}})]}),fieldComponent$5={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=useIsAddNewForm(),r=useFieldComponentName(),{fieldSchema:i,collectionField:n}=useColumnSchema$1(),a=(0,import_react.useFieldSchema)(),l=i||a,c=useFieldModeOptions({fieldSchema:i,collectionField:n}),{dn:u}=useDesignable();return{title:e("Field component"),options:c,value:r,onChange(m){const d={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].mode=m,d["x-component-props"]=l["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=m,isSubMode(l)&&o&&(d.default=null,l.default=null,t.setInitialValue(null),t.setValue(null)),u.emit("patch",{schema:d}),u.refresh()}}}},fileManagerComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:FileManager",items:[fieldComponent$5,{name:"quickUpload",type:"switch",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),{fieldSchema:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=r||i,{dn:a,refresh:l}=useDesignable();return{title:t("Quick upload"),checked:((e=n["x-component-props"])==null?void 0:e.quickUpload)!==!1,onChange(c){const u={"x-uid":n["x-uid"]};o.componentProps.quickUpload=c,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].quickUpload=c,u["x-component-props"]=n["x-component-props"],a.emit("patch",{schema:u}),l()}}},useVisible(){const{fieldSchema:e}=useColumnSchema$1(),t=(0,import_react.useField)(),o=(0,import_react.useForm)();return!(e!=null&&e["x-read-pretty"]||t.readPretty||o.readPretty)}},{name:"selectFile",type:"switch",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),{fieldSchema:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=r||i,{dn:a,refresh:l}=useDesignable();return{title:t("Select file"),checked:((e=n["x-component-props"])==null?void 0:e.selectFile)!==!1,onChange(c){const u={"x-uid":n["x-uid"]};o.componentProps.selectFile=c,n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].selectFile=c,u["x-component-props"]=n["x-component-props"],a.emit("patch",{schema:u}),l()}}},useVisible(){const{fieldSchema:e}=useColumnSchema$1(),t=(0,import_react.useField)(),o=(0,import_react.useForm)();return!(e!=null&&e["x-read-pretty"]||t.readPretty||o.readPretty)}},{name:"size",type:"select",useVisible(){const e=useIsFieldReadPretty(),{fieldSchema:t}=useColumnSchema$1();return e&&!t},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Size"),options:[{label:t("Large"),value:"large"},{label:t("Default"),value:"default"},{label:t("Small"),value:"small"}],value:((e=o==null?void 0:o.componentProps)==null?void 0:e.size)||"default",onChange(n){const a={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].size=n,a["x-component-props"]=r["x-component-props"],o.componentProps=o.componentProps||{},o.componentProps.size=n,i.emit("patch",{schema:a}),i.refresh()}}}},P(x({},getAllowMultiple()),{useVisible(){const e=useIsAssociationField(),t=useIsShowMultipleSwitch();return e&&t()}})]}),designerCss$3=import_css.css`
557
557
  position: relative;
558
558
  &:hover {
559
559
  > .general-schema-designer {
@@ -591,7 +591,7 @@ https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModu
591
591
  }
592
592
  }
593
593
  }
594
- `,TableColumnActionBar=(0,import_react.observer)(e=>{const t=useDesigner();return(0,import_jsx_runtime.jsxs)(SortableItem,{className:designerCss$3,children:[(0,import_jsx_runtime.jsx)(t,{}),e.children]})},{displayName:"TableColumnActionBar"}),useColumnSchema=()=>{const{getField:e}=useCollection_deprecated(),t=useCompile(),o=(0,import_react.useFieldSchema)(),r=o.reduceProperties((n,a)=>a["x-component"]==="CollectionField"?a:n,null);if(!r)return{};const i=e(r.name);return{columnSchema:o,fieldSchema:r,collectionField:i,uiSchema:t(i==null?void 0:i.uiSchema)}},TableColumnDecorator=e=>{const t=useDesigner(),o=(0,import_react.useField)(),{fieldSchema:r,uiSchema:i,collectionField:n}=useColumnSchema(),a=useCompile();return(0,import_react2.useEffect)(()=>{o.title||r&&i!=null&&i.title&&(o.title=i==null?void 0:i.title)},[i==null?void 0:i.title]),(0,import_jsx_runtime.jsxs)(SortableItem,{className:designerCss$3,children:[(0,import_jsx_runtime.jsx)(t,{fieldSchema:r,uiSchema:i,collectionField:n}),o.title||a(i==null?void 0:i.title)]})},previewComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Preview",items:[{name:"size",type:"select",useVisible(){var e;const{fieldSchema:t}=useColumnSchema();return((e=t==null?void 0:t.parent)==null?void 0:e["x-component"])!=="TableV2.Column"},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Size"),options:[{label:t("Large"),value:"large"},{label:t("Default"),value:"default"},{label:t("Small"),value:"small"}],value:((e=o==null?void 0:o.componentProps)==null?void 0:e.size)||"default",onChange(n){const a={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].size=n,a["x-component-props"]=r["x-component-props"],o.componentProps=o.componentProps||{},o.componentProps.size=n,i.emit("patch",{schema:a}),i.refresh()}}}}]}),uploadAttachmentComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Upload.Attachment",items:[{name:"size",type:"select",useVisible(){var e;const{fieldSchema:t}=useColumnSchema$1(),o=((e=t==null?void 0:t.parent)==null?void 0:e["x-component"])==="TableV2.Column";return useIsFieldReadPretty()&&!o},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Size"),options:[{label:t("Large"),value:"large"},{label:t("Default"),value:"default"},{label:t("Small"),value:"small"}],value:((e=o==null?void 0:o.componentProps)==null?void 0:e.size)||"default",onChange(n){const a={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].size=n,a["x-component-props"]=r["x-component-props"],o.componentProps=o.componentProps||{},o.componentProps.size=n,i.emit("patch",{schema:a}),i.refresh()}}}}]}),inputJSONSettings=new SchemaSettings({name:"fieldSettings:component:Input.JSON",items:[ellipsisSettingsItem]}),createSettingsItem=e=>({name:e.name,type:"select",useComponentProps(){var t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{fieldSchema:n}=useColumnSchema$1(),a=n||i,{dn:l}=useDesignable();return{title:o(e.title),options:e.options(o),value:((t=a["x-component-props"])==null?void 0:t[e.name])||e.defaultValue,onChange(c){const u={"x-uid":a["x-uid"]};a["x-component-props"]=a["x-component-props"]||{},a["x-component-props"][e.name]=c,u["x-component-props"]=a["x-component-props"],r.componentProps=r.componentProps||{},r.componentProps[e.name]=c,l.emit("patch",{schema:u})}}}}),getSizeOptions=e=>[{value:"small",label:e("Small")},{value:"middle",label:e("Middle")},{value:"large",label:e("Large")},{value:"oversized",label:e("Oversized")},{value:"auto",label:e("Auto")}],getObjectFitOptions=e=>[{value:"cover",label:e("Cover")},{value:"fill",label:e("Fill")},{value:"contain",label:e("Contain")},{value:"scale-down",label:e("Scale Down")},{value:"none",label:e("None")}],size=createSettingsItem({name:"size",title:"Size",options:getSizeOptions,defaultValue:"small"}),objectFit=createSettingsItem({name:"objectFit",title:"Object Fit",options:getObjectFitOptions,defaultValue:"cover"}),inputPreviewComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Input.Preview",items:[size,objectFit]}),inputTextAreaSettings=new SchemaSettings({name:"fieldSettings:component:Input.TextArea",items:[ellipsisSettingsItem]}),inputURLSettings=new SchemaSettings({name:"fieldSettings:component:Input.URL",items:[ellipsisSettingsItem]}),markdownSettings=new SchemaSettings({name:"fieldSettings:component:Markdown",items:[ellipsisSettingsItem]}),markdownVditorSettings=new SchemaSettings({name:"fieldSettings:component:MarkdownVditor",items:[ellipsisSettingsItem]}),richTextSettings=new SchemaSettings({name:"fieldSettings:component:RichText",items:[ellipsisSettingsItem]}),inputNumberComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:InputNumber",items:[{name:"displayFormat",Component:SchemaSettingsNumberFormat,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{fieldSchema:t}=useColumnSchema$1();return{fieldSchema:t||e}},useVisible(){return useIsFieldReadPretty()}},enableLinkSettingsItem,openModeSettingsItem]}),filterFormItemSettings=new SchemaSettings({name:"FilterFormItemSettings",items:[{name:"editFieldTitle",Component:EditTitle},{name:"editDescription",Component:EditDescription},{name:"editTooltip",Component:EditTooltip},{name:"validationRules",Component:EditValidationRules},{name:"setDataScope",Component:SchemaSettingsDataScope,useVisible(){const e=useIsSelectFieldMode(),t=useIsFormReadPretty();return e&&!t},useComponentProps(){var e,t,o;const{getCollectionJoinField:r,getAllCollectionsInheritChain:i}=useCollectionManager_deprecated(),{getField:n}=useCollection_deprecated(),{form:a}=useFormBlockContext(),l=useRecord(),c=(0,import_react.useField)(),u=(0,import_react.useFieldSchema)(),m=n(u.name)||r(u["x-collection-field"]),d=useVariables$1(),p=useLocalVariables$1(),{dn:g}=useDesignable();return{collectionName:m==null?void 0:m.target,defaultFilter:((o=(t=(e=u==null?void 0:u["x-component-props"])==null?void 0:e.service)==null?void 0:t.params)==null?void 0:o.filter)||{},form:a,dynamicComponent:h=>(0,import_jsx_runtime.jsx)(VariableInput,P(x({},h),{form:a,collectionField:h.collectionField,record:l,shouldChange:getShouldChange({collectionField:h.collectionField,variables:d,localVariables:p,getAllCollectionsInheritChain:i})})),onSubmit:({filter:h})=>{h=removeNullCondition(h),import_lodash.default.set(c.componentProps,"service.params.filter",h),u["x-component-props"]=c.componentProps,g.emit("patch",{schema:{"x-uid":u["x-uid"],"x-component-props":c.componentProps}})}}}},{name:"fieldMode",Component:EditComponent},{name:"operator",Component:EditOperator},{name:"titleField",Component:EditTitleField},{name:"divider",type:"divider",useVisible(){const{getCollectionJoinField:e}=useCollectionManager_deprecated(),{getField:t}=useCollection_deprecated(),o=(0,import_react.useFieldSchema)();return!!(t(o.name)||e(o["x-collection-field"]))}},{name:"remove",type:"remove",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!0,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]}),fieldComponent$4={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),r=useFieldModeOptions(),i=useIsAddNewForm(),n=useFieldComponentName(),{dn:a}=useDesignable();return{title:e("Field component"),options:r,value:n,onChange(l){const c={"x-uid":o["x-uid"]};o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].mode=l,c["x-component-props"]=o["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=l,isSubMode(o)&&i&&(c.default=null,o.default=null,t.setInitialValue(null),t.setValue(null)),a.emit("patch",{schema:c}),a.refresh()}}}},allowSelectExistingRecord={name:"allowSelectExistingRecord",type:"switch",useVisible(){return!useIsFieldReadPretty()},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow selection of existing records"),checked:(e=r["x-component-props"])==null?void 0:e.allowSelectExistingRecord,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.allowSelectExistingRecord=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].allowSelectExistingRecord=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},allowDisassociation={name:"allowDisassociation",type:"switch",useVisible(){return!useIsFieldReadPretty()},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow disassociation"),checked:((e=r["x-component-props"])==null?void 0:e.allowDisassociation)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.allowDisassociation=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].allowDisassociation=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},setDefaultSortingRules={name:"SetDefaultSortingRules",type:"modal",useComponentProps(){const{getCollectionJoinField:e}=useCollectionManager_deprecated(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),r=o["x-collection-field"],{target:i}=e(r)||{},n=useSortFields(i),{t:a}=(0,import_react_i18next.useTranslation)(),{dn:l}=useDesignable(),c=t.componentProps.sortArr||[],u=c==null?void 0:c.map(m=>m!=null&&m.startsWith("-")?{field:m.substring(1),direction:"desc"}:{field:m,direction:"asc"});return{title:a("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:a("Set default sorting rules"),properties:{sort:{type:"array",default:u,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:n,required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:a("ASC"),value:"asc"},{label:a("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:a("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit:({sort:m})=>{const d=m.map(p=>p.direction==="desc"?`-${p.field}`:p.field);t.componentProps.sortArr=d,o["x-component-props"].sortArr=d,l.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}})}}},useVisible(){const{getCollectionJoinField:e}=useCollectionManager_deprecated(),t=(0,import_react.useFieldSchema)()["x-collection-field"],{interface:o}=e(t)||{};return useIsFieldReadPretty()&&["m2m","o2m"].includes(o)}},allowAddNewData={name:"allowAddNewData",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useIsAssociationField();return!e&&t},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow add new"),checked:((e=r["x-component-props"])==null?void 0:e.allowAddnew)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.allowAddnew=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].allowAddnew=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},LinkageRulesComponent=withDynamicSchemaProps(e=>(0,import_jsx_runtime.jsx)(FlagProvider,{isInSubForm:!0,children:(0,import_jsx_runtime.jsx)(FormLinkageRules,x({},e))}),{displayName:"LinkageRulesComponent"}),linkageRules={name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),o=useCollectionManager().getCollectionField(t["x-collection-field"]),{rerenderDataBlock:r}=useRerenderDataBlock();return{collectionName:o==null?void 0:o.target,Component:LinkageRulesComponent,readPretty:e.readPretty,afterSubmit:r}}},recordPerPage={name:"recordsPerPage",type:"select",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useFieldSchema)(),r=(0,import_react.useField)(),{dn:i}=useDesignable(),n=[10,20,50,100];return{title:t("Records per page"),value:((e=r.componentProps)==null?void 0:e.pageSize)||10,options:n.map(a=>({value:a})),onChange:a=>{const l={"x-uid":o["x-uid"]};r.componentProps=r.componentProps||{},r.componentProps.pageSize=a,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].pageSize=a,l["x-component-props"]=o["x-component-props"],i.emit("patch",{schema:l})}}}},subTablePopoverComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:SubTable",items:[fieldComponent$4,allowAddNewData,allowSelectExistingRecord,allowDisassociation,setDefaultSortingRules,linkageRules,recordPerPage]}),allowMultiple$2={name:"allowMultiple",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useCollectionField();return!e&&["hasMany","belongsToMany"].includes(t==null?void 0:t.type)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow multiple"),checked:((e=r["x-component-props"])==null?void 0:e.multiple)===void 0?!0:r["x-component-props"].multiple,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].multiple=a,o.componentProps.multiple=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},fieldComponent$3={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),r=useFieldModeOptions(),i=useIsAddNewForm(),n=useFieldComponentName(),{dn:a}=useDesignable();return{title:e("Field component"),options:r,value:n,onChange(l){const c={"x-uid":o["x-uid"]};o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].mode=l,c["x-component-props"]=o["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=l,isSubMode(o)&&i&&(c.default=null,o.default=null,t.setInitialValue(null),t.setValue(null)),a.emit("patch",{schema:c}),a.refresh()}}}},subformComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Nester",items:[fieldComponent$3,allowMultiple$2,{name:"allowDissociate",type:"switch",useVisible(){const{type:e}=useFormBlockType();return!useIsFormReadPretty()&&e==="update"},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow dissociate"),checked:((e=r["x-component-props"])==null?void 0:e.allowDissociate)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].allowDissociate=a,o.componentProps.allowDissociate=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},setDefaultSortingRules,linkageRules,{name:"setBlockLayout",Component:SchemaSettingsLayoutItem}]}),allowMultiple$1={name:"allowMultiple",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useCollectionField();return!e&&["hasMany","belongsToMany","belongsToArray"].includes(t==null?void 0:t.type)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow multiple"),checked:((e=r["x-component-props"])==null?void 0:e.multiple)===void 0?!0:r["x-component-props"].multiple,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].multiple=a,o.componentProps.multiple=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},fieldComponent$2={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=useIsAddNewForm(),r=useFieldComponentName(),{fieldSchema:i,collectionField:n}=useColumnSchema$1(),a=(0,import_react.useFieldSchema)(),l=i||a,c=useFieldModeOptions({fieldSchema:i,collectionField:n}),{dn:u}=useDesignable();return{title:e("Field component"),options:c,value:r,onChange(m){var d,p;const g={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].mode=m,g["x-component-props"]=l["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=m,isSubMode(l)&&o&&(g.default=null,l.default=null,(d=t==null?void 0:t.setInitialValue)==null||d.call(t,null),(p=t==null?void 0:t.setValue)==null||p.call(t,null)),u.emit("patch",{schema:g}),u.refresh()}}}},recordPickerComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Picker",items:[fieldComponent$2,{name:"popupSize",type:"select",useVisible(){return!useIsFieldReadPretty()},useComponentProps(){var e,t,o;const{t:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_react.useField)(),{fieldSchema:n}=useColumnSchema$1(),a=(0,import_react.useFieldSchema)(),l=n||a,{dn:c}=useDesignable();return{title:r("Popup size"),options:[{label:r("Small"),value:"small"},{label:r("Middle"),value:"middle"},{label:r("Large"),value:"large"}],value:(o=(e=l==null?void 0:l["x-component-props"])==null?void 0:e.openSize)!=null?o:((t=l==null?void 0:l["x-component-props"])==null?void 0:t.openMode)=="modal"?"large":"middle",onChange:u=>{i.componentProps.openSize=u,l["x-component-props"]=P(x({},l["x-component-props"]),{openSize:u}),c.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":l["x-component-props"]}}),c.refresh()}}}},allowAddNew,allowMultiple$1,titleField$1]}),allowMultiple={name:"allowMultiple",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useCollectionField();return!e&&["hasMany","belongsToMany"].includes(t==null?void 0:t.type)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow multiple"),checked:((e=r["x-component-props"])==null?void 0:e.multiple)===void 0?!0:r["x-component-props"].multiple,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].multiple=a,o.componentProps.multiple=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},fieldComponent$1={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),{fieldSchema:o,collectionField:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=o||i,a=useFieldModeOptions({fieldSchema:o,collectionField:r}),{dn:l}=useDesignable(),c=useIsAddNewForm(),u=useFieldComponentName();return{title:e("Field component"),options:a,value:u,onChange(m){const d={"x-uid":n["x-uid"]};n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].mode=m,d["x-component-props"]=n["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=m,isSubMode(n)&&c&&(d.default=null,n.default=null,t.setInitialValue(null),t.setValue(null)),l.emit("patch",{schema:d}),l.refresh()}}}},subformPopoverComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:PopoverNester",items:[fieldComponent$1,allowMultiple,titleField$1,linkageRules,{name:"setBlockLayout",Component:SchemaSettingsLayoutItem}]}),enableLink={name:"enableLink",type:"switch",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),{fieldSchema:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=r||i,{dn:a}=useDesignable();return{title:t("Enable link"),checked:((e=n["x-component-props"])==null?void 0:e.enableLink)!==!1,onChange(l){n["x-component-props"]=P(x({},n==null?void 0:n["x-component-props"]),{enableLink:l}),o.componentProps.enableLink=l,a.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n==null?void 0:n["x-component-props"])}})}}}},titleField={name:"titleField",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),{fieldSchema:i,collectionField:n}=useColumnSchema$1(),a=(0,import_react.useFieldSchema)(),l=i||a,c=useTitleFieldOptions(),u=useCollectionField(),m=n||u,{dn:d}=useDesignable();return{title:o("Title field"),options:c,value:(t=(e=l==null?void 0:l["x-component-props"])==null?void 0:e.fieldNames)==null?void 0:t.label,onChange(p){var g,h;const f={"x-uid":l["x-uid"]},_=P(x(x({},(h=(g=m==null?void 0:m.uiSchema)==null?void 0:g["x-component-props"])==null?void 0:h.fieldNames),r.componentProps.fieldNames),{label:p});l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].fieldNames=_,f["x-component-props"]=l["x-component-props"],r.componentProps.fieldNames=l["x-component-props"].fieldNames,d.emit("patch",{schema:f}),d.refresh()}}}},fieldComponent={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=useIsAddNewForm(),{fieldSchema:r,collectionField:i}=useColumnSchema$1(),n=useFieldModeOptions({fieldSchema:r,collectionField:i}),a=(0,import_react.useFieldSchema)(),l=r||a,c=useFieldComponentName(),{dn:u}=useDesignable();return{title:e("Field component"),options:n,value:c,onChange(m){const d={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].mode=m,d["x-component-props"]=l["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=m,isSubMode(l)&&o&&(d.default=null,l.default=null,t.setInitialValue(null),t.setValue(null)),u.emit("patch",{schema:d}),u.refresh()}}}},tagComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Tag",items:[fieldComponent,{name:"tagColorField",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),n=useCollectionField(),{fieldSchema:a,collectionField:l}=useColumnSchema$1(),c=a||i,u=l||n,{dn:m}=useDesignable(),d=useColorFields((e=u==null?void 0:u.target)!=null?e:u==null?void 0:u.targetCollection);return{title:o("Tag color field"),options:d,value:(t=c==null?void 0:c["x-component-props"])==null?void 0:t.tagColorField,onChange(p){const g={"x-uid":c["x-uid"]};c["x-component-props"]=c["x-component-props"]||{},c["x-component-props"].tagColorField=p,g["x-component-props"]=c["x-component-props"],r.componentProps.tagColorField=p,m.emit("patch",{schema:g}),m.refresh()}}}},titleField,enableLink,ellipsisSettingsItem]}),unixTimestampComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:UnixTimestamp",items:[{name:"dateDisplayFormat",Component:SchemaSettingsDateFormat,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{fieldSchema:t}=useColumnSchema$1();return{fieldSchema:t||e}}},enableLinkSettingsItem,openModeSettingsItem]});function GroupTitleEditor(e){const t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable(),{t:i}=(0,import_react_i18next.useTranslation)();return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:i("Edit group title"),schema:{type:"object",title:i("Edit group title"),properties:{children:{"x-decorator":"FormItem","x-component":"Input",title:i("Group title"),default:t.componentProps.children,"x-component-props":{}}}},onSubmit:({children:n})=>{t.componentProps.children=n,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].children=n,r.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":x({},o["x-component-props"])}}),r.refresh()}})}const dividerSettings=new SchemaSettings({name:"blockSettings:divider",items:[{name:"editTitle",type:"item",Component:GroupTitleEditor},{name:"orientation",type:"select",useComponentProps(){var e;const t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{t:r}=(0,import_react_i18next.useTranslation)(),{dn:i}=useDesignable();return{title:r("Title position"),value:((e=t.componentProps)==null?void 0:e.orientation)||"left",options:[{label:r("Left"),value:"left"},{label:r("Center"),value:"center"},{label:r("Right"),value:"right"}],onChange:n=>{t.componentProps=t.componentProps||{},t.componentProps.orientation=n,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].orientation=n,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}})}}}},{name:"dashed",type:"switch",useComponentProps:()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable();return{title:o("Dashed"),defaultChecked:!0,checked:e.componentProps.dashed,onChange:i=>{e.componentProps.dashed=i,t["x-component-props"].dashed=i,i===!1&&(t["x-component-props"].dashed=!1),r.emit("patch",{schema:t}),r.refresh()}}}},{name:"color",type:"item",useComponentProps:()=>{const{t:e}=(0,import_react_i18next.useTranslation)(),{dn:t}=useDesignable(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)();return{title:(0,import_jsx_runtime.jsxs)("div",{style:{alignItems:"center",display:"flex",justifyContent:"space-between"},children:[e("Color"),(0,import_jsx_runtime.jsx)("div",{style:{float:"right"},children:(0,import_jsx_runtime.jsx)(ColorPicker,{defaultValue:o.componentProps.color||"rgba(0, 0, 0, 0.88)",onChange:i=>{o.componentProps=o.componentProps||{},o.componentProps.color=i,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].color=i,t.emit("patch",{schema:r}),t.refresh()}})})]})}}},{name:"borderColor",type:"item",useComponentProps:()=>{const{t:e}=(0,import_react_i18next.useTranslation)(),{dn:t}=useDesignable(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)();return{title:(0,import_jsx_runtime.jsxs)("div",{style:{alignItems:"center",display:"flex",justifyContent:"space-between"},children:[e("Divider line color"),(0,import_jsx_runtime.jsx)("div",{style:{float:"right"},children:(0,import_jsx_runtime.jsx)(ColorPicker,{defaultValue:o.componentProps.borderColor||"rgba(5, 5, 5, 0.06)",onChange:i=>{o.componentProps=o.componentProps||{},o.componentProps.borderColor=i,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].borderColor=i,t.emit("patch",{schema:r}),t.refresh()}})})]})}}},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]});class SchemaSettingsPlugin extends Plugin{load(){return q(this,null,function*(){this.schemaSettingsManager.add(tableBlockSettings),this.schemaSettingsManager.add(createFormBlockSettings),this.schemaSettingsManager.add(editFormBlockSettings),this.schemaSettingsManager.add(filterFormBlockSettings),this.schemaSettingsManager.add(filterFormItemFieldSettings),this.schemaSettingsManager.add(multiDataDetailsBlockSettings),this.schemaSettingsManager.add(detailsWithPaginationSettings),this.schemaSettingsManager.add(singleDataDetailsBlockSettings),this.schemaSettingsManager.add(detailsBlockSettings),this.schemaSettingsManager.add(tableSelectorBlockSettings),this.schemaSettingsManager.add(listBlockSettings),this.schemaSettingsManager.add(gridCardBlockSettings),this.schemaSettingsManager.add(filterCollapseBlockSettings),this.schemaSettingsManager.add(markdownBlockSettings),this.schemaSettingsManager.add(addNewActionSettings),this.schemaSettingsManager.add(filterActionSettings),this.schemaSettingsManager.add(refreshActionSettings),this.schemaSettingsManager.add(viewActionSettings),this.schemaSettingsManager.add(editActionSettings),this.schemaSettingsManager.add(deleteActionSettings),this.schemaSettingsManager.add(disassociateActionSettings),this.schemaSettingsManager.add(associateActionSettings),this.schemaSettingsManager.add(bulkDeleteActionSettings),this.schemaSettingsManager.add(customizeAddRecordActionSettings),this.schemaSettingsManager.add(customizePopupActionSettings),this.schemaSettingsManager.add(customizeLinkActionSettings),this.schemaSettingsManager.add(customizeUpdateRecordActionSettings),this.schemaSettingsManager.add(createSubmitActionSettings),this.schemaSettingsManager.add(updateSubmitActionSettings),this.schemaSettingsManager.add(submitActionSettings),this.schemaSettingsManager.add(customizeSaveRecordActionSettings),this.schemaSettingsManager.add(addChildActionSettings),this.schemaSettingsManager.add(expendableActionSettings),this.schemaSettingsManager.add(fieldSettingsFormItem),this.schemaSettingsManager.add(tableColumnSettings),this.schemaSettingsManager.add(filterCollapseItemFieldSettings),this.schemaSettingsManager.add(selectComponentFieldSettings),this.schemaSettingsManager.add(filterSelectComponentFieldSettings),this.schemaSettingsManager.add(recordPickerComponentFieldSettings),this.schemaSettingsManager.add(subformComponentFieldSettings),this.schemaSettingsManager.add(subformPopoverComponentFieldSettings),this.schemaSettingsManager.add(subTablePopoverComponentFieldSettings),this.schemaSettingsManager.add(datePickerComponentFieldSettings),this.schemaSettingsManager.add(rangePickerPickerComponentFieldSettings),this.schemaSettingsManager.add(unixTimestampComponentFieldSettings),this.schemaSettingsManager.add(inputNumberComponentFieldSettings),this.schemaSettingsManager.add(inputComponentSettings),this.schemaSettingsManager.add(inputURLSettings),this.schemaSettingsManager.add(inputTextAreaSettings),this.schemaSettingsManager.add(inputJSONSettings),this.schemaSettingsManager.add(markdownSettings),this.schemaSettingsManager.add(markdownVditorSettings),this.schemaSettingsManager.add(richTextSettings),this.schemaSettingsManager.add(fileManagerComponentFieldSettings),this.schemaSettingsManager.add(tagComponentFieldSettings),this.schemaSettingsManager.add(cascadeSelectComponentFieldSettings),this.schemaSettingsManager.add(inputPreviewComponentFieldSettings),this.schemaSettingsManager.add(uploadAttachmentComponentFieldSettings),this.schemaSettingsManager.add(previewComponentFieldSettings),this.schemaSettingsManager.add(dividerSettings)})}}const useBuiltInVariables=()=>{const{currentUserCtx:e}=useCurrentUserVariable(),{currentRoleCtx:t}=useCurrentRoleVariable(),{apiTokenCtx:o}=useAPITokenVariable(),{datetimeCtx:r}=useDatetimeVariable(),{urlSearchParamsCtx:i,name:n,defaultValue:a}=useURLSearchParamsVariable();return{builtinVariables:(0,import_react2.useMemo)(()=>[{name:"$user",ctx:e,collectionName:"users",dataSource:DEFAULT_DATA_SOURCE_KEY},{name:"$nRole",ctx:t,collectionName:"roles"},{name:"$nToken",ctx:o},{name:"currentUser",ctx:e,collectionName:"users",dataSource:DEFAULT_DATA_SOURCE_KEY},{name:"$nDate",ctx:r},{name:"$date",ctx:r},{name:"$system",ctx:{now:()=>(0,import_client.dayjs)().toISOString()}},{name:"currentTime",ctx:()=>(0,import_client.dayjs)().toISOString()},{name:n,ctx:i,defaultValue:a}],[t,e,r,a,i,n])}},filterEmptyValues=e=>Array.isArray(e)?e.filter(t=>t===0||t===!1||t):e,TYPE_TO_ACTION={hasMany:"list?pageSize=9999",belongsTo:"get",hasOne:"get",belongsToMany:"list?pageSize=9999",belongsToArray:"get"},getAction=e=>TYPE_TO_ACTION[e],requested={},hasRequested=e=>!!requested[e],getRequested=e=>requested[e],stashRequested=(e,t)=>{requested[e]=t},clearRequested=e=>{delete requested[e]},uniq=e=>!Array.isArray(e)||!import_lodash.default.isObject(e[0])?e:import_lodash.default.uniqBy(e,t=>"id"in t?t.id:JSON.stringify(t)),VariablesContext=(0,import_react2.createContext)(null);VariablesContext.displayName="VariablesContext";const variablesStore={},getFieldPath=(e,t)=>{let o,r;return{fieldPath:e.split(".").map(i=>t[i]?(o=t[i].dataSource,r=t[i],t[i].collectionName):i).join("."),dataSource:o,variableOption:r}},VariablesProvider=({children:e,filterVariables:t})=>{const o=(0,import_react2.useRef)({}),r=useAPIClient(),{getCollectionJoinField:i,getCollection:n}=useCollectionManager_deprecated(),a=useCompile(),{builtinVariables:l}=useBuiltInVariables(),c=(0,import_react2.useCallback)(_=>{import_lodash.default.isFunction(_)?o.current=_(o.current):o.current=_},[]),u=(0,import_react2.useCallback)((_,v,S)=>q(void 0,null,function*(){var C,b;const y=_.split("."),F=y[0],j=mergeVariableToCollectionNameWithLocalVariables(variablesStore,v);let k=mergeCtxWithLocalVariables(o.current,v);const{fieldPath:T,dataSource:O,variableOption:N}=getFieldPath(F,j);let L=T;const{fieldPath:D}=getFieldPath(_,j),R=y.length===1?N==null?void 0:N.collectionName:(C=i(D,O))==null?void 0:C.target;if(!(F in k))throw new Error(`VariablesProvider: ${F} is not found`);for(let w=0;w<y.length;w++){if(k==null)return{value:k===void 0?N==null?void 0:N.defaultValue:k,dataSource:O,collectionName:R};const I=y[w],{fieldPath:M}=getFieldPath(y.slice(0,w+1).join("."),j),B=i(M,O),z=(b=n(L,O))==null?void 0:b.getPrimaryKey();if(Array.isArray(k)){const E=k.map(V=>{if(!(S!=null&&S.doNotRequest)&&shouldToRequest(V==null?void 0:V[I])&&(V==null?void 0:V[z])!=null&&B!=null&&B.target){const U=`/${L}/${V[B.sourceKey||z]}/${I}:${getAction(B.type)}`;if(hasRequested(U))return getRequested(U);const G=r.request({headers:getDataSourceHeaders(O),url:U,params:{appends:S==null?void 0:S.appends}}).then(W=>(clearRequested(U),V[I]=W.data.data,V[I]));return stashRequested(U,G),G}return V==null?void 0:V[I]});k=removeThroughCollectionFields(import_lodash.default.flatten(yield Promise.all(E)),B)}else if(!(S!=null&&S.doNotRequest)&&shouldToRequest(k[I])&&k[z]!=null&&B!=null&&B.target){const E=`/${L}/${k[B.sourceKey||z]}/${I}:${getAction(B.type)}`;let V=null;if(hasRequested(E))V=yield getRequested(E);else{const U=r.request({headers:getDataSourceHeaders(O),url:E,params:{appends:S==null?void 0:S.appends}});stashRequested(E,U),V=yield U,clearRequested(E)}(0,import_reactive.raw)(k)[I]||((0,import_reactive.raw)(k)[I]=V.data.data),k=removeThroughCollectionFields((0,import_client.getValuesByPath)(k,I),B)}else k=removeThroughCollectionFields((0,import_client.getValuesByPath)(k,I),B);B!=null&&B.target&&(L=B.target)}const $=a(import_lodash.default.isFunction(k)?k({fieldOperator:S==null?void 0:S.fieldOperator,isParsingVariable:!0}):k);return{value:$===void 0?N.defaultValue:$,dataSource:O,collectionName:R}}),[i]),m=(0,import_react2.useCallback)(_=>{if(!isVariable(`{{${_.name}}}`))throw new Error(`VariablesProvider: ${_.name} is not a valid name`);c(v=>P(x({},v),{[_.name]:_.ctx})),variablesStore[_.name]=P(x({},_),{defaultValue:import_lodash.default.has(_,"defaultValue")?_.defaultValue:null})},[c]),d=(0,import_react2.useCallback)(_=>o.current[_]?x({},variablesStore[_]):null,[]),p=(0,import_react2.useCallback)(_=>{c(v=>{const S=x({},v);return delete S[_],S}),delete variablesStore[_]},[c]),g=(0,import_react2.useCallback)((_,v,S)=>q(void 0,null,function*(){if(!isVariable(_))return _;v&&(v=import_lodash.default.isArray(v)?v:[v]);const C=getPath(_),b=yield u(C,v,S);return P(x({},b),{value:uniq(filterEmptyValues(b.value))})}),[u]),h=(0,import_react2.useCallback)((_,v)=>q(void 0,null,function*(){var S;if(!isVariable(_))throw new Error(`VariablesProvider: ${_} is not a variable string`);v&&(v=import_lodash.default.isArray(v)?v:[v]);const C=mergeVariableToCollectionNameWithLocalVariables(variablesStore,v),b=getPath(_),{fieldPath:y,dataSource:F}=getFieldPath(b,C);let j=i(y,F);return!j&&!b.includes(".")&&(j={target:(S=C[b])==null?void 0:S.collectionName}),j}),[i]);(0,import_react2.useEffect)(()=>{l.forEach(_=>{m(P(x({},_),{defaultValue:import_lodash.default.has(_,"defaultValue")?_.defaultValue:null}))})},[l,m]);const f=(0,import_react2.useMemo)(()=>({ctxRef:o,setCtx:c,parseVariable:g,registerVariable:m,getVariable:d,getCollectionField:h,removeVariable:p,filterVariables:t}),[h,d,g,m,p,c]);return(0,import_jsx_runtime.jsx)(VariablesContext.Provider,{value:f,children:e})};VariablesProvider.displayName="VariablesProvider";const VariablesProvider$1=VariablesProvider;function shouldToRequest(e){let t=!1;return(0,import_reactive.untracked)(()=>{if(JSON.stringify(e)==="[{}]"||JSON.stringify(e)==="{}"){t=!0;return}t=import_lodash.default.isEmpty(e)}),t}function mergeCtxWithLocalVariables(e,t){return e=x({},e),t==null||t.forEach(o=>{e[o.name]=o.ctx}),e}function mergeVariableToCollectionNameWithLocalVariables(e,t){return e=x({},e),t==null||t.forEach(o=>{e[o.name]=P(x({},o),{defaultValue:import_lodash.default.has(o,"defaultValue")?o.defaultValue:null})}),e}function removeThroughCollectionFields(e,t){return!(t!=null&&t.through)||!e?e:Array.isArray(e)?e.map(o=>import_lodash.default.omit(o,t.through)):import_lodash.default.omit(e,t.through)}const mergeChildren=(e,t)=>{if(!(!e&&!t)&&!(0,import_shared.isFn)(e))return(0,import_jsx_runtime.jsxs)(import_react2.Fragment,{children:[e,t]})},isValidComponent=e=>e&&(typeof e=="object"||typeof e=="function"),renderChildren=(e,t,o)=>(0,import_shared.isFn)(e)?e(t,o):e,NocoBaseReactiveInternal=e=>{var t;const o=(0,import_react2.useContext)(import_react.SchemaComponentsContext),r=e.field,i=mergeChildren(renderChildren(e.children,r,r.form),(t=r.content)!=null?t:r.componentProps.children);if(r.display!=="visible")return null;const n=a=>{var l;return isValidComponent(a)?a:(l=import_shared.FormPath.getIn(o,a))!=null?l:a};return(a=>r.decoratorType?import_react2.default.createElement(n(r.decoratorType),r.decoratorProps,a):(0,import_jsx_runtime.jsx)(import_react2.Fragment,{children:a}))(r.componentType?import_react2.default.createElement(n(r.componentType),P(x({},r.componentProps),{value:r.value}),i):i)};NocoBaseReactiveInternal.displayName="NocoBaseReactiveInternal";const NocoBaseReactiveField=NocoBaseReactiveInternal;NocoBaseReactiveField.displayName="NocoBaseReactiveField";function createNocoBaseField(e){return new NocoBaseField$1(e)}let NocoBaseField$1=class{constructor(e){A(this,"props"),A(this,"initialized"),A(this,"loading"),A(this,"validating"),A(this,"submitting"),A(this,"selfModified"),A(this,"active"),A(this,"visited"),A(this,"mounted"),A(this,"unmounted"),A(this,"inputValues"),A(this,"inputValue"),A(this,"feedbacks"),A(this,"title"),A(this,"description"),A(this,"display"),A(this,"pattern"),A(this,"editable"),A(this,"disabled"),A(this,"readOnly"),A(this,"readPretty"),A(this,"visible"),A(this,"hidden"),A(this,"dataSource"),A(this,"validator"),A(this,"required"),A(this,"content"),A(this,"initialValue"),A(this,"value"),A(this,"data"),A(this,"decorator"),A(this,"component"),A(this,"decoratorProps"),A(this,"componentProps"),A(this,"decoratorType"),A(this,"componentType"),A(this,"path"),A(this,"form"),A(this,"address"),this.props=e,this.initialize()}initialize(){var e,t,o,r,i,n,a,l,c,u,m,d,p,g,h,f,_,v,S,C;const b=this.props.compile;this.pattern="readPretty",this.readPretty=!0,this.initialized=!0,this.loading=!1,this.validating=!1,this.submitting=!1,this.selfModified=!1,this.active=!1,this.visited=!0,this.mounted=!0,this.unmounted=!1,this.inputValues=[],this.inputValue=null,this.feedbacks=[],this.title=b(this.props.title||((e=this.props.schema)==null?void 0:e.title)),this.description=b(this.props.description||((t=this.props.schema)==null?void 0:t.description)),this.display="visible",this.editable=this.props.editable||((o=this.props.schema)==null?void 0:o["x-editable"]),this.disabled=this.props.disabled||((r=this.props.schema)==null?void 0:r["x-disabled"]),this.readOnly=this.props.readOnly||((i=this.props.schema)==null?void 0:i["x-read-only"]),this.visible=this.props.visible||((n=this.props.schema)==null?void 0:n["x-visible"]),this.hidden=this.props.hidden||((a=this.props.schema)==null?void 0:a["x-hidden"]),this.dataSource=b(this.props.dataSource||((l=this.props.schema)==null?void 0:l.enum)),this.validator=this.props.validator,this.required=this.props.required||!!((c=this.props.schema)!=null&&c.required),this.content=b(this.props.content||((u=this.props.schema)==null?void 0:u["x-content"])),this.initialValue=b(this.props.initialValue||((m=this.props.schema)==null?void 0:m.default)),this.value=b(this.props.value),this.data=this.props.data||((d=this.props.schema)==null?void 0:d["x-data"]),this.decorator=this.props.decorator?(0,import_shared.toArr)(this.props.decorator):[(p=this.props.schema)==null?void 0:p["x-decorator"],(g=this.props.schema)==null?void 0:g["x-decorator-props"]],this.component=this.props.component?(0,import_shared.toArr)(this.props.component):[(h=this.props.schema)==null?void 0:h["x-component"],(f=this.props.schema)==null?void 0:f["x-component-props"]],this.decoratorProps=((_=this.props.schema)==null?void 0:_["x-decorator-props"])||{},this.componentProps=((v=this.props.schema)==null?void 0:v["x-component-props"])||{},this.decoratorType=(S=this.props.schema)==null?void 0:S["x-decorator"],this.componentType=(C=this.props.schema)==null?void 0:C["x-component"],this.path={},this.form={},this.address={concat:import_lodash.default.noop}}};const NocoBaseField=e=>{const t=useCompile(),o=(0,import_react.useFieldSchema)(),r=(0,import_react2.useMemo)(()=>createNocoBaseField(P(x({},e),{compile:t})),[]);return Object.assign(r.componentProps,o["x-component-props"]),r.value=e.value,(0,import_jsx_runtime.jsx)(import_react.FieldContext.Provider,{value:r,children:(0,import_jsx_runtime.jsx)(NocoBaseReactiveField,{field:r,children:e.children})})},CollectionFieldUISchemaContext=import_react2.default.createContext({}),RefreshFieldSchemaContext=import_react2.default.createContext(import_lodash.default.noop),RefreshFieldSchemaProvider=({children:e,refresh:t})=>{const o=useRefreshFieldSchema(),r=(0,import_react2.useCallback)(i=>{t(),i!=null&&i.refreshParentSchema&&(o==null||o())},[o,t]);return(0,import_jsx_runtime.jsx)(RefreshFieldSchemaContext.Provider,{value:r,children:e})},RefreshComponentContext=import_react2.default.createContext(import_lodash.default.noop),RefreshComponentProvider=({children:e,refresh:t})=>(0,import_jsx_runtime.jsx)(RefreshComponentContext.Provider,{value:t,children:e}),useRefreshComponent=()=>import_react2.default.useContext(RefreshComponentContext),useRefreshFieldSchema=()=>import_react2.default.useContext(RefreshFieldSchemaContext),useCollectionFieldUISchema=()=>import_react2.default.useContext(CollectionFieldUISchemaContext)||{},CollectionFieldUISchemaProvider=e=>{const{children:t,fieldSchema:o}=e,r=useCollection(),i=useCollectionManager(),n=o==null?void 0:o.name,a=(0,import_react2.useMemo)(()=>{var l;if(!r)return null;const c=(l=o==null?void 0:o["x-component-props"])==null?void 0:l.field;return i.getCollectionField(o==null?void 0:o["x-collection-field"])||c||r.getField((c==null?void 0:c.name)||n)},[r,i,o,n]);return(0,import_jsx_runtime.jsx)(CollectionFieldUISchemaContext.Provider,{value:a,children:t})},toFieldProps=import_lodash.default.memoize((e,t)=>e.toFieldProps({scope:t})),useFieldProps$1=e=>{const t=(0,import_react.useExpressionScope)();return toFieldProps(e,t)},useBasePath=e=>{var t;const o=(0,import_react.useField)();return e.onlyRenderProperties?e.basePath||((t=o==null?void 0:o.address)==null?void 0:t.concat(e.name)):e.basePath||(o==null?void 0:o.address)},createMergedSchemaInstance=(e,t,o)=>{const r=e.toJSON();if(o){if(!r.properties)return e;const i=Object.keys(r.properties)[0],n=Object.values(r.properties)[0];return r.properties[i]=(0,import_shared.merge)(import_lodash.default.omit(t,"type","x-read-pretty"),n),new import_react.Schema(r)}return new import_react.Schema((0,import_shared.merge)(import_lodash.default.omit(t,"type","x-read-pretty"),r))},propertiesToReactElement=({schema:e,field:t,basePath:o,mapProperties:r,filterProperties:i,propsRecursion:n,values:a,isUseFormilyField:l})=>{const c=import_react.Schema.getOrderProperties(e);return c.length?(0,import_jsx_runtime.jsx)(import_react2.Fragment,{children:c.map(({schema:u,key:m},d)=>{const p=(t==null?void 0:t.address)||o;let g=u;if((0,import_shared.isFn)(r)){const f=r(u,m);f&&(g=f)}if((0,import_shared.isFn)(i)&&i(g,m)===!1)return null;const h=(0,import_shared.isBool)(n)&&n?(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{propsRecursion:!0,filterProperties:i,mapProperties:r,schema:g,name:m,basePath:p,values:import_lodash.default.get(a,m),isUseFormilyField:l}):(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{schema:g,name:m,basePath:p,values:import_lodash.default.get(a,m),isUseFormilyField:l});return g["x-component"]==="CollectionField"?(0,import_jsx_runtime.jsx)(IsInNocoBaseRecursionFieldContext.Provider,{value:!0,children:(0,import_jsx_runtime.jsx)(CollectionFieldUISchemaProvider,{fieldSchema:g,children:h})},`${d}-${m}`):(0,import_jsx_runtime.jsx)(IsInNocoBaseRecursionFieldContext.Provider,{value:!1,children:(0,import_jsx_runtime.jsx)(CollectionFieldUISchemaContext.Provider,{value:EMPTY_OBJECT,children:h})},`${d}-${m}`)})}):null},IsInNocoBaseRecursionFieldContext=import_react2.default.createContext(!1),useIsInNocoBaseRecursionFieldContext=()=>import_react2.default.useContext(IsInNocoBaseRecursionFieldContext),NocoBaseRecursionField=import_react2.default.memo(e=>{const{schema:t,name:o,onlyRenderProperties:r,onlyRenderSelf:i,mapProperties:n,filterProperties:a,propsRecursion:l,values:c,isUseFormilyField:u=!0,uiSchema:m}=e,d=useBasePath(e),p=(0,import_react2.useRef)(null),g=(0,import_react2.useMemo)(()=>(p.current=null,new import_react.Schema(t)),[t]),{uiSchema:h,defaultValue:f}=useCollectionFieldUISchema(),_=(0,import_ahooks.useUpdate)(),{onChange:v}=(0,import_react2.useContext)(SchemaComponentOnChangeContext),S=p.current||g,C=(0,import_react2.useCallback)(()=>{const k=S.parent;p.current=new import_react.Schema(S.toJSON(),k),k!=null&&k.properties&&Object.keys(k.properties).forEach(T=>{T===S.name&&(k.properties[T]=p.current)}),_(),v==null||v()},[S,v,_]),b=(0,import_react2.useMemo)(()=>m?createMergedSchemaInstance(S,m,r):h?(h.default=f,createMergedSchemaInstance(S,h,r)):S,[h,f,S,r,m]),y=useFieldProps$1(b),F=k=>{if(!i)return propertiesToReactElement({schema:S,field:k,basePath:d,mapProperties:n,filterProperties:a,propsRecursion:l,values:c,isUseFormilyField:u})},j=()=>(0,import_shared.isValid)(o)?b.type==="object"?r?F():(0,import_jsx_runtime.jsx)(import_react.ObjectField,P(x({},y),{name:o,basePath:d,children:F})):b.type==="array"?(0,import_jsx_runtime.jsx)(import_react.ArrayField,P(x({},y),{name:o,basePath:d})):b.type==="void"?r?F():(0,import_jsx_runtime.jsx)(import_react.VoidField,P(x({},y),{name:o,basePath:d,children:F})):u?(0,import_jsx_runtime.jsx)(import_react.Field,P(x({},y),{name:o,basePath:d})):(0,import_jsx_runtime.jsx)(NocoBaseField,{name:o,value:c,initialValue:c,basePath:d,schema:b}):F();return S?(0,import_jsx_runtime.jsx)(import_react.SchemaContext.Provider,{value:S,children:(0,import_jsx_runtime.jsx)(RefreshFieldSchemaProvider,{refresh:C,children:j()})}):(0,import_jsx_runtime.jsx)(import_react2.Fragment,{})});NocoBaseRecursionField.displayName="NocoBaseRecursionField";const LAZY_COMPONENT_KEY=Symbol("LAZY_COMPONENT_KEY");function lazy(e,...t){if(t.length===0){const o=(0,import_react2.lazy)(()=>e().then(i=>{const n=i.default;return r[LAZY_COMPONENT_KEY]=n,{default:n}})),r=i=>(0,import_jsx_runtime.jsx)(import_react2.default.Suspense,{fallback:(0,import_jsx_runtime.jsx)(import_antd.Spin,{}),children:(0,import_jsx_runtime.jsx)(o,x({},i))});return r}return t.reduce((o,r)=>{const i=(0,import_react2.lazy)(()=>e().then(n=>{const a=(0,import_lodash.get)(n,r);return o[r][LAZY_COMPONENT_KEY]=a,{default:a}}));return o[r]=n=>(0,import_jsx_runtime.jsx)(import_react2.default.Suspense,{fallback:(0,import_jsx_runtime.jsx)(import_antd.Spin,{}),children:(0,import_jsx_runtime.jsx)(i,x({},n))}),o},{})}function useLazy(e,t){const o=typeof t=="function"?t:i=>i[t],r=(0,import_react_imported_component.loadableResource)(e);if(!r.payload)throw new Promise((i,n)=>{r.loadIfNeeded(),r.resolution.then(i).catch(n)});return o(r.payload)}function addAppVersion(e,t){if(e)return e["x-app-version"]||(e["x-app-version"]=t),Object.keys(e.properties||{}).forEach(o=>{var r;addAppVersion((r=e.properties)==null?void 0:r[o],t)}),e}const name="@nocobase/client",version="1.5.2",license="AGPL-3.0",main="lib/index.js",module$1="es/index.mjs",types="es/index.d.ts",dependencies={"@ahooksjs/use-url-state":"3.5.1","@ant-design/cssinjs":"^1.11.1","@ant-design/icons":"^5.1.4","@ant-design/pro-layout":"^7.16.11","@antv/g2plot":"^2.4.18","@budibase/handlebars-helpers":"^0.14.0","@ctrl/tinycolor":"^3.6.0","@dnd-kit/core":"^5.0.1","@dnd-kit/modifiers":"^6.0.0","@dnd-kit/sortable":"^6.0.0","@emotion/css":"^11.7.1","@formily/antd-v5":"1.1.9","@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":"1.5.2","@nocobase/sdk":"1.5.2","@nocobase/utils":"1.5.2",ahooks:"^3.7.2",antd:"5.12.8","antd-style":"3.7.1",axios:"^1.7.0","bignumber.js":"^9.1.2",classnames:"^2.3.1",cronstrue:"^2.11.0","file-saver":"^2.0.5",filesize:"9.0.11",flat:"^5.0.2",i18next:"^22.4.9","i18next-http-backend":"^2.1.1",json5:"^2.2.3",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-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.11.2","react-to-print":"^2.14.7","sanitize-html":"2.13.0","use-deep-compare-effect":"^1.8.1"},peerDependencies={react:">=18.0.0","react-dom":">=18.0.0","react-is":">=18.0.0"},devDependencies={"@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.28"},clientPkg={name,version,license,main,module:module$1,types,dependencies,peerDependencies,devDependencies};function createDesignable(e){return new Designable(e)}const generateUid=e=>{e&&(e["x-uid"]||(e["x-uid"]=(0,import_shared.uid)()),Object.keys(e.properties||{}).forEach(t=>{generateUid(e.properties[t])}))},defaultWrap=e=>e,matchSchema=(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}},splitWrapSchema=(e,t)=>{if(e["x-uid"]&&e["x-uid"]===t["x-uid"])return[null,e.toJSON()];const o=e.toJSON(),r=P(x({},o),{properties:{}});let i=null;const n=(a,l)=>{Object.keys(a||{}).forEach(c=>{const u=a[c];if(u["x-uid"]===t["x-uid"]){i=a[c];return}else l.properties[c]=P(x({},u),{properties:{}}),n(u==null?void 0:u.properties,l.properties[c])})};return n(o.properties,r),[r,i]},translate=e=>e;class Designable{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=translate}=this.options;if(!t)return;const r=i=>{if(!i)return[];const n=Object.values(i.properties).length,a=[];return i.mapProperties(l=>{l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].width=100/n,l["x-uid"]&&a.push({"x-uid":l["x-uid"],"x-component-props":l["x-component-props"]})}),i["x-uid"]&&a.length?a:[]};this.on("insertAdjacent",i=>q(this,[i],function*({onSuccess:n,current:a,position:l,schema:c,wrap:u,wrapped:m,removed:d}){var p;let g=[];if((m==null?void 0:m["x-component"])==="Grid.Col"&&(g=g.concat(r(m.parent))),(d==null?void 0:d["x-component"])==="Grid.Col"&&(g=g.concat(r(d.parent))),this.refresh(),!a["x-uid"])return;const h=yield t.request({url:`/uiSchemas:insertAdjacent/${a["x-uid"]}?position=${l}`,method:"post",data:{schema:addAppVersion(c,this.appVersion),wrap:u}});g.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:g})),d!=null&&d["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${d["x-uid"]}`,method:"post"})),n==null||n((p=h==null?void 0:h.data)==null?void 0:p.data),import_antd.message.success(o("Saved successfully"),.2)})),this.on("patch",i=>q(this,[i],function*({schema:n}){this.refresh(),n!=null&&n["x-uid"]&&(yield t.request({url:"/uiSchemas:patch",method:"post",data:x({},n)}),import_antd.message.success(o("Saved successfully"),.2))})),this.on("initializeActionContext",i=>q(this,[i],function*({schema:n}){n!=null&&n["x-uid"]&&(yield t.request({url:"/uiSchemas:initializeActionContext",method:"post",data:x({},n)}))})),this.on("batchPatch",i=>q(this,[i],function*({schemas:n}){this.refresh(),yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:n}),import_antd.message.success(o("Saved successfully"),.2)})),this.on("remove",i=>q(this,[i],function*({removed:n}){let a=[];(n==null?void 0:n["x-component"])==="Grid.Col"&&(a=r(n.parent)),this.refresh(),n!=null&&n["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${n["x-uid"]}`,method:"post"}),a.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:a})),import_antd.message.success(o("Saved successfully"),.2))}))}prepareProperty(t){t.type||(t.type="void"),t.name||(t.name=(0,import_shared.uid)()),this.current["x-uid"]&&generateUid(t)}on(t,o){this.events[t]||(this.events[t]=[]),this.events[t].push(o)}emit(t,...o){return q(this,null,function*(){if(!this.events[t])return;const[r,...i]=o;return Promise.all(this.events[t].map(n=>n.bind(this)(x({current:this.current},r),...i)))})}parentsIn(t){if(!t||!import_react.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"},r={"x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(t).forEach(i=>{o[i]?(this.current[i]=t[i],this.updateModel(o[i],t[i])):r[i]?Object.keys(t[i]).forEach(n=>{(0,import_set.default)(this.current,[i,n],t[i][n]),this.updateModel([r[i],n],t[i][n])}):this.current[i]=t[i]}),this.emit("patch",{schema:t})}getSchemaAttribute(t,o){return(0,import_get.default)(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(r=>{this.current[r]=t[r],o[r]&&this.updateModel(o[r],t[r])}),this.emit("patch",{schema:t})}updateModel(t,o){const r=i=>{(0,import_set.default)(i,t,o)};this.model&&r(this.model),this.query&&this.query.take(r)}insertAdjacent(t,o,r={}){switch(t){case"beforeBegin":return this.insertBeforeBegin(o,r);case"afterBegin":return this.insertAfterBegin(o,r);case"beforeEnd":return this.insertBeforeEnd(o,r);case"afterEnd":return this.insertAfterEnd(o,r)}}recursiveRemoveIfNoChildren(t,o){if(!t)return;let r=t,i;const n=o==null?void 0:o.breakRemoveOn;for(;r;){if(typeof n=="function"){if(n(r))break}else if(matchSchema(r,n))break;if(Object.keys(r.properties||{}).length>0)break;r.parent&&(i=r.parent.removeProperty(r.name)),r=r.parent}return i}remove(t,o={}){const{breakRemoveOn:r,removeParentsIfNoChildren:i}=o,n=t||this.current;let a=n.parent.removeProperty(n.name);if(i){const l=this.recursiveRemoveIfNoChildren(n.parent,{breakRemoveOn:r});l&&(a=l)}return this.emit("remove",{removed:a})}removeWithoutEmit(t,o={}){const{breakRemoveOn:r,removeParentsIfNoChildren:i}=o,n=t||this.current;let a=n.parent.removeProperty(n.name);if(i){const l=this.recursiveRemoveIfNoChildren(n.parent,{breakRemoveOn:r});l&&(a=l)}return a}insertBeforeBeginOrAfterEnd(t,o={}){if(!import_react.Schema.isSchemaInstance(this.current)||!import_react.Schema.isSchemaInstance(t)||this.current.parent!==t.parent)return;let r=0,i=0;return this.current.parent.mapProperties((n,a,l)=>{this.current.name===a&&(i=l),t.name===a&&(r=l)}),r>i?this.insertBeforeBegin(t,o):this.insertAfterEnd(t,o)}insertBeforeBegin(t,o={}){if(!import_react.Schema.isSchemaInstance(this.current))return;const r={onSuccess:o.onSuccess},{wrap:i=defaultWrap,breakRemoveOn:n,removeParentsIfNoChildren:a}=o;if(import_react.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),a&&(r.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:n}))}else t&&(t=(0,import_cloneDeep.default)(t));const l={};let c=!1,u=0,m=0;this.current.parent.mapProperties((f,_)=>{_===this.current.name&&(m=u,c=!0,++u),f["x-index"]=u,++u,c&&(l[_]=f,this.current.parent.removeProperty(_))}),this.prepareProperty(t);const d=i(t),p=this.current.parent.addProperty(d.name||(0,import_shared.uid)(),d);p["x-index"]=m,p.parent=this.current.parent,this.current.parent.setProperties(l);const[g,h]=splitWrapSchema(p,t);this.emit("insertAdjacent",x({position:"beforeBegin",schema:h,wrapped:d,wrap:g},r))}insertAfterBegin(t,o={}){if(!import_react.Schema.isSchemaInstance(this.current))return;const r={onSuccess:o.onSuccess},{wrap:i=defaultWrap,breakRemoveOn:n,removeParentsIfNoChildren:a}=o;if(import_react.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),a&&(r.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:n}))}else t&&(t=(0,import_cloneDeep.default)(t));const l={};let c=1;this.current.mapProperties((g,h)=>{g["x-index"]=c,++c,l[h]=g}),this.current.properties={},this.prepareProperty(t);const u=i(t),m=this.current.addProperty(u.name||(0,import_shared.uid)(),u);m["x-index"]=0,m.parent=this.current,this.current.setProperties(l);const[d,p]=splitWrapSchema(m,t);this.emit("insertAdjacent",x({position:"afterBegin",schema:p,wrap:d,wrapped:u},r))}insertBeforeEnd(t,o={}){if(!import_react.Schema.isSchemaInstance(this.current))return;delete t["x-index"];const r={onSuccess:o.onSuccess},{wrap:i=defaultWrap,breakRemoveOn:n,removeParentsIfNoChildren:a}=o;if(import_react.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),a&&(r.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:n}))}else t&&(t=(0,import_cloneDeep.default)(t));this.prepareProperty(t);const l=i(t),c=this.current.addProperty(l.name||(0,import_shared.uid)(),l);c.parent=this.current;const[u,m]=splitWrapSchema(c,t);return this.emit("insertAdjacent",x({position:"beforeEnd",schema:m,wrap:u,wrapped:l},r))}insertAfterEnd(t,o={}){if(!import_react.Schema.isSchemaInstance(this.current))return;const r={onSuccess:o==null?void 0:o.onSuccess},{wrap:i=defaultWrap,breakRemoveOn:n,removeParentsIfNoChildren:a}=o;let l=0,c=0,u=!1;const m={};if(this.current.parent.mapProperties((f,_)=>{f["x-index"]=l,_===this.current.name&&(++l,c=l,u=!0),++l,u&&_!==this.current.name&&(m[_]=f,this.current.parent.removeProperty(_))}),import_react.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),a&&(r.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:n})),t.parent=null}else t&&(t=(0,import_cloneDeep.default)(t));this.prepareProperty(t);const d=i(t),p=this.current.parent.addProperty(d.name||(0,import_shared.uid)(),d);p.parent=this.current.parent,p["x-index"]=c,this.current.parent.setProperties(m);const[g,h]=splitWrapSchema(p,t);this.emit("insertAdjacent",x({position:"afterEnd",schema:h,wrap:g,wrapped:d},r))}}function useFindComponent(){const e=(0,import_react2.useContext)(import_react.SchemaOptionsContext),t=(0,import_react2.useMemo)(()=>(e==null?void 0:e.components)||{},[e]);return o=>{if(!o)return null;if(typeof o!="string")return o;const r=(0,import_get.default)(t,o);return r||console.error(`[nocobase]: Component "${o}" not found`),r}}function useDesignable(){const{designable:e,setDesignable:t,refresh:o,reset:r}=(0,import_react2.useContext)(SchemaComponentContext),i=(0,import_react2.useContext)(import_react.SchemaOptionsContext),n=(0,import_react2.useMemo)(()=>(i==null?void 0:i.components)||{},[i]),a=(0,import_react2.useMemo)(()=>()=>(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{}),[]),l=(0,import_ahooks.useUpdate)(),c=useRefreshFieldSchema(),u=useRefreshComponent(),m=(0,import_react2.useCallback)(_=>{o==null||o(),l(),c==null||c(_),u==null||u()},[o,l,c,u]),d=(0,import_react.useField)(),p=(0,import_react.useFieldSchema)(),g=useAPIClient(),{t:h}=(0,import_react_i18next.useTranslation)(),f=(0,import_react2.useMemo)(()=>createDesignable({t:h,api:g,refresh:m,current:p,model:d,appVersion:clientPkg.version}),[h,g,m,p,d]);return(0,import_react2.useEffect)(()=>{f.loadAPIClientEvents()},[f]),{dn:f,designable:e,reset:r,refresh:m,setDesignable:t,DesignableBar:a,findComponent:(0,import_react2.useCallback)(_=>{var v;if(!_)return null;if(typeof _!="string")return _;const S=(0,import_get.default)(n,_);return(v=S[LAZY_COMPONENT_KEY])!=null?v:S},[import_get.default]),on:f.on.bind(f),patch:(0,import_react2.useCallback)((_,v)=>{const S=C=>{Object.keys(C).forEach(b=>{const y=C[b];b==="title"&&(d.title=y,p.title=y),b==="x-decorator-props"&&(d.decoratorProps||(d.decoratorProps={}),p["x-decorator-props"]||(p["x-decorator-props"]={}),Object.keys(y).forEach(F=>{d.decoratorProps[F]=y[F],p["x-decorator-props"][F]=y[F]})),b==="x-component-props"&&(d.componentProps||(d.componentProps={}),p["x-component-props"]||(p["x-component-props"]={}),Object.keys(y).forEach(F=>{d.componentProps[F]=y[F],p["x-component-props"][F]=y[F]}))})};if(typeof _=="string"){const C={};return(0,import_set.default)(C,_,v),S(C)}S(_),m()},[f]),shallowMerge:(0,import_react2.useCallback)(_=>{f.shallowMerge(_)},[f]),deepMerge:(0,import_react2.useCallback)(_=>{f.deepMerge(_)},[f]),remove:(0,import_react2.useCallback)((_,v)=>{f.remove(_,v)},[f]),insertAdjacent:(0,import_react2.useCallback)((_,v,S)=>{f.insertAdjacent(_,v,S)},[f]),insertBeforeBegin:(0,import_react2.useCallback)(_=>{f.insertBeforeBegin(_)},[f]),insertAfterBegin:(0,import_react2.useCallback)(_=>{f.insertAfterBegin(_)},[f]),insertBeforeEnd:(0,import_react2.useCallback)(_=>{f.insertBeforeEnd(_)},[f]),insertAfterEnd:(0,import_react2.useCallback)(_=>{f.insertAfterEnd(_)},[f])}}const DefaultSchemaToolbar=()=>null;DefaultSchemaToolbar.isNullComponent=!0;const useDesigner=()=>{const{designable:e}=useDesignable(),t=(0,import_react.useFieldSchema)(),o=(0,import_react2.useMemo)(()=>t["x-designer"]||t["x-toolbar"]?t["x-designer"]||t["x-toolbar"]:t["x-settings"]?SchemaToolbar:DefaultSchemaToolbar,[t]),r=useComponent(o);return e&&r||DefaultSchemaToolbar},useFieldProps=e=>{const t=(0,import_react2.useContext)(import_react.SchemaOptionsContext),o=(0,import_react2.useContext)(import_react.SchemaExpressionScopeContext),r=(0,import_react2.useRef)();return r.current=o,e.toFieldProps(P(x({},t),{get scope(){return x(x({},t.scope),r.current)}}))};function useSchemaComponentContext(){return(0,import_react2.useContext)(SchemaComponentContext)}const useFieldComponentOptions=()=>{var e;const{getCollectionJoinField:t,getCollection:o}=useCollectionManager_deprecated(),r=(0,import_react.useFieldSchema)(),{getField:i}=useCollection_deprecated(),n=i(r.name)||t(r["x-collection-field"]),{t:a}=(0,import_react_i18next.useTranslation)(),{label:l}=((e=r["x-component-props"])==null?void 0:e.fieldNames)||{};return(0,import_react2.useMemo)(()=>{if(!n||!(n!=null&&n.interface)||!["o2o","oho","obo","o2m","linkTo","m2o","m2m"].includes(n.interface))return;const c=o(n.target);if((c==null?void 0:c.template)==="file")return[{label:a("Record picker"),value:"CollectionField"},{label:a("Select"),value:"AssociationSelect"}];switch(n.interface){case"o2m":return[{label:a("Record picker"),value:"CollectionField"},{label:a("Subtable"),value:"TableField"},{label:a("Select"),value:"AssociationSelect"}];case"m2o":case"m2m":case"linkTo":return[{label:a("Record picker"),value:"CollectionField"},{label:a("Select"),value:"AssociationSelect"}];default:return[{label:a("Record picker"),value:"CollectionField"},{label:a("Subform"),value:"FormField"},{label:a("Select"),value:"AssociationSelect"}]}},[a,n==null?void 0:n.interface,l])},useFieldTitle=()=>{var e;const t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),r=useCollection(),i=useCollectionManager(),n=(r==null?void 0:r.getField(o.name))||(i==null?void 0:i.getCollectionField(o["x-collection-field"])),a=useCompile();(0,import_react2.useEffect)(()=>{var l;t!=null&&t.title||(t.title=a((l=n==null?void 0:n.uiSchema)==null?void 0:l.title))},[(e=n==null?void 0:n.uiSchema)==null?void 0:e.title])},getPageHeaderHeight=(e,t,o,r,i)=>i.includes("/popups/")?2*r.paddingContentVertical+22+r.paddingPageVertical:e?r.paddingContentHorizontalLG:o?t?r.controlPaddingHorizontal+3*r.controlPaddingHorizontalSM+22+r.paddingContentHorizontalLG:r.paddingContentHorizontalLG+12:t?r.paddingSM+r.controlHeight+r.marginXS+2*r.controlPaddingHorizontalSM+22+r.paddingContentHorizontalLG:r.controlHeight+r.marginXS+(r.paddingXXS+2)*2+r.paddingContentHorizontalLG,usePageFullScreenHeight=e=>{const{token:t}=import_antd.theme.useToken(),{designable:o}=useDesignable(),{heightProps:r}=useBlockHeightProps(),i=(0,import_react_router_dom.useLocation)(),{disablePageHeader:n,enablePageTabs:a,hidePageTitle:l}=e||r||{},c=t.sizeXXL-2,u=o?t.controlHeight+2*t.paddingContentHorizontalLG:1*t.paddingContentHorizontalLG,m=getPageHeaderHeight(n,a,l,t,i.pathname);return c+m+u},useDrawerFullScreenHeight=()=>{const{token:e}=import_antd.theme.useToken(),{designable:t}=useDesignable(),o=e.paddingContentVerticalLG+e.margin+2*e.paddingContentVertical+24,r=t?e.controlHeight+2*e.paddingContentHorizontalLG:1*e.paddingContentHorizontalLG;return o+r},useFullScreenHeight=e=>{const t=(0,import_react.useFieldSchema)(),o=hasActionContainerInParentChain(t),r=usePageFullScreenHeight(e),i=useDrawerFullScreenHeight();return o?i:r},InternalWorkflowCollection=["users_jobs","approvals","approvalRecords"],useTableHeight=()=>{var e;const{token:t}=import_antd.theme.useToken(),{heightProps:o}=useBlockHeightProps(),{heightProps:r}=useTableBlockContext(),{designable:i}=useDesignable(),n=(0,import_react.useFieldSchema)(),a=r||o,l=useFullScreenHeight(a),{name:c}=useCollection(),{heightMode:u,height:m,title:d}=a;if(!(a!=null&&a.heightMode)||u===HeightMode.DEFAULT)return;const p=Object.keys(((e=n.parent.properties.actions)==null?void 0:e.properties)||{}).length>0,g=t.controlHeight+t.padding+t.marginLG,h=p||i?t.controlHeight+2*t.marginLG:t.marginLG,f=(i&&!InternalWorkflowCollection.includes(c)?t.controlHeight:22)+2*t.padding+1,_=d?t.fontSizeLG*t.lineHeightLG+t.padding*2-1:0;return u===HeightMode.FULL_HEIGHT?window.innerHeight-l-_-f-h-g:m-_-h-f-g},useDataBlockHeight=e=>{const{heightProps:t}=useBlockHeightProps(),o=useFullScreenHeight(),{token:r}=import_antd.theme.useToken(),{heightMode:i,height:n,title:a}=t||{},l=a?r.fontSizeLG*r.lineHeightLG+r.padding*2-1:0;if(!(!(t!=null&&t.heightMode)||i===HeightMode.DEFAULT)){if(i===HeightMode.FULL_HEIGHT){let c=window.innerHeight-o;return e!=null&&e.removeBlockHeaderHeight&&(c=c-l),e!=null&&e.innerExtraHeight&&(c=c-e.innerExtraHeight),c}return n}},useBlockHeight=()=>{const e=(0,import_react.useFieldSchema)(),t=(0,import_react2.useMemo)(()=>getPageSchema(e),[]),{disablePageHeader:o,enablePageTabs:r,hidePageTitle:i}=(t==null?void 0:t["x-component-props"])||{},n=P(x({},e==null?void 0:e["x-component-props"]),{disablePageHeader:o,enablePageTabs:r,hidePageTitle:i}),a=useFullScreenHeight(n),{heightMode:l,height:c}=n||{};if(!(!(n!=null&&n.heightMode)||l===HeightMode.DEFAULT))return l===HeightMode.FULL_HEIGHT?window.innerHeight-a:c},useTableSize=()=>{const[e,t]=(0,import_react2.useState)(),o=(0,import_react2.useRef)(null),r=useTableHeight(),i=(0,import_react2.useCallback)((0,import_lodash.debounce)(()=>{var a;if(!o.current)return;const l=o.current.getBoundingClientRect();(a=o.current.querySelector(".ant-table"))!=null&&a.getBoundingClientRect()&&t(l.width)},100),[r]),n=(0,import_react2.useCallback)(a=>{o.current=a&&a.children?a.children[0]:null,i()},[i]);return(0,import_ahooks.useEventListener)("resize",i),{height:r,width:e,tableSizeRefCallback:n}},hasActionContainerInParentChain=e=>{var t;return e?e["x-component"]==="Action.Container"?((t=e==null?void 0:e.parent["x-component-props"])==null?void 0:t.openMode)!=="page":hasActionContainerInParentChain(e.parent):null},useFieldModeOptions=e=>{var t;const{t:o}=(0,import_react_i18next.useTranslation)(),{getCollectionJoinField:r,getCollection:i}=useCollectionManager_deprecated(),n=(0,import_react.useFieldSchema)(),a=(e==null?void 0:e.fieldSchema)||n,l=(0,import_react.useField)(),c=(0,import_react.useForm)(),u=(a==null?void 0:a["x-read-pretty"])||l.readPretty||c.readPretty,m=e==null?void 0:e.fieldSchema,{getField:d}=useCollection_deprecated(),p=(e==null?void 0:e.collectionField)||d(a.name)||r(a["x-collection-field"]),{label:g}=((t=a["x-component-props"])==null?void 0:t.fieldNames)||{};return((0,import_react2.useMemo)(()=>{if(!p||!(p!=null&&p.interface)||!["o2o","oho","obo","o2m","linkTo","m2o","m2m","updatedBy","createdBy","mbm","attachmentURL"].includes(p.interface))return;const h=i(p.target);if((h==null?void 0:h.template)==="file")return u?[{label:o("Title"),value:"Select"},{label:o("File manager"),value:"FileManager"},{label:o("Tag"),value:"Tag"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},{label:o("File manager"),value:"FileManager"}];if((h==null?void 0:h.template)==="tree"&&["m2m","o2m","m2o"].includes(p.interface))return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!m&&{label:o("Sub-details"),value:"Nester"},!m&&{label:o("Sub-table"),value:"SubTable"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!m&&["m2m","o2m"].includes(p.interface)&&{label:o("Sub-table"),value:"SubTable"},!m&&{label:o("Cascade Select"),value:"CascadeSelect"},!m&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"}];switch(p.interface){case"o2m":return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!m&&{label:o("Sub-table"),value:"SubTable"},!m&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!m&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"},!m&&{label:o("Sub-table"),value:"SubTable"}];case"m2m":case"mbm":return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!m&&{label:o("Sub-details"),value:"Nester"},!m&&{label:o("Sub-table"),value:"SubTable"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!m&&{label:o("Sub-table"),value:"SubTable"},!m&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"}];case"m2o":case"linkTo":return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!m&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!m&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"}];default:return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!m&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!m&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"}]}},[o,p==null?void 0:p.interface,g])||[]).filter(Boolean)},useDragEnd=e=>{const{refresh:t}=useDesignable(),o=useAPIClient(),{t:r}=(0,import_react_i18next.useTranslation)();return(0,import_react2.useCallback)(i=>{var n,a,l,c,u,m,d,p,g,h,f,_,v,S,C;const{active:b,over:y}=i,F=(a=(n=b==null?void 0:b.data)==null?void 0:n.current)==null?void 0:a.schema,j=(c=(l=y==null?void 0:y.data)==null?void 0:l.current)==null?void 0:c.schema,k=(m=(u=y==null?void 0:y.data)==null?void 0:u.current)==null?void 0:m.insertAdjacent,T=(p=(d=y==null?void 0:y.data)==null?void 0:d.current)==null?void 0:p.breakRemoveOn,O=(h=(g=y==null?void 0:y.data)==null?void 0:g.current)==null?void 0:h.wrapSchema,N=(_=(f=y==null?void 0:y.data)==null?void 0:f.current)==null?void 0:_.onSuccess,L=(C=(S=(v=y==null?void 0:y.data)==null?void 0:v.current)==null?void 0:S.removeParentsIfNoChildren)!=null?C:!0;if(!F||!j){e==null||e(i);return}if(F===j){e==null||e(i);return}if(F.parent===j&&k==="beforeEnd"){e==null||e(i);return}const D=createDesignable({t:r,api:o,refresh:({refreshParentSchema:R=!0}={})=>t({refreshParentSchema:R}),current:j});if(D.loadAPIClientEvents(),F.parent===j.parent){D.insertBeforeBeginOrAfterEnd(F),e==null||e(i);return}if(k){D.insertAdjacent(k,F,{wrap:O,breakRemoveOn:T,removeParentsIfNoChildren:L,onSuccess:N}),e==null||e(i);return}},[o,e,t,r])},InternalDndContext=import_react2.default.memo(e=>{const{t}=(0,import_react_i18next.useTranslation)(),[o,r]=(0,import_react2.useState)(!0),i=(0,import_react2.useCallback)(a=>{var l,c,u;const{active:m}=a,d=(c=(l=m==null?void 0:m.data)==null?void 0:l.current)==null?void 0:c.schema;r(!!d),e!=null&&e.onDragStart&&((u=e==null?void 0:e.onDragStart)==null||u.call(e,a))},[e==null?void 0:e.onDragStart]),n=useDragEnd(e==null?void 0:e.onDragEnd);return(0,import_jsx_runtime.jsxs)(import_core.DndContext,P(x({collisionDetection:import_core.rectIntersection},e),{onDragStart:i,onDragEnd:n,children:[(0,import_jsx_runtime.jsx)(import_core.DragOverlay,{dropAnimation:{duration:10,easing:"cubic-bezier(0.18, 0.67, 0.6, 1.22)"},children:o&&(0,import_jsx_runtime.jsx)("span",{style:{whiteSpace:"nowrap"},children:t("Dragging")})}),e.children]}))});InternalDndContext.displayName="InternalDndContext";const DndContext=e=>(0,import_jsx_runtime.jsx)(InternalDndContext,x({},e)),DraggableContext=(0,import_react2.createContext)(null);DraggableContext.displayName="DraggableContext";const SortableContext=(0,import_react2.createContext)(null);SortableContext.displayName="SortableContext";const SortableProvider=e=>{const{id:t,data:o,children:r}=e,i=(0,import_core.useDraggable)({id:t,data:o}),n=(0,import_core.useDroppable)({id:t,data:o}),a=(0,import_react2.useMemo)(()=>({draggable:i,droppable:n}),[i,n]);return(0,import_jsx_runtime.jsx)(SortableContext.Provider,{value:a,children:r})},getComputedColor=e=>new import_tinycolor.TinyColor(e).setAlpha(.15).toHex8String(),Sortable=e=>{var t,o;const r=e,{component:i,overStyle:n,style:a,children:l,openMode:c}=r,u=K(r,["component","overStyle","style","children","openMode"]),{token:m}=useToken(),{draggable:d,droppable:p}=(0,import_react2.useContext)(SortableContext),{isOver:g,setNodeRef:h}=p,f=x({},a);return g&&((t=d==null?void 0:d.active)==null?void 0:t.id)!==((o=p==null?void 0:p.over)==null?void 0:o.id)&&(f[i==="a"?"color":"background"]=getComputedColor(m.colorSettings),Object.assign(f,n)),import_react2.default.createElement(i||"div",P(x({role:"none"},u),{className:(0,import_css.cx)("nb-sortable-designer",e.className),ref:h,style:f}),l)},useSortableItemProps=e=>{const t=useSortableItemId(e),o=(0,import_react.useFieldSchema)();return e.schema?P(x({},e),{id:t}):P(x({},e),{id:t,schema:o})},useSortableItemId=e=>{var t;const o=(0,import_react.useField)();return e.id?e.id:(t=o.address)==null?void 0:t.toString()},InternalSortableItem=(0,import_react.observer)(e=>{const t=useSortableItemProps(e),{schema:o,id:r,eid:i,removeParentsIfNoChildren:n}=t,a=K(t,["schema","id","eid","removeParentsIfNoChildren"]),l=(0,import_react2.useMemo)(()=>({insertAdjacent:"afterEnd",schema:o,removeParentsIfNoChildren:n??!0}),[o,n]);return(0,import_jsx_runtime.jsx)(SortableProvider,{id:r,data:l,children:(0,import_jsx_runtime.jsx)(Sortable,P(x({id:i},a),{children:e.children}))})},{displayName:"InternalSortableItem"}),SortableItem=import_react2.default.memo(e=>{const t=e,{component:o}=t,r=K(t,["component"]),{designable:i}=useDesignable();return i?(0,import_jsx_runtime.jsx)(InternalSortableItem,x({},e)):import_react2.default.createElement(o||"div",import_lodash.default.omit(r,["children","schema","overStyle","openMode","id","eid","removeParentsIfNoChildren"]),e.children)});SortableItem.displayName="SortableItem";const DragHandler=e=>{const{draggable:t}=(0,import_react2.useContext)(SortableContext)||{};if(!t)return null;const{attributes:o,listeners:r,setNodeRef:i}=t;return(0,import_jsx_runtime.jsx)("div",{style:{display:"inline-block",width:14,height:14,lineHeight:"14px",textAlign:"left"},children:(0,import_jsx_runtime.jsx)("div",P(x(x({ref:i,style:{position:"relative",zIndex:1,lineHeight:0,fontSize:0,display:"inline-block"}},r),o),{role:"none",children:(0,import_jsx_runtime.jsx)("span",{style:{cursor:"move",fontSize:14},children:e.children})}))})},ShowFormData=(0,import_react.observer)(({children:e})=>{const t=(0,import_react.useForm)();return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)("pre",{style:{marginBottom:20},"data-testid":"form-data",children:JSON.stringify(t.values,null,2)}),e]})}),common=Object.freeze(Object.defineProperty({__proto__:null,DndContext,DragHandler,DraggableContext,ShowFormData,Sortable,SortableContext,SortableItem,SortableProvider,getRenderContent},Symbol.toStringTag,{value:"Module"})),requestChartData=e=>function(){return q(this,null,function*(){var t;try{const o=yield this.api.request(e);return(t=o==null?void 0:o.data)==null?void 0:t.data}catch{return[]}})},FormComponent$1=e=>{const t=e,{form:o,children:r}=t,i=K(t,["form","children"]),n=(0,import_react.useField)(),a=(0,import_react.useFieldSchema)(),l=useAttach(o.createVoidField(P(x({},n.props),{basePath:""})));return(0,import_jsx_runtime.jsx)(import_react.FieldContext.Provider,{value:void 0,children:(0,import_jsx_runtime.jsx)(import_react.FormContext.Provider,{value:o,children:(0,import_jsx_runtime.jsx)(import_antd_v5.FormLayout,P(x({layout:"vertical"},i),{children:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:l.address,schema:a,onlyRenderProperties:!0})}))})})},Def$1=e=>e.children,FormDecorator$1=e=>{const t=e,{form:o,children:r,disabled:i}=t,n=K(t,["form","children","disabled"]),a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)(),c=useAttach(o.createVoidField(P(x({},a.props),{basePath:""}))),u=useComponent(l["x-component"],Def$1);return(0,import_react2.useEffect)(()=>{o.disabled=i||a.disabled},[i,a.disabled]),(0,import_jsx_runtime.jsx)(import_antd.ConfigProvider,{componentDisabled:i,children:(0,import_jsx_runtime.jsx)(import_react.FieldContext.Provider,{value:void 0,children:(0,import_jsx_runtime.jsx)(import_react.FormContext.Provider,{value:o,children:(0,import_jsx_runtime.jsx)(import_antd_v5.FormLayout,P(x({layout:"vertical"},n),{children:(0,import_jsx_runtime.jsx)(import_react.FieldContext.Provider,{value:c,children:(0,import_jsx_runtime.jsx)(u,P(x({},a.componentProps),{children:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:c.address,schema:l,onlyRenderProperties:!0})}))})}))})})})},getRequestParams=e=>{const{request:t,initialValue:o}=e;return t||(()=>Promise.resolve({data:o}))},useDefaultValues=(e={},t={})=>useRequest(getRequestParams(t),e),FormBlockContext=(0,import_react2.createContext)(null);FormBlockContext.displayName="FormBlockContext";const Form$1=(0,import_react.observer)(e=>{const t=e,{request:o,effects:r,initialValue:i,useValues:n=useDefaultValues}=t,a=K(t,["request","effects","initialValue","useValues"]),l=(0,import_react.useFieldSchema)(),c=(0,import_react.useField)(),u=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)({effects:r}),[]),m=n({uid:l["x-uid"],onSuccess(p){return q(this,null,function*(){yield u.reset(),u.setValues(p==null?void 0:p.data),u.setInitialValues(p==null?void 0:p.data)})}},e),d=(0,import_react2.useContext)(FormBlockContext);return(0,import_jsx_runtime.jsx)(FormBlockContext.Provider,{value:{parent:d,form:u,result:m,field:c,fieldSchema:l},children:(0,import_jsx_runtime.jsx)(import_antd.Spin,{spinning:(m==null?void 0:m.loading)||!1,children:l["x-decorator"]==="Form"?(0,import_jsx_runtime.jsx)(FormDecorator$1,x({form:u},a)):(0,import_jsx_runtime.jsx)(FormComponent$1,x({form:u},a))})})},{displayName:"Form"});Form$1.Designer=function e(){const{name:t,title:o}=useCollection_deprecated(),r=useSchemaTemplate(),{componentNamePrefix:i}=useBlockTemplateContext();return(0,import_jsx_runtime.jsxs)(GeneralSchemaDesigner,{template:r,title:o||t,children:[(0,import_jsx_runtime.jsx)(SchemaSettingsTemplate,{componentName:`${i}Form`,collectionName:t}),(0,import_jsx_runtime.jsx)(SchemaSettingsDivider,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};const formV1Settings=new SchemaSettings({name:"FormV1Settings",items:[{name:"template",Component:SchemaSettingsTemplate,useComponentProps(){const{name:e}=useCollection_deprecated(),{componentNamePrefix:t}=useBlockTemplateContext();return{componentName:`${t}Form`,collectionName:e}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),FormDesigner=()=>{const{name:e,title:t}=useCollection_deprecated(),o=useSchemaTemplate();return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,{schemaSettings:"FormSettings",template:o,title:t||e})},ReadPrettyFormDesigner=()=>{const{name:e,title:t}=useCollection_deprecated(),o=useSchemaTemplate();return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,{schemaSettings:"ReadPrettyFormSettings",template:o,title:t||e})},DetailsDesigner=()=>{const{name:e,title:t}=useCollection_deprecated(),o=useSchemaTemplate();return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,{schemaSettings:"FormDetailsSettings",template:o,title:t||e})},FilterDesigner=()=>{const{name:e,title:t}=useCollection_deprecated(),o=useSchemaTemplate();return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,{schemaSettings:"blockSettings:filterForm",template:o,title:t||e})},defaultFieldNames$1={label:"label",value:"value",color:"color",options:"children"};function flatData$1(e,t){const o=[];if(!Array.isArray(e))return o;for(let r=0;r<e.length;r++){const i=e[r][t.options];Array.isArray(i)&&o.push(...flatData$1(i,t)),o.push(x({},e[r]))}return o}function findOptions(e,t,o){if(!e)return[];const r=[];for(const i of o){const n=e.find(a=>a[t.value]==i)||{value:i,label:i&&i.toString()};r.push(n)}return r}function getCurrentOptions(e,t,o){const r=flatData$1(t,o),i=(0,import_lodash.castArray)(e).map(n=>(0,import_client.isPlainObject)(n)?n[o.value]:n);return findOptions(r,o,i)}const ReadPrettyInternal=(0,import_react.observer)(e=>{const[t,o]=(0,import_react2.useState)(!0),[r,i]=(0,import_react2.useState)([]),n=(0,import_react.useField)(),a=useCollectionField();return(0,import_react2.useEffect)(()=>{var l;const c=x(x({},defaultFieldNames$1),e.fieldNames),u=n.dataSource||e.options||(a==null?void 0:a.uiSchema.enum)||[],m=getCurrentOptions(n.value,u,c);if(!(0,import_shared.isValid)(e.value)&&!m.length||(0,import_core2.isArrayField)(n)&&((l=n==null?void 0:n.value)==null?void 0:l.length)===0)return;const d=n.value!==null&&m.map((p,g)=>(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:p[c.color],icon:p.icon,children:p[c.label]},g));i(d),o(!1)},[a==null?void 0:a.uiSchema.enum,n,n.dataSource,n.value,e.fieldNames,e.options,e.value]),t?null:(0,import_jsx_runtime.jsx)(EllipsisWithTooltip,{ellipsis:e.ellipsis,children:r})},{displayName:"SelectReadPretty"}),ReadPretty$b=withPopupWrapper(ReadPrettyInternal),isEmptyObject=e=>!(0,import_shared.isValid)(e)||typeof e=="object"&&Object.keys(e).length===0,ObjectSelect=e=>{const t=e,{value:o,options:r,onChange:i,fieldNames:n,mode:a,loading:l,rawOptions:c,defaultValue:u}=t,m=K(t,["value","options","onChange","fieldNames","mode","loading","rawOptions","defaultValue"]),d=p=>{var g;if(isEmptyObject(p))return;const h=(0,import_shared.toArr)(p).filter(_=>_).map(_=>(0,import_client.isPlainObject)(_)?_[n.value]:_),f=(g=getCurrentOptions(h,r,n))==null?void 0:g.map(_=>({label:_[n.label],value:_[n.value]}));return["tags","multiple"].includes(a)||e.multiple?f:f.shift()};return(0,import_jsx_runtime.jsx)(import_antd.Select,x({role:"button","data-testid":`select-object-${a||"single"}`,value:d(o),defaultValue:d(u),allowClear:{clearIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseCircleFilled,{role:"button","aria-label":"icon-close-select"})},labelInValue:!0,notFoundContent:l?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(0,import_jsx_runtime.jsx)(import_antd.Empty,{image:import_antd.Empty.PRESENTED_IMAGE_SIMPLE}),options:r,fieldNames:n,showSearch:!0,popupMatchSelectWidth:!1,filterOption:(p,g)=>{var h;return((h=g==null?void 0:g[n.label||"label"])!=null?h:"").includes(p)},filterSort:(p,g)=>{var h,f;return((h=p==null?void 0:p[n.label||"label"])!=null?h:"").toLowerCase().localeCompare(((f=g==null?void 0:g[n.label||"label"])!=null?f:"").toLowerCase())},onChange:p=>{const g=getCurrentOptions((0,import_shared.toArr)(p).map(h=>h.value),c||r,n);["tags","multiple"].includes(a)||e.multiple?i==null||i(g):i==null||i(g.shift()||null)},mode:a,tagRender:p=>(0,import_jsx_runtime.jsx)(import_antd.Tag,P(x({role:"button","aria-label":p.label,closeIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseOutlined,{role:"button","aria-label":"icon-close-tag"})},p),{children:p.label})),maxTagCount:"responsive"},m))},filterOption=(e,t)=>{var o;return((o=t==null?void 0:t.label)!=null?o:"").toLowerCase().includes((e||"").toLowerCase())},InternalSelect=(0,import_react.connect)(e=>{const t=e,{objectValue:o,loading:r,value:i,rawOptions:n,defaultValue:a}=t,l=K(t,["objectValue","loading","value","rawOptions","defaultValue"]),c=useCompile();let u=e.multiple?"multiple":e.mode;if(u&&!["multiple","tags"].includes(u)&&(u=void 0),o)return(0,import_jsx_runtime.jsx)(ObjectSelect,P(x({rawOptions:n},l),{defaultValue:a,value:i,mode:u,loading:r}));const m=d=>["tags","multiple"].includes(e.mode)||e.multiple?d?(0,import_shared.toArr)(d):void 0:d;return(0,import_jsx_runtime.jsx)(import_antd.Select,P(x({role:"button","data-testid":`select-${u||"single"}`,showSearch:!0,filterOption,allowClear:{clearIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseCircleFilled,{role:"button","aria-label":"icon-close-select"})},popupMatchSelectWidth:!1,notFoundContent:r?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(0,import_jsx_runtime.jsx)(import_antd.Empty,{image:import_antd.Empty.PRESENTED_IMAGE_SIMPLE}),value:m(i),defaultValue:m(a),tagRender:d=>(0,import_jsx_runtime.jsx)(import_antd.Tag,P(x({role:"button","aria-label":d.label,closeIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseOutlined,{role:"button","aria-label":"icon-close-tag"})},d),{children:d.label}))},c(l)),{onChange:d=>{var p;(p=e.onChange)==null||p.call(e,d===void 0?null:d)},mode:u,maxTagCount:"responsive"}))},(0,import_react.mapProps)({dataSource:"options"},(e,t)=>P(x({},e),{fieldNames:x(x({},defaultFieldNames$1),e.fieldNames),suffixIcon:t!=null&&t.loading||t!=null&&t.validating?(0,import_jsx_runtime.jsx)(import_icons.LoadingOutlined,{}):e.suffixIcon})),(0,import_react.mapReadPretty)(ReadPretty$b)),Select=InternalSelect;Select.ReadPretty=ReadPretty$b;const getValues=(e,t)=>(0,import_lodash.castArray)(e).filter(o=>o!=null).map(o=>typeof o=="object"?o[t.value]:o),ReadPretty$a=(0,import_react.observer)(e=>{const t=x(x({},defaultFieldNames$1),e.fieldNames),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),i=useRecord(),{snapshot:n}=useActionContext(),{data:a}=useRequest(n?()=>q(void 0,null,function*(){return{data:i[r.name]}}):P(x({action:"list"},e.service),{params:{paginate:!1,filter:{[t.value]:{$in:getValues(o.value,t)}}}}),{refreshDeps:[e.service,o.value]});return(0,import_jsx_runtime.jsx)(Select.ReadPretty,P(x({},e),{options:a==null?void 0:a.data}))},{displayName:"ReadPretty"}),EMPTY$1="N/A",InternalRemoteSelect=withDynamicSchemaProps((0,import_react.connect)(e=>{var t,o;const r=e,{fieldNames:i={},service:n={},wait:a=300,value:l,defaultValue:c,objectValue:u,manual:m=!0,mapOptions:d,targetField:p,CustomDropdownRender:g,optionFilter:h,dataSource:f,toOptionsItem:_=H=>H,popupMatchSelectWidth:v=!1}=r,S=K(r,["fieldNames","service","wait","value","defaultValue","objectValue","manual","mapOptions","targetField","CustomDropdownRender","optionFilter","dataSource","toOptionsItem","popupMatchSelectWidth"]),C=useDataSourceKey(),b=useDataSourceHeaders(f||C),[y,F]=(0,import_react2.useState)(!1),j=(0,import_react2.useRef)(!1),k=(0,import_react.useFieldSchema)(),T=((t=k["x-component-props"])==null?void 0:t.addMode)==="quickAdd",{getField:O}=useCollection_deprecated(),N=(0,import_react2.useRef)(null),{getCollectionJoinField:L,getInterface:D}=useCollectionManager_deprecated(),R=k["x-collection-field"]||k.name,$=O(R)||L(R),w=p||($==null?void 0:$.target)&&(i==null?void 0:i.label)&&L(`${$.target}.${i.label}`),I=(0,import_react2.useMemo)(()=>{var H;if(w!=null&&w.interface){const J=D(w.interface),X=((H=J==null?void 0:J.filterable)==null?void 0:H.operators[0].value)||"$includes";return w.type==="string"?"$includes":X}return"$includes"},[w]),M=useCompile(),B=(0,import_react2.useCallback)(H=>{try{return H.filter(J=>["number","string"].includes(typeof J[i.value])||!J[i.value]).map(J=>{var X;let Q=M(J[i.label]);if((X=w==null?void 0:w.uiSchema)!=null&&X.enum)if(Array.isArray(Q))Q=Q.map((ee,te)=>{const ne=w.uiSchema.enum.find(ae=>ae.value===ee);return ne?(0,import_jsx_runtime.jsx)(import_antd.Tag,{role:"button",color:ne.color,style:{marginRight:3},children:(ne==null?void 0:ne.label)||ee},te):(0,import_jsx_runtime.jsx)(import_antd.Tag,{role:"button",children:ee},ee)}).reverse();else{const ee=w.uiSchema.enum.find(te=>te.value===Q);ee&&(Q=(0,import_jsx_runtime.jsx)(import_antd.Tag,{role:"button",color:ee.color,children:ee.label}))}return(w==null?void 0:w.type)==="date"&&(Q=(0,import_dayjs.default)(Q).format("YYYY-MM-DD")),d?d({[i.label]:Q||EMPTY$1,[i.value]:J[i.value]}):P(x({},J),{[i.label]:Q||EMPTY$1,[i.value]:J[i.value]})}).filter(Boolean)}catch(J){return console.error(J),H}},[w==null?void 0:w.uiSchema,i]),{data:z,run:E,loading:V}=useRequest(P(x({action:"list"},n),{headers:b,params:P(x({pageSize:200},n==null?void 0:n.params),{filter:(o=n==null?void 0:n.params)==null?void 0:o.filter})}),x({manual:m,debounceWait:a},n.defaultParams?{defaultParams:[n.defaultParams]}:{})),U=(0,import_react2.useMemo)(()=>JSON.stringify({service:n,fieldNames:i}),[n,i]),G=(0,import_react2.useCallback)(()=>N.current&&g?(0,import_jsx_runtime.jsx)(g,{search:N.current,callBack:()=>{N.current=null,F(!1)}}):null,[N.current]);(0,import_react2.useEffect)(()=>{j.current&&E()},[U]);const W=H=>q(void 0,null,function*(){var J;E({filter:mergeFilter([H?{[i.label]:{[I]:H}}:{},(J=n==null?void 0:n.params)==null?void 0:J.filter])}),N.current=H}),Y=(0,import_react2.useMemo)(()=>{var H;const J=l||c;if(!((H=z==null?void 0:z.data)!=null&&H.length))return J!=null?Array.isArray(J)?J:[J]:[];const X=J!=null&&(Array.isArray(J)?J.map(ee=>P(x({},ee),{[i.value]:ee[i.value]||ee})):[P(x({},J),{[i.value]:J[i.value]||J})])||[],Q=typeof h=="function"?z.data.filter(h):z.data;return(0,import_lodash.uniqBy)(Q.concat(X??[]),i.value)},[l,c,z==null?void 0:z.data,i.value,h]);return(0,import_jsx_runtime.jsx)(Select,P(x({open:y,popupMatchSelectWidth:v,autoClearSearchValue:!0,filterOption:!1,filterSort:null,fieldNames:i,onSearch:W,onDropdownVisibleChange:H=>{F(H),N.current=null,H&&E(),j.current=!0},objectValue:u,value:l,defaultValue:c},S),{loading:z?V:!0,options:_(B(Y)),rawOptions:Y,dropdownRender:H=>{const J=Y.some(X=>X[i.label]===N.current);return(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:T?(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[!((z==null?void 0:z.data.length)===0&&N!=null&&N.current)&&H,(z==null?void 0:z.data.length)>0&&(N==null?void 0:N.current)&&!J&&(0,import_jsx_runtime.jsx)(import_antd.Divider,{style:{margin:0}}),!J&&(0,import_jsx_runtime.jsx)(G,{})]}):H})}}))},(0,import_react.mapProps)({dataSource:"options"},(e,t)=>{var o;const r=(0,import_react.useFieldSchema)();return P(x({},e),{fieldNames:x(x(x(x({},defaultFieldNames$1),e.fieldNames),t.componentProps.fieldNames),(o=r["x-component-props"])==null?void 0:o.fieldNames),suffixIcon:t!=null&&t.loading||t!=null&&t.validating?(0,import_jsx_runtime.jsx)(import_icons.LoadingOutlined,{}):e.suffixIcon})}),(0,import_react.mapReadPretty)(ReadPretty$a))),RemoteSelect=InternalRemoteSelect;RemoteSelect.ReadPretty=ReadPretty$a;const useFormDataTemplates=()=>{const e=(0,import_react.useFieldSchema)(),{t}=(0,import_react_i18next.useTranslation)(),{duplicateData:o}=useFormBlockContext(),{getCollectionJoinField:r}=useCollectionManager_deprecated();if(o)return o;const{items:i=[],display:n=!0}=findDataTemplates(e);i.forEach(c=>{var u;try{c.fields=(u=c.fields)==null?void 0:u.map(m=>r(`${c.collection}.${m}`)?m:"").filter(Boolean)}catch(m){(0,import_client.error)(m),c.fields=[]}});const a=[{key:"none",title:t("None")}].concat(i.map((c,u)=>P(x({key:u},c),{isLeaf:c.dataId!==null&&c.dataId!==void 0,titleCollectionField:(c==null?void 0:c.titleField)&&r(`${c.collection}.${c.titleField}`)}))),l=i.find(c=>c.default);return{templates:a,display:n,defaultTemplate:l,enabled:i.length>0&&i.every(c=>c.dataId||c.dataScope)}},Templates=import_react2.default.memo(({style:e={},form:t})=>{const{token:o}=useToken(),{templates:r,display:i,enabled:n,defaultTemplate:a}=useFormDataTemplates(),{getCollectionJoinField:l}=useCollectionManager_deprecated(),c=compatibleDataId(r),[u,m]=(0,import_react2.useState)((a==null?void 0:a.key)||"none"),[d,p]=(0,import_react2.useState)(null),g=useAPIClient(),{t:h}=(0,import_react_i18next.useTranslation)(),f=useDataSourceKey(),_=useDataSourceHeaders(f);(0,import_react2.useEffect)(()=>{n&&a&&t&&(t.__template=!0,a.key==="duplicate"&&b(a.dataId,a,_))},[]),(0,import_react2.useEffect)(()=>{c!=null&&c.some(F=>F.key===u)||C("none")},[c]);const v=(0,import_react2.useMemo)(()=>x({display:"flex",alignItems:"center",backgroundColor:o.colorFillAlter,padding:o.padding},e),[e,o.colorFillAlter]),S=(0,import_react2.useMemo)(()=>({fontSize:o.fontSize,fontWeight:"bold",whiteSpace:"nowrap",marginRight:o.marginXS}),[o.fontSize,o.marginXS]),C=(0,import_react2.useCallback)(F=>q(void 0,null,function*(){m(F),p(null),t==null||t.reset()}),[]),b=(0,import_react2.useCallback)((F,j,k)=>q(void 0,null,function*(){const T=P(x({},j),{dataId:F});p(j),fetchTemplateData(g,T,k).then(O=>(t&&O&&(t.reset(),t.__template=!0,(0,import_client.forEach)(O,(N,L)=>{var D;N&&(t.values[L]=N,(D=t==null?void 0:t.setInitialValuesIn)==null||D.call(t,L,N))})),O)).catch(O=>{console.error(O)})}),[]);if(!n||!i)return null;const y=c==null?void 0:c.find(F=>F.key===u);return(0,import_jsx_runtime.jsx)("div",{style:v,children:(0,import_jsx_runtime.jsxs)(import_antd.Space,{wrap:!0,children:[(0,import_jsx_runtime.jsxs)("label",{style:S,children:[h("Data template"),": "]}),(0,import_jsx_runtime.jsx)(import_antd.Select,{role:"button","data-testid":"select-form-data-template",popupMatchSelectWidth:!1,options:c,fieldNames:{label:"title",value:"key"},value:u,onChange:C}),u!=="none"&&y&&(0,import_jsx_runtime.jsx)(RemoteSelect,{style:{width:220},fieldNames:{label:y==null?void 0:y.titleField,value:"id"},target:y==null?void 0:y.collection,value:d,objectValue:!0,service:{resource:y==null?void 0:y.collection,params:{filter:y==null?void 0:y.dataScope}},onChange:F=>b(F==null?void 0:F.id,x(x({},F),y),_),targetField:l(`${y==null?void 0:y.collection}.${y.titleField}`)})]})})});Templates.displayName="NocoBaseFormDataTemplates";function findDataTemplates(e){const t=findFormBlock(e);return t?import_lodash.default.cloneDeep(t["x-data-templates"])||{}:{}}function fetchTemplateData(e,t,o){return q(this,null,function*(){if(!(t.fields.length===0||!t.dataId))return e.resource(t.collection,void 0,o).get({filterByTk:t.dataId,fields:t.fields,isTemplate:!0}).then(r=>{var i;return(i=r.data)==null?void 0:i.data})})}const useFormBlockHeight=()=>{var e,t,o;const r=useDataBlockHeight(),i=(0,import_react.useFieldSchema)(),{token:n}=import_antd.theme.useToken(),{designable:a}=useDesignable(),{heightProps:l}=useBlockHeightProps()||{},{title:c}=l||{},{display:u,enabled:m}=useFormDataTemplates(),d=i.reduceProperties((y,F)=>F["x-component"]==="ActionBar"?F:y),p=Object.keys((d==null?void 0:d.properties)||{}).length>0,g=(o=(t=(e=i==null?void 0:i.parent)==null?void 0:e["x-decorator"])==null?void 0:t.includes)==null?void 0:o.call(t,"FormBlockProvider"),h=p||a?n.controlHeight+(g?1:2)*n.marginLG:n.marginLG,f=c?n.fontSizeLG*n.lineHeightLG+n.padding*2-1:0,_=useDataBlockRequestData(),{count:v,pageSize:S}=(_==null?void 0:_.meta)||{},C=v>S?n.controlHeightSM+1*n.paddingLG:0,b=u&&m?n.controlHeight+2*n.padding+n.margin:0;return r-h-n.paddingLG-f-C-b},FormComponent=e=>{const t=e,{form:o,children:r}=t,i=K(t,["form","children"]),n=(0,import_react.useField)(),a=(0,import_react.useFieldSchema)(),l=getCardItemSchema==null?void 0:getCardItemSchema(a),c=useAttach(o.createVoidField(P(x({},n.props),{basePath:""}))),u=useFormBlockHeight(),{token:m}=import_antd.theme.useToken(),{layout:d="vertical",labelAlign:p="left",labelWidth:g=120,labelWrap:h=!0}=(l==null?void 0:l["x-component-props"])||{};return(0,import_jsx_runtime.jsx)(import_react.FieldContext.Provider,{value:void 0,children:(0,import_jsx_runtime.jsx)(import_react.FormContext.Provider,{value:o,children:(0,import_jsx_runtime.jsx)(import_antd_v5.FormLayout,P(x({layout:d},i),{labelAlign:p,labelWidth:d==="horizontal"?g:null,labelWrap:h,children:(0,import_jsx_runtime.jsx)("div",{className:import_css.css`
594
+ `,TableColumnActionBar=(0,import_react.observer)(e=>{const t=useDesigner();return(0,import_jsx_runtime.jsxs)(SortableItem,{className:designerCss$3,children:[(0,import_jsx_runtime.jsx)(t,{}),e.children]})},{displayName:"TableColumnActionBar"}),useColumnSchema=()=>{const{getField:e}=useCollection_deprecated(),t=useCompile(),o=(0,import_react.useFieldSchema)(),r=o.reduceProperties((n,a)=>a["x-component"]==="CollectionField"?a:n,null);if(!r)return{};const i=e(r.name);return{columnSchema:o,fieldSchema:r,collectionField:i,uiSchema:t(i==null?void 0:i.uiSchema)}},TableColumnDecorator=e=>{const t=useDesigner(),o=(0,import_react.useField)(),{fieldSchema:r,uiSchema:i,collectionField:n}=useColumnSchema(),a=useCompile();return(0,import_react2.useEffect)(()=>{o.title||r&&i!=null&&i.title&&(o.title=i==null?void 0:i.title)},[i==null?void 0:i.title]),(0,import_jsx_runtime.jsxs)(SortableItem,{className:designerCss$3,children:[(0,import_jsx_runtime.jsx)(t,{fieldSchema:r,uiSchema:i,collectionField:n}),o.title||a(i==null?void 0:i.title)]})},previewComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Preview",items:[{name:"size",type:"select",useVisible(){var e;const{fieldSchema:t}=useColumnSchema();return((e=t==null?void 0:t.parent)==null?void 0:e["x-component"])!=="TableV2.Column"},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Size"),options:[{label:t("Large"),value:"large"},{label:t("Default"),value:"default"},{label:t("Small"),value:"small"}],value:((e=o==null?void 0:o.componentProps)==null?void 0:e.size)||"default",onChange(n){const a={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].size=n,a["x-component-props"]=r["x-component-props"],o.componentProps=o.componentProps||{},o.componentProps.size=n,i.emit("patch",{schema:a}),i.refresh()}}}}]}),uploadAttachmentComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Upload.Attachment",items:[{name:"size",type:"select",useVisible(){var e;const{fieldSchema:t}=useColumnSchema$1(),o=((e=t==null?void 0:t.parent)==null?void 0:e["x-component"])==="TableV2.Column";return useIsFieldReadPretty()&&!o},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i}=useDesignable();return{title:t("Size"),options:[{label:t("Large"),value:"large"},{label:t("Default"),value:"default"},{label:t("Small"),value:"small"}],value:((e=o==null?void 0:o.componentProps)==null?void 0:e.size)||"default",onChange(n){const a={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].size=n,a["x-component-props"]=r["x-component-props"],o.componentProps=o.componentProps||{},o.componentProps.size=n,i.emit("patch",{schema:a}),i.refresh()}}}}]}),inputJSONSettings=new SchemaSettings({name:"fieldSettings:component:Input.JSON",items:[ellipsisSettingsItem]}),createSettingsItem=e=>({name:e.name,type:"select",useComponentProps(){var t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),{fieldSchema:n}=useColumnSchema$1(),a=n||i,{dn:l}=useDesignable();return{title:o(e.title),options:e.options(o),value:((t=a["x-component-props"])==null?void 0:t[e.name])||e.defaultValue,onChange(c){const u={"x-uid":a["x-uid"]};a["x-component-props"]=a["x-component-props"]||{},a["x-component-props"][e.name]=c,u["x-component-props"]=a["x-component-props"],r.componentProps=r.componentProps||{},r.componentProps[e.name]=c,l.emit("patch",{schema:u})}}}}),getSizeOptions=e=>[{value:"small",label:e("Small")},{value:"middle",label:e("Middle")},{value:"large",label:e("Large")},{value:"oversized",label:e("Oversized")},{value:"auto",label:e("Auto")}],getObjectFitOptions=e=>[{value:"cover",label:e("Cover")},{value:"fill",label:e("Fill")},{value:"contain",label:e("Contain")},{value:"scale-down",label:e("Scale Down")},{value:"none",label:e("None")}],size=createSettingsItem({name:"size",title:"Size",options:getSizeOptions,defaultValue:"small"}),objectFit=createSettingsItem({name:"objectFit",title:"Object Fit",options:getObjectFitOptions,defaultValue:"cover"}),inputPreviewComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Input.Preview",items:[size,objectFit]}),inputTextAreaSettings=new SchemaSettings({name:"fieldSettings:component:Input.TextArea",items:[ellipsisSettingsItem]}),inputURLSettings=new SchemaSettings({name:"fieldSettings:component:Input.URL",items:[ellipsisSettingsItem]}),markdownSettings=new SchemaSettings({name:"fieldSettings:component:Markdown",items:[ellipsisSettingsItem]}),markdownVditorSettings=new SchemaSettings({name:"fieldSettings:component:MarkdownVditor",items:[ellipsisSettingsItem]}),richTextSettings=new SchemaSettings({name:"fieldSettings:component:RichText",items:[ellipsisSettingsItem]}),inputNumberComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:InputNumber",items:[{name:"displayFormat",Component:SchemaSettingsNumberFormat,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{fieldSchema:t}=useColumnSchema$1();return{fieldSchema:t||e}},useVisible(){return useIsFieldReadPretty()}},enableLinkSettingsItem,openModeSettingsItem]}),filterFormItemSettings=new SchemaSettings({name:"FilterFormItemSettings",items:[{name:"editFieldTitle",Component:EditTitle},{name:"editDescription",Component:EditDescription},{name:"editTooltip",Component:EditTooltip},{name:"validationRules",Component:EditValidationRules},{name:"setDataScope",Component:SchemaSettingsDataScope,useVisible(){const e=useIsSelectFieldMode(),t=useIsFormReadPretty();return e&&!t},useComponentProps(){var e,t,o;const{getCollectionJoinField:r,getAllCollectionsInheritChain:i}=useCollectionManager_deprecated(),{getField:n}=useCollection_deprecated(),{form:a}=useFormBlockContext(),l=useRecord(),c=(0,import_react.useField)(),u=(0,import_react.useFieldSchema)(),m=n(u.name)||r(u["x-collection-field"]),d=useVariables$1(),p=useLocalVariables$1(),{dn:g}=useDesignable();return{collectionName:m==null?void 0:m.target,defaultFilter:((o=(t=(e=u==null?void 0:u["x-component-props"])==null?void 0:e.service)==null?void 0:t.params)==null?void 0:o.filter)||{},form:a,dynamicComponent:h=>(0,import_jsx_runtime.jsx)(VariableInput,P(x({},h),{form:a,collectionField:h.collectionField,record:l,shouldChange:getShouldChange({collectionField:h.collectionField,variables:d,localVariables:p,getAllCollectionsInheritChain:i})})),onSubmit:({filter:h})=>{h=removeNullCondition(h),import_lodash.default.set(c.componentProps,"service.params.filter",h),u["x-component-props"]=c.componentProps,g.emit("patch",{schema:{"x-uid":u["x-uid"],"x-component-props":c.componentProps}})}}}},{name:"fieldMode",Component:EditComponent},{name:"operator",Component:EditOperator},{name:"titleField",Component:EditTitleField},{name:"divider",type:"divider",useVisible(){const{getCollectionJoinField:e}=useCollectionManager_deprecated(),{getField:t}=useCollection_deprecated(),o=(0,import_react.useFieldSchema)();return!!(t(o.name)||e(o["x-collection-field"]))}},{name:"remove",type:"remove",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)();return{removeParentsIfNoChildren:!0,confirm:{title:e("Delete field")},breakRemoveOn:{"x-component":"Grid"}}}}]}),fieldComponent$4={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),r=useFieldModeOptions(),i=useIsAddNewForm(),n=useFieldComponentName(),{dn:a}=useDesignable();return{title:e("Field component"),options:r,value:n,onChange(l){const c={"x-uid":o["x-uid"]};o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].mode=l,c["x-component-props"]=o["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=l,isSubMode(o)&&i&&(c.default=null,o.default=null,t.setInitialValue(null),t.setValue(null)),a.emit("patch",{schema:c}),a.refresh()}}}},allowSelectExistingRecord={name:"allowSelectExistingRecord",type:"switch",useVisible(){return!useIsFieldReadPretty()},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow selection of existing records"),checked:(e=r["x-component-props"])==null?void 0:e.allowSelectExistingRecord,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.allowSelectExistingRecord=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].allowSelectExistingRecord=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},allowDisassociation={name:"allowDisassociation",type:"switch",useVisible(){return!useIsFieldReadPretty()},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow disassociation"),checked:((e=r["x-component-props"])==null?void 0:e.allowDisassociation)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.allowDisassociation=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].allowDisassociation=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},setDefaultSortingRules={name:"SetDefaultSortingRules",type:"modal",useComponentProps(){const{getCollectionJoinField:e}=useCollectionManager_deprecated(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),r=o["x-collection-field"],{target:i}=e(r)||{},n=useSortFields(i),{t:a}=(0,import_react_i18next.useTranslation)(),{dn:l}=useDesignable(),c=t.componentProps.sortArr||[],u=c==null?void 0:c.map(m=>m!=null&&m.startsWith("-")?{field:m.substring(1),direction:"desc"}:{field:m,direction:"asc"});return{title:a("Set default sorting rules"),components:{ArrayItems:import_antd_v5.ArrayItems},schema:{type:"object",title:a("Set default sorting rules"),properties:{sort:{type:"array",default:u,"x-component":"ArrayItems","x-decorator":"FormItem",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},field:{type:"string",enum:n,required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:260}}},direction:{type:"string","x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button"},enum:[{label:a("ASC"),value:"asc"},{label:a("DESC"),value:"desc"}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:a("Add sort field"),"x-component":"ArrayItems.Addition"}}}}},onSubmit:({sort:m})=>{const d=m.map(p=>p.direction==="desc"?`-${p.field}`:p.field);t.componentProps.sortArr=d,o["x-component-props"].sortArr=d,l.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}})}}},useVisible(){const{getCollectionJoinField:e}=useCollectionManager_deprecated(),t=(0,import_react.useFieldSchema)()["x-collection-field"],{interface:o}=e(t)||{};return useIsFieldReadPretty()&&["m2m","o2m"].includes(o)}},allowAddNewData={name:"allowAddNewData",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useIsAssociationField();return!e&&t},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow add new"),checked:((e=r["x-component-props"])==null?void 0:e.allowAddnew)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};o.componentProps.allowAddnew=a,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].allowAddnew=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},LinkageRulesComponent=withDynamicSchemaProps(e=>(0,import_jsx_runtime.jsx)(FlagProvider,{isInSubForm:!0,children:(0,import_jsx_runtime.jsx)(FormLinkageRules,x({},e))}),{displayName:"LinkageRulesComponent"}),linkageRules={name:"linkageRules",Component:SchemaSettingsLinkageRules,useComponentProps(){const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),o=useCollectionManager().getCollectionField(t["x-collection-field"]),{rerenderDataBlock:r}=useRerenderDataBlock();return{collectionName:o==null?void 0:o.target,Component:LinkageRulesComponent,readPretty:e.readPretty,afterSubmit:r}}},recordPerPage={name:"recordsPerPage",type:"select",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useFieldSchema)(),r=(0,import_react.useField)(),{dn:i}=useDesignable(),n=[10,20,50,100];return{title:t("Records per page"),value:((e=r.componentProps)==null?void 0:e.pageSize)||10,options:n.map(a=>({value:a})),onChange:a=>{const l={"x-uid":o["x-uid"]};r.componentProps=r.componentProps||{},r.componentProps.pageSize=a,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].pageSize=a,l["x-component-props"]=o["x-component-props"],i.emit("patch",{schema:l})}}}},subTablePopoverComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:SubTable",items:[fieldComponent$4,allowAddNewData,allowSelectExistingRecord,allowDisassociation,setDefaultSortingRules,linkageRules,recordPerPage]}),allowMultiple$2={name:"allowMultiple",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useCollectionField();return!e&&["hasMany","belongsToMany"].includes(t==null?void 0:t.type)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow multiple"),checked:((e=r["x-component-props"])==null?void 0:e.multiple)===void 0?!0:r["x-component-props"].multiple,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].multiple=a,o.componentProps.multiple=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},fieldComponent$3={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),r=useFieldModeOptions(),i=useIsAddNewForm(),n=useFieldComponentName(),{dn:a}=useDesignable();return{title:e("Field component"),options:r,value:n,onChange(l){const c={"x-uid":o["x-uid"]};o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].mode=l,c["x-component-props"]=o["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=l,isSubMode(o)&&i&&(c.default=null,o.default=null,t.setInitialValue(null),t.setValue(null)),a.emit("patch",{schema:c}),a.refresh()}}}},subformComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Nester",items:[fieldComponent$3,allowMultiple$2,{name:"allowDissociate",type:"switch",useVisible(){const{type:e}=useFormBlockType();return!useIsFormReadPretty()&&e==="update"},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow dissociate"),checked:((e=r["x-component-props"])==null?void 0:e.allowDissociate)!==!1,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].allowDissociate=a,o.componentProps.allowDissociate=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},setDefaultSortingRules,linkageRules,{name:"setBlockLayout",Component:SchemaSettingsLayoutItem}]}),allowMultiple$1={name:"allowMultiple",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useCollectionField();return!e&&["hasMany","belongsToMany","belongsToArray"].includes(t==null?void 0:t.type)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow multiple"),checked:((e=r["x-component-props"])==null?void 0:e.multiple)===void 0?!0:r["x-component-props"].multiple,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].multiple=a,o.componentProps.multiple=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},fieldComponent$2={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=useIsAddNewForm(),r=useFieldComponentName(),{fieldSchema:i,collectionField:n}=useColumnSchema$1(),a=(0,import_react.useFieldSchema)(),l=i||a,c=useFieldModeOptions({fieldSchema:i,collectionField:n}),{dn:u}=useDesignable();return{title:e("Field component"),options:c,value:r,onChange(m){var d,p;const g={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].mode=m,g["x-component-props"]=l["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=m,isSubMode(l)&&o&&(g.default=null,l.default=null,(d=t==null?void 0:t.setInitialValue)==null||d.call(t,null),(p=t==null?void 0:t.setValue)==null||p.call(t,null)),u.emit("patch",{schema:g}),u.refresh()}}}},recordPickerComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Picker",items:[fieldComponent$2,{name:"popupSize",type:"select",useVisible(){return!useIsFieldReadPretty()},useComponentProps(){var e,t,o;const{t:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_react.useField)(),{fieldSchema:n}=useColumnSchema$1(),a=(0,import_react.useFieldSchema)(),l=n||a,{dn:c}=useDesignable();return{title:r("Popup size"),options:[{label:r("Small"),value:"small"},{label:r("Middle"),value:"middle"},{label:r("Large"),value:"large"}],value:(o=(e=l==null?void 0:l["x-component-props"])==null?void 0:e.openSize)!=null?o:((t=l==null?void 0:l["x-component-props"])==null?void 0:t.openMode)=="modal"?"large":"middle",onChange:u=>{i.componentProps.openSize=u,l["x-component-props"]=P(x({},l["x-component-props"]),{openSize:u}),c.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":l["x-component-props"]}}),c.refresh()}}}},allowAddNew,allowMultiple$1,titleField$1]}),allowMultiple={name:"allowMultiple",type:"switch",useVisible(){const e=useIsFieldReadPretty(),t=useCollectionField();return!e&&["hasMany","belongsToMany"].includes(t==null?void 0:t.type)},useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{dn:i,refresh:n}=useDesignable();return{title:t("Allow multiple"),checked:((e=r["x-component-props"])==null?void 0:e.multiple)===void 0?!0:r["x-component-props"].multiple,onChange(a){const l={"x-uid":r["x-uid"]};r["x-component-props"]=r["x-component-props"]||{},o.componentProps=o.componentProps||{},r["x-component-props"].multiple=a,o.componentProps.multiple=a,l["x-component-props"]=r["x-component-props"],i.emit("patch",{schema:l}),n()}}}},fieldComponent$1={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),{fieldSchema:o,collectionField:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=o||i,a=useFieldModeOptions({fieldSchema:o,collectionField:r}),{dn:l}=useDesignable(),c=useIsAddNewForm(),u=useFieldComponentName();return{title:e("Field component"),options:a,value:u,onChange(m){const d={"x-uid":n["x-uid"]};n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].mode=m,d["x-component-props"]=n["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=m,isSubMode(n)&&c&&(d.default=null,n.default=null,t.setInitialValue(null),t.setValue(null)),l.emit("patch",{schema:d}),l.refresh()}}}},subformPopoverComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:PopoverNester",items:[fieldComponent$1,allowMultiple,titleField$1,linkageRules,{name:"setBlockLayout",Component:SchemaSettingsLayoutItem}]}),enableLink={name:"enableLink",type:"switch",useComponentProps(){var e;const{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),{fieldSchema:r}=useColumnSchema$1(),i=(0,import_react.useFieldSchema)(),n=r||i,{dn:a}=useDesignable();return{title:t("Enable link"),checked:((e=n["x-component-props"])==null?void 0:e.enableLink)!==!1,onChange(l){n["x-component-props"]=P(x({},n==null?void 0:n["x-component-props"]),{enableLink:l}),o.componentProps.enableLink=l,a.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":x({},n==null?void 0:n["x-component-props"])}})}}}},titleField={name:"titleField",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),{fieldSchema:i,collectionField:n}=useColumnSchema$1(),a=(0,import_react.useFieldSchema)(),l=i||a,c=useTitleFieldOptions(),u=useCollectionField(),m=n||u,{dn:d}=useDesignable();return{title:o("Title field"),options:c,value:(t=(e=l==null?void 0:l["x-component-props"])==null?void 0:e.fieldNames)==null?void 0:t.label,onChange(p){var g,h;const f={"x-uid":l["x-uid"]},_=P(x(x({},(h=(g=m==null?void 0:m.uiSchema)==null?void 0:g["x-component-props"])==null?void 0:h.fieldNames),r.componentProps.fieldNames),{label:p});l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].fieldNames=_,f["x-component-props"]=l["x-component-props"],r.componentProps.fieldNames=l["x-component-props"].fieldNames,d.emit("patch",{schema:f}),d.refresh()}}}},fieldComponent={name:"fieldComponent",type:"select",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),t=(0,import_react.useField)(),o=useIsAddNewForm(),{fieldSchema:r,collectionField:i}=useColumnSchema$1(),n=useFieldModeOptions({fieldSchema:r,collectionField:i}),a=(0,import_react.useFieldSchema)(),l=r||a,c=useFieldComponentName(),{dn:u}=useDesignable();return{title:e("Field component"),options:n,value:c,onChange(m){const d={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].mode=m,d["x-component-props"]=l["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=m,isSubMode(l)&&o&&(d.default=null,l.default=null,t.setInitialValue(null),t.setValue(null)),u.emit("patch",{schema:d}),u.refresh()}}}},tagComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:Tag",items:[fieldComponent,{name:"tagColorField",type:"select",useComponentProps(){var e,t;const{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useField)(),i=(0,import_react.useFieldSchema)(),n=useCollectionField(),{fieldSchema:a,collectionField:l}=useColumnSchema$1(),c=a||i,u=l||n,{dn:m}=useDesignable(),d=useColorFields((e=u==null?void 0:u.target)!=null?e:u==null?void 0:u.targetCollection);return{title:o("Tag color field"),options:d,value:(t=c==null?void 0:c["x-component-props"])==null?void 0:t.tagColorField,onChange(p){const g={"x-uid":c["x-uid"]};c["x-component-props"]=c["x-component-props"]||{},c["x-component-props"].tagColorField=p,g["x-component-props"]=c["x-component-props"],r.componentProps.tagColorField=p,m.emit("patch",{schema:g}),m.refresh()}}}},titleField,enableLink,ellipsisSettingsItem]}),unixTimestampComponentFieldSettings=new SchemaSettings({name:"fieldSettings:component:UnixTimestamp",items:[{name:"dateDisplayFormat",Component:SchemaSettingsDateFormat,useComponentProps(){const e=(0,import_react.useFieldSchema)(),{fieldSchema:t}=useColumnSchema$1();return{fieldSchema:t||e}}},enableLinkSettingsItem,openModeSettingsItem]});function GroupTitleEditor(e){const t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{dn:r}=useDesignable(),{t:i}=(0,import_react_i18next.useTranslation)();return(0,import_jsx_runtime.jsx)(SchemaSettingsModalItem,{title:i("Edit group title"),schema:{type:"object",title:i("Edit group title"),properties:{children:{"x-decorator":"FormItem","x-component":"Input",title:i("Group title"),default:t.componentProps.children,"x-component-props":{}}}},onSubmit:({children:n})=>{t.componentProps.children=n,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].children=n,r.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":x({},o["x-component-props"])}}),r.refresh()}})}const dividerSettings=new SchemaSettings({name:"blockSettings:divider",items:[{name:"editTitle",type:"item",Component:GroupTitleEditor},{name:"orientation",type:"select",useComponentProps(){var e;const t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),{t:r}=(0,import_react_i18next.useTranslation)(),{dn:i}=useDesignable();return{title:r("Title position"),value:((e=t.componentProps)==null?void 0:e.orientation)||"left",options:[{label:r("Left"),value:"left"},{label:r("Center"),value:"center"},{label:r("Right"),value:"right"}],onChange:n=>{t.componentProps=t.componentProps||{},t.componentProps.orientation=n,o["x-component-props"]=o["x-component-props"]||{},o["x-component-props"].orientation=n,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}})}}}},{name:"dashed",type:"switch",useComponentProps:()=>{const e=(0,import_react.useField)(),t=(0,import_react.useFieldSchema)(),{t:o}=(0,import_react_i18next.useTranslation)(),{dn:r}=useDesignable();return{title:o("Dashed"),defaultChecked:!0,checked:e.componentProps.dashed,onChange:i=>{e.componentProps.dashed=i,t["x-component-props"].dashed=i,i===!1&&(t["x-component-props"].dashed=!1),r.emit("patch",{schema:t}),r.refresh()}}}},{name:"color",type:"item",useComponentProps:()=>{const{t:e}=(0,import_react_i18next.useTranslation)(),{dn:t}=useDesignable(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)();return{title:(0,import_jsx_runtime.jsxs)("div",{style:{alignItems:"center",display:"flex",justifyContent:"space-between"},children:[e("Color"),(0,import_jsx_runtime.jsx)("div",{style:{float:"right"},children:(0,import_jsx_runtime.jsx)(ColorPicker,{defaultValue:o.componentProps.color||"rgba(0, 0, 0, 0.88)",onChange:i=>{o.componentProps=o.componentProps||{},o.componentProps.color=i,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].color=i,t.emit("patch",{schema:r}),t.refresh()}})})]})}}},{name:"borderColor",type:"item",useComponentProps:()=>{const{t:e}=(0,import_react_i18next.useTranslation)(),{dn:t}=useDesignable(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)();return{title:(0,import_jsx_runtime.jsxs)("div",{style:{alignItems:"center",display:"flex",justifyContent:"space-between"},children:[e("Divider line color"),(0,import_jsx_runtime.jsx)("div",{style:{float:"right"},children:(0,import_jsx_runtime.jsx)(ColorPicker,{defaultValue:o.componentProps.borderColor||"rgba(5, 5, 5, 0.06)",onChange:i=>{o.componentProps=o.componentProps||{},o.componentProps.borderColor=i,r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].borderColor=i,t.emit("patch",{schema:r}),t.refresh()}})})]})}}},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]});class SchemaSettingsPlugin extends Plugin{load(){return q(this,null,function*(){this.schemaSettingsManager.add(tableBlockSettings),this.schemaSettingsManager.add(createFormBlockSettings),this.schemaSettingsManager.add(editFormBlockSettings),this.schemaSettingsManager.add(filterFormBlockSettings),this.schemaSettingsManager.add(filterFormItemFieldSettings),this.schemaSettingsManager.add(multiDataDetailsBlockSettings),this.schemaSettingsManager.add(detailsWithPaginationSettings),this.schemaSettingsManager.add(singleDataDetailsBlockSettings),this.schemaSettingsManager.add(detailsBlockSettings),this.schemaSettingsManager.add(tableSelectorBlockSettings),this.schemaSettingsManager.add(listBlockSettings),this.schemaSettingsManager.add(gridCardBlockSettings),this.schemaSettingsManager.add(filterCollapseBlockSettings),this.schemaSettingsManager.add(markdownBlockSettings),this.schemaSettingsManager.add(addNewActionSettings),this.schemaSettingsManager.add(filterActionSettings),this.schemaSettingsManager.add(refreshActionSettings),this.schemaSettingsManager.add(viewActionSettings),this.schemaSettingsManager.add(editActionSettings),this.schemaSettingsManager.add(deleteActionSettings),this.schemaSettingsManager.add(disassociateActionSettings),this.schemaSettingsManager.add(associateActionSettings),this.schemaSettingsManager.add(bulkDeleteActionSettings),this.schemaSettingsManager.add(customizeAddRecordActionSettings),this.schemaSettingsManager.add(customizePopupActionSettings),this.schemaSettingsManager.add(customizeLinkActionSettings),this.schemaSettingsManager.add(customizeUpdateRecordActionSettings),this.schemaSettingsManager.add(createSubmitActionSettings),this.schemaSettingsManager.add(updateSubmitActionSettings),this.schemaSettingsManager.add(submitActionSettings),this.schemaSettingsManager.add(customizeSaveRecordActionSettings),this.schemaSettingsManager.add(addChildActionSettings),this.schemaSettingsManager.add(expendableActionSettings),this.schemaSettingsManager.add(fieldSettingsFormItem),this.schemaSettingsManager.add(tableColumnSettings),this.schemaSettingsManager.add(filterCollapseItemFieldSettings),this.schemaSettingsManager.add(selectComponentFieldSettings),this.schemaSettingsManager.add(filterSelectComponentFieldSettings),this.schemaSettingsManager.add(recordPickerComponentFieldSettings),this.schemaSettingsManager.add(subformComponentFieldSettings),this.schemaSettingsManager.add(subformPopoverComponentFieldSettings),this.schemaSettingsManager.add(subTablePopoverComponentFieldSettings),this.schemaSettingsManager.add(datePickerComponentFieldSettings),this.schemaSettingsManager.add(rangePickerPickerComponentFieldSettings),this.schemaSettingsManager.add(unixTimestampComponentFieldSettings),this.schemaSettingsManager.add(inputNumberComponentFieldSettings),this.schemaSettingsManager.add(inputComponentSettings),this.schemaSettingsManager.add(inputURLSettings),this.schemaSettingsManager.add(inputTextAreaSettings),this.schemaSettingsManager.add(inputJSONSettings),this.schemaSettingsManager.add(markdownSettings),this.schemaSettingsManager.add(markdownVditorSettings),this.schemaSettingsManager.add(richTextSettings),this.schemaSettingsManager.add(fileManagerComponentFieldSettings),this.schemaSettingsManager.add(tagComponentFieldSettings),this.schemaSettingsManager.add(cascadeSelectComponentFieldSettings),this.schemaSettingsManager.add(inputPreviewComponentFieldSettings),this.schemaSettingsManager.add(uploadAttachmentComponentFieldSettings),this.schemaSettingsManager.add(previewComponentFieldSettings),this.schemaSettingsManager.add(dividerSettings)})}}const useBuiltInVariables=()=>{const{currentUserCtx:e}=useCurrentUserVariable(),{currentRoleCtx:t}=useCurrentRoleVariable(),{apiTokenCtx:o}=useAPITokenVariable(),{datetimeCtx:r}=useDatetimeVariable(),{urlSearchParamsCtx:i,name:n,defaultValue:a}=useURLSearchParamsVariable();return{builtinVariables:(0,import_react2.useMemo)(()=>[{name:"$user",ctx:e,collectionName:"users",dataSource:DEFAULT_DATA_SOURCE_KEY},{name:"$nRole",ctx:t,collectionName:"roles"},{name:"$nToken",ctx:o},{name:"currentUser",ctx:e,collectionName:"users",dataSource:DEFAULT_DATA_SOURCE_KEY},{name:"$nDate",ctx:r},{name:"$date",ctx:r},{name:"$system",ctx:{now:()=>(0,import_client.dayjs)().toISOString()}},{name:"currentTime",ctx:()=>(0,import_client.dayjs)().toISOString()},{name:n,ctx:i,defaultValue:a}],[t,e,r,a,i,n])}},filterEmptyValues=e=>Array.isArray(e)?e.filter(t=>t===0||t===!1||t):e,TYPE_TO_ACTION={hasMany:"list?pageSize=9999",belongsTo:"get",hasOne:"get",belongsToMany:"list?pageSize=9999",belongsToArray:"get"},getAction=e=>TYPE_TO_ACTION[e],requested={},hasRequested=e=>!!requested[e],getRequested=e=>requested[e],stashRequested=(e,t)=>{requested[e]=t},clearRequested=e=>{delete requested[e]},uniq=e=>!Array.isArray(e)||!import_lodash.default.isObject(e[0])?e:import_lodash.default.uniqBy(e,t=>"id"in t?t.id:JSON.stringify(t)),VariablesContext=(0,import_react2.createContext)(null);VariablesContext.displayName="VariablesContext";const variablesStore={},getFieldPath=(e,t)=>{let o,r;return{fieldPath:e.split(".").map(i=>t[i]?(o=t[i].dataSource,r=t[i],t[i].collectionName):i).join("."),dataSource:o,variableOption:r}},VariablesProvider=({children:e,filterVariables:t})=>{const o=(0,import_react2.useRef)({}),r=useAPIClient(),{getCollectionJoinField:i,getCollection:n}=useCollectionManager_deprecated(),a=useCompile(),{builtinVariables:l}=useBuiltInVariables(),c=(0,import_react2.useCallback)(_=>{import_lodash.default.isFunction(_)?o.current=_(o.current):o.current=_},[]),u=(0,import_react2.useCallback)((_,v,S)=>q(void 0,null,function*(){var C,b;const y=_.split("."),F=y[0],j=mergeVariableToCollectionNameWithLocalVariables(variablesStore,v);let k=mergeCtxWithLocalVariables(o.current,v);const{fieldPath:T,dataSource:O,variableOption:N}=getFieldPath(F,j);let L=T;const{fieldPath:D}=getFieldPath(_,j),R=y.length===1?N==null?void 0:N.collectionName:(C=i(D,O))==null?void 0:C.target;if(!(F in k))throw new Error(`VariablesProvider: ${F} is not found`);for(let w=0;w<y.length;w++){if(k==null)return{value:k===void 0?N==null?void 0:N.defaultValue:k,dataSource:O,collectionName:R};const I=y[w],{fieldPath:M}=getFieldPath(y.slice(0,w+1).join("."),j),B=i(M,O),z=(b=n(L,O))==null?void 0:b.getPrimaryKey();if(Array.isArray(k)){const E=k.map(V=>{if(!(S!=null&&S.doNotRequest)&&shouldToRequest(V==null?void 0:V[I])&&(V==null?void 0:V[z])!=null&&B!=null&&B.target){const U=`/${L}/${V[B.sourceKey||z]}/${I}:${getAction(B.type)}`;if(hasRequested(U))return getRequested(U);const G=r.request({headers:getDataSourceHeaders(O),url:U,params:{appends:S==null?void 0:S.appends}}).then(W=>(clearRequested(U),V[I]=W.data.data,V[I]));return stashRequested(U,G),G}return V==null?void 0:V[I]});k=removeThroughCollectionFields(import_lodash.default.flatten(yield Promise.all(E)),B)}else if(!(S!=null&&S.doNotRequest)&&shouldToRequest(k[I])&&k[z]!=null&&B!=null&&B.target){const E=`/${L}/${k[B.sourceKey||z]}/${I}:${getAction(B.type)}`;let V=null;if(hasRequested(E))V=yield getRequested(E);else{const U=r.request({headers:getDataSourceHeaders(O),url:E,params:{appends:S==null?void 0:S.appends}});stashRequested(E,U),V=yield U,clearRequested(E)}(0,import_reactive.raw)(k)[I]||((0,import_reactive.raw)(k)[I]=V.data.data),k=removeThroughCollectionFields((0,import_client.getValuesByPath)(k,I),B)}else k=removeThroughCollectionFields((0,import_client.getValuesByPath)(k,I),B);B!=null&&B.target&&(L=B.target)}const $=a(import_lodash.default.isFunction(k)?k({fieldOperator:S==null?void 0:S.fieldOperator,isParsingVariable:!0}):k);return{value:$===void 0?N.defaultValue:$,dataSource:O,collectionName:R}}),[i]),m=(0,import_react2.useCallback)(_=>{if(!isVariable(`{{${_.name}}}`))throw new Error(`VariablesProvider: ${_.name} is not a valid name`);c(v=>P(x({},v),{[_.name]:_.ctx})),variablesStore[_.name]=P(x({},_),{defaultValue:import_lodash.default.has(_,"defaultValue")?_.defaultValue:null})},[c]),d=(0,import_react2.useCallback)(_=>o.current[_]?x({},variablesStore[_]):null,[]),p=(0,import_react2.useCallback)(_=>{c(v=>{const S=x({},v);return delete S[_],S}),delete variablesStore[_]},[c]),g=(0,import_react2.useCallback)((_,v,S)=>q(void 0,null,function*(){if(!isVariable(_))return _;v&&(v=import_lodash.default.isArray(v)?v:[v]);const C=getPath(_),b=yield u(C,v,S);return P(x({},b),{value:uniq(filterEmptyValues(b.value))})}),[u]),h=(0,import_react2.useCallback)((_,v)=>q(void 0,null,function*(){var S;if(!isVariable(_))throw new Error(`VariablesProvider: ${_} is not a variable string`);v&&(v=import_lodash.default.isArray(v)?v:[v]);const C=mergeVariableToCollectionNameWithLocalVariables(variablesStore,v),b=getPath(_),{fieldPath:y,dataSource:F}=getFieldPath(b,C);let j=i(y,F);return!j&&!b.includes(".")&&(j={target:(S=C[b])==null?void 0:S.collectionName}),j}),[i]);(0,import_react2.useEffect)(()=>{l.forEach(_=>{m(P(x({},_),{defaultValue:import_lodash.default.has(_,"defaultValue")?_.defaultValue:null}))})},[l,m]);const f=(0,import_react2.useMemo)(()=>({ctxRef:o,setCtx:c,parseVariable:g,registerVariable:m,getVariable:d,getCollectionField:h,removeVariable:p,filterVariables:t}),[h,d,g,m,p,c]);return(0,import_jsx_runtime.jsx)(VariablesContext.Provider,{value:f,children:e})};VariablesProvider.displayName="VariablesProvider";const VariablesProvider$1=VariablesProvider;function shouldToRequest(e){let t=!1;return(0,import_reactive.untracked)(()=>{if(JSON.stringify(e)==="[{}]"||JSON.stringify(e)==="{}"){t=!0;return}t=import_lodash.default.isEmpty(e)}),t}function mergeCtxWithLocalVariables(e,t){return e=x({},e),t==null||t.forEach(o=>{e[o.name]=o.ctx}),e}function mergeVariableToCollectionNameWithLocalVariables(e,t){return e=x({},e),t==null||t.forEach(o=>{e[o.name]=P(x({},o),{defaultValue:import_lodash.default.has(o,"defaultValue")?o.defaultValue:null})}),e}function removeThroughCollectionFields(e,t){return!(t!=null&&t.through)||!e?e:Array.isArray(e)?e.map(o=>import_lodash.default.omit(o,t.through)):import_lodash.default.omit(e,t.through)}const mergeChildren=(e,t)=>{if(!(!e&&!t)&&!(0,import_shared.isFn)(e))return(0,import_jsx_runtime.jsxs)(import_react2.Fragment,{children:[e,t]})},isValidComponent=e=>e&&(typeof e=="object"||typeof e=="function"),renderChildren=(e,t,o)=>(0,import_shared.isFn)(e)?e(t,o):e,NocoBaseReactiveInternal=e=>{var t;const o=(0,import_react2.useContext)(import_react.SchemaComponentsContext),r=e.field,i=mergeChildren(renderChildren(e.children,r,r.form),(t=r.content)!=null?t:r.componentProps.children);if(r.display!=="visible")return null;const n=a=>{var l;return isValidComponent(a)?a:(l=import_shared.FormPath.getIn(o,a))!=null?l:a};return(a=>r.decoratorType?import_react2.default.createElement(n(r.decoratorType),r.decoratorProps,a):(0,import_jsx_runtime.jsx)(import_react2.Fragment,{children:a}))(r.componentType?import_react2.default.createElement(n(r.componentType),P(x({},r.componentProps),{value:r.value}),i):i)};NocoBaseReactiveInternal.displayName="NocoBaseReactiveInternal";const NocoBaseReactiveField=NocoBaseReactiveInternal;NocoBaseReactiveField.displayName="NocoBaseReactiveField";function createNocoBaseField(e){return new NocoBaseField$1(e)}let NocoBaseField$1=class{constructor(e){A(this,"props"),A(this,"initialized"),A(this,"loading"),A(this,"validating"),A(this,"submitting"),A(this,"selfModified"),A(this,"active"),A(this,"visited"),A(this,"mounted"),A(this,"unmounted"),A(this,"inputValues"),A(this,"inputValue"),A(this,"feedbacks"),A(this,"title"),A(this,"description"),A(this,"display"),A(this,"pattern"),A(this,"editable"),A(this,"disabled"),A(this,"readOnly"),A(this,"readPretty"),A(this,"visible"),A(this,"hidden"),A(this,"dataSource"),A(this,"validator"),A(this,"required"),A(this,"content"),A(this,"initialValue"),A(this,"value"),A(this,"data"),A(this,"decorator"),A(this,"component"),A(this,"decoratorProps"),A(this,"componentProps"),A(this,"decoratorType"),A(this,"componentType"),A(this,"path"),A(this,"form"),A(this,"address"),this.props=e,this.initialize()}initialize(){var e,t,o,r,i,n,a,l,c,u,m,d,p,g,h,f,_,v,S,C;const b=this.props.compile;this.pattern="readPretty",this.readPretty=!0,this.initialized=!0,this.loading=!1,this.validating=!1,this.submitting=!1,this.selfModified=!1,this.active=!1,this.visited=!0,this.mounted=!0,this.unmounted=!1,this.inputValues=[],this.inputValue=null,this.feedbacks=[],this.title=b(this.props.title||((e=this.props.schema)==null?void 0:e.title)),this.description=b(this.props.description||((t=this.props.schema)==null?void 0:t.description)),this.display="visible",this.editable=this.props.editable||((o=this.props.schema)==null?void 0:o["x-editable"]),this.disabled=this.props.disabled||((r=this.props.schema)==null?void 0:r["x-disabled"]),this.readOnly=this.props.readOnly||((i=this.props.schema)==null?void 0:i["x-read-only"]),this.visible=this.props.visible||((n=this.props.schema)==null?void 0:n["x-visible"]),this.hidden=this.props.hidden||((a=this.props.schema)==null?void 0:a["x-hidden"]),this.dataSource=b(this.props.dataSource||((l=this.props.schema)==null?void 0:l.enum)),this.validator=this.props.validator,this.required=this.props.required||!!((c=this.props.schema)!=null&&c.required),this.content=b(this.props.content||((u=this.props.schema)==null?void 0:u["x-content"])),this.initialValue=b(this.props.initialValue||((m=this.props.schema)==null?void 0:m.default)),this.value=b(this.props.value),this.data=this.props.data||((d=this.props.schema)==null?void 0:d["x-data"]),this.decorator=this.props.decorator?(0,import_shared.toArr)(this.props.decorator):[(p=this.props.schema)==null?void 0:p["x-decorator"],(g=this.props.schema)==null?void 0:g["x-decorator-props"]],this.component=this.props.component?(0,import_shared.toArr)(this.props.component):[(h=this.props.schema)==null?void 0:h["x-component"],(f=this.props.schema)==null?void 0:f["x-component-props"]],this.decoratorProps=((_=this.props.schema)==null?void 0:_["x-decorator-props"])||{},this.componentProps=((v=this.props.schema)==null?void 0:v["x-component-props"])||{},this.decoratorType=(S=this.props.schema)==null?void 0:S["x-decorator"],this.componentType=(C=this.props.schema)==null?void 0:C["x-component"],this.path={},this.form={},this.address={concat:import_lodash.default.noop}}};const NocoBaseField=e=>{const t=useCompile(),o=(0,import_react.useFieldSchema)(),r=(0,import_react2.useMemo)(()=>createNocoBaseField(P(x({},e),{compile:t})),[]);return Object.assign(r.componentProps,o["x-component-props"]),r.value=e.value,(0,import_jsx_runtime.jsx)(import_react.FieldContext.Provider,{value:r,children:(0,import_jsx_runtime.jsx)(NocoBaseReactiveField,{field:r,children:e.children})})},CollectionFieldUISchemaContext=import_react2.default.createContext({}),RefreshFieldSchemaContext=import_react2.default.createContext(import_lodash.default.noop),RefreshFieldSchemaProvider=({children:e,refresh:t})=>{const o=useRefreshFieldSchema(),r=(0,import_react2.useCallback)(i=>{t(),i!=null&&i.refreshParentSchema&&(o==null||o())},[o,t]);return(0,import_jsx_runtime.jsx)(RefreshFieldSchemaContext.Provider,{value:r,children:e})},RefreshComponentContext=import_react2.default.createContext(import_lodash.default.noop),RefreshComponentProvider=({children:e,refresh:t})=>(0,import_jsx_runtime.jsx)(RefreshComponentContext.Provider,{value:t,children:e}),useRefreshComponent=()=>import_react2.default.useContext(RefreshComponentContext),useRefreshFieldSchema=()=>import_react2.default.useContext(RefreshFieldSchemaContext),useCollectionFieldUISchema=()=>import_react2.default.useContext(CollectionFieldUISchemaContext)||{},CollectionFieldUISchemaProvider=e=>{const{children:t,fieldSchema:o}=e,r=useCollection(),i=useCollectionManager(),n=o==null?void 0:o.name,a=(0,import_react2.useMemo)(()=>{var l;if(!r)return null;const c=(l=o==null?void 0:o["x-component-props"])==null?void 0:l.field;return i.getCollectionField(o==null?void 0:o["x-collection-field"])||c||r.getField((c==null?void 0:c.name)||n)},[r,i,o,n]);return(0,import_jsx_runtime.jsx)(CollectionFieldUISchemaContext.Provider,{value:a,children:t})},toFieldProps=import_lodash.default.memoize((e,t)=>e.toFieldProps({scope:t})),useFieldProps$1=e=>{const t=(0,import_react.useExpressionScope)();return toFieldProps(e,t)},useBasePath=e=>{var t;const o=(0,import_react.useField)();return e.onlyRenderProperties?e.basePath||((t=o==null?void 0:o.address)==null?void 0:t.concat(e.name)):e.basePath||(o==null?void 0:o.address)},createMergedSchemaInstance=(e,t,o)=>{const r=e.toJSON();if(o){if(!r.properties)return e;const i=Object.keys(r.properties)[0],n=Object.values(r.properties)[0];return r.properties[i]=(0,import_shared.merge)(import_lodash.default.omit(t,"type","x-read-pretty"),n),new import_react.Schema(r)}return new import_react.Schema((0,import_shared.merge)(import_lodash.default.omit(t,"type","x-read-pretty"),r))},propertiesToReactElement=({schema:e,field:t,basePath:o,mapProperties:r,filterProperties:i,propsRecursion:n,values:a,isUseFormilyField:l})=>{const c=import_react.Schema.getOrderProperties(e);return c.length?(0,import_jsx_runtime.jsx)(import_react2.Fragment,{children:c.map(({schema:u,key:m},d)=>{const p=(t==null?void 0:t.address)||o;let g=u;if((0,import_shared.isFn)(r)){const f=r(u,m);f&&(g=f)}if((0,import_shared.isFn)(i)&&i(g,m)===!1)return null;const h=(0,import_shared.isBool)(n)&&n?(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{propsRecursion:!0,filterProperties:i,mapProperties:r,schema:g,name:m,basePath:p,values:import_lodash.default.get(a,m),isUseFormilyField:l}):(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{schema:g,name:m,basePath:p,values:import_lodash.default.get(a,m),isUseFormilyField:l});return g["x-component"]==="CollectionField"?(0,import_jsx_runtime.jsx)(IsInNocoBaseRecursionFieldContext.Provider,{value:!0,children:(0,import_jsx_runtime.jsx)(CollectionFieldUISchemaProvider,{fieldSchema:g,children:h})},`${d}-${m}`):(0,import_jsx_runtime.jsx)(IsInNocoBaseRecursionFieldContext.Provider,{value:!1,children:(0,import_jsx_runtime.jsx)(CollectionFieldUISchemaContext.Provider,{value:EMPTY_OBJECT,children:h})},`${d}-${m}`)})}):null},IsInNocoBaseRecursionFieldContext=import_react2.default.createContext(!1),useIsInNocoBaseRecursionFieldContext=()=>import_react2.default.useContext(IsInNocoBaseRecursionFieldContext),NocoBaseRecursionField=import_react2.default.memo(e=>{const{schema:t,name:o,onlyRenderProperties:r,onlyRenderSelf:i,mapProperties:n,filterProperties:a,propsRecursion:l,values:c,isUseFormilyField:u=!0,uiSchema:m}=e,d=useBasePath(e),p=(0,import_react2.useRef)(null),g=(0,import_react2.useMemo)(()=>(p.current=null,new import_react.Schema(t)),[t]),{uiSchema:h,defaultValue:f}=useCollectionFieldUISchema(),_=(0,import_ahooks.useUpdate)(),{onChange:v}=(0,import_react2.useContext)(SchemaComponentOnChangeContext),S=p.current||g,C=(0,import_react2.useCallback)(()=>{const k=S.parent;p.current=new import_react.Schema(S.toJSON(),k),k!=null&&k.properties&&Object.keys(k.properties).forEach(T=>{T===S.name&&(k.properties[T]=p.current)}),_(),v==null||v()},[S,v,_]),b=(0,import_react2.useMemo)(()=>m?createMergedSchemaInstance(S,m,r):h?(h.default=f,createMergedSchemaInstance(S,h,r)):S,[h,f,S,r,m]),y=useFieldProps$1(b),F=k=>{if(!i)return propertiesToReactElement({schema:S,field:k,basePath:d,mapProperties:n,filterProperties:a,propsRecursion:l,values:c,isUseFormilyField:u})},j=()=>(0,import_shared.isValid)(o)?b.type==="object"?r?F():(0,import_jsx_runtime.jsx)(import_react.ObjectField,P(x({},y),{name:o,basePath:d,children:F})):b.type==="array"?(0,import_jsx_runtime.jsx)(import_react.ArrayField,P(x({},y),{name:o,basePath:d})):b.type==="void"?r?F():(0,import_jsx_runtime.jsx)(import_react.VoidField,P(x({},y),{name:o,basePath:d,children:F})):u?(0,import_jsx_runtime.jsx)(import_react.Field,P(x({},y),{name:o,basePath:d})):(0,import_jsx_runtime.jsx)(NocoBaseField,{name:o,value:c,initialValue:c,basePath:d,schema:b}):F();return S?(0,import_jsx_runtime.jsx)(import_react.SchemaContext.Provider,{value:S,children:(0,import_jsx_runtime.jsx)(RefreshFieldSchemaProvider,{refresh:C,children:j()})}):(0,import_jsx_runtime.jsx)(import_react2.Fragment,{})});NocoBaseRecursionField.displayName="NocoBaseRecursionField";const LAZY_COMPONENT_KEY=Symbol("LAZY_COMPONENT_KEY");function lazy(e,...t){if(t.length===0){const o=(0,import_react2.lazy)(()=>e().then(i=>{const n=i.default;return r[LAZY_COMPONENT_KEY]=n,{default:n}})),r=i=>(0,import_jsx_runtime.jsx)(import_react2.default.Suspense,{fallback:(0,import_jsx_runtime.jsx)(import_antd.Spin,{}),children:(0,import_jsx_runtime.jsx)(o,x({},i))});return r}return t.reduce((o,r)=>{const i=(0,import_react2.lazy)(()=>e().then(n=>{const a=(0,import_lodash.get)(n,r);return o[r][LAZY_COMPONENT_KEY]=a,{default:a}}));return o[r]=n=>(0,import_jsx_runtime.jsx)(import_react2.default.Suspense,{fallback:(0,import_jsx_runtime.jsx)(import_antd.Spin,{}),children:(0,import_jsx_runtime.jsx)(i,x({},n))}),o},{})}function useLazy(e,t){const o=typeof t=="function"?t:i=>i[t],r=(0,import_react_imported_component.loadableResource)(e);if(!r.payload)throw new Promise((i,n)=>{r.loadIfNeeded(),r.resolution.then(i).catch(n)});return o(r.payload)}function addAppVersion(e,t){if(e)return e["x-app-version"]||(e["x-app-version"]=t),Object.keys(e.properties||{}).forEach(o=>{var r;addAppVersion((r=e.properties)==null?void 0:r[o],t)}),e}const name="@nocobase/client",version="1.5.4",license="AGPL-3.0",main="lib/index.js",module$1="es/index.mjs",types="es/index.d.ts",dependencies={"@ahooksjs/use-url-state":"3.5.1","@ant-design/cssinjs":"^1.11.1","@ant-design/icons":"^5.1.4","@ant-design/pro-layout":"^7.16.11","@antv/g2plot":"^2.4.18","@budibase/handlebars-helpers":"^0.14.0","@ctrl/tinycolor":"^3.6.0","@dnd-kit/core":"^5.0.1","@dnd-kit/modifiers":"^6.0.0","@dnd-kit/sortable":"^6.0.0","@emotion/css":"^11.7.1","@formily/antd-v5":"1.1.9","@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":"1.5.4","@nocobase/sdk":"1.5.4","@nocobase/utils":"1.5.4",ahooks:"^3.7.2",antd:"5.12.8","antd-style":"3.7.1",axios:"^1.7.0","bignumber.js":"^9.1.2",classnames:"^2.3.1",cronstrue:"^2.11.0","file-saver":"^2.0.5",filesize:"9.0.11",flat:"^5.0.2",i18next:"^22.4.9","i18next-http-backend":"^2.1.1",json5:"^2.2.3",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-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.11.2","react-to-print":"^2.14.7","sanitize-html":"2.13.0","use-deep-compare-effect":"^1.8.1"},peerDependencies={react:">=18.0.0","react-dom":">=18.0.0","react-is":">=18.0.0"},devDependencies={"@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.28"},clientPkg={name,version,license,main,module:module$1,types,dependencies,peerDependencies,devDependencies};function createDesignable(e){return new Designable(e)}const generateUid=e=>{e&&(e["x-uid"]||(e["x-uid"]=(0,import_shared.uid)()),Object.keys(e.properties||{}).forEach(t=>{generateUid(e.properties[t])}))},defaultWrap=e=>e,matchSchema=(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}},splitWrapSchema=(e,t)=>{if(e["x-uid"]&&e["x-uid"]===t["x-uid"])return[null,e.toJSON()];const o=e.toJSON(),r=P(x({},o),{properties:{}});let i=null;const n=(a,l)=>{Object.keys(a||{}).forEach(c=>{const u=a[c];if(u["x-uid"]===t["x-uid"]){i=a[c];return}else l.properties[c]=P(x({},u),{properties:{}}),n(u==null?void 0:u.properties,l.properties[c])})};return n(o.properties,r),[r,i]},translate=e=>e;class Designable{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=translate}=this.options;if(!t)return;const r=i=>{if(!i)return[];const n=Object.values(i.properties).length,a=[];return i.mapProperties(l=>{l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].width=100/n,l["x-uid"]&&a.push({"x-uid":l["x-uid"],"x-component-props":l["x-component-props"]})}),i["x-uid"]&&a.length?a:[]};this.on("insertAdjacent",i=>q(this,[i],function*({onSuccess:n,current:a,position:l,schema:c,wrap:u,wrapped:m,removed:d}){var p;let g=[];if((m==null?void 0:m["x-component"])==="Grid.Col"&&(g=g.concat(r(m.parent))),(d==null?void 0:d["x-component"])==="Grid.Col"&&(g=g.concat(r(d.parent))),this.refresh(),!a["x-uid"])return;const h=yield t.request({url:`/uiSchemas:insertAdjacent/${a["x-uid"]}?position=${l}`,method:"post",data:{schema:addAppVersion(c,this.appVersion),wrap:u}});g.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:g})),d!=null&&d["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${d["x-uid"]}`,method:"post"})),n==null||n((p=h==null?void 0:h.data)==null?void 0:p.data),import_antd.message.success(o("Saved successfully"),.2)})),this.on("patch",i=>q(this,[i],function*({schema:n}){this.refresh(),n!=null&&n["x-uid"]&&(yield t.request({url:"/uiSchemas:patch",method:"post",data:x({},n)}),import_antd.message.success(o("Saved successfully"),.2))})),this.on("initializeActionContext",i=>q(this,[i],function*({schema:n}){n!=null&&n["x-uid"]&&(yield t.request({url:"/uiSchemas:initializeActionContext",method:"post",data:x({},n)}))})),this.on("batchPatch",i=>q(this,[i],function*({schemas:n}){this.refresh(),yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:n}),import_antd.message.success(o("Saved successfully"),.2)})),this.on("remove",i=>q(this,[i],function*({removed:n}){let a=[];(n==null?void 0:n["x-component"])==="Grid.Col"&&(a=r(n.parent)),this.refresh(),n!=null&&n["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${n["x-uid"]}`,method:"post"}),a.length&&(yield t.request({url:"/uiSchemas:batchPatch",method:"post",data:a})),import_antd.message.success(o("Saved successfully"),.2))}))}prepareProperty(t){t.type||(t.type="void"),t.name||(t.name=(0,import_shared.uid)()),this.current["x-uid"]&&generateUid(t)}on(t,o){this.events[t]||(this.events[t]=[]),this.events[t].push(o)}emit(t,...o){return q(this,null,function*(){if(!this.events[t])return;const[r,...i]=o;return Promise.all(this.events[t].map(n=>n.bind(this)(x({current:this.current},r),...i)))})}parentsIn(t){if(!t||!import_react.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"},r={"x-decorator-props":"decoratorProps","x-component-props":"componentProps","x-data":"data"};Object.keys(t).forEach(i=>{o[i]?(this.current[i]=t[i],this.updateModel(o[i],t[i])):r[i]?Object.keys(t[i]).forEach(n=>{(0,import_set.default)(this.current,[i,n],t[i][n]),this.updateModel([r[i],n],t[i][n])}):this.current[i]=t[i]}),this.emit("patch",{schema:t})}getSchemaAttribute(t,o){return(0,import_get.default)(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(r=>{this.current[r]=t[r],o[r]&&this.updateModel(o[r],t[r])}),this.emit("patch",{schema:t})}updateModel(t,o){const r=i=>{(0,import_set.default)(i,t,o)};this.model&&r(this.model),this.query&&this.query.take(r)}insertAdjacent(t,o,r={}){switch(t){case"beforeBegin":return this.insertBeforeBegin(o,r);case"afterBegin":return this.insertAfterBegin(o,r);case"beforeEnd":return this.insertBeforeEnd(o,r);case"afterEnd":return this.insertAfterEnd(o,r)}}recursiveRemoveIfNoChildren(t,o){if(!t)return;let r=t,i;const n=o==null?void 0:o.breakRemoveOn;for(;r;){if(typeof n=="function"){if(n(r))break}else if(matchSchema(r,n))break;if(Object.keys(r.properties||{}).length>0)break;r.parent&&(i=r.parent.removeProperty(r.name)),r=r.parent}return i}remove(t,o={}){const{breakRemoveOn:r,removeParentsIfNoChildren:i}=o,n=t||this.current;let a=n.parent.removeProperty(n.name);if(i){const l=this.recursiveRemoveIfNoChildren(n.parent,{breakRemoveOn:r});l&&(a=l)}return this.emit("remove",{removed:a})}removeWithoutEmit(t,o={}){const{breakRemoveOn:r,removeParentsIfNoChildren:i}=o,n=t||this.current;let a=n.parent.removeProperty(n.name);if(i){const l=this.recursiveRemoveIfNoChildren(n.parent,{breakRemoveOn:r});l&&(a=l)}return a}insertBeforeBeginOrAfterEnd(t,o={}){if(!import_react.Schema.isSchemaInstance(this.current)||!import_react.Schema.isSchemaInstance(t)||this.current.parent!==t.parent)return;let r=0,i=0;return this.current.parent.mapProperties((n,a,l)=>{this.current.name===a&&(i=l),t.name===a&&(r=l)}),r>i?this.insertBeforeBegin(t,o):this.insertAfterEnd(t,o)}insertBeforeBegin(t,o={}){if(!import_react.Schema.isSchemaInstance(this.current))return;const r={onSuccess:o.onSuccess},{wrap:i=defaultWrap,breakRemoveOn:n,removeParentsIfNoChildren:a}=o;if(import_react.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),a&&(r.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:n}))}else t&&(t=(0,import_cloneDeep.default)(t));const l={};let c=!1,u=0,m=0;this.current.parent.mapProperties((f,_)=>{_===this.current.name&&(m=u,c=!0,++u),f["x-index"]=u,++u,c&&(l[_]=f,this.current.parent.removeProperty(_))}),this.prepareProperty(t);const d=i(t),p=this.current.parent.addProperty(d.name||(0,import_shared.uid)(),d);p["x-index"]=m,p.parent=this.current.parent,this.current.parent.setProperties(l);const[g,h]=splitWrapSchema(p,t);this.emit("insertAdjacent",x({position:"beforeBegin",schema:h,wrapped:d,wrap:g},r))}insertAfterBegin(t,o={}){if(!import_react.Schema.isSchemaInstance(this.current))return;const r={onSuccess:o.onSuccess},{wrap:i=defaultWrap,breakRemoveOn:n,removeParentsIfNoChildren:a}=o;if(import_react.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),a&&(r.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:n}))}else t&&(t=(0,import_cloneDeep.default)(t));const l={};let c=1;this.current.mapProperties((g,h)=>{g["x-index"]=c,++c,l[h]=g}),this.current.properties={},this.prepareProperty(t);const u=i(t),m=this.current.addProperty(u.name||(0,import_shared.uid)(),u);m["x-index"]=0,m.parent=this.current,this.current.setProperties(l);const[d,p]=splitWrapSchema(m,t);this.emit("insertAdjacent",x({position:"afterBegin",schema:p,wrap:d,wrapped:u},r))}insertBeforeEnd(t,o={}){if(!import_react.Schema.isSchemaInstance(this.current))return;delete t["x-index"];const r={onSuccess:o.onSuccess},{wrap:i=defaultWrap,breakRemoveOn:n,removeParentsIfNoChildren:a}=o;if(import_react.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),a&&(r.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:n}))}else t&&(t=(0,import_cloneDeep.default)(t));this.prepareProperty(t);const l=i(t),c=this.current.addProperty(l.name||(0,import_shared.uid)(),l);c.parent=this.current;const[u,m]=splitWrapSchema(c,t);return this.emit("insertAdjacent",x({position:"beforeEnd",schema:m,wrap:u,wrapped:l},r))}insertAfterEnd(t,o={}){if(!import_react.Schema.isSchemaInstance(this.current))return;const r={onSuccess:o==null?void 0:o.onSuccess},{wrap:i=defaultWrap,breakRemoveOn:n,removeParentsIfNoChildren:a}=o;let l=0,c=0,u=!1;const m={};if(this.current.parent.mapProperties((f,_)=>{f["x-index"]=l,_===this.current.name&&(++l,c=l,u=!0),++l,u&&_!==this.current.name&&(m[_]=f,this.current.parent.removeProperty(_))}),import_react.Schema.isSchemaInstance(t)){if(this.parentsIn(t)){this.emit("error",{code:"parent_is_not_allowed",schema:t});return}t.parent.removeProperty(t.name),a&&(r.removed=this.recursiveRemoveIfNoChildren(t.parent,{breakRemoveOn:n})),t.parent=null}else t&&(t=(0,import_cloneDeep.default)(t));this.prepareProperty(t);const d=i(t),p=this.current.parent.addProperty(d.name||(0,import_shared.uid)(),d);p.parent=this.current.parent,p["x-index"]=c,this.current.parent.setProperties(m);const[g,h]=splitWrapSchema(p,t);this.emit("insertAdjacent",x({position:"afterEnd",schema:h,wrap:g,wrapped:d},r))}}function useFindComponent(){const e=(0,import_react2.useContext)(import_react.SchemaOptionsContext),t=(0,import_react2.useMemo)(()=>(e==null?void 0:e.components)||{},[e]);return o=>{if(!o)return null;if(typeof o!="string")return o;const r=(0,import_get.default)(t,o);return r||console.error(`[nocobase]: Component "${o}" not found`),r}}function useDesignable(){const{designable:e,setDesignable:t,refresh:o,reset:r}=(0,import_react2.useContext)(SchemaComponentContext),i=(0,import_react2.useContext)(import_react.SchemaOptionsContext),n=(0,import_react2.useMemo)(()=>(i==null?void 0:i.components)||{},[i]),a=(0,import_react2.useMemo)(()=>()=>(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{}),[]),l=(0,import_ahooks.useUpdate)(),c=useRefreshFieldSchema(),u=useRefreshComponent(),m=(0,import_react2.useCallback)(_=>{o==null||o(),l(),c==null||c(_),u==null||u()},[o,l,c,u]),d=(0,import_react.useField)(),p=(0,import_react.useFieldSchema)(),g=useAPIClient(),{t:h}=(0,import_react_i18next.useTranslation)(),f=(0,import_react2.useMemo)(()=>createDesignable({t:h,api:g,refresh:m,current:p,model:d,appVersion:clientPkg.version}),[h,g,m,p,d]);return(0,import_react2.useEffect)(()=>{f.loadAPIClientEvents()},[f]),{dn:f,designable:e,reset:r,refresh:m,setDesignable:t,DesignableBar:a,findComponent:(0,import_react2.useCallback)(_=>{var v;if(!_)return null;if(typeof _!="string")return _;const S=(0,import_get.default)(n,_);return(v=S[LAZY_COMPONENT_KEY])!=null?v:S},[import_get.default]),on:f.on.bind(f),patch:(0,import_react2.useCallback)((_,v)=>{const S=C=>{Object.keys(C).forEach(b=>{const y=C[b];b==="title"&&(d.title=y,p.title=y),b==="x-decorator-props"&&(d.decoratorProps||(d.decoratorProps={}),p["x-decorator-props"]||(p["x-decorator-props"]={}),Object.keys(y).forEach(F=>{d.decoratorProps[F]=y[F],p["x-decorator-props"][F]=y[F]})),b==="x-component-props"&&(d.componentProps||(d.componentProps={}),p["x-component-props"]||(p["x-component-props"]={}),Object.keys(y).forEach(F=>{d.componentProps[F]=y[F],p["x-component-props"][F]=y[F]}))})};if(typeof _=="string"){const C={};return(0,import_set.default)(C,_,v),S(C)}S(_),m()},[f]),shallowMerge:(0,import_react2.useCallback)(_=>{f.shallowMerge(_)},[f]),deepMerge:(0,import_react2.useCallback)(_=>{f.deepMerge(_)},[f]),remove:(0,import_react2.useCallback)((_,v)=>{f.remove(_,v)},[f]),insertAdjacent:(0,import_react2.useCallback)((_,v,S)=>{f.insertAdjacent(_,v,S)},[f]),insertBeforeBegin:(0,import_react2.useCallback)(_=>{f.insertBeforeBegin(_)},[f]),insertAfterBegin:(0,import_react2.useCallback)(_=>{f.insertAfterBegin(_)},[f]),insertBeforeEnd:(0,import_react2.useCallback)(_=>{f.insertBeforeEnd(_)},[f]),insertAfterEnd:(0,import_react2.useCallback)(_=>{f.insertAfterEnd(_)},[f])}}const DefaultSchemaToolbar=()=>null;DefaultSchemaToolbar.isNullComponent=!0;const useDesigner=()=>{const{designable:e}=useDesignable(),t=(0,import_react.useFieldSchema)(),o=(0,import_react2.useMemo)(()=>t["x-designer"]||t["x-toolbar"]?t["x-designer"]||t["x-toolbar"]:t["x-settings"]?SchemaToolbar:DefaultSchemaToolbar,[t]),r=useComponent(o);return e&&r||DefaultSchemaToolbar},useFieldProps=e=>{const t=(0,import_react2.useContext)(import_react.SchemaOptionsContext),o=(0,import_react2.useContext)(import_react.SchemaExpressionScopeContext),r=(0,import_react2.useRef)();return r.current=o,e.toFieldProps(P(x({},t),{get scope(){return x(x({},t.scope),r.current)}}))};function useSchemaComponentContext(){return(0,import_react2.useContext)(SchemaComponentContext)}const useFieldComponentOptions=()=>{var e;const{getCollectionJoinField:t,getCollection:o}=useCollectionManager_deprecated(),r=(0,import_react.useFieldSchema)(),{getField:i}=useCollection_deprecated(),n=i(r.name)||t(r["x-collection-field"]),{t:a}=(0,import_react_i18next.useTranslation)(),{label:l}=((e=r["x-component-props"])==null?void 0:e.fieldNames)||{};return(0,import_react2.useMemo)(()=>{if(!n||!(n!=null&&n.interface)||!["o2o","oho","obo","o2m","linkTo","m2o","m2m"].includes(n.interface))return;const c=o(n.target);if((c==null?void 0:c.template)==="file")return[{label:a("Record picker"),value:"CollectionField"},{label:a("Select"),value:"AssociationSelect"}];switch(n.interface){case"o2m":return[{label:a("Record picker"),value:"CollectionField"},{label:a("Subtable"),value:"TableField"},{label:a("Select"),value:"AssociationSelect"}];case"m2o":case"m2m":case"linkTo":return[{label:a("Record picker"),value:"CollectionField"},{label:a("Select"),value:"AssociationSelect"}];default:return[{label:a("Record picker"),value:"CollectionField"},{label:a("Subform"),value:"FormField"},{label:a("Select"),value:"AssociationSelect"}]}},[a,n==null?void 0:n.interface,l])},useFieldTitle=()=>{var e;const t=(0,import_react.useField)(),o=(0,import_react.useFieldSchema)(),r=useCollection(),i=useCollectionManager(),n=(r==null?void 0:r.getField(o.name))||(i==null?void 0:i.getCollectionField(o["x-collection-field"])),a=useCompile();(0,import_react2.useEffect)(()=>{var l;t!=null&&t.title||(t.title=a((l=n==null?void 0:n.uiSchema)==null?void 0:l.title))},[(e=n==null?void 0:n.uiSchema)==null?void 0:e.title])},getPageHeaderHeight=(e,t,o,r,i)=>i.includes("/popups/")?2*r.paddingContentVertical+22+r.paddingPageVertical:e?r.paddingContentHorizontalLG:o?t?r.controlPaddingHorizontal+3*r.controlPaddingHorizontalSM+22+r.paddingContentHorizontalLG:r.paddingContentHorizontalLG+12:t?r.paddingSM+r.controlHeight+r.marginXS+2*r.controlPaddingHorizontalSM+22+r.paddingContentHorizontalLG:r.controlHeight+r.marginXS+(r.paddingXXS+2)*2+r.paddingContentHorizontalLG,usePageFullScreenHeight=e=>{const{token:t}=import_antd.theme.useToken(),{designable:o}=useDesignable(),{heightProps:r}=useBlockHeightProps(),i=(0,import_react_router_dom.useLocation)(),{disablePageHeader:n,enablePageTabs:a,hidePageTitle:l}=e||r||{},c=t.sizeXXL-2,u=o?t.controlHeight+2*t.paddingContentHorizontalLG:1*t.paddingContentHorizontalLG,m=getPageHeaderHeight(n,a,l,t,i.pathname);return c+m+u},useDrawerFullScreenHeight=()=>{const{token:e}=import_antd.theme.useToken(),{designable:t}=useDesignable(),o=e.paddingContentVerticalLG+e.margin+2*e.paddingContentVertical+24,r=t?e.controlHeight+2*e.paddingContentHorizontalLG:1*e.paddingContentHorizontalLG;return o+r},useFullScreenHeight=e=>{const t=(0,import_react.useFieldSchema)(),o=hasActionContainerInParentChain(t),r=usePageFullScreenHeight(e),i=useDrawerFullScreenHeight();return o?i:r},InternalWorkflowCollection=["users_jobs","approvals","approvalRecords"],useTableHeight=()=>{var e;const{token:t}=import_antd.theme.useToken(),{heightProps:o}=useBlockHeightProps(),{heightProps:r}=useTableBlockContext(),{designable:i}=useDesignable(),n=(0,import_react.useFieldSchema)(),a=r||o,l=useFullScreenHeight(a),{name:c}=useCollection(),{heightMode:u,height:m,title:d}=a;if(!(a!=null&&a.heightMode)||u===HeightMode.DEFAULT)return;const p=Object.keys(((e=n.parent.properties.actions)==null?void 0:e.properties)||{}).length>0,g=t.controlHeight+t.padding+t.marginLG,h=p||i?t.controlHeight+2*t.marginLG:t.marginLG,f=(i&&!InternalWorkflowCollection.includes(c)?t.controlHeight:22)+2*t.padding+1,_=d?t.fontSizeLG*t.lineHeightLG+t.padding*2-1:0;return u===HeightMode.FULL_HEIGHT?window.innerHeight-l-_-f-h-g:m-_-h-f-g},useDataBlockHeight=e=>{const{heightProps:t}=useBlockHeightProps(),o=useFullScreenHeight(),{token:r}=import_antd.theme.useToken(),{heightMode:i,height:n,title:a}=t||{},l=a?r.fontSizeLG*r.lineHeightLG+r.padding*2-1:0;if(!(!(t!=null&&t.heightMode)||i===HeightMode.DEFAULT)){if(i===HeightMode.FULL_HEIGHT){let c=window.innerHeight-o;return e!=null&&e.removeBlockHeaderHeight&&(c=c-l),e!=null&&e.innerExtraHeight&&(c=c-e.innerExtraHeight),c}return n}},useBlockHeight=()=>{const e=(0,import_react.useFieldSchema)(),t=(0,import_react2.useMemo)(()=>getPageSchema(e),[]),{disablePageHeader:o,enablePageTabs:r,hidePageTitle:i}=(t==null?void 0:t["x-component-props"])||{},n=P(x({},e==null?void 0:e["x-component-props"]),{disablePageHeader:o,enablePageTabs:r,hidePageTitle:i}),a=useFullScreenHeight(n),{heightMode:l,height:c}=n||{};if(!(!(n!=null&&n.heightMode)||l===HeightMode.DEFAULT))return l===HeightMode.FULL_HEIGHT?window.innerHeight-a:c},useTableSize=()=>{const[e,t]=(0,import_react2.useState)(),o=(0,import_react2.useRef)(null),r=useTableHeight(),i=(0,import_react2.useCallback)((0,import_lodash.debounce)(()=>{var a;if(!o.current)return;const l=o.current.getBoundingClientRect();(a=o.current.querySelector(".ant-table"))!=null&&a.getBoundingClientRect()&&t(l.width)},100),[r]),n=(0,import_react2.useCallback)(a=>{o.current=a&&a.children?a.children[0]:null,i()},[i]);return(0,import_ahooks.useEventListener)("resize",i),{height:r,width:e,tableSizeRefCallback:n}},hasActionContainerInParentChain=e=>{var t;return e?e["x-component"]==="Action.Container"?((t=e==null?void 0:e.parent["x-component-props"])==null?void 0:t.openMode)!=="page":hasActionContainerInParentChain(e.parent):null},useFieldModeOptions=e=>{var t;const{t:o}=(0,import_react_i18next.useTranslation)(),{getCollectionJoinField:r,getCollection:i}=useCollectionManager_deprecated(),n=(0,import_react.useFieldSchema)(),a=(e==null?void 0:e.fieldSchema)||n,l=(0,import_react.useField)(),c=(0,import_react.useForm)(),u=(a==null?void 0:a["x-read-pretty"])||l.readPretty||c.readPretty,m=e==null?void 0:e.fieldSchema,{getField:d}=useCollection_deprecated(),p=(e==null?void 0:e.collectionField)||d(a.name)||r(a["x-collection-field"]),{label:g}=((t=a["x-component-props"])==null?void 0:t.fieldNames)||{};return((0,import_react2.useMemo)(()=>{if(!p||!(p!=null&&p.interface)||!["o2o","oho","obo","o2m","linkTo","m2o","m2m","updatedBy","createdBy","mbm","attachmentURL"].includes(p.interface))return;const h=i(p.target);if((h==null?void 0:h.template)==="file")return u?[{label:o("Title"),value:"Select"},{label:o("File manager"),value:"FileManager"},{label:o("Tag"),value:"Tag"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},{label:o("File manager"),value:"FileManager"}];if((h==null?void 0:h.template)==="tree"&&["m2m","o2m","m2o"].includes(p.interface))return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!m&&{label:o("Sub-details"),value:"Nester"},!m&&{label:o("Sub-table"),value:"SubTable"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!m&&["m2m","o2m"].includes(p.interface)&&{label:o("Sub-table"),value:"SubTable"},!m&&{label:o("Cascade Select"),value:"CascadeSelect"},!m&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"}];switch(p.interface){case"o2m":return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!m&&{label:o("Sub-table"),value:"SubTable"},!m&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!m&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"},!m&&{label:o("Sub-table"),value:"SubTable"}];case"m2m":case"mbm":return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!m&&{label:o("Sub-details"),value:"Nester"},!m&&{label:o("Sub-table"),value:"SubTable"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!m&&{label:o("Sub-table"),value:"SubTable"},!m&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"}];case"m2o":case"linkTo":return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!m&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!m&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"}];default:return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!m&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!m&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"}]}},[o,p==null?void 0:p.interface,g])||[]).filter(Boolean)},useDragEnd=e=>{const{refresh:t}=useDesignable(),o=useAPIClient(),{t:r}=(0,import_react_i18next.useTranslation)();return(0,import_react2.useCallback)(i=>{var n,a,l,c,u,m,d,p,g,h,f,_,v,S,C;const{active:b,over:y}=i,F=(a=(n=b==null?void 0:b.data)==null?void 0:n.current)==null?void 0:a.schema,j=(c=(l=y==null?void 0:y.data)==null?void 0:l.current)==null?void 0:c.schema,k=(m=(u=y==null?void 0:y.data)==null?void 0:u.current)==null?void 0:m.insertAdjacent,T=(p=(d=y==null?void 0:y.data)==null?void 0:d.current)==null?void 0:p.breakRemoveOn,O=(h=(g=y==null?void 0:y.data)==null?void 0:g.current)==null?void 0:h.wrapSchema,N=(_=(f=y==null?void 0:y.data)==null?void 0:f.current)==null?void 0:_.onSuccess,L=(C=(S=(v=y==null?void 0:y.data)==null?void 0:v.current)==null?void 0:S.removeParentsIfNoChildren)!=null?C:!0;if(!F||!j){e==null||e(i);return}if(F===j){e==null||e(i);return}if(F.parent===j&&k==="beforeEnd"){e==null||e(i);return}const D=createDesignable({t:r,api:o,refresh:({refreshParentSchema:R=!0}={})=>t({refreshParentSchema:R}),current:j});if(D.loadAPIClientEvents(),F.parent===j.parent){D.insertBeforeBeginOrAfterEnd(F),e==null||e(i);return}if(k){D.insertAdjacent(k,F,{wrap:O,breakRemoveOn:T,removeParentsIfNoChildren:L,onSuccess:N}),e==null||e(i);return}},[o,e,t,r])},InternalDndContext=import_react2.default.memo(e=>{const{t}=(0,import_react_i18next.useTranslation)(),[o,r]=(0,import_react2.useState)(!0),i=(0,import_react2.useCallback)(a=>{var l,c,u;const{active:m}=a,d=(c=(l=m==null?void 0:m.data)==null?void 0:l.current)==null?void 0:c.schema;r(!!d),e!=null&&e.onDragStart&&((u=e==null?void 0:e.onDragStart)==null||u.call(e,a))},[e==null?void 0:e.onDragStart]),n=useDragEnd(e==null?void 0:e.onDragEnd);return(0,import_jsx_runtime.jsxs)(import_core.DndContext,P(x({collisionDetection:import_core.rectIntersection},e),{onDragStart:i,onDragEnd:n,children:[(0,import_jsx_runtime.jsx)(import_core.DragOverlay,{dropAnimation:{duration:10,easing:"cubic-bezier(0.18, 0.67, 0.6, 1.22)"},children:o&&(0,import_jsx_runtime.jsx)("span",{style:{whiteSpace:"nowrap"},children:t("Dragging")})}),e.children]}))});InternalDndContext.displayName="InternalDndContext";const DndContext=e=>(0,import_jsx_runtime.jsx)(InternalDndContext,x({},e)),DraggableContext=(0,import_react2.createContext)(null);DraggableContext.displayName="DraggableContext";const SortableContext=(0,import_react2.createContext)(null);SortableContext.displayName="SortableContext";const SortableProvider=e=>{const{id:t,data:o,children:r}=e,i=(0,import_core.useDraggable)({id:t,data:o}),n=(0,import_core.useDroppable)({id:t,data:o}),a=(0,import_react2.useMemo)(()=>({draggable:i,droppable:n}),[i,n]);return(0,import_jsx_runtime.jsx)(SortableContext.Provider,{value:a,children:r})},getComputedColor=e=>new import_tinycolor.TinyColor(e).setAlpha(.15).toHex8String(),Sortable=e=>{var t,o;const r=e,{component:i,overStyle:n,style:a,children:l,openMode:c}=r,u=K(r,["component","overStyle","style","children","openMode"]),{token:m}=useToken(),{draggable:d,droppable:p}=(0,import_react2.useContext)(SortableContext),{isOver:g,setNodeRef:h}=p,f=x({},a);return g&&((t=d==null?void 0:d.active)==null?void 0:t.id)!==((o=p==null?void 0:p.over)==null?void 0:o.id)&&(f[i==="a"?"color":"background"]=getComputedColor(m.colorSettings),Object.assign(f,n)),import_react2.default.createElement(i||"div",P(x({role:"none"},u),{className:(0,import_css.cx)("nb-sortable-designer",e.className),ref:h,style:f}),l)},useSortableItemProps=e=>{const t=useSortableItemId(e),o=(0,import_react.useFieldSchema)();return e.schema?P(x({},e),{id:t}):P(x({},e),{id:t,schema:o})},useSortableItemId=e=>{var t;const o=(0,import_react.useField)();return e.id?e.id:(t=o.address)==null?void 0:t.toString()},InternalSortableItem=(0,import_react.observer)(e=>{const t=useSortableItemProps(e),{schema:o,id:r,eid:i,removeParentsIfNoChildren:n}=t,a=K(t,["schema","id","eid","removeParentsIfNoChildren"]),l=(0,import_react2.useMemo)(()=>({insertAdjacent:"afterEnd",schema:o,removeParentsIfNoChildren:n??!0}),[o,n]);return(0,import_jsx_runtime.jsx)(SortableProvider,{id:r,data:l,children:(0,import_jsx_runtime.jsx)(Sortable,P(x({id:i},a),{children:e.children}))})},{displayName:"InternalSortableItem"}),SortableItem=import_react2.default.memo(e=>{const t=e,{component:o}=t,r=K(t,["component"]),{designable:i}=useDesignable();return i?(0,import_jsx_runtime.jsx)(InternalSortableItem,x({},e)):import_react2.default.createElement(o||"div",import_lodash.default.omit(r,["children","schema","overStyle","openMode","id","eid","removeParentsIfNoChildren"]),e.children)});SortableItem.displayName="SortableItem";const DragHandler=e=>{const{draggable:t}=(0,import_react2.useContext)(SortableContext)||{};if(!t)return null;const{attributes:o,listeners:r,setNodeRef:i}=t;return(0,import_jsx_runtime.jsx)("div",{style:{display:"inline-block",width:14,height:14,lineHeight:"14px",textAlign:"left"},children:(0,import_jsx_runtime.jsx)("div",P(x(x({ref:i,style:{position:"relative",zIndex:1,lineHeight:0,fontSize:0,display:"inline-block"}},r),o),{role:"none",children:(0,import_jsx_runtime.jsx)("span",{style:{cursor:"move",fontSize:14},children:e.children})}))})},ShowFormData=(0,import_react.observer)(({children:e})=>{const t=(0,import_react.useForm)();return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)("pre",{style:{marginBottom:20},"data-testid":"form-data",children:JSON.stringify(t.values,null,2)}),e]})}),common=Object.freeze(Object.defineProperty({__proto__:null,DndContext,DragHandler,DraggableContext,ShowFormData,Sortable,SortableContext,SortableItem,SortableProvider,getRenderContent},Symbol.toStringTag,{value:"Module"})),requestChartData=e=>function(){return q(this,null,function*(){var t;try{const o=yield this.api.request(e);return(t=o==null?void 0:o.data)==null?void 0:t.data}catch{return[]}})},FormComponent$1=e=>{const t=e,{form:o,children:r}=t,i=K(t,["form","children"]),n=(0,import_react.useField)(),a=(0,import_react.useFieldSchema)(),l=useAttach(o.createVoidField(P(x({},n.props),{basePath:""})));return(0,import_jsx_runtime.jsx)(import_react.FieldContext.Provider,{value:void 0,children:(0,import_jsx_runtime.jsx)(import_react.FormContext.Provider,{value:o,children:(0,import_jsx_runtime.jsx)(import_antd_v5.FormLayout,P(x({layout:"vertical"},i),{children:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:l.address,schema:a,onlyRenderProperties:!0})}))})})},Def$1=e=>e.children,FormDecorator$1=e=>{const t=e,{form:o,children:r,disabled:i}=t,n=K(t,["form","children","disabled"]),a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)(),c=useAttach(o.createVoidField(P(x({},a.props),{basePath:""}))),u=useComponent(l["x-component"],Def$1);return(0,import_react2.useEffect)(()=>{o.disabled=i||a.disabled},[i,a.disabled]),(0,import_jsx_runtime.jsx)(import_antd.ConfigProvider,{componentDisabled:i,children:(0,import_jsx_runtime.jsx)(import_react.FieldContext.Provider,{value:void 0,children:(0,import_jsx_runtime.jsx)(import_react.FormContext.Provider,{value:o,children:(0,import_jsx_runtime.jsx)(import_antd_v5.FormLayout,P(x({layout:"vertical"},n),{children:(0,import_jsx_runtime.jsx)(import_react.FieldContext.Provider,{value:c,children:(0,import_jsx_runtime.jsx)(u,P(x({},a.componentProps),{children:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{basePath:c.address,schema:l,onlyRenderProperties:!0})}))})}))})})})},getRequestParams=e=>{const{request:t,initialValue:o}=e;return t||(()=>Promise.resolve({data:o}))},useDefaultValues=(e={},t={})=>useRequest(getRequestParams(t),e),FormBlockContext=(0,import_react2.createContext)(null);FormBlockContext.displayName="FormBlockContext";const Form$1=(0,import_react.observer)(e=>{const t=e,{request:o,effects:r,initialValue:i,useValues:n=useDefaultValues}=t,a=K(t,["request","effects","initialValue","useValues"]),l=(0,import_react.useFieldSchema)(),c=(0,import_react.useField)(),u=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)({effects:r}),[]),m=n({uid:l["x-uid"],onSuccess(p){return q(this,null,function*(){yield u.reset(),u.setValues(p==null?void 0:p.data),u.setInitialValues(p==null?void 0:p.data)})}},e),d=(0,import_react2.useContext)(FormBlockContext);return(0,import_jsx_runtime.jsx)(FormBlockContext.Provider,{value:{parent:d,form:u,result:m,field:c,fieldSchema:l},children:(0,import_jsx_runtime.jsx)(import_antd.Spin,{spinning:(m==null?void 0:m.loading)||!1,children:l["x-decorator"]==="Form"?(0,import_jsx_runtime.jsx)(FormDecorator$1,x({form:u},a)):(0,import_jsx_runtime.jsx)(FormComponent$1,x({form:u},a))})})},{displayName:"Form"});Form$1.Designer=function e(){const{name:t,title:o}=useCollection_deprecated(),r=useSchemaTemplate(),{componentNamePrefix:i}=useBlockTemplateContext();return(0,import_jsx_runtime.jsxs)(GeneralSchemaDesigner,{template:r,title:o||t,children:[(0,import_jsx_runtime.jsx)(SchemaSettingsTemplate,{componentName:`${i}Form`,collectionName:t}),(0,import_jsx_runtime.jsx)(SchemaSettingsDivider,{}),(0,import_jsx_runtime.jsx)(SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};const formV1Settings=new SchemaSettings({name:"FormV1Settings",items:[{name:"template",Component:SchemaSettingsTemplate,useComponentProps(){const{name:e}=useCollection_deprecated(),{componentNamePrefix:t}=useBlockTemplateContext();return{componentName:`${t}Form`,collectionName:e}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),FormDesigner=()=>{const{name:e,title:t}=useCollection_deprecated(),o=useSchemaTemplate();return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,{schemaSettings:"FormSettings",template:o,title:t||e})},ReadPrettyFormDesigner=()=>{const{name:e,title:t}=useCollection_deprecated(),o=useSchemaTemplate();return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,{schemaSettings:"ReadPrettyFormSettings",template:o,title:t||e})},DetailsDesigner=()=>{const{name:e,title:t}=useCollection_deprecated(),o=useSchemaTemplate();return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,{schemaSettings:"FormDetailsSettings",template:o,title:t||e})},FilterDesigner=()=>{const{name:e,title:t}=useCollection_deprecated(),o=useSchemaTemplate();return(0,import_jsx_runtime.jsx)(GeneralSchemaDesigner,{schemaSettings:"blockSettings:filterForm",template:o,title:t||e})},defaultFieldNames$1={label:"label",value:"value",color:"color",options:"children"};function flatData$1(e,t){const o=[];if(!Array.isArray(e))return o;for(let r=0;r<e.length;r++){const i=e[r][t.options];Array.isArray(i)&&o.push(...flatData$1(i,t)),o.push(x({},e[r]))}return o}function findOptions(e,t,o){if(!e)return[];const r=[];for(const i of o){const n=e.find(a=>a[t.value]==i)||{value:i,label:i&&i.toString()};r.push(n)}return r}function getCurrentOptions(e,t,o){const r=flatData$1(t,o),i=(0,import_lodash.castArray)(e).map(n=>(0,import_client.isPlainObject)(n)?n[o.value]:n);return findOptions(r,o,i)}const ReadPrettyInternal=(0,import_react.observer)(e=>{const[t,o]=(0,import_react2.useState)(!0),[r,i]=(0,import_react2.useState)([]),n=(0,import_react.useField)(),a=useCollectionField();return(0,import_react2.useEffect)(()=>{var l;const c=x(x({},defaultFieldNames$1),e.fieldNames),u=n.dataSource||e.options||(a==null?void 0:a.uiSchema.enum)||[],m=getCurrentOptions(n.value,u,c);if(!(0,import_shared.isValid)(e.value)&&!m.length||(0,import_core2.isArrayField)(n)&&((l=n==null?void 0:n.value)==null?void 0:l.length)===0)return;const d=n.value!==null&&m.map((p,g)=>(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:p[c.color],icon:p.icon,children:p[c.label]},g));i(d),o(!1)},[a==null?void 0:a.uiSchema.enum,n,n.dataSource,n.value,e.fieldNames,e.options,e.value]),t?null:(0,import_jsx_runtime.jsx)(EllipsisWithTooltip,{ellipsis:e.ellipsis,children:r})},{displayName:"SelectReadPretty"}),ReadPretty$b=withPopupWrapper(ReadPrettyInternal),isEmptyObject=e=>!(0,import_shared.isValid)(e)||typeof e=="object"&&Object.keys(e).length===0,ObjectSelect=e=>{const t=e,{value:o,options:r,onChange:i,fieldNames:n,mode:a,loading:l,rawOptions:c,defaultValue:u}=t,m=K(t,["value","options","onChange","fieldNames","mode","loading","rawOptions","defaultValue"]),d=p=>{var g;if(isEmptyObject(p))return;const h=(0,import_shared.toArr)(p).filter(_=>_).map(_=>(0,import_client.isPlainObject)(_)?_[n.value]:_),f=(g=getCurrentOptions(h,r,n))==null?void 0:g.map(_=>({label:_[n.label],value:_[n.value]}));return["tags","multiple"].includes(a)||e.multiple?f:f.shift()};return(0,import_jsx_runtime.jsx)(import_antd.Select,x({role:"button","data-testid":`select-object-${a||"single"}`,value:d(o),defaultValue:d(u),allowClear:{clearIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseCircleFilled,{role:"button","aria-label":"icon-close-select"})},labelInValue:!0,notFoundContent:l?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(0,import_jsx_runtime.jsx)(import_antd.Empty,{image:import_antd.Empty.PRESENTED_IMAGE_SIMPLE}),options:r,fieldNames:n,showSearch:!0,popupMatchSelectWidth:!1,filterOption:(p,g)=>{var h;return((h=g==null?void 0:g[n.label||"label"])!=null?h:"").includes(p)},filterSort:(p,g)=>{var h,f;return((h=p==null?void 0:p[n.label||"label"])!=null?h:"").toLowerCase().localeCompare(((f=g==null?void 0:g[n.label||"label"])!=null?f:"").toLowerCase())},onChange:p=>{const g=getCurrentOptions((0,import_shared.toArr)(p).map(h=>h.value),c||r,n);["tags","multiple"].includes(a)||e.multiple?i==null||i(g):i==null||i(g.shift()||null)},mode:a,tagRender:p=>(0,import_jsx_runtime.jsx)(import_antd.Tag,P(x({role:"button","aria-label":p.label,closeIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseOutlined,{role:"button","aria-label":"icon-close-tag"})},p),{children:p.label})),maxTagCount:"responsive"},m))},filterOption=(e,t)=>{var o;return((o=t==null?void 0:t.label)!=null?o:"").toLowerCase().includes((e||"").toLowerCase())},InternalSelect=(0,import_react.connect)(e=>{const t=e,{objectValue:o,loading:r,value:i,rawOptions:n,defaultValue:a}=t,l=K(t,["objectValue","loading","value","rawOptions","defaultValue"]),c=useCompile();let u=e.multiple?"multiple":e.mode;if(u&&!["multiple","tags"].includes(u)&&(u=void 0),o)return(0,import_jsx_runtime.jsx)(ObjectSelect,P(x({rawOptions:n},l),{defaultValue:a,value:i,mode:u,loading:r}));const m=d=>["tags","multiple"].includes(e.mode)||e.multiple?d?(0,import_shared.toArr)(d):void 0:d;return(0,import_jsx_runtime.jsx)(import_antd.Select,P(x({role:"button","data-testid":`select-${u||"single"}`,showSearch:!0,filterOption,allowClear:{clearIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseCircleFilled,{role:"button","aria-label":"icon-close-select"})},popupMatchSelectWidth:!1,notFoundContent:r?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(0,import_jsx_runtime.jsx)(import_antd.Empty,{image:import_antd.Empty.PRESENTED_IMAGE_SIMPLE}),value:m(i),defaultValue:m(a),tagRender:d=>(0,import_jsx_runtime.jsx)(import_antd.Tag,P(x({role:"button","aria-label":d.label,closeIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseOutlined,{role:"button","aria-label":"icon-close-tag"})},d),{children:d.label}))},c(l)),{onChange:d=>{var p;(p=e.onChange)==null||p.call(e,d===void 0?null:d)},mode:u,maxTagCount:"responsive"}))},(0,import_react.mapProps)({dataSource:"options"},(e,t)=>P(x({},e),{fieldNames:x(x({},defaultFieldNames$1),e.fieldNames),suffixIcon:t!=null&&t.loading||t!=null&&t.validating?(0,import_jsx_runtime.jsx)(import_icons.LoadingOutlined,{}):e.suffixIcon})),(0,import_react.mapReadPretty)(ReadPretty$b)),Select=InternalSelect;Select.ReadPretty=ReadPretty$b;const getValues=(e,t)=>(0,import_lodash.castArray)(e).filter(o=>o!=null).map(o=>typeof o=="object"?o[t.value]:o),ReadPretty$a=(0,import_react.observer)(e=>{const t=x(x({},defaultFieldNames$1),e.fieldNames),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),i=useRecord(),{snapshot:n}=useActionContext(),{data:a}=useRequest(n?()=>q(void 0,null,function*(){return{data:i[r.name]}}):P(x({action:"list"},e.service),{params:{paginate:!1,filter:{[t.value]:{$in:getValues(o.value,t)}}}}),{refreshDeps:[e.service,o.value]});return(0,import_jsx_runtime.jsx)(Select.ReadPretty,P(x({},e),{options:a==null?void 0:a.data}))},{displayName:"ReadPretty"}),EMPTY$1="N/A",InternalRemoteSelect=withDynamicSchemaProps((0,import_react.connect)(e=>{var t,o;const r=e,{fieldNames:i={},service:n={},wait:a=300,value:l,defaultValue:c,objectValue:u,manual:m=!0,mapOptions:d,targetField:p,CustomDropdownRender:g,optionFilter:h,dataSource:f,toOptionsItem:_=H=>H,popupMatchSelectWidth:v=!1}=r,S=K(r,["fieldNames","service","wait","value","defaultValue","objectValue","manual","mapOptions","targetField","CustomDropdownRender","optionFilter","dataSource","toOptionsItem","popupMatchSelectWidth"]),C=useDataSourceKey(),b=useDataSourceHeaders(f||C),[y,F]=(0,import_react2.useState)(!1),j=(0,import_react2.useRef)(!1),k=(0,import_react.useFieldSchema)(),T=((t=k["x-component-props"])==null?void 0:t.addMode)==="quickAdd",{getField:O}=useCollection_deprecated(),N=(0,import_react2.useRef)(null),{getCollectionJoinField:L,getInterface:D}=useCollectionManager_deprecated(),R=k["x-collection-field"]||k.name,$=O(R)||L(R),w=p||($==null?void 0:$.target)&&(i==null?void 0:i.label)&&L(`${$.target}.${i.label}`),I=(0,import_react2.useMemo)(()=>{var H;if(w!=null&&w.interface){const J=D(w.interface),X=((H=J==null?void 0:J.filterable)==null?void 0:H.operators[0].value)||"$includes";return w.type==="string"?"$includes":X}return"$includes"},[w]),M=useCompile(),B=(0,import_react2.useCallback)(H=>{try{return H.filter(J=>["number","string"].includes(typeof J[i.value])||!J[i.value]).map(J=>{var X;let Q=M(J[i.label]);if((X=w==null?void 0:w.uiSchema)!=null&&X.enum)if(Array.isArray(Q))Q=Q.map((ee,te)=>{const ne=w.uiSchema.enum.find(ae=>ae.value===ee);return ne?(0,import_jsx_runtime.jsx)(import_antd.Tag,{role:"button",color:ne.color,style:{marginRight:3},children:(ne==null?void 0:ne.label)||ee},te):(0,import_jsx_runtime.jsx)(import_antd.Tag,{role:"button",children:ee},ee)}).reverse();else{const ee=w.uiSchema.enum.find(te=>te.value===Q);ee&&(Q=(0,import_jsx_runtime.jsx)(import_antd.Tag,{role:"button",color:ee.color,children:ee.label}))}return(w==null?void 0:w.type)==="date"&&(Q=(0,import_dayjs.default)(Q).format("YYYY-MM-DD")),d?d({[i.label]:Q||EMPTY$1,[i.value]:J[i.value]}):P(x({},J),{[i.label]:Q||EMPTY$1,[i.value]:J[i.value]})}).filter(Boolean)}catch(J){return console.error(J),H}},[w==null?void 0:w.uiSchema,i]),{data:z,run:E,loading:V}=useRequest(P(x({action:"list"},n),{headers:b,params:P(x({pageSize:200},n==null?void 0:n.params),{filter:(o=n==null?void 0:n.params)==null?void 0:o.filter})}),x({manual:m,debounceWait:a},n.defaultParams?{defaultParams:[n.defaultParams]}:{})),U=(0,import_react2.useMemo)(()=>JSON.stringify({service:n,fieldNames:i}),[n,i]),G=(0,import_react2.useCallback)(()=>N.current&&g?(0,import_jsx_runtime.jsx)(g,{search:N.current,callBack:()=>{N.current=null,F(!1)}}):null,[N.current]);(0,import_react2.useEffect)(()=>{j.current&&E()},[U]);const W=H=>q(void 0,null,function*(){var J;E({filter:mergeFilter([H?{[i.label]:{[I]:H}}:{},(J=n==null?void 0:n.params)==null?void 0:J.filter])}),N.current=H}),Y=(0,import_react2.useMemo)(()=>{var H;const J=l||c;if(!((H=z==null?void 0:z.data)!=null&&H.length))return J!=null?Array.isArray(J)?J:[J]:[];const X=J!=null&&(Array.isArray(J)?J.map(ee=>P(x({},ee),{[i.value]:ee[i.value]||ee})):[P(x({},J),{[i.value]:J[i.value]||J})])||[],Q=typeof h=="function"?z.data.filter(h):z.data;return(0,import_lodash.uniqBy)(Q.concat(X??[]),i.value)},[l,c,z==null?void 0:z.data,i.value,h]);return(0,import_jsx_runtime.jsx)(Select,P(x({open:y,popupMatchSelectWidth:v,autoClearSearchValue:!0,filterOption:!1,filterSort:null,fieldNames:i,onSearch:W,onDropdownVisibleChange:H=>{F(H),N.current=null,H&&E(),j.current=!0},objectValue:u,value:l,defaultValue:c},S),{loading:z?V:!0,options:_(B(Y)),rawOptions:Y,dropdownRender:H=>{const J=Y.some(X=>X[i.label]===N.current);return(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:T?(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[!((z==null?void 0:z.data.length)===0&&N!=null&&N.current)&&H,(z==null?void 0:z.data.length)>0&&(N==null?void 0:N.current)&&!J&&(0,import_jsx_runtime.jsx)(import_antd.Divider,{style:{margin:0}}),!J&&(0,import_jsx_runtime.jsx)(G,{})]}):H})}}))},(0,import_react.mapProps)({dataSource:"options"},(e,t)=>{var o;const r=(0,import_react.useFieldSchema)();return P(x({},e),{fieldNames:x(x(x(x({},defaultFieldNames$1),e.fieldNames),t.componentProps.fieldNames),(o=r["x-component-props"])==null?void 0:o.fieldNames),suffixIcon:t!=null&&t.loading||t!=null&&t.validating?(0,import_jsx_runtime.jsx)(import_icons.LoadingOutlined,{}):e.suffixIcon})}),(0,import_react.mapReadPretty)(ReadPretty$a))),RemoteSelect=InternalRemoteSelect;RemoteSelect.ReadPretty=ReadPretty$a;const useFormDataTemplates=()=>{const e=(0,import_react.useFieldSchema)(),{t}=(0,import_react_i18next.useTranslation)(),{duplicateData:o}=useFormBlockContext(),{getCollectionJoinField:r}=useCollectionManager_deprecated();if(o)return o;const{items:i=[],display:n=!0}=findDataTemplates(e);i.forEach(c=>{var u;try{c.fields=(u=c.fields)==null?void 0:u.map(m=>r(`${c.collection}.${m}`)?m:"").filter(Boolean)}catch(m){(0,import_client.error)(m),c.fields=[]}});const a=[{key:"none",title:t("None")}].concat(i.map((c,u)=>P(x({key:u},c),{isLeaf:c.dataId!==null&&c.dataId!==void 0,titleCollectionField:(c==null?void 0:c.titleField)&&r(`${c.collection}.${c.titleField}`)}))),l=i.find(c=>c.default);return{templates:a,display:n,defaultTemplate:l,enabled:i.length>0&&i.every(c=>c.dataId||c.dataScope)}},Templates=import_react2.default.memo(({style:e={},form:t})=>{const{token:o}=useToken(),{templates:r,display:i,enabled:n,defaultTemplate:a}=useFormDataTemplates(),{getCollectionJoinField:l}=useCollectionManager_deprecated(),c=compatibleDataId(r),[u,m]=(0,import_react2.useState)((a==null?void 0:a.key)||"none"),[d,p]=(0,import_react2.useState)(null),g=useAPIClient(),{t:h}=(0,import_react_i18next.useTranslation)(),f=useDataSourceKey(),_=useDataSourceHeaders(f);(0,import_react2.useEffect)(()=>{n&&a&&t&&(t.__template=!0,a.key==="duplicate"&&b(a.dataId,a,_))},[]),(0,import_react2.useEffect)(()=>{c!=null&&c.some(F=>F.key===u)||C("none")},[c]);const v=(0,import_react2.useMemo)(()=>x({display:"flex",alignItems:"center",backgroundColor:o.colorFillAlter,padding:o.padding},e),[e,o.colorFillAlter]),S=(0,import_react2.useMemo)(()=>({fontSize:o.fontSize,fontWeight:"bold",whiteSpace:"nowrap",marginRight:o.marginXS}),[o.fontSize,o.marginXS]),C=(0,import_react2.useCallback)(F=>q(void 0,null,function*(){m(F),p(null),t==null||t.reset()}),[]),b=(0,import_react2.useCallback)((F,j,k)=>q(void 0,null,function*(){const T=P(x({},j),{dataId:F});p(j),fetchTemplateData(g,T,k).then(O=>(t&&O&&(t.reset(),t.__template=!0,(0,import_client.forEach)(O,(N,L)=>{var D;N&&(t.values[L]=N,(D=t==null?void 0:t.setInitialValuesIn)==null||D.call(t,L,N))})),O)).catch(O=>{console.error(O)})}),[]);if(!n||!i)return null;const y=c==null?void 0:c.find(F=>F.key===u);return(0,import_jsx_runtime.jsx)("div",{style:v,children:(0,import_jsx_runtime.jsxs)(import_antd.Space,{wrap:!0,children:[(0,import_jsx_runtime.jsxs)("label",{style:S,children:[h("Data template"),": "]}),(0,import_jsx_runtime.jsx)(import_antd.Select,{role:"button","data-testid":"select-form-data-template",popupMatchSelectWidth:!1,options:c,fieldNames:{label:"title",value:"key"},value:u,onChange:C}),u!=="none"&&y&&(0,import_jsx_runtime.jsx)(RemoteSelect,{style:{width:220},fieldNames:{label:y==null?void 0:y.titleField,value:"id"},target:y==null?void 0:y.collection,value:d,objectValue:!0,service:{resource:y==null?void 0:y.collection,params:{filter:y==null?void 0:y.dataScope}},onChange:F=>b(F==null?void 0:F.id,x(x({},F),y),_),targetField:l(`${y==null?void 0:y.collection}.${y.titleField}`)})]})})});Templates.displayName="NocoBaseFormDataTemplates";function findDataTemplates(e){const t=findFormBlock(e);return t?import_lodash.default.cloneDeep(t["x-data-templates"])||{}:{}}function fetchTemplateData(e,t,o){return q(this,null,function*(){if(!(t.fields.length===0||!t.dataId))return e.resource(t.collection,void 0,o).get({filterByTk:t.dataId,fields:t.fields,isTemplate:!0}).then(r=>{var i;return(i=r.data)==null?void 0:i.data})})}const useFormBlockHeight=()=>{var e,t,o;const r=useDataBlockHeight(),i=(0,import_react.useFieldSchema)(),{token:n}=import_antd.theme.useToken(),{designable:a}=useDesignable(),{heightProps:l}=useBlockHeightProps()||{},{title:c}=l||{},{display:u,enabled:m}=useFormDataTemplates(),d=i.reduceProperties((y,F)=>F["x-component"]==="ActionBar"?F:y),p=Object.keys((d==null?void 0:d.properties)||{}).length>0,g=(o=(t=(e=i==null?void 0:i.parent)==null?void 0:e["x-decorator"])==null?void 0:t.includes)==null?void 0:o.call(t,"FormBlockProvider"),h=p||a?n.controlHeight+(g?1:2)*n.marginLG:n.marginLG,f=c?n.fontSizeLG*n.lineHeightLG+n.padding*2-1:0,_=useDataBlockRequestData(),{count:v,pageSize:S}=(_==null?void 0:_.meta)||{},C=v>S?n.controlHeightSM+1*n.paddingLG:0,b=u&&m?n.controlHeight+2*n.padding+n.margin:0;return r-h-n.paddingLG-f-C-b},FormComponent=e=>{const t=e,{form:o,children:r}=t,i=K(t,["form","children"]),n=(0,import_react.useField)(),a=(0,import_react.useFieldSchema)(),l=getCardItemSchema==null?void 0:getCardItemSchema(a),c=useAttach(o.createVoidField(P(x({},n.props),{basePath:""}))),u=useFormBlockHeight(),{token:m}=import_antd.theme.useToken(),{layout:d="vertical",labelAlign:p="left",labelWidth:g=120,labelWrap:h=!0}=(l==null?void 0:l["x-component-props"])||{};return(0,import_jsx_runtime.jsx)(import_react.FieldContext.Provider,{value:void 0,children:(0,import_jsx_runtime.jsx)(import_react.FormContext.Provider,{value:o,children:(0,import_jsx_runtime.jsx)(import_antd_v5.FormLayout,P(x({layout:d},i),{labelAlign:p,labelWidth:d==="horizontal"?g:null,labelWrap:h,children:(0,import_jsx_runtime.jsx)("div",{className:import_css.css`
595
595
  .nb-grid-container {
596
596
  height: ${u?u+"px":"100%"};
597
597
  overflow-y: auto;
@@ -1328,7 +1328,7 @@ https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModu
1328
1328
  const targetValue = field.query('.min').value();
1329
1329
  field.selfErrors =
1330
1330
  !!targetValue && !!field.value && targetValue > field.value ? '${i18n.t("Max length must greater than min length")}' : ''
1331
- }}}`},min:{type:"number",title:'{{ t("Min length") }}',minimum:0,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0},"x-reactions":{dependencies:[".max"],fulfill:{state:{selfErrors:`{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t("Min length must less than max length")}' : ''}}`}}}}})),A(this,"filterable",{operators:string})}schemaInitialize(t,{block:o}){["Table","Kanban"].includes(o)&&(t["x-component-props"]=t["x-component-props"]||{},t["x-component-props"].ellipsis=!0)}}class TimeFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","time"),A(this,"type","object"),A(this,"group","datetime"),A(this,"order",4),A(this,"title",'{{t("Time")}}'),A(this,"sortable",!0),A(this,"default",{type:"time",uiSchema:{type:"string","x-component":"TimePicker"}}),A(this,"availableTypes",["time"]),A(this,"hasDefaultValue",!0),A(this,"properties",P(x({},defaultProps),{"uiSchema.x-component-props.format":{type:"string",title:'{{t("Time format")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:"HH:mm:ss",enum:[{label:'{{t("12 hour")}}',value:"hh:mm:ss a"},{label:'{{t("24 hour")}}',value:"HH:mm:ss"}]}})),A(this,"filterable",{operators:time}),A(this,"titleUsable",!0)}}class UpdatedAtFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","updatedAt"),A(this,"type","object"),A(this,"group","systemInfo"),A(this,"order",2),A(this,"title",'{{t("Last updated at")}}'),A(this,"sortable",!0),A(this,"default",{type:"date",field:"updatedAt",uiSchema:{type:"string",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}),A(this,"availableTypes",[]),A(this,"properties",x(x({},defaultProps),dateTimeProps)),A(this,"filterable",{operators:datetime}),A(this,"titleUsable",!0)}}class UpdatedByFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","updatedBy"),A(this,"type","object"),A(this,"group","systemInfo"),A(this,"order",4),A(this,"title",'{{t("Last updated by")}}'),A(this,"isAssociation",!0),A(this,"default",{type:"belongsTo",target:"users",foreignKey:"updatedById",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}),A(this,"availableTypes",["belongsTo"]),A(this,"properties",x({},defaultProps)),A(this,"filterable",{nested:!0,children:[]})}schemaInitialize(t,{block:o}){t.properties={viewer:(0,import_lodash.cloneDeep)(recordPickerViewer)},["Table","Kanban"].includes(o)&&(t["x-component-props"]=t["x-component-props"]||{},t["x-component-props"].ellipsis=!0)}}class UrlFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","url"),A(this,"type","string"),A(this,"group","basic"),A(this,"order",5),A(this,"title",'{{t("URL")}}'),A(this,"default",{type:"text",uiSchema:{type:"string","x-component":"Input.URL"}}),A(this,"componentOptions",[{label:"URL",value:"Input.URL"},{label:"Preview",value:"Input.Preview"}]),A(this,"availableTypes",["string","text"]),A(this,"properties",x({},defaultProps)),A(this,"titleUsable",!0),A(this,"filterable",{operators:string})}schemaInitialize(t,{block:o}){}}class UUIDFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","uuid"),A(this,"type","object"),A(this,"group","advanced"),A(this,"order",0),A(this,"title",'{{t("UUID")}}'),A(this,"hidden",!1),A(this,"sortable",!0),A(this,"default",{type:"uuid",uiSchema:{type:"string","x-component":"Input","x-validator":"uuid"}}),A(this,"availableTypes",["uid","uuid"]),A(this,"properties",{"uiSchema.title":{type:"string",title:'{{t("Field display name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Field name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input","x-disabled":"{{ !createOnly }}",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"},autoFill,layout:{type:"void",title:'{{t("Index")}}',"x-component":"Space","x-decorator":"FormItem","x-decorator-props":{style:{marginBottom:"0px"}},properties:{primaryKey,unique}}}),A(this,"filterable",{operators:string}),A(this,"titleUsable",!0)}}class NanoidFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","nanoid"),A(this,"type","object"),A(this,"group","advanced"),A(this,"order",0),A(this,"title",'{{t("Nano ID")}}'),A(this,"hidden",!1),A(this,"sortable",!0),A(this,"default",{type:"nanoid",uiSchema:{type:"string","x-component":"NanoIDInput"}}),A(this,"availableTypes",["nanoid"]),A(this,"properties",{"uiSchema.title":{type:"string",title:'{{t("Field display name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Field name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input","x-disabled":"{{ !createOnly }}",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"},customAlphabet:{type:"string",title:'{{t("Alphabet")}}',default:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","x-decorator":"FormItem","x-component":"Input"},size:{type:"number",title:'{{t("Length")}}',default:21,"x-decorator":"FormItem","x-component":"InputNumber"},autoFill,layout:{type:"void",title:'{{t("Index")}}',"x-component":"Space","x-decorator":"FormItem","x-decorator-props":{style:{marginBottom:"0px"}},properties:{primaryKey,unique}}}),A(this,"filterable",{operators:string}),A(this,"titleUsable",!0)}}class UnixTimestampFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","unixTimestamp"),A(this,"type","object"),A(this,"group","datetime"),A(this,"order",4),A(this,"title",'{{t("Unix Timestamp")}}'),A(this,"sortable",!0),A(this,"default",{type:"unixTimestamp",accuracy:"second",timezone:!0,defaultToCurrentTime:!1,onUpdateToCurrentTime:!1,uiSchema:{type:"number","x-component":"UnixTimestamp","x-component-props":{showTime:!0}}}),A(this,"availableTypes",["unixTimestamp"]),A(this,"hasDefaultValue",!1),A(this,"properties",P(x(x({},defaultProps),dateTimeProps),{accuracy:{type:"string",title:'{{t("Accuracy")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:"second",enum:[{value:"millisecond",label:'{{t("Millisecond")}}'},{value:"second",label:'{{t("Second")}}'}]},defaultToCurrentTime:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Default value to current time")}}'},onUpdateToCurrentTime:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Automatically update timestamp on update")}}'}})),A(this,"filterable",{operators:datetime}),A(this,"titleUsable",!0)}}class DateFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","date"),A(this,"type","object"),A(this,"group","datetime"),A(this,"order",3),A(this,"title",'{{t("DateOnly")}}'),A(this,"sortable",!0),A(this,"default",{type:"dateOnly",uiSchema:{type:"string","x-component":"DatePicker","x-component-props":{dateOnly:!0}}}),A(this,"availableTypes",["dateOnly"]),A(this,"hasDefaultValue",!0),A(this,"properties",P(x(x({},defaultProps),dateTimeProps),{"uiSchema.x-component-props.showTime":{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-visible":!1}})),A(this,"filterable",{operators:datetime}),A(this,"titleUsable",!0)}}class DatetimeNoTzFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","datetimeNoTz"),A(this,"type","object"),A(this,"group","datetime"),A(this,"order",2),A(this,"title",'{{t("Datetime (without time zone)")}}'),A(this,"sortable",!0),A(this,"default",{type:"datetimeNoTz",defaultToCurrentTime:!1,onUpdateToCurrentTime:!1,timezone:!1,uiSchema:{type:"string","x-component":"DatePicker","x-component-props":{showTime:!1,utc:!1}}}),A(this,"availableTypes",["string","datetimeNoTz"]),A(this,"hasDefaultValue",!0),A(this,"properties",P(x(x({},defaultProps),dateTimeProps),{defaultToCurrentTime:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Default value to current server time")}}'},onUpdateToCurrentTime:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Automatically update timestamp to the current server time on update")}}'},"uiSchema.x-component-props.gmt":{type:"boolean",title:'{{t("GMT")}}',"x-hidden":!0,"x-component":"Checkbox","x-content":'{{t("Use the same time zone (GMT) for all users")}}',"x-decorator":"FormItem",default:!1}})),A(this,"filterable",{operators:datetime}),A(this,"titleUsable",!0)}}class InheritanceCollectionMixin extends Collection{constructor(){super(...arguments),A(this,"parentCollectionsName"),A(this,"parentCollections"),A(this,"childrenCollections",{}),A(this,"childrenCollectionsName",{}),A(this,"inheritsFields"),A(this,"currentFields"),A(this,"allFields"),A(this,"parentCollectionFields",{}),A(this,"allCollectionsInheritChain"),A(this,"inheritCollectionsChain"),A(this,"foreignKeyFields")}getParentCollectionsName(){if(this.parentCollectionsName)return this.parentCollectionsName.slice();const t=[],o=r=>{const i=this.collectionManager.getCollection(r);if(i){const{inherits:n}=i;if(n)for(let a=0;a<n.length;a++){const l=n[a];t.push(l),o(l)}}return(0,import_lodash.uniq)(t)};return this.parentCollectionsName=o(this.name),this.parentCollectionsName}getParentCollections(){return this.parentCollections?this.parentCollections.slice():(this.parentCollections=this.getParentCollectionsName().map(t=>this.collectionManager.getCollection(t)),this.parentCollections)}getChildrenCollectionsName(t=!1){const o=t?"supportView":"notSupportView";if(this.childrenCollectionsName[o])return this.childrenCollectionsName[o].slice();const r=[],i=this.collectionManager.getCollections(),n=a=>(i.filter(l=>{var c;return(c=l.inherits)==null?void 0:c.includes(a)}).forEach(l=>{const c=l.name;return r.push(c),n(c)}),t&&i.filter(l=>{var c;return((c=l.sources)==null?void 0:c.length)===1&&(l==null?void 0:l.sources[0])===a}).forEach(l=>{const c=l.name;return r.push(l.name),n(c)}),(0,import_lodash.uniq)(r));return this.childrenCollectionsName[o]=n(this.name),this.childrenCollectionsName[o]}getChildrenCollections(t=!1){const o=t?"supportView":"notSupportView";return this.childrenCollections[o]?this.childrenCollections[o].slice():(this.childrenCollections[o]=this.getChildrenCollectionsName(t).map(r=>this.collectionManager.getCollection(r)),this.childrenCollections[o])}getInheritedFields(){if(this.inheritsFields)return this.inheritsFields.slice();const t=this.getParentCollectionsName();return this.inheritsFields=t.map(o=>{var r;return(r=this.collectionManager.getCollection(o))==null?void 0:r.getFields()}).flat().filter(Boolean),this.inheritsFields}getFieldsMap(){return this.fieldsMap?this.fieldsMap:(this.fieldsMap=this.getAllFields().reduce((t,o)=>(t[o.name]=o,t),{}),this.fieldsMap)}getCurrentFields(t){return super.getFields(t)}getParentCollectionFields(t){if(this.parentCollectionFields||(this.parentCollectionFields={}),this.parentCollectionFields[t])return this.parentCollectionFields[t];const o=this.getCurrentFields(),r=this.getParentCollectionsName(),i=this.collectionManager.getCollection(t).getCurrentFields(),n=r.indexOf(t);let a=o;return n>0&&(r.splice(n),r.forEach(l=>{const c=this.collectionManager.getCollection(l);a=a.concat(c.getCurrentFields())})),this.parentCollectionFields[t]=i.filter(l=>a.find(c=>c.name===l.name).collectionName!==this.name),this.parentCollectionFields[t]}getAllCollectionsInheritChain(){if(this.allCollectionsInheritChain)return this.allCollectionsInheritChain.slice();const t=[this.name],o=r=>{const i=this.collectionManager.getCollection(r);if(i){const{inherits:n}=i,a=i.getChildrenCollectionsName();if(n)for(let l=0;l<n.length;l++){const c=n[l];t.includes(c)||(t.push(c),o(c))}if(a)for(let l=0;l<a.length;l++){const c=this.collectionManager.getCollection(a[l]).name;t.includes(c)||(t.push(c),o(c))}}return t};return this.allCollectionsInheritChain=o(this.name),this.allCollectionsInheritChain||[]}getInheritCollectionsChain(){if(this.inheritCollectionsChain)return this.inheritCollectionsChain.slice();const t=[this.name],o=r=>{const i=this.collectionManager.getCollection(r);if(i){const{inherits:n}=i;if(n)for(let a=0;a<n.length;a++){const l=n[a];t.includes(l)||(t.push(l),o(l))}}return t};return this.inheritCollectionsChain=o(this.name),this.inheritCollectionsChain}getAllFields(t){if(this.allFields)return this.allFields.slice();const o=this.getCurrentFields(),r=this.getInheritedFields(),i=(0,import_lodash.unionBy)((o==null?void 0:o.concat(r))||[],"name");return this.allFields=i,t?(0,import_lodash.filter)(i,t):i}getForeignKeyFields(){if(this.foreignKeyFields)return this.foreignKeyFields.slice();const t=this.getCurrentFields(),o=this.getInheritedFields();return(0,import_lodash.unionBy)((t==null?void 0:t.concat(o))||[],"name")}}class GeneralCollectionTemplate extends CollectionTemplate{constructor(){super(...arguments),A(this,"name","general"),A(this,"title",'{{t("General collection")}}'),A(this,"order",1),A(this,"color","blue"),A(this,"default",{fields:[]}),A(this,"configurableProperties",getConfigurableProperties("title","name","inherits","category","description","simplePaginate","presetFields"))}}class TreeCollectionTemplate extends CollectionTemplate{constructor(){super(...arguments),A(this,"name","tree"),A(this,"title",'{{t("Tree collection")}}'),A(this,"order",3),A(this,"color","blue"),A(this,"default",{tree:"adjacencyList",fields:[{interface:"integer",name:"parentId",type:"bigInt",isForeignKey:!0,uiSchema:{type:"number",title:'{{t("Parent ID")}}',"x-component":"InputNumber","x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"parent",foreignKey:"parentId",treeParent:!0,onDelete:"CASCADE",uiSchema:{title:'{{t("Parent")}}',"x-component":"AssociationField","x-component-props":{multiple:!1,fieldNames:{label:"id",value:"id"}}}},{interface:"o2m",type:"hasMany",name:"children",foreignKey:"parentId",treeChildren:!0,onDelete:"CASCADE",uiSchema:{title:'{{t("Children")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{label:"id",value:"id"}}}}]}),A(this,"presetFieldsDisabledIncludes",["id"]),A(this,"events",{beforeSubmit(t){Array.isArray(t==null?void 0:t.fields)&&(t==null||t.fields.map(o=>{!o.target&&["belongsToMany","belongsTo","hasMany","hasOne"].includes(o.type)&&(o.target=t.name)}))}}),A(this,"configurableProperties",getConfigurableProperties("title","name","inherits","category","description","presetFields"))}}class ViewCollectionTemplate extends CollectionTemplate{constructor(){super(...arguments),A(this,"name","view"),A(this,"title",'{{t("Connect to database view")}}'),A(this,"order",4),A(this,"color","yellow"),A(this,"default",{fields:[]}),A(this,"divider",!0),A(this,"configurableProperties",x({title:{type:"string",title:'{{ t("Collection display name") }}',required:!0,"x-decorator":"FormItem","x-component":"Input"},databaseView:{title:'{{t("Connect to database view")}}',type:"single",required:!0,"x-decorator":"FormItem","x-component":"Select","x-reactions":["{{useAsyncDataSource(loadDBViews)}}"],"x-disabled":"{{ !createOnly }}","x-visible":"{{!createMainOnly}}"},name:{type:"string",title:'{{t("Collection name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input","x-validator":"uid",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}","x-reactions":{dependencies:["databaseView"],when:"{{isPG}}",fulfill:{state:{initialValue:"{{$deps[0]&&$deps[0].match(/^([^_]+)_(.*)$/)?.[2]}}"}},otherwise:{state:{value:null}}}},schema:{type:"string","x-hidden":!0,"x-reactions":{dependencies:["databaseView"],when:"{{isPG}}",fulfill:{state:{value:"{{$deps[0].split('@')?.[0]}}"}},otherwise:{state:{value:null}}}},viewName:{type:"string","x-hidden":!0,"x-reactions":{dependencies:["databaseView"],when:"{{isPG}}",fulfill:{state:{value:"{{$deps[0].split('@')?.[1]}}"}},otherwise:{state:{value:"{{$deps[0]}}"}}}},writableView:{type:"boolean","x-content":'{{t("Allow add new, update and delete actions")}}',"x-decorator":"FormItem","x-component":"Checkbox",default:!1,"x-visible":"{{!createMainOnly}}"},sources:{type:"array",title:'{{ t("Source collections") }}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0},"x-reactions":["{{useAsyncDataSource(loadCollections)}}"],"x-disabled":!0,"x-visible":"{{!createMainOnly}}"},fields:{type:"array","x-component":PreviewFields,"x-hidden":"{{ !createOnly }}","x-decorator":"FormItem","x-reactions":{dependencies:["name"],fulfill:{schema:{"x-component-props":"{{$form.values}}"}}},description:'{{t("Fields can only be used correctly if they are defined with an interface.")}}'},preview:{type:"void","x-visible":"{{ createOnly }}","x-component":PreviewTable$1,"x-reactions":{dependencies:["name","fields"],fulfill:{schema:{"x-component-props":"{{$form.values}}"}}}},filterTargetKey:{title:'{{ t("Record unique key")}}',type:"single",description:'{{t( "If a collection lacks a primary key, you must configure a unique record key to locate row records within a block, failure to configure this will prevent the creation of data blocks for the collection.")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0},"x-reactions":["{{useAsyncDataSource(loadFilterTargetKeys)}}"]}},getConfigurableProperties("category","description")))}}class SqlCollectionTemplate extends CollectionTemplate{constructor(){super(...arguments),A(this,"name","sql"),A(this,"title",'{{t("SQL collection")}}'),A(this,"order",4),A(this,"color","yellow"),A(this,"default",{fields:[]}),A(this,"configurableProperties",x({title:{type:"string",title:'{{ t("Collection display name") }}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Collection name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input","x-validator":"uid",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"},config:{type:"void","x-decorator":SQLRequestProvider,properties:{sql:{type:"string",title:'{{t("SQL")}}',"x-decorator":"FormItem","x-component":SQLInput,required:!0,"x-validator":(t,o,{form:r})=>r.query("sql").take().componentProps.disabled?"":i18n.t("Please confirm the SQL statement first")},sources:{type:"array",title:'{{t("Source collections")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0},"x-reactions":["{{useAsyncDataSource(loadCollections)}}"]},fields:{type:"array",title:'{{t("Fields")}}',"x-decorator":"FormItem","x-component":FieldsConfigure,required:!0},table:{type:"void",title:'{{t("Preview")}}',"x-decorator":"FormItem","x-component":PreviewTable}}},filterTargetKey:{title:'{{ t("Record unique key")}}',type:"single",description:'{{t( "If a collection lacks a primary key, you must configure a unique record key to locate row records within a block, failure to configure this will prevent the creation of data blocks for the collection.")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0},"x-reactions":["{{useAsyncDataSource(loadFilterTargetKeys)}}"]}},getConfigurableProperties("category","description")))}}class MainDataSource extends DataSource{getDataSource(){return q(this,null,function*(){var t;const o=yield this.app.apiClient.request({resource:"collections",action:"listMeta"});return{collections:((t=o==null?void 0:o.data)==null?void 0:t.data)||[]}})}}class CollectionPlugin extends Plugin{load(){return q(this,null,function*(){this.dataSourceManager.addCollectionMixins([InheritanceCollectionMixin]),this.addFieldInterfaces(),this.addCollectionTemplates(),this.addFieldInterfaces(),this.addFieldInterfaceGroups(),this.addMainDataSource()})}addMainDataSource(){var t,o;((o=(t=this.options)==null?void 0:t.config)==null?void 0:o.enableRemoteDataSource)!==!1&&this.dataSourceManager.addDataSource(MainDataSource,{key:DEFAULT_DATA_SOURCE_KEY,displayName:DEFAULT_DATA_SOURCE_TITLE})}addFieldInterfaceGroups(){this.dataSourceManager.addFieldInterfaceGroups({basic:{label:'{{t("Basic")}}'},choices:{label:'{{t("Choices")}}'},media:{label:'{{t("Media")}}'},datetime:{label:'{{t("Date & Time")}}'},relation:{label:'{{t("Relation")}}'},advanced:{label:'{{t("Advanced type")}}'},systemInfo:{label:'{{t("System info")}}'},others:{label:'{{t("Others")}}'}})}addFieldInterfaces(){this.dataSourceManager.addFieldInterfaces([CheckboxFieldInterface,CheckboxGroupFieldInterface,CollectionSelectFieldInterface,ColorFieldInterface,CreatedAtFieldInterface,CreatedByFieldInterface,DatetimeFieldInterface,EmailFieldInterface,IconFieldInterface,IdFieldInterface,InputFieldInterface,IntegerFieldInterface,JsonFieldInterface,LinkToFieldInterface,M2MFieldInterface,M2OFieldInterface,MarkdownFieldInterface,MultipleSelectFieldInterface,NumberFieldInterface,O2MFieldInterface,O2OFieldInterface,OHOFieldInterface,OBOFieldInterface,PasswordFieldInterface,PercentFieldInterface,PhoneFieldInterface,RadioGroupFieldInterface,RichTextFieldInterface,SelectFieldInterface,SubTableFieldInterface,TableoidFieldInterface,TextareaFieldInterface,TimeFieldInterface,UpdatedAtFieldInterface,UpdatedByFieldInterface,UrlFieldInterface,UUIDFieldInterface,NanoidFieldInterface,UnixTimestampFieldInterface,DateFieldInterface,DatetimeNoTzFieldInterface])}addCollectionTemplates(){this.dataSourceManager.addCollectionTemplates([GeneralCollectionTemplate,SqlCollectionTemplate,TreeCollectionTemplate,ViewCollectionTemplate])}}function parseCollectionName(e){var t;if(!e)return[];const o=e.split(":"),r=o.pop();return[(t=o[0])!=null?t:"main",r]}function joinCollectionName(e,t){return!e||e==="main"?t:`${e}:${t}`}const useSourceId=()=>{const{sourceId:e,association:t}=useDataBlockProps()||{},o=useSourceKey(t),r=useDataBlockParentRecord({association:t});return e||(r==null?void 0:r[o])},BlockResourceContext=(0,import_react2.createContext)(null);BlockResourceContext.displayName="BlockResourceContext";const BlockAssociationContext=(0,import_react2.createContext)(null);BlockAssociationContext.displayName="BlockAssociationContext";const BlockRequestContext_deprecated=(0,import_react2.createContext)({});BlockRequestContext_deprecated.displayName="BlockRequestContext_deprecated";const useBlockResource=()=>{const e=useDataBlockResource();return(0,import_react2.useContext)(BlockResourceContext)||e},MaybeCollectionProvider=e=>{const{collection:t}=e;return t?(0,import_jsx_runtime.jsx)(CollectionProvider_deprecated,{collection:t,children:(0,import_jsx_runtime.jsx)(ACLCollectionProvider,{children:e.children})}):e.children},BlockRequestProvider_deprecated=e=>{const t=(0,import_react.useField)(),o=useDataBlockResource(),r=useDataBlockRequest(),i=useCollectionRecord(),n=useCollectionParentRecord(),a=useBlockRequestContext(),l=(0,import_react2.useMemo)(()=>({block:e.block,props:e,field:t,service:r,resource:o,__parent:a,updateAssociationValues:(e==null?void 0:e.updateAssociationValues)||[]}),[a,t,e,o,r]);return(0,import_jsx_runtime.jsx)(BlockRequestContext_deprecated.Provider,{value:l,children:(0,import_jsx_runtime.jsx)(RecordProvider,{isNew:i==null?void 0:i.isNew,record:i==null?void 0:i.data,parent:n==null?void 0:n.data,children:e.children})})},useBlockRequestContext=()=>(0,import_react2.useContext)(BlockRequestContext_deprecated),RenderChildrenWithAssociationFilter=e=>{var t;const o=(0,import_react.useFieldSchema)(),{findComponent:r}=useDesignable(),i=(0,import_react.useField)(),n=r((t=i.component)==null?void 0:t[0])||import_react2.default.Fragment;return o.reduceProperties((a,l)=>l["x-component"]==="AssociationFilter"?l:a,null)?(0,import_jsx_runtime.jsx)(n,P(x({},i.componentProps),{children:(0,import_jsx_runtime.jsxs)(import_antd.Row,{style:{height:"100%"},gutter:16,wrap:!1,children:[(0,import_jsx_runtime.jsx)(import_antd.Col,{style:x({width:200,flex:"0 0 auto"},e.associationFilterStyle||{}),children:(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:o,onlyRenderProperties:!0,filterProperties:a=>a["x-component"]==="AssociationFilter"})}),(0,import_jsx_runtime.jsx)(import_antd.Col,{style:{flex:"1 1 auto",minWidth:0},children:(0,import_jsx_runtime.jsx)("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:o,onlyRenderProperties:!0,filterProperties:a=>a["x-component"]!=="AssociationFilter"})})})]})})):e.children},BlockContext=(0,import_react2.createContext)(null);BlockContext.displayName="BlockContext";const useBlockContext=()=>(0,import_react2.useContext)(BlockContext),useCompatDataBlockParentRecord=e=>(0,import_react.useFieldSchema)()["x-use-decorator-props"]?e.parentRecord:useDataBlockParentRecord(e),BlockProvider=e=>{const{name:t,dataSource:o,useParams:r,parentRecord:i}=e,n=useCompatDataBlockParentRecord(e),a=useRefreshComponent(),l=(0,import_ahooks.useUpdate)(),c=(0,import_react2.useCallback)(()=>{l(),a==null||a()},[l,a]),u=r==null?void 0:r(),{getAssociationAppends:m}=useAssociationNames(o),{appends:d,updateAssociationValues:p}=m(),g=(0,import_react2.useMemo)(()=>{var f;return(f=e.params)!=null&&f.appends?x(x({},e.params),u):x(P(x({},e.params),{appends:d}),u)},[d,u,e.params]),h=(0,import_react2.useMemo)(()=>({name:t}),[t]);return(0,import_jsx_runtime.jsx)(BlockContext.Provider,{value:h,children:(0,import_jsx_runtime.jsx)(DataBlockProvider,P(x({},e),{params:g,parentRecord:i||n,children:(0,import_jsx_runtime.jsx)(BlockRequestProvider_deprecated,P(x({},e),{updateAssociationValues:p,params:g,children:(0,import_jsx_runtime.jsx)(RefreshComponentProvider,{refresh:c,children:e.children})}))}))})},useBlockAssociationContext=()=>{const{association:e}=useDataBlockProps();return(0,import_react2.useContext)(BlockAssociationContext)||e},useFilterByTk=e=>{const{resource:t,__parent:o}=useBlockRequestContext(),r=useRecordIndex(),i=useCollectionRecordData(),n=useCollection_deprecated(),a=useBlockAssociationContext(),l=(e==null?void 0:e.association)||a,c=(0,import_react2.useContext)(WithoutTableFieldResource),u=useCollectionManager();if(!c&&(t instanceof TableFieldResource||(o==null?void 0:o.block)==="TableField"))return r;if(l){const m=u.getCollectionField(l);return i==null?void 0:i[m.targetKey||m.sourceKey||"id"]}if((0,import_lodash.isArray)(n.filterTargetKey)){const m={};for(const d of n.filterTargetKey)m[d]=i==null?void 0:i[d];return m}else return i==null?void 0:i[n.filterTargetKey||"id"]},useSourceIdFromRecord=()=>{const e=useRecord(),{getCollectionField:t}=useCollectionManager_deprecated(),o=useBlockAssociationContext();if(o){const r=t(o);return e==null?void 0:e[r.sourceKey||"id"]}},useSourceIdFromParentRecord=()=>useSourceId(),useParamsFromRecord=e=>{var t,o;const r=useFilterByTk(e),i=useRecord(),{fields:n}=useCollection_deprecated(),a=(0,import_react.useFieldSchema)(),{getCollectionJoinField:l}=useCollectionManager_deprecated(),c=l(((t=a==null?void 0:a["x-decorator-props"])==null?void 0:t.resource)||((o=a==null?void 0:a["x-decorator-props"])==null?void 0:o.association)),u=n.filter(p=>["boolean","date","integer","radio","sort","string","time","uid","uuid"].includes(p.type)).map(p=>p.name),m=Object.keys(i).filter(p=>u.includes(p)).reduce((p,g)=>(p[g]=i[g],p),{}),d={filterByTk:r};return i.__collection&&c&&!["oho","m2o","obo"].includes(c.interface)&&(d.targetCollection=i.__collection),!r&&Object.keys(m).length>0&&(d.filter=m),d},RecordLink=e=>{const t=(0,import_react.useField)(),o=useRecord(),r=e,{title:i,to:n}=r,a=K(r,["title","to"]),l=(0,import_template.default)(n||"");return(0,import_jsx_runtime.jsx)(import_react_router_dom.Link,P(x({},a),{to:l({record:o||{}}),children:t.title}))},ACLContext=(0,import_react2.createContext)({});ACLContext.displayName="ACLContext";const ACLProvider=e=>(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{components:{ACLCollectionFieldProvider,ACLActionProvider,ACLMenuItemProvider,ACLCollectionProvider},children:e.children}),ACLRolesCheckProvider=e=>{const{setDesignable:t}=useDesignable(),{render:o}=useAppSpin(),r=useAPIClient(),i=useApp(),n=useRequest({url:"roles:check"},{onSuccess(a){var l,c,u,m;(l=a==null?void 0:a.data)!=null&&l.snippets.includes("ui.*")||t(!1),((c=a==null?void 0:a.data)==null?void 0:c.role)!==r.auth.role&&r.auth.setRole((u=a==null?void 0:a.data)==null?void 0:u.role),i.pluginSettingsManager.setAclSnippets(((m=a==null?void 0:a.data)==null?void 0:m.snippets)||[])}});return n.loading?o():n.error?(0,import_jsx_runtime.jsx)(NavigateToSigninWithRedirect,{}):(0,import_jsx_runtime.jsx)(ACLContext.Provider,{value:n,children:e.children})},useRoleRecheck=()=>{const e=(0,import_react2.useContext)(ACLContext),{allowAll:t}=useACLRoleContext();return()=>{t||e.refresh()}},useACLContext=()=>(0,import_react2.useContext)(ACLContext),ACLActionParamsContext=(0,import_react2.createContext)({});ACLActionParamsContext.displayName="ACLActionParamsContext";const ACLCustomContext=(0,import_react2.createContext)({});ACLCustomContext.displayName="ACLCustomContext";const useACLCustomContext=()=>(0,import_react2.useContext)(ACLCustomContext),useACLRolesCheck=()=>{var e,t,o;const r=(0,import_react2.useContext)(ACLContext),i=useDataSourceKey(),{dataSources:n}=((e=r==null?void 0:r.data)==null?void 0:e.meta)||{},a=x(x({},(t=r==null?void 0:r.data)==null?void 0:t.data),(0,import_lodash.omit)(n==null?void 0:n[i],"snippets")),l=(0,import_react2.useCallback)(c=>{var u;const m=c.split(":").pop();return((u=a==null?void 0:a.actionAlias)==null?void 0:u[m])||m},[a==null?void 0:a.actionAlias]);return{data:a,getActionAlias:l,inResources:(0,import_react2.useCallback)(c=>{var u,m;return(m=(u=a==null?void 0:a.resources)==null?void 0:u.includes)==null?void 0:m.call(u,c)},[a==null?void 0:a.resources]),getResourceActionParams:(0,import_react2.useCallback)(c=>{var u,m;const[d]=c.split(":"),p=l(c);return((u=a==null?void 0:a.actions)==null?void 0:u[`${d}:${p}`])||((m=a==null?void 0:a.actions)==null?void 0:m[c])},[a==null?void 0:a.actions,l]),getStrategyActionParams:(0,import_react2.useCallback)(c=>{var u,m;const d=l(c);return(m=(u=a==null?void 0:a.strategy)==null?void 0:u.actions)!=null&&m.find(p=>{const[g]=p.split(":");return g===d})?{}:null},[(o=a==null?void 0:a.strategy)==null?void 0:o.actions,l])}},getIgnoreScope=(e={})=>{var t;const{schema:o,recordPkValue:r}=e;let i=!1;return e.ignoreScope&&(i=!0),o!=null&&o["x-acl-ignore-scope"]&&(i=!0),(t=o==null?void 0:o["x-acl-action-props"])!=null&&t.skipScopeCheck&&(i=!0),r||(i=!0),i},useAllowedActions=()=>{var e,t;const o=useResourceActionContext();return(t=(e=o==null?void 0:o.data)==null?void 0:e.meta)==null?void 0:t.allowedActions},useResourceName=()=>{var e;const t=useResourceActionContext(),o=useDataBlockProps();return(o==null?void 0:o.resource)||(o==null?void 0:o.association)||(o==null?void 0:o.collection)||((e=t==null?void 0:t.defaultRequest)==null?void 0:e.resource)};function useACLRoleContext(){const{data:e,getActionAlias:t,inResources:o,getResourceActionParams:r,getStrategyActionParams:i}=useACLRolesCheck(),n=useAllowedActions(),a=useCollectionManager(),l=(0,import_react2.useCallback)((c,u)=>{const m=t(c);return Array.isArray(n==null?void 0:n[m])?n[m].includes(u):null},[n,t]);return P(x({},e),{parseAction:(0,import_react2.useCallback)((c,u={})=>{var m;const[d,p]=(c==null?void 0:c.split(":"))||[],g=(d==null?void 0:d.includes("."))&&((m=a.getCollectionField(d))==null?void 0:m.target);if(!getIgnoreScope(u)){const h=l(p,u.recordPkValue);if(h!==null)return h?{}:null}return e!=null&&e.allowAll?{}:o(g)?r(`${g}:${p}`):o(d)?r(c):i(c)},[a,e==null?void 0:e.allowAll,r,i,o,l])})}function useUIConfigurationPermissions(){const{allowAll:e,snippets:t}=useACLRoleContext();return{allowConfigUI:e||t.includes("ui.*")}}const ACLCollectionProvider=e=>{var t,o;const{allowAll:r,parseAction:i}=useACLRoleContext(),{allowAll:n}=useACLCustomContext(),a=useApp(),l=(0,import_react.useFieldSchema)();let c=(l==null?void 0:l["x-acl-action"])||e.actionPath;const u=((t=l==null?void 0:l["x-decorator-props"])==null?void 0:t.association)||((o=l==null?void 0:l["x-decorator-props"])==null?void 0:o.collection);c==="undefined:list"&&u&&u!=="undefined"&&(c=`${u}:list`);const m=(0,import_react2.useMemo)(()=>c?i(c,{schema:l}):null,[i,c,l]);if(r||a.disableAcl||n)return e.children;if(!c)return(0,import_jsx_runtime.jsx)(ACLActionParamsContext.Provider,{value:{},children:e.children});if(!m)return(0,import_jsx_runtime.jsx)(CollectionNotAllowViewPlaceholder,{});const[d,p]=c.split(":");return m.actionName=p,(0,import_jsx_runtime.jsx)(ACLActionParamsContext.Provider,{value:m,children:e.children})},useACLActionParamsContext=()=>(0,import_react2.useContext)(ACLActionParamsContext),useRecordPkValue=()=>{const e=useCollection(),t=useCollectionRecordData();if(!e)return;const o=e.getPrimaryKey();return t==null?void 0:t[o]},ACLActionProvider=e=>{const t=useCollection(),o=useRecordPkValue(),r=useResourceName(),{parseAction:i}=useACLRoleContext(),n=(0,import_react.useFieldSchema)();let a=n["x-acl-action"];const l=["create","update","destroy","importXlsx"];!a&&r&&n["x-action"]&&(a=`${r}:${n["x-action"]}`),a!=null&&a.includes(":")||(a=`${r}:${a}`);const c=(0,import_react2.useMemo)(()=>i(a,{schema:n,recordPkValue:o}),[i,a,n,o]);return a?r?c?l.includes(a)||l.includes(a==null?void 0:a.split(":")[1])?t&&t.template!=="view"||t!=null&&t.writableView?(0,import_jsx_runtime.jsx)(ACLActionParamsContext.Provider,{value:c,children:e.children}):null:(0,import_jsx_runtime.jsx)(ACLActionParamsContext.Provider,{value:c,children:e.children}):(0,import_jsx_runtime.jsx)(ACLActionParamsContext.Provider,{value:c,children:e.children}):(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children})},useACLFieldWhitelist=()=>{const e=(0,import_react2.useContext)(ACLActionParamsContext),t=(0,import_react2.useMemo)(()=>[].concat((e==null?void 0:e.whitelist)||[]).concat((e==null?void 0:e.fields)||[]).concat((e==null?void 0:e.appends)||[]),[e==null?void 0:e.whitelist,e==null?void 0:e.fields,e==null?void 0:e.appends]);return{whitelist:t,schemaInWhitelist:(0,import_react2.useCallback)((o,r)=>{if(r||t.length===0||!o||!o["x-collection-field"])return!0;const[i,n]=o["x-collection-field"].split("."),[a]=o.name.split(".");return t==null?void 0:t.includes(a||n||i)},[t])}},ACLCollectionFieldProvider=e=>{const t=(0,import_react.useFieldSchema)(),o=(0,import_react.useField)(),{allowAll:r}=useACLRoleContext(),{whitelist:i}=useACLFieldWhitelist(),[n]=t.name.split("."),a=!t["x-acl-ignore"]&&i.length>0&&t!=null&&t["x-collection-field"]?i.includes(n):!0;return(0,import_react2.useEffect)(()=>{a||(o.required=!1,o.display="hidden")},[a,o]),r?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):t["x-collection-field"]?a?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):null:(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children})},ACLMenuItemProvider=e=>{const{allowAll:t,allowMenuItemIds:o=[],snippets:r}=useACLRoleContext(),i=(0,import_react.useFieldSchema)();return t||r.includes("ui.*")?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):i["x-uid"]?o.includes(i["x-uid"])?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):null:(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children})},useAdminSchemaUid=()=>"nocobase-admin-menu",useViewportMeta=()=>{const e=(0,import_react2.useRef)("initial-scale=0.1"),t=(0,import_react2.useRef)();return(0,import_react2.useEffect)(()=>{let o=document.querySelector('meta[name="viewport"]');o?e.current=o.content:(o=document.createElement("meta"),o.name="viewport"),o&&(o.content="width=device-width, initial-scale=1, user-scalable=0",t.current=o)},[]),{metaRef:t,restore:()=>{t.current&&(t.current.content=e.current)}}};function useViewport(){const{metaRef:e,restore:t}=useViewportMeta();(0,import_react2.useEffect)(()=>{if(e.current)return document.head.insertBefore(e.current,document.head.firstChild),()=>{t()}},[])}const MenuItemsContext=(0,import_react2.createContext)(null);MenuItemsContext.displayName="MenuItemsContext";const toItems=(e={})=>{const t=[];for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const r=e[o],i={title:r.title,uid:r["x-uid"]};r.properties&&(i.children=toItems(r.properties)),t.push(i)}return t},useMenuItems=()=>(0,import_react2.useContext)(MenuItemsContext),MenuItemsProvider=e=>{var t,o;const r={url:`uiSchemas:getProperties/${useAdminSchemaUid()}`},i=useRequest(r);if(i.loading)return(0,import_jsx_runtime.jsx)(import_antd.Spin,{});const n=toItems((o=(t=i.data)==null?void 0:t.data)==null?void 0:o.properties);return(0,import_jsx_runtime.jsx)(MenuItemsContext.Provider,{value:{service:i,items:n},children:e.children})},findUids=e=>{if(!Array.isArray(e))return[];const t=[];for(const o of e)t.push(o.uid),t.push(...findUids(o.children));return t},getParentUids=(e,t,o=[])=>{if(!e)return[];for(const r of e){if(o.push(r.uid),t(r))return o;if(r.children){const i=getParentUids(r.children,t,o);if(i.length)return i}o.pop()}return[]},getChildrenUids=(e=[],t=[])=>{for(const o of e)t.push(o.uid),o.children&&o.children.length&&getChildrenUids(o.children,t);return t},MenuConfigure=()=>{const e=useRecord(),t=useAPIClient(),{items:o}=useMenuItems(),{t:r}=(0,import_react_i18next.useTranslation)(),i=findUids(o),[n,a]=(0,import_react2.useState)([]),{loading:l,refresh:c}=useRequest({resource:"roles.menuUiSchemas",resourceOf:e.name,action:"list",params:{paginate:!1}},{onSuccess(g){var h;a(((h=g==null?void 0:g.data)==null?void 0:h.map(f=>f["x-uid"]))||[])}}),u=t.resource("roles.menuUiSchemas",e.name),m=i.length===n.length,d=(g,h)=>q(void 0,null,function*(){const f=getParentUids(o,v=>v.uid===h.uid),_=getChildrenUids(h==null?void 0:h.children,[]);if(g){const v=_.concat(h.uid),S=n.filter(C=>!v.includes(C));a([...S]),yield u.remove({values:v})}else{const v=_.concat(f);a(S=>(0,import_lodash.uniq)([...S,...v])),yield u.add({values:v})}import_antd.message.success(r("Saved successfully"))}),p=g=>g.map(h=>{const f=r(h.title);return h.children?P(x({},h),{title:f,children:p(h.children)}):P(x({},h),{title:f})});return(0,import_jsx_runtime.jsx)(import_antd.Table,{className:antTableCell,loading:l,rowKey:"uid",pagination:!1,expandable:{defaultExpandAllRows:!0},columns:[{dataIndex:"title",title:r("Menu item title")},{dataIndex:"accessible",title:(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:m,onChange:g=>q(void 0,null,function*(){m?yield u.set({values:[]}):yield u.set({values:i}),c(),import_antd.message.success(r("Saved successfully"))})})," ",r("Accessible")]}),render:(g,h)=>{const f=n.includes(h.uid);return(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:f,onChange:()=>d(f,h)})}}],dataSource:p(o)})},SettingCenterPermissionProvider=e=>{var t;const{currentRecord:o}=(0,import_react2.useContext)(PermissionContext);return(t=o==null?void 0:o.snippets)!=null&&t.includes("pm.*")?(0,import_jsx_runtime.jsx)("div",{children:e.children}):null},PermissionContext=(0,import_react2.createContext)(null);PermissionContext.displayName="PermissionContext";const PermissionProvider=e=>{const t=useAPIClient(),o=useRecord(),{t:r}=(0,import_react_i18next.useTranslation)(),{snippets:i}=o;i==null||i.forEach(l=>{o[l]=!0});const[n,a]=(0,import_react2.useState)(o);return(0,import_jsx_runtime.jsx)(PermissionContext.Provider,{value:{currentRecord:n,update:(l,c)=>q(void 0,null,function*(){const{path:u,value:m}=l.getState();if(["ui.*","pm","pm.*"].includes(u)){const d=t.resource("roles.snippets",o.name);m?yield d.add({values:[u]}):yield d.remove({values:[u]}),a(P(x(x({},n),c.values),{[u]:m}))}else yield t.resource("roles").update({filterByTk:o.name,values:c.values}),a(x(x({},n),c.values));import_antd.message.success(r("Saved successfully"))})},children:e.children})},SnippetCheckboxGroup=(0,import_react.connect)(e=>{const{t}=(0,import_react_i18next.useTranslation)();return(0,import_jsx_runtime.jsxs)(import_antd.Checkbox.Group,{style:{width:"100%",display:"block"},value:e.value,onChange:o=>{const r=["ui.*","pm","pm.*","app"],i=r.map(a=>`!${a}`),n=(0,import_uniq.default)([...e.value||[],...o]).filter(a=>a&&!i.includes(a)).map(a=>!r.includes(a)||o!=null&&o.includes(a)?a:`!${a}`);for(const a of r)!n.includes(a)&&!n.includes(`!${a}`)&&n.push(`!${a}`);e.onChange(n)},children:[(0,import_jsx_runtime.jsx)("div",{style:{marginTop:16},children:(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{value:"ui.*",children:t("Allows to configure interface")})}),(0,import_jsx_runtime.jsx)("div",{style:{marginTop:8},children:(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{value:"pm",children:t("Allows to install, activate, disable plugins")})}),(0,import_jsx_runtime.jsx)("div",{style:{marginTop:8},children:(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{value:"pm.*",children:t("Allows to configure plugins")})}),(0,import_jsx_runtime.jsx)("div",{style:{marginTop:8},children:(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{value:"app",children:t("Allows to clear cache, reboot application")})})]})}),RoleConfigure=()=>{const{update:e,currentRecord:t}=(0,import_react2.useContext)(PermissionContext),{t:o}=(0,import_react_i18next.useTranslation)();return(0,import_jsx_runtime.jsx)(SchemaComponent,{components:{SnippetCheckboxGroup},schema:{type:"void",name:"form","x-component":"Form","x-component-props":{useValues:r=>{const i=useAPIClient();return useRequest(()=>i.resource("roles").get({filterByTk:t.name}).then(n=>{var a,l;const c=(a=n==null?void 0:n.data)==null?void 0:a.data;return(l=c.snippets)==null||l.forEach(u=>{c[u]=!0}),{data:c}}),r)},effects(){(0,import_core2.onFieldChange)("*",(r,i)=>q(this,null,function*(){i.modified&&(yield e(r,i))}))}},properties:{snippets:{title:o("Configure permissions"),type:"boolean","x-decorator":"FormItem","x-component":"SnippetCheckboxGroup"},allowNewMenu:{title:o("Menu permissions"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":o("New menu items are allowed to be accessed by default.")}}}})},collection={name:"roles",filterTargetKey:"name",targetKey:"name",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Role display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Role UID")}}',type:"string","x-component":"Input"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{title:'{{t("Default role")}}',type:"boolean","x-component":"Checkbox"}}]},roleSchema={type:"object",properties:{block1:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection,resourceName:"roles",request:{resource:"roles",action:"list",params:{pageSize:50,filter:{"name.$ne":"root"},showAnonymous:!0,sort:["createdAt"],appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete role')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add role")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(e){const t=useActionContext();return useRequest(()=>Promise.resolve({data:{name:`r_${(0,import_shared.uid)()}`,snippets:["!ui.*","!pm","!pm.*"]}}),P(x({},e),{refreshDeps:[t.visible]}))}},title:'{{t("Add role")}}',properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'},default:{"x-component":"CollectionField","x-decorator":"FormItem",title:"","x-content":'{{t("Default role")}}'},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{column1:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{default:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-decorator":"ACLActionProvider","x-acl-action":"roles:update","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"PermissionProvider",title:'{{t("Configure permissions")}}',properties:{tabs1:{type:"void","x-component":"Tabs","x-component-props":{},properties:{tab1:{type:"void",title:'{{t("General permissions")}}',"x-component":"Tabs.TabPane","x-component-props":{},properties:{role:{"x-component":"RoleConfigure"}}},tab3:{type:"void",title:'{{t("Menu permissions")}}',"x-component":"Tabs.TabPane","x-component-props":{},properties:{menu:{"x-decorator":"MenuItemsProvider","x-component":"MenuConfigure"}}},tab4:{type:"void",title:'{{t("Plugin settings permissions")}}',"x-decorator":"SettingCenterPermissionProvider","x-component":"Tabs.TabPane","x-component-props":{},properties:{menu:{"x-decorator":"SettingCenterProvider","x-component":"SettingsCenterConfigure"}}}}}}}}},update:{type:"void",title:'{{t("Edit")}}',"x-decorator":"ACLActionProvider","x-acl-action":"roles:update","x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:e=>{const t=useRecord(),o=useRequest(()=>Promise.resolve({data:(0,import_pick.default)(t,["title","name","default"])}),P(x({},e),{manual:!0})),r=useActionContext();return(0,import_react2.useEffect)(()=>{r.visible&&o.run()},[r.visible]),o}},title:'{{t("Edit role")}}',properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},default:{title:"","x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Default role")}}'},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-acl-action":"roles:destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete role')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}}}},AvailableActionsContext=(0,import_react2.createContext)([]);AvailableActionsContext.displayName="AvailableActionsContext";const AvailableActionsProver=e=>{const{data:t,loading:o}=useRequest({resource:"availableActions",action:"list"});return o?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(0,import_jsx_runtime.jsx)(AvailableActionsContext.Provider,{value:t==null?void 0:t.data,children:e.children})},useAvailableActions=()=>(0,import_react2.useContext)(AvailableActionsContext),RoleTable=()=>(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:{designable:!1},children:(0,import_jsx_runtime.jsx)(AvailableActionsProver,{children:(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:roleSchema,components:{MenuItemsProvider,SettingCenterPermissionProvider,PermissionProvider}})})})}),rolesResourcesScopesCollection={name:"rolesResourcesScopes",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Scope name")}}',type:"string","x-component":"Input",required:!0}}]},useFormBlockProps=()=>{const{name:e}=(0,import_react2.useContext)(RoleResourceCollectionContext),t=useFormBlockContext();return(0,import_react2.useEffect)(()=>{t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},scopesSchema={type:"object",properties:{scope:{"x-component":"RecordPicker","x-component-props":{size:"small",fieldNames:{label:"name",value:"id"},multiple:!1,association:{target:"rolesResourcesScopes"},onChange:"{{ onChange }}"},properties:{selector:{type:"void",title:'{{ t("Select record") }}',"x-component":"RecordPicker.Selector","x-component-props":{className:"nb-record-picker-selector"},properties:{tableBlock:{type:"void","x-decorator":"TableSelectorProvider","x-decorator-props":{collection:rolesResourcesScopesCollection,resource:"rolesResourcesScopes",action:"list",params:{pageSize:20},useParams(){return{filter:{$or:[{resourceName:(0,import_react2.useContext)(RoleResourceCollectionContext).name},{resourceName:null}]}}},rowKey:"id"},"x-component":"BlockItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{create:{type:"void",title:'{{ t("Add new") }}',"x-action":"create","x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:rolesResourcesScopesCollection},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":useFormBlockProps,properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const e=(0,import_react2.useContext)(RoleResourceCollectionContext);return{options:useFilterOptions(e.name)}},"x-component-props":{dynamicComponent:VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}}}},value:{type:"array","x-component":"TableV2.Selector","x-use-component-props":"useTableSelectorProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-component":"TableV2.Column",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:rolesResourcesScopesCollection,action:"get",useParams:"{{ useParamsFromRecord }}"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const e=(0,import_react2.useContext)(RoleResourceCollectionContext);return{options:useFilterOptions(e.name)}},"x-component-props":{dynamicComponent:VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{update:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}},destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"usePickActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}},RolesResourcesScopesSelectedRowKeysContext=(0,import_react2.createContext)(null);RolesResourcesScopesSelectedRowKeysContext.displayName="RolesResourcesScopesSelectedRowKeysContext";const RolesResourcesScopesSelectedRowKeysProvider=e=>{const[t,o]=(0,import_react2.useState)([]);return(0,import_jsx_runtime.jsx)(RolesResourcesScopesSelectedRowKeysContext.Provider,{value:[t,o],children:e.children})},useRolesResourcesScopesSelectedRowKeys=()=>(0,import_react2.useContext)(RolesResourcesScopesSelectedRowKeysContext),ScopeSelect=e=>{const t=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)({values:{scope:e.value}}),[]);return(0,import_jsx_runtime.jsx)(FormProvider,{form:t,children:(0,import_jsx_runtime.jsx)(SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider},scope:{onChange(o){var r;(r=e==null?void 0:e.onChange)==null||r.call(e,o)}},schema:scopesSchema})})},toActionMap=e=>{var t;const o={};return(t=e==null?void 0:e.forEach)==null||t.call(e,r=>{r.name&&(o[r.name]=r,o[r.name].scope=(0,import_lodash.isEmpty)(r.scope)?null:r.scope)}),o},RoleResourceCollectionContext=(0,import_react2.createContext)({});RoleResourceCollectionContext.displayName="RoleResourceCollectionContext";const RolesResourcesActions=(0,import_react.connect)(e=>{var t,o,r,i;const n=F=>{const j=F.map(k=>P(x({},k),{scope:(0,import_lodash.isEmpty)(k.scope)?null:k.scope}));e.onChange(j)};(0,import_react.useForm)();const a=useRecord(),l=useAvailableActions(),{getCollection:c,getCollectionFields:u}=useCollectionManager_deprecated(),m=c(a.collectionName),d=u(a.collectionName),p=useCompile(),{t:g}=(0,import_react_i18next.useTranslation)(),h=(0,import_react.useField)(),f=toActionMap(h.value||[]),_=(F,j)=>{var k;const T=f==null?void 0:f[F];return T?(k=T==null?void 0:T.fields)==null?void 0:k.includes(j):!1},v=l.filter(F=>F.allowConfigureFields),S=(t=d==null?void 0:d.filter(F=>F.interface))==null?void 0:t.map(F=>{const j=x({},F);for(const k of v)j[k.name]=_(k.name,F.name);return j}),C=F=>{var j,k;f[F]?delete f[F]:f[F]={name:F,fields:(k=(j=d==null?void 0:d.filter(T=>T.interface))==null?void 0:j.map)==null?void 0:k.call(j,T=>T.name)},n(Object.values(f))},b=(F,j)=>{f[F]?(f[F].scope=j,n(Object.values(f))):(C(F),f[F].scope=j)},y={};for(const F of v)y[F.name]=((o=d==null?void 0:d.filter(j=>j.interface))==null?void 0:o.length)===((i=(r=f==null?void 0:f[F.name])==null?void 0:r.fields)==null?void 0:i.length);return(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsx)(RoleResourceCollectionContext.Provider,{value:m,children:(0,import_jsx_runtime.jsxs)(import_antd_v5.FormLayout,{layout:"vertical",children:[(0,import_jsx_runtime.jsx)(import_antd_v5.FormItem,{label:g("Action permission"),children:(0,import_jsx_runtime.jsx)(import_antd.Table,{className:antTableCell,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:g("Action display name"),render:F=>p(F)},{dataIndex:"onNewRecord",title:g("Action type"),render:F=>F?(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:"green",children:g("Action on new records")}):(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:"geekblue",children:g("Action on existing records")})},{dataIndex:"enabled",title:g("Allow"),render:(F,j)=>(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:F,onChange:()=>{C(j.name)}})},{dataIndex:"scope",title:g("Data scope"),render:(F,j)=>!j.onNewRecord&&(0,import_jsx_runtime.jsx)(ScopeSelect,{value:F,onChange:k=>{b(j.name,k)}})}],dataSource:l==null?void 0:l.map(F=>{let j=!1,k=null;return f[F.name]&&(j=!0,F.onNewRecord||(k=f[F.name].scope)),P(x({},F),{enabled:j,scope:k})})})}),(0,import_jsx_runtime.jsx)(import_antd_v5.FormItem,{label:g("Field permission"),children:(0,import_jsx_runtime.jsx)(import_antd.Table,{className:antTableCell,pagination:!1,dataSource:S,columns:[{dataIndex:["uiSchema","title"],title:g("Field display name"),render:F=>p(F)},...v.map(F=>{const j=y==null?void 0:y[F.name];return{dataIndex:F.name,title:(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:j,onChange:()=>{var k;const T=f[F.name]||{name:F.name};j?T.fields=[]:T.fields=(k=d==null?void 0:d.map)==null?void 0:k.call(d,O=>O.name),f[F.name]=T,n(Object.values(f))}})," ",p(F.displayName)]}),render:(k,T)=>(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:k,"aria-label":`${F.name}_checkbox`,onChange:()=>{const O=f[F.name]||{name:F.name},N=O.fields||[];if(k){const L=N.indexOf(T.name);N.splice(L,1)}else N.push(T.name);O.fields=N,f[F.name]=O,n(Object.values(f))}})}})]})})]})})})}),toScopes=e=>{var t;if(!e)return{};const o={};return(t=e==null?void 0:e.forEach)==null||t.call(e,r=>{const[i,n]=r.split(":");o[i]=n||"all"}),o},toFieldValue=e=>{const t=[];for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const r=e[o];r==="all"?t.push(o):t.push(`${o}:${r}`)}return t},StrategyActions=(0,import_react.connect)(e=>{const{onChange:t}=e,o=useAvailableActions(),r=useCompile(),{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useField)(),a=toScopes(n.value);return(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsx)(import_antd.Table,{size:"small",pagination:!1,rowKey:"name",columns:[{dataIndex:"displayName",title:i("Action display name"),render:l=>r(l)},{dataIndex:"onNewRecord",title:i("Action type"),render:l=>l?(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:"green",children:i("Action on new records")}):(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:"geekblue",children:i("Action on existing records")})},{dataIndex:"enabled",title:i("Allow"),render:(l,c)=>(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:l,"aria-label":`${c.name}_checkbox`,onChange:u=>{l?delete a[c.name]:a[c.name]="all",t(toFieldValue(a))}})},{dataIndex:"scope",title:i("Data scope"),render:(l,c)=>!c.onNewRecord&&(0,import_jsx_runtime.jsx)(import_antd.Select,{"data-testid":"select-data-scope",popupMatchSelectWidth:!1,size:"small",value:l,options:[{label:i("All records"),value:"all"},{label:i("Own records"),value:"own"}],onChange:u=>{a[c.name]=u,t(toFieldValue(a))}})}],dataSource:o==null?void 0:o.map(l=>{let c="all",u=!1;return a[l.name]&&(u=!0,c=a[l.name]),P(x({},l),{enabled:u,scope:c})})})})}),PluginManagerLink=()=>{const{t:e}=(0,import_react_i18next.useTranslation)(),t=useNavigateNoUpdate(),{token:o}=useToken$1();return(0,import_jsx_runtime.jsx)(import_antd.Tooltip,{title:e("Plugin manager"),children:(0,import_jsx_runtime.jsx)(import_antd.Button,{"data-testid":"plugin-manager-button",icon:(0,import_jsx_runtime.jsx)(import_icons.ApiOutlined,{style:{color:o.colorTextHeaderMenu}}),title:e("Plugin manager"),onClick:()=>{t("/admin/pm/list")}})})},SettingsCenterDropdown=()=>{const e=useCompile(),{t}=(0,import_react_i18next.useTranslation)(),{token:o}=useToken$1(),r=useApp(),i=(0,import_react2.useMemo)(()=>r.pluginSettingsManager.getList().filter(n=>n.isTopLevel!==!1).map(n=>({key:n.name,icon:n.icon,label:n.link?(0,import_jsx_runtime.jsx)("div",{onClick:()=>window.open(n.link),children:e(n.title)}):(0,import_jsx_runtime.jsx)(import_react_router_dom.Link,{to:n.path,children:e(n.title)})})),[r,t]);return(0,import_react2.useEffect)(()=>()=>{r.pluginSettingsManager.clearCache()},[r.pluginSettingsManager]),(0,import_jsx_runtime.jsx)(import_antd.Dropdown,{menu:{style:{maxHeight:"70vh",overflow:"auto"},items:i},children:(0,import_jsx_runtime.jsx)(import_antd.Button,{"data-testid":"plugin-settings-button",icon:(0,import_jsx_runtime.jsx)(import_icons.SettingOutlined,{style:{color:o.colorTextHeaderMenu}})})})},useStyles$1=(0,import_antd_style.createStyles)(({token:e})=>({cardActionDisabled:{color:e.colorTextDisabled,cursor:"not-allowed"},pageHeader:{backgroundColor:e.colorBgContainer,paddingTop:e.paddingSM,paddingBottom:0,paddingInline:e.paddingLG,".ant-page-header-footer":{marginBlockStart:"0"},"& .ant-tabs-nav":{marginBottom:0},".ant-page-header-heading-title":{color:e.colorText}},pageContent:{margin:e.marginLG},PluginDetailBaseInfo:{display:"flex",flexDirection:"column",marginBottom:e.margin},PluginDocument:{background:e.colorBgContainer,padding:e.paddingLG,height:"60vh",overflowY:"auto"},avatar:{".ant-card-meta-avatar":{marginTop:"8px",".ant-avatar":{borderRadius:"2px"}}},version:{display:"block",color:e.colorTextDescription,fontWeight:"normal",fontSize:e.fontSize}}));import_dayjs.default.extend(import_relativeTime.default);const PluginDetail=({plugin:e,onCancel:t})=>{var o,r,i,n,a,l,c,u;const{t:m}=(0,import_react_i18next.useTranslation)(),d=(0,import_react2.useMemo)(()=>[{title:m("Name"),dataIndex:"name",key:"name"},{title:m("Version range"),dataIndex:"versionRange",key:"versionRange"},{title:m("Plugin's version"),dataIndex:"packageVersion",key:"packageVersion"},{title:m("Result"),dataIndex:"result",key:"result",render:C=>(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:C?"success":"error",children:C?"Yes":"No"})}],[m]),{data:p,loading:g}=useRequest({url:"pm:get",params:{filterByTk:e.name}},{refreshDeps:[e.name],ready:!!e.name}),h=(0,import_react2.useMemo)(()=>{var C,b,y;if(!((b=(C=p==null?void 0:p.data)==null?void 0:C.packageJson)!=null&&b.repository))return null;const F=(y=p==null?void 0:p.data)==null?void 0:y.packageJson.repository;return(typeof F=="string"?F:F.url).replace(/\.git$/,"").replace(/^git\+/,"")},[p]),f=(0,import_react2.useMemo)(()=>{var C;const b=(C=p==null?void 0:p.data)==null?void 0:C.packageJson.author;return b?typeof b=="string"?b:b.name:null},[p]),{styles:_,theme:v}=useStyles$1(),S=[{key:"readme",label:m("Readme"),children:(0,import_jsx_runtime.jsxs)(import_antd.Row,{gutter:20,children:[e.name&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Name")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:e.name})]})}),e.displayName&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("DisplayName")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:e.displayName})]})}),(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("PackageName")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:e.packageName})]})}),h&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Repository")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:h})]})}),((o=p==null?void 0:p.data)==null?void 0:o.packageJson.homepage)&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Homepage")}),(0,import_jsx_runtime.jsx)("a",{href:(r=p==null?void 0:p.data)==null?void 0:r.packageJson.homepage,target:"_blank",rel:"noreferrer",children:(i=p==null?void 0:p.data)==null?void 0:i.packageJson.homepage})]})}),e.description&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Description")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:e.description})]})}),((n=p==null?void 0:p.data)==null?void 0:n.packageJson.license)&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("License")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:(a=p==null?void 0:p.data)==null?void 0:a.packageJson.license})]})}),f&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Author")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:f})]})}),(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Version")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:e==null?void 0:e.version})]})})]})},{key:"dependencies",label:m("Dependencies compatibility check"),children:(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:((l=p==null?void 0:p.data)==null?void 0:l.depsCompatible)===!1?(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"danger",children:m("`dist/externalVersion.js` not found or failed to `require`. Please rebuild this plugin.")}):(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[!((c=p==null?void 0:p.data)!=null&&c.isCompatible)&&(0,import_jsx_runtime.jsx)(import_antd.Alert,{showIcon:!0,type:"error",message:m("Plugin dependencies check failed, you should change the dependent version to meet the version requirements.")}),(0,import_jsx_runtime.jsx)(import_antd.Table,{style:{marginTop:v.margin},rowKey:"name",pagination:!1,columns:d,dataSource:(u=p==null?void 0:p.data)==null?void 0:u.depsCompatible})]})})}];return(0,import_jsx_runtime.jsx)(import_antd.Modal,{open:!!e,footer:!1,destroyOnClose:!0,width:600,onCancel:t,children:g?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):e&&(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Title,{level:3,children:e.packageName}),(0,import_jsx_runtime.jsx)(import_antd.Space,{split:(0,import_jsx_runtime.jsx)("span",{children:" • "}),children:(0,import_jsx_runtime.jsx)("span",{children:e.version})}),(0,import_jsx_runtime.jsx)(import_antd.Tabs,{style:{minHeight:"50vh"},items:S,defaultActiveKey:e.isCompatible?void 0:"dependencies"})]})})},PluginNpmForm=({onClose:e,isUpgrade:t,pluginData:o})=>{import_antd.App.useApp();const r=[],i=()=>{const c=useAPIClient();(0,import_react_i18next.useTranslation)();const u=(0,import_react.useForm)();return{run(){return q(this,null,function*(){yield u.submit(),c.request({url:t?"pm:update":"pm:add",method:"post",data:x({},u.values)}),e(!0)})}}},n=c=>useRequest(()=>Promise.resolve({data:t?(0,import_lodash.pick)(o,["name","packageName","version"]):{}}),c),a=()=>({run(){e()}}),l=(0,import_react2.useMemo)(()=>{const c=(0,import_shared.uid)(),u={type:"object",properties:{[c]:{"x-decorator":"Form","x-component":"div",type:"void","x-decorator-props":{useValues:"{{ useValuesFromProps }}"},properties:{packageName:{type:"string",title:"{{t('Npm package name')}}","x-decorator":"FormItem","x-component":"Input",required:!0,"x-component-props":{disabled:!0}},registry:{type:"string",title:"{{t('Registry url')}}",default:"https://registry.npmjs.org/","x-decorator":"FormItem","x-component":"Input","x-decorator-props":{tooltip:"Example: https://registry.npmjs.org/"}},authToken:{type:"string",title:"{{t('Npm authToken')}}","x-decorator":"FormItem","x-component":"Input"},version:{type:"string",title:"{{t('Version')}}","x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{justifyContent:"right"}},properties:{cancel:{title:"Cancel","x-component":"Action","x-component-props":{useAction:"{{ useCancel }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useSaveValues }}"}}}}}}}};return u.properties[c].properties.packageName["x-component-props"].disabled=t,t||delete u.properties[c].properties.version,u},[t]);return(0,import_jsx_runtime.jsx)(SchemaComponent,{scope:{useCancel:a,useSaveValues:i,versionList:r,useValuesFromProps:n},schema:l})};PluginNpmForm.displayName="PluginNpmForm";const PluginUploadForm=({onClose:e,pluginData:t,isUpgrade:o})=>{const{message:r}=import_antd.App.useApp(),i=()=>{const l=useAPIClient(),{t:c}=(0,import_react_i18next.useTranslation)(),u=(0,import_react.useForm)();return{run(){return q(this,null,function*(){var m,d;yield u.submit();const p=new FormData;p.append("file",(d=(m=u.values.uploadFile)==null?void 0:m[0])==null?void 0:d.originFileObj),t!=null&&t.packageName&&p.append("packageName",t.packageName),yield l.request({url:`pm:${o?"update":"add"}`,method:"post",data:p}),import_antd.Modal.info({icon:null,width:520,content:(0,import_jsx_runtime.jsx)(import_antd.Result,{icon:(0,import_jsx_runtime.jsx)(import_icons.LoadingOutlined,{}),title:c("Plugin uploading"),subTitle:c("Plugin is uploading, please wait...")}),footer:null}),e(!0);function g(){l.silent().request({url:"__health_check",method:"get"}).then(h=>{(h==null?void 0:h.data)==="ok"&&window.location.reload()}).catch(h=>{})}setInterval(g,1e3)})}}},n=()=>({run(){e()}}),a=(0,import_react2.useMemo)(()=>({type:"object",properties:{[(0,import_shared.uid)()]:{"x-decorator":"Form","x-component":"div",type:"void",properties:{uploadFile:{type:"string","x-decorator":"FormItem","x-component":"Upload.Dragger",required:!0,"x-component-props":{action:"",multiple:!1,maxCount:1,height:"150px",tipContent:"{{t('Drag and drop the file here or click to upload, file size should not exceed 30M')}}",beforeUpload:l=>(/\.(zip|rar|tar|gz|bz2|tgz)$/.test(l.name)||r.error("File only support zip, rar, tar, gz, bz2!"),l.size/1024/1024<30||r.error("File must smaller than 30MB!"),!1)}},footer:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{justifyContent:"right"}},properties:{cancel:{title:"Cancel","x-component":"Action","x-component-props":{useAction:"{{ useCancel }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useSaveValues }}"}}}}}}}}),[r]);return(0,import_jsx_runtime.jsx)(SchemaComponent,{scope:{useCancel:n,useSaveValues:i},schema:a})},PluginUrlForm=({onClose:e,pluginData:t,isUpgrade:o})=>{import_antd.App.useApp();const r=()=>{const l=useAPIClient();(0,import_react_i18next.useTranslation)();const c=(0,import_react.useForm)();return{run(){return q(this,null,function*(){const u=c.values.compressedFileUrl;if(!u)return;yield c.submit();const m={compressedFileUrl:u};t!=null&&t.packageName&&(m.packageName=t.packageName),l.request({url:`pm:${o?"update":"add"}`,method:"post",data:m}),e(!0)})}}},i=l=>useRequest(()=>Promise.resolve({data:{compressedFileUrl:t.compressedFileUrl}}),l),n=()=>({run(){e()}}),a=(0,import_react2.useMemo)(()=>({type:"object",properties:{[(0,import_shared.uid)()]:{"x-decorator":"Form","x-component":"div",type:"void","x-decorator-props":{useValues:"{{ useValuesFromProps }}"},properties:{compressedFileUrl:{type:"string","x-decorator":"FormItem","x-component":"Input",required:!0},footer:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{justifyContent:"right"}},properties:{cancel:{title:"Cancel","x-component":"Action","x-component-props":{useAction:"{{ useCancel }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useSaveValues }}"}}}}}}}}),[]);return(0,import_jsx_runtime.jsx)(SchemaComponent,{scope:{useCancel:n,useValuesFromProps:i,useSaveValues:r},schema:a})},PluginUpgradeModal=({onClose:e,isShow:t,pluginData:o})=>{const{t:r}=(0,import_react_i18next.useTranslation)(),{theme:i}=useStyles$1(),[n,a]=(0,import_react2.useState)("npm");return(0,import_jsx_runtime.jsxs)(import_antd.Modal,{onCancel:()=>e(),footer:null,destroyOnClose:!0,title:r("Update plugin"),width:580,open:t,children:[(0,import_jsx_runtime.jsx)("div",{style:{marginTop:i.marginLG,marginBottom:i.marginLG},children:(0,import_jsx_runtime.jsxs)(import_antd.Radio.Group,{optionType:"button",defaultValue:n,onChange:l=>a(l.target.value),children:[(0,import_jsx_runtime.jsx)(import_antd.Radio,{value:"npm",children:r("Npm package")}),(0,import_jsx_runtime.jsx)(import_antd.Radio,{value:"upload",children:r("Upload plugin")}),(0,import_jsx_runtime.jsx)(import_antd.Radio,{value:"url",children:r("Compressed file url")})]})}),n==="npm"&&(0,import_jsx_runtime.jsx)(PluginNpmForm,{isUpgrade:!0,onClose:e,pluginData:o}),n==="upload"&&(0,import_jsx_runtime.jsx)(PluginUploadForm,{isUpgrade:!0,onClose:e,pluginData:o}),n==="url"&&(0,import_jsx_runtime.jsx)(PluginUrlForm,{isUpgrade:!0,onClose:e,pluginData:o})]})};function PluginInfo(e){const{data:t,onClick:o}=e,r=useApp(),{name:i,displayName:n,isCompatible:a,packageName:l,updatable:c,builtIn:u,enabled:m,removable:d,description:p,error:g,homepage:h}=t,{styles:f,theme:_}=useStyles$1(),v=(0,import_react_router_dom.useNavigate)(),{t:S}=(0,import_react_i18next.useTranslation)(),C=useAPIClient(),{modal:b}=import_antd.App.useApp(),[y,F]=(0,import_react2.useState)(!1),j=n||i||l;return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[y&&(0,import_jsx_runtime.jsx)(PluginUpgradeModal,{isShow:y,pluginData:t,onClose:k=>{F(!1)}}),(0,import_jsx_runtime.jsx)(import_antd.Card,{role:"button","aria-label":j,size:"small",bordered:!1,onClick:()=>{!g&&o()},headStyle:{border:"none",minHeight:"inherit",paddingTop:14},bodyStyle:{paddingTop:10},title:(0,import_jsx_runtime.jsx)("div",{children:j}),hoverable:!0,className:import_css.css`
1331
+ }}}`},min:{type:"number",title:'{{ t("Min length") }}',minimum:0,"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0},"x-reactions":{dependencies:[".max"],fulfill:{state:{selfErrors:`{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t("Min length must less than max length")}' : ''}}`}}}}})),A(this,"filterable",{operators:string})}schemaInitialize(t,{block:o}){["Table","Kanban"].includes(o)&&(t["x-component-props"]=t["x-component-props"]||{},t["x-component-props"].ellipsis=!0)}}class TimeFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","time"),A(this,"type","object"),A(this,"group","datetime"),A(this,"order",4),A(this,"title",'{{t("Time")}}'),A(this,"sortable",!0),A(this,"default",{type:"time",uiSchema:{type:"string","x-component":"TimePicker"}}),A(this,"availableTypes",["time"]),A(this,"hasDefaultValue",!0),A(this,"properties",P(x({},defaultProps),{"uiSchema.x-component-props.format":{type:"string",title:'{{t("Time format")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:"HH:mm:ss",enum:[{label:'{{t("12 hour")}}',value:"hh:mm:ss a"},{label:'{{t("24 hour")}}',value:"HH:mm:ss"}]}})),A(this,"filterable",{operators:time}),A(this,"titleUsable",!0)}}class UpdatedAtFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","updatedAt"),A(this,"type","object"),A(this,"group","systemInfo"),A(this,"order",2),A(this,"title",'{{t("Last updated at")}}'),A(this,"sortable",!0),A(this,"default",{type:"date",field:"updatedAt",uiSchema:{type:"string",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}),A(this,"availableTypes",[]),A(this,"properties",x(x({},defaultProps),dateTimeProps)),A(this,"filterable",{operators:datetime}),A(this,"titleUsable",!0)}}class UpdatedByFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","updatedBy"),A(this,"type","object"),A(this,"group","systemInfo"),A(this,"order",4),A(this,"title",'{{t("Last updated by")}}'),A(this,"isAssociation",!0),A(this,"default",{type:"belongsTo",target:"users",foreignKey:"updatedById",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}),A(this,"availableTypes",["belongsTo"]),A(this,"properties",x({},defaultProps)),A(this,"filterable",{nested:!0,children:[]})}schemaInitialize(t,{block:o}){t.properties={viewer:(0,import_lodash.cloneDeep)(recordPickerViewer)},["Table","Kanban"].includes(o)&&(t["x-component-props"]=t["x-component-props"]||{},t["x-component-props"].ellipsis=!0)}}class UrlFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","url"),A(this,"type","string"),A(this,"group","basic"),A(this,"order",5),A(this,"title",'{{t("URL")}}'),A(this,"default",{type:"text",uiSchema:{type:"string","x-component":"Input.URL"}}),A(this,"componentOptions",[{label:"URL",value:"Input.URL"},{label:"Preview",value:"Input.Preview"}]),A(this,"availableTypes",["string","text"]),A(this,"properties",x({},defaultProps)),A(this,"titleUsable",!0),A(this,"filterable",{operators:string})}schemaInitialize(t,{block:o}){}}class UUIDFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","uuid"),A(this,"type","object"),A(this,"group","advanced"),A(this,"order",0),A(this,"title",'{{t("UUID")}}'),A(this,"hidden",!1),A(this,"sortable",!0),A(this,"default",{type:"uuid",uiSchema:{type:"string","x-component":"Input","x-validator":"uuid"}}),A(this,"availableTypes",["uid","uuid"]),A(this,"properties",{"uiSchema.title":{type:"string",title:'{{t("Field display name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Field name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input","x-disabled":"{{ !createOnly }}",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"},autoFill,layout:{type:"void",title:'{{t("Index")}}',"x-component":"Space","x-decorator":"FormItem","x-decorator-props":{style:{marginBottom:"0px"}},properties:{primaryKey,unique}}}),A(this,"filterable",{operators:string}),A(this,"titleUsable",!0)}}class NanoidFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","nanoid"),A(this,"type","object"),A(this,"group","advanced"),A(this,"order",0),A(this,"title",'{{t("Nano ID")}}'),A(this,"hidden",!1),A(this,"sortable",!0),A(this,"default",{type:"nanoid",uiSchema:{type:"string","x-component":"NanoIDInput"}}),A(this,"availableTypes",["nanoid"]),A(this,"properties",{"uiSchema.title":{type:"string",title:'{{t("Field display name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Field name")}}',required:!0,"x-decorator":"FormItem","x-component":"Input","x-disabled":"{{ !createOnly }}",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"},customAlphabet:{type:"string",title:'{{t("Alphabet")}}',default:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","x-decorator":"FormItem","x-component":"Input"},size:{type:"number",title:'{{t("Length")}}',default:21,"x-decorator":"FormItem","x-component":"InputNumber"},autoFill,layout:{type:"void",title:'{{t("Index")}}',"x-component":"Space","x-decorator":"FormItem","x-decorator-props":{style:{marginBottom:"0px"}},properties:{primaryKey,unique}}}),A(this,"filterable",{operators:string}),A(this,"titleUsable",!0)}}class UnixTimestampFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","unixTimestamp"),A(this,"type","object"),A(this,"group","datetime"),A(this,"order",4),A(this,"title",'{{t("Unix Timestamp")}}'),A(this,"sortable",!0),A(this,"default",{type:"unixTimestamp",accuracy:"second",timezone:!0,defaultToCurrentTime:!1,onUpdateToCurrentTime:!1,uiSchema:{type:"number","x-component":"UnixTimestamp","x-component-props":{showTime:!0}}}),A(this,"availableTypes",["unixTimestamp"]),A(this,"hasDefaultValue",!1),A(this,"properties",P(x(x({},defaultProps),dateTimeProps),{accuracy:{type:"string",title:'{{t("Accuracy")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:"second",enum:[{value:"millisecond",label:'{{t("Millisecond")}}'},{value:"second",label:'{{t("Second")}}'}]},defaultToCurrentTime:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Default value to current time")}}'},onUpdateToCurrentTime:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Automatically update timestamp on update")}}'}})),A(this,"filterable",{operators:datetime}),A(this,"titleUsable",!0)}}class DateFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","date"),A(this,"type","object"),A(this,"group","datetime"),A(this,"order",3),A(this,"title",'{{t("DateOnly")}}'),A(this,"sortable",!0),A(this,"default",{type:"dateOnly",uiSchema:{type:"string","x-component":"DatePicker","x-component-props":{dateOnly:!0}}}),A(this,"availableTypes",["dateOnly"]),A(this,"hasDefaultValue",!0),A(this,"properties",P(x(x({},defaultProps),dateTimeProps),{"uiSchema.x-component-props.showTime":{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-visible":!1}})),A(this,"filterable",{operators:datetime}),A(this,"titleUsable",!0)}}class DatetimeNoTzFieldInterface extends CollectionFieldInterface{constructor(){super(...arguments),A(this,"name","datetimeNoTz"),A(this,"type","object"),A(this,"group","datetime"),A(this,"order",2),A(this,"title",'{{t("Datetime (without time zone)")}}'),A(this,"sortable",!0),A(this,"default",{type:"datetimeNoTz",defaultToCurrentTime:!1,onUpdateToCurrentTime:!1,timezone:!1,uiSchema:{type:"string","x-component":"DatePicker","x-component-props":{showTime:!1,utc:!1}}}),A(this,"availableTypes",["string","datetimeNoTz"]),A(this,"hasDefaultValue",!0),A(this,"properties",P(x(x({},defaultProps),dateTimeProps),{defaultToCurrentTime:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Default value to current server time")}}'},onUpdateToCurrentTime:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Automatically update timestamp to the current server time on update")}}'},"uiSchema.x-component-props.gmt":{type:"boolean",title:'{{t("GMT")}}',"x-hidden":!0,"x-component":"Checkbox","x-content":'{{t("Use the same time zone (GMT) for all users")}}',"x-decorator":"FormItem",default:!1}})),A(this,"filterable",{operators:datetime}),A(this,"titleUsable",!0)}}class InheritanceCollectionMixin extends Collection{constructor(){super(...arguments),A(this,"parentCollectionsName"),A(this,"parentCollections"),A(this,"childrenCollections",{}),A(this,"childrenCollectionsName",{}),A(this,"inheritsFields"),A(this,"currentFields"),A(this,"allFields"),A(this,"parentCollectionFields",{}),A(this,"allCollectionsInheritChain"),A(this,"inheritCollectionsChain"),A(this,"foreignKeyFields")}getParentCollectionsName(){if(this.parentCollectionsName)return this.parentCollectionsName.slice();const t=[],o=r=>{const i=this.collectionManager.getCollection(r);if(i){const{inherits:n}=i;if(n)for(let a=0;a<n.length;a++){const l=n[a];t.push(l),o(l)}}return(0,import_lodash.uniq)(t)};return this.parentCollectionsName=o(this.name),this.parentCollectionsName}getParentCollections(){return this.parentCollections?this.parentCollections.slice():(this.parentCollections=this.getParentCollectionsName().map(t=>this.collectionManager.getCollection(t)),this.parentCollections)}getChildrenCollectionsName(t=!1){const o=t?"supportView":"notSupportView";if(this.childrenCollectionsName[o])return this.childrenCollectionsName[o].slice();const r=[],i=this.collectionManager.getCollections(),n=a=>(i.filter(l=>{var c;return(c=l.inherits)==null?void 0:c.includes(a)}).forEach(l=>{const c=l.name;return r.push(c),n(c)}),t&&i.filter(l=>{var c;return((c=l.sources)==null?void 0:c.length)===1&&(l==null?void 0:l.sources[0])===a}).forEach(l=>{const c=l.name;return r.push(l.name),n(c)}),(0,import_lodash.uniq)(r));return this.childrenCollectionsName[o]=n(this.name),this.childrenCollectionsName[o]}getChildrenCollections(t=!1){const o=t?"supportView":"notSupportView";return this.childrenCollections[o]?this.childrenCollections[o].slice():(this.childrenCollections[o]=this.getChildrenCollectionsName(t).map(r=>this.collectionManager.getCollection(r)),this.childrenCollections[o])}getInheritedFields(){if(this.inheritsFields)return this.inheritsFields.slice();const t=this.getParentCollectionsName();return this.inheritsFields=t.map(o=>{var r;return(r=this.collectionManager.getCollection(o))==null?void 0:r.getFields()}).flat().filter(Boolean),this.inheritsFields}getFieldsMap(){return this.fieldsMap?this.fieldsMap:(this.fieldsMap=this.getAllFields().reduce((t,o)=>(t[o.name]=o,t),{}),this.fieldsMap)}getCurrentFields(t){return super.getFields(t)}getParentCollectionFields(t){if(this.parentCollectionFields||(this.parentCollectionFields={}),this.parentCollectionFields[t])return this.parentCollectionFields[t];const o=this.getCurrentFields(),r=this.getParentCollectionsName(),i=this.collectionManager.getCollection(t).getCurrentFields(),n=r.indexOf(t);let a=o;return n>0&&(r.splice(n),r.forEach(l=>{const c=this.collectionManager.getCollection(l);a=a.concat(c.getCurrentFields())})),this.parentCollectionFields[t]=i.filter(l=>a.find(c=>c.name===l.name).collectionName!==this.name),this.parentCollectionFields[t]}getAllCollectionsInheritChain(){if(this.allCollectionsInheritChain)return this.allCollectionsInheritChain.slice();const t=[this.name],o=r=>{const i=this.collectionManager.getCollection(r);if(i){const{inherits:n}=i,a=i.getChildrenCollectionsName();if(n)for(let l=0;l<n.length;l++){const c=n[l];t.includes(c)||(t.push(c),o(c))}if(a)for(let l=0;l<a.length;l++){const c=this.collectionManager.getCollection(a[l]).name;t.includes(c)||(t.push(c),o(c))}}return t};return this.allCollectionsInheritChain=o(this.name),this.allCollectionsInheritChain||[]}getInheritCollectionsChain(){if(this.inheritCollectionsChain)return this.inheritCollectionsChain.slice();const t=[this.name],o=r=>{const i=this.collectionManager.getCollection(r);if(i){const{inherits:n}=i;if(n)for(let a=0;a<n.length;a++){const l=n[a];t.includes(l)||(t.push(l),o(l))}}return t};return this.inheritCollectionsChain=o(this.name),this.inheritCollectionsChain}getAllFields(t){if(this.allFields)return this.allFields.slice();const o=this.getCurrentFields(),r=this.getInheritedFields(),i=(0,import_lodash.unionBy)((o==null?void 0:o.concat(r))||[],"name");return this.allFields=i,t?(0,import_lodash.filter)(i,t):i}getForeignKeyFields(){if(this.foreignKeyFields)return this.foreignKeyFields.slice();const t=this.getCurrentFields(),o=this.getInheritedFields();return(0,import_lodash.unionBy)((t==null?void 0:t.concat(o))||[],"name")}}class GeneralCollectionTemplate extends CollectionTemplate{constructor(){super(...arguments),A(this,"name","general"),A(this,"title",'{{t("General collection")}}'),A(this,"order",1),A(this,"color","blue"),A(this,"default",{fields:[]}),A(this,"configurableProperties",getConfigurableProperties("title","name","inherits","category","description","simplePaginate","presetFields"))}}class TreeCollectionTemplate extends CollectionTemplate{constructor(){super(...arguments),A(this,"name","tree"),A(this,"title",'{{t("Tree collection")}}'),A(this,"order",3),A(this,"color","blue"),A(this,"default",{tree:"adjacencyList",fields:[{interface:"integer",name:"parentId",type:"bigInt",isForeignKey:!0,uiSchema:{type:"number",title:'{{t("Parent ID")}}',"x-component":"InputNumber","x-read-pretty":!0}},{interface:"m2o",type:"belongsTo",name:"parent",foreignKey:"parentId",treeParent:!0,onDelete:"CASCADE",uiSchema:{title:'{{t("Parent")}}',"x-component":"AssociationField","x-component-props":{multiple:!1,fieldNames:{label:"id",value:"id"}}}},{interface:"o2m",type:"hasMany",name:"children",foreignKey:"parentId",treeChildren:!0,onDelete:"CASCADE",uiSchema:{title:'{{t("Children")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{label:"id",value:"id"}}}}]}),A(this,"presetFieldsDisabledIncludes",["id"]),A(this,"events",{beforeSubmit(t){Array.isArray(t==null?void 0:t.fields)&&(t==null||t.fields.map(o=>{!o.target&&["belongsToMany","belongsTo","hasMany","hasOne"].includes(o.type)&&(o.target=t.name)}))}}),A(this,"configurableProperties",getConfigurableProperties("title","name","inherits","category","description","presetFields"))}}class ViewCollectionTemplate extends CollectionTemplate{constructor(){super(...arguments),A(this,"name","view"),A(this,"title",'{{t("Connect to database view")}}'),A(this,"order",4),A(this,"color","yellow"),A(this,"default",{fields:[]}),A(this,"divider",!0),A(this,"configurableProperties",x({title:{type:"string",title:'{{ t("Collection display name") }}',required:!0,"x-decorator":"FormItem","x-component":"Input"},databaseView:{title:'{{t("Connect to database view")}}',type:"single",required:!0,"x-decorator":"FormItem","x-component":"Select","x-reactions":["{{useAsyncDataSource(loadDBViews)}}"],"x-disabled":"{{ !createOnly }}","x-visible":"{{!createMainOnly}}"},name:{type:"string",title:'{{t("Collection name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input","x-validator":"uid",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}","x-reactions":{dependencies:["databaseView"],when:"{{isPG}}",fulfill:{state:{initialValue:"{{$deps[0]&&$deps[0].match(/^([^_]+)_(.*)$/)?.[2]}}"}},otherwise:{state:{value:null}}}},schema:{type:"string","x-hidden":!0,"x-reactions":{dependencies:["databaseView"],when:"{{isPG}}",fulfill:{state:{value:"{{$deps[0].split('@')?.[0]}}"}},otherwise:{state:{value:null}}}},viewName:{type:"string","x-hidden":!0,"x-reactions":{dependencies:["databaseView"],when:"{{isPG}}",fulfill:{state:{value:"{{$deps[0].split('@')?.[1]}}"}},otherwise:{state:{value:"{{$deps[0]}}"}}}},writableView:{type:"boolean","x-content":'{{t("Allow add new, update and delete actions")}}',"x-decorator":"FormItem","x-component":"Checkbox",default:!1,"x-visible":"{{!createMainOnly}}"},sources:{type:"array",title:'{{ t("Source collections") }}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0},"x-reactions":["{{useAsyncDataSource(loadCollections)}}"],"x-disabled":!0,"x-visible":"{{!createMainOnly}}"},fields:{type:"array","x-component":PreviewFields,"x-hidden":"{{ !createOnly }}","x-decorator":"FormItem","x-reactions":{dependencies:["name"],fulfill:{schema:{"x-component-props":"{{$form.values}}"}}},description:'{{t("Fields can only be used correctly if they are defined with an interface.")}}'},preview:{type:"void","x-visible":"{{ createOnly }}","x-component":PreviewTable$1,"x-reactions":{dependencies:["name","fields"],fulfill:{schema:{"x-component-props":"{{$form.values}}"}}}},filterTargetKey:{title:'{{ t("Record unique key")}}',type:"single",description:'{{t( "If a collection lacks a primary key, you must configure a unique record key to locate row records within a block, failure to configure this will prevent the creation of data blocks for the collection.")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0},"x-reactions":["{{useAsyncDataSource(loadFilterTargetKeys)}}"]}},getConfigurableProperties("category","description")))}}class SqlCollectionTemplate extends CollectionTemplate{constructor(){super(...arguments),A(this,"name","sql"),A(this,"title",'{{t("SQL collection")}}'),A(this,"order",4),A(this,"color","yellow"),A(this,"default",{fields:[]}),A(this,"configurableProperties",x({title:{type:"string",title:'{{ t("Collection display name") }}',required:!0,"x-decorator":"FormItem","x-component":"Input"},name:{type:"string",title:'{{t("Collection name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input","x-validator":"uid",description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"},config:{type:"void","x-decorator":SQLRequestProvider,properties:{sql:{type:"string",title:'{{t("SQL")}}',"x-decorator":"FormItem","x-component":SQLInput,required:!0,"x-validator":(t,o,{form:r})=>r.query("sql").take().componentProps.disabled?"":i18n.t("Please confirm the SQL statement first")},sources:{type:"array",title:'{{t("Source collections")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0},"x-reactions":["{{useAsyncDataSource(loadCollections)}}"]},fields:{type:"array",title:'{{t("Fields")}}',"x-decorator":"FormItem","x-component":FieldsConfigure,required:!0},table:{type:"void",title:'{{t("Preview")}}',"x-decorator":"FormItem","x-component":PreviewTable}}},filterTargetKey:{title:'{{ t("Record unique key")}}',type:"single",description:'{{t( "If a collection lacks a primary key, you must configure a unique record key to locate row records within a block, failure to configure this will prevent the creation of data blocks for the collection.")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0},"x-reactions":["{{useAsyncDataSource(loadFilterTargetKeys)}}"]}},getConfigurableProperties("category","description")))}}class MainDataSource extends DataSource{getDataSource(){return q(this,null,function*(){var t;const o=yield this.app.apiClient.request({resource:"collections",action:"listMeta"});return{collections:((t=o==null?void 0:o.data)==null?void 0:t.data)||[]}})}}class CollectionPlugin extends Plugin{load(){return q(this,null,function*(){this.dataSourceManager.addCollectionMixins([InheritanceCollectionMixin]),this.addFieldInterfaces(),this.addCollectionTemplates(),this.addFieldInterfaces(),this.addFieldInterfaceGroups(),this.addMainDataSource()})}addMainDataSource(){var t,o;((o=(t=this.options)==null?void 0:t.config)==null?void 0:o.enableRemoteDataSource)!==!1&&this.dataSourceManager.addDataSource(MainDataSource,{key:DEFAULT_DATA_SOURCE_KEY,displayName:DEFAULT_DATA_SOURCE_TITLE})}addFieldInterfaceGroups(){this.dataSourceManager.addFieldInterfaceGroups({basic:{label:'{{t("Basic")}}'},choices:{label:'{{t("Choices")}}'},media:{label:'{{t("Media")}}'},datetime:{label:'{{t("Date & Time")}}'},relation:{label:'{{t("Relation")}}'},advanced:{label:'{{t("Advanced type")}}'},systemInfo:{label:'{{t("System info")}}'},others:{label:'{{t("Others")}}'}})}addFieldInterfaces(){this.dataSourceManager.addFieldInterfaces([CheckboxFieldInterface,CheckboxGroupFieldInterface,CollectionSelectFieldInterface,ColorFieldInterface,CreatedAtFieldInterface,CreatedByFieldInterface,DatetimeFieldInterface,EmailFieldInterface,IconFieldInterface,IdFieldInterface,InputFieldInterface,IntegerFieldInterface,JsonFieldInterface,LinkToFieldInterface,M2MFieldInterface,M2OFieldInterface,MarkdownFieldInterface,MultipleSelectFieldInterface,NumberFieldInterface,O2MFieldInterface,O2OFieldInterface,OHOFieldInterface,OBOFieldInterface,PasswordFieldInterface,PercentFieldInterface,PhoneFieldInterface,RadioGroupFieldInterface,RichTextFieldInterface,SelectFieldInterface,SubTableFieldInterface,TableoidFieldInterface,TextareaFieldInterface,TimeFieldInterface,UpdatedAtFieldInterface,UpdatedByFieldInterface,UrlFieldInterface,UUIDFieldInterface,NanoidFieldInterface,UnixTimestampFieldInterface,DateFieldInterface,DatetimeNoTzFieldInterface])}addCollectionTemplates(){this.dataSourceManager.addCollectionTemplates([GeneralCollectionTemplate,SqlCollectionTemplate,TreeCollectionTemplate,ViewCollectionTemplate])}}function parseCollectionName(e){var t;if(!e)return[];const o=e.split(":"),r=o.pop();return[(t=o[0])!=null?t:"main",r]}function joinCollectionName(e,t){return!e||e==="main"?t:`${e}:${t}`}const useSourceId=()=>{const{sourceId:e,association:t}=useDataBlockProps()||{},o=useSourceKey(t),r=useDataBlockParentRecord({association:t});return e||(r==null?void 0:r[o])},BlockResourceContext=(0,import_react2.createContext)(null);BlockResourceContext.displayName="BlockResourceContext";const BlockAssociationContext=(0,import_react2.createContext)(null);BlockAssociationContext.displayName="BlockAssociationContext";const BlockRequestContext_deprecated=(0,import_react2.createContext)({});BlockRequestContext_deprecated.displayName="BlockRequestContext_deprecated";const useBlockResource=()=>{const e=useDataBlockResource();return(0,import_react2.useContext)(BlockResourceContext)||e},MaybeCollectionProvider=e=>{const{collection:t}=e;return t?(0,import_jsx_runtime.jsx)(CollectionProvider_deprecated,{collection:t,children:(0,import_jsx_runtime.jsx)(ACLCollectionProvider,{children:e.children})}):e.children},BlockRequestProvider_deprecated=e=>{const t=(0,import_react.useField)(),o=useDataBlockResource(),r=useDataBlockRequest(),i=useCollectionRecord(),n=useCollectionParentRecord(),a=useBlockRequestContext(),l=(0,import_react2.useMemo)(()=>({block:e.block,props:e,field:t,service:r,resource:o,__parent:a,updateAssociationValues:(e==null?void 0:e.updateAssociationValues)||[]}),[a,t,e,o,r]);return(0,import_jsx_runtime.jsx)(BlockRequestContext_deprecated.Provider,{value:l,children:(0,import_jsx_runtime.jsx)(RecordProvider,{isNew:i==null?void 0:i.isNew,record:i==null?void 0:i.data,parent:n==null?void 0:n.data,children:e.children})})},useBlockRequestContext=()=>(0,import_react2.useContext)(BlockRequestContext_deprecated),RenderChildrenWithAssociationFilter=e=>{var t;const o=(0,import_react.useFieldSchema)(),{findComponent:r}=useDesignable(),i=(0,import_react.useField)(),n=r((t=i.component)==null?void 0:t[0])||import_react2.default.Fragment;return o.reduceProperties((a,l)=>l["x-component"]==="AssociationFilter"?l:a,null)?(0,import_jsx_runtime.jsx)(n,P(x({},i.componentProps),{children:(0,import_jsx_runtime.jsxs)(import_antd.Row,{style:{height:"100%"},gutter:16,wrap:!1,children:[(0,import_jsx_runtime.jsx)(import_antd.Col,{style:x({width:200,flex:"0 0 auto"},e.associationFilterStyle||{}),children:(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:o,onlyRenderProperties:!0,filterProperties:a=>a["x-component"]==="AssociationFilter"})}),(0,import_jsx_runtime.jsx)(import_antd.Col,{style:{flex:"1 1 auto",minWidth:0},children:(0,import_jsx_runtime.jsx)("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:(0,import_jsx_runtime.jsx)(import_react.RecursionField,{schema:o,onlyRenderProperties:!0,filterProperties:a=>a["x-component"]!=="AssociationFilter"})})})]})})):e.children},BlockContext=(0,import_react2.createContext)(null);BlockContext.displayName="BlockContext";const useBlockContext=()=>(0,import_react2.useContext)(BlockContext),useCompatDataBlockParentRecord=e=>(0,import_react.useFieldSchema)()["x-use-decorator-props"]?e.parentRecord:useDataBlockParentRecord(e),BlockProvider=e=>{const{name:t,dataSource:o,useParams:r,parentRecord:i}=e,n=useCompatDataBlockParentRecord(e),a=useRefreshComponent(),l=(0,import_ahooks.useUpdate)(),c=(0,import_react2.useCallback)(()=>{l(),a==null||a()},[l,a]),u=r==null?void 0:r(),{getAssociationAppends:m}=useAssociationNames(o),{appends:d,updateAssociationValues:p}=m(),g=(0,import_react2.useMemo)(()=>{var f;return(f=e.params)!=null&&f.appends?x(x({},e.params),u):x(P(x({},e.params),{appends:d}),u)},[d,u,e.params]),h=(0,import_react2.useMemo)(()=>({name:t}),[t]);return(0,import_jsx_runtime.jsx)(BlockContext.Provider,{value:h,children:(0,import_jsx_runtime.jsx)(DataBlockProvider,P(x({},e),{params:g,parentRecord:i||n,children:(0,import_jsx_runtime.jsx)(BlockRequestProvider_deprecated,P(x({},e),{updateAssociationValues:p,params:g,children:(0,import_jsx_runtime.jsx)(RefreshComponentProvider,{refresh:c,children:e.children})}))}))})},useBlockAssociationContext=()=>{const{association:e}=useDataBlockProps();return(0,import_react2.useContext)(BlockAssociationContext)||e},useFilterByTk=e=>{const{resource:t,__parent:o}=useBlockRequestContext(),r=useRecordIndex(),i=useCollectionRecordData(),n=useCollection_deprecated(),a=useBlockAssociationContext(),l=(e==null?void 0:e.association)||a,c=(0,import_react2.useContext)(WithoutTableFieldResource),u=useCollectionManager();if(!c&&(t instanceof TableFieldResource||(o==null?void 0:o.block)==="TableField"))return r;if(l){const m=u.getCollectionField(l);return i==null?void 0:i[m.targetKey||m.sourceKey||"id"]}if((0,import_lodash.isArray)(n.filterTargetKey)){const m={};for(const d of n.filterTargetKey)m[d]=i==null?void 0:i[d];return m}else return i==null?void 0:i[n.filterTargetKey||"id"]},useSourceIdFromRecord=()=>{const e=useRecord(),{getCollectionField:t}=useCollectionManager_deprecated(),o=useBlockAssociationContext();if(o){const r=t(o);return e==null?void 0:e[r.sourceKey||"id"]}},useSourceIdFromParentRecord=()=>useSourceId(),useParamsFromRecord=e=>{var t,o;const r=useFilterByTk(e),i=useRecord(),{fields:n}=useCollection_deprecated(),a=(0,import_react.useFieldSchema)(),{getCollectionJoinField:l}=useCollectionManager_deprecated(),c=l(((t=a==null?void 0:a["x-decorator-props"])==null?void 0:t.resource)||((o=a==null?void 0:a["x-decorator-props"])==null?void 0:o.association)),u=n.filter(p=>["boolean","date","integer","radio","sort","string","time","uid","uuid"].includes(p.type)).map(p=>p.name),m=Object.keys(i).filter(p=>u.includes(p)).reduce((p,g)=>(p[g]=i[g],p),{}),d={filterByTk:r};return i.__collection&&c&&!["oho","m2o","obo"].includes(c.interface)&&(d.targetCollection=i.__collection),!r&&Object.keys(m).length>0&&(d.filter=m),d},RecordLink=e=>{const t=(0,import_react.useField)(),o=useRecord(),r=e,{title:i,to:n}=r,a=K(r,["title","to"]),l=(0,import_template.default)(n||"");return(0,import_jsx_runtime.jsx)(import_react_router_dom.Link,P(x({},a),{to:l({record:o||{}}),children:t.title}))},ACLContext=(0,import_react2.createContext)({});ACLContext.displayName="ACLContext";const ACLProvider=e=>(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{components:{ACLCollectionFieldProvider,ACLActionProvider,ACLMenuItemProvider,ACLCollectionProvider},children:e.children}),ACLRolesCheckProvider=e=>{const{setDesignable:t}=useDesignable(),{render:o}=useAppSpin(),r=useAPIClient(),i=useApp(),n=useRequest({url:"roles:check"},{onSuccess(a){var l,c,u,m;(l=a==null?void 0:a.data)!=null&&l.snippets.includes("ui.*")||t(!1),((c=a==null?void 0:a.data)==null?void 0:c.role)!==r.auth.role&&r.auth.setRole((u=a==null?void 0:a.data)==null?void 0:u.role),i.pluginSettingsManager.setAclSnippets(((m=a==null?void 0:a.data)==null?void 0:m.snippets)||[])}});return n.loading?o():n.error?(0,import_jsx_runtime.jsx)(NavigateToSigninWithRedirect,{}):(0,import_jsx_runtime.jsx)(ACLContext.Provider,{value:n,children:e.children})},useRoleRecheck=()=>{const e=(0,import_react2.useContext)(ACLContext),{allowAll:t}=useACLRoleContext();return()=>{t||e.refresh()}},useACLContext=()=>(0,import_react2.useContext)(ACLContext),ACLActionParamsContext=(0,import_react2.createContext)({});ACLActionParamsContext.displayName="ACLActionParamsContext";const ACLCustomContext=(0,import_react2.createContext)({});ACLCustomContext.displayName="ACLCustomContext";const useACLCustomContext=()=>(0,import_react2.useContext)(ACLCustomContext),useACLRolesCheck=()=>{var e,t,o;const r=(0,import_react2.useContext)(ACLContext),i=useDataSourceKey(),{dataSources:n}=((e=r==null?void 0:r.data)==null?void 0:e.meta)||{},a=x(x({},(t=r==null?void 0:r.data)==null?void 0:t.data),(0,import_lodash.omit)(n==null?void 0:n[i],"snippets")),l=(0,import_react2.useCallback)(c=>{var u;const m=c.split(":").pop();return((u=a==null?void 0:a.actionAlias)==null?void 0:u[m])||m},[a==null?void 0:a.actionAlias]);return{data:a,getActionAlias:l,inResources:(0,import_react2.useCallback)(c=>{var u,m;return(m=(u=a==null?void 0:a.resources)==null?void 0:u.includes)==null?void 0:m.call(u,c)},[a==null?void 0:a.resources]),getResourceActionParams:(0,import_react2.useCallback)(c=>{var u,m;const[d]=c.split(":"),p=l(c);return((u=a==null?void 0:a.actions)==null?void 0:u[`${d}:${p}`])||((m=a==null?void 0:a.actions)==null?void 0:m[c])},[a==null?void 0:a.actions,l]),getStrategyActionParams:(0,import_react2.useCallback)(c=>{var u,m;const d=l(c);return(m=(u=a==null?void 0:a.strategy)==null?void 0:u.actions)!=null&&m.find(p=>{const[g]=p.split(":");return g===d})?{}:null},[(o=a==null?void 0:a.strategy)==null?void 0:o.actions,l])}},getIgnoreScope=(e={})=>{var t;const{schema:o,recordPkValue:r}=e;let i=!1;return e.ignoreScope&&(i=!0),o!=null&&o["x-acl-ignore-scope"]&&(i=!0),(t=o==null?void 0:o["x-acl-action-props"])!=null&&t.skipScopeCheck&&(i=!0),r||(i=!0),i},useAllowedActions=()=>{var e,t;const o=useResourceActionContext();return(t=(e=o==null?void 0:o.data)==null?void 0:e.meta)==null?void 0:t.allowedActions},useResourceName=()=>{var e;const t=useResourceActionContext(),o=useDataBlockProps();return(o==null?void 0:o.resource)||(o==null?void 0:o.association)||(o==null?void 0:o.collection)||((e=t==null?void 0:t.defaultRequest)==null?void 0:e.resource)};function useACLRoleContext(){const{data:e,getActionAlias:t,inResources:o,getResourceActionParams:r,getStrategyActionParams:i}=useACLRolesCheck(),n=useAllowedActions(),a=useCollectionManager(),l=(0,import_react2.useCallback)((c,u)=>{const m=t(c);return Array.isArray(n==null?void 0:n[m])?n[m].includes(u):null},[n,t]);return P(x({},e),{parseAction:(0,import_react2.useCallback)((c,u={})=>{var m;const[d,p]=(c==null?void 0:c.split(":"))||[],g=(d==null?void 0:d.includes("."))&&((m=a.getCollectionField(d))==null?void 0:m.target);if(!getIgnoreScope(u)){const h=l(p,u.recordPkValue);if(h!==null)return h?{}:null}return e!=null&&e.allowAll?{}:o(g)?r(`${g}:${p}`):o(d)?r(c):i(c)},[a,e==null?void 0:e.allowAll,r,i,o,l])})}function useUIConfigurationPermissions(){const{allowAll:e,snippets:t}=useACLRoleContext();return{allowConfigUI:e||t.includes("ui.*")}}const ACLCollectionProvider=e=>{var t,o;const{allowAll:r,parseAction:i}=useACLRoleContext(),{allowAll:n}=useACLCustomContext(),a=useApp(),l=(0,import_react.useFieldSchema)();let c=(l==null?void 0:l["x-acl-action"])||e.actionPath;const u=((t=l==null?void 0:l["x-decorator-props"])==null?void 0:t.association)||((o=l==null?void 0:l["x-decorator-props"])==null?void 0:o.collection);c==="undefined:list"&&u&&u!=="undefined"&&(c=`${u}:list`);const m=(0,import_react2.useMemo)(()=>c?i(c,{schema:l}):null,[i,c,l]);if(r||a.disableAcl||n)return e.children;if(!c)return(0,import_jsx_runtime.jsx)(ACLActionParamsContext.Provider,{value:{},children:e.children});if(!m)return(0,import_jsx_runtime.jsx)(CollectionNotAllowViewPlaceholder,{});const[d,p]=c.split(":");return m.actionName=p,(0,import_jsx_runtime.jsx)(ACLActionParamsContext.Provider,{value:m,children:e.children})},useACLActionParamsContext=()=>(0,import_react2.useContext)(ACLActionParamsContext),useRecordPkValue=()=>{const e=useCollection(),t=useCollectionRecordData();if(!e)return;const o=e.getPrimaryKey();return t==null?void 0:t[o]},ACLActionProvider=e=>{const t=useCollection(),o=useRecordPkValue(),r=useResourceName(),{parseAction:i}=useACLRoleContext(),n=(0,import_react.useFieldSchema)();let a=n["x-acl-action"];const l=["create","update","destroy","importXlsx"];!a&&r&&n["x-action"]&&(a=`${r}:${n["x-action"]}`),a!=null&&a.includes(":")||(a=`${r}:${a}`);const c=(0,import_react2.useMemo)(()=>i(a,{schema:n,recordPkValue:o}),[i,a,n,o]);return a?r?c?l.includes(a)||l.includes(a==null?void 0:a.split(":")[1])?t&&t.template!=="view"||t!=null&&t.writableView?(0,import_jsx_runtime.jsx)(ACLActionParamsContext.Provider,{value:c,children:e.children}):null:(0,import_jsx_runtime.jsx)(ACLActionParamsContext.Provider,{value:c,children:e.children}):(0,import_jsx_runtime.jsx)(ACLActionParamsContext.Provider,{value:c,children:e.children}):(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children})},useACLFieldWhitelist=()=>{const e=(0,import_react2.useContext)(ACLActionParamsContext),t=(0,import_react2.useMemo)(()=>[].concat((e==null?void 0:e.whitelist)||[]).concat((e==null?void 0:e.fields)||[]).concat((e==null?void 0:e.appends)||[]),[e==null?void 0:e.whitelist,e==null?void 0:e.fields,e==null?void 0:e.appends]);return{whitelist:t,schemaInWhitelist:(0,import_react2.useCallback)((o,r)=>{if(r||t.length===0||!o||!o["x-collection-field"])return!0;const[i,n]=o["x-collection-field"].split("."),[a]=o.name.split(".");return t==null?void 0:t.includes(a||n||i)},[t])}},ACLCollectionFieldProvider=e=>{const t=(0,import_react.useFieldSchema)(),o=(0,import_react.useField)(),{allowAll:r}=useACLRoleContext(),{whitelist:i}=useACLFieldWhitelist(),[n]=t.name.split("."),a=!t["x-acl-ignore"]&&i.length>0&&t!=null&&t["x-collection-field"]?i.includes(n):!0;return(0,import_react2.useEffect)(()=>{a||(o.required=!1,o.display="hidden")},[a,o]),r?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):t["x-collection-field"]?a?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):null:(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children})},ACLMenuItemProvider=e=>{const{allowAll:t,allowMenuItemIds:o=[],snippets:r}=useACLRoleContext(),i=(0,import_react.useFieldSchema)();return t||r.includes("ui.*")?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):i["x-uid"]?o.includes(i["x-uid"])?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children}):null:(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:e.children})},useAdminSchemaUid=()=>"nocobase-admin-menu",useViewportMeta=()=>{const e=(0,import_react2.useRef)("initial-scale=0.1"),t=(0,import_react2.useRef)();return(0,import_react2.useEffect)(()=>{let o=document.querySelector('meta[name="viewport"]');o?e.current=o.content:(o=document.createElement("meta"),o.name="viewport"),o&&(o.content="width=device-width, initial-scale=1, user-scalable=0",t.current=o)},[]),{metaRef:t,restore:()=>{t.current&&(t.current.content=e.current)}}};function useViewport(){const{metaRef:e,restore:t}=useViewportMeta();(0,import_react2.useEffect)(()=>{if(e.current)return document.head.insertBefore(e.current,document.head.firstChild),()=>{t()}},[])}const MenuItemsContext=(0,import_react2.createContext)(null);MenuItemsContext.displayName="MenuItemsContext";const toItems=(e={})=>{const t=[];for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const r=e[o],i={title:r.title,uid:r["x-uid"]};r.properties&&(i.children=toItems(r.properties)),t.push(i)}return t},useMenuItems=()=>(0,import_react2.useContext)(MenuItemsContext),MenuItemsProvider=e=>{var t,o;const r={url:`uiSchemas:getProperties/${useAdminSchemaUid()}`},i=useRequest(r);if(i.loading)return(0,import_jsx_runtime.jsx)(import_antd.Spin,{});const n=toItems((o=(t=i.data)==null?void 0:t.data)==null?void 0:o.properties);return(0,import_jsx_runtime.jsx)(MenuItemsContext.Provider,{value:{service:i,items:n},children:e.children})},findUids=e=>{if(!Array.isArray(e))return[];const t=[];for(const o of e)t.push(o.uid),t.push(...findUids(o.children));return t},getParentUids=(e,t,o=[])=>{if(!e)return[];for(const r of e){if(o.push(r.uid),t(r))return o;if(r.children){const i=getParentUids(r.children,t,o);if(i.length)return i}o.pop()}return[]},getChildrenUids=(e=[],t=[])=>{for(const o of e)t.push(o.uid),o.children&&o.children.length&&getChildrenUids(o.children,t);return t},MenuConfigure=()=>{const e=useRecord(),t=useAPIClient(),{items:o}=useMenuItems(),{t:r}=(0,import_react_i18next.useTranslation)(),i=findUids(o),[n,a]=(0,import_react2.useState)([]),{loading:l,refresh:c}=useRequest({resource:"roles.menuUiSchemas",resourceOf:e.name,action:"list",params:{paginate:!1}},{onSuccess(g){var h;a(((h=g==null?void 0:g.data)==null?void 0:h.map(f=>f["x-uid"]))||[])}}),u=t.resource("roles.menuUiSchemas",e.name),m=i.length===n.length,d=(g,h)=>q(void 0,null,function*(){const f=getParentUids(o,v=>v.uid===h.uid),_=getChildrenUids(h==null?void 0:h.children,[]);if(g){const v=_.concat(h.uid),S=n.filter(C=>!v.includes(C));a([...S]),yield u.remove({values:v})}else{const v=_.concat(f);a(S=>(0,import_lodash.uniq)([...S,...v])),yield u.add({values:v})}import_antd.message.success(r("Saved successfully"))}),p=g=>g.map(h=>{const f=r(h.title);return h.children?P(x({},h),{title:f,children:p(h.children)}):P(x({},h),{title:f})});return(0,import_jsx_runtime.jsx)(import_antd.Table,{className:antTableCell,loading:l,rowKey:"uid",pagination:!1,expandable:{defaultExpandAllRows:!0},columns:[{dataIndex:"title",title:r("Menu item title")},{dataIndex:"accessible",title:(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:m,onChange:g=>q(void 0,null,function*(){m?yield u.set({values:[]}):yield u.set({values:i}),c(),import_antd.message.success(r("Saved successfully"))})})," ",r("Accessible")]}),render:(g,h)=>{const f=n.includes(h.uid);return(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:f,onChange:()=>d(f,h)})}}],dataSource:p(o)})},SettingCenterPermissionProvider=e=>{var t;const{currentRecord:o}=(0,import_react2.useContext)(PermissionContext);return(t=o==null?void 0:o.snippets)!=null&&t.includes("pm.*")?(0,import_jsx_runtime.jsx)("div",{children:e.children}):null},PermissionContext=(0,import_react2.createContext)(null);PermissionContext.displayName="PermissionContext";const PermissionProvider=e=>{const t=useAPIClient(),o=useRecord(),{t:r}=(0,import_react_i18next.useTranslation)(),{snippets:i}=o;i==null||i.forEach(l=>{o[l]=!0});const[n,a]=(0,import_react2.useState)(o);return(0,import_jsx_runtime.jsx)(PermissionContext.Provider,{value:{currentRecord:n,update:(l,c)=>q(void 0,null,function*(){const{path:u,value:m}=l.getState();if(["ui.*","pm","pm.*"].includes(u)){const d=t.resource("roles.snippets",o.name);m?yield d.add({values:[u]}):yield d.remove({values:[u]}),a(P(x(x({},n),c.values),{[u]:m}))}else yield t.resource("roles").update({filterByTk:o.name,values:c.values}),a(x(x({},n),c.values));import_antd.message.success(r("Saved successfully"))})},children:e.children})},SnippetCheckboxGroup=(0,import_react.connect)(e=>{const{t}=(0,import_react_i18next.useTranslation)();return(0,import_jsx_runtime.jsxs)(import_antd.Checkbox.Group,{style:{width:"100%",display:"block"},value:e.value,onChange:o=>{const r=["ui.*","pm","pm.*","app"],i=r.map(a=>`!${a}`),n=(0,import_uniq.default)([...e.value||[],...o]).filter(a=>a&&!i.includes(a)).map(a=>!r.includes(a)||o!=null&&o.includes(a)?a:`!${a}`);for(const a of r)!n.includes(a)&&!n.includes(`!${a}`)&&n.push(`!${a}`);e.onChange(n)},children:[(0,import_jsx_runtime.jsx)("div",{style:{marginTop:16},children:(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{value:"ui.*",children:t("Allows to configure interface")})}),(0,import_jsx_runtime.jsx)("div",{style:{marginTop:8},children:(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{value:"pm",children:t("Allows to install, activate, disable plugins")})}),(0,import_jsx_runtime.jsx)("div",{style:{marginTop:8},children:(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{value:"pm.*",children:t("Allows to configure plugins")})}),(0,import_jsx_runtime.jsx)("div",{style:{marginTop:8},children:(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{value:"app",children:t("Allows to clear cache, reboot application")})})]})}),RoleConfigure=()=>{const{update:e,currentRecord:t}=(0,import_react2.useContext)(PermissionContext),{t:o}=(0,import_react_i18next.useTranslation)();return(0,import_jsx_runtime.jsx)(SchemaComponent,{components:{SnippetCheckboxGroup},schema:{type:"void",name:"form","x-component":"Form","x-component-props":{useValues:r=>{const i=useAPIClient();return useRequest(()=>i.resource("roles").get({filterByTk:t.name}).then(n=>{var a,l;const c=(a=n==null?void 0:n.data)==null?void 0:a.data;return(l=c.snippets)==null||l.forEach(u=>{c[u]=!0}),{data:c}}),r)},effects(){(0,import_core2.onFieldChange)("*",(r,i)=>q(this,null,function*(){i.modified&&(yield e(r,i))}))}},properties:{snippets:{title:o("Configure permissions"),type:"boolean","x-decorator":"FormItem","x-component":"SnippetCheckboxGroup"},allowNewMenu:{title:o("Menu permissions"),"x-decorator":"FormItem","x-component":"Checkbox","x-content":o("New menu items are allowed to be accessed by default.")}}}})},collection={name:"roles",filterTargetKey:"name",targetKey:"name",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Role display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Role UID")}}',type:"string","x-component":"Input"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{title:'{{t("Default role")}}',type:"boolean","x-component":"Checkbox"}}]},roleSchema={type:"object",properties:{block1:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection,resourceName:"roles",request:{resource:"roles",action:"list",params:{pageSize:50,filter:{"name.$ne":"root"},showAnonymous:!0,sort:["createdAt"],appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete role')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add role")}}',"x-component":"Action","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(e){const t=useActionContext();return useRequest(()=>Promise.resolve({data:{name:`r_${(0,import_shared.uid)()}`,snippets:["!ui.*","!pm","!pm.*"]}}),P(x({},e),{refreshDeps:[t.visible]}))}},title:'{{t("Add role")}}',properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'},default:{"x-component":"CollectionField","x-decorator":"FormItem",title:"","x-content":'{{t("Default role")}}'},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{column1:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{default:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-decorator":"ACLActionProvider","x-acl-action":"roles:update","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"PermissionProvider",title:'{{t("Configure permissions")}}',properties:{tabs1:{type:"void","x-component":"Tabs","x-component-props":{},properties:{tab1:{type:"void",title:'{{t("General permissions")}}',"x-component":"Tabs.TabPane","x-component-props":{},properties:{role:{"x-component":"RoleConfigure"}}},tab3:{type:"void",title:'{{t("Menu permissions")}}',"x-component":"Tabs.TabPane","x-component-props":{},properties:{menu:{"x-decorator":"MenuItemsProvider","x-component":"MenuConfigure"}}},tab4:{type:"void",title:'{{t("Plugin settings permissions")}}',"x-decorator":"SettingCenterPermissionProvider","x-component":"Tabs.TabPane","x-component-props":{},properties:{menu:{"x-decorator":"SettingCenterProvider","x-component":"SettingsCenterConfigure"}}}}}}}}},update:{type:"void",title:'{{t("Edit")}}',"x-decorator":"ACLActionProvider","x-acl-action":"roles:update","x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:e=>{const t=useRecord(),o=useRequest(()=>Promise.resolve({data:(0,import_pick.default)(t,["title","name","default"])}),P(x({},e),{manual:!0})),r=useActionContext();return(0,import_react2.useEffect)(()=>{r.visible&&o.run()},[r.visible]),o}},title:'{{t("Edit role")}}',properties:{title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},default:{title:"","x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Default role")}}'},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-acl-action":"roles:destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete role')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}}}},AvailableActionsContext=(0,import_react2.createContext)([]);AvailableActionsContext.displayName="AvailableActionsContext";const AvailableActionsProver=e=>{const{data:t,loading:o}=useRequest({resource:"availableActions",action:"list"});return o?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):(0,import_jsx_runtime.jsx)(AvailableActionsContext.Provider,{value:t==null?void 0:t.data,children:e.children})},useAvailableActions=()=>(0,import_react2.useContext)(AvailableActionsContext),RoleTable=()=>(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:{designable:!1},children:(0,import_jsx_runtime.jsx)(AvailableActionsProver,{children:(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:roleSchema,components:{MenuItemsProvider,SettingCenterPermissionProvider,PermissionProvider}})})})}),rolesResourcesScopesCollection={name:"rolesResourcesScopes",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Scope name")}}',type:"string","x-component":"Input",required:!0}}]},useFormBlockProps=()=>{const{name:e}=(0,import_react2.useContext)(RoleResourceCollectionContext),t=useFormBlockContext();return(0,import_react2.useEffect)(()=>{t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},scopesSchema={type:"object",properties:{scope:{"x-component":"RecordPicker","x-component-props":{size:"small",fieldNames:{label:"name",value:"id"},multiple:!1,association:{target:"rolesResourcesScopes"},onChange:"{{ onChange }}"},properties:{selector:{type:"void",title:'{{ t("Select record") }}',"x-component":"RecordPicker.Selector","x-component-props":{className:"nb-record-picker-selector"},properties:{tableBlock:{type:"void","x-decorator":"TableSelectorProvider","x-decorator-props":{collection:rolesResourcesScopesCollection,resource:"rolesResourcesScopes",action:"list",params:{pageSize:20},useParams(){return{filter:{$or:[{resourceName:(0,import_react2.useContext)(RoleResourceCollectionContext).name},{resourceName:null}]}}},rowKey:"id"},"x-component":"BlockItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{create:{type:"void",title:'{{ t("Add new") }}',"x-action":"create","x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:rolesResourcesScopesCollection},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":useFormBlockProps,properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const e=(0,import_react2.useContext)(RoleResourceCollectionContext);return{options:useFilterOptions(e.name)}},"x-component-props":{dynamicComponent:VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}}}},value:{type:"array","x-component":"TableV2.Selector","x-use-component-props":"useTableSelectorProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-component":"TableV2.Column",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"rolesResourcesScopes",collection:rolesResourcesScopesCollection,action:"get",useParams:"{{ useParamsFromRecord }}"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const e=(0,import_react2.useContext)(RoleResourceCollectionContext);return{options:useFilterOptions(e.name)}},"x-component-props":{dynamicComponent:VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{update:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}},destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"usePickActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}},RolesResourcesScopesSelectedRowKeysContext=(0,import_react2.createContext)(null);RolesResourcesScopesSelectedRowKeysContext.displayName="RolesResourcesScopesSelectedRowKeysContext";const RolesResourcesScopesSelectedRowKeysProvider=e=>{const[t,o]=(0,import_react2.useState)([]);return(0,import_jsx_runtime.jsx)(RolesResourcesScopesSelectedRowKeysContext.Provider,{value:[t,o],children:e.children})},useRolesResourcesScopesSelectedRowKeys=()=>(0,import_react2.useContext)(RolesResourcesScopesSelectedRowKeysContext),ScopeSelect=e=>{const t=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)({values:{scope:e.value}}),[]);return(0,import_jsx_runtime.jsx)(FormProvider,{form:t,children:(0,import_jsx_runtime.jsx)(SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider},scope:{onChange(o){var r;(r=e==null?void 0:e.onChange)==null||r.call(e,o)}},schema:scopesSchema})})},toActionMap=e=>{var t;const o={};return(t=e==null?void 0:e.forEach)==null||t.call(e,r=>{r.name&&(o[r.name]=r,o[r.name].scope=(0,import_lodash.isEmpty)(r.scope)?null:r.scope)}),o},RoleResourceCollectionContext=(0,import_react2.createContext)({});RoleResourceCollectionContext.displayName="RoleResourceCollectionContext";const RolesResourcesActions=(0,import_react.connect)(e=>{var t,o,r,i;const n=F=>{const j=F.map(k=>P(x({},k),{scope:(0,import_lodash.isEmpty)(k.scope)?null:k.scope}));e.onChange(j)};(0,import_react.useForm)();const a=useRecord(),l=useAvailableActions(),{getCollection:c,getCollectionFields:u}=useCollectionManager_deprecated(),m=c(a.collectionName),d=u(a.collectionName),p=useCompile(),{t:g}=(0,import_react_i18next.useTranslation)(),h=(0,import_react.useField)(),f=toActionMap(h.value||[]),_=(F,j)=>{var k;const T=f==null?void 0:f[F];return T?(k=T==null?void 0:T.fields)==null?void 0:k.includes(j):!1},v=l.filter(F=>F.allowConfigureFields),S=(t=d==null?void 0:d.filter(F=>F.interface))==null?void 0:t.map(F=>{const j=x({},F);for(const k of v)j[k.name]=_(k.name,F.name);return j}),C=F=>{var j,k;f[F]?delete f[F]:f[F]={name:F,fields:(k=(j=d==null?void 0:d.filter(T=>T.interface))==null?void 0:j.map)==null?void 0:k.call(j,T=>T.name)},n(Object.values(f))},b=(F,j)=>{f[F]?(f[F].scope=j,n(Object.values(f))):(C(F),f[F].scope=j)},y={};for(const F of v)y[F.name]=((o=d==null?void 0:d.filter(j=>j.interface))==null?void 0:o.length)===((i=(r=f==null?void 0:f[F.name])==null?void 0:r.fields)==null?void 0:i.length);return(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsx)(RoleResourceCollectionContext.Provider,{value:m,children:(0,import_jsx_runtime.jsxs)(import_antd_v5.FormLayout,{layout:"vertical",children:[(0,import_jsx_runtime.jsx)(import_antd_v5.FormItem,{label:g("Action permission"),children:(0,import_jsx_runtime.jsx)(import_antd.Table,{className:antTableCell,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:g("Action display name"),render:F=>p(F)},{dataIndex:"onNewRecord",title:g("Action type"),render:F=>F?(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:"green",children:g("Action on new records")}):(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:"geekblue",children:g("Action on existing records")})},{dataIndex:"enabled",title:g("Allow"),render:(F,j)=>(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:F,onChange:()=>{C(j.name)}})},{dataIndex:"scope",title:g("Data scope"),render:(F,j)=>!j.onNewRecord&&(0,import_jsx_runtime.jsx)(ScopeSelect,{value:F,onChange:k=>{b(j.name,k)}})}],dataSource:l==null?void 0:l.map(F=>{let j=!1,k=null;return f[F.name]&&(j=!0,F.onNewRecord||(k=f[F.name].scope)),P(x({},F),{enabled:j,scope:k})})})}),(0,import_jsx_runtime.jsx)(import_antd_v5.FormItem,{label:g("Field permission"),children:(0,import_jsx_runtime.jsx)(import_antd.Table,{className:antTableCell,pagination:!1,dataSource:S,columns:[{dataIndex:["uiSchema","title"],title:g("Field display name"),render:F=>p(F)},...v.map(F=>{const j=y==null?void 0:y[F.name];return{dataIndex:F.name,title:(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:j,onChange:()=>{var k;const T=f[F.name]||{name:F.name};j?T.fields=[]:T.fields=(k=d==null?void 0:d.map)==null?void 0:k.call(d,O=>O.name),f[F.name]=T,n(Object.values(f))}})," ",p(F.displayName)]}),render:(k,T)=>(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:k,"aria-label":`${F.name}_checkbox`,onChange:()=>{const O=f[F.name]||{name:F.name},N=O.fields||[];if(k){const L=N.indexOf(T.name);N.splice(L,1)}else N.push(T.name);O.fields=N,f[F.name]=O,n(Object.values(f))}})}})]})})]})})})}),toScopes=e=>{var t;if(!e)return{};const o={};return(t=e==null?void 0:e.forEach)==null||t.call(e,r=>{const[i,n]=r.split(":");o[i]=n||"all"}),o},toFieldValue=e=>{const t=[];for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const r=e[o];r==="all"?t.push(o):t.push(`${o}:${r}`)}return t},StrategyActions=(0,import_react.connect)(e=>{const{onChange:t}=e,o=useAvailableActions(),r=useCompile(),{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useField)(),a=toScopes(n.value);return(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsx)(import_antd.Table,{size:"small",pagination:!1,rowKey:"name",columns:[{dataIndex:"displayName",title:i("Action display name"),render:l=>r(l)},{dataIndex:"onNewRecord",title:i("Action type"),render:l=>l?(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:"green",children:i("Action on new records")}):(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:"geekblue",children:i("Action on existing records")})},{dataIndex:"enabled",title:i("Allow"),render:(l,c)=>(0,import_jsx_runtime.jsx)(import_antd.Checkbox,{checked:l,"aria-label":`${c.name}_checkbox`,onChange:u=>{l?delete a[c.name]:a[c.name]="all",t(toFieldValue(a))}})},{dataIndex:"scope",title:i("Data scope"),render:(l,c)=>!c.onNewRecord&&(0,import_jsx_runtime.jsx)(import_antd.Select,{"data-testid":"select-data-scope",popupMatchSelectWidth:!1,size:"small",value:l,options:[{label:i("All records"),value:"all"},{label:i("Own records"),value:"own"}],onChange:u=>{a[c.name]=u,t(toFieldValue(a))}})}],dataSource:o==null?void 0:o.map(l=>{let c="all",u=!1;return a[l.name]&&(u=!0,c=a[l.name]),P(x({},l),{enabled:u,scope:c})})})})}),PluginManagerLink=()=>{const{t:e}=(0,import_react_i18next.useTranslation)(),t=useNavigateNoUpdate(),{token:o}=useToken$1();return(0,import_jsx_runtime.jsx)(import_antd.Tooltip,{title:e("Plugin manager"),children:(0,import_jsx_runtime.jsx)(import_antd.Button,{"data-testid":"plugin-manager-button",icon:(0,import_jsx_runtime.jsx)(import_icons.ApiOutlined,{style:{color:o.colorTextHeaderMenu}}),title:e("Plugin manager"),onClick:()=>{t("/admin/pm/list")}})})},SettingsCenterDropdown=()=>{const e=useCompile(),{t}=(0,import_react_i18next.useTranslation)(),{token:o}=useToken$1(),r=useApp(),i=(0,import_react2.useMemo)(()=>r.pluginSettingsManager.getList().filter(n=>n.isTopLevel!==!1).map(n=>({key:n.name,icon:n.icon,label:n.link?(0,import_jsx_runtime.jsx)("div",{onClick:()=>window.open(n.link),children:e(n.title)}):(0,import_jsx_runtime.jsx)(import_react_router_dom.Link,{to:n.path,children:e(n.title)})})),[r,t]);return(0,import_react2.useEffect)(()=>()=>{r.pluginSettingsManager.clearCache()},[r.pluginSettingsManager]),(0,import_jsx_runtime.jsx)(import_antd.Dropdown,{menu:{style:{maxHeight:"70vh",overflow:"auto"},items:i},children:(0,import_jsx_runtime.jsx)(import_antd.Button,{"data-testid":"plugin-settings-button",icon:(0,import_jsx_runtime.jsx)(import_icons.SettingOutlined,{style:{color:o.colorTextHeaderMenu}})})})},useStyles$1=(0,import_antd_style.createStyles)(({token:e})=>({cardActionDisabled:{color:e.colorTextDisabled,cursor:"not-allowed"},pageHeader:{backgroundColor:e.colorBgContainer,paddingTop:e.paddingSM,paddingBottom:0,paddingInline:e.paddingLG,".ant-page-header-footer":{marginBlockStart:"0"},"& .ant-tabs-nav":{marginBottom:0},".ant-page-header-heading-title":{color:e.colorText}},pageContent:{margin:e.marginLG},PluginDetailBaseInfo:{display:"flex",flexDirection:"column",marginBottom:e.margin},PluginDocument:{background:e.colorBgContainer,padding:e.paddingLG,height:"60vh",overflowY:"auto"},avatar:{".ant-card-meta-avatar":{marginTop:"8px",".ant-avatar":{borderRadius:"2px"}}},version:{display:"block",color:e.colorTextDescription,fontWeight:"normal",fontSize:e.fontSize}}));import_dayjs.default.extend(import_relativeTime.default);const PluginDetail=({plugin:e,onCancel:t})=>{var o,r,i,n,a,l,c,u;const{t:m}=(0,import_react_i18next.useTranslation)(),d=(0,import_react2.useMemo)(()=>[{title:m("Name"),dataIndex:"name",key:"name"},{title:m("Version range"),dataIndex:"versionRange",key:"versionRange"},{title:m("Plugin's version"),dataIndex:"packageVersion",key:"packageVersion"},{title:m("Result"),dataIndex:"result",key:"result",render:C=>(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:C?"success":"error",children:C?"Yes":"No"})}],[m]),{data:p,loading:g}=useRequest({url:"pm:get",params:{filterByTk:e.name}},{refreshDeps:[e.name],ready:!!e.name}),h=(0,import_react2.useMemo)(()=>{var C,b,y;if(!((b=(C=p==null?void 0:p.data)==null?void 0:C.packageJson)!=null&&b.repository))return null;const F=(y=p==null?void 0:p.data)==null?void 0:y.packageJson.repository;return(typeof F=="string"?F:F.url).replace(/\.git$/,"").replace(/^git\+/,"")},[p]),f=(0,import_react2.useMemo)(()=>{var C;const b=(C=p==null?void 0:p.data)==null?void 0:C.packageJson.author;return b?typeof b=="string"?b:b.name:null},[p]),{styles:_,theme:v}=useStyles$1(),S=[{key:"readme",label:m("Readme"),children:(0,import_jsx_runtime.jsxs)(import_antd.Row,{gutter:20,children:[e.name&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Name")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:e.name})]})}),e.displayName&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("DisplayName")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:e.displayName})]})}),(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("PackageName")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:e.packageName})]})}),h&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Repository")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:h})]})}),((o=p==null?void 0:p.data)==null?void 0:o.homepage)&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Homepage")}),(0,import_jsx_runtime.jsx)("a",{href:(r=p==null?void 0:p.data)==null?void 0:r.homepage,target:"_blank",rel:"noreferrer",children:(i=p==null?void 0:p.data)==null?void 0:i.homepage})]})}),e.description&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Description")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:e.description})]})}),((n=p==null?void 0:p.data)==null?void 0:n.packageJson.license)&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("License")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:(a=p==null?void 0:p.data)==null?void 0:a.packageJson.license})]})}),f&&(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Author")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:f})]})}),(0,import_jsx_runtime.jsx)(import_antd.Col,{span:24,children:(0,import_jsx_runtime.jsxs)("div",{className:_.PluginDetailBaseInfo,children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"secondary",children:m("Version")}),(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{strong:!0,children:e==null?void 0:e.version})]})})]})},{key:"dependencies",label:m("Dependencies compatibility check"),children:(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:((l=p==null?void 0:p.data)==null?void 0:l.depsCompatible)===!1?(0,import_jsx_runtime.jsx)(import_antd.Typography.Text,{type:"danger",children:m("`dist/externalVersion.js` not found or failed to `require`. Please rebuild this plugin.")}):(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[!((c=p==null?void 0:p.data)!=null&&c.isCompatible)&&(0,import_jsx_runtime.jsx)(import_antd.Alert,{showIcon:!0,type:"error",message:m("Plugin dependencies check failed, you should change the dependent version to meet the version requirements.")}),(0,import_jsx_runtime.jsx)(import_antd.Table,{style:{marginTop:v.margin},rowKey:"name",pagination:!1,columns:d,dataSource:(u=p==null?void 0:p.data)==null?void 0:u.depsCompatible})]})})}];return(0,import_jsx_runtime.jsx)(import_antd.Modal,{open:!!e,footer:!1,destroyOnClose:!0,width:600,onCancel:t,children:g?(0,import_jsx_runtime.jsx)(import_antd.Spin,{}):e&&(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)(import_antd.Typography.Title,{level:3,children:e.packageName}),(0,import_jsx_runtime.jsx)(import_antd.Space,{split:(0,import_jsx_runtime.jsx)("span",{children:" • "}),children:(0,import_jsx_runtime.jsx)("span",{children:e.version})}),(0,import_jsx_runtime.jsx)(import_antd.Tabs,{style:{minHeight:"50vh"},items:S,defaultActiveKey:e.isCompatible?void 0:"dependencies"})]})})},PluginNpmForm=({onClose:e,isUpgrade:t,pluginData:o})=>{import_antd.App.useApp();const r=[],i=()=>{const c=useAPIClient();(0,import_react_i18next.useTranslation)();const u=(0,import_react.useForm)();return{run(){return q(this,null,function*(){yield u.submit(),c.request({url:t?"pm:update":"pm:add",method:"post",data:x({},u.values)}),e(!0)})}}},n=c=>useRequest(()=>Promise.resolve({data:t?(0,import_lodash.pick)(o,["name","packageName","version"]):{}}),c),a=()=>({run(){e()}}),l=(0,import_react2.useMemo)(()=>{const c=(0,import_shared.uid)(),u={type:"object",properties:{[c]:{"x-decorator":"Form","x-component":"div",type:"void","x-decorator-props":{useValues:"{{ useValuesFromProps }}"},properties:{packageName:{type:"string",title:"{{t('Npm package name')}}","x-decorator":"FormItem","x-component":"Input",required:!0,"x-component-props":{disabled:!0}},registry:{type:"string",title:"{{t('Registry url')}}",default:"https://registry.npmjs.org/","x-decorator":"FormItem","x-component":"Input","x-decorator-props":{tooltip:"Example: https://registry.npmjs.org/"}},authToken:{type:"string",title:"{{t('Npm authToken')}}","x-decorator":"FormItem","x-component":"Input"},version:{type:"string",title:"{{t('Version')}}","x-decorator":"FormItem","x-component":"Input"},footer:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{justifyContent:"right"}},properties:{cancel:{title:"Cancel","x-component":"Action","x-component-props":{useAction:"{{ useCancel }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useSaveValues }}"}}}}}}}};return u.properties[c].properties.packageName["x-component-props"].disabled=t,t||delete u.properties[c].properties.version,u},[t]);return(0,import_jsx_runtime.jsx)(SchemaComponent,{scope:{useCancel:a,useSaveValues:i,versionList:r,useValuesFromProps:n},schema:l})};PluginNpmForm.displayName="PluginNpmForm";const PluginUploadForm=({onClose:e,pluginData:t,isUpgrade:o})=>{const{message:r}=import_antd.App.useApp(),i=()=>{const l=useAPIClient(),{t:c}=(0,import_react_i18next.useTranslation)(),u=(0,import_react.useForm)();return{run(){return q(this,null,function*(){var m,d;yield u.submit();const p=new FormData;p.append("file",(d=(m=u.values.uploadFile)==null?void 0:m[0])==null?void 0:d.originFileObj),t!=null&&t.packageName&&p.append("packageName",t.packageName),yield l.request({url:`pm:${o?"update":"add"}`,method:"post",data:p}),import_antd.Modal.info({icon:null,width:520,content:(0,import_jsx_runtime.jsx)(import_antd.Result,{icon:(0,import_jsx_runtime.jsx)(import_icons.LoadingOutlined,{}),title:c("Plugin uploading"),subTitle:c("Plugin is uploading, please wait...")}),footer:null}),e(!0);function g(){l.silent().request({url:"__health_check",method:"get"}).then(h=>{(h==null?void 0:h.data)==="ok"&&window.location.reload()}).catch(h=>{})}setInterval(g,1e3)})}}},n=()=>({run(){e()}}),a=(0,import_react2.useMemo)(()=>({type:"object",properties:{[(0,import_shared.uid)()]:{"x-decorator":"Form","x-component":"div",type:"void",properties:{uploadFile:{type:"string","x-decorator":"FormItem","x-component":"Upload.Dragger",required:!0,"x-component-props":{action:"",multiple:!1,maxCount:1,height:"150px",tipContent:"{{t('Drag and drop the file here or click to upload, file size should not exceed 30M')}}",beforeUpload:l=>(/\.(zip|rar|tar|gz|bz2|tgz)$/.test(l.name)||r.error("File only support zip, rar, tar, gz, bz2!"),l.size/1024/1024<30||r.error("File must smaller than 30MB!"),!1)}},footer:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{justifyContent:"right"}},properties:{cancel:{title:"Cancel","x-component":"Action","x-component-props":{useAction:"{{ useCancel }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useSaveValues }}"}}}}}}}}),[r]);return(0,import_jsx_runtime.jsx)(SchemaComponent,{scope:{useCancel:n,useSaveValues:i},schema:a})},PluginUrlForm=({onClose:e,pluginData:t,isUpgrade:o})=>{import_antd.App.useApp();const r=()=>{const l=useAPIClient();(0,import_react_i18next.useTranslation)();const c=(0,import_react.useForm)();return{run(){return q(this,null,function*(){const u=c.values.compressedFileUrl;if(!u)return;yield c.submit();const m={compressedFileUrl:u};t!=null&&t.packageName&&(m.packageName=t.packageName),l.request({url:`pm:${o?"update":"add"}`,method:"post",data:m}),e(!0)})}}},i=l=>useRequest(()=>Promise.resolve({data:{compressedFileUrl:t.compressedFileUrl}}),l),n=()=>({run(){e()}}),a=(0,import_react2.useMemo)(()=>({type:"object",properties:{[(0,import_shared.uid)()]:{"x-decorator":"Form","x-component":"div",type:"void","x-decorator-props":{useValues:"{{ useValuesFromProps }}"},properties:{compressedFileUrl:{type:"string","x-decorator":"FormItem","x-component":"Input",required:!0},footer:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{justifyContent:"right"}},properties:{cancel:{title:"Cancel","x-component":"Action","x-component-props":{useAction:"{{ useCancel }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",htmlType:"submit",useAction:"{{ useSaveValues }}"}}}}}}}}),[]);return(0,import_jsx_runtime.jsx)(SchemaComponent,{scope:{useCancel:n,useValuesFromProps:i,useSaveValues:r},schema:a})},PluginUpgradeModal=({onClose:e,isShow:t,pluginData:o})=>{const{t:r}=(0,import_react_i18next.useTranslation)(),{theme:i}=useStyles$1(),[n,a]=(0,import_react2.useState)("npm");return(0,import_jsx_runtime.jsxs)(import_antd.Modal,{onCancel:()=>e(),footer:null,destroyOnClose:!0,title:r("Update plugin"),width:580,open:t,children:[(0,import_jsx_runtime.jsx)("div",{style:{marginTop:i.marginLG,marginBottom:i.marginLG},children:(0,import_jsx_runtime.jsxs)(import_antd.Radio.Group,{optionType:"button",defaultValue:n,onChange:l=>a(l.target.value),children:[(0,import_jsx_runtime.jsx)(import_antd.Radio,{value:"npm",children:r("Npm package")}),(0,import_jsx_runtime.jsx)(import_antd.Radio,{value:"upload",children:r("Upload plugin")}),(0,import_jsx_runtime.jsx)(import_antd.Radio,{value:"url",children:r("Compressed file url")})]})}),n==="npm"&&(0,import_jsx_runtime.jsx)(PluginNpmForm,{isUpgrade:!0,onClose:e,pluginData:o}),n==="upload"&&(0,import_jsx_runtime.jsx)(PluginUploadForm,{isUpgrade:!0,onClose:e,pluginData:o}),n==="url"&&(0,import_jsx_runtime.jsx)(PluginUrlForm,{isUpgrade:!0,onClose:e,pluginData:o})]})};function PluginInfo(e){const{data:t,onClick:o}=e,r=useApp(),{name:i,displayName:n,isCompatible:a,packageName:l,updatable:c,builtIn:u,enabled:m,removable:d,description:p,error:g,homepage:h}=t,{styles:f,theme:_}=useStyles$1(),v=(0,import_react_router_dom.useNavigate)(),{t:S}=(0,import_react_i18next.useTranslation)(),C=useAPIClient(),{modal:b}=import_antd.App.useApp(),[y,F]=(0,import_react2.useState)(!1),j=n||i||l;return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[y&&(0,import_jsx_runtime.jsx)(PluginUpgradeModal,{isShow:y,pluginData:t,onClose:k=>{F(!1)}}),(0,import_jsx_runtime.jsx)(import_antd.Card,{role:"button","aria-label":j,size:"small",bordered:!1,onClick:()=>{!g&&o()},headStyle:{border:"none",minHeight:"inherit",paddingTop:14},bodyStyle:{paddingTop:10},title:(0,import_jsx_runtime.jsx)("div",{children:j}),hoverable:!0,className:import_css.css`
1332
1332
  .ant-card-actions {
1333
1333
  li .ant-space {
1334
1334
  gap: 2px !important;
@@ -1586,4 +1586,4 @@ https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModu
1586
1586
  color: ${i.colorText};
1587
1587
  }
1588
1588
  }
1589
- `,u=`<span class="nb-app-version">v${(e=a==null?void 0:a.data)==null?void 0:e.version}</span>`;return(0,import_jsx_runtime.jsx)("div",{className:(0,import_css.cx)(c,"nb-brand"),dangerouslySetInnerHTML:{__html:(0,import_client.parseHTML)(((o=(t=n==null?void 0:n.options)==null?void 0:t.options)==null?void 0:o.brand)||`Powered by <a href="${l[r.language]||l["en-US"]}" target="_blank">NocoBase</a>`,{appVersion:u})}})};class MockAPIClient extends APIClient{mockAdapter(){const t=require("axios-mock-adapter");return new t(this.axios)}}const mockAPIClient=()=>{const e=new MockAPIClient,t=e.mockAdapter();return{apiClient:e,mockRequest:t}},PopupContextProvider=e=>{var t,o;const{visible:r,setVisible:i}=e,[n,a]=(0,import_react2.useState)(!1),{visible:l,setVisible:c}=(0,import_react2.useContext)(PopupVisibleProviderContext)||{visible:!1,setVisible:()=>{}},u=(0,import_react.useFieldSchema)(),m=(0,import_react2.useCallback)(g=>{i==null||i(g),a==null||a(g),c==null||c(g)},[i,c]),d=((t=u["x-component-props"])==null?void 0:t.openMode)||"drawer",p=(o=u["x-component-props"])==null?void 0:o.openSize;return(0,import_jsx_runtime.jsx)(PopupVisibleProvider,{visible:!1,children:(0,import_jsx_runtime.jsx)(ActionContextProvider,{visible:r||n||l,setVisible:m,openMode:d,openSize:p,children:e.children})})};function SwitchLanguage(){var e,t,o;const{data:r}=useSystemSettings()||{},i=useAPIClient();return((e=r==null?void 0:r.data)==null?void 0:e.enabledLanguages.length)>1&&(0,import_jsx_runtime.jsx)(import_antd.Dropdown,{menu:{onClick(n){i.auth.setLocale(n.key),window.location.reload()},selectable:!0,defaultSelectedKeys:[i.auth.locale],items:(o=(t=r==null?void 0:r.data)==null?void 0:t.enabledLanguages)==null?void 0:o.map(n=>({key:n,label:languageCodes[n].label}))},children:(0,import_jsx_runtime.jsx)(import_icons.TranslationOutlined,{style:{fontSize:24}})})}
1589
+ `,u=`<span class="nb-app-version">v${(e=a==null?void 0:a.data)==null?void 0:e.version}</span>`;return(0,import_jsx_runtime.jsx)("div",{className:(0,import_css.cx)(c,"nb-brand"),dangerouslySetInnerHTML:{__html:(0,import_client.parseHTML)(((o=(t=n==null?void 0:n.options)==null?void 0:t.options)==null?void 0:o.brand)||`Powered by <a href="${l[r.language]||l["en-US"]}" target="_blank">NocoBase</a>`,{appVersion:u})}})};class MockAPIClient extends APIClient{mockAdapter(){const t=require("axios-mock-adapter");return new t(this.axios)}}const mockAPIClient=()=>{const e=new MockAPIClient,t=e.mockAdapter();return{apiClient:e,mockRequest:t}},PopupContextProvider=e=>{var t,o;const{visible:r,setVisible:i}=e,[n,a]=(0,import_react2.useState)(!1),[l,c]=(0,import_react2.useState)(!1),{visible:u,setVisible:m}=(0,import_react2.useContext)(PopupVisibleProviderContext)||{visible:!1,setVisible:()=>{}},d=(0,import_react.useFieldSchema)(),p=(0,import_react2.useCallback)(f=>{i==null||i(f),a==null||a(f),m==null||m(f)},[i,m]),g=((t=d["x-component-props"])==null?void 0:t.openMode)||"drawer",h=(o=d["x-component-props"])==null?void 0:o.openSize;return(0,import_jsx_runtime.jsx)(PopupVisibleProvider,{visible:!1,children:(0,import_jsx_runtime.jsx)(ActionContextProvider,{visible:r||n||u,setVisible:p,openMode:g,openSize:h,formValueChanged:l,setFormValueChanged:c,children:e.children})})};function SwitchLanguage(){var e,t,o;const{data:r}=useSystemSettings()||{},i=useAPIClient();return((e=r==null?void 0:r.data)==null?void 0:e.enabledLanguages.length)>1&&(0,import_jsx_runtime.jsx)(import_antd.Dropdown,{menu:{onClick(n){i.auth.setLocale(n.key),window.location.reload()},selectable:!0,defaultSelectedKeys:[i.auth.locale],items:(o=(t=r==null?void 0:r.data)==null?void 0:t.enabledLanguages)==null?void 0:o.map(n=>({key:n,label:languageCodes[n].label}))},children:(0,import_jsx_runtime.jsx)(import_icons.TranslationOutlined,{style:{fontSize:24}})})}