@firecms/core 3.0.0-canary.47 → 3.0.0-canary.49
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/dist/index.es.js +303 -307
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
- package/src/core/EntityEditView.tsx +0 -1
- package/src/form/EntityForm.tsx +0 -5
package/dist/index.umd.js
CHANGED
|
@@ -585,5 +585,5 @@
|
|
|
585
585
|
.rc-md-editor .header-list .list-item:hover {
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
-
`;function In({propertyKey:e,value:t,error:o,showError:a,isSubmitting:n,setValue:i,tableMode:s,property:l,includeDescription:c,underlyingValueHasChanged:u,context:m,disabled:g}){if(!Array.isArray(l.resolvedProperties))throw Error("ArrayCustomShapedFieldBinding misconfiguration. Property `of` not set");const f=l.expanded===void 0?!0:l.expanded;Te({property:l,value:t,setValue:i});const h=r.jsx(Ee,{icon:_e(l,"small"),required:l.validation?.required,className:"text-text-secondary dark:text-text-secondary-dark",title:l.name}),b=l.resolvedProperties.map((y,A)=>{const k={propertyKey:`${e}[${A}]`,disabled:g,property:y,includeDescription:c,underlyingValueHasChanged:u,context:m,tableMode:!1,partOfArray:!0,partOfBlock:!1,autoFocus:!1};return r.jsx("div",{className:"pb-4",children:r.jsx(ot,{...k})},`custom_shaped_array_${A}`)});return r.jsxs(r.Fragment,{children:[!s&&r.jsx(p.ExpandablePanel,{initiallyExpanded:f,title:h,className:"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2",children:b}),s&&b,r.jsx(Ce,{includeDescription:c,showError:a,error:o,disabled:g,property:l})]})}const $l=({containerRef:e})=>{const{isSubmitting:t,isValidating:o,errors:a}=ve.useFormex();return d.useEffect(()=>{const n=Object.keys(a);if(n.length>0&&t&&!o){const i=e?.current?.querySelector(`#form_field_${n[0]}`);if(i&&e?.current){const s=Fn(e.current);if(s){const c=i.getBoundingClientRect().top;s.scrollTo({top:s.scrollTop+c-196,behavior:"smooth"})}const l=i.querySelector("input");l&&l.focus()}}},[t,o,a,e]),null},ql=e=>{const t=e&&e.scrollHeight>e.clientHeight,o=e?window.getComputedStyle(e).overflowY:null,a=o&&o.indexOf("hidden")!==-1;return t&&!a},Fn=e=>!e||e===document.body?document.body:ql(e)?e:Fn(e.parentNode);function Wl({customId:e,entityId:t,status:o,onChange:a,error:n,entity:i,loading:s}){const{errors:l}=ve.useFormex(),c=o==="existing"||!e,u=o!=="existing"&&!e,m=d.useMemo(()=>{if(!(!e||typeof e=="boolean"||e==="optional"))return qe(e)},[e]),g=He(),{copy:f}=ha({onSuccess:y=>g.open({type:"success",message:`Copied ${y}`})}),h=oe(),b={label:u?"ID is set automatically":"ID",disabled:c||s,name:"id",value:(i&&o==="existing"?i.id:t)??"",endAdornment:s?r.jsx(p.CircularProgress,{size:"small"}):i?r.jsxs(r.Fragment,{children:[r.jsx(p.Tooltip,{title:"Copy",children:r.jsx(p.IconButton,{onClick:y=>f(i.id),"aria-label":"copy-id",children:r.jsx(p.ContentCopyIcon,{size:"small"})})}),h?.entityLinkBuilder&&r.jsx(p.Tooltip,{title:"Open in the console",children:r.jsx(p.IconButton,{component:"a",href:h.entityLinkBuilder({entity:i}),rel:"noopener noreferrer",target:"_blank",onClick:y=>y.stopPropagation(),"aria-label":"go-to-datasource",children:r.jsx(p.OpenInNewIcon,{size:"small"})})})]}):void 0};return r.jsxs(r.Fragment,{children:[m&&r.jsx(p.Select,{error:n,onValueChange:y=>a(y),...b,renderValue:y=>{const A=m.find(k=>k.id===y);return A?`${A.id} - ${A.label}`:y},children:m.map(y=>r.jsx(p.SelectItem,{value:String(y.id),children:r.jsx(Ie,{enumKey:y.id,enumValues:m,size:"medium"})},y.id))}),!m&&r.jsx(p.TextField,{...b,error:n,placeholder:e==="optional"?"Autogenerated ID, it can be manually changed":o==="new"||o==="copy"?"ID of the new document":"ID of the document",onChange:y=>{let A=y.target.value;return A&&(A=A.trim()),a(A.length?A:void 0)}}),l.id&&r.jsx(p.Typography,{variant:"caption",className:"ml-3.5 text-red-500 dark:text-red-500",children:l.id})]})}function Jl({propertyId:e}){const[t,o]=d.useState(!1);return r.jsxs("div",{className:"flex flex-row gap-2 items-center justify-center text-white",children:[r.jsxs("div",{children:[r.jsx(p.Typography,{variant:"caption",className:"min-w-20 text-slate-400",color:"disabled",children:t?"Copied":"Property ID"}),r.jsx(p.Typography,{variant:"caption",className:"text-white",children:r.jsx("code",{children:e})})]}),r.jsx(p.IconButton,{size:"small",children:r.jsx(p.ContentPasteIcon,{size:"smallest",className:"text-white",onClick:d.useCallback(()=>{navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)},[e])})})]})}const Nn=Hl;function Pn(e,t,o){const a=e.properties;if((t==="existing"||t==="copy")&&o)return o.values??kt(a);if(t==="new")return kt(a);throw console.error({status:t,entity:o}),new Error("Form has not been initialised with the correct parameters")}function Hl({status:e,path:t,collection:o,entity:a,onEntitySaveRequested:n,onDiscard:i,onModified:s,onValuesChanged:l,onIdChange:c,onFormContextChange:u,hideId:m,autoSave:g,onIdUpdateError:f}){console.log("inputCollection",o);const h=ut(),b=oe(),y=Ae(),A=Me(o),k=b.plugins,v=d.useMemo(()=>Ne({collection:o,path:t,values:a?.values,fields:b.propertyConfigs}),[a?.values,t]),_=(e==="new"||e==="copy")&&!!v.customId&&v.customId!=="optional",E=d.useMemo(()=>e==="new"||e==="copy"?_?void 0:A.generateEntityId(t):a?.id,[]),C=d.useRef(!1),B=d.useRef(Pn(v,e,a)),[x,S]=d.useState(E),[I,D]=d.useState(!1),[P,T]=d.useState(),[V,re]=d.useState(!1),[R,$]=d.useState(a?.values??B.current),G=te=>n({collection:ee,path:t,entityId:x,values:te,previousValues:a?.values,closeAfterSave:C.current,autoSave:g??!1}).then(O=>{const ie=e==="new"?"new_entity_saved":e==="copy"?"entity_copied":e==="existing"?"entity_edited":"unmapped_event";h.onAnalyticsEvent?.(ie,{path:t})}).catch(O=>{console.error(O),T(O)}).finally(()=>{C.current=!1}),z=(te,O)=>{if(_&&!x){console.error("Missing custom Id"),D(!0),O.setSubmitting(!1);return}if(T(void 0),D(!1),e==="existing"){if(!a?.id)throw Error("Form misconfiguration when saving, no id for existing entity")}else if(e==="new"||e==="copy"){if(o.customId&&o.customId!=="optional"&&!x)throw Error("Form misconfiguration when saving, entityId should be set")}else throw Error("New FormType added, check EntityForm");return G(te)?.then(ie=>{O.resetForm({values:te,submitCount:0,touched:{}})}).finally(()=>{O.setSubmitting(!1)})},H=ve.useCreateFormex({initialValues:B.current,onSubmit:z,validation:te=>Y?.validate(te,{abortEarly:!1}).then(()=>({})).catch(O=>{const ie={};return O.inner.forEach(fe=>{ie[fe.path]=fe.message}),Xl(O)})});d.useEffect(()=>{B.current=Pn(v,e,a);const te=H.initialValues;!H.isSubmitting&&te&&e==="existing"?Z(Object.entries(ee.properties).map(([O,ie])=>{if(vt(ie))return{};const fe=te[O],ue=B.current[O];return L(fe,ue)?{}:{[O]:ue}}).reduce((O,ie)=>({...O,...ie}),{})):Z({})},[a,v,e]);const J=te=>{const O=H.initialValues;$(te),l&&l(te),g&&te&&!L(te,O)&&G(te)};d.useEffect(()=>{x&&c&&c(x)},[x,c]);const ee=Ne({collection:o,path:t,entityId:x,values:R,previousValues:H.initialValues,fields:b.propertyConfigs});console.log("internalValues",R),console.log("resolvedCollection",ee);const ne=Fr(ee,b.propertyConfigs),U=R&&ne?Ye(R,ne):void 0,X=o.callbacks?.onIdUpdate,Q=d.useCallback(async()=>{if(X&&R&&(e==="new"||e==="copy")){re(!0);try{const te=await X({collection:ee,path:t,entityId:x,values:R,context:y});S(te)}catch(te){f&&f(te),console.error(te)}re(!1)}},[x,R,e]);d.useEffect(()=>{Q()},[Q]);const[K,Z]=d.useState({}),M=d.useCallback(({name:te,value:O,property:ie})=>A.checkUniqueField(t,te,O,x),[A,t,x]),Y=d.useMemo(()=>x?Ua(x,ee.properties,M):void 0,[x,ee.properties,M]),q=We(),F=d.useCallback(({entity:te,customEntityActions:O})=>{const ie=ct(o,q,t,null),fe=te?Wt(o,q,t,te):!0,ue=[];return ie&&ue.push(mn),fe&&ue.push(fn),O&&ue.push(...O),ue},[q,o,t]),N=[],le={setFieldValue:d.useCallback(H.setFieldValue,[]),values:H.values,collection:ee,entityId:x,path:t,save:G},xe=d.useRef(null);if(d.useEffect(()=>{u&&!Kl(xe.current??void 0,le)&&(u(le),xe.current=le)},[le,u]),k&&o){const te={entityId:x,path:t,status:e,collection:o,context:y,currentEntityId:x,formContext:le};N.push(...k.map((O,ie)=>O.form?.Actions?r.jsx(O.form.Actions,{...te},`actions_${O.key}`):null).filter(Boolean))}return r.jsx(ve.Formex,{value:H,children:r.jsxs("div",{className:"h-full overflow-auto",children:[N.length>0&&r.jsx("div",{className:p.cn("w-full flex justify-end items-center sticky top-0 right-0 left-0 z-10 bg-opacity-60 bg-slate-200 dark:bg-opacity-60 dark:bg-slate-800 backdrop-blur-md"),children:N}),r.jsxs("div",{className:"pt-12 pb-16 pl-8 pr-8 md:pl-10 md:pr-10",children:[r.jsxs("div",{className:`w-full py-2 flex flex-col items-start mt-${4+(N?8:0)} lg:mt-${8+(N?8:0)} mb-8`,children:[r.jsx(p.Typography,{className:"mt-4 flex-grow line-clamp-1 "+o.hideIdFromForm?"mb-2":"mb-0",variant:"h4",children:U??o.singularName??o.name}),r.jsx(p.Alert,{color:"base",className:"w-full",size:"small",children:r.jsxs("code",{className:"text-xs select-all",children:[t,"/",x]})})]}),!m&&r.jsx(Wl,{customId:o.customId,entityId:x,status:e,onChange:S,error:I,loading:V,entity:a}),x&&r.jsx(Zl,{...H,initialValues:H.initialValues,onModified:s,onDiscard:i,onValuesChanged:J,underlyingChanges:K,entity:a,resolvedCollection:ee,formContext:le,status:e,savingError:P,closeAfterSaveRef:C,autoSave:g,entityActions:F({entity:a,customEntityActions:o.entityActions})})]})]})})}function Zl(e){const{values:t,onDiscard:o,onModified:a,onValuesChanged:n,underlyingChanges:i,formContext:s,entity:l,touched:c,setFieldValue:u,resolvedCollection:m,isSubmitting:g,status:f,handleSubmit:h,resetForm:b,savingError:y,dirty:A,closeAfterSaveRef:k,autoSave:v,entityActions:_}=e,E=Ae(),C=_.filter(P=>P.includeInForm===void 0||P.includeInForm),B=Je(),x=A;d.useEffect(()=>{a&&a(x),n&&n(t)},[x,t]),d.useEffect(()=>{!v&&!g&&i&&l&&Object.entries(i).forEach(([P,T])=>{const V=t[P];!L(T,V)&&!c[P]&&(console.debug("Updated value from the datasource:",P,T),u(P,T!==void 0?T:null))})},[g,v,i,l,t,c,u]);const S=r.jsx("div",{className:"flex flex-col gap-8",children:(m.propertiesOrder??Object.keys(m.properties)).map(P=>{const T=m.properties[P];if(!T)return console.warn(`Property ${P} not found in collection ${m.name}`),null;const V=!!i&&Object.keys(i).includes(P)&&!!c[P],re=!v&&g||st(T)||!!T.disabled;if(vt(T))return null;const $={propertyKey:P,disabled:re,property:T,includeDescription:T.description||T.longDescription,underlyingValueHasChanged:V&&!v,context:s,tableMode:!1,partOfArray:!1,partOfBlock:!1,autoFocus:!1};return r.jsx("div",{id:`form_field_${P}`,children:r.jsx(ae,{children:r.jsx(p.Tooltip,{title:r.jsx(Jl,{propertyId:P}),delayDuration:800,side:"left",align:"start",sideOffset:16,children:r.jsx(ot,{...$})})})},`field_${m.name}_${P}`)}).filter(Boolean)}),I=g||!x&&f==="existing",D=d.useRef(null);return r.jsxs("form",{onSubmit:h,onReset:()=>(console.debug("Resetting form"),b(),o&&o()),noValidate:!0,children:[r.jsxs("div",{className:"mt-12",ref:D,children:[S,r.jsx($l,{containerRef:D})]}),r.jsx("div",{className:"h-14"}),!v&&r.jsxs(p.DialogActions,{position:"absolute",children:[y&&r.jsx("div",{className:"text-right",children:r.jsx(p.Typography,{color:"error",children:y.message})}),l&&C.length>0&&r.jsx("div",{className:"flex-grow flex overflow-auto no-scrollbar",children:C.map(P=>r.jsx(p.IconButton,{color:"primary",onClick:T=>{T.stopPropagation(),l&&P.onClick({entity:l,fullPath:m.path,collection:m,context:E,sideEntityController:B})},children:P.icon},P.name))}),r.jsx(p.Button,{variant:"text",disabled:I,type:"reset",children:f==="existing"?"Discard":"Clear"}),r.jsxs(p.Button,{variant:"text",color:"primary",type:"submit",disabled:I,onClick:()=>{k.current=!1},children:[f==="existing"&&"Save",f==="copy"&&"Create copy",f==="new"&&"Create"]}),r.jsxs(p.Button,{variant:"filled",color:"primary",type:"submit",disabled:I,onClick:()=>{k.current=!0},children:[f==="existing"&&"Save and close",f==="copy"&&"Create copy and close",f==="new"&&"Create and close"]})]})]})}function Xl(e){let t={};if(e.inner){if(e.inner.length===0)return ve.setIn(t,e.path,e.message);for(const o of e.inner)ve.getIn(t,o.path)||(t=ve.setIn(t,o.path,o.message))}return t}function Kl(e,t){return e?.path===t?.path&&e?.entityId===t?.entityId&&L(e?.values,t?.values)&&L(e?.collection,t?.collection)}function Tn(e){return Object.keys(ir).includes(e)}const ir={text_field:{key:"text_field",name:"Text field",description:"Simple short text",Icon:p.ShortTextIcon,color:"#2d7ff9",property:{dataType:"string",Field:bt}},multiline:{key:"multiline",name:"Multiline",description:"Text with multiple lines",Icon:p.SubjectIcon,color:"#2d7ff9",property:{dataType:"string",multiline:!0,Field:bt}},markdown:{key:"markdown",name:"Markdown",description:"Text with advanced markdown syntax",Icon:p.FormatQuoteIcon,color:"#2d7ff9",property:{dataType:"string",markdown:!0,Field:Sn}},url:{key:"url",name:"Url",description:"Text with URL validation",Icon:p.HttpIcon,color:"#154fb3",property:{dataType:"string",url:!0,Field:bt}},email:{key:"email",name:"Email",description:"Text with email validation",Icon:p.EmailIcon,color:"#154fb3",property:{dataType:"string",email:!0,Field:bt}},switch:{key:"switch",name:"Switch",description:"Boolean true or false field (or yes or no, 0 or 1...)",Icon:p.FlagIcon,color:"#20d9d2",property:{dataType:"boolean",Field:vn}},select:{key:"select",name:"Select/enum",description:"Select one text value from within an enumeration",Icon:p.ListIcon,color:"#4223c9",property:{dataType:"string",enumValues:[],Field:po}},multi_select:{key:"multi_select",name:"Multi select",description:"Select multiple text values from within an enumeration",Icon:p.ListAltIcon,color:"#4223c9",property:{dataType:"array",of:{dataType:"string",enumValues:[]},Field:uo}},number_input:{key:"number_input",name:"Number input",description:"Simple number field with validation",Icon:p.NumbersIcon,color:"#bec920",property:{dataType:"number",Field:bt}},number_select:{key:"number_select",name:"Number select",description:"Select a number value from within an enumeration",Icon:p.FormatListNumberedIcon,color:"#bec920",property:{dataType:"number",enumValues:[],Field:po}},multi_number_select:{key:"multi_number_select",name:"Multiple number select",description:"Select multiple number values from within an enumeration",Icon:p.FormatListNumberedIcon,color:"#bec920",property:{dataType:"array",of:{dataType:"number",enumValues:[]},Field:uo}},file_upload:{key:"file_upload",name:"File upload",description:"Input for uploading single files",Icon:p.UploadFileIcon,color:"#f92d9a",property:{dataType:"string",storage:{storagePath:"{path}"},Field:mo}},multi_file_upload:{key:"multi_file_upload",name:"Multiple file upload",description:"Input for uploading multiple files",Icon:p.DriveFolderUploadIcon,color:"#f92d9a",property:{dataType:"array",of:{dataType:"string",storage:{storagePath:"{path}"}},Field:mo}},reference:{key:"reference",name:"Reference",description:"The value refers to a different collection",Icon:p.LinkIcon,color:"#ff0042",property:{dataType:"reference",Field:_n}},multi_references:{key:"multi_references",name:"Multiple references",description:"Multiple values that refer to a different collection",Icon:p.AddLinkIcon,color:"#ff0042",property:{dataType:"array",of:{dataType:"reference"},Field:yn}},date_time:{key:"date_time",name:"Date/time",description:"A date time select field",Icon:p.ScheduleIcon,color:"#8b46ff",property:{dataType:"date",Field:kn}},group:{key:"group",name:"Group",description:"Group of multiple fields",Icon:p.BallotIcon,color:"#ff9408",property:{dataType:"map",properties:{},Field:xn}},key_value:{key:"key_value",name:"Key-value",description:"Flexible field that allows the user to add multiple key-value pairs",Icon:p.BallotIcon,color:"#ff9408",property:{dataType:"map",keyValue:!0,Field:Cn}},repeat:{key:"repeat",name:"Repeat/list",description:"A field that gets repeated multiple times (e.g. multiple text fields)",Icon:p.RepeatIcon,color:"#ff9408",property:{dataType:"array",of:{dataType:"string"},Field:En}},custom_array:{key:"custom_array",name:"Custom array",description:"A field that saved its value as an array of custom objects",Icon:p.RepeatIcon,color:"#ff9408",property:{dataType:"array",of:[],Field:In}},block:{key:"block",name:"Block",description:"A complex field that allows the user to compose different fields together, with a key->value format",Icon:p.ViewStreamIcon,color:"#ff9408",property:{dataType:"array",oneOf:{properties:{}},Field:Bn}}};function Dn(e){const t=sr(e);if(!t){console.error("No field id found for property",e);return}return ir[t]}function Ft(e,t){const o=yo(e),a=sr(e);if(!a){console.error("No field id found for property",e);return}const n=ir[a],i=o?t[o]:void 0;return De(n??{},i??{})}function sr(e){if(e.dataType==="string")return e.multiline?"multiline":e.markdown?"markdown":e.storage?"file_upload":e.url?"url":e.email?"email":e.enumValues?"select":"text_field";if(e.dataType==="number")return e.enumValues?"number_select":"number_input";if(e.dataType==="map")return e.keyValue?"key_value":"group";if(e.dataType==="array"){const t=e.of;return e.oneOf?"block":Array.isArray(t)?"custom_array":ke(t)?"repeat":t?.dataType==="string"&&t.enumValues?"multi_select":t?.dataType==="number"&&t.enumValues?"multi_number_select":t?.dataType==="string"&&t.storage?"multi_file_upload":t?.dataType==="reference"?"multi_references":"repeat"}else{if(e.dataType==="boolean")return"switch";if(e.dataType==="date")return"date_time";if(e.dataType==="reference")return"reference"}console.error("Unsupported field config mapping",e)}function yo(e){return e.propertyConfig?e.propertyConfig:sr(e)}const Ne=({collection:e,path:t,entityId:o,values:a,previousValues:n,userConfigPersistence:i,fields:s})=>{const l=i?.getCollectionConfig(t),c=Ye(l,"properties"),u=kt(e.properties),m=a??u,g=n??a??u,f=Object.entries(e.properties).map(([y,A])=>{const k=Pe({propertyKey:y,propertyOrBuilder:A,values:m,previousValues:g,path:t,entityId:o,fields:s});return k?{[y]:k}:{}}).filter(y=>y!==null).reduce((y,A)=>({...y,...A}),{}),h=De(f,c),b=Object.entries(h).filter(([y,A])=>!!A?.dataType).map(([y,A])=>({[y]:A})).reduce((y,A)=>({...y,...A}),{});return{...e,properties:b,originalCollection:e}};function Pe({propertyOrBuilder:e,fromBuilder:t=!1,...o}){if(typeof e=="object"&&"resolved"in e)return e;let a=null;if(e)if(ke(e)){const n=o.path;if(!n)throw Error("Trying to resolve a property builder without specifying the entity path");const i=o.propertyKey?ve.getIn(o.values,o.propertyKey):void 0,s=e({...o,path:n,propertyValue:i,values:o.values??{},previousValues:o.previousValues??o.values??{}});if(!s)return null;a=Pe({...o,propertyOrBuilder:s,fromBuilder:!0})}else{const n=e;if(n.dataType==="map"&&n.properties){const i=wo({...o,properties:n.properties});a={...n,resolved:!0,fromBuilder:t,properties:i}}else n.dataType==="array"?a=Xe({property:n,fromBuilder:t,...o}):(n.dataType==="string"||n.dataType==="number")&&n.enumValues&&(a=vo(n,t))}else return null;if(a||(a={...e,resolved:!0,fromBuilder:t}),a.propertyConfig&&!Tn(a.propertyConfig)){const n=o.fields;if(!n)throw Error(`Trying to resolve a property with key ${a.propertyConfig} that inherits from a custom property config but no custom property configs were provided. Use the property \`propertyConfigs\` in your app config to provide them`);const i=n[a.propertyConfig];if(!i)return console.warn(`Trying to resolve a property with key ${a.propertyConfig} that inherits from a custom property config but no custom property config with that key was found. Check the \`propertyConfigs\` in your app config`),console.warn("Available property configs",n),null;if(i.property){const s=i.property;"propertyConfig"in s&&delete s.propertyConfig;const l=Pe({propertyOrBuilder:s,...o});l&&(a=De(l,a))}}return a?{...a,resolved:!0}:null}function Xe({propertyKey:e,property:t,...o}){const a=e?ve.getIn(o.values,e):void 0;if(t.of){if(Array.isArray(t.of))return{...t,resolved:!0,fromBuilder:o.fromBuilder,resolvedProperties:t.of.map((n,i)=>Pe({propertyKey:`${e}.${i}`,propertyOrBuilder:n,...o,index:i}))};{const n=t.of,i=Array.isArray(a)?a.map((l,c)=>Pe({propertyKey:`${e}.${c}`,propertyOrBuilder:n,...o,index:c})).filter(l=>!!l):[],s=Pe({propertyKey:`${e}`,propertyOrBuilder:n,...o});if(!s)throw Error("When using a property builder as the 'of' prop of an ArrayProperty, you must return a valid child property");return{...t,resolved:!0,fromBuilder:o.fromBuilder,of:s,resolvedProperties:i}}}else if(t.oneOf){const n=t.oneOf?.typeField??wt,i=Array.isArray(a)?a.map((l,c)=>{const u=l&&l[n],m=t.oneOf?.properties[u];return!u||!m?null:Pe({propertyKey:`${e}.${c}`,propertyOrBuilder:m,...o})}).filter(l=>!!l):[],s=wo({properties:t.oneOf.properties,...o});return{...t,resolved:!0,oneOf:{...t.oneOf,properties:s},fromBuilder:o.fromBuilder,resolvedProperties:i}}else{if(t.Field)return{...t,resolved:!0,fromBuilder:o.fromBuilder};throw Error("The array property needs to declare an 'of' or a 'oneOf' property, or provide a custom `Field`")}}function wo({properties:e,...t}){return Object.entries(e).map(([o,a])=>{const n=Pe({propertyKey:o,propertyOrBuilder:a,...t});return n?{[o]:n}:{}}).filter(o=>o!==null).reduce((o,a)=>({...o,...a}),{})}function vo(e,t){return typeof e.enumValues=="object"?{...e,resolved:!0,enumValues:qe(e.enumValues)?.filter(o=>o&&o.id&&o.label)??[],fromBuilder:t??!1}:e}function Rl(e){return typeof e=="object"?Object.entries(e).map(([t,o])=>typeof o=="string"?{id:t,label:o}:o):Array.isArray(e)?e:void 0}function ko(e,t){return typeof e=="string"?t?.find(o=>o.key===e):e}function _o(e){const{path:t,collections:o=[],currentFullPath:a}=e,n=me(t).split("/"),i=Ot(n),s=[];for(let l=0;l<i.length;l++){const c=i[l],u=o&&o.find(m=>m.id===c||m.path===c);if(u){const m=u.id??u.path,g=a&&a.length>0?a+"/"+m:m;s.push({type:"collection",path:g,collection:u});const f=me(me(t).replace(c,"")),h=f.length>0?f.split("/"):[];if(h.length>0){const b=h[0],y=g+"/"+b;if(s.push({type:"entity",entityId:b,path:g,parentCollection:u}),h.length>1){const A=h.slice(1).join("/");if(!u)throw Error("collection not found resolving path: "+u);const k=u.entityViews,v=k&&k.map(_=>ko(_,e.contextEntityViews)).filter(Boolean).find(_=>_.key===A);if(v){const _=a&&a.length>0?a+"/"+v.key:v.key;s.push({type:"custom_view",path:_,view:v})}else u.subcollections&&s.push(..._o({path:A,collections:u.subcollections,currentFullPath:y,contextEntityViews:e.contextEntityViews}))}}break}}return s}const ec="100vw",tc="55vw",lr="768px",cr="main_##Q$SC^#S6";function rc({path:e,entityId:t,selectedSubPath:o,copy:a,collection:n,parentCollectionIds:i,onValuesAreModified:s,formWidth:l,onUpdate:c,onClose:u}){n.customId&&n.formAutoSave&&console.warn(`The collection ${n.path} has customId and formAutoSave enabled. This is not supported and formAutoSave will be ignored`);const[m,g]=d.useState(!1),[f,h]=d.useState(void 0);Ut(f,()=>{f&&F({entityId:U?.id,collection:n,path:e,values:f,closeAfterSave:!1})},!1,2e3);const b=Me(n),y=dr(),A=Je(),k=He(),v=oe(),_=Ae(),E=We(),[C,B]=d.useState(void 0),[x,S]=d.useState(a?"copy":t?"existing":"new"),I=d.useRef(void 0),D=I.current,P=(n.subcollections??[]).filter(j=>!j.hideFromNavigation),T=P?.length??0,V=n.entityViews,re=V?.length??0,R=n.formAutoSave&&!n.customId,$=re>0||T>0,G=o??Cr(n?n.defaultSelectedView:void 0,{status:x,entityId:t}),z=d.useRef(G??cr),H=z.current===cr,{entity:J,dataLoading:ee,dataLoadingError:ne}=Qr({path:e,entityId:t,collection:n,useCache:!1}),[U,X]=d.useState(J),[Q,K]=d.useState(void 0);d.useEffect(()=>{J&&X(J)},[J]),d.useEffect(()=>{if(x==="new")K(!1);else{const j=U?Ir(n,E,e,U??null):!1;U&&K(!j)}},[E,U,x]);const Z=d.useCallback(j=>{g(!1),k.open({type:"error",message:"Error before saving: "+j?.message}),console.error(j)},[k]),M=d.useCallback(j=>{g(!1),k.open({type:"error",message:"Error after saving (entity is saved): "+j?.message}),console.error(j)},[k]),Y=(j,Be)=>{g(!1),R||k.open({type:"success",message:`${n.singularName??n.name}: Saved correctly`}),X(j),S("existing"),s(!1),c&&c({entity:j}),Be?(y.setBlocked(!1),y.close(!0),u?.()):x!=="existing"&&A.replace({path:e,entityId:j.id,selectedSubPath:z.current,updateUrl:!0,collection:n})},q=d.useCallback(j=>{g(!1),k.open({type:"error",message:"Error saving: "+j?.message}),console.error("Error saving entity",e,t),console.error(j)},[t,e,k]),F=({values:j,previousValues:Be,closeAfterSave:Se,entityId:$e,collection:Nt,path:Pt})=>{g(!0),Mr({path:Pt,entityId:$e,values:j,previousValues:Be,collection:Nt,status:x,dataSource:b,context:_,onSaveSuccess:Tt=>Y(Tt,Se),onSaveFailure:q,onPreSaveHookError:Z,onSaveSuccessHookError:M}).then()},N=async({collection:j,path:Be,entityId:Se,values:$e,previousValues:Nt,closeAfterSave:Pt,autoSave:Tt})=>{x&&(Tt?h($e):F({collection:j,path:Be,entityId:Se,values:$e,previousValues:Nt,closeAfterSave:Pt}))},le=V?V.map(j=>ko(j,v.entityViews)).filter(Boolean):[],xe=V&&le.map((j,Be)=>{if(!j||z.current!==j.key)return null;const Se=j.Builder;return Se?r.jsx("div",{className:p.cn(p.defaultBorderMixin,"relative flex-grow w-full h-full overflow-auto "),role:"tabpanel",children:r.jsx(ae,{children:C&&r.jsx(Se,{collection:n,entity:U,modifiedValues:D??U?.values,formContext:C})})},`custom_view_${j.key}`):(console.error("customView.Builder is not defined"),null)}).filter(Boolean),te=ee&&!U||(!U||Q===void 0)&&(x==="existing"||x==="copy"),O=te||m,ie=P&&P.map((j,Be)=>{const Se=j.id??j.path,$e=U?`${e}/${U?.id}/${me(Se)}`:void 0;return z.current!==Se?null:r.jsxs("div",{className:"relative flex-grow h-full overflow-auto w-full",role:"tabpanel",children:[O&&r.jsx(or,{}),!te&&(U&&$e?r.jsx(io,{fullPath:$e,parentCollectionIds:[...i,n.id],isSubCollection:!0,...j}):r.jsx("div",{className:"flex items-center justify-center w-full h-full p-3",children:r.jsx(p.Typography,{variant:"label",children:"You need to save your entity before adding additional collections"})}))]},`subcol_${Se}`)}).filter(Boolean),fe=d.useCallback(()=>{s(!1)},[]),ue=j=>{z.current=j,A.replace({path:e,entityId:t,selectedSubPath:j===cr?void 0:j,updateUrl:!0,collection:n})},he=d.useCallback(j=>{I.current=j},[]),ze=d.useCallback(j=>{k.open({type:"error",message:"Error updating id, check the console"})},[]),Ve=d.useCallback(j=>{X(Be=>Be?{...Be,id:j}:void 0)},[]),Ge=j=>{R||s(j)};console.log("eeee",n);function Ue(){const j=v.plugins;let Be=r.jsx(Nn,{status:x,path:e,collection:n,onEntitySaveRequested:N,onDiscard:fe,onValuesChanged:he,onModified:Ge,entity:U,onIdChange:Ve,onFormContextChange:B,hideId:n.hideIdFromForm,autoSave:R,onIdUpdateError:ze});return j&&j.forEach(Se=>{Se.form?.provider&&(Be=r.jsx(Se.form.provider.Component,{status:x,path:e,collection:n,onDiscard:fe,onValuesChanged:he,onModified:Ge,entity:U,context:_,formContext:C,...Se.form.provider.props,children:Be}))}),r.jsx(ae,{children:Be})}const at=Q===void 0?r.jsx(r.Fragment,{}):Q?r.jsxs(r.Fragment,{children:[r.jsx(p.Typography,{className:"mt-16 mb-8 mx-8",variant:"h4",children:n.singularName??n.name}),r.jsx(qr,{className:"px-12",entity:U,path:e,collection:n})]}):Ue(),Co=P&&P.map(j=>r.jsx(p.Tab,{className:"text-sm min-w-[140px]",value:j.id,children:j.name},`entity_detail_collection_tab_${j.name}`)),Eo=le.map(j=>r.jsx(p.Tab,{className:"text-sm min-w-[140px]",value:j.key,children:j.name},`entity_detail_collection_tab_${j.name}`));return r.jsx("div",{className:"flex flex-col h-full w-full transition-width duration-250 ease-in-out",children:r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:p.cn(p.defaultBorderMixin,"no-scrollbar border-b pl-2 pr-2 pt-1 flex items-end overflow-scroll bg-gray-50 dark:bg-gray-950"),children:[r.jsx("div",{className:"pb-1 self-center",children:r.jsx(p.IconButton,{onClick:()=>(u?.(),y.close(!1)),size:"large",children:r.jsx(p.CloseIcon,{})})}),r.jsx("div",{className:"flex-grow"}),te&&r.jsx("div",{className:"self-center",children:r.jsx(p.CircularProgress,{size:"small"})}),r.jsxs(p.Tabs,{value:z.current,onValueChange:j=>{ue(j)},className:"pl-4 pr-4 pt-0",children:[r.jsx(p.Tab,{disabled:!$,value:cr,className:`${$?"":"hidden"} text-sm min-w-[140px]`,children:n.singularName??n.name}),Eo,Co]})]}),r.jsxs("div",{className:"flex-grow h-full flex overflow-auto flex-row w-full ",style:{},children:[r.jsx("div",{role:"tabpanel",hidden:!H,id:`form_${e}`,className:" w-full",children:te?r.jsx(or,{}):at}),xe,ie]})]})})}function oc(e,t){const[o,a]=d.useState(),{navigator:n}=d.useContext(ge.UNSAFE_NavigationContext),i=ge.useNavigate(),s=()=>{a(void 0)},l=()=>{t(),a(void 0),i(-1)},c=d.useCallback(({action:u,location:m,retry:g})=>{switch(u){case"REPLACE":{g();return}case"POP":a(m)}},[]);return d.useEffect(()=>{if(!e||o||!("block"in n))return;const u=n.block(m=>{const g={...m,retry(){u(),m.retry()}};c(g)});return u},[n,c,e,o]),{navigationWasBlocked:!!o,handleCancel:s,handleOk:l}}function ac({open:e,handleOk:t,handleCancel:o,body:a,title:n}){return r.jsxs(p.Dialog,{open:e,onOpenChange:i=>i?o():t(),children:[r.jsxs(p.DialogContent,{children:[r.jsx(p.Typography,{variant:"h6",children:n}),a,r.jsx(p.Typography,{children:"Are you sure you want to leave this page?"})]}),r.jsxs(p.DialogActions,{children:[r.jsx(p.Button,{variant:"text",onClick:o,autoFocus:!0,children:" Cancel "}),r.jsx(p.Button,{onClick:t,children:" Ok "})]})]})}const Qn=d.createContext({width:"",blocked:!1,setBlocked:e=>{},setBlockedNavigationMessage:e=>{},close:()=>{}}),dr=()=>d.useContext(Qn);function nc(){const t=xt().sidePanels,o=[...t];return o.push(void 0),r.jsx(r.Fragment,{children:o.map((a,n)=>r.jsx(ic,{panel:a,offsetPosition:t.length-n-1},`side_dialog_${n}`))})}function ic({offsetPosition:e,panel:t}){const[o,a]=d.useState(!1),[n,i]=d.useState(!1),[s,l]=d.useState(),c=d.useRef(t?.width),u=c.current,m=xt(),{navigationWasBlocked:g,handleOk:f,handleCancel:h}=oc(n&&!o,()=>i(!1));d.useEffect(()=>{t&&(c.current=t.width)},[t]);const b=()=>{i(!1),a(!1),m.close(),t?.onClose?.()},y=()=>{a(!1)},A=k=>{n&&!k?a(!0):(m.close(),t?.onClose?.())};return r.jsxs(Qn.Provider,{value:{blocked:n,setBlocked:i,setBlockedNavigationMessage:l,width:u,close:A},children:[r.jsxs(p.Sheet,{open:!!t,onOpenChange:k=>!k&&A(),children:[t&&r.jsx("div",{className:"transform max-w-[100vw] lg:max-w-[95vw] flex flex-col h-full transition-all duration-250 ease-in-out bg-white dark:bg-gray-900 ",style:{width:t.width,transform:`translateX(-${e*200}px)`},children:r.jsx(ae,{children:t.component})}),!t&&r.jsx("div",{style:{width:u}})]}),r.jsx(ac,{open:g||o,handleOk:o?b:f,handleCancel:o?y:h,body:s})]})}function sc(e){const{blocked:t,setBlocked:o,setBlockedNavigationMessage:a}=dr(),n=pe(),i=d.useMemo(()=>n.getParentCollectionIds(e.path),[n,e.path]),s=d.useMemo(()=>{if(!e)return;let c=e.collection;const u=n.getCollection(e.path,e.entityId);if(u&&(c=u),!c)throw console.error("ERROR: No collection found in path `",e.path,"`. Entity id: ",e.entityId),Error("ERROR: No collection found in path `"+e.path+"`. Make sure you have defined a collection for this path in the root navigation.");return c},[n,e]);d.useEffect(()=>{function c(u){t&&s&&(u.preventDefault(),u.returnValue=`You have unsaved changes in this ${s.name}. Are you sure you want to leave this page?`)}return typeof window<"u"&&window.addEventListener("beforeunload",c),()=>{typeof window<"u"&&window.removeEventListener("beforeunload",c)}},[t,s]);const l=d.useCallback(c=>{o(c),a(c?r.jsxs(r.Fragment,{children:[" You have unsaved changes in this ",r.jsx("b",{children:s?.singularName??s?.name}),"."]}):void 0)},[s?.name,o,a]);return!e||!s?r.jsx("div",{className:"w-full"}):r.jsx(r.Fragment,{children:r.jsx(ae,{children:r.jsx(rc,{...e,formWidth:e.width,collection:s,parentCollectionIds:i,onValuesAreModified:l})})})}const Mn="new";function lc(e,t){if(t)return ec;const o=!e.selectedSubPath;let a;return e.width?a=typeof e.width=="number"?`${e.width}px`:e.width:e.collection?.sideDialogWidth&&(a=typeof e.collection.sideDialogWidth=="number"?`${e.collection.sideDialogWidth}px`:e.collection.sideDialogWidth),o?a||(e.collection?cc(e.collection):lr):`calc(${tc} + ${a??lr})`}const xo={};function cc(e){if(xo[e.id])return xo[e.id];const t=Ne({collection:e,path:"__ignored"});let o=lr;if(t?.properties){const a=Object.values(t.properties).map(i=>pr(i)),n=Math.max(...a);n<3?o=lr:o=768+32*(n-2)+"px"}return xo[e.id]=o,o}function pr(e,t=0){if(e.dataType==="map"&&e.properties){const o=Object.values(e.properties).flatMap(a=>pr(a,t+1));return Math.max(...o)}else return e.dataType==="array"&&e.oneOf?t+3:e.dataType==="array"&&e.of?Array.isArray(e.of)?Math.max(...e.of.map(o=>pr(o,t+1))):pr(e.of,t+1):t+1}const dc=(e,t)=>{const o=ge.useLocation(),a=d.useRef(!1),n=!Qe();d.useEffect(()=>{if(!e.loading&&!a.current){if(console.debug("Initialising side entity controller"),e.isUrlCollectionPath(o.pathname)){const c=o.hash===`#${Mn}`,u=e.urlPathToDataPath(o.pathname),m=pc(u,e.collections??[],c);for(let g=0;g<m.length;g++){const f=m[g];setTimeout(()=>{g===0?t.replace(ur(f,e.buildUrlCollectionPath,e.resolveAliasesFrom,n)):t.open(ur(f,e.buildUrlCollectionPath,e.resolveAliasesFrom,n))},1)}}a.current=!0}},[o,e.loading,e.isUrlCollectionPath,e.buildUrlCollectionPath,e.resolveAliasesFrom,t,n,e]);const i=d.useCallback(()=>{t.close()},[t]),s=d.useCallback(c=>{if(c.copy&&!c.entityId)throw Error("If you want to copy an entity you need to provide an entityId");const u=Cr(c.collection?c.collection.defaultSelectedView:void 0,{status:c.copy?"copy":c.entityId?"existing":"new",entityId:c.entityId});t.open(ur({selectedSubPath:u,...c},e.buildUrlCollectionPath,e.resolveAliasesFrom,n))},[t,e.buildUrlCollectionPath,e.resolveAliasesFrom,n]),l=d.useCallback(c=>{if(c.copy&&!c.entityId)throw Error("If you want to copy an entity you need to provide an entityId");t.replace(ur(c,e.buildUrlCollectionPath,e.resolveAliasesFrom,n))},[e.buildUrlCollectionPath,e.resolveAliasesFrom,t,n]);return{close:i,open:s,replace:l}};function pc(e,t,o){const a=_o({path:e,collections:t}),n=[];let i="";for(let s=0;s<a.length;s++){const l=a[s];if(l.type==="collection"&&(i=l.path),s>0){const c=a[s-1];if(l.type==="entity")n.push({path:l.path,entityId:l.entityId,copy:!1,width:l.parentCollection?.sideDialogWidth});else if(l.type==="custom_view"){if(c.type==="entity"){const u=n[n.length-1];u&&(u.selectedSubPath=l.view.key)}}else if(l.type==="collection"&&c.type==="entity"){const u=n[n.length-1];u&&(u.selectedSubPath=l.collection.id??l.collection.path)}}}return o&&n.push({path:i,copy:!1}),n}const ur=(e,t,o,a)=>{const n=me(e.path),i=e.entityId?t(`${n}/${e.entityId}/${e.selectedSubPath||""}`):t(`${n}#${Mn}`),s=o(e.path),l={...e,path:s};return{key:`${e.path}/${e.entityId}`,component:r.jsx(sc,{...l}),urlPath:i,parentUrlPath:t(n),width:lc(e,a),onClose:e.onClose}};function uc(){const e=ge.useLocation(),t=ge.useNavigate(),[o,a]=d.useState([]),n=d.useRef(o),i=d.useRef({}),s=d.useRef(0),l=g=>{n.current=g,a(g)};d.useEffect(()=>{const h=(e.state?.panels??[]).map(b=>i.current[b]).filter(b=>!!b);L(n.current.map(b=>b.key),h.map(b=>b.key))||l(h)},[e]);const c=d.useCallback(()=>{if(o.length===0)return;const g=o[o.length-1],f=[...o.slice(0,-1)];if(l(f),s.current>0)g.urlPath&&t(-1),s.current--;else if(g.parentUrlPath){const h=e.state?.base_location??e;t(g.parentUrlPath,{replace:!0,state:{base_location:h,panels:f.map(b=>b.key)}})}},[o,t,e]),u=d.useCallback(g=>{const f=Array.isArray(g)?g:[g];f.forEach(y=>{i.current[y.key]=y}),s.current=s.current+f.length;const h=e.state?.base_location??e,b=[...o,...f];l(b),f.forEach(y=>{y.urlPath&&t(y.urlPath,{state:{base_location:h,panels:b.map(A=>A.key)}})})},[e,t,o]),m=d.useCallback(g=>{const f=Array.isArray(g)?g:[g];f.forEach(y=>{i.current[y.key]=y});const h=e.state?.base_location??e,b=[...o.slice(0,-f.length),...f];l(b),f.forEach(y=>{y.urlPath&&t(y.urlPath,{replace:!0,state:{base_location:h,panels:b.map(A=>A.key)}})})},[e,t,o]);return{sidePanels:o,close:c,open:u,replace:m}}function mc({delegate:e,propertyConfigs:t,navigationController:o}){return{fetchCollection:d.useCallback(({path:a,collection:n,filter:i,limit:s,startAfter:l,searchString:c,orderBy:u,order:m})=>e.fetchCollection({path:a,filter:i,limit:s,startAfter:l,searchString:c,orderBy:u,order:m}),[e]),listenCollection:e.listenCollection?d.useCallback(({path:a,collection:n,filter:i,limit:s,startAfter:l,searchString:c,orderBy:u,order:m,onUpdate:g,onError:f})=>{const h=n??o.getCollection(a),b=!!h?.collectionGroup;if(!e.listenCollection)throw Error("useBuildDataSource delegate not initialised");return e.listenCollection({path:a,filter:i,limit:s,startAfter:l,searchString:c,orderBy:u,order:m,onUpdate:g,onError:f,isCollectionGroup:b,collection:h})},[e,o.getCollection]):void 0,fetchEntity:d.useCallback(({path:a,entityId:n})=>e.fetchEntity({path:a,entityId:n}),[e]),listenEntity:e.listenEntity?d.useCallback(({path:a,entityId:n,collection:i,onUpdate:s,onError:l})=>{if(!e.listenEntity)throw Error("useBuildDataSource delegate not initialised");return e.listenEntity({path:a,entityId:n,onUpdate:s,onError:l})},[e.listenEntity]):void 0,saveEntity:d.useCallback(({path:a,entityId:n,values:i,collection:s,status:l})=>{const c=s??o.getCollection(a),m=(c?Ne({collection:c,path:a,entityId:n,fields:t}):void 0)?.properties,g=e.cmsToDelegateModel(i),f=m?Oo({inputValues:g,properties:m,status:l,timestampNowValue:e.currentTime(),setDateToMidnight:e.setDateToMidnight}):g;return e.saveEntity({path:a,entityId:n,values:f,status:l}).then(h=>({id:h.id,path:h.path,values:e.delegateToCMSModel(f)}))},[e.saveEntity,o.getCollection]),deleteEntity:d.useCallback(({entity:a})=>e.deleteEntity({entity:a}),[e.deleteEntity]),checkUniqueField:d.useCallback((a,n,i,s)=>e.checkUniqueField(a,n,i,s),[e.checkUniqueField]),generateEntityId:d.useCallback(a=>e.generateEntityId(a),[e.generateEntityId]),countEntities:e.countEntities?async({path:a,collection:n,filter:i,order:s,orderBy:l})=>e.countEntities({path:a,filter:i,orderBy:l,order:s,isCollectionGroup:!!n.collectionGroup}):void 0,isFilterCombinationValid:d.useCallback(({path:a,filterValues:n,sortBy:i})=>e.isFilterCombinationValid?e.isFilterCombinationValid({path:a,filterValues:n,sortBy:i}):!0,[e.isFilterCombinationValid])}}function xc(e){return e}const fc="https://api-drplyi3b6q-ey.a.run.app";async function hc(e,t){const o=await e.getAuthToken();return fetch(fc+"/access_log",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${o}`},body:JSON.stringify({plugins:t})}).then(async a=>a.json())}function gc(e,t){const[o,a]=d.useState(null),n=d.useRef(null),i=t?.map(s=>s.key);return d.useEffect(()=>{e.user&&e.user.uid!==n.current&&!e.initialLoading&&(hc(e,i).then(a),n.current=e.user.uid)},[e,i]),o}function Ac(e){const t=Or(),{children:o,entityLinkBuilder:a,userConfigPersistence:n,dateTimeFormat:i,locale:s,authController:l,storageSource:c,dataSourceDelegate:u,plugins:m,onAnalyticsEvent:g,propertyConfigs:f,entityViews:h,components:b,navigationController:y}=e;p.useLocaleConfig(s);const A=mc({delegate:u,propertyConfigs:f,navigationController:y}),k=uc(),v=dc(y,k),_=m?.some(S=>S.loading)??!1,E=l.initialLoading||y.loading||_,C={dateTimeFormat:i,locale:s,entityLinkBuilder:a,plugins:m,entityViews:h??[],propertyConfigs:f??{},components:b},B=d.useMemo(()=>({onAnalyticsEvent:g}),[]),x=gc(l,m);return y.navigationLoadingError?r.jsx(p.CenteredView,{maxWidth:"md",children:r.jsx(ye,{title:"Error loading navigation",error:y.navigationLoadingError})}):l.authError?r.jsx(p.CenteredView,{maxWidth:"md",children:r.jsx(ye,{title:"Error loading auth",error:l.authError})}):x?.blocked?r.jsxs(p.CenteredView,{maxWidth:"md",fullScreen:!0,children:[r.jsx(p.Typography,{variant:"h4",children:"Access blocked"}),r.jsxs(p.Typography,{children:["This app has been blocked. Please reach out at ",r.jsx("a",{href:"mailto:hello@firecms.co",children:"hello@firecms.co"})," for more information."]}),x?.message&&r.jsxs(p.Typography,{children:["Response from the server: ",x?.message]})]}):r.jsx(Qt.Provider,{value:t,children:r.jsx(ua.Provider,{value:B,children:r.jsx(pa.Provider,{value:C,children:r.jsx(ca.Provider,{value:n,children:r.jsx(la.Provider,{value:c,children:r.jsx(aa.Provider,{value:A,children:r.jsx(fr.Provider,{value:l,children:r.jsx(ia.Provider,{value:k,children:r.jsx(sa.Provider,{value:v,children:r.jsx(na.Provider,{value:y,children:r.jsx(Fi,{children:r.jsx(bc,{loading:E,children:o})})})})})})})})})})})})}function bc({loading:e,children:t}){const o=Ae(),a=oe();let n=t({context:o,loading:e});const i=a.plugins;return!e&&i&&i.forEach(s=>{s.provider&&(n=r.jsx(s.provider.Component,{...s.provider.props,context:o,children:n}))}),r.jsx(r.Fragment,{children:n})}function On({hovered:e,drawerOpen:t,closeDrawer:o}){const a=ut(),n=pe(),i=e&&!t,s=Qe(),l=ge.useNavigate(),[c,u]=d.useState(!1);if(!n.topLevelNavigation)throw Error("Navigation not ready in Drawer");const{navigationEntries:m,groups:g}=n.topLevelNavigation,f=m.filter(A=>A.type==="admin")??[],h=g.filter(A=>A!=="Admin"),b=d.useCallback(A=>t?r.jsx("div",{className:"pt-8 pl-6 pr-8 pb-2 flex flex-row items-center",children:r.jsx(p.Typography,{variant:"caption",color:"secondary",className:"font-medium flex-grow line-clamp-1",children:A?A.toUpperCase():"Views".toUpperCase()})}):r.jsx("div",{className:"h-12 w-full"}),[t]),y=A=>{const k=A.type==="collection"?"drawer_navigate_to_collection":A.type==="view"?"drawer_navigate_to_view":"unmapped_event";a.onAnalyticsEvent?.(k,{url:A.url}),s||o()};return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-grow overflow-scroll no-scrollbar",children:h.map(A=>r.jsxs(d.Fragment,{children:[b(A),Object.values(m).filter(k=>k.group===A).map((k,v)=>r.jsx(zn,{icon:r.jsx(Zt,{collectionOrView:k.collection??k.view}),tooltipsOpen:i,drawerOpen:t,onClick:()=>y(k),url:k.url,name:k.name},`navigation_${v}`))]},`drawer_group_${A}`))}),f.length>0&&r.jsx(p.Menu,{open:c,onOpenChange:u,trigger:r.jsxs(p.IconButton,{shape:"square",className:"m-4 text-gray-900 dark:text-white w-fit",children:[r.jsx(p.Tooltip,{title:"Admin",open:i,side:"right",sideOffset:28,children:r.jsx(p.MoreVertIcon,{})}),t&&r.jsx("div",{className:p.cn(t?"opacity-100":"opacity-0 hidden","mx-4 font-inherit text-inherit"),children:"ADMIN"})]}),children:f.map((A,k)=>r.jsxs(p.MenuItem,{onClick:v=>{v.preventDefault(),l(A.path)},children:[r.jsx(Zt,{collectionOrView:A.view}),A.name]},`navigation_${k}`))})]})}function zn({name:e,icon:t,drawerOpen:o,tooltipsOpen:a,url:n,onClick:i}){const s=r.jsx("div",{className:"text-gray-600 dark:text-gray-500",children:t}),l=r.jsxs(ge.NavLink,{onClick:i,style:{width:o?"280px":"72px",transition:o?"width 150ms ease-in":void 0},className:({isActive:c})=>p.cn("rounded-r-xl truncate","hover:bg-slate-300 hover:bg-opacity-75 dark:hover:bg-gray-700 dark:hover:bg-opacity-75 text-gray-800 dark:text-gray-200 hover:text-gray-900 hover:dark:text-white","flex flex-row items-center mr-8",o?"pl-8 h-12":"pl-6 h-11","font-medium text-sm",c?"bg-slate-200 bg-opacity-75 dark:bg-gray-800":""),to:n,children:[s,r.jsx("div",{className:p.cn(o?"opacity-100":"opacity-0 hidden","ml-4 font-inherit text-inherit"),children:e.toUpperCase()})]});return r.jsx(p.Tooltip,{open:o?!1:a,side:"right",title:e,children:l})}const yc=280,wc=d.memo(function(t){const{children:o,name:a,logo:n,includeDrawer:i=!0,autoOpenDrawer:s,Drawer:l=On,drawerProps:c,FireCMSAppBar:u=An,fireCMSAppBarProps:m}=t,g=Qe(),[f,h]=d.useState(!1),[b,y]=d.useState(!1),A=d.useCallback(()=>y(!0),[]),k=d.useCallback(()=>y(!1),[]),v=d.useCallback(()=>{h(!1)},[]),_=f||!!(g&&s&&b);return r.jsxs("div",{className:"flex h-screen w-screen bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white overflow-hidden",style:{paddingTop:"env(safe-area-inset-top)",paddingLeft:"env(safe-area-inset-left)",paddingRight:"env(safe-area-inset-right)",paddingBottom:"env(safe-area-inset-bottom)",height:"100dvh"},children:[r.jsx(u,{title:a,includeDrawer:i,logo:n,drawerOpen:_,...m}),r.jsx(kc,{displayed:i,onMouseEnter:A,onMouseMove:A,onMouseLeave:k,open:_,logo:n,hovered:b,setDrawerOpen:h,children:i&&r.jsx(l,{hovered:b,drawerOpen:_,closeDrawer:v,...c})}),r.jsxs("main",{className:"flex flex-col flex-grow overflow-auto",children:[r.jsx(vc,{}),r.jsx("div",{className:p.cn(p.defaultBorderMixin,"flex-grow overflow-auto lg:m-0 lg:mx-4 lg:mb-4 lg:rounded-lg lg:border lg:border-solid m-0 mt-1"),children:r.jsx(ae,{children:o})})]})]})},L),vc=()=>r.jsx("div",{className:"flex flex-col min-h-[68px]"});function kc(e){const t=pe(),o=e.displayed?e.open?yc:72:0,a=r.jsxs("div",{className:"relative h-full no-scrollbar overflow-y-auto overflow-x-hidden",style:{width:o,transition:"left 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms"},children:[!e.open&&e.displayed&&r.jsx(p.Tooltip,{title:"Open menu",side:"right",sideOffset:12,className:"fixed top-2 left-3 !bg-gray-50 dark:!bg-gray-900 rounded-full w-fit",children:r.jsx(p.IconButton,{color:"inherit","aria-label":"Open menu",className:"sticky top-2 left-3 ",onClick:()=>e.setDrawerOpen(!0),size:"large",children:r.jsx(p.MenuIcon,{})})}),r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx("div",{style:{transition:"padding 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms",padding:e.open?"32px 144px 0px 24px":"72px 16px 0px"},className:p.cn("cursor-pointer"),children:r.jsx(p.Tooltip,{title:"Home",sideOffset:20,side:"right",children:r.jsx(ge.Link,{to:t.basePath,children:e.logo?r.jsx("img",{src:e.logo,alt:"Logo",className:p.cn("max-w-full max-h-full",e.open??"w-[112px] h-[112px]")}):r.jsx(so,{})})})}),e.children]})]});return Qe()?r.jsxs("div",{className:"relative",onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseLeave:e.onMouseLeave,style:{width:o,transition:"left 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms"},children:[a,r.jsx("div",{className:`absolute right-0 top-4 ${e.open?"opacity-100":"opacity-0 invisible"} transition-opacity duration-1000 ease-in-out`,children:r.jsx(p.IconButton,{"aria-label":"Close drawer",onClick:()=>e.setDrawerOpen(!1),children:r.jsx(p.ChevronLeftIcon,{})})})]}):e.displayed?r.jsxs(r.Fragment,{children:[r.jsx(p.IconButton,{color:"inherit","aria-label":"Open drawer",onClick:()=>e.setDrawerOpen(!0),size:"large",className:"absolute top-2 left-6",children:r.jsx(p.MenuIcon,{})}),r.jsx(p.Sheet,{side:"left",transparent:!0,open:e.open,onOpenChange:e.setDrawerOpen,children:a})]}):null}const _c=d.memo(function({homePage:t=r.jsx(dn,{}),customRoutes:o}){const a=ge.useLocation(),n=pe();if(!n)return r.jsx(r.Fragment,{});const i=a.state,s=i&&i.base_location?i.base_location:a,l=[];n.views&&n.views.forEach(f=>{Array.isArray(f.path)?l.push(...f.path.map(h=>mr(h,f))):l.push(mr(f.path,f))}),n.adminViews&&n.adminViews.forEach(f=>{Array.isArray(f.path)?l.push(...f.path.map(h=>mr(h,f))):l.push(mr(f.path,f))});const u=[...n.collections??[]].sort((f,h)=>h.path.length-f.path.length).map(f=>{const h=n.buildUrlCollectionPath(f.id??f.path);return r.jsx(ge.Route,{path:h+"/*",element:r.jsx(ae,{children:r.jsx(io,{isSubCollection:!1,parentCollectionIds:[],fullPath:f.id??f.path,...f,Actions:St(f.Actions)},`collection_view_${f.id??f.path}`)})},`navigation_${f.id??f.path}`)}),m=r.jsx(ge.Route,{path:"/",element:t}),g=r.jsx(ge.Route,{path:"*",element:r.jsx(gn,{})});return r.jsxs(ge.Routes,{location:s,children:[u,l,m,g,o]})}),mr=(e,t)=>r.jsx(ge.Route,{path:e,element:t.view},"navigation_view_"+e);w.ArrayContainer=lo,w.ArrayContainerItem=co,w.ArrayCustomShapedFieldBinding=In,w.ArrayEnumPreview=Lr,w.ArrayItemOptions=bn,w.ArrayOfMapsPreview=ds,w.ArrayOfReferencesFieldBinding=yn,w.ArrayOfReferencesPreview=Sa,w.ArrayOfStorageComponentsPreview=Ia,w.ArrayOfStringsPreview=Fa,w.ArrayOneOfPreview=Na,w.ArrayPropertyEnumPreview=Ur,w.ArrayPropertyPreview=jr,w.AsyncPreviewComponent=ps,w.AuthControllerContext=fr,w.BlockFieldBinding=Bn,w.BooleanPreview=Da,w.COLLECTION_PATH_SEPARATOR=Lo,w.CircularProgressCenter=or,w.DEFAULT_FIELD_CONFIGS=ir,w.DatePreview=Ta,w.DateTimeFieldBinding=kn,w.DefaultHomePage=dn,w.DeleteConfirmationDialog=vl,w.Drawer=On,w.DrawerNavigationItem=zn,w.EmptyValue=et,w.EntityCollectionRowActions=tr,w.EntityCollectionTable=eo,w.EntityCollectionView=io,w.EntityCollectionViewActions=pn,w.EntityForm=Nn,w.EntityReference=gr,w.EntityView=qr,w.EnumValuesChip=Ie,w.ErrorBoundary=ae,w.ErrorView=ye,w.FieldCaption=Bl,w.FieldHelperText=Ce,w.FireCMS=Ac,w.FireCMSAppBar=An,w.FireCMSLogo=so,w.FormikArrayContainer=nr,w.GeoPoint=Ar,w.IconForView=Zt,w.ImagePreview=ka,w.KeyValueFieldBinding=Cn,w.KeyValuePreview=$r,w.LabelWithIcon=Ee,w.MapFieldBinding=xn,w.MapPropertyPreview=Pa,w.MarkdownFieldBinding=Sn,w.ModeControllerContext=Qt,w.ModeControllerProvider=Kn,w.MultiSelectBinding=uo,w.NavigationCard=sn,w.NavigationCardBinding=cn,w.NavigationGroup=ao,w.NavigationRoutes=_c,w.NotFoundPage=gn,w.NumberPropertyPreview=Qa,w.PropertyConfigBadge=wl,w.PropertyFieldBinding=ot,w.PropertyPreview=we,w.PropertyTableCell=qa,w.ReadOnlyFieldBinding=fo,w.ReferenceFieldBinding=_n,w.ReferencePreview=Oe,w.ReferenceSelectionTable=nn,w.ReferenceWidget=xl,w.RepeatFieldBinding=En,w.Scaffold=wc,w.SearchIconsView=El,w.SelectFieldBinding=po,w.SelectableTable=on,w.SideDialogs=nc,w.SkeletonPropertyComponent=tt,w.SmallNavigationCard=ln,w.SnackbarProvider=Zn,w.StorageThumbnail=_a,w.StorageThumbnailInternal=Ca,w.StorageUploadFieldBinding=mo,w.StringPropertyPreview=Yr,w.SwitchFieldBinding=vn,w.TextFieldBinding=bt,w.UrlComponentPreview=Et,w.Vector=ti,w.VirtualTable=Ka,w.addInitialSlash=Rn,w.applyPermissionsFunctionIfEmpty=Yo,w.buildAdditionalFieldDelegate=Bi,w.buildCollection=wi,w.buildEntityCallbacks=Ei,w.buildEnumLabel=Vo,w.buildEnumValueConfig=Ci,w.buildEnumValues=xi,w.buildFieldConfig=Si,w.buildIdColumn=Ls,w.buildProperties=ki,w.buildPropertiesOrBuilder=_i,w.buildProperty=vi,w.canCreateEntity=ct,w.canDeleteEntity=Wt,w.canEditEntity=Ir,w.defaultDateFormat=jo,w.deleteEntityWithCallbacks=ma,w.enumToObjectEntries=qe,w.flattenObject=Nr,w.fullPathToCollectionSegments=Br,w.getArrayValuesCount=Xo,w.getBracketNotation=hi,w.getCollectionByPathOrId=Mt,w.getCollectionPathsCombinations=Ot,w.getColorForProperty=fi,w.getColorScheme=zo,w.getColumnKeysForProperty=rr,w.getDefaultFieldConfig=Dn,w.getDefaultFieldId=sr,w.getDefaultPropertiesOrder=gi,w.getDefaultValueFor=Gt,w.getDefaultValueForDataType=kr,w.getDefaultValuesFor=kt,w.getEntityImagePreviewPropertyKey=Zo,w.getEntityPreviewKeys=Ho,w.getEntityTitlePropertyKey=Fr,w.getFieldConfig=Ft,w.getFieldId=yo,w.getHashValue=yr,w.getIcon=Jo,w.getIconForProperty=_e,w.getIconForWidget=$t,w.getIdIcon=mi,w.getLabelOrConfigFrom=jt,w.getLastSegment=ei,w.getPropertiesWithPropertiesOrder=Wo,w.getPropertyInPath=Re,w.getRandomId=It,w.getReferenceFrom=je,w.getResolvedPropertyInPath=Sr,w.getSidePanelKey=Yi,w.getValueInPath=Ye,w.hydrateRegExp=$o,w.iconSynonyms=Jt,w.iconsSearch=Ht,w.isDefaultFieldConfigId=Tn,w.isEmptyObject=vr,w.isEnumValueDisabled=ai,w.isHidden=vt,w.isObject=zt,w.isPropertyBuilder=ke,w.isReadOnly=st,w.isReferenceProperty=qo,w.isValidRegExp=ui,w.joinCollectionLists=ea,w.makePropertiesEditable=Ko,w.makePropertiesNonEditable=Ro,w.mergeCollection=ta,w.mergeDeep=De,w.pick=Qo,w.plural=bi,w.printChanged=Tr,w.propertiesToColumns=Za,w.randomColor=ci,w.randomString=lt,w.removeFunctions=br,w.removeInPath=ri,w.removeInitialAndTrailingSlashes=me,w.removeInitialSlash=To,w.removePropsIfExisting=Mo,w.removeTrailingSlash=Do,w.removeUndefined=wr,w.renderSkeletonCaptionText=os,w.renderSkeletonIcon=Gr,w.renderSkeletonImageThumbnail=Vr,w.renderSkeletonText=Le,w.resolveArrayProperty=Xe,w.resolveCollection=Ne,w.resolveCollectionPathIds=hr,w.resolveDefaultSelectedView=Cr,w.resolveEntityView=ko,w.resolveEnumValues=Rl,w.resolveNavigationFrom=fa,w.resolvePermissions=_t,w.resolveProperties=wo,w.resolveProperty=Pe,w.resolvePropertyEnum=vo,w.sanitizeData=oi,w.saveEntityWithCallbacks=Mr,w.segmentsToStrippedPath=Uo,w.serializeRegExp=pi,w.singular=yi,w.slugify=Lt,w.sortProperties=xr,w.stripCollectionPath=Er,w.toKebabCase=ii,w.toSnakeCase=li,w.traverseValueProperty=Yt,w.traverseValuesProperties=_r,w.unslugify=di,w.updateDateAutoValues=Oo,w.useAuthController=We,w.useBrowserTitleAndIcon=Oi,w.useBuildLocalConfigurationPersistence=Ui,w.useBuildModeController=$i,w.useBuildNavigationController=Gi,w.useClearRestoreValue=Te,w.useClipboard=ha,w.useCollectionFetch=Pi,w.useColumnIds=Xr,w.useCustomizationController=oe,w.useDataSource=Me,w.useDataSourceEntityCollectionTableController=to,w.useDebouncedCallback=Ut,w.useDebouncedData=an,w.useEntityFetch=Qr,w.useFireCMSContext=Ae,w.useLargeLayout=Qe,w.useModeController=Or,w.useNavigationController=pe,w.useReferenceDialog=mt,w.useResolvedNavigationFrom=Ti,w.useSelectionController=ro,w.useSideDialogContext=dr,w.useSideDialogsController=xt,w.useSideEntityController=Je,w.useSnackbarController=He,w.useStorageSource=dt,w.useTableSearchHelper=oo,w.useTraceUpdate=Ii,w.useValidateAuthenticator=qi,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
|
588
|
+
`;function In({propertyKey:e,value:t,error:o,showError:a,isSubmitting:n,setValue:i,tableMode:s,property:l,includeDescription:c,underlyingValueHasChanged:u,context:m,disabled:g}){if(!Array.isArray(l.resolvedProperties))throw Error("ArrayCustomShapedFieldBinding misconfiguration. Property `of` not set");const f=l.expanded===void 0?!0:l.expanded;Te({property:l,value:t,setValue:i});const h=r.jsx(Ee,{icon:_e(l,"small"),required:l.validation?.required,className:"text-text-secondary dark:text-text-secondary-dark",title:l.name}),b=l.resolvedProperties.map((y,A)=>{const k={propertyKey:`${e}[${A}]`,disabled:g,property:y,includeDescription:c,underlyingValueHasChanged:u,context:m,tableMode:!1,partOfArray:!0,partOfBlock:!1,autoFocus:!1};return r.jsx("div",{className:"pb-4",children:r.jsx(ot,{...k})},`custom_shaped_array_${A}`)});return r.jsxs(r.Fragment,{children:[!s&&r.jsx(p.ExpandablePanel,{initiallyExpanded:f,title:h,className:"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2",children:b}),s&&b,r.jsx(Ce,{includeDescription:c,showError:a,error:o,disabled:g,property:l})]})}const $l=({containerRef:e})=>{const{isSubmitting:t,isValidating:o,errors:a}=ve.useFormex();return d.useEffect(()=>{const n=Object.keys(a);if(n.length>0&&t&&!o){const i=e?.current?.querySelector(`#form_field_${n[0]}`);if(i&&e?.current){const s=Fn(e.current);if(s){const c=i.getBoundingClientRect().top;s.scrollTo({top:s.scrollTop+c-196,behavior:"smooth"})}const l=i.querySelector("input");l&&l.focus()}}},[t,o,a,e]),null},ql=e=>{const t=e&&e.scrollHeight>e.clientHeight,o=e?window.getComputedStyle(e).overflowY:null,a=o&&o.indexOf("hidden")!==-1;return t&&!a},Fn=e=>!e||e===document.body?document.body:ql(e)?e:Fn(e.parentNode);function Wl({customId:e,entityId:t,status:o,onChange:a,error:n,entity:i,loading:s}){const{errors:l}=ve.useFormex(),c=o==="existing"||!e,u=o!=="existing"&&!e,m=d.useMemo(()=>{if(!(!e||typeof e=="boolean"||e==="optional"))return qe(e)},[e]),g=He(),{copy:f}=ha({onSuccess:y=>g.open({type:"success",message:`Copied ${y}`})}),h=oe(),b={label:u?"ID is set automatically":"ID",disabled:c||s,name:"id",value:(i&&o==="existing"?i.id:t)??"",endAdornment:s?r.jsx(p.CircularProgress,{size:"small"}):i?r.jsxs(r.Fragment,{children:[r.jsx(p.Tooltip,{title:"Copy",children:r.jsx(p.IconButton,{onClick:y=>f(i.id),"aria-label":"copy-id",children:r.jsx(p.ContentCopyIcon,{size:"small"})})}),h?.entityLinkBuilder&&r.jsx(p.Tooltip,{title:"Open in the console",children:r.jsx(p.IconButton,{component:"a",href:h.entityLinkBuilder({entity:i}),rel:"noopener noreferrer",target:"_blank",onClick:y=>y.stopPropagation(),"aria-label":"go-to-datasource",children:r.jsx(p.OpenInNewIcon,{size:"small"})})})]}):void 0};return r.jsxs(r.Fragment,{children:[m&&r.jsx(p.Select,{error:n,onValueChange:y=>a(y),...b,renderValue:y=>{const A=m.find(k=>k.id===y);return A?`${A.id} - ${A.label}`:y},children:m.map(y=>r.jsx(p.SelectItem,{value:String(y.id),children:r.jsx(Ie,{enumKey:y.id,enumValues:m,size:"medium"})},y.id))}),!m&&r.jsx(p.TextField,{...b,error:n,placeholder:e==="optional"?"Autogenerated ID, it can be manually changed":o==="new"||o==="copy"?"ID of the new document":"ID of the document",onChange:y=>{let A=y.target.value;return A&&(A=A.trim()),a(A.length?A:void 0)}}),l.id&&r.jsx(p.Typography,{variant:"caption",className:"ml-3.5 text-red-500 dark:text-red-500",children:l.id})]})}function Jl({propertyId:e}){const[t,o]=d.useState(!1);return r.jsxs("div",{className:"flex flex-row gap-2 items-center justify-center text-white",children:[r.jsxs("div",{children:[r.jsx(p.Typography,{variant:"caption",className:"min-w-20 text-slate-400",color:"disabled",children:t?"Copied":"Property ID"}),r.jsx(p.Typography,{variant:"caption",className:"text-white",children:r.jsx("code",{children:e})})]}),r.jsx(p.IconButton,{size:"small",children:r.jsx(p.ContentPasteIcon,{size:"smallest",className:"text-white",onClick:d.useCallback(()=>{navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2e3)},[e])})})]})}const Nn=Hl;function Pn(e,t,o){const a=e.properties;if((t==="existing"||t==="copy")&&o)return o.values??kt(a);if(t==="new")return kt(a);throw console.error({status:t,entity:o}),new Error("Form has not been initialised with the correct parameters")}function Hl({status:e,path:t,collection:o,entity:a,onEntitySaveRequested:n,onDiscard:i,onModified:s,onValuesChanged:l,onIdChange:c,onFormContextChange:u,hideId:m,autoSave:g,onIdUpdateError:f}){const h=ut(),b=oe(),y=Ae(),A=Me(o),k=b.plugins,v=d.useMemo(()=>Ne({collection:o,path:t,values:a?.values,fields:b.propertyConfigs}),[a?.values,t]),_=(e==="new"||e==="copy")&&!!v.customId&&v.customId!=="optional",E=d.useMemo(()=>e==="new"||e==="copy"?_?void 0:A.generateEntityId(t):a?.id,[]),C=d.useRef(!1),B=d.useRef(Pn(v,e,a)),[x,S]=d.useState(E),[I,D]=d.useState(!1),[P,T]=d.useState(),[V,re]=d.useState(!1),[R,$]=d.useState(a?.values??B.current),G=te=>n({collection:ee,path:t,entityId:x,values:te,previousValues:a?.values,closeAfterSave:C.current,autoSave:g??!1}).then(O=>{const ie=e==="new"?"new_entity_saved":e==="copy"?"entity_copied":e==="existing"?"entity_edited":"unmapped_event";h.onAnalyticsEvent?.(ie,{path:t})}).catch(O=>{console.error(O),T(O)}).finally(()=>{C.current=!1}),z=(te,O)=>{if(_&&!x){console.error("Missing custom Id"),D(!0),O.setSubmitting(!1);return}if(T(void 0),D(!1),e==="existing"){if(!a?.id)throw Error("Form misconfiguration when saving, no id for existing entity")}else if(e==="new"||e==="copy"){if(o.customId&&o.customId!=="optional"&&!x)throw Error("Form misconfiguration when saving, entityId should be set")}else throw Error("New FormType added, check EntityForm");return G(te)?.then(ie=>{O.resetForm({values:te,submitCount:0,touched:{}})}).finally(()=>{O.setSubmitting(!1)})},H=ve.useCreateFormex({initialValues:B.current,onSubmit:z,validation:te=>Y?.validate(te,{abortEarly:!1}).then(()=>({})).catch(O=>{const ie={};return O.inner.forEach(fe=>{ie[fe.path]=fe.message}),Xl(O)})});d.useEffect(()=>{B.current=Pn(v,e,a);const te=H.initialValues;!H.isSubmitting&&te&&e==="existing"?Z(Object.entries(ee.properties).map(([O,ie])=>{if(vt(ie))return{};const fe=te[O],ue=B.current[O];return L(fe,ue)?{}:{[O]:ue}}).reduce((O,ie)=>({...O,...ie}),{})):Z({})},[a,v,e]);const J=te=>{const O=H.initialValues;$(te),l&&l(te),g&&te&&!L(te,O)&&G(te)};d.useEffect(()=>{x&&c&&c(x)},[x,c]);const ee=Ne({collection:o,path:t,entityId:x,values:R,previousValues:H.initialValues,fields:b.propertyConfigs}),ne=Fr(ee,b.propertyConfigs),U=R&&ne?Ye(R,ne):void 0,X=o.callbacks?.onIdUpdate,Q=d.useCallback(async()=>{if(X&&R&&(e==="new"||e==="copy")){re(!0);try{const te=await X({collection:ee,path:t,entityId:x,values:R,context:y});S(te)}catch(te){f&&f(te),console.error(te)}re(!1)}},[x,R,e]);d.useEffect(()=>{Q()},[Q]);const[K,Z]=d.useState({}),M=d.useCallback(({name:te,value:O,property:ie})=>A.checkUniqueField(t,te,O,x),[A,t,x]),Y=d.useMemo(()=>x?Ua(x,ee.properties,M):void 0,[x,ee.properties,M]),q=We(),F=d.useCallback(({entity:te,customEntityActions:O})=>{const ie=ct(o,q,t,null),fe=te?Wt(o,q,t,te):!0,ue=[];return ie&&ue.push(mn),fe&&ue.push(fn),O&&ue.push(...O),ue},[q,o,t]),N=[],le={setFieldValue:d.useCallback(H.setFieldValue,[]),values:H.values,collection:ee,entityId:x,path:t,save:G},xe=d.useRef(null);if(d.useEffect(()=>{u&&!Kl(xe.current??void 0,le)&&(u(le),xe.current=le)},[le,u]),k&&o){const te={entityId:x,path:t,status:e,collection:o,context:y,currentEntityId:x,formContext:le};N.push(...k.map((O,ie)=>O.form?.Actions?r.jsx(O.form.Actions,{...te},`actions_${O.key}`):null).filter(Boolean))}return r.jsx(ve.Formex,{value:H,children:r.jsxs("div",{className:"h-full overflow-auto",children:[N.length>0&&r.jsx("div",{className:p.cn("w-full flex justify-end items-center sticky top-0 right-0 left-0 z-10 bg-opacity-60 bg-slate-200 dark:bg-opacity-60 dark:bg-slate-800 backdrop-blur-md"),children:N}),r.jsxs("div",{className:"pt-12 pb-16 pl-8 pr-8 md:pl-10 md:pr-10",children:[r.jsxs("div",{className:`w-full py-2 flex flex-col items-start mt-${4+(N?8:0)} lg:mt-${8+(N?8:0)} mb-8`,children:[r.jsx(p.Typography,{className:"mt-4 flex-grow line-clamp-1 "+o.hideIdFromForm?"mb-2":"mb-0",variant:"h4",children:U??o.singularName??o.name}),r.jsx(p.Alert,{color:"base",className:"w-full",size:"small",children:r.jsxs("code",{className:"text-xs select-all",children:[t,"/",x]})})]}),!m&&r.jsx(Wl,{customId:o.customId,entityId:x,status:e,onChange:S,error:I,loading:V,entity:a}),x&&r.jsx(Zl,{...H,initialValues:H.initialValues,onModified:s,onDiscard:i,onValuesChanged:J,underlyingChanges:K,entity:a,resolvedCollection:ee,formContext:le,status:e,savingError:P,closeAfterSaveRef:C,autoSave:g,entityActions:F({entity:a,customEntityActions:o.entityActions})})]})]})})}function Zl(e){const{values:t,onDiscard:o,onModified:a,onValuesChanged:n,underlyingChanges:i,formContext:s,entity:l,touched:c,setFieldValue:u,resolvedCollection:m,isSubmitting:g,status:f,handleSubmit:h,resetForm:b,savingError:y,dirty:A,closeAfterSaveRef:k,autoSave:v,entityActions:_}=e,E=Ae(),C=_.filter(P=>P.includeInForm===void 0||P.includeInForm),B=Je(),x=A;d.useEffect(()=>{a&&a(x),n&&n(t)},[x,t]),d.useEffect(()=>{!v&&!g&&i&&l&&Object.entries(i).forEach(([P,T])=>{const V=t[P];!L(T,V)&&!c[P]&&(console.debug("Updated value from the datasource:",P,T),u(P,T!==void 0?T:null))})},[g,v,i,l,t,c,u]);const S=r.jsx("div",{className:"flex flex-col gap-8",children:(m.propertiesOrder??Object.keys(m.properties)).map(P=>{const T=m.properties[P];if(!T)return console.warn(`Property ${P} not found in collection ${m.name}`),null;const V=!!i&&Object.keys(i).includes(P)&&!!c[P],re=!v&&g||st(T)||!!T.disabled;if(vt(T))return null;const $={propertyKey:P,disabled:re,property:T,includeDescription:T.description||T.longDescription,underlyingValueHasChanged:V&&!v,context:s,tableMode:!1,partOfArray:!1,partOfBlock:!1,autoFocus:!1};return r.jsx("div",{id:`form_field_${P}`,children:r.jsx(ae,{children:r.jsx(p.Tooltip,{title:r.jsx(Jl,{propertyId:P}),delayDuration:800,side:"left",align:"start",sideOffset:16,children:r.jsx(ot,{...$})})})},`field_${m.name}_${P}`)}).filter(Boolean)}),I=g||!x&&f==="existing",D=d.useRef(null);return r.jsxs("form",{onSubmit:h,onReset:()=>(console.debug("Resetting form"),b(),o&&o()),noValidate:!0,children:[r.jsxs("div",{className:"mt-12",ref:D,children:[S,r.jsx($l,{containerRef:D})]}),r.jsx("div",{className:"h-14"}),!v&&r.jsxs(p.DialogActions,{position:"absolute",children:[y&&r.jsx("div",{className:"text-right",children:r.jsx(p.Typography,{color:"error",children:y.message})}),l&&C.length>0&&r.jsx("div",{className:"flex-grow flex overflow-auto no-scrollbar",children:C.map(P=>r.jsx(p.IconButton,{color:"primary",onClick:T=>{T.stopPropagation(),l&&P.onClick({entity:l,fullPath:m.path,collection:m,context:E,sideEntityController:B})},children:P.icon},P.name))}),r.jsx(p.Button,{variant:"text",disabled:I,type:"reset",children:f==="existing"?"Discard":"Clear"}),r.jsxs(p.Button,{variant:"text",color:"primary",type:"submit",disabled:I,onClick:()=>{k.current=!1},children:[f==="existing"&&"Save",f==="copy"&&"Create copy",f==="new"&&"Create"]}),r.jsxs(p.Button,{variant:"filled",color:"primary",type:"submit",disabled:I,onClick:()=>{k.current=!0},children:[f==="existing"&&"Save and close",f==="copy"&&"Create copy and close",f==="new"&&"Create and close"]})]})]})}function Xl(e){let t={};if(e.inner){if(e.inner.length===0)return ve.setIn(t,e.path,e.message);for(const o of e.inner)ve.getIn(t,o.path)||(t=ve.setIn(t,o.path,o.message))}return t}function Kl(e,t){return e?.path===t?.path&&e?.entityId===t?.entityId&&L(e?.values,t?.values)&&L(e?.collection,t?.collection)}function Tn(e){return Object.keys(ir).includes(e)}const ir={text_field:{key:"text_field",name:"Text field",description:"Simple short text",Icon:p.ShortTextIcon,color:"#2d7ff9",property:{dataType:"string",Field:bt}},multiline:{key:"multiline",name:"Multiline",description:"Text with multiple lines",Icon:p.SubjectIcon,color:"#2d7ff9",property:{dataType:"string",multiline:!0,Field:bt}},markdown:{key:"markdown",name:"Markdown",description:"Text with advanced markdown syntax",Icon:p.FormatQuoteIcon,color:"#2d7ff9",property:{dataType:"string",markdown:!0,Field:Sn}},url:{key:"url",name:"Url",description:"Text with URL validation",Icon:p.HttpIcon,color:"#154fb3",property:{dataType:"string",url:!0,Field:bt}},email:{key:"email",name:"Email",description:"Text with email validation",Icon:p.EmailIcon,color:"#154fb3",property:{dataType:"string",email:!0,Field:bt}},switch:{key:"switch",name:"Switch",description:"Boolean true or false field (or yes or no, 0 or 1...)",Icon:p.FlagIcon,color:"#20d9d2",property:{dataType:"boolean",Field:vn}},select:{key:"select",name:"Select/enum",description:"Select one text value from within an enumeration",Icon:p.ListIcon,color:"#4223c9",property:{dataType:"string",enumValues:[],Field:po}},multi_select:{key:"multi_select",name:"Multi select",description:"Select multiple text values from within an enumeration",Icon:p.ListAltIcon,color:"#4223c9",property:{dataType:"array",of:{dataType:"string",enumValues:[]},Field:uo}},number_input:{key:"number_input",name:"Number input",description:"Simple number field with validation",Icon:p.NumbersIcon,color:"#bec920",property:{dataType:"number",Field:bt}},number_select:{key:"number_select",name:"Number select",description:"Select a number value from within an enumeration",Icon:p.FormatListNumberedIcon,color:"#bec920",property:{dataType:"number",enumValues:[],Field:po}},multi_number_select:{key:"multi_number_select",name:"Multiple number select",description:"Select multiple number values from within an enumeration",Icon:p.FormatListNumberedIcon,color:"#bec920",property:{dataType:"array",of:{dataType:"number",enumValues:[]},Field:uo}},file_upload:{key:"file_upload",name:"File upload",description:"Input for uploading single files",Icon:p.UploadFileIcon,color:"#f92d9a",property:{dataType:"string",storage:{storagePath:"{path}"},Field:mo}},multi_file_upload:{key:"multi_file_upload",name:"Multiple file upload",description:"Input for uploading multiple files",Icon:p.DriveFolderUploadIcon,color:"#f92d9a",property:{dataType:"array",of:{dataType:"string",storage:{storagePath:"{path}"}},Field:mo}},reference:{key:"reference",name:"Reference",description:"The value refers to a different collection",Icon:p.LinkIcon,color:"#ff0042",property:{dataType:"reference",Field:_n}},multi_references:{key:"multi_references",name:"Multiple references",description:"Multiple values that refer to a different collection",Icon:p.AddLinkIcon,color:"#ff0042",property:{dataType:"array",of:{dataType:"reference"},Field:yn}},date_time:{key:"date_time",name:"Date/time",description:"A date time select field",Icon:p.ScheduleIcon,color:"#8b46ff",property:{dataType:"date",Field:kn}},group:{key:"group",name:"Group",description:"Group of multiple fields",Icon:p.BallotIcon,color:"#ff9408",property:{dataType:"map",properties:{},Field:xn}},key_value:{key:"key_value",name:"Key-value",description:"Flexible field that allows the user to add multiple key-value pairs",Icon:p.BallotIcon,color:"#ff9408",property:{dataType:"map",keyValue:!0,Field:Cn}},repeat:{key:"repeat",name:"Repeat/list",description:"A field that gets repeated multiple times (e.g. multiple text fields)",Icon:p.RepeatIcon,color:"#ff9408",property:{dataType:"array",of:{dataType:"string"},Field:En}},custom_array:{key:"custom_array",name:"Custom array",description:"A field that saved its value as an array of custom objects",Icon:p.RepeatIcon,color:"#ff9408",property:{dataType:"array",of:[],Field:In}},block:{key:"block",name:"Block",description:"A complex field that allows the user to compose different fields together, with a key->value format",Icon:p.ViewStreamIcon,color:"#ff9408",property:{dataType:"array",oneOf:{properties:{}},Field:Bn}}};function Dn(e){const t=sr(e);if(!t){console.error("No field id found for property",e);return}return ir[t]}function Ft(e,t){const o=yo(e),a=sr(e);if(!a){console.error("No field id found for property",e);return}const n=ir[a],i=o?t[o]:void 0;return De(n??{},i??{})}function sr(e){if(e.dataType==="string")return e.multiline?"multiline":e.markdown?"markdown":e.storage?"file_upload":e.url?"url":e.email?"email":e.enumValues?"select":"text_field";if(e.dataType==="number")return e.enumValues?"number_select":"number_input";if(e.dataType==="map")return e.keyValue?"key_value":"group";if(e.dataType==="array"){const t=e.of;return e.oneOf?"block":Array.isArray(t)?"custom_array":ke(t)?"repeat":t?.dataType==="string"&&t.enumValues?"multi_select":t?.dataType==="number"&&t.enumValues?"multi_number_select":t?.dataType==="string"&&t.storage?"multi_file_upload":t?.dataType==="reference"?"multi_references":"repeat"}else{if(e.dataType==="boolean")return"switch";if(e.dataType==="date")return"date_time";if(e.dataType==="reference")return"reference"}console.error("Unsupported field config mapping",e)}function yo(e){return e.propertyConfig?e.propertyConfig:sr(e)}const Ne=({collection:e,path:t,entityId:o,values:a,previousValues:n,userConfigPersistence:i,fields:s})=>{const l=i?.getCollectionConfig(t),c=Ye(l,"properties"),u=kt(e.properties),m=a??u,g=n??a??u,f=Object.entries(e.properties).map(([y,A])=>{const k=Pe({propertyKey:y,propertyOrBuilder:A,values:m,previousValues:g,path:t,entityId:o,fields:s});return k?{[y]:k}:{}}).filter(y=>y!==null).reduce((y,A)=>({...y,...A}),{}),h=De(f,c),b=Object.entries(h).filter(([y,A])=>!!A?.dataType).map(([y,A])=>({[y]:A})).reduce((y,A)=>({...y,...A}),{});return{...e,properties:b,originalCollection:e}};function Pe({propertyOrBuilder:e,fromBuilder:t=!1,...o}){if(typeof e=="object"&&"resolved"in e)return e;let a=null;if(e)if(ke(e)){const n=o.path;if(!n)throw Error("Trying to resolve a property builder without specifying the entity path");const i=o.propertyKey?ve.getIn(o.values,o.propertyKey):void 0,s=e({...o,path:n,propertyValue:i,values:o.values??{},previousValues:o.previousValues??o.values??{}});if(!s)return null;a=Pe({...o,propertyOrBuilder:s,fromBuilder:!0})}else{const n=e;if(n.dataType==="map"&&n.properties){const i=wo({...o,properties:n.properties});a={...n,resolved:!0,fromBuilder:t,properties:i}}else n.dataType==="array"?a=Xe({property:n,fromBuilder:t,...o}):(n.dataType==="string"||n.dataType==="number")&&n.enumValues&&(a=vo(n,t))}else return null;if(a||(a={...e,resolved:!0,fromBuilder:t}),a.propertyConfig&&!Tn(a.propertyConfig)){const n=o.fields;if(!n)throw Error(`Trying to resolve a property with key ${a.propertyConfig} that inherits from a custom property config but no custom property configs were provided. Use the property \`propertyConfigs\` in your app config to provide them`);const i=n[a.propertyConfig];if(!i)return console.warn(`Trying to resolve a property with key ${a.propertyConfig} that inherits from a custom property config but no custom property config with that key was found. Check the \`propertyConfigs\` in your app config`),console.warn("Available property configs",n),null;if(i.property){const s=i.property;"propertyConfig"in s&&delete s.propertyConfig;const l=Pe({propertyOrBuilder:s,...o});l&&(a=De(l,a))}}return a?{...a,resolved:!0}:null}function Xe({propertyKey:e,property:t,...o}){const a=e?ve.getIn(o.values,e):void 0;if(t.of){if(Array.isArray(t.of))return{...t,resolved:!0,fromBuilder:o.fromBuilder,resolvedProperties:t.of.map((n,i)=>Pe({propertyKey:`${e}.${i}`,propertyOrBuilder:n,...o,index:i}))};{const n=t.of,i=Array.isArray(a)?a.map((l,c)=>Pe({propertyKey:`${e}.${c}`,propertyOrBuilder:n,...o,index:c})).filter(l=>!!l):[],s=Pe({propertyKey:`${e}`,propertyOrBuilder:n,...o});if(!s)throw Error("When using a property builder as the 'of' prop of an ArrayProperty, you must return a valid child property");return{...t,resolved:!0,fromBuilder:o.fromBuilder,of:s,resolvedProperties:i}}}else if(t.oneOf){const n=t.oneOf?.typeField??wt,i=Array.isArray(a)?a.map((l,c)=>{const u=l&&l[n],m=t.oneOf?.properties[u];return!u||!m?null:Pe({propertyKey:`${e}.${c}`,propertyOrBuilder:m,...o})}).filter(l=>!!l):[],s=wo({properties:t.oneOf.properties,...o});return{...t,resolved:!0,oneOf:{...t.oneOf,properties:s},fromBuilder:o.fromBuilder,resolvedProperties:i}}else{if(t.Field)return{...t,resolved:!0,fromBuilder:o.fromBuilder};throw Error("The array property needs to declare an 'of' or a 'oneOf' property, or provide a custom `Field`")}}function wo({properties:e,...t}){return Object.entries(e).map(([o,a])=>{const n=Pe({propertyKey:o,propertyOrBuilder:a,...t});return n?{[o]:n}:{}}).filter(o=>o!==null).reduce((o,a)=>({...o,...a}),{})}function vo(e,t){return typeof e.enumValues=="object"?{...e,resolved:!0,enumValues:qe(e.enumValues)?.filter(o=>o&&o.id&&o.label)??[],fromBuilder:t??!1}:e}function Rl(e){return typeof e=="object"?Object.entries(e).map(([t,o])=>typeof o=="string"?{id:t,label:o}:o):Array.isArray(e)?e:void 0}function ko(e,t){return typeof e=="string"?t?.find(o=>o.key===e):e}function _o(e){const{path:t,collections:o=[],currentFullPath:a}=e,n=me(t).split("/"),i=Ot(n),s=[];for(let l=0;l<i.length;l++){const c=i[l],u=o&&o.find(m=>m.id===c||m.path===c);if(u){const m=u.id??u.path,g=a&&a.length>0?a+"/"+m:m;s.push({type:"collection",path:g,collection:u});const f=me(me(t).replace(c,"")),h=f.length>0?f.split("/"):[];if(h.length>0){const b=h[0],y=g+"/"+b;if(s.push({type:"entity",entityId:b,path:g,parentCollection:u}),h.length>1){const A=h.slice(1).join("/");if(!u)throw Error("collection not found resolving path: "+u);const k=u.entityViews,v=k&&k.map(_=>ko(_,e.contextEntityViews)).filter(Boolean).find(_=>_.key===A);if(v){const _=a&&a.length>0?a+"/"+v.key:v.key;s.push({type:"custom_view",path:_,view:v})}else u.subcollections&&s.push(..._o({path:A,collections:u.subcollections,currentFullPath:y,contextEntityViews:e.contextEntityViews}))}}break}}return s}const ec="100vw",tc="55vw",lr="768px",cr="main_##Q$SC^#S6";function rc({path:e,entityId:t,selectedSubPath:o,copy:a,collection:n,parentCollectionIds:i,onValuesAreModified:s,formWidth:l,onUpdate:c,onClose:u}){n.customId&&n.formAutoSave&&console.warn(`The collection ${n.path} has customId and formAutoSave enabled. This is not supported and formAutoSave will be ignored`);const[m,g]=d.useState(!1),[f,h]=d.useState(void 0);Ut(f,()=>{f&&F({entityId:U?.id,collection:n,path:e,values:f,closeAfterSave:!1})},!1,2e3);const b=Me(n),y=dr(),A=Je(),k=He(),v=oe(),_=Ae(),E=We(),[C,B]=d.useState(void 0),[x,S]=d.useState(a?"copy":t?"existing":"new"),I=d.useRef(void 0),D=I.current,P=(n.subcollections??[]).filter(j=>!j.hideFromNavigation),T=P?.length??0,V=n.entityViews,re=V?.length??0,R=n.formAutoSave&&!n.customId,$=re>0||T>0,G=o??Cr(n?n.defaultSelectedView:void 0,{status:x,entityId:t}),z=d.useRef(G??cr),H=z.current===cr,{entity:J,dataLoading:ee,dataLoadingError:ne}=Qr({path:e,entityId:t,collection:n,useCache:!1}),[U,X]=d.useState(J),[Q,K]=d.useState(void 0);d.useEffect(()=>{J&&X(J)},[J]),d.useEffect(()=>{if(x==="new")K(!1);else{const j=U?Ir(n,E,e,U??null):!1;U&&K(!j)}},[E,U,x]);const Z=d.useCallback(j=>{g(!1),k.open({type:"error",message:"Error before saving: "+j?.message}),console.error(j)},[k]),M=d.useCallback(j=>{g(!1),k.open({type:"error",message:"Error after saving (entity is saved): "+j?.message}),console.error(j)},[k]),Y=(j,Be)=>{g(!1),R||k.open({type:"success",message:`${n.singularName??n.name}: Saved correctly`}),X(j),S("existing"),s(!1),c&&c({entity:j}),Be?(y.setBlocked(!1),y.close(!0),u?.()):x!=="existing"&&A.replace({path:e,entityId:j.id,selectedSubPath:z.current,updateUrl:!0,collection:n})},q=d.useCallback(j=>{g(!1),k.open({type:"error",message:"Error saving: "+j?.message}),console.error("Error saving entity",e,t),console.error(j)},[t,e,k]),F=({values:j,previousValues:Be,closeAfterSave:Se,entityId:$e,collection:Nt,path:Pt})=>{g(!0),Mr({path:Pt,entityId:$e,values:j,previousValues:Be,collection:Nt,status:x,dataSource:b,context:_,onSaveSuccess:Tt=>Y(Tt,Se),onSaveFailure:q,onPreSaveHookError:Z,onSaveSuccessHookError:M}).then()},N=async({collection:j,path:Be,entityId:Se,values:$e,previousValues:Nt,closeAfterSave:Pt,autoSave:Tt})=>{x&&(Tt?h($e):F({collection:j,path:Be,entityId:Se,values:$e,previousValues:Nt,closeAfterSave:Pt}))},le=V?V.map(j=>ko(j,v.entityViews)).filter(Boolean):[],xe=V&&le.map((j,Be)=>{if(!j||z.current!==j.key)return null;const Se=j.Builder;return Se?r.jsx("div",{className:p.cn(p.defaultBorderMixin,"relative flex-grow w-full h-full overflow-auto "),role:"tabpanel",children:r.jsx(ae,{children:C&&r.jsx(Se,{collection:n,entity:U,modifiedValues:D??U?.values,formContext:C})})},`custom_view_${j.key}`):(console.error("customView.Builder is not defined"),null)}).filter(Boolean),te=ee&&!U||(!U||Q===void 0)&&(x==="existing"||x==="copy"),O=te||m,ie=P&&P.map((j,Be)=>{const Se=j.id??j.path,$e=U?`${e}/${U?.id}/${me(Se)}`:void 0;return z.current!==Se?null:r.jsxs("div",{className:"relative flex-grow h-full overflow-auto w-full",role:"tabpanel",children:[O&&r.jsx(or,{}),!te&&(U&&$e?r.jsx(io,{fullPath:$e,parentCollectionIds:[...i,n.id],isSubCollection:!0,...j}):r.jsx("div",{className:"flex items-center justify-center w-full h-full p-3",children:r.jsx(p.Typography,{variant:"label",children:"You need to save your entity before adding additional collections"})}))]},`subcol_${Se}`)}).filter(Boolean),fe=d.useCallback(()=>{s(!1)},[]),ue=j=>{z.current=j,A.replace({path:e,entityId:t,selectedSubPath:j===cr?void 0:j,updateUrl:!0,collection:n})},he=d.useCallback(j=>{I.current=j},[]),ze=d.useCallback(j=>{k.open({type:"error",message:"Error updating id, check the console"})},[]),Ve=d.useCallback(j=>{X(Be=>Be?{...Be,id:j}:void 0)},[]),Ge=j=>{R||s(j)};function Ue(){const j=v.plugins;let Be=r.jsx(Nn,{status:x,path:e,collection:n,onEntitySaveRequested:N,onDiscard:fe,onValuesChanged:he,onModified:Ge,entity:U,onIdChange:Ve,onFormContextChange:B,hideId:n.hideIdFromForm,autoSave:R,onIdUpdateError:ze});return j&&j.forEach(Se=>{Se.form?.provider&&(Be=r.jsx(Se.form.provider.Component,{status:x,path:e,collection:n,onDiscard:fe,onValuesChanged:he,onModified:Ge,entity:U,context:_,formContext:C,...Se.form.provider.props,children:Be}))}),r.jsx(ae,{children:Be})}const at=Q===void 0?r.jsx(r.Fragment,{}):Q?r.jsxs(r.Fragment,{children:[r.jsx(p.Typography,{className:"mt-16 mb-8 mx-8",variant:"h4",children:n.singularName??n.name}),r.jsx(qr,{className:"px-12",entity:U,path:e,collection:n})]}):Ue(),Co=P&&P.map(j=>r.jsx(p.Tab,{className:"text-sm min-w-[140px]",value:j.id,children:j.name},`entity_detail_collection_tab_${j.name}`)),Eo=le.map(j=>r.jsx(p.Tab,{className:"text-sm min-w-[140px]",value:j.key,children:j.name},`entity_detail_collection_tab_${j.name}`));return r.jsx("div",{className:"flex flex-col h-full w-full transition-width duration-250 ease-in-out",children:r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:p.cn(p.defaultBorderMixin,"no-scrollbar border-b pl-2 pr-2 pt-1 flex items-end overflow-scroll bg-gray-50 dark:bg-gray-950"),children:[r.jsx("div",{className:"pb-1 self-center",children:r.jsx(p.IconButton,{onClick:()=>(u?.(),y.close(!1)),size:"large",children:r.jsx(p.CloseIcon,{})})}),r.jsx("div",{className:"flex-grow"}),te&&r.jsx("div",{className:"self-center",children:r.jsx(p.CircularProgress,{size:"small"})}),r.jsxs(p.Tabs,{value:z.current,onValueChange:j=>{ue(j)},className:"pl-4 pr-4 pt-0",children:[r.jsx(p.Tab,{disabled:!$,value:cr,className:`${$?"":"hidden"} text-sm min-w-[140px]`,children:n.singularName??n.name}),Eo,Co]})]}),r.jsxs("div",{className:"flex-grow h-full flex overflow-auto flex-row w-full ",style:{},children:[r.jsx("div",{role:"tabpanel",hidden:!H,id:`form_${e}`,className:" w-full",children:te?r.jsx(or,{}):at}),xe,ie]})]})})}function oc(e,t){const[o,a]=d.useState(),{navigator:n}=d.useContext(ge.UNSAFE_NavigationContext),i=ge.useNavigate(),s=()=>{a(void 0)},l=()=>{t(),a(void 0),i(-1)},c=d.useCallback(({action:u,location:m,retry:g})=>{switch(u){case"REPLACE":{g();return}case"POP":a(m)}},[]);return d.useEffect(()=>{if(!e||o||!("block"in n))return;const u=n.block(m=>{const g={...m,retry(){u(),m.retry()}};c(g)});return u},[n,c,e,o]),{navigationWasBlocked:!!o,handleCancel:s,handleOk:l}}function ac({open:e,handleOk:t,handleCancel:o,body:a,title:n}){return r.jsxs(p.Dialog,{open:e,onOpenChange:i=>i?o():t(),children:[r.jsxs(p.DialogContent,{children:[r.jsx(p.Typography,{variant:"h6",children:n}),a,r.jsx(p.Typography,{children:"Are you sure you want to leave this page?"})]}),r.jsxs(p.DialogActions,{children:[r.jsx(p.Button,{variant:"text",onClick:o,autoFocus:!0,children:" Cancel "}),r.jsx(p.Button,{onClick:t,children:" Ok "})]})]})}const Qn=d.createContext({width:"",blocked:!1,setBlocked:e=>{},setBlockedNavigationMessage:e=>{},close:()=>{}}),dr=()=>d.useContext(Qn);function nc(){const t=xt().sidePanels,o=[...t];return o.push(void 0),r.jsx(r.Fragment,{children:o.map((a,n)=>r.jsx(ic,{panel:a,offsetPosition:t.length-n-1},`side_dialog_${n}`))})}function ic({offsetPosition:e,panel:t}){const[o,a]=d.useState(!1),[n,i]=d.useState(!1),[s,l]=d.useState(),c=d.useRef(t?.width),u=c.current,m=xt(),{navigationWasBlocked:g,handleOk:f,handleCancel:h}=oc(n&&!o,()=>i(!1));d.useEffect(()=>{t&&(c.current=t.width)},[t]);const b=()=>{i(!1),a(!1),m.close(),t?.onClose?.()},y=()=>{a(!1)},A=k=>{n&&!k?a(!0):(m.close(),t?.onClose?.())};return r.jsxs(Qn.Provider,{value:{blocked:n,setBlocked:i,setBlockedNavigationMessage:l,width:u,close:A},children:[r.jsxs(p.Sheet,{open:!!t,onOpenChange:k=>!k&&A(),children:[t&&r.jsx("div",{className:"transform max-w-[100vw] lg:max-w-[95vw] flex flex-col h-full transition-all duration-250 ease-in-out bg-white dark:bg-gray-900 ",style:{width:t.width,transform:`translateX(-${e*200}px)`},children:r.jsx(ae,{children:t.component})}),!t&&r.jsx("div",{style:{width:u}})]}),r.jsx(ac,{open:g||o,handleOk:o?b:f,handleCancel:o?y:h,body:s})]})}function sc(e){const{blocked:t,setBlocked:o,setBlockedNavigationMessage:a}=dr(),n=pe(),i=d.useMemo(()=>n.getParentCollectionIds(e.path),[n,e.path]),s=d.useMemo(()=>{if(!e)return;let c=e.collection;const u=n.getCollection(e.path,e.entityId);if(u&&(c=u),!c)throw console.error("ERROR: No collection found in path `",e.path,"`. Entity id: ",e.entityId),Error("ERROR: No collection found in path `"+e.path+"`. Make sure you have defined a collection for this path in the root navigation.");return c},[n,e]);d.useEffect(()=>{function c(u){t&&s&&(u.preventDefault(),u.returnValue=`You have unsaved changes in this ${s.name}. Are you sure you want to leave this page?`)}return typeof window<"u"&&window.addEventListener("beforeunload",c),()=>{typeof window<"u"&&window.removeEventListener("beforeunload",c)}},[t,s]);const l=d.useCallback(c=>{o(c),a(c?r.jsxs(r.Fragment,{children:[" You have unsaved changes in this ",r.jsx("b",{children:s?.singularName??s?.name}),"."]}):void 0)},[s?.name,o,a]);return!e||!s?r.jsx("div",{className:"w-full"}):r.jsx(r.Fragment,{children:r.jsx(ae,{children:r.jsx(rc,{...e,formWidth:e.width,collection:s,parentCollectionIds:i,onValuesAreModified:l})})})}const Mn="new";function lc(e,t){if(t)return ec;const o=!e.selectedSubPath;let a;return e.width?a=typeof e.width=="number"?`${e.width}px`:e.width:e.collection?.sideDialogWidth&&(a=typeof e.collection.sideDialogWidth=="number"?`${e.collection.sideDialogWidth}px`:e.collection.sideDialogWidth),o?a||(e.collection?cc(e.collection):lr):`calc(${tc} + ${a??lr})`}const xo={};function cc(e){if(xo[e.id])return xo[e.id];const t=Ne({collection:e,path:"__ignored"});let o=lr;if(t?.properties){const a=Object.values(t.properties).map(i=>pr(i)),n=Math.max(...a);n<3?o=lr:o=768+32*(n-2)+"px"}return xo[e.id]=o,o}function pr(e,t=0){if(e.dataType==="map"&&e.properties){const o=Object.values(e.properties).flatMap(a=>pr(a,t+1));return Math.max(...o)}else return e.dataType==="array"&&e.oneOf?t+3:e.dataType==="array"&&e.of?Array.isArray(e.of)?Math.max(...e.of.map(o=>pr(o,t+1))):pr(e.of,t+1):t+1}const dc=(e,t)=>{const o=ge.useLocation(),a=d.useRef(!1),n=!Qe();d.useEffect(()=>{if(!e.loading&&!a.current){if(console.debug("Initialising side entity controller"),e.isUrlCollectionPath(o.pathname)){const c=o.hash===`#${Mn}`,u=e.urlPathToDataPath(o.pathname),m=pc(u,e.collections??[],c);for(let g=0;g<m.length;g++){const f=m[g];setTimeout(()=>{g===0?t.replace(ur(f,e.buildUrlCollectionPath,e.resolveAliasesFrom,n)):t.open(ur(f,e.buildUrlCollectionPath,e.resolveAliasesFrom,n))},1)}}a.current=!0}},[o,e.loading,e.isUrlCollectionPath,e.buildUrlCollectionPath,e.resolveAliasesFrom,t,n,e]);const i=d.useCallback(()=>{t.close()},[t]),s=d.useCallback(c=>{if(c.copy&&!c.entityId)throw Error("If you want to copy an entity you need to provide an entityId");const u=Cr(c.collection?c.collection.defaultSelectedView:void 0,{status:c.copy?"copy":c.entityId?"existing":"new",entityId:c.entityId});t.open(ur({selectedSubPath:u,...c},e.buildUrlCollectionPath,e.resolveAliasesFrom,n))},[t,e.buildUrlCollectionPath,e.resolveAliasesFrom,n]),l=d.useCallback(c=>{if(c.copy&&!c.entityId)throw Error("If you want to copy an entity you need to provide an entityId");t.replace(ur(c,e.buildUrlCollectionPath,e.resolveAliasesFrom,n))},[e.buildUrlCollectionPath,e.resolveAliasesFrom,t,n]);return{close:i,open:s,replace:l}};function pc(e,t,o){const a=_o({path:e,collections:t}),n=[];let i="";for(let s=0;s<a.length;s++){const l=a[s];if(l.type==="collection"&&(i=l.path),s>0){const c=a[s-1];if(l.type==="entity")n.push({path:l.path,entityId:l.entityId,copy:!1,width:l.parentCollection?.sideDialogWidth});else if(l.type==="custom_view"){if(c.type==="entity"){const u=n[n.length-1];u&&(u.selectedSubPath=l.view.key)}}else if(l.type==="collection"&&c.type==="entity"){const u=n[n.length-1];u&&(u.selectedSubPath=l.collection.id??l.collection.path)}}}return o&&n.push({path:i,copy:!1}),n}const ur=(e,t,o,a)=>{const n=me(e.path),i=e.entityId?t(`${n}/${e.entityId}/${e.selectedSubPath||""}`):t(`${n}#${Mn}`),s=o(e.path),l={...e,path:s};return{key:`${e.path}/${e.entityId}`,component:r.jsx(sc,{...l}),urlPath:i,parentUrlPath:t(n),width:lc(e,a),onClose:e.onClose}};function uc(){const e=ge.useLocation(),t=ge.useNavigate(),[o,a]=d.useState([]),n=d.useRef(o),i=d.useRef({}),s=d.useRef(0),l=g=>{n.current=g,a(g)};d.useEffect(()=>{const h=(e.state?.panels??[]).map(b=>i.current[b]).filter(b=>!!b);L(n.current.map(b=>b.key),h.map(b=>b.key))||l(h)},[e]);const c=d.useCallback(()=>{if(o.length===0)return;const g=o[o.length-1],f=[...o.slice(0,-1)];if(l(f),s.current>0)g.urlPath&&t(-1),s.current--;else if(g.parentUrlPath){const h=e.state?.base_location??e;t(g.parentUrlPath,{replace:!0,state:{base_location:h,panels:f.map(b=>b.key)}})}},[o,t,e]),u=d.useCallback(g=>{const f=Array.isArray(g)?g:[g];f.forEach(y=>{i.current[y.key]=y}),s.current=s.current+f.length;const h=e.state?.base_location??e,b=[...o,...f];l(b),f.forEach(y=>{y.urlPath&&t(y.urlPath,{state:{base_location:h,panels:b.map(A=>A.key)}})})},[e,t,o]),m=d.useCallback(g=>{const f=Array.isArray(g)?g:[g];f.forEach(y=>{i.current[y.key]=y});const h=e.state?.base_location??e,b=[...o.slice(0,-f.length),...f];l(b),f.forEach(y=>{y.urlPath&&t(y.urlPath,{replace:!0,state:{base_location:h,panels:b.map(A=>A.key)}})})},[e,t,o]);return{sidePanels:o,close:c,open:u,replace:m}}function mc({delegate:e,propertyConfigs:t,navigationController:o}){return{fetchCollection:d.useCallback(({path:a,collection:n,filter:i,limit:s,startAfter:l,searchString:c,orderBy:u,order:m})=>e.fetchCollection({path:a,filter:i,limit:s,startAfter:l,searchString:c,orderBy:u,order:m}),[e]),listenCollection:e.listenCollection?d.useCallback(({path:a,collection:n,filter:i,limit:s,startAfter:l,searchString:c,orderBy:u,order:m,onUpdate:g,onError:f})=>{const h=n??o.getCollection(a),b=!!h?.collectionGroup;if(!e.listenCollection)throw Error("useBuildDataSource delegate not initialised");return e.listenCollection({path:a,filter:i,limit:s,startAfter:l,searchString:c,orderBy:u,order:m,onUpdate:g,onError:f,isCollectionGroup:b,collection:h})},[e,o.getCollection]):void 0,fetchEntity:d.useCallback(({path:a,entityId:n})=>e.fetchEntity({path:a,entityId:n}),[e]),listenEntity:e.listenEntity?d.useCallback(({path:a,entityId:n,collection:i,onUpdate:s,onError:l})=>{if(!e.listenEntity)throw Error("useBuildDataSource delegate not initialised");return e.listenEntity({path:a,entityId:n,onUpdate:s,onError:l})},[e.listenEntity]):void 0,saveEntity:d.useCallback(({path:a,entityId:n,values:i,collection:s,status:l})=>{const c=s??o.getCollection(a),m=(c?Ne({collection:c,path:a,entityId:n,fields:t}):void 0)?.properties,g=e.cmsToDelegateModel(i),f=m?Oo({inputValues:g,properties:m,status:l,timestampNowValue:e.currentTime(),setDateToMidnight:e.setDateToMidnight}):g;return e.saveEntity({path:a,entityId:n,values:f,status:l}).then(h=>({id:h.id,path:h.path,values:e.delegateToCMSModel(f)}))},[e.saveEntity,o.getCollection]),deleteEntity:d.useCallback(({entity:a})=>e.deleteEntity({entity:a}),[e.deleteEntity]),checkUniqueField:d.useCallback((a,n,i,s)=>e.checkUniqueField(a,n,i,s),[e.checkUniqueField]),generateEntityId:d.useCallback(a=>e.generateEntityId(a),[e.generateEntityId]),countEntities:e.countEntities?async({path:a,collection:n,filter:i,order:s,orderBy:l})=>e.countEntities({path:a,filter:i,orderBy:l,order:s,isCollectionGroup:!!n.collectionGroup}):void 0,isFilterCombinationValid:d.useCallback(({path:a,filterValues:n,sortBy:i})=>e.isFilterCombinationValid?e.isFilterCombinationValid({path:a,filterValues:n,sortBy:i}):!0,[e.isFilterCombinationValid])}}function xc(e){return e}const fc="https://api-drplyi3b6q-ey.a.run.app";async function hc(e,t){const o=await e.getAuthToken();return fetch(fc+"/access_log",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${o}`},body:JSON.stringify({plugins:t})}).then(async a=>a.json())}function gc(e,t){const[o,a]=d.useState(null),n=d.useRef(null),i=t?.map(s=>s.key);return d.useEffect(()=>{e.user&&e.user.uid!==n.current&&!e.initialLoading&&(hc(e,i).then(a),n.current=e.user.uid)},[e,i]),o}function Ac(e){const t=Or(),{children:o,entityLinkBuilder:a,userConfigPersistence:n,dateTimeFormat:i,locale:s,authController:l,storageSource:c,dataSourceDelegate:u,plugins:m,onAnalyticsEvent:g,propertyConfigs:f,entityViews:h,components:b,navigationController:y}=e;p.useLocaleConfig(s);const A=mc({delegate:u,propertyConfigs:f,navigationController:y}),k=uc(),v=dc(y,k),_=m?.some(S=>S.loading)??!1,E=l.initialLoading||y.loading||_,C={dateTimeFormat:i,locale:s,entityLinkBuilder:a,plugins:m,entityViews:h??[],propertyConfigs:f??{},components:b},B=d.useMemo(()=>({onAnalyticsEvent:g}),[]),x=gc(l,m);return y.navigationLoadingError?r.jsx(p.CenteredView,{maxWidth:"md",children:r.jsx(ye,{title:"Error loading navigation",error:y.navigationLoadingError})}):l.authError?r.jsx(p.CenteredView,{maxWidth:"md",children:r.jsx(ye,{title:"Error loading auth",error:l.authError})}):x?.blocked?r.jsxs(p.CenteredView,{maxWidth:"md",fullScreen:!0,children:[r.jsx(p.Typography,{variant:"h4",children:"Access blocked"}),r.jsxs(p.Typography,{children:["This app has been blocked. Please reach out at ",r.jsx("a",{href:"mailto:hello@firecms.co",children:"hello@firecms.co"})," for more information."]}),x?.message&&r.jsxs(p.Typography,{children:["Response from the server: ",x?.message]})]}):r.jsx(Qt.Provider,{value:t,children:r.jsx(ua.Provider,{value:B,children:r.jsx(pa.Provider,{value:C,children:r.jsx(ca.Provider,{value:n,children:r.jsx(la.Provider,{value:c,children:r.jsx(aa.Provider,{value:A,children:r.jsx(fr.Provider,{value:l,children:r.jsx(ia.Provider,{value:k,children:r.jsx(sa.Provider,{value:v,children:r.jsx(na.Provider,{value:y,children:r.jsx(Fi,{children:r.jsx(bc,{loading:E,children:o})})})})})})})})})})})})}function bc({loading:e,children:t}){const o=Ae(),a=oe();let n=t({context:o,loading:e});const i=a.plugins;return!e&&i&&i.forEach(s=>{s.provider&&(n=r.jsx(s.provider.Component,{...s.provider.props,context:o,children:n}))}),r.jsx(r.Fragment,{children:n})}function On({hovered:e,drawerOpen:t,closeDrawer:o}){const a=ut(),n=pe(),i=e&&!t,s=Qe(),l=ge.useNavigate(),[c,u]=d.useState(!1);if(!n.topLevelNavigation)throw Error("Navigation not ready in Drawer");const{navigationEntries:m,groups:g}=n.topLevelNavigation,f=m.filter(A=>A.type==="admin")??[],h=g.filter(A=>A!=="Admin"),b=d.useCallback(A=>t?r.jsx("div",{className:"pt-8 pl-6 pr-8 pb-2 flex flex-row items-center",children:r.jsx(p.Typography,{variant:"caption",color:"secondary",className:"font-medium flex-grow line-clamp-1",children:A?A.toUpperCase():"Views".toUpperCase()})}):r.jsx("div",{className:"h-12 w-full"}),[t]),y=A=>{const k=A.type==="collection"?"drawer_navigate_to_collection":A.type==="view"?"drawer_navigate_to_view":"unmapped_event";a.onAnalyticsEvent?.(k,{url:A.url}),s||o()};return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-grow overflow-scroll no-scrollbar",children:h.map(A=>r.jsxs(d.Fragment,{children:[b(A),Object.values(m).filter(k=>k.group===A).map((k,v)=>r.jsx(zn,{icon:r.jsx(Zt,{collectionOrView:k.collection??k.view}),tooltipsOpen:i,drawerOpen:t,onClick:()=>y(k),url:k.url,name:k.name},`navigation_${v}`))]},`drawer_group_${A}`))}),f.length>0&&r.jsx(p.Menu,{open:c,onOpenChange:u,trigger:r.jsxs(p.IconButton,{shape:"square",className:"m-4 text-gray-900 dark:text-white w-fit",children:[r.jsx(p.Tooltip,{title:"Admin",open:i,side:"right",sideOffset:28,children:r.jsx(p.MoreVertIcon,{})}),t&&r.jsx("div",{className:p.cn(t?"opacity-100":"opacity-0 hidden","mx-4 font-inherit text-inherit"),children:"ADMIN"})]}),children:f.map((A,k)=>r.jsxs(p.MenuItem,{onClick:v=>{v.preventDefault(),l(A.path)},children:[r.jsx(Zt,{collectionOrView:A.view}),A.name]},`navigation_${k}`))})]})}function zn({name:e,icon:t,drawerOpen:o,tooltipsOpen:a,url:n,onClick:i}){const s=r.jsx("div",{className:"text-gray-600 dark:text-gray-500",children:t}),l=r.jsxs(ge.NavLink,{onClick:i,style:{width:o?"280px":"72px",transition:o?"width 150ms ease-in":void 0},className:({isActive:c})=>p.cn("rounded-r-xl truncate","hover:bg-slate-300 hover:bg-opacity-75 dark:hover:bg-gray-700 dark:hover:bg-opacity-75 text-gray-800 dark:text-gray-200 hover:text-gray-900 hover:dark:text-white","flex flex-row items-center mr-8",o?"pl-8 h-12":"pl-6 h-11","font-medium text-sm",c?"bg-slate-200 bg-opacity-75 dark:bg-gray-800":""),to:n,children:[s,r.jsx("div",{className:p.cn(o?"opacity-100":"opacity-0 hidden","ml-4 font-inherit text-inherit"),children:e.toUpperCase()})]});return r.jsx(p.Tooltip,{open:o?!1:a,side:"right",title:e,children:l})}const yc=280,wc=d.memo(function(t){const{children:o,name:a,logo:n,includeDrawer:i=!0,autoOpenDrawer:s,Drawer:l=On,drawerProps:c,FireCMSAppBar:u=An,fireCMSAppBarProps:m}=t,g=Qe(),[f,h]=d.useState(!1),[b,y]=d.useState(!1),A=d.useCallback(()=>y(!0),[]),k=d.useCallback(()=>y(!1),[]),v=d.useCallback(()=>{h(!1)},[]),_=f||!!(g&&s&&b);return r.jsxs("div",{className:"flex h-screen w-screen bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white overflow-hidden",style:{paddingTop:"env(safe-area-inset-top)",paddingLeft:"env(safe-area-inset-left)",paddingRight:"env(safe-area-inset-right)",paddingBottom:"env(safe-area-inset-bottom)",height:"100dvh"},children:[r.jsx(u,{title:a,includeDrawer:i,logo:n,drawerOpen:_,...m}),r.jsx(kc,{displayed:i,onMouseEnter:A,onMouseMove:A,onMouseLeave:k,open:_,logo:n,hovered:b,setDrawerOpen:h,children:i&&r.jsx(l,{hovered:b,drawerOpen:_,closeDrawer:v,...c})}),r.jsxs("main",{className:"flex flex-col flex-grow overflow-auto",children:[r.jsx(vc,{}),r.jsx("div",{className:p.cn(p.defaultBorderMixin,"flex-grow overflow-auto lg:m-0 lg:mx-4 lg:mb-4 lg:rounded-lg lg:border lg:border-solid m-0 mt-1"),children:r.jsx(ae,{children:o})})]})]})},L),vc=()=>r.jsx("div",{className:"flex flex-col min-h-[68px]"});function kc(e){const t=pe(),o=e.displayed?e.open?yc:72:0,a=r.jsxs("div",{className:"relative h-full no-scrollbar overflow-y-auto overflow-x-hidden",style:{width:o,transition:"left 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms"},children:[!e.open&&e.displayed&&r.jsx(p.Tooltip,{title:"Open menu",side:"right",sideOffset:12,className:"fixed top-2 left-3 !bg-gray-50 dark:!bg-gray-900 rounded-full w-fit",children:r.jsx(p.IconButton,{color:"inherit","aria-label":"Open menu",className:"sticky top-2 left-3 ",onClick:()=>e.setDrawerOpen(!0),size:"large",children:r.jsx(p.MenuIcon,{})})}),r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx("div",{style:{transition:"padding 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms",padding:e.open?"32px 144px 0px 24px":"72px 16px 0px"},className:p.cn("cursor-pointer"),children:r.jsx(p.Tooltip,{title:"Home",sideOffset:20,side:"right",children:r.jsx(ge.Link,{to:t.basePath,children:e.logo?r.jsx("img",{src:e.logo,alt:"Logo",className:p.cn("max-w-full max-h-full",e.open??"w-[112px] h-[112px]")}):r.jsx(so,{})})})}),e.children]})]});return Qe()?r.jsxs("div",{className:"relative",onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseLeave:e.onMouseLeave,style:{width:o,transition:"left 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms"},children:[a,r.jsx("div",{className:`absolute right-0 top-4 ${e.open?"opacity-100":"opacity-0 invisible"} transition-opacity duration-1000 ease-in-out`,children:r.jsx(p.IconButton,{"aria-label":"Close drawer",onClick:()=>e.setDrawerOpen(!1),children:r.jsx(p.ChevronLeftIcon,{})})})]}):e.displayed?r.jsxs(r.Fragment,{children:[r.jsx(p.IconButton,{color:"inherit","aria-label":"Open drawer",onClick:()=>e.setDrawerOpen(!0),size:"large",className:"absolute top-2 left-6",children:r.jsx(p.MenuIcon,{})}),r.jsx(p.Sheet,{side:"left",transparent:!0,open:e.open,onOpenChange:e.setDrawerOpen,children:a})]}):null}const _c=d.memo(function({homePage:t=r.jsx(dn,{}),customRoutes:o}){const a=ge.useLocation(),n=pe();if(!n)return r.jsx(r.Fragment,{});const i=a.state,s=i&&i.base_location?i.base_location:a,l=[];n.views&&n.views.forEach(f=>{Array.isArray(f.path)?l.push(...f.path.map(h=>mr(h,f))):l.push(mr(f.path,f))}),n.adminViews&&n.adminViews.forEach(f=>{Array.isArray(f.path)?l.push(...f.path.map(h=>mr(h,f))):l.push(mr(f.path,f))});const u=[...n.collections??[]].sort((f,h)=>h.path.length-f.path.length).map(f=>{const h=n.buildUrlCollectionPath(f.id??f.path);return r.jsx(ge.Route,{path:h+"/*",element:r.jsx(ae,{children:r.jsx(io,{isSubCollection:!1,parentCollectionIds:[],fullPath:f.id??f.path,...f,Actions:St(f.Actions)},`collection_view_${f.id??f.path}`)})},`navigation_${f.id??f.path}`)}),m=r.jsx(ge.Route,{path:"/",element:t}),g=r.jsx(ge.Route,{path:"*",element:r.jsx(gn,{})});return r.jsxs(ge.Routes,{location:s,children:[u,l,m,g,o]})}),mr=(e,t)=>r.jsx(ge.Route,{path:e,element:t.view},"navigation_view_"+e);w.ArrayContainer=lo,w.ArrayContainerItem=co,w.ArrayCustomShapedFieldBinding=In,w.ArrayEnumPreview=Lr,w.ArrayItemOptions=bn,w.ArrayOfMapsPreview=ds,w.ArrayOfReferencesFieldBinding=yn,w.ArrayOfReferencesPreview=Sa,w.ArrayOfStorageComponentsPreview=Ia,w.ArrayOfStringsPreview=Fa,w.ArrayOneOfPreview=Na,w.ArrayPropertyEnumPreview=Ur,w.ArrayPropertyPreview=jr,w.AsyncPreviewComponent=ps,w.AuthControllerContext=fr,w.BlockFieldBinding=Bn,w.BooleanPreview=Da,w.COLLECTION_PATH_SEPARATOR=Lo,w.CircularProgressCenter=or,w.DEFAULT_FIELD_CONFIGS=ir,w.DatePreview=Ta,w.DateTimeFieldBinding=kn,w.DefaultHomePage=dn,w.DeleteConfirmationDialog=vl,w.Drawer=On,w.DrawerNavigationItem=zn,w.EmptyValue=et,w.EntityCollectionRowActions=tr,w.EntityCollectionTable=eo,w.EntityCollectionView=io,w.EntityCollectionViewActions=pn,w.EntityForm=Nn,w.EntityReference=gr,w.EntityView=qr,w.EnumValuesChip=Ie,w.ErrorBoundary=ae,w.ErrorView=ye,w.FieldCaption=Bl,w.FieldHelperText=Ce,w.FireCMS=Ac,w.FireCMSAppBar=An,w.FireCMSLogo=so,w.FormikArrayContainer=nr,w.GeoPoint=Ar,w.IconForView=Zt,w.ImagePreview=ka,w.KeyValueFieldBinding=Cn,w.KeyValuePreview=$r,w.LabelWithIcon=Ee,w.MapFieldBinding=xn,w.MapPropertyPreview=Pa,w.MarkdownFieldBinding=Sn,w.ModeControllerContext=Qt,w.ModeControllerProvider=Kn,w.MultiSelectBinding=uo,w.NavigationCard=sn,w.NavigationCardBinding=cn,w.NavigationGroup=ao,w.NavigationRoutes=_c,w.NotFoundPage=gn,w.NumberPropertyPreview=Qa,w.PropertyConfigBadge=wl,w.PropertyFieldBinding=ot,w.PropertyPreview=we,w.PropertyTableCell=qa,w.ReadOnlyFieldBinding=fo,w.ReferenceFieldBinding=_n,w.ReferencePreview=Oe,w.ReferenceSelectionTable=nn,w.ReferenceWidget=xl,w.RepeatFieldBinding=En,w.Scaffold=wc,w.SearchIconsView=El,w.SelectFieldBinding=po,w.SelectableTable=on,w.SideDialogs=nc,w.SkeletonPropertyComponent=tt,w.SmallNavigationCard=ln,w.SnackbarProvider=Zn,w.StorageThumbnail=_a,w.StorageThumbnailInternal=Ca,w.StorageUploadFieldBinding=mo,w.StringPropertyPreview=Yr,w.SwitchFieldBinding=vn,w.TextFieldBinding=bt,w.UrlComponentPreview=Et,w.Vector=ti,w.VirtualTable=Ka,w.addInitialSlash=Rn,w.applyPermissionsFunctionIfEmpty=Yo,w.buildAdditionalFieldDelegate=Bi,w.buildCollection=wi,w.buildEntityCallbacks=Ei,w.buildEnumLabel=Vo,w.buildEnumValueConfig=Ci,w.buildEnumValues=xi,w.buildFieldConfig=Si,w.buildIdColumn=Ls,w.buildProperties=ki,w.buildPropertiesOrBuilder=_i,w.buildProperty=vi,w.canCreateEntity=ct,w.canDeleteEntity=Wt,w.canEditEntity=Ir,w.defaultDateFormat=jo,w.deleteEntityWithCallbacks=ma,w.enumToObjectEntries=qe,w.flattenObject=Nr,w.fullPathToCollectionSegments=Br,w.getArrayValuesCount=Xo,w.getBracketNotation=hi,w.getCollectionByPathOrId=Mt,w.getCollectionPathsCombinations=Ot,w.getColorForProperty=fi,w.getColorScheme=zo,w.getColumnKeysForProperty=rr,w.getDefaultFieldConfig=Dn,w.getDefaultFieldId=sr,w.getDefaultPropertiesOrder=gi,w.getDefaultValueFor=Gt,w.getDefaultValueForDataType=kr,w.getDefaultValuesFor=kt,w.getEntityImagePreviewPropertyKey=Zo,w.getEntityPreviewKeys=Ho,w.getEntityTitlePropertyKey=Fr,w.getFieldConfig=Ft,w.getFieldId=yo,w.getHashValue=yr,w.getIcon=Jo,w.getIconForProperty=_e,w.getIconForWidget=$t,w.getIdIcon=mi,w.getLabelOrConfigFrom=jt,w.getLastSegment=ei,w.getPropertiesWithPropertiesOrder=Wo,w.getPropertyInPath=Re,w.getRandomId=It,w.getReferenceFrom=je,w.getResolvedPropertyInPath=Sr,w.getSidePanelKey=Yi,w.getValueInPath=Ye,w.hydrateRegExp=$o,w.iconSynonyms=Jt,w.iconsSearch=Ht,w.isDefaultFieldConfigId=Tn,w.isEmptyObject=vr,w.isEnumValueDisabled=ai,w.isHidden=vt,w.isObject=zt,w.isPropertyBuilder=ke,w.isReadOnly=st,w.isReferenceProperty=qo,w.isValidRegExp=ui,w.joinCollectionLists=ea,w.makePropertiesEditable=Ko,w.makePropertiesNonEditable=Ro,w.mergeCollection=ta,w.mergeDeep=De,w.pick=Qo,w.plural=bi,w.printChanged=Tr,w.propertiesToColumns=Za,w.randomColor=ci,w.randomString=lt,w.removeFunctions=br,w.removeInPath=ri,w.removeInitialAndTrailingSlashes=me,w.removeInitialSlash=To,w.removePropsIfExisting=Mo,w.removeTrailingSlash=Do,w.removeUndefined=wr,w.renderSkeletonCaptionText=os,w.renderSkeletonIcon=Gr,w.renderSkeletonImageThumbnail=Vr,w.renderSkeletonText=Le,w.resolveArrayProperty=Xe,w.resolveCollection=Ne,w.resolveCollectionPathIds=hr,w.resolveDefaultSelectedView=Cr,w.resolveEntityView=ko,w.resolveEnumValues=Rl,w.resolveNavigationFrom=fa,w.resolvePermissions=_t,w.resolveProperties=wo,w.resolveProperty=Pe,w.resolvePropertyEnum=vo,w.sanitizeData=oi,w.saveEntityWithCallbacks=Mr,w.segmentsToStrippedPath=Uo,w.serializeRegExp=pi,w.singular=yi,w.slugify=Lt,w.sortProperties=xr,w.stripCollectionPath=Er,w.toKebabCase=ii,w.toSnakeCase=li,w.traverseValueProperty=Yt,w.traverseValuesProperties=_r,w.unslugify=di,w.updateDateAutoValues=Oo,w.useAuthController=We,w.useBrowserTitleAndIcon=Oi,w.useBuildLocalConfigurationPersistence=Ui,w.useBuildModeController=$i,w.useBuildNavigationController=Gi,w.useClearRestoreValue=Te,w.useClipboard=ha,w.useCollectionFetch=Pi,w.useColumnIds=Xr,w.useCustomizationController=oe,w.useDataSource=Me,w.useDataSourceEntityCollectionTableController=to,w.useDebouncedCallback=Ut,w.useDebouncedData=an,w.useEntityFetch=Qr,w.useFireCMSContext=Ae,w.useLargeLayout=Qe,w.useModeController=Or,w.useNavigationController=pe,w.useReferenceDialog=mt,w.useResolvedNavigationFrom=Ti,w.useSelectionController=ro,w.useSideDialogContext=dr,w.useSideDialogsController=xt,w.useSideEntityController=Je,w.useSnackbarController=He,w.useStorageSource=dt,w.useTableSearchHelper=oo,w.useTraceUpdate=Ii,w.useValidateAuthenticator=qi,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
|
589
589
|
//# sourceMappingURL=index.umd.js.map
|