@nocobase/client 1.5.20 → 1.5.21
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/es/index.mjs +11 -6
- package/lib/index.js +5 -2
- package/package.json +5 -5
package/es/index.mjs
CHANGED
|
@@ -12076,9 +12076,11 @@ const InternalDetailsBlockProvider = (e) => {
|
|
|
12076
12076
|
}
|
|
12077
12077
|
return { params: n, parseVariableLoading: o };
|
|
12078
12078
|
}, DetailsBlockProvider = withDynamicSchemaProps((e) => {
|
|
12079
|
-
const { params: t, parseVariableLoading: n } = useCompatDetailsBlockParams(e), o = useCollectionRecordData(), { association: r, dataSource: i
|
|
12079
|
+
const { params: t, parseVariableLoading: n } = useCompatDetailsBlockParams(e), o = useCollectionRecordData(), { association: r, dataSource: i, action: a } = e;
|
|
12080
|
+
useCollectionManager_deprecated(i);
|
|
12081
|
+
const { __collection: l } = o || {}, { designable: c } = useDesignable(), u = e.collection;
|
|
12080
12082
|
let d = !0;
|
|
12081
|
-
!c && l && (d = l === u);
|
|
12083
|
+
!c && l && a === "get" && !r && (d = l === u);
|
|
12082
12084
|
const p = useUpdate();
|
|
12083
12085
|
return !d || n ? null : /* @__PURE__ */ jsx(TemplateBlockProvider, { onTemplateLoaded: p, children: /* @__PURE__ */ jsx(BlockProvider, P(x({ name: "details" }, e), { params: t, children: /* @__PURE__ */ jsx(InternalDetailsBlockProvider, x({}, e)) })) });
|
|
12084
12086
|
}), useDetailsBlockContext = () => useContext(DetailsBlockContext), useDetailsBlockProps = () => {
|
|
@@ -27590,6 +27592,9 @@ const formItemWrapCss = css`
|
|
|
27590
27592
|
max-width: 100%;
|
|
27591
27593
|
}
|
|
27592
27594
|
`, formItemLabelCss = css`
|
|
27595
|
+
.ant-card-body {
|
|
27596
|
+
padding: 0px !important;
|
|
27597
|
+
}
|
|
27593
27598
|
> .ant-formily-item-label {
|
|
27594
27599
|
display: none;
|
|
27595
27600
|
}
|
|
@@ -35211,7 +35216,7 @@ function addAppVersion(e, t) {
|
|
|
35211
35216
|
addAppVersion((o = e.properties) == null ? void 0 : o[n], t);
|
|
35212
35217
|
}), e;
|
|
35213
35218
|
}
|
|
35214
|
-
const name = "@nocobase/client", version = "1.5.
|
|
35219
|
+
const name = "@nocobase/client", version = "1.5.21", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
|
|
35215
35220
|
"@ahooksjs/use-url-state": "3.5.1",
|
|
35216
35221
|
"@ant-design/cssinjs": "^1.11.1",
|
|
35217
35222
|
"@ant-design/icons": "^5.1.4",
|
|
@@ -35233,9 +35238,9 @@ const name = "@nocobase/client", version = "1.5.20", license = "AGPL-3.0", main
|
|
|
35233
35238
|
"@formily/reactive-react": "^2.2.27",
|
|
35234
35239
|
"@formily/shared": "^2.2.27",
|
|
35235
35240
|
"@formily/validator": "^2.2.27",
|
|
35236
|
-
"@nocobase/evaluators": "1.5.
|
|
35237
|
-
"@nocobase/sdk": "1.5.
|
|
35238
|
-
"@nocobase/utils": "1.5.
|
|
35241
|
+
"@nocobase/evaluators": "1.5.21",
|
|
35242
|
+
"@nocobase/sdk": "1.5.21",
|
|
35243
|
+
"@nocobase/utils": "1.5.21",
|
|
35239
35244
|
ahooks: "^3.7.2",
|
|
35240
35245
|
antd: "5.12.8",
|
|
35241
35246
|
"antd-style": "3.7.1",
|
package/lib/index.js
CHANGED
|
@@ -253,7 +253,7 @@ ${JSON.stringify(M,null,2)}`)},[u,c,l,i,r,j,t,a,n,h,o,f,S,k,b,y,g]),z=(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:m,onlyRenderProperties:!0,filterProperties:b=>b["x-component"]===o}):!1,children:(0,import_jsx_runtime.jsx)(ActionModalContent,{footerNodeName:o,field:p,schema:m})}))}))})})},{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=W(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=W(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),d=o.getCollection(l||(u==null?void 0:u.target)),m=["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:d,compile:c}),m].filter(Boolean),[i,r,u,d,c,m]);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 d=import_lodash.default.isEmpty(l)?[]:import_lodash.default.map(transformValue(l,{field:u,subFieldSchema:t}),m=>markRecordAsNew(m));isSubset(d,u.initialValue)||u.setInitialValue(d)}}},[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:d,deprecated:m})=>e.map(p=>!p.target||p.target==="chinaRegions"?{key:p.name,value:p.name,label:l(p.title),disabled:m||(n?!1:c({option:p,collectionField:t,uiSchema:o,targetFieldSchema:u,getCollectionField:d})),isLeaf:!0,depth:r}:r>=i?null:{key:p.name,value:p.name,label:l(p.title),isLeaf:!1,field:p,depth:r,disabled:m||(n?!1:c({option:p,collectionField:t,uiSchema:o,targetFieldSchema:u,getCollectionField:d})),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:d=g=>g,deprecated:m,tooltip:p})=>{const g=useCompile(),h=useGetFilterOptions(),{isDisabled:f}=(0,import_react2.useContext)(BaseVariableContext)||{},_=useCollectionManager(),v=C=>{var S;if(!((S=C.field)!=null&&S.target))return Promise.resolve(void 0);const b=C.field.target;return new Promise(y=>{setTimeout(()=>{const F=(getChildren$2(d(h(b,u,!0),C),{collectionField:e,uiSchema:t,targetFieldSchema:o,depth:C.depth+1,maxDepth:r,noDisabled:c,loadChildren:v,compile:g,isDisabled:f||isDisabledDefault,getCollectionField:_.getCollectionField,deprecated:m})||[]).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){C.disabled=!0,C.isLeaf=!0,y();return}C.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:!!m,deprecated:m}),[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:d}=useBlockRequestContext(),m=useCollectionParentRecord(),p=(i==="list"?(o=(t=d==null?void 0:d.data)==null?void 0:t.data)==null?void 0:o[0]:(r=d==null?void 0:d.data)==null?void 0:r.data)||{},g=(0,import_react2.useRef)(),h=(0,import_react2.useMemo)(()=>({action:i,form:l,field:a,service:d,resource:u,formBlockRef:g}),[i,a,l,u,d]);return d.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:m==null?void 0:m.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 d=!0;!c&&l&&(d=l===u);const m=(0,import_ahooks.useUpdate)();return!d||o?null:(0,import_jsx_runtime.jsx)(TemplateBlockProvider,{onTemplateLoaded:m,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 d=a.name===((o==null?void 0:o.name)||o)&&!c||!a.name||!o;return{hidden:i||!u&&!d&&!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}),d=(0,import_react2.useRef)(),m=(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:C,setNodeRef:S,isDragging:b}=(0,import_core.useDraggable)({disabled:e.first||e.last||!l,id:e.id,data:{dividerRef:d,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=d.current,R=k.previousElementSibling,z=k.nextElementSibling;F([R.clientWidth,z.clientWidth])},onDragMove(j){if(!l||!b)return;n.current===j.active.id&&(n.current=n.current+"_move");const k=d.current,R=k.previousElementSibling,z=k.nextElementSibling;R.style.width=`${y[0]+j.delta.x}px`,z.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 R=d.current,z=R.previousElementSibling,N=R.nextElementSibling;f["x-component-props"]=f["x-component-props"]||{},_["x-component-props"]=_["x-component-props"]||{};const L=R.clientWidth*(e.cols.length+1)/e.cols.length,D=(100*(z.getBoundingClientRect().width+L)/R.parentElement.clientWidth).toFixed(2),T=(100*(N.getBoundingClientRect().width+L)/R.parentElement.clientWidth).toFixed(2);import_lodash.default.set(f,"x-component-props.width",D),import_lodash.default.set(_,"x-component-props.width",T),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),d.current=j)},className:(0,import_classnames.default)("nb-col-divider","ColDivider"),style:m,children:(0,import_jsx_runtime.jsx)("div",P(x(x({ref:S},C),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),d=(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]),m=(0,import_core.useDndContext)(),p=e.rows[e.index],g=(r=(o=(t=m.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:d})});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)(C=>a(C),[]),c=i.address.toString(),u=useRowProperties(),{setPrintContent:d}=useFormBlockContext(),{componentCls:m,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&&(d==null||d(r.current))},[d]);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 ${m} ${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((C,S)=>(0,import_jsx_runtime.jsxs)(import_react2.default.Fragment,{children:[g?(0,import_jsx_runtime.jsx)(SchemaComponent,{name:C.name,schema:C,distributed:!0}):(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{name:C.name,schema:C,isUseFormilyField:!0}),o?(0,import_jsx_runtime.jsx)(RowDivider,{rows:u,index:S,id:`${c}_${S+1}`,data:getRowDividerData(C,"afterEnd")}):null]},S))]}),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}),[d,m]=(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%"},[d,c]);(0,import_core.useDndMonitor)({onDragStart(f){a&&m(!0)},onDragMove(f){},onDragOver(f){},onDragEnd(f){a&&m(!1)},onDragCancel(f){a&&m(!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:d}=useFilterBlock(),m=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 C;h!=null&&h.current&&((C=h.current.parentElement)==null||C.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 C,S;if(!(u!=null&&u.loading)){const b=(S=(C=m.field)==null?void 0:C.data)==null?void 0:S.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=m.field)==null?void 0:o.data)==null?void 0:r.selectedRowKeys]),{value:v,childrenColumnName:m.childrenColumnName,loading:u==null?void 0:u.loading,showIndex:m.showIndex,dragSort:m.dragSort&&m.dragSortBy,rowKey:m.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)((C,S)=>{var b,y,F;m&&(m.field.data=((b=m.field)==null?void 0:b.data)||{},m.field.data.selectedRowKeys=C,m.field.data.selectedRowData=S,(F=(y=m.field)==null?void 0:y.onRowSelect)==null||F.call(y,C))},[]),onRowDragEnd:(0,import_react2.useCallback)(C=>q(void 0,[C],function*({from:S,to:b}){yield p.current.resource.move({sourceId:S[m.rowKey||"id"],targetId:b[m.rowKey||"id"],sortField:m.dragSort&&m.dragSortBy}),p.current.service.refresh()}),[m.rowKey,m.dragSort,m.dragSortBy]),onChange:(0,import_react2.useCallback)(({current:C,pageSize:S},b,y)=>{var F,j,k,R,z,N,L,D,T,$;const w=(k=(j=(F=l.parent)==null?void 0:F["x-decorator-props"])==null?void 0:j.params)==null?void 0:k.sort,A=y.order?y.order==="ascend"?[y.field]:[`-${y.field}`]:w||m.dragSortBy,B=S||((N=(z=(R=l.parent)==null?void 0:R["x-decorator-props"])==null?void 0:z.params)==null?void 0:N.pageSize),M=P(x({},(T=(D=(L=p.current)==null?void 0:L.service)==null?void 0:D.params)==null?void 0:T[0]),{page:C||1,pageSize:B});A&&(M.sort=A),($=p.current)==null||$.service.run(M)},[l.parent]),onClickRow:(0,import_react2.useCallback)((C,S,b)=>{const{targets:y,uid:F}=findFilterTargets(l),j=d();if(!y||!y.some(R=>j.some(z=>z.uid===R.uid))){S(R=>R.length?[]:R);return}const k=j.find(R=>R.uid===l.parent["x-uid"]);j.forEach(R=>{var z,N,L;const D=y.find(M=>M.uid===R.uid);if(!D)return;const T=getSourceKey(k,D.field)||m.rowKey||"id",$=[C[T]],w=((z=R.service.params)==null?void 0:z[0])||{},A=((L=(N=R.service.params)==null?void 0:N[1])==null?void 0:L.filters)||{};if(b.includes(C[m.rowKey])){if(R.dataLoadingMode==="manual")return R.clearData();delete A[F]}else A[F]={$and:[{[D.field||m.rowKey]:{[D.field?"$in":"$eq"]:$}}]};const B=mergeFilter([...Object.values(A).map(M=>removeNullCondition(M)),R.defaultFilter]);return R.doFilter(P(x({},w),{page:1,filter:B}),{filters:A})}),S(R=>R!=null&&R.includes(C[m.rowKey])?[]:[C[m.rowKey]])},[m.rowKey,l,d]),onExpand:(0,import_react2.useCallback)((C,S)=>{var b,y;(y=(b=m.field).onExpandClick)==null||y.call(b,C,S)},[])}};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)(d=>{const m=n.getField(l.name)||i.getCollectionField(l["x-collection-field"]);return u({collectionField:o||m,getInterface:r==null?void 0:r.collectionFieldInterfaceManager.getFieldInterface.bind(r==null?void 0:r.collectionFieldInterfaceManager),form:e||a,formBlockType:c,fieldSchema:t||l,isSubTableColumn:d})},[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:d}=useCollectionManager_deprecated(),{uiSchema:m,defaultValue:p,interface:g}=useCollectionField(),{isAllowToSetDefaultValue:h}=useIsAllowToSetDefaultValue(),f=d(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)||(m==null?void 0:m["x-component"])||"Input"),C=useFormBlockContext(),S=useDynamicComponentProps(m==null?void 0:m["x-use-component-props"],e);return(0,import_react2.useEffect)(()=>{var b;if(!m)return;const y=l(m);if(setFieldProps$1(c,"content",y["x-content"]),setFieldProps$1(c,"title",y.title),setFieldProps$1(c,"description",y.description),C!=null&&C.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||{},S||{})},[m]),m?(0,import_jsx_runtime.jsx)(v,x(x({},e),S)):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)(),d=(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])||{};d.reset(),(0,import_client.forEach)(h,(f,_)=>{f&&(d.values[_]=f)})}),[]);const{resource:m,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:d,field:u,service:p,resource:m,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:d}=useBlockRequestContext(),m=useFormBlockContext(),p=useFormFieldContext(),g=p&&p.fieldName?`${p.fieldName}.${a}`:a;return(t=m==null?void 0:m.updateAssociationValues)!=null&&t.includes(g)||(o=m==null?void 0:m.updateAssociationValues)==null||o.push(g),(0,import_jsx_runtime.jsx)(TableFieldContext.Provider,{value:{field:l,fieldSchema:c,service:d,resource:u,params:r,showIndex:i,dragSort:n},children:e.children})};class TableFieldResource{constructor(t){I(this,"field"),I(this,"api"),I(this,"sourceId"),I(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 d,m,p,g,h;(d=u==null?void 0:u.service)!=null&&d.loading||(c.value=(p=(m=u==null?void 0:u.service)==null?void 0:m.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:d=>{var m,p;return(p=(m=c.value)==null?void 0:m.indexOf)==null?void 0:p.call(m,d)},onRowSelectionChange(d,m){var p;u.field.data=((p=u==null?void 0:u.field)==null?void 0:p.data)||{},u.field.data.selectedRowKeys=d,u.field.data.selectedRowData=m},onChange({current:d,pageSize:m}){u.service.run({page:d,pageSize:m})}}},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),d=useCollectionParentRecordData();return(0,import_jsx_runtime.jsx)(RecordProvider,{record:{},parent:d,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[d]=u.name.split(".");return u["x-collection-field"]&&r.has(d)?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"),d=i(u==null?void 0:u["x-collection-field"]),m=l(d==null?void 0:d.collectionName),p=m==null?void 0:m.getPrimaryKey(),g=useAssociationNames$1(e.collection);let h=x({},e.params);e.dragSort&&(h.sort=["sort"]),(d==null?void 0:d.target)===(d==null?void 0:d.collectionName)&&m!=null&&m.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(d&&(["oho","o2m"].includes(d.interface)&&!isInFilterFormBlock(r)&&(a!=null&&a[d.sourceKey]?f={$or:[{[d.foreignKey]:{$is:null}},{[d.foreignKey]:{$eq:a==null?void 0:a[d.sourceKey]}}]}:f={[d.foreignKey]:{$is:null}}),["obo"].includes(d.interface)&&!isInFilterFormBlock(r))){const C=n(d.target).find(S=>S.foreignKey&&S.foreignKey===d.foreignKey);C&&(a!=null&&a[d.foreignKey]?f={$or:[{[`${C.name}.${C.foreignKey}`]:{$is:null}},{[`${C.name}.${C.foreignKey}`]:{$eq:a==null?void 0:a[d.foreignKey]}}]}:f={[`${C.name}.${C.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(C){console.error(C)}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,d,m,p,g,h,f;const _=(0,import_react.useField)(),v=useTableSelectorContext(),C=(0,import_react.useFieldSchema)(),{getCollectionJoinField:S}=useCollectionManager_deprecated(),b=recursiveParent$1(C,"CollectionField"),y=S(b==null?void 0:b["x-collection-field"]);return(0,import_react2.useEffect)(()=>{var F,j,k,R,z,N,L,D,T,$,w,A,B;if(!((F=v==null?void 0:v.service)!=null&&F.loading)){const M=(k=(j=v==null?void 0:v.service)==null?void 0:j.data)==null?void 0:k.data.map(O=>O);_.value=M,(R=_==null?void 0:_.setInitialValue)==null||R.call(_,M),_.data=_.data||{},_.data.selectedRowKeys=[],_.componentProps.pagination=_.componentProps.pagination||{},_.componentProps.pagination.pageSize=(L=(N=(z=v==null?void 0:v.service)==null?void 0:z.data)==null?void 0:N.meta)==null?void 0:L.pageSize,_.componentProps.pagination.total=($=(T=(D=v==null?void 0:v.service)==null?void 0:D.data)==null?void 0:T.meta)==null?void 0:$.count,_.componentProps.pagination.current=(B=(A=(w=v==null?void 0:v.service)==null?void 0:w.data)==null?void 0:A.meta)==null?void 0:B.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=(m=(d=v==null?void 0:v.service)==null?void 0:d.data)==null?void 0:m.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=C==null?void 0:C["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 d,m;i["x-linkage-rules"]=((d=u==null?void 0:u.data)==null?void 0:d["x-linkage-rules"])||[],i.setProperties((m=u==null?void 0:u.data)==null?void 0:m.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,d,m;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||((d=l.uiSchema)==null?void 0:d["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:((m=l==null?void 0:l.uiSchema)==null?void 0:m.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 d=e(t.target),m=(c=d==null?void 0:d.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",key:`${t.target}_${g.name}_${_}`,name:_,title:((h=g==null?void 0:g.uiSchema)==null?void 0:h.title)||g.name,Component:"TableCollectionFieldInitializer",find:findTableColumn,remove:removeTableColumn,schemaInitialize:C=>{var S;(S=f==null?void 0:f.schemaInitialize)==null||S.call(f,C,{field:g,readPretty:!0,block:"Table",targetCollection:r(t.target)})},field:g,schema:v}}),p=[{type:"itemGroup",key:`${t.target}_${i}_displayFields`,name:`${i}-displayCollectionFields`,title:l("Display fields"),children:m}];if(a<n){const g=d==null?void 0:d.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",key:`${t.target}_${i}_associationFields`,name:`${i}-associationFields`,title:l("Display association fields"),children:g};p.push(h)}}return{type:"subMenu",key:`${t.target}_${i}_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 d=i(u,e),m=r(u);return{[m==null?void 0:m.title]:d==null?void 0:d.filter(p=>p==null?void 0:p.interface).map(p=>{var g,h,f,_;const v=t(p.interface),C=(p==null?void 0:p.target)&&((g=r(p==null?void 0:p.target))==null?void 0:g.template)==="file",S={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":C?{fieldNames:{label:"preview",value:"id"}}:{},"x-decorator":n?quickEditField$1.includes(p.interface)||C?"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:S}})}})}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:d}=useActionContext(),m=d==null?void 0:d["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 C=n(p.interface),S=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=S,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:(S==null?void 0:S.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:R=>{var z;(z=C==null?void 0:C.schemaInitialize)==null||z.call(C,R,{field:p,block:u,readPretty:c,action:m,targetCollection:S})},schema:j};return u=="Kanban"&&(k.find=(R,z,N)=>{const L=findSchema(R,"x-component",u);return findSchema(L,z,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:d,fieldSchema:m}=useActionContext(),p=m==null?void 0:m["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),C=a(g.target);let S={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)&&(S={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:C})},schema:S}})},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:d="Form"}=e||{},m=d==="Form"?["m2o","obo","oho"]:["o2o","oho","obo","m2o"];return(t=r==null?void 0:r.filter(p=>m.includes(p.interface)))==null?void 0:t.map(p=>getGroupItemForForm({getCollectionFields:n,field:p,getInterface:i,getCollection:a,readPretty:u,block:d,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(d=>associationFieldToMenu(d,`${t}.${d.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 d=n(c,t),{readPretty:m=l.readPretty,block:p="Form",component:g="CollectionField"}=e||{},h=i(c);return{[h==null?void 0:h.title]:(u=d==null?void 0:d.filter(f=>f==null?void 0:f.interface))==null?void 0:u.map(f=>{var _,v,C,S;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:((C=f==null?void 0:f.uiSchema)==null?void 0:C.title)||f.name,type:"item",title:((S=f==null?void 0:f.uiSchema)==null?void 0:S.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:m,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 d=n(c,t),{readPretty:m=l.readPretty,block:p="Form"}={};return{[i(c).title]:(u=d==null?void 0:d.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 C=o(g.interface),S=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=C==null?void 0:C.schemaInitialize)==null||F.call(C,y,{field:g,block:p,readPretty:m,targetCollection:S})},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(d=>(d==null?void 0:d.interface)&&d.interface!=="snapshot"&&d.type!=="sequence"))==null?void 0:t.map(d=>{var m,p,g;const h=i(d.interface),f={type:"string",name:d.name,title:((m=d==null?void 0:d.uiSchema)==null?void 0:m.title)||d.name,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem","x-component":"AssignedField","x-decorator":"FormItem","x-collection-field":`${o}.${d.name}`};return{name:((p=d==null?void 0:d.uiSchema)==null?void 0:p.title)||d.name,type:"item",title:((g=d==null?void 0:d.uiSchema)==null?void 0:g.title)||d.name,Component:"CollectionFieldInitializer",remove:u,schemaInitialize:_=>{var v;(v=h==null?void 0:h.schemaInitialize)==null||v.call(h,_,{field:d,block:c,readPretty:l,targetCollection:n(d.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 d=recursiveParent(l);d&&(l=d)}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(d=>{var m,p;(m=d.setValue)==null||m.call(d,void 0),(p=d.setInitialValue)==null||p.call(d,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 d=["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:d||i("Untitled")}})},{key:`${o||e}_table_subMenu_${c}_ref`,type:"subMenu",name:"ref",title:i("Reference template"),children:l.map(u=>{const d=["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:d||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:d,otherText:m})=>{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}),C=useAssociationName();let S=h.getAllCollections({filterCollection:F=>r&&F.dataSource!==f?!1:o({collection:F}),filterDataSource:n});r&&(S=S.filter(F=>F.key===f));const{getTemplatesByCollection:b}=useSchemaTemplateManager(),y=(0,import_react2.useMemo)(()=>S.map(({key:F,displayName:j,collections:k})=>({name:F,label:j,type:"subMenu",children:[...getChildren$1({name:e,association:C,collections:k,componentName:p+t,searchValue:"",dataSource:F,getTemplatesByCollection:b,t:g,componentNamePrefix:p}).sort(R=>{const z=import_lodash.default.toArray((_==null?void 0:_.inherits)||[]);if(R.name===(_==null?void 0:_.name)||z.some(N=>N===R.name))return-1})]})),[S,_==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:d||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}]})},R={ReadPrettyFormItem:"Details"},z={name:"otherRecords",Component:DataBlockInitializer,onClick(){},componentProps:P(x({},a),{hideSearch:!1,icon:null,title:m||g("Other records"),name:"otherRecords",showAssociationFields:!1,onlyCurrentDataSource:!1,hideChildrenIfSingleCollection:!1,fromOthersInPopup:!0,componentType:R[t]||t,filter({collection:D,associationField:T}){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,z];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,z];else l?N=[L]:N=[L,z];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,d=W(t,["formItemInitializers","actionInitializers","collection","dataSource","association","template","settings","action"]),m=a||i;return{type:"void","x-acl-action":u==="get"?`${m}:get`:`${m}:view`,"x-decorator":"DetailsBlockProvider","x-decorator-props":x(x({dataSource:n,collection:i,association:a,readPretty:!0,action:u},u==="list"?{params:{pageSize:1}}:{}),d),"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":d="FormV2.Designer",template:m,title:p,settings:g}=t,h=W(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":d}),{"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:m||{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,d=W(t,["formItemInitializers","actionInitializers","collection","association","dataSource","resource","template","settings"]),m=l||n||i;return{type:"void","x-acl-action":`${m}:get`,"x-decorator":"FormBlockProvider","x-decorator-props":x({resource:m,collection:i,association:n,dataSource:a,readPretty:!0,action:"get",useParams:"{{ useParamsFromRecord }}"},d),"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:d,pageSize:m=20}=t,p=W(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:m},rowKey:r,showIndex:!0,dragSort:!1,disableTemplate:c??!1,blockType:d},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(d=>{if(d.inherit)return!1;if(d.filterTargetKey){if([c+"Kanban",c+"FormItem"].includes(i)&&(d.template==="view"&&!d.writableView||d.template==="sql")||d.template==="file"&&[c+"Kanban",c+"FormItem",c+"Calendar"].includes(i))return!1;{const m=d.title||d.tableName;return m?m.toUpperCase().includes(n.toUpperCase())&&!(d!=null&&d.isThrough&&d!=null&&d.autoCreate):!1}}else return!1}))==null?void 0:u.map((d,m)=>{const p=d.title||d.tableName||d.label,g=a(r,d.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_${m}`,type:"subMenu",name:`${d.name}_${m}`,title:p,dataSource:r,children:[{type:"item",name:d.name,dataSource:r,title:l("Blank block")},{type:"divider"},{key:`${i}_table_subMenu_${m}_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:d.name,template:h,dataSource:r,title:f||l("Untitled")}})},{key:`${i}_table_subMenu_${m}_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:d.name,template:h,dataSource:r,title:f||l("Untitled")}})}]}:{type:"item",name:d.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 d,m;const p=e(t.target),g=(d=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:d.map(f=>{var _,v;const C=o(f.interface),S=(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:S?{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=C==null?void 0:C.schemaInitialize)==null||j.call(C,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:(m=t.uiSchema)==null?void 0:m.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)(),d=useCompile();return(0,import_react2.useMemo)(()=>{if(!o)return[];let m=[];if(i["x-initializer"])m=a.fields;else{const p=recursiveParent(i.parent);p&&(m=n(p))}return m.filter(p=>["linkTo","subTable","o2m","m2m","obo","oho","o2o","m2o"].includes(p.interface)).filter(p=>t({associationField:p})).map((p,g)=>{const h=d(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,d,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:m,onlyRenderProperties:!0,filterProperties:b=>b["x-component"]===o}):!1,children:(0,import_jsx_runtime.jsx)(ActionModalContent,{footerNodeName:o,field:p,schema:m})}))}))})})},{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=W(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=W(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),d=o.getCollection(l||(u==null?void 0:u.target)),m=["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:d,compile:c}),m].filter(Boolean),[i,r,u,d,c,m]);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 d=import_lodash.default.isEmpty(l)?[]:import_lodash.default.map(transformValue(l,{field:u,subFieldSchema:t}),m=>markRecordAsNew(m));isSubset(d,u.initialValue)||u.setInitialValue(d)}}},[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:d,deprecated:m})=>e.map(p=>!p.target||p.target==="chinaRegions"?{key:p.name,value:p.name,label:l(p.title),disabled:m||(n?!1:c({option:p,collectionField:t,uiSchema:o,targetFieldSchema:u,getCollectionField:d})),isLeaf:!0,depth:r}:r>=i?null:{key:p.name,value:p.name,label:l(p.title),isLeaf:!1,field:p,depth:r,disabled:m||(n?!1:c({option:p,collectionField:t,uiSchema:o,targetFieldSchema:u,getCollectionField:d})),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:d=g=>g,deprecated:m,tooltip:p})=>{const g=useCompile(),h=useGetFilterOptions(),{isDisabled:f}=(0,import_react2.useContext)(BaseVariableContext)||{},_=useCollectionManager(),v=C=>{var S;if(!((S=C.field)!=null&&S.target))return Promise.resolve(void 0);const b=C.field.target;return new Promise(y=>{setTimeout(()=>{const F=(getChildren$2(d(h(b,u,!0),C),{collectionField:e,uiSchema:t,targetFieldSchema:o,depth:C.depth+1,maxDepth:r,noDisabled:c,loadChildren:v,compile:g,isDisabled:f||isDisabledDefault,getCollectionField:_.getCollectionField,deprecated:m})||[]).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){C.disabled=!0,C.isLeaf=!0,y();return}C.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:!!m,deprecated:m}),[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:d}=useBlockRequestContext(),m=useCollectionParentRecord(),p=(i==="list"?(o=(t=d==null?void 0:d.data)==null?void 0:t.data)==null?void 0:o[0]:(r=d==null?void 0:d.data)==null?void 0:r.data)||{},g=(0,import_react2.useRef)(),h=(0,import_react2.useMemo)(()=>({action:i,form:l,field:a,service:d,resource:u,formBlockRef:g}),[i,a,l,u,d]);return d.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:m==null?void 0:m.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,action:a}=e;useCollectionManager_deprecated(n);const{__collection:l}=r||{},{designable:c}=useDesignable(),u=e.collection;let d=!0;!c&&l&&a==="get"&&!i&&(d=l===u);const m=(0,import_ahooks.useUpdate)();return!d||o?null:(0,import_jsx_runtime.jsx)(TemplateBlockProvider,{onTemplateLoaded:m,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 d=a.name===((o==null?void 0:o.name)||o)&&!c||!a.name||!o;return{hidden:i||!u&&!d&&!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}),d=(0,import_react2.useRef)(),m=(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:C,setNodeRef:S,isDragging:b}=(0,import_core.useDraggable)({disabled:e.first||e.last||!l,id:e.id,data:{dividerRef:d,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=d.current,R=k.previousElementSibling,z=k.nextElementSibling;F([R.clientWidth,z.clientWidth])},onDragMove(j){if(!l||!b)return;n.current===j.active.id&&(n.current=n.current+"_move");const k=d.current,R=k.previousElementSibling,z=k.nextElementSibling;R.style.width=`${y[0]+j.delta.x}px`,z.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 R=d.current,z=R.previousElementSibling,N=R.nextElementSibling;f["x-component-props"]=f["x-component-props"]||{},_["x-component-props"]=_["x-component-props"]||{};const L=R.clientWidth*(e.cols.length+1)/e.cols.length,D=(100*(z.getBoundingClientRect().width+L)/R.parentElement.clientWidth).toFixed(2),T=(100*(N.getBoundingClientRect().width+L)/R.parentElement.clientWidth).toFixed(2);import_lodash.default.set(f,"x-component-props.width",D),import_lodash.default.set(_,"x-component-props.width",T),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),d.current=j)},className:(0,import_classnames.default)("nb-col-divider","ColDivider"),style:m,children:(0,import_jsx_runtime.jsx)("div",P(x(x({ref:S},C),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),d=(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]),m=(0,import_core.useDndContext)(),p=e.rows[e.index],g=(r=(o=(t=m.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:d})});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)(C=>a(C),[]),c=i.address.toString(),u=useRowProperties(),{setPrintContent:d}=useFormBlockContext(),{componentCls:m,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&&(d==null||d(r.current))},[d]);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 ${m} ${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((C,S)=>(0,import_jsx_runtime.jsxs)(import_react2.default.Fragment,{children:[g?(0,import_jsx_runtime.jsx)(SchemaComponent,{name:C.name,schema:C,distributed:!0}):(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{name:C.name,schema:C,isUseFormilyField:!0}),o?(0,import_jsx_runtime.jsx)(RowDivider,{rows:u,index:S,id:`${c}_${S+1}`,data:getRowDividerData(C,"afterEnd")}):null]},S))]}),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}),[d,m]=(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%"},[d,c]);(0,import_core.useDndMonitor)({onDragStart(f){a&&m(!0)},onDragMove(f){},onDragOver(f){},onDragEnd(f){a&&m(!1)},onDragCancel(f){a&&m(!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:d}=useFilterBlock(),m=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 C;h!=null&&h.current&&((C=h.current.parentElement)==null||C.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 C,S;if(!(u!=null&&u.loading)){const b=(S=(C=m.field)==null?void 0:C.data)==null?void 0:S.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=m.field)==null?void 0:o.data)==null?void 0:r.selectedRowKeys]),{value:v,childrenColumnName:m.childrenColumnName,loading:u==null?void 0:u.loading,showIndex:m.showIndex,dragSort:m.dragSort&&m.dragSortBy,rowKey:m.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)((C,S)=>{var b,y,F;m&&(m.field.data=((b=m.field)==null?void 0:b.data)||{},m.field.data.selectedRowKeys=C,m.field.data.selectedRowData=S,(F=(y=m.field)==null?void 0:y.onRowSelect)==null||F.call(y,C))},[]),onRowDragEnd:(0,import_react2.useCallback)(C=>q(void 0,[C],function*({from:S,to:b}){yield p.current.resource.move({sourceId:S[m.rowKey||"id"],targetId:b[m.rowKey||"id"],sortField:m.dragSort&&m.dragSortBy}),p.current.service.refresh()}),[m.rowKey,m.dragSort,m.dragSortBy]),onChange:(0,import_react2.useCallback)(({current:C,pageSize:S},b,y)=>{var F,j,k,R,z,N,L,D,T,$;const w=(k=(j=(F=l.parent)==null?void 0:F["x-decorator-props"])==null?void 0:j.params)==null?void 0:k.sort,A=y.order?y.order==="ascend"?[y.field]:[`-${y.field}`]:w||m.dragSortBy,B=S||((N=(z=(R=l.parent)==null?void 0:R["x-decorator-props"])==null?void 0:z.params)==null?void 0:N.pageSize),M=P(x({},(T=(D=(L=p.current)==null?void 0:L.service)==null?void 0:D.params)==null?void 0:T[0]),{page:C||1,pageSize:B});A&&(M.sort=A),($=p.current)==null||$.service.run(M)},[l.parent]),onClickRow:(0,import_react2.useCallback)((C,S,b)=>{const{targets:y,uid:F}=findFilterTargets(l),j=d();if(!y||!y.some(R=>j.some(z=>z.uid===R.uid))){S(R=>R.length?[]:R);return}const k=j.find(R=>R.uid===l.parent["x-uid"]);j.forEach(R=>{var z,N,L;const D=y.find(M=>M.uid===R.uid);if(!D)return;const T=getSourceKey(k,D.field)||m.rowKey||"id",$=[C[T]],w=((z=R.service.params)==null?void 0:z[0])||{},A=((L=(N=R.service.params)==null?void 0:N[1])==null?void 0:L.filters)||{};if(b.includes(C[m.rowKey])){if(R.dataLoadingMode==="manual")return R.clearData();delete A[F]}else A[F]={$and:[{[D.field||m.rowKey]:{[D.field?"$in":"$eq"]:$}}]};const B=mergeFilter([...Object.values(A).map(M=>removeNullCondition(M)),R.defaultFilter]);return R.doFilter(P(x({},w),{page:1,filter:B}),{filters:A})}),S(R=>R!=null&&R.includes(C[m.rowKey])?[]:[C[m.rowKey]])},[m.rowKey,l,d]),onExpand:(0,import_react2.useCallback)((C,S)=>{var b,y;(y=(b=m.field).onExpandClick)==null||y.call(b,C,S)},[])}};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)(d=>{const m=n.getField(l.name)||i.getCollectionField(l["x-collection-field"]);return u({collectionField:o||m,getInterface:r==null?void 0:r.collectionFieldInterfaceManager.getFieldInterface.bind(r==null?void 0:r.collectionFieldInterfaceManager),form:e||a,formBlockType:c,fieldSchema:t||l,isSubTableColumn:d})},[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:d}=useCollectionManager_deprecated(),{uiSchema:m,defaultValue:p,interface:g}=useCollectionField(),{isAllowToSetDefaultValue:h}=useIsAllowToSetDefaultValue(),f=d(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)||(m==null?void 0:m["x-component"])||"Input"),C=useFormBlockContext(),S=useDynamicComponentProps(m==null?void 0:m["x-use-component-props"],e);return(0,import_react2.useEffect)(()=>{var b;if(!m)return;const y=l(m);if(setFieldProps$1(c,"content",y["x-content"]),setFieldProps$1(c,"title",y.title),setFieldProps$1(c,"description",y.description),C!=null&&C.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||{},S||{})},[m]),m?(0,import_jsx_runtime.jsx)(v,x(x({},e),S)):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)(),d=(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])||{};d.reset(),(0,import_client.forEach)(h,(f,_)=>{f&&(d.values[_]=f)})}),[]);const{resource:m,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:d,field:u,service:p,resource:m,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:d}=useBlockRequestContext(),m=useFormBlockContext(),p=useFormFieldContext(),g=p&&p.fieldName?`${p.fieldName}.${a}`:a;return(t=m==null?void 0:m.updateAssociationValues)!=null&&t.includes(g)||(o=m==null?void 0:m.updateAssociationValues)==null||o.push(g),(0,import_jsx_runtime.jsx)(TableFieldContext.Provider,{value:{field:l,fieldSchema:c,service:d,resource:u,params:r,showIndex:i,dragSort:n},children:e.children})};class TableFieldResource{constructor(t){I(this,"field"),I(this,"api"),I(this,"sourceId"),I(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 d,m,p,g,h;(d=u==null?void 0:u.service)!=null&&d.loading||(c.value=(p=(m=u==null?void 0:u.service)==null?void 0:m.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:d=>{var m,p;return(p=(m=c.value)==null?void 0:m.indexOf)==null?void 0:p.call(m,d)},onRowSelectionChange(d,m){var p;u.field.data=((p=u==null?void 0:u.field)==null?void 0:p.data)||{},u.field.data.selectedRowKeys=d,u.field.data.selectedRowData=m},onChange({current:d,pageSize:m}){u.service.run({page:d,pageSize:m})}}},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),d=useCollectionParentRecordData();return(0,import_jsx_runtime.jsx)(RecordProvider,{record:{},parent:d,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[d]=u.name.split(".");return u["x-collection-field"]&&r.has(d)?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"),d=i(u==null?void 0:u["x-collection-field"]),m=l(d==null?void 0:d.collectionName),p=m==null?void 0:m.getPrimaryKey(),g=useAssociationNames$1(e.collection);let h=x({},e.params);e.dragSort&&(h.sort=["sort"]),(d==null?void 0:d.target)===(d==null?void 0:d.collectionName)&&m!=null&&m.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(d&&(["oho","o2m"].includes(d.interface)&&!isInFilterFormBlock(r)&&(a!=null&&a[d.sourceKey]?f={$or:[{[d.foreignKey]:{$is:null}},{[d.foreignKey]:{$eq:a==null?void 0:a[d.sourceKey]}}]}:f={[d.foreignKey]:{$is:null}}),["obo"].includes(d.interface)&&!isInFilterFormBlock(r))){const C=n(d.target).find(S=>S.foreignKey&&S.foreignKey===d.foreignKey);C&&(a!=null&&a[d.foreignKey]?f={$or:[{[`${C.name}.${C.foreignKey}`]:{$is:null}},{[`${C.name}.${C.foreignKey}`]:{$eq:a==null?void 0:a[d.foreignKey]}}]}:f={[`${C.name}.${C.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(C){console.error(C)}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,d,m,p,g,h,f;const _=(0,import_react.useField)(),v=useTableSelectorContext(),C=(0,import_react.useFieldSchema)(),{getCollectionJoinField:S}=useCollectionManager_deprecated(),b=recursiveParent$1(C,"CollectionField"),y=S(b==null?void 0:b["x-collection-field"]);return(0,import_react2.useEffect)(()=>{var F,j,k,R,z,N,L,D,T,$,w,A,B;if(!((F=v==null?void 0:v.service)!=null&&F.loading)){const M=(k=(j=v==null?void 0:v.service)==null?void 0:j.data)==null?void 0:k.data.map(O=>O);_.value=M,(R=_==null?void 0:_.setInitialValue)==null||R.call(_,M),_.data=_.data||{},_.data.selectedRowKeys=[],_.componentProps.pagination=_.componentProps.pagination||{},_.componentProps.pagination.pageSize=(L=(N=(z=v==null?void 0:v.service)==null?void 0:z.data)==null?void 0:N.meta)==null?void 0:L.pageSize,_.componentProps.pagination.total=($=(T=(D=v==null?void 0:v.service)==null?void 0:D.data)==null?void 0:T.meta)==null?void 0:$.count,_.componentProps.pagination.current=(B=(A=(w=v==null?void 0:v.service)==null?void 0:w.data)==null?void 0:A.meta)==null?void 0:B.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=(m=(d=v==null?void 0:v.service)==null?void 0:d.data)==null?void 0:m.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=C==null?void 0:C["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 d,m;i["x-linkage-rules"]=((d=u==null?void 0:u.data)==null?void 0:d["x-linkage-rules"])||[],i.setProperties((m=u==null?void 0:u.data)==null?void 0:m.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,d,m;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||((d=l.uiSchema)==null?void 0:d["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:((m=l==null?void 0:l.uiSchema)==null?void 0:m.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 d=e(t.target),m=(c=d==null?void 0:d.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",key:`${t.target}_${g.name}_${_}`,name:_,title:((h=g==null?void 0:g.uiSchema)==null?void 0:h.title)||g.name,Component:"TableCollectionFieldInitializer",find:findTableColumn,remove:removeTableColumn,schemaInitialize:C=>{var S;(S=f==null?void 0:f.schemaInitialize)==null||S.call(f,C,{field:g,readPretty:!0,block:"Table",targetCollection:r(t.target)})},field:g,schema:v}}),p=[{type:"itemGroup",key:`${t.target}_${i}_displayFields`,name:`${i}-displayCollectionFields`,title:l("Display fields"),children:m}];if(a<n){const g=d==null?void 0:d.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",key:`${t.target}_${i}_associationFields`,name:`${i}-associationFields`,title:l("Display association fields"),children:g};p.push(h)}}return{type:"subMenu",key:`${t.target}_${i}_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 d=i(u,e),m=r(u);return{[m==null?void 0:m.title]:d==null?void 0:d.filter(p=>p==null?void 0:p.interface).map(p=>{var g,h,f,_;const v=t(p.interface),C=(p==null?void 0:p.target)&&((g=r(p==null?void 0:p.target))==null?void 0:g.template)==="file",S={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":C?{fieldNames:{label:"preview",value:"id"}}:{},"x-decorator":n?quickEditField$1.includes(p.interface)||C?"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:S}})}})}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:d}=useActionContext(),m=d==null?void 0:d["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 C=n(p.interface),S=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=S,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:(S==null?void 0:S.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:R=>{var z;(z=C==null?void 0:C.schemaInitialize)==null||z.call(C,R,{field:p,block:u,readPretty:c,action:m,targetCollection:S})},schema:j};return u=="Kanban"&&(k.find=(R,z,N)=>{const L=findSchema(R,"x-component",u);return findSchema(L,z,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:d,fieldSchema:m}=useActionContext(),p=m==null?void 0:m["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),C=a(g.target);let S={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)&&(S={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:C})},schema:S}})},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:d="Form"}=e||{},m=d==="Form"?["m2o","obo","oho"]:["o2o","oho","obo","m2o"];return(t=r==null?void 0:r.filter(p=>m.includes(p.interface)))==null?void 0:t.map(p=>getGroupItemForForm({getCollectionFields:n,field:p,getInterface:i,getCollection:a,readPretty:u,block:d,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(d=>associationFieldToMenu(d,`${t}.${d.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 d=n(c,t),{readPretty:m=l.readPretty,block:p="Form",component:g="CollectionField"}=e||{},h=i(c);return{[h==null?void 0:h.title]:(u=d==null?void 0:d.filter(f=>f==null?void 0:f.interface))==null?void 0:u.map(f=>{var _,v,C,S;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:((C=f==null?void 0:f.uiSchema)==null?void 0:C.title)||f.name,type:"item",title:((S=f==null?void 0:f.uiSchema)==null?void 0:S.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:m,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 d=n(c,t),{readPretty:m=l.readPretty,block:p="Form"}={};return{[i(c).title]:(u=d==null?void 0:d.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 C=o(g.interface),S=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=C==null?void 0:C.schemaInitialize)==null||F.call(C,y,{field:g,block:p,readPretty:m,targetCollection:S})},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(d=>(d==null?void 0:d.interface)&&d.interface!=="snapshot"&&d.type!=="sequence"))==null?void 0:t.map(d=>{var m,p,g;const h=i(d.interface),f={type:"string",name:d.name,title:((m=d==null?void 0:d.uiSchema)==null?void 0:m.title)||d.name,"x-toolbar":"FormItemSchemaToolbar","x-settings":"fieldSettings:FormItem","x-component":"AssignedField","x-decorator":"FormItem","x-collection-field":`${o}.${d.name}`};return{name:((p=d==null?void 0:d.uiSchema)==null?void 0:p.title)||d.name,type:"item",title:((g=d==null?void 0:d.uiSchema)==null?void 0:g.title)||d.name,Component:"CollectionFieldInitializer",remove:u,schemaInitialize:_=>{var v;(v=h==null?void 0:h.schemaInitialize)==null||v.call(h,_,{field:d,block:c,readPretty:l,targetCollection:n(d.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 d=recursiveParent(l);d&&(l=d)}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(d=>{var m,p;(m=d.setValue)==null||m.call(d,void 0),(p=d.setInitialValue)==null||p.call(d,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 d=["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:d||i("Untitled")}})},{key:`${o||e}_table_subMenu_${c}_ref`,type:"subMenu",name:"ref",title:i("Reference template"),children:l.map(u=>{const d=["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:d||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:d,otherText:m})=>{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}),C=useAssociationName();let S=h.getAllCollections({filterCollection:F=>r&&F.dataSource!==f?!1:o({collection:F}),filterDataSource:n});r&&(S=S.filter(F=>F.key===f));const{getTemplatesByCollection:b}=useSchemaTemplateManager(),y=(0,import_react2.useMemo)(()=>S.map(({key:F,displayName:j,collections:k})=>({name:F,label:j,type:"subMenu",children:[...getChildren$1({name:e,association:C,collections:k,componentName:p+t,searchValue:"",dataSource:F,getTemplatesByCollection:b,t:g,componentNamePrefix:p}).sort(R=>{const z=import_lodash.default.toArray((_==null?void 0:_.inherits)||[]);if(R.name===(_==null?void 0:_.name)||z.some(N=>N===R.name))return-1})]})),[S,_==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:d||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}]})},R={ReadPrettyFormItem:"Details"},z={name:"otherRecords",Component:DataBlockInitializer,onClick(){},componentProps:P(x({},a),{hideSearch:!1,icon:null,title:m||g("Other records"),name:"otherRecords",showAssociationFields:!1,onlyCurrentDataSource:!1,hideChildrenIfSingleCollection:!1,fromOthersInPopup:!0,componentType:R[t]||t,filter({collection:D,associationField:T}){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,z];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,z];else l?N=[L]:N=[L,z];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,d=W(t,["formItemInitializers","actionInitializers","collection","dataSource","association","template","settings","action"]),m=a||i;return{type:"void","x-acl-action":u==="get"?`${m}:get`:`${m}:view`,"x-decorator":"DetailsBlockProvider","x-decorator-props":x(x({dataSource:n,collection:i,association:a,readPretty:!0,action:u},u==="list"?{params:{pageSize:1}}:{}),d),"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":d="FormV2.Designer",template:m,title:p,settings:g}=t,h=W(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":d}),{"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:m||{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,d=W(t,["formItemInitializers","actionInitializers","collection","association","dataSource","resource","template","settings"]),m=l||n||i;return{type:"void","x-acl-action":`${m}:get`,"x-decorator":"FormBlockProvider","x-decorator-props":x({resource:m,collection:i,association:n,dataSource:a,readPretty:!0,action:"get",useParams:"{{ useParamsFromRecord }}"},d),"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:d,pageSize:m=20}=t,p=W(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:m},rowKey:r,showIndex:!0,dragSort:!1,disableTemplate:c??!1,blockType:d},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(d=>{if(d.inherit)return!1;if(d.filterTargetKey){if([c+"Kanban",c+"FormItem"].includes(i)&&(d.template==="view"&&!d.writableView||d.template==="sql")||d.template==="file"&&[c+"Kanban",c+"FormItem",c+"Calendar"].includes(i))return!1;{const m=d.title||d.tableName;return m?m.toUpperCase().includes(n.toUpperCase())&&!(d!=null&&d.isThrough&&d!=null&&d.autoCreate):!1}}else return!1}))==null?void 0:u.map((d,m)=>{const p=d.title||d.tableName||d.label,g=a(r,d.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_${m}`,type:"subMenu",name:`${d.name}_${m}`,title:p,dataSource:r,children:[{type:"item",name:d.name,dataSource:r,title:l("Blank block")},{type:"divider"},{key:`${i}_table_subMenu_${m}_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:d.name,template:h,dataSource:r,title:f||l("Untitled")}})},{key:`${i}_table_subMenu_${m}_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:d.name,template:h,dataSource:r,title:f||l("Untitled")}})}]}:{type:"item",name:d.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 d,m;const p=e(t.target),g=(d=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:d.map(f=>{var _,v;const C=o(f.interface),S=(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:S?{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=C==null?void 0:C.schemaInitialize)==null||j.call(C,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:(m=t.uiSchema)==null?void 0:m.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)(),d=useCompile();return(0,import_react2.useMemo)(()=>{if(!o)return[];let m=[];if(i["x-initializer"])m=a.fields;else{const p=recursiveParent(i.parent);p&&(m=n(p))}return m.filter(p=>["linkTo","subTable","o2m","m2m","obo","oho","o2o","m2o"].includes(p.interface)).filter(p=>t({associationField:p})).map((p,g)=>{const h=d(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,d,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;
|
|
@@ -440,6 +440,9 @@ https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModu
|
|
|
440
440
|
max-width: 100%;
|
|
441
441
|
}
|
|
442
442
|
`,formItemLabelCss=import_css.css`
|
|
443
|
+
.ant-card-body {
|
|
444
|
+
padding: 0px !important;
|
|
445
|
+
}
|
|
443
446
|
> .ant-formily-item-label {
|
|
444
447
|
display: none;
|
|
445
448
|
}
|
|
@@ -592,7 +595,7 @@ https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModu
|
|
|
592
595
|
}
|
|
593
596
|
}
|
|
594
597
|
}
|
|
595
|
-
`,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)(),d=n(u.name)||r(u["x-collection-field"]),m=useVariables$1(),p=useLocalVariables$1(),{dn:g}=useDesignable();return{collectionName:d==null?void 0:d.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:m,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(d=>d!=null&&d.startsWith("-")?{field:d.substring(1),direction:"desc"}:{field:d,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:d})=>{const m=d.map(p=>p.direction==="desc"?`-${p.field}`:p.field);t.componentProps.sortArr=m,o["x-component-props"].sortArr=m,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(d){var m,p;const g={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].mode=d,g["x-component-props"]=l["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=d,isSubMode(l)&&o&&(g.default=null,l.default=null,(m=t==null?void 0:t.setInitialValue)==null||m.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(d){const m={"x-uid":n["x-uid"]};n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].mode=d,m["x-component-props"]=n["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=d,isSubMode(n)&&c&&(m.default=null,n.default=null,t.setInitialValue(null),t.setValue(null)),l.emit("patch",{schema:m}),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(),d=n||u,{dn:m}=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=d==null?void 0:d.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,m.emit("patch",{schema:f}),m.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(d){const m={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].mode=d,m["x-component-props"]=l["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=d,isSubMode(l)&&o&&(m.default=null,l.default=null,t.setInitialValue(null),t.setValue(null)),u.emit("patch",{schema:m}),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:d}=useDesignable(),m=useColorFields((e=u==null?void 0:u.target)!=null?e:u==null?void 0:u.targetCollection);return{title:o("Tag color field"),options:m,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,d.emit("patch",{schema:g}),d.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])}},cache=new Map,cacheLazyLoadedValues=(e,t,o)=>{const r=cache.get(e);r?r[t]=o:cache.set(e,{[t]:o})},getCachedLazyLoadedValues=(e,t)=>{const o=cache.get(e);return o==null?void 0:o[t]},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,C)=>q(void 0,null,function*(){var S,b;const y=_.split("."),F=y[0],j=mergeVariableToCollectionNameWithLocalVariables(variablesStore,v);let k=mergeCtxWithLocalVariables(o.current,v);const{fieldPath:R,dataSource:z,variableOption:N}=getFieldPath(F,j);let L=R;const{fieldPath:D}=getFieldPath(_,j),T=y.length===1?N==null?void 0:N.collectionName:(S=i(D,z))==null?void 0:S.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:z,collectionName:T};const A=y[w],B=y.slice(0,w+1).join("."),{fieldPath:M}=getFieldPath(B,j),O=i(M,z),E=(b=n(L,z))==null?void 0:b.getPrimaryKey();if(Array.isArray(k)){const U=k.map(V=>{if(!(C!=null&&C.doNotRequest)&&shouldToRequest(V==null?void 0:V[A],V,B)&&(V==null?void 0:V[E])!=null&&O!=null&&O.target){const G=`/${L}/${V[O.sourceKey||E]}/${A}:${getAction(O.type)}`;if(hasRequested(G))return getRequested(G);const H=r.request({headers:getDataSourceHeaders(z),url:G,params:{appends:C==null?void 0:C.appends}}).then(Y=>{clearRequested(G);const K=Y.data.data;return cacheLazyLoadedValues(V,B,K),K});return stashRequested(G,H),H}return getCachedLazyLoadedValues(V,B)||(V==null?void 0:V[A])});k=removeThroughCollectionFields(import_lodash.default.flatten(yield Promise.all(U)),O)}else if(!(C!=null&&C.doNotRequest)&&shouldToRequest(k[A],k,B)&&k[E]!=null&&O!=null&&O.target){const U=`/${L}/${k[O.sourceKey||E]}/${A}:${getAction(O.type)}`;let V=null;if(hasRequested(U))V=yield getRequested(U);else{const H=r.request({headers:getDataSourceHeaders(z),url:U,params:{appends:C==null?void 0:C.appends}});stashRequested(U,H),V=yield H,clearRequested(U)}const G=V.data.data;getCachedLazyLoadedValues(k,B)||cacheLazyLoadedValues(k,B,G),k=removeThroughCollectionFields(G,O)}else k=removeThroughCollectionFields(getCachedLazyLoadedValues(k,B)||(0,import_client.getValuesByPath)(k,A),O);O!=null&&O.target&&(L=O.target)}const $=a(import_lodash.default.isFunction(k)?k({fieldOperator:C==null?void 0:C.fieldOperator,isParsingVariable:!0}):k);return{value:$===void 0?N.defaultValue:$,dataSource:z,collectionName:T}}),[i]),d=(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]),m=(0,import_react2.useCallback)(_=>o.current[_]?x({},variablesStore[_]):null,[]),p=(0,import_react2.useCallback)(_=>{c(v=>{const C=x({},v);return delete C[_],C}),delete variablesStore[_]},[c]),g=(0,import_react2.useCallback)((_,v,C)=>q(void 0,null,function*(){if(!isVariable(_))return _;v&&(v=import_lodash.default.isArray(v)?v:[v]);const S=getPath(_),b=yield u(S,v,C);return P(x({},b),{value:uniq(filterEmptyValues(b.value))})}),[u]),h=(0,import_react2.useCallback)((_,v)=>q(void 0,null,function*(){var C;if(!isVariable(_))throw new Error(`VariablesProvider: ${_} is not a variable string`);v&&(v=import_lodash.default.isArray(v)?v:[v]);const S=mergeVariableToCollectionNameWithLocalVariables(variablesStore,v),b=getPath(_),{fieldPath:y,dataSource:F}=getFieldPath(b,S);let j=i(y,F);return!j&&!b.includes(".")&&(j={target:(C=S[b])==null?void 0:C.collectionName}),j}),[i]);(0,import_react2.useEffect)(()=>{l.forEach(_=>{d(P(x({},_),{defaultValue:import_lodash.default.has(_,"defaultValue")?_.defaultValue:null}))})},[l,d]);const f=(0,import_react2.useMemo)(()=>({ctxRef:o,setCtx:c,parseVariable:g,registerVariable:d,getVariable:m,getCollectionField:h,removeVariable:p,filterVariables:t}),[h,m,g,d,p,c]);return(0,import_jsx_runtime.jsx)(VariablesContext.Provider,{value:f,children:e})};VariablesProvider.displayName="VariablesProvider";const VariablesProvider$1=VariablesProvider;function shouldToRequest(e,t,o){let r=!1;return getCachedLazyLoadedValues(t,o)?!1:((0,import_reactive.untracked)(()=>{if(JSON.stringify(e)==="[{}]"||JSON.stringify(e)==="{}"){r=!0;return}r=import_lodash.default.isEmpty(e)}),r)}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){I(this,"props"),I(this,"initialized"),I(this,"loading"),I(this,"validating"),I(this,"submitting"),I(this,"selfModified"),I(this,"active"),I(this,"visited"),I(this,"mounted"),I(this,"unmounted"),I(this,"inputValues"),I(this,"inputValue"),I(this,"feedbacks"),I(this,"title"),I(this,"description"),I(this,"display"),I(this,"pattern"),I(this,"editable"),I(this,"disabled"),I(this,"readOnly"),I(this,"readPretty"),I(this,"visible"),I(this,"hidden"),I(this,"dataSource"),I(this,"validator"),I(this,"required"),I(this,"content"),I(this,"initialValue"),I(this,"value"),I(this,"data"),I(this,"decorator"),I(this,"component"),I(this,"decoratorProps"),I(this,"componentProps"),I(this,"decoratorType"),I(this,"componentType"),I(this,"path"),I(this,"form"),I(this,"address"),this.props=e,this.initialize()}initialize(){var e,t,o,r,i,n,a,l,c,u,d,m,p,g,h,f,_,v,C,S;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||((d=this.props.schema)==null?void 0:d.default)),this.value=b(this.props.value),this.data=this.props.data||((m=this.props.schema)==null?void 0:m["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=(C=this.props.schema)==null?void 0:C["x-decorator"],this.componentType=(S=this.props.schema)==null?void 0:S["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:d},m)=>{const p=(t==null?void 0:t.address)||o;let g=u;if((0,import_shared.isFn)(r)){const f=r(u,d);f&&(g=f)}if((0,import_shared.isFn)(i)&&i(g,d)===!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:d,basePath:p,values:import_lodash.default.get(a,d),isUseFormilyField:l}):(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{schema:g,name:d,basePath:p,values:import_lodash.default.get(a,d),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})},`${m}-${d}`):(0,import_jsx_runtime.jsx)(IsInNocoBaseRecursionFieldContext.Provider,{value:!1,children:(0,import_jsx_runtime.jsx)(CollectionFieldUISchemaContext.Provider,{value:EMPTY_OBJECT,children:h})},`${m}-${d}`)})}):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:d}=e,m=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),C=p.current||g,S=(0,import_react2.useCallback)(()=>{const k=C.parent;p.current=new import_react.Schema(C.toJSON(),k),k!=null&&k.properties&&Object.keys(k.properties).forEach(R=>{R===C.name&&(k.properties[R]=p.current)}),_(),v==null||v()},[C,v,_]),b=(0,import_react2.useMemo)(()=>d?createMergedSchemaInstance(C,d,r):h?(h.default=f,createMergedSchemaInstance(C,h,r)):C,[h,f,C,r,d]),y=useFieldProps$1(b),F=k=>{if(!i)return propertiesToReactElement({schema:C,field:k,basePath:m,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:m,children:F})):b.type==="array"?(0,import_jsx_runtime.jsx)(import_react.ArrayField,P(x({},y),{name:o,basePath:m})):b.type==="void"?r?F():(0,import_jsx_runtime.jsx)(import_react.VoidField,P(x({},y),{name:o,basePath:m,children:F})):u?(0,import_jsx_runtime.jsx)(import_react.Field,P(x({},y),{name:o,basePath:m})):(0,import_jsx_runtime.jsx)(NocoBaseField,{name:o,value:c,initialValue:c,basePath:m,schema:b}):F();return C?(0,import_jsx_runtime.jsx)(import_react.SchemaContext.Provider,{value:C,children:(0,import_jsx_runtime.jsx)(RefreshFieldSchemaProvider,{refresh:S,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.20",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.20","@nocobase/sdk":"1.5.20","@nocobase/utils":"1.5.20",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){I(this,"current"),I(this,"options"),I(this,"appVersion"),I(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:d,removed:m}){var p;let g=[];if((d==null?void 0:d["x-component"])==="Grid.Col"&&(g=g.concat(r(d.parent))),(m==null?void 0:m["x-component"])==="Grid.Col"&&(g=g.concat(r(m.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})),m!=null&&m["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${m["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,d=0;this.current.parent.mapProperties((f,_)=>{_===this.current.name&&(d=u,c=!0,++u),f["x-index"]=u,++u,c&&(l[_]=f,this.current.parent.removeProperty(_))}),this.prepareProperty(t);const m=i(t),p=this.current.parent.addProperty(m.name||(0,import_shared.uid)(),m);p["x-index"]=d,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:m,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),d=this.current.addProperty(u.name||(0,import_shared.uid)(),u);d["x-index"]=0,d.parent=this.current,this.current.setProperties(l);const[m,p]=splitWrapSchema(d,t);this.emit("insertAdjacent",x({position:"afterBegin",schema:p,wrap:m,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,d]=splitWrapSchema(c,t);return this.emit("insertAdjacent",x({position:"beforeEnd",schema:d,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 d={};if(this.current.parent.mapProperties((f,_)=>{f["x-index"]=l,_===this.current.name&&(++l,c=l,u=!0),++l,u&&_!==this.current.name&&(d[_]=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 m=i(t),p=this.current.parent.addProperty(m.name||(0,import_shared.uid)(),m);p.parent=this.current.parent,p["x-index"]=c,this.current.parent.setProperties(d);const[g,h]=splitWrapSchema(p,t);this.emit("insertAdjacent",x({position:"afterEnd",schema:h,wrap:g,wrapped:m},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(),d=(0,import_react2.useCallback)(_=>{o==null||o(),l(),c==null||c(_),u==null||u()},[o,l,c,u]),m=(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:d,current:p,model:m,appVersion:clientPkg.version}),[h,g,d,p,m]);return(0,import_react2.useEffect)(()=>{f.loadAPIClientEvents()},[f]),{dn:f,designable:e,reset:r,refresh:d,setDesignable:t,DesignableBar:a,findComponent:(0,import_react2.useCallback)(_=>{var v;if(!_)return null;if(typeof _!="string")return _;const C=(0,import_get.default)(n,_);return(v=C[LAZY_COMPONENT_KEY])!=null?v:C},[import_get.default]),on:f.on.bind(f),patch:(0,import_react2.useCallback)((_,v)=>{const C=S=>{Object.keys(S).forEach(b=>{const y=S[b];b==="title"&&(m.title=y,p.title=y),b==="x-decorator-props"&&(m.decoratorProps||(m.decoratorProps={}),p["x-decorator-props"]||(p["x-decorator-props"]={}),Object.keys(y).forEach(F=>{m.decoratorProps[F]=y[F],p["x-decorator-props"][F]=y[F]})),b==="x-component-props"&&(m.componentProps||(m.componentProps={}),p["x-component-props"]||(p["x-component-props"]={}),Object.keys(y).forEach(F=>{m.componentProps[F]=y[F],p["x-component-props"][F]=y[F]}))})};if(typeof _=="string"){const S={};return(0,import_set.default)(S,_,v),C(S)}C(_),d()},[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,C)=>{f.insertAdjacent(_,v,C)},[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,d=getPageHeaderHeight(n,a,l,t,i.pathname);return c+d+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:d,title:m}=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,_=m?t.fontSizeLG*t.lineHeightLG+t.padding*2-1:0;return u===HeightMode.FULL_HEIGHT?window.innerHeight-l-_-f-h-g:d-_-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,d=e==null?void 0:e.fieldSchema,{getField:m}=useCollection_deprecated(),p=(e==null?void 0:e.collectionField)||m(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"},!d&&{label:o("Sub-details"),value:"Nester"},!d&&{label:o("Sub-table"),value:"SubTable"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!d&&["m2m","o2m"].includes(p.interface)&&{label:o("Sub-table"),value:"SubTable"},!d&&{label:o("Cascade Select"),value:"CascadeSelect"},!d&&{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"},!d&&{label:o("Sub-table"),value:"SubTable"},!d&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!d&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"},!d&&{label:o("Sub-table"),value:"SubTable"}];case"m2m":case"mbm":return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!d&&{label:o("Sub-details"),value:"Nester"},!d&&{label:o("Sub-table"),value:"SubTable"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!d&&{label:o("Sub-table"),value:"SubTable"},!d&&{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"},!d&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!d&&{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"},!d&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!d&&{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,d,m,p,g,h,f,_,v,C,S;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=(d=(u=y==null?void 0:y.data)==null?void 0:u.current)==null?void 0:d.insertAdjacent,R=(p=(m=y==null?void 0:y.data)==null?void 0:m.current)==null?void 0:p.breakRemoveOn,z=(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=(S=(C=(v=y==null?void 0:y.data)==null?void 0:v.current)==null?void 0:C.removeParentsIfNoChildren)!=null?S:!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:T=!0}={})=>t({refreshParentSchema:T}),current:j});if(D.loadAPIClientEvents(),F.parent===j.parent){D.insertBeforeBeginOrAfterEnd(F),e==null||e(i);return}if(k){D.insertAdjacent(k,F,{wrap:z,breakRemoveOn:R,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:d}=a,m=(c=(l=d==null?void 0:d.data)==null?void 0:l.current)==null?void 0:c.schema;r(!!m),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=W(r,["component","overStyle","style","children","openMode"]),{token:d}=useToken(),{draggable:m,droppable:p}=(0,import_react2.useContext)(SortableContext),{isOver:g,setNodeRef:h}=p,f=x({},a);return g&&((t=m==null?void 0:m.active)==null?void 0:t.id)!==((o=p==null?void 0:p.over)==null?void 0:o.id)&&(f[i==="a"?"color":"background"]=getComputedColor(d.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=W(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=W(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=W(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=W(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=W(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}),[]),d=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),m=(0,import_react2.useContext)(FormBlockContext);return(0,import_jsx_runtime.jsx)(FormBlockContext.Provider,{value:{parent:m,form:u,result:d,field:c,fieldSchema:l},children:(0,import_jsx_runtime.jsx)(import_antd.Spin,{spinning:(d==null?void 0:d.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)||[],d=getCurrentOptions(n.value,u,c);if(!(0,import_shared.isValid)(e.value)&&!d.length||(0,import_core2.isArrayField)(n)&&((l=n==null?void 0:n.value)==null?void 0:l.length)===0)return;const m=n.value!==null&&d.map((p,g)=>(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:p[c.color],icon:p.icon,children:p[c.label]},g));i(m),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,d=W(t,["value","options","onChange","fieldNames","mode","loading","rawOptions","defaultValue"]),m=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:m(o),defaultValue:m(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"},d))},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=W(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 d=m=>["tags","multiple"].includes(e.mode)||e.multiple?m?(0,import_shared.toArr)(m):void 0:m;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:d(i),defaultValue:d(a),tagRender:m=>(0,import_jsx_runtime.jsx)(import_antd.Tag,P(x({role:"button","aria-label":m.label,closeIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseOutlined,{role:"button","aria-label":"icon-close-tag"})},m),{children:m.label}))},c(l)),{onChange:m=>{var p;(p=e.onChange)==null||p.call(e,m===void 0?null:m)},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:d=!0,mapOptions:m,targetField:p,CustomDropdownRender:g,optionFilter:h,dataSource:f,toOptionsItem:_=K=>K,popupMatchSelectWidth:v=!1}=r,C=W(r,["fieldNames","service","wait","value","defaultValue","objectValue","manual","mapOptions","targetField","CustomDropdownRender","optionFilter","dataSource","toOptionsItem","popupMatchSelectWidth"]),S=useDataSourceKey(),b=useDataSourceHeaders(f||S),[y,F]=(0,import_react2.useState)(!1),j=(0,import_react2.useRef)(!1),k=(0,import_react.useFieldSchema)(),R=((t=k["x-component-props"])==null?void 0:t.addMode)==="quickAdd",{getField:z}=useCollection_deprecated(),N=(0,import_react2.useRef)(null),{getCollectionJoinField:L,getInterface:D}=useCollectionManager_deprecated(),T=k["x-collection-field"]||k.name,$=z(T)||L(T),w=p||($==null?void 0:$.target)&&(i==null?void 0:i.label)&&L(`${$.target}.${i.label}`),A=(0,import_react2.useMemo)(()=>{var K;if(w!=null&&w.interface){const J=D(w.interface),X=((K=J==null?void 0:J.filterable)==null?void 0:K.operators[0].value)||"$includes";return w.type==="string"?"$includes":X}return"$includes"},[w]),B=useCompile(),M=(0,import_react2.useCallback)(K=>{try{return K.filter(J=>["number","string"].includes(typeof J[i.value])||!J[i.value]).map(J=>{var X;let Q=B(J[i.label]);if((X=w==null?void 0:w.uiSchema)!=null&&X.enum)if(Array.isArray(Q))Q=Q.map((te,ee)=>{const ne=w.uiSchema.enum.find(ae=>ae.value===te);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)||te},ee):(0,import_jsx_runtime.jsx)(import_antd.Tag,{role:"button",children:te},te)}).reverse();else{const te=w.uiSchema.enum.find(ee=>ee.value===Q);te&&(Q=(0,import_jsx_runtime.jsx)(import_antd.Tag,{role:"button",color:te.color,children:te.label}))}return(w==null?void 0:w.type)==="date"&&(Q=(0,import_dayjs.default)(Q).format("YYYY-MM-DD")),m?m({[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),K}},[w==null?void 0:w.uiSchema,i]),{data:O,run:E,loading:U}=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:d,debounceWait:a},n.defaultParams?{defaultParams:[n.defaultParams]}:{})),V=(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()},[V]);const H=K=>q(void 0,null,function*(){var J;E({filter:mergeFilter([K?{[i.label]:{[A]:K}}:{},(J=n==null?void 0:n.params)==null?void 0:J.filter])}),N.current=K}),Y=(0,import_react2.useMemo)(()=>{var K;const J=l||c;if(!((K=O==null?void 0:O.data)!=null&&K.length))return J!=null?Array.isArray(J)?J:[J]:[];const X=J!=null&&(Array.isArray(J)?J.map(te=>P(x({},te),{[i.value]:te[i.value]||te})):[P(x({},J),{[i.value]:J[i.value]||J})])||[],Q=typeof h=="function"?O.data.filter(h):O.data;return(0,import_lodash.uniqBy)(Q.concat(X??[]),i.value)},[l,c,O==null?void 0:O.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:H,onDropdownVisibleChange:K=>{F(K),N.current=null,K&&E(),j.current=!0},objectValue:u,value:l,defaultValue:c},C),{loading:O?U:!0,options:_(M(Y)),rawOptions:Y,dropdownRender:K=>{const J=Y.some(X=>X[i.label]===N.current);return(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:R?(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[!((O==null?void 0:O.data.length)===0&&N!=null&&N.current)&&K,(O==null?void 0:O.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,{})]}):K})}}))},(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(d=>r(`${c.collection}.${d}`)?d:"").filter(Boolean)}catch(d){(0,import_client.error)(d),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,d]=(0,import_react2.useState)((a==null?void 0:a.key)||"none"),[m,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)||S("none")},[c]);const v=(0,import_react2.useMemo)(()=>x({display:"flex",alignItems:"center",backgroundColor:o.colorFillAlter,padding:o.padding},e),[e,o.colorFillAlter]),C=(0,import_react2.useMemo)(()=>({fontSize:o.fontSize,fontWeight:"bold",whiteSpace:"nowrap",marginRight:o.marginXS}),[o.fontSize,o.marginXS]),S=(0,import_react2.useCallback)(F=>q(void 0,null,function*(){d(F),p(null),t==null||t.reset()}),[]),b=(0,import_react2.useCallback)((F,j,k)=>q(void 0,null,function*(){const R=P(x({},j),{dataId:F});p(j),fetchTemplateData(g,R,k).then(z=>(t&&z&&(t.reset(),t.__template=!0,(0,import_client.forEach)(z,(N,L)=>{var D;N&&(t.values[L]=N,(D=t==null?void 0:t.setInitialValuesIn)==null||D.call(t,L,N))})),z)).catch(z=>{console.error(z)})}),[]);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:C,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:S}),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:m,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:d}=useFormDataTemplates(),m=i.reduceProperties((y,F)=>F["x-component"]==="ActionBar"?F:y),p=Object.keys((m==null?void 0:m.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:C}=(_==null?void 0:_.meta)||{},S=v>C?n.controlHeightSM+1*n.paddingLG:0,b=u&&d?n.controlHeight+2*n.padding+n.margin:0;return r-h-n.paddingLG-f-S-b},FormComponent=e=>{const t=e,{form:o,children:r}=t,i=W(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:d}=import_antd.theme.useToken(),{layout:m="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:m},i),{labelAlign:p,labelWidth:m==="horizontal"?g:null,labelWrap:h,children:(0,import_jsx_runtime.jsx)("div",{className:import_css.css`
|
|
598
|
+
`,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)(),d=n(u.name)||r(u["x-collection-field"]),m=useVariables$1(),p=useLocalVariables$1(),{dn:g}=useDesignable();return{collectionName:d==null?void 0:d.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:m,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(d=>d!=null&&d.startsWith("-")?{field:d.substring(1),direction:"desc"}:{field:d,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:d})=>{const m=d.map(p=>p.direction==="desc"?`-${p.field}`:p.field);t.componentProps.sortArr=m,o["x-component-props"].sortArr=m,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(d){var m,p;const g={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].mode=d,g["x-component-props"]=l["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=d,isSubMode(l)&&o&&(g.default=null,l.default=null,(m=t==null?void 0:t.setInitialValue)==null||m.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(d){const m={"x-uid":n["x-uid"]};n["x-component-props"]=n["x-component-props"]||{},n["x-component-props"].mode=d,m["x-component-props"]=n["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=d,isSubMode(n)&&c&&(m.default=null,n.default=null,t.setInitialValue(null),t.setValue(null)),l.emit("patch",{schema:m}),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(),d=n||u,{dn:m}=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=d==null?void 0:d.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,m.emit("patch",{schema:f}),m.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(d){const m={"x-uid":l["x-uid"]};l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].mode=d,m["x-component-props"]=l["x-component-props"],t.componentProps=t.componentProps||{},t.componentProps.mode=d,isSubMode(l)&&o&&(m.default=null,l.default=null,t.setInitialValue(null),t.setValue(null)),u.emit("patch",{schema:m}),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:d}=useDesignable(),m=useColorFields((e=u==null?void 0:u.target)!=null?e:u==null?void 0:u.targetCollection);return{title:o("Tag color field"),options:m,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,d.emit("patch",{schema:g}),d.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])}},cache=new Map,cacheLazyLoadedValues=(e,t,o)=>{const r=cache.get(e);r?r[t]=o:cache.set(e,{[t]:o})},getCachedLazyLoadedValues=(e,t)=>{const o=cache.get(e);return o==null?void 0:o[t]},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,C)=>q(void 0,null,function*(){var S,b;const y=_.split("."),F=y[0],j=mergeVariableToCollectionNameWithLocalVariables(variablesStore,v);let k=mergeCtxWithLocalVariables(o.current,v);const{fieldPath:R,dataSource:z,variableOption:N}=getFieldPath(F,j);let L=R;const{fieldPath:D}=getFieldPath(_,j),T=y.length===1?N==null?void 0:N.collectionName:(S=i(D,z))==null?void 0:S.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:z,collectionName:T};const A=y[w],B=y.slice(0,w+1).join("."),{fieldPath:M}=getFieldPath(B,j),O=i(M,z),E=(b=n(L,z))==null?void 0:b.getPrimaryKey();if(Array.isArray(k)){const U=k.map(V=>{if(!(C!=null&&C.doNotRequest)&&shouldToRequest(V==null?void 0:V[A],V,B)&&(V==null?void 0:V[E])!=null&&O!=null&&O.target){const G=`/${L}/${V[O.sourceKey||E]}/${A}:${getAction(O.type)}`;if(hasRequested(G))return getRequested(G);const H=r.request({headers:getDataSourceHeaders(z),url:G,params:{appends:C==null?void 0:C.appends}}).then(Y=>{clearRequested(G);const K=Y.data.data;return cacheLazyLoadedValues(V,B,K),K});return stashRequested(G,H),H}return getCachedLazyLoadedValues(V,B)||(V==null?void 0:V[A])});k=removeThroughCollectionFields(import_lodash.default.flatten(yield Promise.all(U)),O)}else if(!(C!=null&&C.doNotRequest)&&shouldToRequest(k[A],k,B)&&k[E]!=null&&O!=null&&O.target){const U=`/${L}/${k[O.sourceKey||E]}/${A}:${getAction(O.type)}`;let V=null;if(hasRequested(U))V=yield getRequested(U);else{const H=r.request({headers:getDataSourceHeaders(z),url:U,params:{appends:C==null?void 0:C.appends}});stashRequested(U,H),V=yield H,clearRequested(U)}const G=V.data.data;getCachedLazyLoadedValues(k,B)||cacheLazyLoadedValues(k,B,G),k=removeThroughCollectionFields(G,O)}else k=removeThroughCollectionFields(getCachedLazyLoadedValues(k,B)||(0,import_client.getValuesByPath)(k,A),O);O!=null&&O.target&&(L=O.target)}const $=a(import_lodash.default.isFunction(k)?k({fieldOperator:C==null?void 0:C.fieldOperator,isParsingVariable:!0}):k);return{value:$===void 0?N.defaultValue:$,dataSource:z,collectionName:T}}),[i]),d=(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]),m=(0,import_react2.useCallback)(_=>o.current[_]?x({},variablesStore[_]):null,[]),p=(0,import_react2.useCallback)(_=>{c(v=>{const C=x({},v);return delete C[_],C}),delete variablesStore[_]},[c]),g=(0,import_react2.useCallback)((_,v,C)=>q(void 0,null,function*(){if(!isVariable(_))return _;v&&(v=import_lodash.default.isArray(v)?v:[v]);const S=getPath(_),b=yield u(S,v,C);return P(x({},b),{value:uniq(filterEmptyValues(b.value))})}),[u]),h=(0,import_react2.useCallback)((_,v)=>q(void 0,null,function*(){var C;if(!isVariable(_))throw new Error(`VariablesProvider: ${_} is not a variable string`);v&&(v=import_lodash.default.isArray(v)?v:[v]);const S=mergeVariableToCollectionNameWithLocalVariables(variablesStore,v),b=getPath(_),{fieldPath:y,dataSource:F}=getFieldPath(b,S);let j=i(y,F);return!j&&!b.includes(".")&&(j={target:(C=S[b])==null?void 0:C.collectionName}),j}),[i]);(0,import_react2.useEffect)(()=>{l.forEach(_=>{d(P(x({},_),{defaultValue:import_lodash.default.has(_,"defaultValue")?_.defaultValue:null}))})},[l,d]);const f=(0,import_react2.useMemo)(()=>({ctxRef:o,setCtx:c,parseVariable:g,registerVariable:d,getVariable:m,getCollectionField:h,removeVariable:p,filterVariables:t}),[h,m,g,d,p,c]);return(0,import_jsx_runtime.jsx)(VariablesContext.Provider,{value:f,children:e})};VariablesProvider.displayName="VariablesProvider";const VariablesProvider$1=VariablesProvider;function shouldToRequest(e,t,o){let r=!1;return getCachedLazyLoadedValues(t,o)?!1:((0,import_reactive.untracked)(()=>{if(JSON.stringify(e)==="[{}]"||JSON.stringify(e)==="{}"){r=!0;return}r=import_lodash.default.isEmpty(e)}),r)}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){I(this,"props"),I(this,"initialized"),I(this,"loading"),I(this,"validating"),I(this,"submitting"),I(this,"selfModified"),I(this,"active"),I(this,"visited"),I(this,"mounted"),I(this,"unmounted"),I(this,"inputValues"),I(this,"inputValue"),I(this,"feedbacks"),I(this,"title"),I(this,"description"),I(this,"display"),I(this,"pattern"),I(this,"editable"),I(this,"disabled"),I(this,"readOnly"),I(this,"readPretty"),I(this,"visible"),I(this,"hidden"),I(this,"dataSource"),I(this,"validator"),I(this,"required"),I(this,"content"),I(this,"initialValue"),I(this,"value"),I(this,"data"),I(this,"decorator"),I(this,"component"),I(this,"decoratorProps"),I(this,"componentProps"),I(this,"decoratorType"),I(this,"componentType"),I(this,"path"),I(this,"form"),I(this,"address"),this.props=e,this.initialize()}initialize(){var e,t,o,r,i,n,a,l,c,u,d,m,p,g,h,f,_,v,C,S;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||((d=this.props.schema)==null?void 0:d.default)),this.value=b(this.props.value),this.data=this.props.data||((m=this.props.schema)==null?void 0:m["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=(C=this.props.schema)==null?void 0:C["x-decorator"],this.componentType=(S=this.props.schema)==null?void 0:S["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:d},m)=>{const p=(t==null?void 0:t.address)||o;let g=u;if((0,import_shared.isFn)(r)){const f=r(u,d);f&&(g=f)}if((0,import_shared.isFn)(i)&&i(g,d)===!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:d,basePath:p,values:import_lodash.default.get(a,d),isUseFormilyField:l}):(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{schema:g,name:d,basePath:p,values:import_lodash.default.get(a,d),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})},`${m}-${d}`):(0,import_jsx_runtime.jsx)(IsInNocoBaseRecursionFieldContext.Provider,{value:!1,children:(0,import_jsx_runtime.jsx)(CollectionFieldUISchemaContext.Provider,{value:EMPTY_OBJECT,children:h})},`${m}-${d}`)})}):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:d}=e,m=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),C=p.current||g,S=(0,import_react2.useCallback)(()=>{const k=C.parent;p.current=new import_react.Schema(C.toJSON(),k),k!=null&&k.properties&&Object.keys(k.properties).forEach(R=>{R===C.name&&(k.properties[R]=p.current)}),_(),v==null||v()},[C,v,_]),b=(0,import_react2.useMemo)(()=>d?createMergedSchemaInstance(C,d,r):h?(h.default=f,createMergedSchemaInstance(C,h,r)):C,[h,f,C,r,d]),y=useFieldProps$1(b),F=k=>{if(!i)return propertiesToReactElement({schema:C,field:k,basePath:m,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:m,children:F})):b.type==="array"?(0,import_jsx_runtime.jsx)(import_react.ArrayField,P(x({},y),{name:o,basePath:m})):b.type==="void"?r?F():(0,import_jsx_runtime.jsx)(import_react.VoidField,P(x({},y),{name:o,basePath:m,children:F})):u?(0,import_jsx_runtime.jsx)(import_react.Field,P(x({},y),{name:o,basePath:m})):(0,import_jsx_runtime.jsx)(NocoBaseField,{name:o,value:c,initialValue:c,basePath:m,schema:b}):F();return C?(0,import_jsx_runtime.jsx)(import_react.SchemaContext.Provider,{value:C,children:(0,import_jsx_runtime.jsx)(RefreshFieldSchemaProvider,{refresh:S,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.21",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.21","@nocobase/sdk":"1.5.21","@nocobase/utils":"1.5.21",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){I(this,"current"),I(this,"options"),I(this,"appVersion"),I(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:d,removed:m}){var p;let g=[];if((d==null?void 0:d["x-component"])==="Grid.Col"&&(g=g.concat(r(d.parent))),(m==null?void 0:m["x-component"])==="Grid.Col"&&(g=g.concat(r(m.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})),m!=null&&m["x-uid"]&&(yield t.request({url:`/uiSchemas:remove/${m["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,d=0;this.current.parent.mapProperties((f,_)=>{_===this.current.name&&(d=u,c=!0,++u),f["x-index"]=u,++u,c&&(l[_]=f,this.current.parent.removeProperty(_))}),this.prepareProperty(t);const m=i(t),p=this.current.parent.addProperty(m.name||(0,import_shared.uid)(),m);p["x-index"]=d,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:m,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),d=this.current.addProperty(u.name||(0,import_shared.uid)(),u);d["x-index"]=0,d.parent=this.current,this.current.setProperties(l);const[m,p]=splitWrapSchema(d,t);this.emit("insertAdjacent",x({position:"afterBegin",schema:p,wrap:m,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,d]=splitWrapSchema(c,t);return this.emit("insertAdjacent",x({position:"beforeEnd",schema:d,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 d={};if(this.current.parent.mapProperties((f,_)=>{f["x-index"]=l,_===this.current.name&&(++l,c=l,u=!0),++l,u&&_!==this.current.name&&(d[_]=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 m=i(t),p=this.current.parent.addProperty(m.name||(0,import_shared.uid)(),m);p.parent=this.current.parent,p["x-index"]=c,this.current.parent.setProperties(d);const[g,h]=splitWrapSchema(p,t);this.emit("insertAdjacent",x({position:"afterEnd",schema:h,wrap:g,wrapped:m},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(),d=(0,import_react2.useCallback)(_=>{o==null||o(),l(),c==null||c(_),u==null||u()},[o,l,c,u]),m=(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:d,current:p,model:m,appVersion:clientPkg.version}),[h,g,d,p,m]);return(0,import_react2.useEffect)(()=>{f.loadAPIClientEvents()},[f]),{dn:f,designable:e,reset:r,refresh:d,setDesignable:t,DesignableBar:a,findComponent:(0,import_react2.useCallback)(_=>{var v;if(!_)return null;if(typeof _!="string")return _;const C=(0,import_get.default)(n,_);return(v=C[LAZY_COMPONENT_KEY])!=null?v:C},[import_get.default]),on:f.on.bind(f),patch:(0,import_react2.useCallback)((_,v)=>{const C=S=>{Object.keys(S).forEach(b=>{const y=S[b];b==="title"&&(m.title=y,p.title=y),b==="x-decorator-props"&&(m.decoratorProps||(m.decoratorProps={}),p["x-decorator-props"]||(p["x-decorator-props"]={}),Object.keys(y).forEach(F=>{m.decoratorProps[F]=y[F],p["x-decorator-props"][F]=y[F]})),b==="x-component-props"&&(m.componentProps||(m.componentProps={}),p["x-component-props"]||(p["x-component-props"]={}),Object.keys(y).forEach(F=>{m.componentProps[F]=y[F],p["x-component-props"][F]=y[F]}))})};if(typeof _=="string"){const S={};return(0,import_set.default)(S,_,v),C(S)}C(_),d()},[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,C)=>{f.insertAdjacent(_,v,C)},[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,d=getPageHeaderHeight(n,a,l,t,i.pathname);return c+d+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:d,title:m}=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,_=m?t.fontSizeLG*t.lineHeightLG+t.padding*2-1:0;return u===HeightMode.FULL_HEIGHT?window.innerHeight-l-_-f-h-g:d-_-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,d=e==null?void 0:e.fieldSchema,{getField:m}=useCollection_deprecated(),p=(e==null?void 0:e.collectionField)||m(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"},!d&&{label:o("Sub-details"),value:"Nester"},!d&&{label:o("Sub-table"),value:"SubTable"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!d&&["m2m","o2m"].includes(p.interface)&&{label:o("Sub-table"),value:"SubTable"},!d&&{label:o("Cascade Select"),value:"CascadeSelect"},!d&&{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"},!d&&{label:o("Sub-table"),value:"SubTable"},!d&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!d&&{label:o("Sub-form"),value:"Nester"},{label:o("Sub-form(Popover)"),value:"PopoverNester"},!d&&{label:o("Sub-table"),value:"SubTable"}];case"m2m":case"mbm":return u?[{label:o("Title"),value:"Select"},{label:o("Tag"),value:"Tag"},!d&&{label:o("Sub-details"),value:"Nester"},!d&&{label:o("Sub-table"),value:"SubTable"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!d&&{label:o("Sub-table"),value:"SubTable"},!d&&{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"},!d&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!d&&{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"},!d&&{label:o("Sub-details"),value:"Nester"}]:[{label:o("Select"),value:"Select"},{label:o("Record picker"),value:"Picker"},!d&&{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,d,m,p,g,h,f,_,v,C,S;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=(d=(u=y==null?void 0:y.data)==null?void 0:u.current)==null?void 0:d.insertAdjacent,R=(p=(m=y==null?void 0:y.data)==null?void 0:m.current)==null?void 0:p.breakRemoveOn,z=(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=(S=(C=(v=y==null?void 0:y.data)==null?void 0:v.current)==null?void 0:C.removeParentsIfNoChildren)!=null?S:!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:T=!0}={})=>t({refreshParentSchema:T}),current:j});if(D.loadAPIClientEvents(),F.parent===j.parent){D.insertBeforeBeginOrAfterEnd(F),e==null||e(i);return}if(k){D.insertAdjacent(k,F,{wrap:z,breakRemoveOn:R,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:d}=a,m=(c=(l=d==null?void 0:d.data)==null?void 0:l.current)==null?void 0:c.schema;r(!!m),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=W(r,["component","overStyle","style","children","openMode"]),{token:d}=useToken(),{draggable:m,droppable:p}=(0,import_react2.useContext)(SortableContext),{isOver:g,setNodeRef:h}=p,f=x({},a);return g&&((t=m==null?void 0:m.active)==null?void 0:t.id)!==((o=p==null?void 0:p.over)==null?void 0:o.id)&&(f[i==="a"?"color":"background"]=getComputedColor(d.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=W(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=W(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=W(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=W(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=W(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}),[]),d=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),m=(0,import_react2.useContext)(FormBlockContext);return(0,import_jsx_runtime.jsx)(FormBlockContext.Provider,{value:{parent:m,form:u,result:d,field:c,fieldSchema:l},children:(0,import_jsx_runtime.jsx)(import_antd.Spin,{spinning:(d==null?void 0:d.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)||[],d=getCurrentOptions(n.value,u,c);if(!(0,import_shared.isValid)(e.value)&&!d.length||(0,import_core2.isArrayField)(n)&&((l=n==null?void 0:n.value)==null?void 0:l.length)===0)return;const m=n.value!==null&&d.map((p,g)=>(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:p[c.color],icon:p.icon,children:p[c.label]},g));i(m),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,d=W(t,["value","options","onChange","fieldNames","mode","loading","rawOptions","defaultValue"]),m=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:m(o),defaultValue:m(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"},d))},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=W(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 d=m=>["tags","multiple"].includes(e.mode)||e.multiple?m?(0,import_shared.toArr)(m):void 0:m;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:d(i),defaultValue:d(a),tagRender:m=>(0,import_jsx_runtime.jsx)(import_antd.Tag,P(x({role:"button","aria-label":m.label,closeIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseOutlined,{role:"button","aria-label":"icon-close-tag"})},m),{children:m.label}))},c(l)),{onChange:m=>{var p;(p=e.onChange)==null||p.call(e,m===void 0?null:m)},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:d=!0,mapOptions:m,targetField:p,CustomDropdownRender:g,optionFilter:h,dataSource:f,toOptionsItem:_=K=>K,popupMatchSelectWidth:v=!1}=r,C=W(r,["fieldNames","service","wait","value","defaultValue","objectValue","manual","mapOptions","targetField","CustomDropdownRender","optionFilter","dataSource","toOptionsItem","popupMatchSelectWidth"]),S=useDataSourceKey(),b=useDataSourceHeaders(f||S),[y,F]=(0,import_react2.useState)(!1),j=(0,import_react2.useRef)(!1),k=(0,import_react.useFieldSchema)(),R=((t=k["x-component-props"])==null?void 0:t.addMode)==="quickAdd",{getField:z}=useCollection_deprecated(),N=(0,import_react2.useRef)(null),{getCollectionJoinField:L,getInterface:D}=useCollectionManager_deprecated(),T=k["x-collection-field"]||k.name,$=z(T)||L(T),w=p||($==null?void 0:$.target)&&(i==null?void 0:i.label)&&L(`${$.target}.${i.label}`),A=(0,import_react2.useMemo)(()=>{var K;if(w!=null&&w.interface){const J=D(w.interface),X=((K=J==null?void 0:J.filterable)==null?void 0:K.operators[0].value)||"$includes";return w.type==="string"?"$includes":X}return"$includes"},[w]),B=useCompile(),M=(0,import_react2.useCallback)(K=>{try{return K.filter(J=>["number","string"].includes(typeof J[i.value])||!J[i.value]).map(J=>{var X;let Q=B(J[i.label]);if((X=w==null?void 0:w.uiSchema)!=null&&X.enum)if(Array.isArray(Q))Q=Q.map((te,ee)=>{const ne=w.uiSchema.enum.find(ae=>ae.value===te);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)||te},ee):(0,import_jsx_runtime.jsx)(import_antd.Tag,{role:"button",children:te},te)}).reverse();else{const te=w.uiSchema.enum.find(ee=>ee.value===Q);te&&(Q=(0,import_jsx_runtime.jsx)(import_antd.Tag,{role:"button",color:te.color,children:te.label}))}return(w==null?void 0:w.type)==="date"&&(Q=(0,import_dayjs.default)(Q).format("YYYY-MM-DD")),m?m({[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),K}},[w==null?void 0:w.uiSchema,i]),{data:O,run:E,loading:U}=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:d,debounceWait:a},n.defaultParams?{defaultParams:[n.defaultParams]}:{})),V=(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()},[V]);const H=K=>q(void 0,null,function*(){var J;E({filter:mergeFilter([K?{[i.label]:{[A]:K}}:{},(J=n==null?void 0:n.params)==null?void 0:J.filter])}),N.current=K}),Y=(0,import_react2.useMemo)(()=>{var K;const J=l||c;if(!((K=O==null?void 0:O.data)!=null&&K.length))return J!=null?Array.isArray(J)?J:[J]:[];const X=J!=null&&(Array.isArray(J)?J.map(te=>P(x({},te),{[i.value]:te[i.value]||te})):[P(x({},J),{[i.value]:J[i.value]||J})])||[],Q=typeof h=="function"?O.data.filter(h):O.data;return(0,import_lodash.uniqBy)(Q.concat(X??[]),i.value)},[l,c,O==null?void 0:O.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:H,onDropdownVisibleChange:K=>{F(K),N.current=null,K&&E(),j.current=!0},objectValue:u,value:l,defaultValue:c},C),{loading:O?U:!0,options:_(M(Y)),rawOptions:Y,dropdownRender:K=>{const J=Y.some(X=>X[i.label]===N.current);return(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:R?(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[!((O==null?void 0:O.data.length)===0&&N!=null&&N.current)&&K,(O==null?void 0:O.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,{})]}):K})}}))},(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(d=>r(`${c.collection}.${d}`)?d:"").filter(Boolean)}catch(d){(0,import_client.error)(d),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,d]=(0,import_react2.useState)((a==null?void 0:a.key)||"none"),[m,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)||S("none")},[c]);const v=(0,import_react2.useMemo)(()=>x({display:"flex",alignItems:"center",backgroundColor:o.colorFillAlter,padding:o.padding},e),[e,o.colorFillAlter]),C=(0,import_react2.useMemo)(()=>({fontSize:o.fontSize,fontWeight:"bold",whiteSpace:"nowrap",marginRight:o.marginXS}),[o.fontSize,o.marginXS]),S=(0,import_react2.useCallback)(F=>q(void 0,null,function*(){d(F),p(null),t==null||t.reset()}),[]),b=(0,import_react2.useCallback)((F,j,k)=>q(void 0,null,function*(){const R=P(x({},j),{dataId:F});p(j),fetchTemplateData(g,R,k).then(z=>(t&&z&&(t.reset(),t.__template=!0,(0,import_client.forEach)(z,(N,L)=>{var D;N&&(t.values[L]=N,(D=t==null?void 0:t.setInitialValuesIn)==null||D.call(t,L,N))})),z)).catch(z=>{console.error(z)})}),[]);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:C,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:S}),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:m,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:d}=useFormDataTemplates(),m=i.reduceProperties((y,F)=>F["x-component"]==="ActionBar"?F:y),p=Object.keys((m==null?void 0:m.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:C}=(_==null?void 0:_.meta)||{},S=v>C?n.controlHeightSM+1*n.paddingLG:0,b=u&&d?n.controlHeight+2*n.padding+n.margin:0;return r-h-n.paddingLG-f-S-b},FormComponent=e=>{const t=e,{form:o,children:r}=t,i=W(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:d}=import_antd.theme.useToken(),{layout:m="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:m},i),{labelAlign:p,labelWidth:m==="horizontal"?g:null,labelWrap:h,children:(0,import_jsx_runtime.jsx)("div",{className:import_css.css`
|
|
596
599
|
.nb-grid-container {
|
|
597
600
|
height: ${u?u+"px":"100%"};
|
|
598
601
|
overflow-y: auto;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/client",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.21",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"@formily/reactive-react": "^2.2.27",
|
|
28
28
|
"@formily/shared": "^2.2.27",
|
|
29
29
|
"@formily/validator": "^2.2.27",
|
|
30
|
-
"@nocobase/evaluators": "1.5.
|
|
31
|
-
"@nocobase/sdk": "1.5.
|
|
32
|
-
"@nocobase/utils": "1.5.
|
|
30
|
+
"@nocobase/evaluators": "1.5.21",
|
|
31
|
+
"@nocobase/sdk": "1.5.21",
|
|
32
|
+
"@nocobase/utils": "1.5.21",
|
|
33
33
|
"ahooks": "^3.7.2",
|
|
34
34
|
"antd": "5.12.8",
|
|
35
35
|
"antd-style": "3.7.1",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"dumi": "2.2.14",
|
|
82
82
|
"dumi-theme-nocobase": "^0.2.28"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "5464963b6d2af7667b96efec60af2aaf5360ecd2"
|
|
85
85
|
}
|