@nocobase/client 1.5.12 → 1.5.13
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 +6 -6
- package/lib/index.js +2 -2
- package/package.json +5 -5
package/es/index.mjs
CHANGED
|
@@ -35211,7 +35211,7 @@ function addAppVersion(e, t) {
|
|
|
35211
35211
|
addAppVersion((o = e.properties) == null ? void 0 : o[n], t);
|
|
35212
35212
|
}), e;
|
|
35213
35213
|
}
|
|
35214
|
-
const name = "@nocobase/client", version = "1.5.
|
|
35214
|
+
const name = "@nocobase/client", version = "1.5.13", license = "AGPL-3.0", main = "lib/index.js", module = "es/index.mjs", types = "es/index.d.ts", dependencies = {
|
|
35215
35215
|
"@ahooksjs/use-url-state": "3.5.1",
|
|
35216
35216
|
"@ant-design/cssinjs": "^1.11.1",
|
|
35217
35217
|
"@ant-design/icons": "^5.1.4",
|
|
@@ -35233,9 +35233,9 @@ const name = "@nocobase/client", version = "1.5.12", license = "AGPL-3.0", main
|
|
|
35233
35233
|
"@formily/reactive-react": "^2.2.27",
|
|
35234
35234
|
"@formily/shared": "^2.2.27",
|
|
35235
35235
|
"@formily/validator": "^2.2.27",
|
|
35236
|
-
"@nocobase/evaluators": "1.5.
|
|
35237
|
-
"@nocobase/sdk": "1.5.
|
|
35238
|
-
"@nocobase/utils": "1.5.
|
|
35236
|
+
"@nocobase/evaluators": "1.5.13",
|
|
35237
|
+
"@nocobase/sdk": "1.5.13",
|
|
35238
|
+
"@nocobase/utils": "1.5.13",
|
|
35239
35239
|
ahooks: "^3.7.2",
|
|
35240
35240
|
antd: "5.12.8",
|
|
35241
35241
|
"antd-style": "3.7.1",
|
|
@@ -38779,14 +38779,14 @@ function Uploader(n) {
|
|
|
38779
38779
|
var M;
|
|
38780
38780
|
return c((M = B.response) == null ? void 0 : M.data);
|
|
38781
38781
|
})];
|
|
38782
|
-
z.length ? d(w) : (
|
|
38782
|
+
z.length ? d(w) : (l == null || l([...a, ...w]), d([]));
|
|
38783
38783
|
}
|
|
38784
38784
|
} else {
|
|
38785
38785
|
const $ = j.fileList.find((w) => w.uid === j.file.uid);
|
|
38786
38786
|
$.status === "done" && (l == null || l(c((L = $.response) == null ? void 0 : L.data)), m([]));
|
|
38787
38787
|
}
|
|
38788
38788
|
},
|
|
38789
|
-
[i, u, c, l]
|
|
38789
|
+
[i, a, u, c, l]
|
|
38790
38790
|
), y = useCallback((j) => {
|
|
38791
38791
|
m((z) => {
|
|
38792
38792
|
const L = z.indexOf(j);
|
package/lib/index.js
CHANGED
|
@@ -592,7 +592,7 @@ https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModu
|
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
594
|
}
|
|
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:B}=getFieldPath(F,j);let L=R;const{fieldPath:D}=getFieldPath(_,j),T=y.length===1?B==null?void 0:B.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?B==null?void 0:B.defaultValue:k,dataSource:z,collectionName:T};const I=y[w],N=y.slice(0,w+1).join("."),{fieldPath:M}=getFieldPath(N,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[I],V,N)&&(V==null?void 0:V[E])!=null&&O!=null&&O.target){const G=`/${L}/${V[O.sourceKey||E]}/${I}:${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,N,K),K});return stashRequested(G,H),H}return getCachedLazyLoadedValues(V,N)||(V==null?void 0:V[I])});k=removeThroughCollectionFields(import_lodash.default.flatten(yield Promise.all(U)),O)}else if(!(C!=null&&C.doNotRequest)&&shouldToRequest(k[I],k,N)&&k[E]!=null&&O!=null&&O.target){const U=`/${L}/${k[O.sourceKey||E]}/${I}:${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,N)||cacheLazyLoadedValues(k,N,G),k=removeThroughCollectionFields(G,O)}else k=removeThroughCollectionFields(getCachedLazyLoadedValues(k,N)||(0,import_client.getValuesByPath)(k,I),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?B.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){A(this,"props"),A(this,"initialized"),A(this,"loading"),A(this,"validating"),A(this,"submitting"),A(this,"selfModified"),A(this,"active"),A(this,"visited"),A(this,"mounted"),A(this,"unmounted"),A(this,"inputValues"),A(this,"inputValue"),A(this,"feedbacks"),A(this,"title"),A(this,"description"),A(this,"display"),A(this,"pattern"),A(this,"editable"),A(this,"disabled"),A(this,"readOnly"),A(this,"readPretty"),A(this,"visible"),A(this,"hidden"),A(this,"dataSource"),A(this,"validator"),A(this,"required"),A(this,"content"),A(this,"initialValue"),A(this,"value"),A(this,"data"),A(this,"decorator"),A(this,"component"),A(this,"decoratorProps"),A(this,"componentProps"),A(this,"decoratorType"),A(this,"componentType"),A(this,"path"),A(this,"form"),A(this,"address"),this.props=e,this.initialize()}initialize(){var e,t,o,r,i,n,a,l,c,u,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.12",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.12","@nocobase/sdk":"1.5.12","@nocobase/utils":"1.5.12",ahooks:"^3.7.2",antd:"5.12.8","antd-style":"3.7.1",axios:"^1.7.0","bignumber.js":"^9.1.2",classnames:"^2.3.1",cronstrue:"^2.11.0","file-saver":"^2.0.5",filesize:"9.0.11",flat:"^5.0.2",i18next:"^22.4.9","i18next-http-backend":"^2.1.1",json5:"^2.2.3",lodash:"4.17.21","lru-cache":"6.0.0","markdown-it":"14.1.0","markdown-it-highlightjs":"3.3.1",mathjs:"^10.6.0",mermaid:"9.4.3",mime:"^4.0.4","mime-match":"^1.0.2","react-beautiful-dnd":"^13.1.0","react-drag-listview":"^0.1.9","react-error-boundary":"^4.0.10","react-helmet":"^6.1.0","react-hotkeys-hook":"^3.4.7","react-i18next":"^11.15.1","react-iframe":"~1.8.5","react-image-lightbox":"^5.1.4","react-intersection-observer":"9.14.0","react-js-cron":"^3.1.0","react-quill":"^2.0.0","react-router-dom":"^6.11.2","react-to-print":"^2.14.7","sanitize-html":"2.13.0","use-deep-compare-effect":"^1.8.1"},peerDependencies={react:">=18.0.0","react-dom":">=18.0.0","react-is":">=18.0.0"},devDependencies={"@testing-library/react":"^14.0.0","@types/markdown-it":"14.1.1","@types/markdown-it-highlightjs":"3.3.1","@types/react-big-calendar":"^1.6.4","axios-mock-adapter":"^1.20.0",dumi:"2.2.14","dumi-theme-nocobase":"^0.2.28"},clientPkg={name,version,license,main,module:module$1,types,dependencies,peerDependencies,devDependencies};function createDesignable(e){return new Designable(e)}const generateUid=e=>{e&&(e["x-uid"]||(e["x-uid"]=(0,import_shared.uid)()),Object.keys(e.properties||{}).forEach(t=>{generateUid(e.properties[t])}))},defaultWrap=e=>e,matchSchema=(e,t)=>{if(!(!e||!t)){for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==(e==null?void 0:e[o]))return!1;return!0}},splitWrapSchema=(e,t)=>{if(e["x-uid"]&&e["x-uid"]===t["x-uid"])return[null,e.toJSON()];const o=e.toJSON(),r=P(x({},o),{properties:{}});let i=null;const n=(a,l)=>{Object.keys(a||{}).forEach(c=>{const u=a[c];if(u["x-uid"]===t["x-uid"]){i=a[c];return}else l.properties[c]=P(x({},u),{properties:{}}),n(u==null?void 0:u.properties,l.properties[c])})};return n(o.properties,r),[r,i]},translate=e=>e;class Designable{constructor(t){A(this,"current"),A(this,"options"),A(this,"appVersion"),A(this,"events",{}),this.options=t,this.current=t.current,this.appVersion=t.appVersion}get model(){return this.options.model}get query(){return this.options.query}loadAPIClientEvents(){const{api:t,t:o=translate}=this.options;if(!t)return;const r=i=>{if(!i)return[];const n=Object.values(i.properties).length,a=[];return i.mapProperties(l=>{l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].width=100/n,l["x-uid"]&&a.push({"x-uid":l["x-uid"],"x-component-props":l["x-component-props"]})}),i["x-uid"]&&a.length?a:[]};this.on("insertAdjacent",i=>q(this,[i],function*({onSuccess:n,current:a,position:l,schema:c,wrap:u,wrapped: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,B=(_=(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:B}),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(),B=(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}`),I=(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]),N=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=N(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)(()=>B.current&&g?(0,import_jsx_runtime.jsx)(g,{search:B.current,callBack:()=>{B.current=null,F(!1)}}):null,[B.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]:{[I]:K}}:{},(J=n==null?void 0:n.params)==null?void 0:J.filter])}),B.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),B.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]===B.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&&B!=null&&B.current)&&K,(O==null?void 0:O.data.length)>0&&(B==null?void 0:B.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,(B,L)=>{var D;B&&(t.values[L]=B,(D=t==null?void 0:t.setInitialValuesIn)==null||D.call(t,L,B))})),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`
|
|
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:B}=getFieldPath(F,j);let L=R;const{fieldPath:D}=getFieldPath(_,j),T=y.length===1?B==null?void 0:B.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?B==null?void 0:B.defaultValue:k,dataSource:z,collectionName:T};const I=y[w],N=y.slice(0,w+1).join("."),{fieldPath:M}=getFieldPath(N,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[I],V,N)&&(V==null?void 0:V[E])!=null&&O!=null&&O.target){const G=`/${L}/${V[O.sourceKey||E]}/${I}:${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,N,K),K});return stashRequested(G,H),H}return getCachedLazyLoadedValues(V,N)||(V==null?void 0:V[I])});k=removeThroughCollectionFields(import_lodash.default.flatten(yield Promise.all(U)),O)}else if(!(C!=null&&C.doNotRequest)&&shouldToRequest(k[I],k,N)&&k[E]!=null&&O!=null&&O.target){const U=`/${L}/${k[O.sourceKey||E]}/${I}:${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,N)||cacheLazyLoadedValues(k,N,G),k=removeThroughCollectionFields(G,O)}else k=removeThroughCollectionFields(getCachedLazyLoadedValues(k,N)||(0,import_client.getValuesByPath)(k,I),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?B.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){A(this,"props"),A(this,"initialized"),A(this,"loading"),A(this,"validating"),A(this,"submitting"),A(this,"selfModified"),A(this,"active"),A(this,"visited"),A(this,"mounted"),A(this,"unmounted"),A(this,"inputValues"),A(this,"inputValue"),A(this,"feedbacks"),A(this,"title"),A(this,"description"),A(this,"display"),A(this,"pattern"),A(this,"editable"),A(this,"disabled"),A(this,"readOnly"),A(this,"readPretty"),A(this,"visible"),A(this,"hidden"),A(this,"dataSource"),A(this,"validator"),A(this,"required"),A(this,"content"),A(this,"initialValue"),A(this,"value"),A(this,"data"),A(this,"decorator"),A(this,"component"),A(this,"decoratorProps"),A(this,"componentProps"),A(this,"decoratorType"),A(this,"componentType"),A(this,"path"),A(this,"form"),A(this,"address"),this.props=e,this.initialize()}initialize(){var e,t,o,r,i,n,a,l,c,u,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.13",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.13","@nocobase/sdk":"1.5.13","@nocobase/utils":"1.5.13",ahooks:"^3.7.2",antd:"5.12.8","antd-style":"3.7.1",axios:"^1.7.0","bignumber.js":"^9.1.2",classnames:"^2.3.1",cronstrue:"^2.11.0","file-saver":"^2.0.5",filesize:"9.0.11",flat:"^5.0.2",i18next:"^22.4.9","i18next-http-backend":"^2.1.1",json5:"^2.2.3",lodash:"4.17.21","lru-cache":"6.0.0","markdown-it":"14.1.0","markdown-it-highlightjs":"3.3.1",mathjs:"^10.6.0",mermaid:"9.4.3",mime:"^4.0.4","mime-match":"^1.0.2","react-beautiful-dnd":"^13.1.0","react-drag-listview":"^0.1.9","react-error-boundary":"^4.0.10","react-helmet":"^6.1.0","react-hotkeys-hook":"^3.4.7","react-i18next":"^11.15.1","react-iframe":"~1.8.5","react-image-lightbox":"^5.1.4","react-intersection-observer":"9.14.0","react-js-cron":"^3.1.0","react-quill":"^2.0.0","react-router-dom":"^6.11.2","react-to-print":"^2.14.7","sanitize-html":"2.13.0","use-deep-compare-effect":"^1.8.1"},peerDependencies={react:">=18.0.0","react-dom":">=18.0.0","react-is":">=18.0.0"},devDependencies={"@testing-library/react":"^14.0.0","@types/markdown-it":"14.1.1","@types/markdown-it-highlightjs":"3.3.1","@types/react-big-calendar":"^1.6.4","axios-mock-adapter":"^1.20.0",dumi:"2.2.14","dumi-theme-nocobase":"^0.2.28"},clientPkg={name,version,license,main,module:module$1,types,dependencies,peerDependencies,devDependencies};function createDesignable(e){return new Designable(e)}const generateUid=e=>{e&&(e["x-uid"]||(e["x-uid"]=(0,import_shared.uid)()),Object.keys(e.properties||{}).forEach(t=>{generateUid(e.properties[t])}))},defaultWrap=e=>e,matchSchema=(e,t)=>{if(!(!e||!t)){for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==(e==null?void 0:e[o]))return!1;return!0}},splitWrapSchema=(e,t)=>{if(e["x-uid"]&&e["x-uid"]===t["x-uid"])return[null,e.toJSON()];const o=e.toJSON(),r=P(x({},o),{properties:{}});let i=null;const n=(a,l)=>{Object.keys(a||{}).forEach(c=>{const u=a[c];if(u["x-uid"]===t["x-uid"]){i=a[c];return}else l.properties[c]=P(x({},u),{properties:{}}),n(u==null?void 0:u.properties,l.properties[c])})};return n(o.properties,r),[r,i]},translate=e=>e;class Designable{constructor(t){A(this,"current"),A(this,"options"),A(this,"appVersion"),A(this,"events",{}),this.options=t,this.current=t.current,this.appVersion=t.appVersion}get model(){return this.options.model}get query(){return this.options.query}loadAPIClientEvents(){const{api:t,t:o=translate}=this.options;if(!t)return;const r=i=>{if(!i)return[];const n=Object.values(i.properties).length,a=[];return i.mapProperties(l=>{l["x-component-props"]=l["x-component-props"]||{},l["x-component-props"].width=100/n,l["x-uid"]&&a.push({"x-uid":l["x-uid"],"x-component-props":l["x-component-props"]})}),i["x-uid"]&&a.length?a:[]};this.on("insertAdjacent",i=>q(this,[i],function*({onSuccess:n,current:a,position:l,schema:c,wrap:u,wrapped: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,B=(_=(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:B}),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(),B=(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}`),I=(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]),N=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=N(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)(()=>B.current&&g?(0,import_jsx_runtime.jsx)(g,{search:B.current,callBack:()=>{B.current=null,F(!1)}}):null,[B.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]:{[I]:K}}:{},(J=n==null?void 0:n.params)==null?void 0:J.filter])}),B.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),B.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]===B.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&&B!=null&&B.current)&&K,(O==null?void 0:O.data.length)>0&&(B==null?void 0:B.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,(B,L)=>{var D;B&&(t.values[L]=B,(D=t==null?void 0:t.setInitialValuesIn)==null||D.call(t,L,B))})),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
596
|
.nb-grid-container {
|
|
597
597
|
height: ${u?u+"px":"100%"};
|
|
598
598
|
overflow-y: auto;
|
|
@@ -624,7 +624,7 @@ https://requirejs.org/docs/errors.html#`+e);return i.requireType=e,i.requireModu
|
|
|
624
624
|
display: none;
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
|
-
`,displayBlock={display:"block"},displayNone$1={display:"none"},TabPane=import_react2.default.memo(({schema:e,active:t})=>{const o=(0,import_react2.useRef)(!1),{active:r}=useKeepAlive();t&&!o.current&&(o.current=!0);const i=(0,import_react2.useMemo)(()=>new import_react.Schema({properties:{[e.name]:e}}),[e]);return o.current?(0,import_jsx_runtime.jsx)("div",{style:t?displayBlock:displayNone$1,children:(0,import_jsx_runtime.jsx)(KeepAliveProvider,{active:r&&t,children:(0,import_jsx_runtime.jsx)(SchemaComponent,{distributed:!0,schema:i})})}):null}),InternalPageContent=e=>{const{loading:t,disablePageHeader:o,enablePageTabs:r,fieldSchema:i,activeKey:n}=e;return!o&&r?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:i.mapProperties(a=>(0,import_jsx_runtime.jsx)(TabPane,{schema:a,active:a.name===n},a.name))}):(0,import_jsx_runtime.jsx)("div",{className:className1$1,children:(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:i,distributed:!0})})},PageContent=(0,import_react2.memo)(e=>(0,import_jsx_runtime.jsx)(PopupRouteContextResetter,{children:(0,import_jsx_runtime.jsx)(InternalPageContent,x({},e))})),NocoBasePageHeaderTabs=({className:e,activeKey:t})=>{var o;const r=(0,import_react.useFieldSchema)(),{t:i}=(0,import_react_i18next.useTranslation)(),{token:n}=useToken(),a=useRouterBasename(),l=useNavigateNoUpdate(),c=(0,import_react2.useCallback)(v=>{navigateToTab({activeKey:v,navigate:l,basename:a})},[a,l]),u=useDesignable(),{getAriaLabel:d}=useGetAriaLabelOfSchemaInitializer(),m=(0,import_react2.useContext)(import_react.SchemaOptionsContext),{theme:p}=useGlobalTheme(),g=(0,import_react2.useMemo)(()=>u.designable&&(0,import_jsx_runtime.jsx)(import_antd.Button,{"aria-label":d("tabs"),icon:(0,import_jsx_runtime.jsx)(import_icons.PlusOutlined,{}),className:"addTabBtn",type:"dashed",onClick:()=>q(void 0,null,function*(){const v=yield FormDialog(i("Add tab"),()=>(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{scope:m.scope,components:x({},m.components),children:(0,import_jsx_runtime.jsx)(import_antd_v5.FormLayout,{layout:"vertical",children:(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:{properties:{title:{title:i("Tab name"),"x-component":"Input","x-decorator":"FormItem",required:!0},icon:{title:i("Icon"),"x-component":"IconPicker","x-decorator":"FormItem"}}}})})}),p).open({initialValues:{}}),{title:C,icon:S}=v;u.insertBeforeEnd({type:"void",title:C,"x-icon":S,"x-component":"Grid","x-initializer":"page:addBlock",properties:{}})}),children:i("Add tab")}),[u,d,m==null?void 0:m.components,m==null?void 0:m.scope,i,p]),h=(o=r["x-component-props"])==null?void 0:o.enablePageTabs,f=(0,import_react2.useMemo)(()=>({paddingLeft:n.paddingLG-n.paddingPageHorizontal,paddingRight:n.paddingLG-n.paddingPageHorizontal,marginLeft:n.paddingPageHorizontal-n.paddingLG,marginRight:n.paddingPageHorizontal-n.paddingLG}),[n.paddingLG,n.paddingPageHorizontal]),_=(0,import_react2.useMemo)(()=>r.mapProperties(v=>({label:(0,import_jsx_runtime.jsxs)(SortableItem,{id:v.name,schema:v,className:(0,import_classnames.default)("nb-action-link","designerCss",e),children:[v["x-icon"]&&(0,import_jsx_runtime.jsx)(Icon,{style:{marginRight:8},type:v["x-icon"]}),(0,import_jsx_runtime.jsx)("span",{children:v.title||i("Unnamed")}),(0,import_jsx_runtime.jsx)(PageTabDesigner,{schema:v})]}),key:v.name})),[r,e,i,r.mapProperties(v=>v.title||i("Unnamed")).join()]);return h?(0,import_jsx_runtime.jsx)(DndContext,{children:(0,import_jsx_runtime.jsx)(import_antd.Tabs,{size:"small",activeKey:t,tabBarStyle:f,onChange:c,tabBarExtraContent:g,items:_})}):null},NocoBasePageHeader=import_react2.default.memo(({activeKey:e,className:t})=>{var o,r,i;const n=(0,import_react.useFieldSchema)(),{setTitle:a}=useDocumentTitle(),{t:l}=(0,import_react_i18next.useTranslation)(),[c,u]=(0,import_react2.useState)(()=>l(n.title)),d=(o=n["x-component-props"])==null?void 0:o.disablePageHeader,m=(r=n["x-component-props"])==null?void 0:r.enablePageTabs,p=(i=n["x-component-props"])==null?void 0:i.hidePageTitle;return(0,import_react2.useEffect)(()=>{if(n.title){const g=l(n.title);a(g),u(g)}},[n.title,c,a,l]),useRequest({url:`/uiSchemas:getParentJsonSchema/${n["x-uid"]}`},{ready:!p&&!n.title,onSuccess(g){u(g.data.title),a(g.data.title)}}),(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)(PageDesigner,{title:c}),!d&&(0,import_jsx_runtime.jsx)(import_pro_layout.PageHeader,{className:(0,import_classnames.default)("pageHeaderCss",c||m?"":"height0"),ghost:!1,title:p?" ":c||" ",footer:(0,import_jsx_runtime.jsx)(NocoBasePageHeaderTabs,{className:t,activeKey:e})})]})});NocoBasePageHeader.displayName="NocoBasePageHeader";function navigateToTab({activeKey:e,navigate:t,basename:o,pathname:r=window.location.pathname}){r=r.replace(o,""),r.endsWith("/")&&(r=r.slice(0,-1)),r.startsWith("/")||(r=`/${r}`),isTabPage(r)?t(withSearchParams(`${r.replace(/\/tabs\/[^/]+$/,`/tabs/${e}`)}`),{replace:!0}):t(withSearchParams(`${r}/tabs/${e}`),{replace:!0})}function isTabPage(e){e.endsWith("/")&&(e=e.slice(0,-1));const t=e.split("/");return t[t.length-2]==="tabs"}function useNotDisableHeader(){var e;return!((e=(0,import_react.useFieldSchema)()["x-component-props"])!=null&&e.disablePageHeader)}const pageSettings=new SchemaSettings({name:"PageSettings",items:[{name:"enablePageHeader",type:"switch",useComponentProps(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)();return{title:o("Enable page header"),checked:!((e=r["x-component-props"])!=null&&e.disablePageHeader),onChange(i){r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].disablePageHeader=!i,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":r["x-component-props"]}}),t.refresh()}}}},{name:"divider",type:"divider",useVisible:useNotDisableHeader},{name:"displayPageTitle",type:"switch",useVisible:useNotDisableHeader,useComponentProps(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)();return{title:o("Display page title"),checked:!((e=r["x-component-props"])!=null&&e.hidePageTitle),onChange(i){r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].hidePageTitle=!i,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":r["x-component-props"]}}),t.refresh()}}}},{name:"editPageTitle",type:"modal",useVisible(){var e;const t=useNotDisableHeader(),o=!((e=(0,import_react.useFieldSchema)()["x-component-props"])!=null&&e.hidePageTitle);return t&&o},useComponentProps(){const{dn:e}=useDesignable(),{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{title:i}=useSchemaToolbar();return{hide:!0,title:t("Edit page title"),schema:{type:"object",title:t("Edit page title"),properties:{title:{title:t("Title"),required:!0,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},initialValues:{title:i},onSubmit({title:n}){o.title=n,r.title=n,e.emit("patch",{schema:{"x-uid":r["x-uid"],title:n}})}}}},{name:"enablePageTabs",type:"switch",useVisible:useNotDisableHeader,useComponentProps(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)();return{title:o("Enable page tabs"),checked:(e=r["x-component-props"])==null?void 0:e.enablePageTabs,onChange(i){r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].enablePageTabs=i,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":r["x-component-props"]}}),t.refresh()}}}}]}),pageTabSettings=new SchemaSettings({name:"PageTabSettings",items:[{name:"edit",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),{schema:t}=useSchemaToolbar(),{dn:o}=useDesignable();return{title:e("Edit"),schema:{type:"object",title:e("Edit tab"),properties:{title:{title:e("Tab name"),required:!0,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}},icon:{title:e("Icon"),"x-decorator":"FormItem","x-component":"IconPicker","x-component-props":{}}}},initialValues:{title:t.title,icon:t["x-icon"]},onSubmit:({title:r,icon:i})=>{t.title=r,t["x-icon"]=i,o.emit("patch",{schema:{"x-uid":t["x-uid"],title:r,"x-icon":i}}),o.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"item",useComponentProps(){const{modal:e}=import_antd.App.useApp(),{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),{schema:r}=useSchemaToolbar();return{title:o("Delete"),eventKey:"remove",onClick(){e.confirm(P(x({title:o("Delete block"),content:o("Are you sure you want to delete it?")},confirm),{onOk(){t.remove(r)}}))},children:o("Delete")}}}]}),AntdSchemaComponentProvider=e=>{const{children:t}=e;return(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{scope:{requestChartData,useFilterActionProps:useFilterActionProps$1},components:x(x({},components$2),common),children:t})};class AntdSchemaComponentPlugin extends Plugin{load(){return q(this,null,function*(){this.addComponents(),this.addScopes(),this.addSchemaSettings()})}addComponents(){this.app.addComponents(x(x({},components$2),common))}addScopes(){this.app.addScopes({requestChartData,useFilterActionProps:useFilterActionProps$1})}addSchemaSettings(){this.app.schemaSettingsManager.add(pageSettings),this.app.schemaSettingsManager.add(pageTabSettings),this.app.schemaSettingsManager.add(formItemSettings),this.app.schemaSettingsManager.add(filterFormItemSettings),this.app.schemaSettingsManager.add(formV1Settings),this.app.schemaSettingsManager.add(formSettings),this.app.schemaSettingsManager.add(readPrettyFormSettings),this.app.schemaSettingsManager.add(formDetailsSettings),this.app.schemaSettingsManager.add(actionSettings)}}function usePropsCollection({collection:e}){return e}function loadChildren(e){const t=getCollectionFieldOptions.call(this,e.field.target,e);return t.length&&t.some(o=>isAssociation(o.field))||(e.isLeaf=!0),t}function isAssociation(e){return e.target&&e.interface}function trueFilter(e){return!0}function getCollectionFieldOptions(e,t){const o=this.getCollectionFields(e).filter(isAssociation),r=loadChildren.bind(this);return o.filter(this.filter).map(i=>{var n,a,l;const c=t?`${t.value?`${t.value}.`:""}${i.name}`:i.name,u=(a=this.compile((n=i.uiSchema)==null?void 0:n.title))!=null?a:i.name,d=!this.getCollectionFields(i.target).filter(isAssociation).filter(this.filter).length;return{pId:(l=t==null?void 0:t.key)!=null?l:null,id:c,key:c,value:c,title:u,isLeaf:d,loadChildren:d?null:r,field:i,fullTitle:t?[...t.fullTitle,u]:[u]}})}const AppendsTreeSelect=e=>{const t=e,{title:o,value:r,onChange:i,collection:n,useCollection:a=usePropsCollection,filter:l=trueFilter,rootOption:c,loadData:u}=t,d=W(t,["title","value","onChange","collection","useCollection","filter","rootOption","loadData"]),m=useCompile(),{t:p}=(0,import_react_i18next.useTranslation)(),[g,h]=(0,import_react2.useState)({}),f=a({collection:n}),[_,v]=parseCollectionName(f),C=useApp(),{collectionManager:S}=C.dataSourceManager.getDataSource(_),b=(L,D)=>{const T=S.getCollection(L);return T?T.getAllFields(D):[]},y=Object.values(g),F=(0,import_react2.useMemo)(()=>e.multiple?(r||[]).map(L=>g[L]).filter(Boolean):r,[r,e.multiple,g]),j=(0,import_react2.useCallback)(L=>q(void 0,null,function*(){if(u!=null)return u(L);if(!L.isLeaf&&L.loadChildren){const D=L.loadChildren(L);h(T=>D.reduce(($,w)=>Object.assign($,{[w.value]:w}),x({},T)))}}),[u]);(0,import_react2.useEffect)(()=>{const L=c?P(x({},c),{id:c.value,key:c.value,title:c.label,fullTitle:c.label,isLeaf:!1}):null,D=(u===null?[]:getCollectionFieldOptions.call({compile:m,getCollectionFields:b,filter:l},v,L)).reduce((T,$)=>Object.assign(T,{[$.value]:$}),{});L&&(D[L.value]=L),h(D)},[f,c,l,u]),(0,import_react2.useEffect)(()=>{const L=e.multiple?r:r?[r]:[];if(!(L!=null&&L.length)||L.every(T=>!!g[T]))return;const D=[];L.forEach(T=>{const $=T.split(".");let w=g[$[0]];for(let I=1;I<$.length&&w;I++){const N=$.slice(0,I+1).join(".");if(g[N]){w=g[N];break}if(!w.isLeaf&&w.loadChildren){const M=w.loadChildren(w);M!=null&&M.length&&(D.push(...M),w=M.find(O=>O.value===$.slice(0,I+1).join(".")))}}}),h(T=>D.reduce(($,w)=>Object.assign($,{[w.value]:w}),x({},T)))},[r,y.length,e.multiple]);const k=(0,import_react2.useCallback)(L=>{if(!e.multiple){i(L);return}const D=L.map(w=>w.value).filter(Boolean),T=new Set(D),$=F.find(w=>!T.has(w.value));if($){const w=`${$.value}.`;Object.keys(g).forEach(I=>{I.startsWith(w)&&T.delete(I)})}else D.forEach(w=>{const I=w.split(".");if(I.length)for(let N=1;N<=I.length;N++)T.add(I.slice(0,N).join("."))});i(Array.from(T))},[e.multiple,F,i,g]),R=(0,import_react2.useCallback)(L=>{var D;const{value:T,onClose:$,disabled:w,closable:I}=L;if(!T)return null;const{fullTitle:N}=(D=g[T])!=null?D:{};return(0,import_jsx_runtime.jsx)(import_antd.Tag,{closable:I&&!w,onClose:$,children:N==null?void 0:N.join(" / ")})},[g]),z=Array.isArray(F)?F.filter(L=>L.value in g):F,B=e.multiple?r:r!=null?[r]:[];return(0,import_jsx_runtime.jsx)(import_antd.TreeSelect,x({role:"button","data-testid":`select-field${o?`-${o}`:""}`,value:z,placeholder:p("Select field"),showCheckedStrategy:import_antd.TreeSelect.SHOW_ALL,treeDefaultExpandedKeys:B,allowClear:{clearIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseCircleFilled,{role:"button","aria-label":"icon-close"})},treeCheckStrictly:e.multiple,treeCheckable:e.multiple,tagRender:R,onChange:k,treeDataSimpleMode:!0,treeData:y,loadData:j},d))},AssociationFieldAddNewer=e=>{const t=(0,import_react2.useContext)(SchemaComponentContext);return(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:P(x({},t),{draggable:!0}),children:(0,import_jsx_runtime.jsx)(Action.Container,x({},e))})},filterAnalyses=e=>{if(!e)return;const t=Object.keys(e)[0]||"$and",o=e[t],r=[];return o==null||o.map(i=>{var n,a,l;const c=getInnermostKeyAndValue(i);if(!(c!=null&&c.key))return!0;const u=/\{\{\$[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*\.(\w+)\.id\}\}/,d=(l=(a=(n=c==null?void 0:c.value)==null?void 0:n.match)==null?void 0:a.call(n,u))==null?void 0:l[1];d&&r.push(d)}),r},InternalAssociationSelect$1=(0,import_react.observer)(e=>{var t;const o=e,{objectValue:r=!0,addMode:i}=o,n=W(o,["objectValue","addMode"]),a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)(),c=useServiceOptions$1((l==null?void 0:l["x-component-props"])||e),{options:u}=useAssociationFieldContext(),d=isVariable(e.value)?void 0:e.value,m=Array.isArray(d)?d.filter(Boolean):d,[p,g]=(0,import_react2.useState)(m),h=(t=l["x-component-props"])==null?void 0:t.addMode,{t:f}=(0,import_react_i18next.useTranslation)(),{multiple:_}=e,v=(0,import_react.useForm)(),C=useAPIClient().resource(u.target),S=useCollectionRecordData(),b=(0,import_react2.useContext)(SchemaComponentContext);(0,import_react2.useEffect)(()=>{const j=isVariable(a.value)?void 0:a.value,k=Array.isArray(j)?j.filter(Boolean):j;g(k)},[a.value]),(0,import_react2.useEffect)(()=>{const j=(0,import_shared.uid)();return v.addEffects(j,()=>{(0,import_core2.onFieldInputValueChange)("*",k=>{var R,z,B,L,D;(filterAnalyses((B=(z=(R=a.componentProps)==null?void 0:R.service)==null?void 0:z.params)==null?void 0:B.filter)||[]).includes((L=k==null?void 0:k.props)==null?void 0:L.name)&&a.value&&(0,import_lodash.isEqual)(k==null?void 0:k.indexes,a==null?void 0:a.indexes)&&((D=k==null?void 0:k.props)==null?void 0:D.name)!==a.props.name&&(a.setValue(null),g(null))})}),()=>{v.removeEffects(j)}},[]);const y=j=>q(void 0,null,function*(){var k,R;const{search:z,callBack:B}=j,{data:{data:L}}=yield C.create({values:{[((R=(k=a==null?void 0:a.componentProps)==null?void 0:k.fieldNames)==null?void 0:R.label)||"id"]:z}});if(L){if(["m2m","o2m"].includes(u==null?void 0:u.interface)&&_!==!1){const D=v.getValuesIn(a.path)||[];D.push(L),v.setValuesIn(a.path,D),a.onInput(D)}else v.setValuesIn(a.path,L),a.onInput(L);(0,import_mathjs.isFunction)(B)&&(B==null||B()),import_antd.message.success(f("Saved successfully"))}}),F=j=>(0,import_jsx_runtime.jsxs)("div",{onClick:()=>y(j),style:{cursor:"pointer",padding:"5px 12px",color:"#0d0c0c"},children:[(0,import_jsx_runtime.jsx)(import_icons.PlusOutlined,{}),(0,import_jsx_runtime.jsx)("span",{style:{paddingLeft:5},children:f("Add")+` “${j.search}” `})]});return console.log(l),(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsxs)(import_antd.Space.Compact,{style:{display:"flex"},children:[(0,import_jsx_runtime.jsx)(RemoteSelect,P(x({style:{width:"100%"}},n),{size:"middle",objectValue:r,value:m||p,service:c,onChange:j=>{var k;const R=(j==null?void 0:j.length)!==0?j:null;(k=e.onChange)==null||k.call(e,R)},CustomDropdownRender:h==="quickAdd"&&F})),h==="modalAdd"&&(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:P(x({},b),{draggable:!1}),children:(0,import_jsx_runtime.jsx)(RecordProvider,{isNew:!0,record:null,parent:S,children:(0,import_jsx_runtime.jsx)(VariablePopupRecordProvider,{children:(0,import_jsx_runtime.jsx)(ClearCollectionFieldContext,{children:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{onlyRenderProperties:!0,basePath:a.address,schema:l,filterProperties:j=>j["x-component"]==="Action"})})})})})]})},l.name)},{displayName:"AssociationSelect"}),AssociationSelect$1=InternalAssociationSelect$1;(0,import_react.connect)(e=>{const t=useServiceOptions$1(e);return e.fieldNames?(0,import_jsx_runtime.jsx)(RemoteSelect.ReadPretty,P(x({},e),{service:t})):null},(0,import_react.mapProps)({dataSource:"options",loading:!0},(e,t)=>P(x({},e),{fieldNames:e.fieldNames&&x(x({},e.fieldNames),t.componentProps.fieldNames),suffixIcon:t!=null&&t.loading||t!=null&&t.validating?(0,import_jsx_runtime.jsx)(import_icons.LoadingOutlined,{}):e.suffixIcon})));const publicPath=window.__nocobase_dev_public_path__||window.__nocobase_public_path__||"/",UPLOAD_PLACEHOLDER=[{ext:/\.docx?$/i,icon:"/file-placeholder/docx-200-200.png"},{ext:/\.pptx?$/i,icon:"/file-placeholder/pptx-200-200.png"},{ext:/\.jpe?g$/i,icon:"/file-placeholder/jpeg-200-200.png"},{ext:/\.pdf$/i,icon:"/file-placeholder/pdf-200-200.png"},{ext:/\.png$/i,icon:"/file-placeholder/png-200-200.png"},{ext:/\.eps$/i,icon:"/file-placeholder/eps-200-200.png"},{ext:/\.ai$/i,icon:"/file-placeholder/ai-200-200.png"},{ext:/\.gif$/i,icon:"/file-placeholder/gif-200-200.png"},{ext:/\.svg$/i,icon:"/file-placeholder/svg-200-200.png"},{ext:/\.xlsx?$/i,icon:"/file-placeholder/xlsx-200-200.png"},{ext:/\.psd?$/i,icon:"/file-placeholder/psd-200-200.png"},{ext:/\.(wav|aif|aiff|au|mp1|mp2|mp3|ra|rm|ram|mid|rmi)$/i,icon:"/file-placeholder/audio-200-200.png"},{ext:/\.(avi|wmv|mpg|mpeg|vob|dat|3gp|mp4|mkv|rm|rmvb|mov|flv)$/i,icon:"/file-placeholder/video-200-200.png"},{ext:/\.(zip|rar|arj|z|gz|iso|jar|ace|tar|uue|dmg|pkg|lzh|cab)$/i,icon:"/file-placeholder/zip-200-200.png"}].map(e=>({ext:e.ext,icon:publicPath+e.icon.slice(1)})),UNKNOWN_FILE_ICON=publicPath+"file-placeholder/unknown-200-200.png",FILE_SIZE_LIMIT_DEFAULT=1024*1024*20;class AttachmentFileTypes{constructor(){A(this,"types",[])}add(t){this.types.unshift(t)}getTypeByFile(t){return this.types.find(o=>o.match(t))}}const attachmentFileTypes=new AttachmentFileTypes;function matchMimetype(e,t){if(!e)return!1;if(e.originFileObj)return(0,import_mime_match.default)(e.type,t);if(e.mimetype)return(0,import_mime_match.default)(e.mimetype,t);if(e.url){const[o]=e.url.split("?");return(0,import_mime_match.default)(import_mime.default.getType(o)||"",t)}return!1}const toArr$1=e=>(0,import_shared.isValid)(e)?Object.keys(e).length===0?[]:(0,import_shared.toArr)(e):[],testOpts=(e,t)=>t&&(0,import_shared.isArr)(t.include)?t.include.some(o=>e.test(o)):t&&(0,import_shared.isArr)(t.exclude)?!t.exclude.some(o=>e.test(o)):!0;function getThumbnailPlaceholderURL(e,t={}){for(let o=0;o<UPLOAD_PLACEHOLDER.length;o++)if(UPLOAD_PLACEHOLDER[o].ext.test(e.extname||e.filename||e.url||e.name))return testOpts(UPLOAD_PLACEHOLDER[o].ext,t)?UPLOAD_PLACEHOLDER[o].icon||UNKNOWN_FILE_ICON:e.name;return UNKNOWN_FILE_ICON}function getResponseMessage({error:e,response:t}){var o,r,i,n;if(e instanceof Error&&"isAxiosError"in e)return e.response?(i=(r=(o=e.response.data)==null?void 0:o.errors)==null?void 0:r.map)==null?void 0:i.call(r,l=>l==null?void 0:l.message).join(", "):e.message;if(!t)return"";if(typeof t=="string")return t;const{errors:a}=(n=t.data)!=null?n:{};return a!=null&&a.length?a.map(l=>l==null?void 0:l.message).join(", "):""}function normalizeFile(e){const t=getResponseMessage(e);return P(x({},e),{title:e.name,response:t})}function useUploadProps(e){const t=useAPIClient();return x({customRequest({action:o,data:r,file:i,filename:n,headers:a,onError:l,onProgress:c,onSuccess:u,withCredentials:d}){const m=new FormData;return r&&Object.keys(r).forEach(p=>{m.append(p,r[p])}),m.append(n,i),t.axios.post(o,m,{withCredentials:d,headers:a,onUploadProgress:({total:p,loaded:g})=>{c({percent:Math.round(g/p*100).toFixed(2)},i)}}).then(({data:p})=>{u(p,i)}).catch(l).finally(()=>{}),{abort(){console.log("upload progress is aborted.")}}}},e)}function toValueItem(e){return e}const toItem=e=>{var t;return typeof e=="string"?{url:e}:((t=e==null?void 0:e.response)!=null&&t.data&&(e=x({uid:e.uid},e.response.data)),P(x({},e),{id:e.id||e.uid,title:e.title||e.name}))},toFileList=e=>toArr$1(e).filter(Boolean).map(toItem),Rules={size(e,t){const o=t??FILE_SIZE_LIMIT_DEFAULT;return o===0||e.size<=o?null:"File size exceeds the limit"},mimetype(e,t="*"){const o=t.toString().trim();return!o||o==="*"||o.split(",").filter(Boolean).some((0,import_mime_match.default)(e.type))?null:"File type is not allowed"}};function validate(e,t){if(!t)return null;const o=Object.keys(t);if(!o.length)return null;for(const r of o){const i=Rules[r](e,t[r]);if(i)return i}return null}function useBeforeUpload(e){const{t}=(0,import_react_i18next.useTranslation)();return(0,import_react2.useCallback)(o=>{const r=validate(o,e);return r?(o.status="error",o.response=t(r)):o.status==="error"&&(delete o.status,delete o.response),!r},[e])}const useStyles$8=genStyleHook("upload",e=>{const{componentCls:t,antCls:o}=e;return{[`${t}-wrapper`]:{"&.nb-upload.nb-upload-small":{[`${t}-list-picture-card-container`]:{margin:"0 3px 3px 0 !important",height:"32px !important",width:"32px !important",marginBlock:"0 !important"},[`${t}-list-picture-card ${t}-list-item-name${t}-list-item-name`]:{display:"none !important"},[`${t}-list-picture ${t}-list-item, ${t}-list-picture-card ${t}-list-item`]:{borderRadius:"4px",padding:"1px !important",[`${t}-list-item-image`]:{borderRadius:"2px"}}},"&.nb-upload-large":{[`${t}-list-picture-card-container`]:{margin:"0 3px 3px 0 !important",height:"160px !important",width:"160px !important",marginBlock:"0 28px !important"}},"&.nb-upload":{[`${t}-list-item, ${t}-list-item-list-type-picture-card`]:{padding:"3px !important"},[`${t}-list-item-thumbnail`]:{img:{objectFit:"cover !important"}},[`${t}-list-item-actions`]:{left:"auto !important",right:"2px !important",top:"2px !important",transform:"none !important",width:"fit-content !important",[`${o}-btn-text:hover, ${o}-btn-text:focus`]:{background:"rgba(0, 0, 0, 0.4)"}},[`${t}-list-picture-card ${t}-list-item-info`]:{overflow:"inherit",width:"100%",height:"100%"},[`${t}-list-picture-card ${t}-list-item-name`]:{display:"block !important",marginTop:"10px",fontSize:"13px",color:"#636363"},[`${t}-list-picture-card ${t}-list-item::before`]:{display:"none !important"},[`${t}-list-picture-card ${t}-list-item-progress`]:{bottom:"calc(50% - 11px)",left:`${e.margin/2}px`,pointerEvents:"none"},[`${o}-btn`]:{background:"rgba(0, 0, 0, 0.5)"},[`${t}-list-picture-card-container`]:{marginBlock:"0 28px !important"}},[`${t}-list-item-error`]:{[`${t}-list-item-info img`]:{opacity:.6}},[`${t}-drag`]:{[`${t}-drag-container`]:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",height:"100%",ul:{color:e.colorTextSecondary,[`${t}-hint`]:{textAlign:"left"}}}}}}}),useUploadStyles=useStyles$8;attachmentFileTypes.add({match(e){return matchMimetype(e,"image/*")},getThumbnailURL(e){return e.url?`${e.url}${e.thumbnailRule||""}`:e.originFileObj?URL.createObjectURL(e.originFileObj):null},Previewer({index:e,list:t,onSwitchIndex:o}){var r,i,n,a;const l=(0,import_react2.useCallback)(c=>{c.preventDefault();const u=t[e];(0,import_file_saver.saveAs)(u.url,`${u.title}${u.extname}`)},[e,t]);return(0,import_jsx_runtime.jsx)(import_react_image_lightbox.default,{mainSrc:(r=t[e])==null?void 0:r.url,nextSrc:(i=t[(e+1)%t.length])==null?void 0:i.url,prevSrc:(n=t[(e+t.length-1)%t.length])==null?void 0:n.url,onCloseRequest:()=>o(null),onMovePrevRequest:()=>o((e+t.length-1)%t.length),onMoveNextRequest:()=>o((e+1)%t.length),imageTitle:(a=t[e])==null?void 0:a.title,toolbarButtons:[(0,import_jsx_runtime.jsx)("button",{style:{fontSize:22,background:"none",lineHeight:1},type:"button","aria-label":"Download",title:"Download",className:"ril-zoom-in ril__toolbarItemChild ril__builtinButton",onClick:l,children:(0,import_jsx_runtime.jsx)(import_icons.DownloadOutlined,{})},"preview-img")]})}});const iframePreviewSupportedTypes=["application/pdf","audio/*","image/*","video/*"];function IframePreviewer({index:e,list:t,onSwitchIndex:o}){const{t:r}=(0,import_react_i18next.useTranslation)(),i=t[e],n=(0,import_react2.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),window.open(i.url)},[i]),a=(0,import_react2.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),(0,import_file_saver.saveAs)(i.url,`${i.title}${i.extname}`)},[i]),l=(0,import_react2.useCallback)(()=>{o(null)},[o]);return(0,import_jsx_runtime.jsx)(import_antd.Modal,{open:e!=null,title:i.title,onCancel:l,footer:[(0,import_jsx_runtime.jsx)(import_antd.Button,{onClick:n,children:r("Open in new window")},"open"),(0,import_jsx_runtime.jsx)(import_antd.Button,{onClick:a,children:r("Download")},"download"),(0,import_jsx_runtime.jsx)(import_antd.Button,{onClick:l,children:r("Close")},"close")],width:"85vw",centered:!0,children:(0,import_jsx_runtime.jsx)("div",{style:{maxWidth:"100%",maxHeight:"calc(100vh - 256px)",height:"90vh",width:"100%",background:"white",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflowY:"auto"},children:iframePreviewSupportedTypes.some(c=>matchMimetype(i,c))?(0,import_jsx_runtime.jsx)("iframe",{src:i.url,style:{width:"100%",maxHeight:"90vh",flex:"1 1 auto",border:"none"}}):(0,import_jsx_runtime.jsx)(import_antd.Alert,{type:"warning",description:r("File type is not supported for previewing, please download it to preview."),showIcon:!0})})})}function InternalUpload(e){const t=e,{onChange:o}=t,r=W(t,["onChange"]),i=(0,import_react2.useCallback)(n=>{o==null||o(toFileList(n.fileList))},[o]);return(0,import_jsx_runtime.jsx)(import_antd.Upload,P(x({},useUploadProps(r)),{onChange:i}))}function ReadPretty$9({value:e,onChange:t,disabled:o,multiple:r,size:i}){const{wrapSSR:n,hashId:a,componentCls:l}=useStyles$8();return(import_style2.default.default?import_style2.default.default:import_style2.default)(l),n((0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${l}-wrapper`,`${l}-picture-card-wrapper`,"nb-upload",i?`nb-upload-${i}`:null,a),children:(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${l}-list`,`${l}-list-picture-card`),children:(0,import_jsx_runtime.jsx)(AttachmentList,{disabled:o,readPretty:!0,multiple:r,value:e,onChange:t})})}))}const Upload=(0,import_react.connect)(InternalUpload,(0,import_react.mapProps)({value:"fileList"}),(0,import_react.mapReadPretty)(ReadPretty$9));Upload.ReadPretty=ReadPretty$9;function useSizeHint(e){const t=e??FILE_SIZE_LIMIT_DEFAULT,{t:o,i18n:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_filesize.default)(t,{base:2,standard:"jedec",locale:r.language});return t!==0?o("File size should not exceed {{size}}.",{size:i}):""}function DefaultThumbnailPreviewer({file:e}){var t;const{componentCls:o}=useStyles$8(),{getThumbnailURL:r=getThumbnailPlaceholderURL}=(t=attachmentFileTypes.getTypeByFile(e))!=null?t:{},i=r(e);return(0,import_jsx_runtime.jsx)("img",{src:i,alt:e.title,className:`${o}-list-item-image`})}function AttachmentListItem(e){var t,o;const{file:r,disabled:i,onPreview:n,onDelete:a,readPretty:l}=e,{componentCls:c}=useStyles$8(),{t:u}=(0,import_react_i18next.useTranslation)(),d=(0,import_react2.useCallback)(v=>{v.preventDefault(),v.stopPropagation(),n==null||n(r)},[r,n]),m=(0,import_react2.useCallback)(()=>{a==null||a(r)},[r,a]),p=(0,import_react2.useCallback)(()=>{(0,import_file_saver.saveAs)(r.url,`${r.title}${r.extname}`)},[r]),{ThumbnailPreviewer:g=DefaultThumbnailPreviewer}=(t=attachmentFileTypes.getTypeByFile(r))!=null?t:{},h=[(0,import_jsx_runtime.jsx)("span",{className:`${c}-list-item-thumbnail`,children:(0,import_jsx_runtime.jsx)(g,{file:r})},"thumbnail"),(0,import_jsx_runtime.jsx)("span",{className:`${c}-list-item-name`,title:r.title,children:r.status==="uploading"?u("Uploading"):r.title},"title")],f=r.url?(0,import_jsx_runtime.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:r.url,onClick:d,children:h}):(0,import_jsx_runtime.jsx)("span",{className:`${c}-span`,children:h}),_=(0,import_jsx_runtime.jsxs)("div",{className:(0,import_classnames.default)(`${c}-list-item`,`${c}-list-item-${(o=r.status)!=null?o:"done"}`,`${c}-list-item-list-type-picture-card`),children:[(0,import_jsx_runtime.jsx)("div",{className:`${c}-list-item-info`,children:f}),(0,import_jsx_runtime.jsx)("span",{className:`${c}-list-item-actions`,children:(0,import_jsx_runtime.jsxs)(import_antd.Space,{size:3,children:[!l&&r.url&&(0,import_jsx_runtime.jsx)(import_antd.Button,{size:"small",type:"text",icon:(0,import_jsx_runtime.jsx)(import_icons.DownloadOutlined,{}),onClick:p}),!l&&!i&&r.status!=="uploading"&&(0,import_jsx_runtime.jsx)(import_antd.Button,{size:"small",type:"text",icon:(0,import_jsx_runtime.jsx)(import_icons.DeleteOutlined,{}),onClick:m})]})}),r.status==="uploading"&&(0,import_jsx_runtime.jsx)("div",{className:`${c}-list-item-progress`,children:(0,import_jsx_runtime.jsx)(import_antd.Progress,{strokeWidth:4,type:"line",showInfo:!1,percent:Number(r.percent)})})]});return(0,import_jsx_runtime.jsx)("div",{className:`${c}-list-picture-card-container ${c}-list-item-container`,children:r.status==="error"?(0,import_jsx_runtime.jsx)(import_antd.Tooltip,{title:r.response,getPopupContainer:v=>v.parentNode,children:_}):_})}function Previewer({index:e,onSwitchIndex:t,list:o}){var r;if(e==null)return null;const i=o[e],{Previewer:n=IframePreviewer}=(r=attachmentFileTypes.getTypeByFile(i))!=null?r:{};return(0,import_jsx_runtime.jsx)(n,{index:e,list:o,onSwitchIndex:t})}function AttachmentList(e){const{disabled:t,multiple:o,value:r,onChange:i,readPretty:n}=e,[a,l]=(0,import_react2.useState)([]),[c,u]=(0,import_react2.useState)(null);(0,import_react2.useEffect)(()=>{const p=toFileList(r);l(p)},[r]);const d=(0,import_react2.useCallback)(p=>{const g=a.findIndex(h=>h.id===p.id);u(g)},[a]),m=(0,import_react2.useCallback)(p=>{i(o?r.filter(g=>g.id!==p.id):null)},[o,i,r]);return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[a.map((p,g)=>(0,import_jsx_runtime.jsx)(AttachmentListItem,{file:p,index:g,disabled:t,onPreview:d,onDelete:m,readPretty:n},p.id||p.url)),(0,import_jsx_runtime.jsx)(Previewer,{index:c,onSwitchIndex:u,list:a})]})}function Uploader(e){var t=e,{rules:o}=t,r=W(t,["rules"]);const{disabled:i,multiple:n,value:a,onChange:l,toValueItem:c=toValueItem}=r,[u,d]=(0,import_react2.useState)([]),[m,p]=(0,import_react2.useState)([]),{t:g}=(0,import_react_i18next.useTranslation)(),{componentCls:h}=useStyles$8(),f=(0,import_react.useField)(),_=useUploadProps(r),v=useBeforeUpload(o);(0,import_react2.useEffect)(()=>{m.length?f.setFeedback({type:"error",code:"ValidateError",messages:[g("Incomplete uploading files need to be resolved")]}):f.setFeedback({})},[f,m]);const C=(0,import_react2.useCallback)(z=>{var B;const L=z.fileList.filter(D=>D.status!=="done").map(normalizeFile);if(p(L),n){const D=z.fileList.filter(T=>T.status==="done");if(D.length){const T=[...u,...D.map($=>{var w;return c((w=$.response)==null?void 0:w.data)})];L.length?d(T):(d([]),l==null||l(T))}}else{const D=z.fileList.find(T=>T.uid===z.file.uid);D.status==="done"&&(l==null||l(c((B=D.response)==null?void 0:B.data)),p([]))}},[n,u,c,l]),S=(0,import_react2.useCallback)(z=>{p(B=>{const L=B.indexOf(z);return B.splice(L,1),[...B]})},[]),b=(0,import_react2.useCallback)(z=>{d(B=>{const L=B.indexOf(z);return B.splice(L,1),[...B]})},[]),y=useComponent("QRCodeUploader"),{mimetype:F,size:j}=o??{},k=useSizeHint(j),R=!i&&(n||(!a||Array.isArray(a)&&!a.length)&&!m.length);return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[u.map((z,B)=>(0,import_jsx_runtime.jsx)(AttachmentListItem,{file:z,index:B,disabled:i,onDelete:b},z.id)),m.map((z,B)=>(0,import_jsx_runtime.jsx)(AttachmentListItem,{file:z,index:B,disabled:i,onDelete:S},z.uid)),(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${h}-list-picture-card-container`,`${h}-list-item-container`),style:R?{}:{display:"none"},children:(0,import_jsx_runtime.jsx)(import_antd.Tooltip,{title:k,children:(0,import_jsx_runtime.jsx)(import_antd.Upload,P(x({accept:F},_),{disabled:i,multiple:n,listType:"picture-card",fileList:m,beforeUpload:v,onChange:C,showUploadList:!1,children:R?(0,import_jsx_runtime.jsxs)("span",{children:[(0,import_jsx_runtime.jsx)(import_icons.PlusOutlined,{}),(0,import_jsx_runtime.jsx)("br",{})," ",g("Upload")]}):null}))})}),R&&y&&(0,import_jsx_runtime.jsx)(y,{disabled:i,multiple:n,value:a,onChange:l})]})}function Attachment(e){const{wrapSSR:t,hashId:o,componentCls:r}=useStyles$8();return t((0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${r}-wrapper`,`${r}-picture-card-wrapper`,"nb-upload",o),children:(0,import_jsx_runtime.jsxs)("div",{className:(0,import_classnames.default)(`${r}-list`,`${r}-list-picture-card`),children:[(0,import_jsx_runtime.jsx)(AttachmentList,x({},e)),(0,import_jsx_runtime.jsx)(Uploader,x({},e))]})}))}Attachment.ReadPretty=ReadPretty$9;Upload.Attachment=withDynamicSchemaProps((0,import_react.connect)(Attachment,(0,import_react.mapReadPretty)(Attachment.ReadPretty)),{displayName:"Upload.Attachment"});Upload.Dragger=(0,import_react.connect)(e=>{const t=e,{tipContent:o,onChange:r}=t,i=W(t,["tipContent","onChange"]),{wrapSSR:n,hashId:a,componentCls:l}=useStyles$8(),c=(0,import_react2.useCallback)(u=>{r==null||r(toFileList(u.fileList))},[r]);return n((0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${l}-dragger`,a),children:(0,import_jsx_runtime.jsxs)(import_antd.Upload.Dragger,P(x({},useUploadProps(i)),{onChange:c,children:[o,e.children]}))}))},(0,import_react.mapProps)({value:"fileList"}));Upload.DraggerV2=withDynamicSchemaProps((0,import_react.connect)(e=>{var t=e,{rules:o}=t,r=W(t,["rules"]);const{t:i}=(0,import_react_i18next.useTranslation)(),n=i("Click or drag file to this area to upload"),a=useProps(r),{title:l=n}=a,c=W(a,["title"]),[u,d]=(0,import_react2.useState)(!1),{wrapSSR:m,hashId:p,componentCls:g}=useStyles$8(),h=useBeforeUpload(o),{size:f,mimetype:_}=o??{},v=useSizeHint(f),C=(0,import_react2.useCallback)(({fileList:S})=>{const{onChange:b}=c;b==null||b(S),S.some(y=>y.status==="uploading")?d(!0):d(!1)},[c]);return m((0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${g}-dragger`,p),children:(0,import_jsx_runtime.jsxs)(import_antd.Upload.Dragger,P(x({},useUploadProps(P(x(x({},r),c),{accept:_,onChange:C,beforeUpload:h}))),{children:[(0,import_jsx_runtime.jsx)("p",{className:`${g}-drag-icon`,children:u?(0,import_jsx_runtime.jsx)(import_icons.LoadingOutlined,{style:{fontSize:36},spin:!0}):(0,import_jsx_runtime.jsx)(import_icons.InboxOutlined,{})}),(0,import_jsx_runtime.jsx)("p",{className:`${g}-text`,children:l}),(0,import_jsx_runtime.jsxs)("ul",{children:[(0,import_jsx_runtime.jsx)("li",{className:`${g}-hint`,children:i("Support for a single or bulk upload.")}),(0,import_jsx_runtime.jsx)("li",{className:`${g}-hint`,children:v})]})]}))}))},(0,import_react.mapProps)({value:"fileList"})),{displayName:"Upload.DraggerV2"});const schema$1={Nester:{type:"void","x-component":"AssociationField.Nester",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"form:configureFields"}}},AddNewer:{type:"void","x-component":"AssociationField.AddNewer","x-action":"create",title:'{{ t("Add record") }}',"x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"popup:addNew:addBlock"},properties:{tab1:{type:"void",title:'{{t("Add new")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:addNew:addBlock",properties:{}}}}}}}},Selector:{type:"void","x-component":"AssociationField.Selector",title:'{{ t("Select record") }}',"x-component-props":{className:"nb-record-picker-selector"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:tableSelector:addBlock",properties:{}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"usePickActionProps","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:submit","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}},Viewer:{type:"void",title:'{{ t("View record") }}',"x-component":"AssociationField.Viewer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}},SubTable:{type:"void","x-component":"AssociationField.SubTable","x-initializer":"table:configureColumns","x-initializer-props":{action:!1},properties:{}}},useTableSelectorProps$3=()=>{const e=(0,import_react.useField)(),{multiple:t,options:o=[],setSelectedRows:r,selectedRows:i=[],onChange:n}=(0,import_react2.useContext)(RecordPickerContext),a=useTableSelectorProps$4(),{onRowSelectionChange:l,rowKey:c="id"}=a,u=W(a,["onRowSelectionChange","rowKey"]),{setVisible:d}=useActionContext();return P(x({},u),{rowKey:c,rowSelection:{type:t?"checkbox":"radio",selectedRowKeys:i==null?void 0:i.filter(m=>o.every(p=>p[c]!==m[c])).map(m=>m[c])},onRowSelectionChange(m,p){if(t){const g=flatData$2(e.value)||[],h=(0,import_lodash.differenceBy)(i||[],g,c),f=(0,import_lodash.unionBy)(h,p,c),_=f.map(v=>v[c]);r==null||r(f),l==null||l(_,f)}else r==null||r(p),l==null||l(m,p),n((p==null?void 0:p[0])||null),d(!1)}})};function FileSelector(e){const t=e,{disabled:o,multiple:r,value:i,onChange:n,action:a,onSelect:l,quickUpload:c,selectFile:u}=t,d=W(t,["disabled","multiple","value","onChange","action","onSelect","quickUpload","selectFile"]),{wrapSSR:m,hashId:p,componentCls:g}=useStyles$8(),{useFileCollectionStorageRules:h,useAttachmentFieldProps:f}=(0,import_react.useExpressionScope)(),{t:_}=(0,import_react_i18next.useTranslation)(),v=h(),C=f(),S=u===void 0&&c===void 0;return m((0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${g}-wrapper`,`${g}-picture-card-wrapper`,"nb-upload",p),children:(0,import_jsx_runtime.jsxs)("div",{className:(0,import_classnames.default)(`${g}-list`,`${g}-list-picture-card`),children:[(0,import_jsx_runtime.jsx)(AttachmentList,{disabled:o,multiple:r,value:i,onChange:n}),S?(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${g}-list-picture-card-container`,`${g}-list-item-container`),children:(0,import_jsx_runtime.jsx)(import_antd.Upload,{disabled:o,multiple:r,listType:"picture-card",showUploadList:!1,children:(0,import_jsx_runtime.jsxs)("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},onClick:l,children:[(0,import_jsx_runtime.jsx)(import_icons.PlusOutlined,{}),_("Select")]})})}):null,c?(0,import_jsx_runtime.jsx)(Uploader,x(P(x({},C),{value:i,multiple:r,onChange:n,action:a,rules:v,disabled:o}),d)):null,u&&(r||!i)?(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${g}-list-picture-card-container`,`${g}-list-item-container`),children:(0,import_jsx_runtime.jsx)(import_antd.Upload,{disabled:o,multiple:r,listType:"picture-card",showUploadList:!1,children:(0,import_jsx_runtime.jsxs)("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},onClick:l,children:[(0,import_jsx_runtime.jsx)(import_icons.PlusOutlined,{}),_("Select")]})})}):null]})}))}const InternalFileManager=e=>{var t,o;const r=e,{value:i,multiple:n,onChange:a}=r,l=W(r,["value","multiple","onChange"]),c=(0,import_react.useFieldSchema)(),[u,d]=(0,import_react2.useState)(!1),[m,p]=(0,import_react2.useState)([]),g=useInsertSchema$1("Selector"),h=useFieldNames$1(e),{designable:f}=useDesignable(),_=(0,import_react.useField)(),[v,C]=(0,import_react2.useState)([]),{getField:S}=useCollection_deprecated(),b=S(_.props.name),y=useLabelUiSchema$1(b==null?void 0:b.target,(h==null?void 0:h.label)||"label"),F=useCompile(),{modalProps:j}=useActionContext(),k=B=>{B.stopPropagation(),B.preventDefault(),f?g(schema$1.Selector):c.reduceProperties((L,D)=>D["x-component"]==="AssociationField.Selector"?D:L,null)||c.addProperty("selector",schema$1.Selector),d(!0),p([])};(0,import_react2.useEffect)(()=>{if(i&&Object.keys(i).length>0){const B=(Array.isArray(i)?i:i?[i]:[]).filter(Boolean).map(L=>{const D=L[h.label];return P(x({},L),{[h.label]:getLabelFormatValue$1(F(y),F(D))})});C(B)}else C([])},[i,h==null?void 0:h.label]);const R={size:"small",fieldNames:h,multiple:["o2m","m2m","mbm"].includes(b==null?void 0:b.interface)&&n,association:{target:b==null?void 0:b.target},options:v,onChange:e==null?void 0:e.onChange,selectedRows:m,setSelectedRows:p,collectionField:b},z=()=>{const{setVisible:B}=useActionContext(),{multiple:L,selectedRows:D,onChange:T,options:$,collectionField:w}=(0,import_react2.useContext)(RecordPickerContext);return{onClick(){T(L?(0,import_lodash.unionBy)(D,$,(w==null?void 0:w.targetKey)||"id"):(D==null?void 0:D[0])||null),B(!1)}}};return(0,import_jsx_runtime.jsxs)("div",{style:{width:"100%",overflow:"auto"},children:[(0,import_jsx_runtime.jsx)(FileSelector,P(x({},l),{value:n?v:v==null?void 0:v[0],multiple:n,quickUpload:((t=c["x-component-props"])==null?void 0:t.quickUpload)!==!1,selectFile:((o=c["x-component-props"])==null?void 0:o.selectFile)!==!1,action:`${b==null?void 0:b.target}:create`,onSelect:k,onChange:a})),(0,import_jsx_runtime.jsx)(ActionContextProvider,{value:{openMode:"drawer",visible:u,setVisible:d,modalProps:{getContainer:(l==null?void 0:l.getContainer)||(j==null?void 0:j.getContainer)},formValueChanged:!1},children:(0,import_jsx_runtime.jsx)(RecordPickerProvider,P(x({},R),{children:(0,import_jsx_runtime.jsx)(CollectionProvider_deprecated,{name:b==null?void 0:b.target,children:(0,import_jsx_runtime.jsx)(FormProvider,{children:(0,import_jsx_runtime.jsx)(TableSelectorParamsProvider,{params:{},children:(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{scope:{usePickActionProps:z,useTableSelectorProps:useTableSelectorProps$3},children:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{onlyRenderProperties:!0,basePath:_.address,schema:c,filterProperties:B=>B["x-component"]==="AssociationField.Selector"})})})})})}))})]})},FileManageReadPretty=(0,import_react.connect)(e=>{const t=(0,import_react.useFieldSchema)(),{getField:o}=useCollection_deprecated(),{getCollectionJoinField:r}=useCollectionManager_deprecated(),i=o(t.name)||r(t["x-collection-field"]);return(0,import_jsx_runtime.jsx)(EllipsisWithTooltip,{ellipsis:!0,children:i?(0,import_jsx_runtime.jsx)(Upload.ReadPretty,x({},e)):null})}),EMPTY="N/A",SchemaField=(0,import_react.createSchemaField)({components:{Space:import_antd.Space,Input:import_antd.Input,ArrayItems:import_antd_v5.ArrayItems,FormItem:import_antd_v5.FormItem}}),CascadeSelect=(0,import_react.connect)(e=>{var t;const{data:o,mapOptions:r,onChange:i,value:n}=e,[a,l]=(0,import_react2.useState)([{key:void 0,children:[],value:null}]),[c,u]=(0,import_react2.useState)(o),[d,m]=(0,import_react2.useState)(!1),p=useCompile(),g=useAPIClient(),h=useServiceOptions$1(e),{options:f,field:_}=useAssociationFieldContext(),v=g.resource(f.target),{getCollectionJoinField:C,getInterface:S}=useCollectionManager_deprecated(),b=(t=_==null?void 0:_.componentProps)==null?void 0:t.fieldNames,y=(f==null?void 0:f.target)&&(b==null?void 0:b.label)&&C(`${f.target}.${b.label}`),F=(0,import_react2.useMemo)(()=>{var D,T;return y!=null&&y.interface&&((T=(D=S(y.interface))==null?void 0:D.filterable)==null?void 0:T.operators[0].value)||"$includes"},[y]),j=(0,import_react.useField)();(0,import_react2.useEffect)(()=>{var D;if(n){const T=Array.isArray(n)?extractLastNonNullValueObjects(n==null?void 0:n.filter(w=>w.value),!0):transformNestedData(n),$=(D=T==null?void 0:T.map)==null?void 0:D.call(T,w=>({key:w.parentId,children:[],value:w}));l($)}},[]);const k=(0,import_react2.useCallback)(D=>{try{return D==null?void 0:D.filter(T=>["number","string"].includes(typeof T[b.value])).map(T=>{var $,w,I;let N=p(T[b.label]);if(($=y==null?void 0:y.uiSchema)!=null&&$.enum)if(Array.isArray(N))N=N.map((M,O)=>{var E,U;const V=(U=(E=y.uiSchema.enum).find)==null?void 0:U.call(E,G=>G.value===M);return V?(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:V.color,style:{marginRight:3},children:(V==null?void 0:V.label)||M},O):(0,import_jsx_runtime.jsx)(import_antd.Tag,{children:M},M)}).reverse();else{const M=(I=(w=y.uiSchema.enum).find)==null?void 0:I.call(w,O=>O.value===N);M&&(N=(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:M.color,children:M.label}))}return(y==null?void 0:y.type)==="date"&&(N=(0,import_dayjs.default)(N).format("YYYY-MM-DD")),r?r({[b.label]:N||EMPTY,[b.value]:T[b.value]}):P(x({},T),{[b.label]:N||EMPTY,[b.value]:T[b.value]})}).filter(Boolean)}catch(T){return console.error(T),D}},[y==null?void 0:y.uiSchema,b]),R=D=>q(void 0,null,function*(){var T;const $=yield v.list({pageSize:200,params:h==null?void 0:h.params,filter:mergeFilter([D]),tree:D.parentId?void 0:!0});return(T=$==null?void 0:$.data)==null?void 0:T.data}),z=(D,T,$)=>q(void 0,null,function*(){const w=yield R({parentId:T==null?void 0:T.id}),I=[...a];if(I.splice($+1),I[$]=P(x({},I[$]),{value:T}),T!=null&&T.id&&(I[$+1]={key:T==null?void 0:T.id,children:(w==null?void 0:w.length)>0?w:null}),l(I),["o2m","m2m"].includes(f.interface)){const N=Array.isArray(_.fieldValue)?_.fieldValue:[];N[j.index]=T,_.fieldValue=N}else _.value=T;i==null||i(I)}),B=(D,T,$)=>q(void 0,null,function*(){var w,I,N;if(D){m(!0);const M=yield R({parentId:T==null?void 0:T.key});if(m(!1),u(M),$===(a==null?void 0:a.length)-1&&(w=T==null?void 0:T.value)!=null&&w.id){const O=yield R({parentId:(I=T==null?void 0:T.value)==null?void 0:I.id}),E=[...a];E.splice($+1),E[$]=P(x({},E[$]),{value:T==null?void 0:T.value}),E[$+1]={key:(N=T==null?void 0:T.value)==null?void 0:N.id,children:(O==null?void 0:O.length)>0?O:null},l(E),i==null||i(E)}}}),L=(D,T)=>q(void 0,null,function*(){const $=D?{[b.label]:{[F]:D}}:{};m(!0);const w=yield R(P(x({},$),{parentId:T==null?void 0:T.key}));m(!1),u(w)});return(0,import_jsx_runtime.jsx)(import_antd.Space,{wrap:!0,children:a.map((D,T)=>{var $,w,I;return D.children&&(0,import_jsx_runtime.jsx)(import_antd.Select,{disabled:_.disabled,allowClear:!0,showSearch:!0,autoClearSearchValue:!0,filterOption:!1,filterSort:null,defaultValue:{label:($=D==null?void 0:D.value)==null?void 0:$[b.label],value:(w=D==null?void 0:D.value)==null?void 0:w[b.value]},labelInValue:!0,onSearch:N=>L(N,D),fieldNames:b,style:{minWidth:150},onChange:(N,M)=>z(N,M,T),options:d?[]:k(c),onDropdownVisibleChange:N=>B(N,D,T),notFoundContent:d?(0,import_jsx_runtime.jsx)(import_antd.Spin,{size:"small"}):null},`${(I=D.value)==null?void 0:I.id}+ ${D.key} + ${b.label}`)})})}),AssociationCascadeSelect=(0,import_react.connect)(e=>(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsx)(CascadeSelect,x({},e))})),InternalCascadeSelect=(0,import_react.observer)(e=>{var t;const{options:o}=useAssociationFieldContext(),r=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)(),[]),{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useField)(),a=(0,import_react.useFieldSchema)(),{loading:l,data:c}=useDataBlockRequest()||{},u=(t=c==null?void 0:c.data)==null?void 0:t[a.name];(0,import_react2.useEffect)(()=>{const m=(0,import_shared.uid)();return r.addEffects(m,()=>{(0,import_core2.onFormValuesChange)(p=>{var g,h;if(o.interface==="m2o"){const f=extractLastNonNullValueObjects((g=p.values)==null?void 0:g[a.name]);setTimeout(()=>{p.setValuesIn(a.name,f),n.value=f})}else{const f=extractLastNonNullValueObjects((h=p.values)==null?void 0:h.select_array).filter(_=>_&&Object.keys(_).length>0);setTimeout(()=>{n.value=f})}})}),()=>{r.removeEffects(m)}},[]);const d={type:"object",properties:{select_array:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",default:Array.isArray(u)&&u.length>0?u:[{}],items:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},select:{type:"string","x-decorator":"FormItem","x-component":AssociationCascadeSelect,"x-component-props":x({},e)},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:i("Add new"),"x-component":"ArrayItems.Addition"}}}}};return!l&&(0,import_jsx_runtime.jsx)(import_react.FormProvider,{form:r,children:o.interface==="m2o"?(0,import_jsx_runtime.jsx)(SchemaComponent,{components:{FormItem:import_antd_v5.FormItem},schema:P(x({},a),{default:u,title:"","x-component":AssociationCascadeSelect,"x-component-props":x({},e)})}):(0,import_jsx_runtime.jsx)(SchemaField,{schema:d})})},{displayName:"InternalCascadeSelect"});function extractLastNonNullValueObjects(e,t){var o,r;let i=[];if(!Array.isArray(e))return e;for(const n of e){let a=null;if(Array.isArray(n)){for(let l=(n==null?void 0:n.length)-1;l>=0;l--)if(n[l].value){a=n[l].value;break}a&&i.push(a)}else n!=null&&n.value?a=n.value:a=null,a?t?(o=i==null?void 0:i.push)==null||o.call(i,a):i=a:(r=i==null?void 0:i.push)==null||r.call(i,n)}return i}function transformNestedData(e){const t=[];function o(r){if(r!=null&&r.parent){const{parent:a}=r;o(a)}const i=r,n=W(i,["parent"]);t.push(n)}return e&&o(e),t}const InternalNesterCss=import_css.css`
|
|
627
|
+
`,displayBlock={display:"block"},displayNone$1={display:"none"},TabPane=import_react2.default.memo(({schema:e,active:t})=>{const o=(0,import_react2.useRef)(!1),{active:r}=useKeepAlive();t&&!o.current&&(o.current=!0);const i=(0,import_react2.useMemo)(()=>new import_react.Schema({properties:{[e.name]:e}}),[e]);return o.current?(0,import_jsx_runtime.jsx)("div",{style:t?displayBlock:displayNone$1,children:(0,import_jsx_runtime.jsx)(KeepAliveProvider,{active:r&&t,children:(0,import_jsx_runtime.jsx)(SchemaComponent,{distributed:!0,schema:i})})}):null}),InternalPageContent=e=>{const{loading:t,disablePageHeader:o,enablePageTabs:r,fieldSchema:i,activeKey:n}=e;return!o&&r?(0,import_jsx_runtime.jsx)(import_jsx_runtime.Fragment,{children:i.mapProperties(a=>(0,import_jsx_runtime.jsx)(TabPane,{schema:a,active:a.name===n},a.name))}):(0,import_jsx_runtime.jsx)("div",{className:className1$1,children:(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:i,distributed:!0})})},PageContent=(0,import_react2.memo)(e=>(0,import_jsx_runtime.jsx)(PopupRouteContextResetter,{children:(0,import_jsx_runtime.jsx)(InternalPageContent,x({},e))})),NocoBasePageHeaderTabs=({className:e,activeKey:t})=>{var o;const r=(0,import_react.useFieldSchema)(),{t:i}=(0,import_react_i18next.useTranslation)(),{token:n}=useToken(),a=useRouterBasename(),l=useNavigateNoUpdate(),c=(0,import_react2.useCallback)(v=>{navigateToTab({activeKey:v,navigate:l,basename:a})},[a,l]),u=useDesignable(),{getAriaLabel:d}=useGetAriaLabelOfSchemaInitializer(),m=(0,import_react2.useContext)(import_react.SchemaOptionsContext),{theme:p}=useGlobalTheme(),g=(0,import_react2.useMemo)(()=>u.designable&&(0,import_jsx_runtime.jsx)(import_antd.Button,{"aria-label":d("tabs"),icon:(0,import_jsx_runtime.jsx)(import_icons.PlusOutlined,{}),className:"addTabBtn",type:"dashed",onClick:()=>q(void 0,null,function*(){const v=yield FormDialog(i("Add tab"),()=>(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{scope:m.scope,components:x({},m.components),children:(0,import_jsx_runtime.jsx)(import_antd_v5.FormLayout,{layout:"vertical",children:(0,import_jsx_runtime.jsx)(SchemaComponent,{schema:{properties:{title:{title:i("Tab name"),"x-component":"Input","x-decorator":"FormItem",required:!0},icon:{title:i("Icon"),"x-component":"IconPicker","x-decorator":"FormItem"}}}})})}),p).open({initialValues:{}}),{title:C,icon:S}=v;u.insertBeforeEnd({type:"void",title:C,"x-icon":S,"x-component":"Grid","x-initializer":"page:addBlock",properties:{}})}),children:i("Add tab")}),[u,d,m==null?void 0:m.components,m==null?void 0:m.scope,i,p]),h=(o=r["x-component-props"])==null?void 0:o.enablePageTabs,f=(0,import_react2.useMemo)(()=>({paddingLeft:n.paddingLG-n.paddingPageHorizontal,paddingRight:n.paddingLG-n.paddingPageHorizontal,marginLeft:n.paddingPageHorizontal-n.paddingLG,marginRight:n.paddingPageHorizontal-n.paddingLG}),[n.paddingLG,n.paddingPageHorizontal]),_=(0,import_react2.useMemo)(()=>r.mapProperties(v=>({label:(0,import_jsx_runtime.jsxs)(SortableItem,{id:v.name,schema:v,className:(0,import_classnames.default)("nb-action-link","designerCss",e),children:[v["x-icon"]&&(0,import_jsx_runtime.jsx)(Icon,{style:{marginRight:8},type:v["x-icon"]}),(0,import_jsx_runtime.jsx)("span",{children:v.title||i("Unnamed")}),(0,import_jsx_runtime.jsx)(PageTabDesigner,{schema:v})]}),key:v.name})),[r,e,i,r.mapProperties(v=>v.title||i("Unnamed")).join()]);return h?(0,import_jsx_runtime.jsx)(DndContext,{children:(0,import_jsx_runtime.jsx)(import_antd.Tabs,{size:"small",activeKey:t,tabBarStyle:f,onChange:c,tabBarExtraContent:g,items:_})}):null},NocoBasePageHeader=import_react2.default.memo(({activeKey:e,className:t})=>{var o,r,i;const n=(0,import_react.useFieldSchema)(),{setTitle:a}=useDocumentTitle(),{t:l}=(0,import_react_i18next.useTranslation)(),[c,u]=(0,import_react2.useState)(()=>l(n.title)),d=(o=n["x-component-props"])==null?void 0:o.disablePageHeader,m=(r=n["x-component-props"])==null?void 0:r.enablePageTabs,p=(i=n["x-component-props"])==null?void 0:i.hidePageTitle;return(0,import_react2.useEffect)(()=>{if(n.title){const g=l(n.title);a(g),u(g)}},[n.title,c,a,l]),useRequest({url:`/uiSchemas:getParentJsonSchema/${n["x-uid"]}`},{ready:!p&&!n.title,onSuccess(g){u(g.data.title),a(g.data.title)}}),(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[(0,import_jsx_runtime.jsx)(PageDesigner,{title:c}),!d&&(0,import_jsx_runtime.jsx)(import_pro_layout.PageHeader,{className:(0,import_classnames.default)("pageHeaderCss",c||m?"":"height0"),ghost:!1,title:p?" ":c||" ",footer:(0,import_jsx_runtime.jsx)(NocoBasePageHeaderTabs,{className:t,activeKey:e})})]})});NocoBasePageHeader.displayName="NocoBasePageHeader";function navigateToTab({activeKey:e,navigate:t,basename:o,pathname:r=window.location.pathname}){r=r.replace(o,""),r.endsWith("/")&&(r=r.slice(0,-1)),r.startsWith("/")||(r=`/${r}`),isTabPage(r)?t(withSearchParams(`${r.replace(/\/tabs\/[^/]+$/,`/tabs/${e}`)}`),{replace:!0}):t(withSearchParams(`${r}/tabs/${e}`),{replace:!0})}function isTabPage(e){e.endsWith("/")&&(e=e.slice(0,-1));const t=e.split("/");return t[t.length-2]==="tabs"}function useNotDisableHeader(){var e;return!((e=(0,import_react.useFieldSchema)()["x-component-props"])!=null&&e.disablePageHeader)}const pageSettings=new SchemaSettings({name:"PageSettings",items:[{name:"enablePageHeader",type:"switch",useComponentProps(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)();return{title:o("Enable page header"),checked:!((e=r["x-component-props"])!=null&&e.disablePageHeader),onChange(i){r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].disablePageHeader=!i,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":r["x-component-props"]}}),t.refresh()}}}},{name:"divider",type:"divider",useVisible:useNotDisableHeader},{name:"displayPageTitle",type:"switch",useVisible:useNotDisableHeader,useComponentProps(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)();return{title:o("Display page title"),checked:!((e=r["x-component-props"])!=null&&e.hidePageTitle),onChange(i){r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].hidePageTitle=!i,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":r["x-component-props"]}}),t.refresh()}}}},{name:"editPageTitle",type:"modal",useVisible(){var e;const t=useNotDisableHeader(),o=!((e=(0,import_react.useFieldSchema)()["x-component-props"])!=null&&e.hidePageTitle);return t&&o},useComponentProps(){const{dn:e}=useDesignable(),{t}=(0,import_react_i18next.useTranslation)(),o=(0,import_react.useField)(),r=(0,import_react.useFieldSchema)(),{title:i}=useSchemaToolbar();return{hide:!0,title:t("Edit page title"),schema:{type:"object",title:t("Edit page title"),properties:{title:{title:t("Title"),required:!0,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}}}},initialValues:{title:i},onSubmit({title:n}){o.title=n,r.title=n,e.emit("patch",{schema:{"x-uid":r["x-uid"],title:n}})}}}},{name:"enablePageTabs",type:"switch",useVisible:useNotDisableHeader,useComponentProps(){var e;const{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),r=(0,import_react.useFieldSchema)();return{title:o("Enable page tabs"),checked:(e=r["x-component-props"])==null?void 0:e.enablePageTabs,onChange(i){r["x-component-props"]=r["x-component-props"]||{},r["x-component-props"].enablePageTabs=i,t.emit("patch",{schema:{"x-uid":r["x-uid"],"x-component-props":r["x-component-props"]}}),t.refresh()}}}}]}),pageTabSettings=new SchemaSettings({name:"PageTabSettings",items:[{name:"edit",type:"modal",useComponentProps(){const{t:e}=(0,import_react_i18next.useTranslation)(),{schema:t}=useSchemaToolbar(),{dn:o}=useDesignable();return{title:e("Edit"),schema:{type:"object",title:e("Edit tab"),properties:{title:{title:e("Tab name"),required:!0,"x-decorator":"FormItem","x-component":"Input","x-component-props":{}},icon:{title:e("Icon"),"x-decorator":"FormItem","x-component":"IconPicker","x-component-props":{}}}},initialValues:{title:t.title,icon:t["x-icon"]},onSubmit:({title:r,icon:i})=>{t.title=r,t["x-icon"]=i,o.emit("patch",{schema:{"x-uid":t["x-uid"],title:r,"x-icon":i}}),o.refresh()}}}},{name:"divider",type:"divider"},{name:"delete",type:"item",useComponentProps(){const{modal:e}=import_antd.App.useApp(),{dn:t}=useDesignable(),{t:o}=(0,import_react_i18next.useTranslation)(),{schema:r}=useSchemaToolbar();return{title:o("Delete"),eventKey:"remove",onClick(){e.confirm(P(x({title:o("Delete block"),content:o("Are you sure you want to delete it?")},confirm),{onOk(){t.remove(r)}}))},children:o("Delete")}}}]}),AntdSchemaComponentProvider=e=>{const{children:t}=e;return(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{scope:{requestChartData,useFilterActionProps:useFilterActionProps$1},components:x(x({},components$2),common),children:t})};class AntdSchemaComponentPlugin extends Plugin{load(){return q(this,null,function*(){this.addComponents(),this.addScopes(),this.addSchemaSettings()})}addComponents(){this.app.addComponents(x(x({},components$2),common))}addScopes(){this.app.addScopes({requestChartData,useFilterActionProps:useFilterActionProps$1})}addSchemaSettings(){this.app.schemaSettingsManager.add(pageSettings),this.app.schemaSettingsManager.add(pageTabSettings),this.app.schemaSettingsManager.add(formItemSettings),this.app.schemaSettingsManager.add(filterFormItemSettings),this.app.schemaSettingsManager.add(formV1Settings),this.app.schemaSettingsManager.add(formSettings),this.app.schemaSettingsManager.add(readPrettyFormSettings),this.app.schemaSettingsManager.add(formDetailsSettings),this.app.schemaSettingsManager.add(actionSettings)}}function usePropsCollection({collection:e}){return e}function loadChildren(e){const t=getCollectionFieldOptions.call(this,e.field.target,e);return t.length&&t.some(o=>isAssociation(o.field))||(e.isLeaf=!0),t}function isAssociation(e){return e.target&&e.interface}function trueFilter(e){return!0}function getCollectionFieldOptions(e,t){const o=this.getCollectionFields(e).filter(isAssociation),r=loadChildren.bind(this);return o.filter(this.filter).map(i=>{var n,a,l;const c=t?`${t.value?`${t.value}.`:""}${i.name}`:i.name,u=(a=this.compile((n=i.uiSchema)==null?void 0:n.title))!=null?a:i.name,d=!this.getCollectionFields(i.target).filter(isAssociation).filter(this.filter).length;return{pId:(l=t==null?void 0:t.key)!=null?l:null,id:c,key:c,value:c,title:u,isLeaf:d,loadChildren:d?null:r,field:i,fullTitle:t?[...t.fullTitle,u]:[u]}})}const AppendsTreeSelect=e=>{const t=e,{title:o,value:r,onChange:i,collection:n,useCollection:a=usePropsCollection,filter:l=trueFilter,rootOption:c,loadData:u}=t,d=W(t,["title","value","onChange","collection","useCollection","filter","rootOption","loadData"]),m=useCompile(),{t:p}=(0,import_react_i18next.useTranslation)(),[g,h]=(0,import_react2.useState)({}),f=a({collection:n}),[_,v]=parseCollectionName(f),C=useApp(),{collectionManager:S}=C.dataSourceManager.getDataSource(_),b=(L,D)=>{const T=S.getCollection(L);return T?T.getAllFields(D):[]},y=Object.values(g),F=(0,import_react2.useMemo)(()=>e.multiple?(r||[]).map(L=>g[L]).filter(Boolean):r,[r,e.multiple,g]),j=(0,import_react2.useCallback)(L=>q(void 0,null,function*(){if(u!=null)return u(L);if(!L.isLeaf&&L.loadChildren){const D=L.loadChildren(L);h(T=>D.reduce(($,w)=>Object.assign($,{[w.value]:w}),x({},T)))}}),[u]);(0,import_react2.useEffect)(()=>{const L=c?P(x({},c),{id:c.value,key:c.value,title:c.label,fullTitle:c.label,isLeaf:!1}):null,D=(u===null?[]:getCollectionFieldOptions.call({compile:m,getCollectionFields:b,filter:l},v,L)).reduce((T,$)=>Object.assign(T,{[$.value]:$}),{});L&&(D[L.value]=L),h(D)},[f,c,l,u]),(0,import_react2.useEffect)(()=>{const L=e.multiple?r:r?[r]:[];if(!(L!=null&&L.length)||L.every(T=>!!g[T]))return;const D=[];L.forEach(T=>{const $=T.split(".");let w=g[$[0]];for(let I=1;I<$.length&&w;I++){const N=$.slice(0,I+1).join(".");if(g[N]){w=g[N];break}if(!w.isLeaf&&w.loadChildren){const M=w.loadChildren(w);M!=null&&M.length&&(D.push(...M),w=M.find(O=>O.value===$.slice(0,I+1).join(".")))}}}),h(T=>D.reduce(($,w)=>Object.assign($,{[w.value]:w}),x({},T)))},[r,y.length,e.multiple]);const k=(0,import_react2.useCallback)(L=>{if(!e.multiple){i(L);return}const D=L.map(w=>w.value).filter(Boolean),T=new Set(D),$=F.find(w=>!T.has(w.value));if($){const w=`${$.value}.`;Object.keys(g).forEach(I=>{I.startsWith(w)&&T.delete(I)})}else D.forEach(w=>{const I=w.split(".");if(I.length)for(let N=1;N<=I.length;N++)T.add(I.slice(0,N).join("."))});i(Array.from(T))},[e.multiple,F,i,g]),R=(0,import_react2.useCallback)(L=>{var D;const{value:T,onClose:$,disabled:w,closable:I}=L;if(!T)return null;const{fullTitle:N}=(D=g[T])!=null?D:{};return(0,import_jsx_runtime.jsx)(import_antd.Tag,{closable:I&&!w,onClose:$,children:N==null?void 0:N.join(" / ")})},[g]),z=Array.isArray(F)?F.filter(L=>L.value in g):F,B=e.multiple?r:r!=null?[r]:[];return(0,import_jsx_runtime.jsx)(import_antd.TreeSelect,x({role:"button","data-testid":`select-field${o?`-${o}`:""}`,value:z,placeholder:p("Select field"),showCheckedStrategy:import_antd.TreeSelect.SHOW_ALL,treeDefaultExpandedKeys:B,allowClear:{clearIcon:(0,import_jsx_runtime.jsx)(import_icons.CloseCircleFilled,{role:"button","aria-label":"icon-close"})},treeCheckStrictly:e.multiple,treeCheckable:e.multiple,tagRender:R,onChange:k,treeDataSimpleMode:!0,treeData:y,loadData:j},d))},AssociationFieldAddNewer=e=>{const t=(0,import_react2.useContext)(SchemaComponentContext);return(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:P(x({},t),{draggable:!0}),children:(0,import_jsx_runtime.jsx)(Action.Container,x({},e))})},filterAnalyses=e=>{if(!e)return;const t=Object.keys(e)[0]||"$and",o=e[t],r=[];return o==null||o.map(i=>{var n,a,l;const c=getInnermostKeyAndValue(i);if(!(c!=null&&c.key))return!0;const u=/\{\{\$[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*\.(\w+)\.id\}\}/,d=(l=(a=(n=c==null?void 0:c.value)==null?void 0:n.match)==null?void 0:a.call(n,u))==null?void 0:l[1];d&&r.push(d)}),r},InternalAssociationSelect$1=(0,import_react.observer)(e=>{var t;const o=e,{objectValue:r=!0,addMode:i}=o,n=W(o,["objectValue","addMode"]),a=(0,import_react.useField)(),l=(0,import_react.useFieldSchema)(),c=useServiceOptions$1((l==null?void 0:l["x-component-props"])||e),{options:u}=useAssociationFieldContext(),d=isVariable(e.value)?void 0:e.value,m=Array.isArray(d)?d.filter(Boolean):d,[p,g]=(0,import_react2.useState)(m),h=(t=l["x-component-props"])==null?void 0:t.addMode,{t:f}=(0,import_react_i18next.useTranslation)(),{multiple:_}=e,v=(0,import_react.useForm)(),C=useAPIClient().resource(u.target),S=useCollectionRecordData(),b=(0,import_react2.useContext)(SchemaComponentContext);(0,import_react2.useEffect)(()=>{const j=isVariable(a.value)?void 0:a.value,k=Array.isArray(j)?j.filter(Boolean):j;g(k)},[a.value]),(0,import_react2.useEffect)(()=>{const j=(0,import_shared.uid)();return v.addEffects(j,()=>{(0,import_core2.onFieldInputValueChange)("*",k=>{var R,z,B,L,D;(filterAnalyses((B=(z=(R=a.componentProps)==null?void 0:R.service)==null?void 0:z.params)==null?void 0:B.filter)||[]).includes((L=k==null?void 0:k.props)==null?void 0:L.name)&&a.value&&(0,import_lodash.isEqual)(k==null?void 0:k.indexes,a==null?void 0:a.indexes)&&((D=k==null?void 0:k.props)==null?void 0:D.name)!==a.props.name&&(a.setValue(null),g(null))})}),()=>{v.removeEffects(j)}},[]);const y=j=>q(void 0,null,function*(){var k,R;const{search:z,callBack:B}=j,{data:{data:L}}=yield C.create({values:{[((R=(k=a==null?void 0:a.componentProps)==null?void 0:k.fieldNames)==null?void 0:R.label)||"id"]:z}});if(L){if(["m2m","o2m"].includes(u==null?void 0:u.interface)&&_!==!1){const D=v.getValuesIn(a.path)||[];D.push(L),v.setValuesIn(a.path,D),a.onInput(D)}else v.setValuesIn(a.path,L),a.onInput(L);(0,import_mathjs.isFunction)(B)&&(B==null||B()),import_antd.message.success(f("Saved successfully"))}}),F=j=>(0,import_jsx_runtime.jsxs)("div",{onClick:()=>y(j),style:{cursor:"pointer",padding:"5px 12px",color:"#0d0c0c"},children:[(0,import_jsx_runtime.jsx)(import_icons.PlusOutlined,{}),(0,import_jsx_runtime.jsx)("span",{style:{paddingLeft:5},children:f("Add")+` “${j.search}” `})]});return console.log(l),(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsxs)(import_antd.Space.Compact,{style:{display:"flex"},children:[(0,import_jsx_runtime.jsx)(RemoteSelect,P(x({style:{width:"100%"}},n),{size:"middle",objectValue:r,value:m||p,service:c,onChange:j=>{var k;const R=(j==null?void 0:j.length)!==0?j:null;(k=e.onChange)==null||k.call(e,R)},CustomDropdownRender:h==="quickAdd"&&F})),h==="modalAdd"&&(0,import_jsx_runtime.jsx)(SchemaComponentContext.Provider,{value:P(x({},b),{draggable:!1}),children:(0,import_jsx_runtime.jsx)(RecordProvider,{isNew:!0,record:null,parent:S,children:(0,import_jsx_runtime.jsx)(VariablePopupRecordProvider,{children:(0,import_jsx_runtime.jsx)(ClearCollectionFieldContext,{children:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{onlyRenderProperties:!0,basePath:a.address,schema:l,filterProperties:j=>j["x-component"]==="Action"})})})})})]})},l.name)},{displayName:"AssociationSelect"}),AssociationSelect$1=InternalAssociationSelect$1;(0,import_react.connect)(e=>{const t=useServiceOptions$1(e);return e.fieldNames?(0,import_jsx_runtime.jsx)(RemoteSelect.ReadPretty,P(x({},e),{service:t})):null},(0,import_react.mapProps)({dataSource:"options",loading:!0},(e,t)=>P(x({},e),{fieldNames:e.fieldNames&&x(x({},e.fieldNames),t.componentProps.fieldNames),suffixIcon:t!=null&&t.loading||t!=null&&t.validating?(0,import_jsx_runtime.jsx)(import_icons.LoadingOutlined,{}):e.suffixIcon})));const publicPath=window.__nocobase_dev_public_path__||window.__nocobase_public_path__||"/",UPLOAD_PLACEHOLDER=[{ext:/\.docx?$/i,icon:"/file-placeholder/docx-200-200.png"},{ext:/\.pptx?$/i,icon:"/file-placeholder/pptx-200-200.png"},{ext:/\.jpe?g$/i,icon:"/file-placeholder/jpeg-200-200.png"},{ext:/\.pdf$/i,icon:"/file-placeholder/pdf-200-200.png"},{ext:/\.png$/i,icon:"/file-placeholder/png-200-200.png"},{ext:/\.eps$/i,icon:"/file-placeholder/eps-200-200.png"},{ext:/\.ai$/i,icon:"/file-placeholder/ai-200-200.png"},{ext:/\.gif$/i,icon:"/file-placeholder/gif-200-200.png"},{ext:/\.svg$/i,icon:"/file-placeholder/svg-200-200.png"},{ext:/\.xlsx?$/i,icon:"/file-placeholder/xlsx-200-200.png"},{ext:/\.psd?$/i,icon:"/file-placeholder/psd-200-200.png"},{ext:/\.(wav|aif|aiff|au|mp1|mp2|mp3|ra|rm|ram|mid|rmi)$/i,icon:"/file-placeholder/audio-200-200.png"},{ext:/\.(avi|wmv|mpg|mpeg|vob|dat|3gp|mp4|mkv|rm|rmvb|mov|flv)$/i,icon:"/file-placeholder/video-200-200.png"},{ext:/\.(zip|rar|arj|z|gz|iso|jar|ace|tar|uue|dmg|pkg|lzh|cab)$/i,icon:"/file-placeholder/zip-200-200.png"}].map(e=>({ext:e.ext,icon:publicPath+e.icon.slice(1)})),UNKNOWN_FILE_ICON=publicPath+"file-placeholder/unknown-200-200.png",FILE_SIZE_LIMIT_DEFAULT=1024*1024*20;class AttachmentFileTypes{constructor(){A(this,"types",[])}add(t){this.types.unshift(t)}getTypeByFile(t){return this.types.find(o=>o.match(t))}}const attachmentFileTypes=new AttachmentFileTypes;function matchMimetype(e,t){if(!e)return!1;if(e.originFileObj)return(0,import_mime_match.default)(e.type,t);if(e.mimetype)return(0,import_mime_match.default)(e.mimetype,t);if(e.url){const[o]=e.url.split("?");return(0,import_mime_match.default)(import_mime.default.getType(o)||"",t)}return!1}const toArr$1=e=>(0,import_shared.isValid)(e)?Object.keys(e).length===0?[]:(0,import_shared.toArr)(e):[],testOpts=(e,t)=>t&&(0,import_shared.isArr)(t.include)?t.include.some(o=>e.test(o)):t&&(0,import_shared.isArr)(t.exclude)?!t.exclude.some(o=>e.test(o)):!0;function getThumbnailPlaceholderURL(e,t={}){for(let o=0;o<UPLOAD_PLACEHOLDER.length;o++)if(UPLOAD_PLACEHOLDER[o].ext.test(e.extname||e.filename||e.url||e.name))return testOpts(UPLOAD_PLACEHOLDER[o].ext,t)?UPLOAD_PLACEHOLDER[o].icon||UNKNOWN_FILE_ICON:e.name;return UNKNOWN_FILE_ICON}function getResponseMessage({error:e,response:t}){var o,r,i,n;if(e instanceof Error&&"isAxiosError"in e)return e.response?(i=(r=(o=e.response.data)==null?void 0:o.errors)==null?void 0:r.map)==null?void 0:i.call(r,l=>l==null?void 0:l.message).join(", "):e.message;if(!t)return"";if(typeof t=="string")return t;const{errors:a}=(n=t.data)!=null?n:{};return a!=null&&a.length?a.map(l=>l==null?void 0:l.message).join(", "):""}function normalizeFile(e){const t=getResponseMessage(e);return P(x({},e),{title:e.name,response:t})}function useUploadProps(e){const t=useAPIClient();return x({customRequest({action:o,data:r,file:i,filename:n,headers:a,onError:l,onProgress:c,onSuccess:u,withCredentials:d}){const m=new FormData;return r&&Object.keys(r).forEach(p=>{m.append(p,r[p])}),m.append(n,i),t.axios.post(o,m,{withCredentials:d,headers:a,onUploadProgress:({total:p,loaded:g})=>{c({percent:Math.round(g/p*100).toFixed(2)},i)}}).then(({data:p})=>{u(p,i)}).catch(l).finally(()=>{}),{abort(){console.log("upload progress is aborted.")}}}},e)}function toValueItem(e){return e}const toItem=e=>{var t;return typeof e=="string"?{url:e}:((t=e==null?void 0:e.response)!=null&&t.data&&(e=x({uid:e.uid},e.response.data)),P(x({},e),{id:e.id||e.uid,title:e.title||e.name}))},toFileList=e=>toArr$1(e).filter(Boolean).map(toItem),Rules={size(e,t){const o=t??FILE_SIZE_LIMIT_DEFAULT;return o===0||e.size<=o?null:"File size exceeds the limit"},mimetype(e,t="*"){const o=t.toString().trim();return!o||o==="*"||o.split(",").filter(Boolean).some((0,import_mime_match.default)(e.type))?null:"File type is not allowed"}};function validate(e,t){if(!t)return null;const o=Object.keys(t);if(!o.length)return null;for(const r of o){const i=Rules[r](e,t[r]);if(i)return i}return null}function useBeforeUpload(e){const{t}=(0,import_react_i18next.useTranslation)();return(0,import_react2.useCallback)(o=>{const r=validate(o,e);return r?(o.status="error",o.response=t(r)):o.status==="error"&&(delete o.status,delete o.response),!r},[e])}const useStyles$8=genStyleHook("upload",e=>{const{componentCls:t,antCls:o}=e;return{[`${t}-wrapper`]:{"&.nb-upload.nb-upload-small":{[`${t}-list-picture-card-container`]:{margin:"0 3px 3px 0 !important",height:"32px !important",width:"32px !important",marginBlock:"0 !important"},[`${t}-list-picture-card ${t}-list-item-name${t}-list-item-name`]:{display:"none !important"},[`${t}-list-picture ${t}-list-item, ${t}-list-picture-card ${t}-list-item`]:{borderRadius:"4px",padding:"1px !important",[`${t}-list-item-image`]:{borderRadius:"2px"}}},"&.nb-upload-large":{[`${t}-list-picture-card-container`]:{margin:"0 3px 3px 0 !important",height:"160px !important",width:"160px !important",marginBlock:"0 28px !important"}},"&.nb-upload":{[`${t}-list-item, ${t}-list-item-list-type-picture-card`]:{padding:"3px !important"},[`${t}-list-item-thumbnail`]:{img:{objectFit:"cover !important"}},[`${t}-list-item-actions`]:{left:"auto !important",right:"2px !important",top:"2px !important",transform:"none !important",width:"fit-content !important",[`${o}-btn-text:hover, ${o}-btn-text:focus`]:{background:"rgba(0, 0, 0, 0.4)"}},[`${t}-list-picture-card ${t}-list-item-info`]:{overflow:"inherit",width:"100%",height:"100%"},[`${t}-list-picture-card ${t}-list-item-name`]:{display:"block !important",marginTop:"10px",fontSize:"13px",color:"#636363"},[`${t}-list-picture-card ${t}-list-item::before`]:{display:"none !important"},[`${t}-list-picture-card ${t}-list-item-progress`]:{bottom:"calc(50% - 11px)",left:`${e.margin/2}px`,pointerEvents:"none"},[`${o}-btn`]:{background:"rgba(0, 0, 0, 0.5)"},[`${t}-list-picture-card-container`]:{marginBlock:"0 28px !important"}},[`${t}-list-item-error`]:{[`${t}-list-item-info img`]:{opacity:.6}},[`${t}-drag`]:{[`${t}-drag-container`]:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",height:"100%",ul:{color:e.colorTextSecondary,[`${t}-hint`]:{textAlign:"left"}}}}}}}),useUploadStyles=useStyles$8;attachmentFileTypes.add({match(e){return matchMimetype(e,"image/*")},getThumbnailURL(e){return e.url?`${e.url}${e.thumbnailRule||""}`:e.originFileObj?URL.createObjectURL(e.originFileObj):null},Previewer({index:e,list:t,onSwitchIndex:o}){var r,i,n,a;const l=(0,import_react2.useCallback)(c=>{c.preventDefault();const u=t[e];(0,import_file_saver.saveAs)(u.url,`${u.title}${u.extname}`)},[e,t]);return(0,import_jsx_runtime.jsx)(import_react_image_lightbox.default,{mainSrc:(r=t[e])==null?void 0:r.url,nextSrc:(i=t[(e+1)%t.length])==null?void 0:i.url,prevSrc:(n=t[(e+t.length-1)%t.length])==null?void 0:n.url,onCloseRequest:()=>o(null),onMovePrevRequest:()=>o((e+t.length-1)%t.length),onMoveNextRequest:()=>o((e+1)%t.length),imageTitle:(a=t[e])==null?void 0:a.title,toolbarButtons:[(0,import_jsx_runtime.jsx)("button",{style:{fontSize:22,background:"none",lineHeight:1},type:"button","aria-label":"Download",title:"Download",className:"ril-zoom-in ril__toolbarItemChild ril__builtinButton",onClick:l,children:(0,import_jsx_runtime.jsx)(import_icons.DownloadOutlined,{})},"preview-img")]})}});const iframePreviewSupportedTypes=["application/pdf","audio/*","image/*","video/*"];function IframePreviewer({index:e,list:t,onSwitchIndex:o}){const{t:r}=(0,import_react_i18next.useTranslation)(),i=t[e],n=(0,import_react2.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),window.open(i.url)},[i]),a=(0,import_react2.useCallback)(c=>{c.preventDefault(),c.stopPropagation(),(0,import_file_saver.saveAs)(i.url,`${i.title}${i.extname}`)},[i]),l=(0,import_react2.useCallback)(()=>{o(null)},[o]);return(0,import_jsx_runtime.jsx)(import_antd.Modal,{open:e!=null,title:i.title,onCancel:l,footer:[(0,import_jsx_runtime.jsx)(import_antd.Button,{onClick:n,children:r("Open in new window")},"open"),(0,import_jsx_runtime.jsx)(import_antd.Button,{onClick:a,children:r("Download")},"download"),(0,import_jsx_runtime.jsx)(import_antd.Button,{onClick:l,children:r("Close")},"close")],width:"85vw",centered:!0,children:(0,import_jsx_runtime.jsx)("div",{style:{maxWidth:"100%",maxHeight:"calc(100vh - 256px)",height:"90vh",width:"100%",background:"white",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflowY:"auto"},children:iframePreviewSupportedTypes.some(c=>matchMimetype(i,c))?(0,import_jsx_runtime.jsx)("iframe",{src:i.url,style:{width:"100%",maxHeight:"90vh",flex:"1 1 auto",border:"none"}}):(0,import_jsx_runtime.jsx)(import_antd.Alert,{type:"warning",description:r("File type is not supported for previewing, please download it to preview."),showIcon:!0})})})}function InternalUpload(e){const t=e,{onChange:o}=t,r=W(t,["onChange"]),i=(0,import_react2.useCallback)(n=>{o==null||o(toFileList(n.fileList))},[o]);return(0,import_jsx_runtime.jsx)(import_antd.Upload,P(x({},useUploadProps(r)),{onChange:i}))}function ReadPretty$9({value:e,onChange:t,disabled:o,multiple:r,size:i}){const{wrapSSR:n,hashId:a,componentCls:l}=useStyles$8();return(import_style2.default.default?import_style2.default.default:import_style2.default)(l),n((0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${l}-wrapper`,`${l}-picture-card-wrapper`,"nb-upload",i?`nb-upload-${i}`:null,a),children:(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${l}-list`,`${l}-list-picture-card`),children:(0,import_jsx_runtime.jsx)(AttachmentList,{disabled:o,readPretty:!0,multiple:r,value:e,onChange:t})})}))}const Upload=(0,import_react.connect)(InternalUpload,(0,import_react.mapProps)({value:"fileList"}),(0,import_react.mapReadPretty)(ReadPretty$9));Upload.ReadPretty=ReadPretty$9;function useSizeHint(e){const t=e??FILE_SIZE_LIMIT_DEFAULT,{t:o,i18n:r}=(0,import_react_i18next.useTranslation)(),i=(0,import_filesize.default)(t,{base:2,standard:"jedec",locale:r.language});return t!==0?o("File size should not exceed {{size}}.",{size:i}):""}function DefaultThumbnailPreviewer({file:e}){var t;const{componentCls:o}=useStyles$8(),{getThumbnailURL:r=getThumbnailPlaceholderURL}=(t=attachmentFileTypes.getTypeByFile(e))!=null?t:{},i=r(e);return(0,import_jsx_runtime.jsx)("img",{src:i,alt:e.title,className:`${o}-list-item-image`})}function AttachmentListItem(e){var t,o;const{file:r,disabled:i,onPreview:n,onDelete:a,readPretty:l}=e,{componentCls:c}=useStyles$8(),{t:u}=(0,import_react_i18next.useTranslation)(),d=(0,import_react2.useCallback)(v=>{v.preventDefault(),v.stopPropagation(),n==null||n(r)},[r,n]),m=(0,import_react2.useCallback)(()=>{a==null||a(r)},[r,a]),p=(0,import_react2.useCallback)(()=>{(0,import_file_saver.saveAs)(r.url,`${r.title}${r.extname}`)},[r]),{ThumbnailPreviewer:g=DefaultThumbnailPreviewer}=(t=attachmentFileTypes.getTypeByFile(r))!=null?t:{},h=[(0,import_jsx_runtime.jsx)("span",{className:`${c}-list-item-thumbnail`,children:(0,import_jsx_runtime.jsx)(g,{file:r})},"thumbnail"),(0,import_jsx_runtime.jsx)("span",{className:`${c}-list-item-name`,title:r.title,children:r.status==="uploading"?u("Uploading"):r.title},"title")],f=r.url?(0,import_jsx_runtime.jsx)("a",{target:"_blank",rel:"noopener noreferrer",href:r.url,onClick:d,children:h}):(0,import_jsx_runtime.jsx)("span",{className:`${c}-span`,children:h}),_=(0,import_jsx_runtime.jsxs)("div",{className:(0,import_classnames.default)(`${c}-list-item`,`${c}-list-item-${(o=r.status)!=null?o:"done"}`,`${c}-list-item-list-type-picture-card`),children:[(0,import_jsx_runtime.jsx)("div",{className:`${c}-list-item-info`,children:f}),(0,import_jsx_runtime.jsx)("span",{className:`${c}-list-item-actions`,children:(0,import_jsx_runtime.jsxs)(import_antd.Space,{size:3,children:[!l&&r.url&&(0,import_jsx_runtime.jsx)(import_antd.Button,{size:"small",type:"text",icon:(0,import_jsx_runtime.jsx)(import_icons.DownloadOutlined,{}),onClick:p}),!l&&!i&&r.status!=="uploading"&&(0,import_jsx_runtime.jsx)(import_antd.Button,{size:"small",type:"text",icon:(0,import_jsx_runtime.jsx)(import_icons.DeleteOutlined,{}),onClick:m})]})}),r.status==="uploading"&&(0,import_jsx_runtime.jsx)("div",{className:`${c}-list-item-progress`,children:(0,import_jsx_runtime.jsx)(import_antd.Progress,{strokeWidth:4,type:"line",showInfo:!1,percent:Number(r.percent)})})]});return(0,import_jsx_runtime.jsx)("div",{className:`${c}-list-picture-card-container ${c}-list-item-container`,children:r.status==="error"?(0,import_jsx_runtime.jsx)(import_antd.Tooltip,{title:r.response,getPopupContainer:v=>v.parentNode,children:_}):_})}function Previewer({index:e,onSwitchIndex:t,list:o}){var r;if(e==null)return null;const i=o[e],{Previewer:n=IframePreviewer}=(r=attachmentFileTypes.getTypeByFile(i))!=null?r:{};return(0,import_jsx_runtime.jsx)(n,{index:e,list:o,onSwitchIndex:t})}function AttachmentList(e){const{disabled:t,multiple:o,value:r,onChange:i,readPretty:n}=e,[a,l]=(0,import_react2.useState)([]),[c,u]=(0,import_react2.useState)(null);(0,import_react2.useEffect)(()=>{const p=toFileList(r);l(p)},[r]);const d=(0,import_react2.useCallback)(p=>{const g=a.findIndex(h=>h.id===p.id);u(g)},[a]),m=(0,import_react2.useCallback)(p=>{i(o?r.filter(g=>g.id!==p.id):null)},[o,i,r]);return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[a.map((p,g)=>(0,import_jsx_runtime.jsx)(AttachmentListItem,{file:p,index:g,disabled:t,onPreview:d,onDelete:m,readPretty:n},p.id||p.url)),(0,import_jsx_runtime.jsx)(Previewer,{index:c,onSwitchIndex:u,list:a})]})}function Uploader(e){var t=e,{rules:o}=t,r=W(t,["rules"]);const{disabled:i,multiple:n,value:a,onChange:l,toValueItem:c=toValueItem}=r,[u,d]=(0,import_react2.useState)([]),[m,p]=(0,import_react2.useState)([]),{t:g}=(0,import_react_i18next.useTranslation)(),{componentCls:h}=useStyles$8(),f=(0,import_react.useField)(),_=useUploadProps(r),v=useBeforeUpload(o);(0,import_react2.useEffect)(()=>{m.length?f.setFeedback({type:"error",code:"ValidateError",messages:[g("Incomplete uploading files need to be resolved")]}):f.setFeedback({})},[f,m]);const C=(0,import_react2.useCallback)(z=>{var B;const L=z.fileList.filter(D=>D.status!=="done").map(normalizeFile);if(p(L),n){const D=z.fileList.filter(T=>T.status==="done");if(D.length){const T=[...u,...D.map($=>{var w;return c((w=$.response)==null?void 0:w.data)})];L.length?d(T):(l==null||l([...a,...T]),d([]))}}else{const D=z.fileList.find(T=>T.uid===z.file.uid);D.status==="done"&&(l==null||l(c((B=D.response)==null?void 0:B.data)),p([]))}},[n,a,u,c,l]),S=(0,import_react2.useCallback)(z=>{p(B=>{const L=B.indexOf(z);return B.splice(L,1),[...B]})},[]),b=(0,import_react2.useCallback)(z=>{d(B=>{const L=B.indexOf(z);return B.splice(L,1),[...B]})},[]),y=useComponent("QRCodeUploader"),{mimetype:F,size:j}=o??{},k=useSizeHint(j),R=!i&&(n||(!a||Array.isArray(a)&&!a.length)&&!m.length);return(0,import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment,{children:[u.map((z,B)=>(0,import_jsx_runtime.jsx)(AttachmentListItem,{file:z,index:B,disabled:i,onDelete:b},z.id)),m.map((z,B)=>(0,import_jsx_runtime.jsx)(AttachmentListItem,{file:z,index:B,disabled:i,onDelete:S},z.uid)),(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${h}-list-picture-card-container`,`${h}-list-item-container`),style:R?{}:{display:"none"},children:(0,import_jsx_runtime.jsx)(import_antd.Tooltip,{title:k,children:(0,import_jsx_runtime.jsx)(import_antd.Upload,P(x({accept:F},_),{disabled:i,multiple:n,listType:"picture-card",fileList:m,beforeUpload:v,onChange:C,showUploadList:!1,children:R?(0,import_jsx_runtime.jsxs)("span",{children:[(0,import_jsx_runtime.jsx)(import_icons.PlusOutlined,{}),(0,import_jsx_runtime.jsx)("br",{})," ",g("Upload")]}):null}))})}),R&&y&&(0,import_jsx_runtime.jsx)(y,{disabled:i,multiple:n,value:a,onChange:l})]})}function Attachment(e){const{wrapSSR:t,hashId:o,componentCls:r}=useStyles$8();return t((0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${r}-wrapper`,`${r}-picture-card-wrapper`,"nb-upload",o),children:(0,import_jsx_runtime.jsxs)("div",{className:(0,import_classnames.default)(`${r}-list`,`${r}-list-picture-card`),children:[(0,import_jsx_runtime.jsx)(AttachmentList,x({},e)),(0,import_jsx_runtime.jsx)(Uploader,x({},e))]})}))}Attachment.ReadPretty=ReadPretty$9;Upload.Attachment=withDynamicSchemaProps((0,import_react.connect)(Attachment,(0,import_react.mapReadPretty)(Attachment.ReadPretty)),{displayName:"Upload.Attachment"});Upload.Dragger=(0,import_react.connect)(e=>{const t=e,{tipContent:o,onChange:r}=t,i=W(t,["tipContent","onChange"]),{wrapSSR:n,hashId:a,componentCls:l}=useStyles$8(),c=(0,import_react2.useCallback)(u=>{r==null||r(toFileList(u.fileList))},[r]);return n((0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${l}-dragger`,a),children:(0,import_jsx_runtime.jsxs)(import_antd.Upload.Dragger,P(x({},useUploadProps(i)),{onChange:c,children:[o,e.children]}))}))},(0,import_react.mapProps)({value:"fileList"}));Upload.DraggerV2=withDynamicSchemaProps((0,import_react.connect)(e=>{var t=e,{rules:o}=t,r=W(t,["rules"]);const{t:i}=(0,import_react_i18next.useTranslation)(),n=i("Click or drag file to this area to upload"),a=useProps(r),{title:l=n}=a,c=W(a,["title"]),[u,d]=(0,import_react2.useState)(!1),{wrapSSR:m,hashId:p,componentCls:g}=useStyles$8(),h=useBeforeUpload(o),{size:f,mimetype:_}=o??{},v=useSizeHint(f),C=(0,import_react2.useCallback)(({fileList:S})=>{const{onChange:b}=c;b==null||b(S),S.some(y=>y.status==="uploading")?d(!0):d(!1)},[c]);return m((0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${g}-dragger`,p),children:(0,import_jsx_runtime.jsxs)(import_antd.Upload.Dragger,P(x({},useUploadProps(P(x(x({},r),c),{accept:_,onChange:C,beforeUpload:h}))),{children:[(0,import_jsx_runtime.jsx)("p",{className:`${g}-drag-icon`,children:u?(0,import_jsx_runtime.jsx)(import_icons.LoadingOutlined,{style:{fontSize:36},spin:!0}):(0,import_jsx_runtime.jsx)(import_icons.InboxOutlined,{})}),(0,import_jsx_runtime.jsx)("p",{className:`${g}-text`,children:l}),(0,import_jsx_runtime.jsxs)("ul",{children:[(0,import_jsx_runtime.jsx)("li",{className:`${g}-hint`,children:i("Support for a single or bulk upload.")}),(0,import_jsx_runtime.jsx)("li",{className:`${g}-hint`,children:v})]})]}))}))},(0,import_react.mapProps)({value:"fileList"})),{displayName:"Upload.DraggerV2"});const schema$1={Nester:{type:"void","x-component":"AssociationField.Nester",properties:{grid:{type:"void","x-component":"Grid","x-initializer":"form:configureFields"}}},AddNewer:{type:"void","x-component":"AssociationField.AddNewer","x-action":"create",title:'{{ t("Add record") }}',"x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab","x-initializer-props":{gridInitializer:"popup:addNew:addBlock"},properties:{tab1:{type:"void",title:'{{t("Add new")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:addNew:addBlock",properties:{}}}}}}}},Selector:{type:"void","x-component":"AssociationField.Selector",title:'{{ t("Select record") }}',"x-component-props":{className:"nb-record-picker-selector"},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:tableSelector:addBlock",properties:{}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"usePickActionProps","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:submit","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}},Viewer:{type:"void",title:'{{ t("View record") }}',"x-component":"AssociationField.Viewer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock",properties:{}}}}}}}},SubTable:{type:"void","x-component":"AssociationField.SubTable","x-initializer":"table:configureColumns","x-initializer-props":{action:!1},properties:{}}},useTableSelectorProps$3=()=>{const e=(0,import_react.useField)(),{multiple:t,options:o=[],setSelectedRows:r,selectedRows:i=[],onChange:n}=(0,import_react2.useContext)(RecordPickerContext),a=useTableSelectorProps$4(),{onRowSelectionChange:l,rowKey:c="id"}=a,u=W(a,["onRowSelectionChange","rowKey"]),{setVisible:d}=useActionContext();return P(x({},u),{rowKey:c,rowSelection:{type:t?"checkbox":"radio",selectedRowKeys:i==null?void 0:i.filter(m=>o.every(p=>p[c]!==m[c])).map(m=>m[c])},onRowSelectionChange(m,p){if(t){const g=flatData$2(e.value)||[],h=(0,import_lodash.differenceBy)(i||[],g,c),f=(0,import_lodash.unionBy)(h,p,c),_=f.map(v=>v[c]);r==null||r(f),l==null||l(_,f)}else r==null||r(p),l==null||l(m,p),n((p==null?void 0:p[0])||null),d(!1)}})};function FileSelector(e){const t=e,{disabled:o,multiple:r,value:i,onChange:n,action:a,onSelect:l,quickUpload:c,selectFile:u}=t,d=W(t,["disabled","multiple","value","onChange","action","onSelect","quickUpload","selectFile"]),{wrapSSR:m,hashId:p,componentCls:g}=useStyles$8(),{useFileCollectionStorageRules:h,useAttachmentFieldProps:f}=(0,import_react.useExpressionScope)(),{t:_}=(0,import_react_i18next.useTranslation)(),v=h(),C=f(),S=u===void 0&&c===void 0;return m((0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${g}-wrapper`,`${g}-picture-card-wrapper`,"nb-upload",p),children:(0,import_jsx_runtime.jsxs)("div",{className:(0,import_classnames.default)(`${g}-list`,`${g}-list-picture-card`),children:[(0,import_jsx_runtime.jsx)(AttachmentList,{disabled:o,multiple:r,value:i,onChange:n}),S?(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${g}-list-picture-card-container`,`${g}-list-item-container`),children:(0,import_jsx_runtime.jsx)(import_antd.Upload,{disabled:o,multiple:r,listType:"picture-card",showUploadList:!1,children:(0,import_jsx_runtime.jsxs)("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},onClick:l,children:[(0,import_jsx_runtime.jsx)(import_icons.PlusOutlined,{}),_("Select")]})})}):null,c?(0,import_jsx_runtime.jsx)(Uploader,x(P(x({},C),{value:i,multiple:r,onChange:n,action:a,rules:v,disabled:o}),d)):null,u&&(r||!i)?(0,import_jsx_runtime.jsx)("div",{className:(0,import_classnames.default)(`${g}-list-picture-card-container`,`${g}-list-item-container`),children:(0,import_jsx_runtime.jsx)(import_antd.Upload,{disabled:o,multiple:r,listType:"picture-card",showUploadList:!1,children:(0,import_jsx_runtime.jsxs)("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},onClick:l,children:[(0,import_jsx_runtime.jsx)(import_icons.PlusOutlined,{}),_("Select")]})})}):null]})}))}const InternalFileManager=e=>{var t,o;const r=e,{value:i,multiple:n,onChange:a}=r,l=W(r,["value","multiple","onChange"]),c=(0,import_react.useFieldSchema)(),[u,d]=(0,import_react2.useState)(!1),[m,p]=(0,import_react2.useState)([]),g=useInsertSchema$1("Selector"),h=useFieldNames$1(e),{designable:f}=useDesignable(),_=(0,import_react.useField)(),[v,C]=(0,import_react2.useState)([]),{getField:S}=useCollection_deprecated(),b=S(_.props.name),y=useLabelUiSchema$1(b==null?void 0:b.target,(h==null?void 0:h.label)||"label"),F=useCompile(),{modalProps:j}=useActionContext(),k=B=>{B.stopPropagation(),B.preventDefault(),f?g(schema$1.Selector):c.reduceProperties((L,D)=>D["x-component"]==="AssociationField.Selector"?D:L,null)||c.addProperty("selector",schema$1.Selector),d(!0),p([])};(0,import_react2.useEffect)(()=>{if(i&&Object.keys(i).length>0){const B=(Array.isArray(i)?i:i?[i]:[]).filter(Boolean).map(L=>{const D=L[h.label];return P(x({},L),{[h.label]:getLabelFormatValue$1(F(y),F(D))})});C(B)}else C([])},[i,h==null?void 0:h.label]);const R={size:"small",fieldNames:h,multiple:["o2m","m2m","mbm"].includes(b==null?void 0:b.interface)&&n,association:{target:b==null?void 0:b.target},options:v,onChange:e==null?void 0:e.onChange,selectedRows:m,setSelectedRows:p,collectionField:b},z=()=>{const{setVisible:B}=useActionContext(),{multiple:L,selectedRows:D,onChange:T,options:$,collectionField:w}=(0,import_react2.useContext)(RecordPickerContext);return{onClick(){T(L?(0,import_lodash.unionBy)(D,$,(w==null?void 0:w.targetKey)||"id"):(D==null?void 0:D[0])||null),B(!1)}}};return(0,import_jsx_runtime.jsxs)("div",{style:{width:"100%",overflow:"auto"},children:[(0,import_jsx_runtime.jsx)(FileSelector,P(x({},l),{value:n?v:v==null?void 0:v[0],multiple:n,quickUpload:((t=c["x-component-props"])==null?void 0:t.quickUpload)!==!1,selectFile:((o=c["x-component-props"])==null?void 0:o.selectFile)!==!1,action:`${b==null?void 0:b.target}:create`,onSelect:k,onChange:a})),(0,import_jsx_runtime.jsx)(ActionContextProvider,{value:{openMode:"drawer",visible:u,setVisible:d,modalProps:{getContainer:(l==null?void 0:l.getContainer)||(j==null?void 0:j.getContainer)},formValueChanged:!1},children:(0,import_jsx_runtime.jsx)(RecordPickerProvider,P(x({},R),{children:(0,import_jsx_runtime.jsx)(CollectionProvider_deprecated,{name:b==null?void 0:b.target,children:(0,import_jsx_runtime.jsx)(FormProvider,{children:(0,import_jsx_runtime.jsx)(TableSelectorParamsProvider,{params:{},children:(0,import_jsx_runtime.jsx)(SchemaComponentOptions,{scope:{usePickActionProps:z,useTableSelectorProps:useTableSelectorProps$3},children:(0,import_jsx_runtime.jsx)(NocoBaseRecursionField,{onlyRenderProperties:!0,basePath:_.address,schema:c,filterProperties:B=>B["x-component"]==="AssociationField.Selector"})})})})})}))})]})},FileManageReadPretty=(0,import_react.connect)(e=>{const t=(0,import_react.useFieldSchema)(),{getField:o}=useCollection_deprecated(),{getCollectionJoinField:r}=useCollectionManager_deprecated(),i=o(t.name)||r(t["x-collection-field"]);return(0,import_jsx_runtime.jsx)(EllipsisWithTooltip,{ellipsis:!0,children:i?(0,import_jsx_runtime.jsx)(Upload.ReadPretty,x({},e)):null})}),EMPTY="N/A",SchemaField=(0,import_react.createSchemaField)({components:{Space:import_antd.Space,Input:import_antd.Input,ArrayItems:import_antd_v5.ArrayItems,FormItem:import_antd_v5.FormItem}}),CascadeSelect=(0,import_react.connect)(e=>{var t;const{data:o,mapOptions:r,onChange:i,value:n}=e,[a,l]=(0,import_react2.useState)([{key:void 0,children:[],value:null}]),[c,u]=(0,import_react2.useState)(o),[d,m]=(0,import_react2.useState)(!1),p=useCompile(),g=useAPIClient(),h=useServiceOptions$1(e),{options:f,field:_}=useAssociationFieldContext(),v=g.resource(f.target),{getCollectionJoinField:C,getInterface:S}=useCollectionManager_deprecated(),b=(t=_==null?void 0:_.componentProps)==null?void 0:t.fieldNames,y=(f==null?void 0:f.target)&&(b==null?void 0:b.label)&&C(`${f.target}.${b.label}`),F=(0,import_react2.useMemo)(()=>{var D,T;return y!=null&&y.interface&&((T=(D=S(y.interface))==null?void 0:D.filterable)==null?void 0:T.operators[0].value)||"$includes"},[y]),j=(0,import_react.useField)();(0,import_react2.useEffect)(()=>{var D;if(n){const T=Array.isArray(n)?extractLastNonNullValueObjects(n==null?void 0:n.filter(w=>w.value),!0):transformNestedData(n),$=(D=T==null?void 0:T.map)==null?void 0:D.call(T,w=>({key:w.parentId,children:[],value:w}));l($)}},[]);const k=(0,import_react2.useCallback)(D=>{try{return D==null?void 0:D.filter(T=>["number","string"].includes(typeof T[b.value])).map(T=>{var $,w,I;let N=p(T[b.label]);if(($=y==null?void 0:y.uiSchema)!=null&&$.enum)if(Array.isArray(N))N=N.map((M,O)=>{var E,U;const V=(U=(E=y.uiSchema.enum).find)==null?void 0:U.call(E,G=>G.value===M);return V?(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:V.color,style:{marginRight:3},children:(V==null?void 0:V.label)||M},O):(0,import_jsx_runtime.jsx)(import_antd.Tag,{children:M},M)}).reverse();else{const M=(I=(w=y.uiSchema.enum).find)==null?void 0:I.call(w,O=>O.value===N);M&&(N=(0,import_jsx_runtime.jsx)(import_antd.Tag,{color:M.color,children:M.label}))}return(y==null?void 0:y.type)==="date"&&(N=(0,import_dayjs.default)(N).format("YYYY-MM-DD")),r?r({[b.label]:N||EMPTY,[b.value]:T[b.value]}):P(x({},T),{[b.label]:N||EMPTY,[b.value]:T[b.value]})}).filter(Boolean)}catch(T){return console.error(T),D}},[y==null?void 0:y.uiSchema,b]),R=D=>q(void 0,null,function*(){var T;const $=yield v.list({pageSize:200,params:h==null?void 0:h.params,filter:mergeFilter([D]),tree:D.parentId?void 0:!0});return(T=$==null?void 0:$.data)==null?void 0:T.data}),z=(D,T,$)=>q(void 0,null,function*(){const w=yield R({parentId:T==null?void 0:T.id}),I=[...a];if(I.splice($+1),I[$]=P(x({},I[$]),{value:T}),T!=null&&T.id&&(I[$+1]={key:T==null?void 0:T.id,children:(w==null?void 0:w.length)>0?w:null}),l(I),["o2m","m2m"].includes(f.interface)){const N=Array.isArray(_.fieldValue)?_.fieldValue:[];N[j.index]=T,_.fieldValue=N}else _.value=T;i==null||i(I)}),B=(D,T,$)=>q(void 0,null,function*(){var w,I,N;if(D){m(!0);const M=yield R({parentId:T==null?void 0:T.key});if(m(!1),u(M),$===(a==null?void 0:a.length)-1&&(w=T==null?void 0:T.value)!=null&&w.id){const O=yield R({parentId:(I=T==null?void 0:T.value)==null?void 0:I.id}),E=[...a];E.splice($+1),E[$]=P(x({},E[$]),{value:T==null?void 0:T.value}),E[$+1]={key:(N=T==null?void 0:T.value)==null?void 0:N.id,children:(O==null?void 0:O.length)>0?O:null},l(E),i==null||i(E)}}}),L=(D,T)=>q(void 0,null,function*(){const $=D?{[b.label]:{[F]:D}}:{};m(!0);const w=yield R(P(x({},$),{parentId:T==null?void 0:T.key}));m(!1),u(w)});return(0,import_jsx_runtime.jsx)(import_antd.Space,{wrap:!0,children:a.map((D,T)=>{var $,w,I;return D.children&&(0,import_jsx_runtime.jsx)(import_antd.Select,{disabled:_.disabled,allowClear:!0,showSearch:!0,autoClearSearchValue:!0,filterOption:!1,filterSort:null,defaultValue:{label:($=D==null?void 0:D.value)==null?void 0:$[b.label],value:(w=D==null?void 0:D.value)==null?void 0:w[b.value]},labelInValue:!0,onSearch:N=>L(N,D),fieldNames:b,style:{minWidth:150},onChange:(N,M)=>z(N,M,T),options:d?[]:k(c),onDropdownVisibleChange:N=>B(N,D,T),notFoundContent:d?(0,import_jsx_runtime.jsx)(import_antd.Spin,{size:"small"}):null},`${(I=D.value)==null?void 0:I.id}+ ${D.key} + ${b.label}`)})})}),AssociationCascadeSelect=(0,import_react.connect)(e=>(0,import_jsx_runtime.jsx)("div",{children:(0,import_jsx_runtime.jsx)(CascadeSelect,x({},e))})),InternalCascadeSelect=(0,import_react.observer)(e=>{var t;const{options:o}=useAssociationFieldContext(),r=(0,import_react2.useMemo)(()=>(0,import_core2.createForm)(),[]),{t:i}=(0,import_react_i18next.useTranslation)(),n=(0,import_react.useField)(),a=(0,import_react.useFieldSchema)(),{loading:l,data:c}=useDataBlockRequest()||{},u=(t=c==null?void 0:c.data)==null?void 0:t[a.name];(0,import_react2.useEffect)(()=>{const m=(0,import_shared.uid)();return r.addEffects(m,()=>{(0,import_core2.onFormValuesChange)(p=>{var g,h;if(o.interface==="m2o"){const f=extractLastNonNullValueObjects((g=p.values)==null?void 0:g[a.name]);setTimeout(()=>{p.setValuesIn(a.name,f),n.value=f})}else{const f=extractLastNonNullValueObjects((h=p.values)==null?void 0:h.select_array).filter(_=>_&&Object.keys(_).length>0);setTimeout(()=>{n.value=f})}})}),()=>{r.removeEffects(m)}},[]);const d={type:"object",properties:{select_array:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",default:Array.isArray(u)&&u.length>0?u:[{}],items:{type:"void","x-component":"Space",properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},select:{type:"string","x-decorator":"FormItem","x-component":AssociationCascadeSelect,"x-component-props":x({},e)},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:i("Add new"),"x-component":"ArrayItems.Addition"}}}}};return!l&&(0,import_jsx_runtime.jsx)(import_react.FormProvider,{form:r,children:o.interface==="m2o"?(0,import_jsx_runtime.jsx)(SchemaComponent,{components:{FormItem:import_antd_v5.FormItem},schema:P(x({},a),{default:u,title:"","x-component":AssociationCascadeSelect,"x-component-props":x({},e)})}):(0,import_jsx_runtime.jsx)(SchemaField,{schema:d})})},{displayName:"InternalCascadeSelect"});function extractLastNonNullValueObjects(e,t){var o,r;let i=[];if(!Array.isArray(e))return e;for(const n of e){let a=null;if(Array.isArray(n)){for(let l=(n==null?void 0:n.length)-1;l>=0;l--)if(n[l].value){a=n[l].value;break}a&&i.push(a)}else n!=null&&n.value?a=n.value:a=null,a?t?(o=i==null?void 0:i.push)==null||o.call(i,a):i=a:(r=i==null?void 0:i.push)==null||r.call(i,n)}return i}function transformNestedData(e){const t=[];function o(r){if(r!=null&&r.parent){const{parent:a}=r;o(a)}const i=r,n=W(i,["parent"]);t.push(n)}return e&&o(e),t}const InternalNesterCss=import_css.css`
|
|
628
628
|
& .ant-formily-item-layout-vertical {
|
|
629
629
|
margin-bottom: 10px;
|
|
630
630
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/client",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.13",
|
|
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.13",
|
|
31
|
+
"@nocobase/sdk": "1.5.13",
|
|
32
|
+
"@nocobase/utils": "1.5.13",
|
|
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": "60008474fbdd9238debfd10be248b579d288ab93"
|
|
85
85
|
}
|