@firecms/core 3.0.0-canary.24 → 3.0.0-canary.25
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 +3 -8
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/storage.d.ts +11 -3
- package/package.json +4 -4
- package/src/hooks/useBuildNavigationController.tsx +1 -7
- package/src/internal/useBuildSideEntityController.tsx +2 -0
- package/src/types/storage.ts +12 -3
package/dist/index.umd.js
CHANGED
|
@@ -585,5 +585,5 @@
|
|
|
585
585
|
}
|
|
586
586
|
|
|
587
587
|
`;function gn({propertyKey:e,value:t,error:o,showError:a,isSubmitting:i,setValue:n,tableMode:s,property:c,includeDescription:l,underlyingValueHasChanged:u,context:m,disabled:h}){if(!Array.isArray(c.resolvedProperties))throw Error("ArrayCustomShapedFieldBinding misconfiguration. Property `of` not set");const f=c.expanded===void 0?!0:c.expanded;Te({property:c,value:t,setValue:n});const A=r.jsx(Ce,{icon:ve(c,"small"),required:c.validation?.required,className:"text-text-secondary dark:text-text-secondary-dark",title:c.name}),g=c.resolvedProperties.map((b,y)=>{const k={propertyKey:`${e}[${y}]`,disabled:h,property:b,includeDescription:l,underlyingValueHasChanged:u,context:m,tableMode:!1,partOfArray:!0,partOfBlock:!1,autoFocus:!1};return r.jsx("div",{className:"pb-4",children:r.jsx(tt,{...k})},`custom_shaped_array_${y}`)});return r.jsxs(r.Fragment,{children:[!s&&r.jsx(p.ExpandablePanel,{initiallyExpanded:f,title:A,className:"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2",children:g}),s&&g,r.jsx(xe,{includeDescription:l,showError:a,error:o,disabled:h,property:c})]})}const Al=({containerRef:e})=>{const{isSubmitting:t,isValidating:o,errors:a}=_e.useFormex();return d.useEffect(()=>{const i=Object.keys(a);if(i.length>0&&t&&!o){const n=e?.current?.querySelector(`#form_field_${i[0]}`);if(n&&e?.current){const s=An(e.current);if(s){const l=n.getBoundingClientRect().top;s.scrollTo({top:s.scrollTop+l-196,behavior:"smooth"})}const c=n.querySelector("input");c&&c.focus()}}},[t,o,a,e]),null},bl=e=>{const t=e&&e.scrollHeight>e.clientHeight,o=e?window.getComputedStyle(e).overflowY:null,a=o&&o.indexOf("hidden")!==-1;return t&&!a},An=e=>!e||e===document.body?document.body:bl(e)?e:An(e.parentNode);function yl({customId:e,entityId:t,status:o,onChange:a,error:i,entity:n,loading:s}){const{errors:c}=_e.useFormex(),l=o==="existing"||!e,u=o!=="existing"&&!e,m=d.useMemo(()=>{if(!(!e||typeof e=="boolean"||e==="optional"))return Ue(e)},[e]),h=Je(),{copy:f}=ma({onSuccess:b=>h.open({type:"success",message:`Copied ${b}`})}),A=ae(),g={label:u?"ID is set automatically":"ID",disabled:l||s,name:"id",value:(n&&o==="existing"?n.id:t)??"",endAdornment:s?r.jsx(p.CircularProgress,{size:"small"}):n?r.jsxs(r.Fragment,{children:[r.jsx(p.Tooltip,{title:"Copy",children:r.jsx(p.IconButton,{onClick:b=>f(n.id),"aria-label":"copy-id",children:r.jsx(p.ContentCopyIcon,{size:"small"})})}),A?.entityLinkBuilder&&r.jsx(p.Tooltip,{title:"Open in the console",children:r.jsx(p.IconButton,{component:"a",href:A.entityLinkBuilder({entity:n}),rel:"noopener noreferrer",target:"_blank",onClick:b=>b.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:i,onValueChange:b=>a(b),...g,renderValue:b=>{const y=m.find(k=>k.id===b);return y?`${y.id} - ${y.label}`:b},children:m.map(b=>r.jsx(p.SelectItem,{value:String(b.id),children:r.jsx(Se,{enumKey:b.id,enumValues:m,size:"medium"})},b.id))}),!m&&r.jsx(p.TextField,{...g,error:i,placeholder:e==="optional"?"Autogenerated ID, it can be manually changed":o==="new"||o==="copy"?"ID of the new document":"ID of the document",onChange:b=>{let y=b.target.value;return y&&(y=y.trim()),a(y.length?y:void 0)}}),c.id&&r.jsx(p.Typography,{variant:"caption",className:"ml-3.5 text-red-500 dark:text-red-500",children:c.id})]})}function bn({entityOrEntitiesToDelete:e,collection:t,onClose:o,open:a,callbacks:i,onEntityDelete:n,onMultipleEntitiesDelete:s,path:c}){const l=ze(t),u=ae(),m=Je(),[h,f]=d.useState(!1),[A,g]=d.useState(),[b,y]=d.useState(),k=Ae();d.useEffect(()=>{if(e){const T=Array.isArray(e)&&e.length===1?e[0]:e;g(T),y(Array.isArray(T))}},[e]);const v=d.useMemo(()=>Pe({collection:t,path:c,fields:u.propertyConfigs}),[t,c]),_=d.useCallback(()=>{o()},[o]),E=d.useCallback(T=>{console.debug("Deleted",T)},[]),C=d.useCallback((T,z)=>{m.open({type:"error",message:"Error deleting: "+z?.message}),console.error("Error deleting entity"),console.error(z)},[v.name]),B=d.useCallback((T,z)=>{m.open({type:"error",message:"Error before deleting: "+z?.message}),console.error(z)},[v.name]),x=d.useCallback((T,z)=>{m.open({type:"error",message:"Error after deleting: "+z?.message}),console.error(z)},[v.name]),S=d.useCallback(T=>pa({dataSource:l,entity:T,collection:v,callbacks:i,onDeleteSuccess:E,onDeleteFailure:C,onPreDeleteHookError:B,onDeleteSuccessHookError:x,context:k}),[l,v,i,E,C,B,x,k]),I=d.useCallback(async()=>{A&&(f(!0),b?Promise.all(A.map(S)).then(T=>{f(!1),s&&A&&s(c,A),T.every(Boolean)?m.open({type:"success",message:`${v.name}: multiple deleted`}):T.some(Boolean)?m.open({type:"warning",message:`${v.name}: Some of the entities have been deleted, but not all`}):m.open({type:"error",message:`${v.name}: Error deleting entities`}),o()}):S(A).then(T=>{f(!1),T&&(n&&A&&n(c,A),m.open({type:"success",message:`${v.singularName??v.name} deleted`}),o())}))},[A,b,S,s,c,o,m,v.name,n]);let Q;if(A&&b)Q=r.jsx(r.Fragment,{children:"Multiple entities"});else{const T=A;Q=T?r.jsx(Wr,{entity:T,collection:t,path:c}):r.jsx(r.Fragment,{})}const P=b?r.jsxs(r.Fragment,{children:[r.jsx("b",{children:v.name}),": Confirm multiple delete?"]}):`Would you like to delete this ${v.singularName??v.name}?`;return r.jsxs(p.Dialog,{maxWidth:b?"lg":"2xl","aria-labelledby":"delete-dialog",open:a,onOpenChange:T=>T?void 0:o(),children:[r.jsxs(p.DialogContent,{fullHeight:!0,children:[r.jsx(p.Typography,{variant:"subtitle2",className:"p-4",children:P}),!b&&r.jsx("div",{className:"p-4",children:Q})]}),r.jsxs(p.DialogActions,{children:[h&&r.jsx(p.CircularProgress,{size:"small"}),r.jsx(p.Button,{onClick:_,disabled:h,variant:"text",color:"primary",children:"Cancel"}),r.jsx(p.Button,{autoFocus:!0,disabled:h,onClick:I,variant:"filled",color:"primary",children:"Ok"})]})]})}const wl={icon:r.jsx(p.KeyboardTabIcon,{}),name:"Edit",collapsed:!1,onClick({entity:e,collection:t,fullPath:o,context:a,highlightEntity:i,unhighlightEntity:n}){i?.(e),a.analyticsController?.onAnalyticsEvent?.("entity_click",{path:e.path,entityId:e.id});const s=t?.collectionGroup?e.path:o??e.path;return a.sideEntityController.open({entityId:e.id,path:s,collection:t,updateUrl:!0,onClose:()=>n?.(e)}),Promise.resolve(void 0)}},yn={icon:r.jsx(p.FileCopyIcon,{}),name:"Copy",onClick({entity:e,collection:t,context:o,highlightEntity:a,unhighlightEntity:i}){return a?.(e),o.analyticsController?.onAnalyticsEvent?.("copy_entity_click",{path:e.path,entityId:e.id}),o.sideEntityController.open({entityId:e.id,path:e.path,copy:!0,collection:t,updateUrl:!0,onClose:()=>i?.(e)}),Promise.resolve(void 0)}},wn={icon:r.jsx(p.DeleteIcon,{}),name:"Delete",onClick({entity:e,fullPath:t,collection:o,context:a,selectionController:i,onCollectionChange:n,sideEntityController:s}){const{closeDialog:c}=a.dialogsController.open({key:"delete_entity_dialog_"+e.id,Component:({open:l})=>{if(!o||!t)throw new Error("deleteEntityAction: Collection is undefined");return r.jsx(bn,{entityOrEntitiesToDelete:e,path:t,collection:o,callbacks:o.callbacks,open:l,onEntityDelete:()=>{a.analyticsController?.onAnalyticsEvent?.("single_entity_deleted",{path:t}),i?.setSelectedEntities(i.selectedEntities.filter(u=>u.id!==e.id)),n?.(),s?.close()},onClose:c})}});return Promise.resolve(void 0)}};function vl({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 vn=d.memo(kl,(e,t)=>e.status===t.status&&e.path===t.path&&$(e.entity?.values,t.entity?.values));function kn(e,t,o){const a=e.properties;if((t==="existing"||t==="copy")&&o)return o.values??vt(a);if(t==="new")return vt(a);throw console.error({status:t,entity:o}),new Error("Form has not been initialised with the correct parameters")}function kl({status:e,path:t,collection:o,entity:a,onEntitySaveRequested:i,onDiscard:n,onModified:s,onValuesChanged:c,onIdChange:l,onFormContextChange:u,hideId:m,autoSave:h,onIdUpdateError:f}){const A=pt(),g=ae(),b=Ae(),y=ze(o),k=g.plugins,v=d.useMemo(()=>Pe({collection:o,path:t,values:a?.values,fields:g.propertyConfigs}),[a?.values,t]),_=(e==="new"||e==="copy")&&!!v.customId&&v.customId!=="optional",E=d.useMemo(()=>e==="new"||e==="copy"?_?void 0:y.generateEntityId(t):a?.id,[]),C=d.useRef(!1),B=d.useRef(kn(v,e,a)),[x,S]=d.useState(E),[I,Q]=d.useState(!1),[P,T]=d.useState(),[z,te]=d.useState(!1),[L,Y]=d.useState(a?.values??B.current),W=R=>i({collection:V,path:t,entityId:x,values:R,previousValues:a?.values,closeAfterSave:C.current,autoSave:h??!1}).then(D=>{const re=e==="new"?"new_entity_saved":e==="copy"?"entity_copied":e==="existing"?"entity_edited":"unmapped_event";A.onAnalyticsEvent?.(re,{path:t})}).catch(D=>{console.error(D),T(D)}).finally(()=>{C.current=!1}),M=(R,D)=>{if(_&&!x){console.error("Missing custom Id"),Q(!0),D.setSubmitting(!1);return}if(T(void 0),Q(!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 W(R)?.then(re=>{D.resetForm({values:R,submitCount:0,touched:{}})}).finally(()=>{D.setSubmitting(!1)})},J=_e.useCreateFormex({initialValues:B.current,onSubmit:M,validation:R=>U?.validate(R,{abortEarly:!1}).then(()=>({})).catch(D=>{const re={};return D.inner.forEach(he=>{re[he.path]=he.message}),xl(D)})});d.useEffect(()=>{B.current=kn(v,e,a);const R=J.initialValues;!J.isSubmitting&&R&&e==="existing"?q(Object.entries(V.properties).map(([D,re])=>{if(wt(re))return{};const he=R[D],pe=B.current[D];return $(he,pe)?{}:{[D]:pe}}).reduce((D,re)=>({...D,...re}),{})):q({})},[a,v,e]);const H=R=>{const D=J.initialValues;Y(R),c&&c(R),h&&R&&!$(R,D)&&W(R)};d.useEffect(()=>{x&&l&&l(x)},[x,l]);const V=Pe({collection:o,path:t,entityId:x,values:L,previousValues:J.initialValues,fields:g.propertyConfigs}),ie=Nr(V,g.propertyConfigs),Z=L&&ie?Oe(L,ie):void 0,oe=o.callbacks?.onIdUpdate,O=d.useCallback(async()=>{if(oe&&L&&(e==="new"||e==="copy")){te(!0);try{const R=await oe({collection:V,path:t,entityId:x,values:L,context:b});S(R)}catch(R){f&&f(R),console.error(R)}te(!1)}},[x,L,e]);d.useEffect(()=>{O()},[O]);const[X,q]=d.useState({}),K=d.useCallback(({name:R,value:D,property:re})=>y.checkUniqueField(t,R,D,x),[y,t,x]),U=d.useMemo(()=>x?za(x,V.properties,K):void 0,[x,V.properties,K]),F=qe(),N=d.useCallback(({entity:R,customEntityActions:D})=>{const re=lt(o,F,t,null),he=R?qt(o,F,t,R):!0,pe=[];return re&&pe.push(yn),he&&pe.push(wn),D&&pe.push(...D),pe},[F,o,t]),ee=[],se={setFieldValue:J.setFieldValue,values:J.values,collection:V,entityId:x,path:t,save:W};if(d.useEffect(()=>{u&&u(se)},[u,se]),k&&o){const R={entityId:x,path:t,status:e,collection:o,context:b,currentEntityId:x,formContext:se};ee.push(...k.map((D,re)=>D.form?.Actions?r.jsx(D.form.Actions,{...R},`actions_${D.key}`):null).filter(Boolean))}return r.jsx(_e.Formex,{value:J,children:r.jsxs("div",{className:"h-full overflow-auto",children:[ee.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:ee}),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+(ee?8:0)} lg:mt-${8+(ee?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:Z??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(yl,{customId:o.customId,entityId:x,status:e,onChange:S,error:I,loading:z,entity:a}),x&&r.jsx(_l,{...J,initialValues:J.initialValues,onModified:s,onDiscard:n,onValuesChanged:H,underlyingChanges:X,entity:a,resolvedCollection:V,formContext:se,status:e,savingError:P,closeAfterSaveRef:C,autoSave:h,entityActions:N({entity:a,customEntityActions:o.entityActions})})]})]})})}function _l(e){const{values:t,onDiscard:o,onModified:a,onValuesChanged:i,underlyingChanges:n,formContext:s,entity:c,touched:l,setFieldValue:u,resolvedCollection:m,isSubmitting:h,status:f,handleSubmit:A,resetForm:g,savingError:b,dirty:y,closeAfterSaveRef:k,autoSave:v,entityActions:_}=e,E=Ae(),C=_.filter(P=>P.includeInForm===void 0||P.includeInForm),B=We(),x=y;d.useEffect(()=>{a&&a(x),i&&i(t)},[x,t]),d.useEffect(()=>{!v&&!h&&n&&c&&Object.entries(n).forEach(([P,T])=>{const z=t[P];!$(T,z)&&!l[P]&&(console.debug("Updated value from the datasource:",P,T),u(P,T!==void 0?T:null))})},[h,v,n,c,t,l,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 z=!!n&&Object.keys(n).includes(P)&&!!l[P],te=!v&&h||it(T)||!!T.disabled;if(wt(T))return null;const Y={propertyKey:P,disabled:te,property:T,includeDescription:T.description||T.longDescription,underlyingValueHasChanged:z&&!v,context:s,tableMode:!1,partOfArray:!1,partOfBlock:!1,autoFocus:!1};return r.jsx("div",{id:`form_field_${P}`,children:r.jsx(ne,{children:r.jsx(p.Tooltip,{title:r.jsx(vl,{propertyId:P}),delayDuration:800,side:"left",align:"start",sideOffset:16,children:r.jsx(tt,{...Y})})})},`field_${m.name}_${P}`)}).filter(Boolean)}),I=h||!x&&f==="existing",Q=d.useRef(null);return r.jsxs("form",{onSubmit:A,onReset:()=>(console.debug("Resetting form"),g(),o&&o()),noValidate:!0,children:[r.jsxs("div",{className:"mt-12",ref:Q,children:[S,r.jsx(Al,{containerRef:Q})]}),r.jsx("div",{className:"h-14"}),!v&&r.jsxs(p.DialogActions,{position:"absolute",children:[b&&r.jsx("div",{className:"text-right",children:r.jsx(p.Typography,{color:"error",children:b.message})}),c&&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(),c&&P.onClick({entity:c,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 _e.setIn(t,e.path,e.message);for(const o of e.inner)_e.getIn(t,o.path)||(t=_e.setIn(t,o.path,o.message))}return t}function Cl(e){return e.open?r.jsx(El,{...e}):null}function El({tableKey:e,entity:t,customFieldValidator:o,propertyKey:a,collection:i,path:n,cellRect:s,open:c,onClose:l,onCellValueChange:u,container:m}){const h=Ae(),f=ae(),[A,g]=d.useState(),[b,y]=d.useState(),k=t?.id,[v,_]=d.useState(t),[E,C]=d.useState(v?.values),B=i?Pe({collection:i,path:n,values:E,entityId:k,fields:f.propertyConfigs}):void 0,x=Ks(),S=d.useRef(null),I=d.useRef(null),Q=d.useRef(!1),P=d.useCallback(()=>{if(!s)throw Error("getInitialLocation error");return{x:s.left<x.width-s.right?s.x+s.width/2:s.x-s.width/2,y:s.top<x.height-s.bottom?s.y+s.height/2:s.y-s.height/2}},[s,x.height,x.width]),T=d.useCallback(({x:F,y:N})=>{const ee=S.current?.getBoundingClientRect();if(!ee)throw Error("normalizePosition called before draggableBoundingRect is set");return{x:Math.max(0,Math.min(F,x.width-ee.width)),y:Math.max(0,Math.min(N,x.height-ee.height))}},[x]),z=d.useCallback(F=>{const N=S.current?.getBoundingClientRect();if(!s||!N)return;const ee=F??T(P());(!b||ee.x!==b.x||ee.y!==b.y)&&y(ee)},[s,P,T,b]);Xs({containerRef:S,innerRef:I,x:b?.x,y:b?.y,onMove:z}),d.useEffect(()=>{Q.current=!1},[a,v]),d.useLayoutEffect(()=>{const F=S.current?.getBoundingClientRect();!s||!F||Q.current||(z(),Q.current=!0)},[s,z,Q.current]),d.useLayoutEffect(()=>{z(b)},[x,s]);const te=d.useMemo(()=>{if(!(!B||!k))return za(k,a&&B.properties[a]?{[a]:B.properties[a]}:{},o)},[B,k,a,o]),L=d.useCallback(()=>z(b),[b,z]),Y=async F=>(g(null),i&&v&&u&&a?u({value:F[a],propertyKey:a,entity:v,setError:g,onValueUpdated:()=>{},fullPath:n,context:h}):Promise.resolve());if(!v)return r.jsx(r.Fragment,{});const W=_e.useCreateFormex({initialValues:v?.values??{},validation:F=>te?.validate(F,{abortEarly:!1}).then(()=>({})).catch(N=>{const ee={};return N.inner.forEach(se=>{ee[se.path]=se.message}),ee}),validateOnInitialRender:!0,onSubmit:(F,N)=>{Y(F).then(()=>l()).finally(()=>N.setSubmitting(!1))}}),{values:M,isSubmitting:J,setFieldValue:H,handleSubmit:V}=W;if(d.useEffect(()=>{$(M,E)||C(M)},[M]),!v)return r.jsx(be,{error:"PopupFormField misconfiguration"});if(!B)return r.jsx(r.Fragment,{});const ie=J,Z={collection:B,entityId:k,values:M,path:n,setFieldValue:H,save:Y},oe=a&&Xe(B.properties,a),O=a&&oe?{propertyKey:a,disabled:J||it(oe)||!!oe.disabled,property:oe,includeDescription:!1,underlyingValueHasChanged:!1,context:Z,tableMode:!0,partOfArray:!1,partOfBlock:!1,autoFocus:c}:void 0;let X=r.jsx(r.Fragment,{children:r.jsx("div",{className:"w-[560px] max-w-full max-h-[85vh]",children:r.jsxs("form",{onSubmit:V,noValidate:!0,children:[r.jsx("div",{className:"mb-1 p-4 flex flex-col relative",children:r.jsx("div",{ref:I,className:"cursor-auto",style:{cursor:"auto !important"},children:O&&r.jsx(tt,{...O})})}),r.jsx(p.DialogActions,{children:r.jsx(p.Button,{variant:"filled",color:"primary",type:"submit",disabled:ie,children:"Save"})})]})},`popup_form_${e}_${k}_${a}`)});const q=f.plugins;q&&q.forEach(F=>{F.form?.provider&&(X=r.jsx(F.form.provider.Component,{status:"existing",path:n,collection:B,entity:v,context:h,currentEntityId:k,formContext:Z,...F.form.provider.props,children:X}))});const K=r.jsxs("div",{className:`text-gray-900 dark:text-white overflow-auto rounded rounded-md bg-white dark:bg-gray-950 ${c?"":"hidden"} cursor-grab max-w-[100vw]`,children:[X,A&&r.jsx(p.Typography,{color:"error",children:A.message})]}),U=r.jsxs("div",{style:{boxShadow:"0 0 0 2px rgba(128,128,128,0.2)"},className:`inline-block fixed z-20 shadow-outline rounded-md bg-white dark:bg-gray-950 ${c?"visible":"invisible"} cursor-grab overflow-visible`,ref:S,children:[r.jsx(Rs,{onResize:L}),r.jsxs("div",{className:"overflow-hidden",children:[K,r.jsx("div",{className:"absolute -top-3.5 -right-3.5 bg-gray-500 rounded-full",style:{width:"32px",height:"32px"},children:r.jsx(p.IconButton,{size:"small",onClick:F=>{F.stopPropagation(),l()},children:r.jsx(p.ClearIcon,{className:"text-white",size:"small"})})})]})]},`draggable_${a}_${k}_${c}`);return r.jsx(Wn.Root,{asChild:!0,container:m,children:r.jsx(_e.Formex,{value:W,children:U})})}const Bl="collectionGroupParent",go=d.memo(function({fullPath:t,parentCollectionIds:o,isSubCollection:a,className:i,...n}){const s=ze(n),c=ue(),l=We(),u=qe(),m=dt(),h=pt(),f=ae(),A=d.useRef(null),g=d.useMemo(()=>{const j=m?.getCollectionConfig(t);return j?Qe(n,j):n},[n,t,m?.getCollectionConfig]),b=d.useRef(g);d.useEffect(()=>{b.current=g},[g]);const y=lt(g,u,t,null),[k,v]=d.useState(void 0),[_,E]=d.useState(void 0),[C,B]=d.useState(0),[x,S]=d.useState(0),I=d.useCallback(()=>{const j=k;setTimeout(()=>{j===k&&v(void 0)},2400)},[k]),Q=d.useCallback(j=>{const le=b.current;return Ir(le,u,t,j??null)?le.inlineEditing===void 0||le.inlineEditing:!1},[u,t]),P=g.selectionEnabled===void 0||g.selectionEnabled,T=!Q(),[z,te]=d.useState(!1),L=oo(),Y=g.selectionController??L,{selectedEntities:W,toggleEntitySelection:M,isEntitySelected:J,setSelectedEntities:H}=Y;d.useEffect(()=>{E(void 0)},[W]);const V=ro({fullPath:t,collection:b.current,entitiesDisplayedFirst:[],lastDeleteTimestamp:C}),ie=d.useRef(Math.random().toString(36)),Z=V.popupCell,oe=d.useCallback(()=>{V.setPopupCell?.(void 0)},[V.setPopupCell]),O=d.useCallback(j=>{console.log("Entity clicked",j);const le=b.current;return v(j),h.onAnalyticsEvent?.("edit_entity_clicked",{path:j.path,entityId:j.id}),l.open({entityId:j.id,path:j.path,collection:le,updateUrl:!0,onClose:I})},[I,l]),X=d.useCallback(()=>{const j=b.current;h.onAnalyticsEvent?.("new_entity_click",{path:t}),l.open({path:t,collection:j,updateUrl:!0,onClose:I})},[t,l]),q=()=>{h.onAnalyticsEvent?.("multiple_delete_dialog_open",{path:t}),E(W)},K=(j,le)=>{h.onAnalyticsEvent?.("single_entity_deleted",{path:t}),H(de=>de.filter(ce=>ce.id!==le.id)),B(Date.now())},U=(j,le)=>{h.onAnalyticsEvent?.("multiple_entities_deleted",{path:t}),H([]),E(void 0),B(Date.now())};let F;f?.plugins&&(F=f.plugins.find(j=>j.collectionView?.AddColumnComponent)?.collectionView?.AddColumnComponent);const N=d.useCallback((j,le)=>{if(m){const de=m.getCollectionConfig(j),ce=Qe(de,le);m.onCollectionModified(j,ce)}},[m]),ee=d.useCallback(({width:j,key:le})=>{const de=b.current;if(!Xe(de.properties,le))return;const ce=_n(le,j);N(t,ce)},[N,t]),se=d.useCallback(j=>{m&&N(t,{defaultSize:j})},[N,t,m]),R=lt(g,u,t,null),D=d.useCallback(({name:j,value:le,property:de,entityId:ce})=>s.checkUniqueField(t,j,le,ce),[t]),re=({fullPath:j,context:le,value:de,propertyKey:ce,onValueUpdated:ke,setError:Nt,entity:Pt})=>{const gc=_e.setIn({...Pt.values},ce,de),Ac={path:j,entityId:Pt.id,values:gc,previousValues:Pt.values,collection:g,status:"existing"};return Or({...Ac,collection:g,callbacks:g.callbacks,dataSource:s,context:le,onSaveSuccess:()=>ke(),onSaveFailure:zn=>{console.error("Save failure"),console.error(zn),Nt(zn)}})},he=c.resolveAliasesFrom(t),pe=d.useMemo(()=>Pe({collection:g,path:t,fields:f.propertyConfigs}),[g,t]),fe=d.useCallback(({propertyKey:j,propertyValue:le,entity:de})=>{let ce=Xe(g.properties,j);return ce||(ce=Xe(pe.properties,j)),Fe({propertyKey:j,propertyOrBuilder:ce,path:t,propertyValue:le,values:de.values,entityId:de.id,fields:f.propertyConfigs})},[g.properties,f.propertyConfigs,t,pe.properties]),Me=Kr(pe,!0),Ge=d.useMemo(()=>{const j=g.subcollections?.map(de=>({key:Xr(de),name:de.name,width:200,dependencies:[],Builder:({entity:ce})=>r.jsx(p.Button,{color:"primary",variant:"outlined",startIcon:r.jsx(p.KeyboardTabIcon,{size:"small"}),onClick:ke=>{ke.stopPropagation(),l.open({path:t,entityId:ce.id,selectedSubPath:de.id??de.path,collection:g,updateUrl:!0})},children:de.name})}))??[],le=g.collectionGroup?[{key:Bl,name:"Parent entities",width:260,dependencies:[],Builder:({entity:de})=>{const ce=c.getParentReferencesFromPath(de.path);return r.jsx(r.Fragment,{children:ce.map(ke=>r.jsx(Ve,{reference:ke,size:"tiny"},ke.path+"/"+ke.id))})}}]:[];return[...g.additionalFields??[],...j,...le]},[g,t,l]),rt=d.useCallback(()=>{B(Date.now())},[]),Ne=De(),ot=({entity:j,customEntityActions:le})=>{const de=j?qt(g,u,t,j):!0,ce=[wl];return R&&ce.push(yn),de&&ce.push(wn),le&&ce.push(...le),ce},vo=()=>{const j=ot({}),le=j.filter(ke=>ke.collapsed!==!1),ce=j.filter(ke=>ke.collapsed===!1).length*(Ne?40:30);return(Ne?80+ce:70+ce)+(le.length>0?Ne?40:30:0)},ko=({entity:j,size:le,width:de,frozen:ce})=>{const ke=J(j),Nt=ot({entity:j,customEntityActions:g.entityActions});return r.jsx(Kt,{entity:j,width:de,frozen:ce,isSelected:ke,selectionEnabled:P,size:le,highlightEntity:v,unhighlightEntity:I,collection:g,fullPath:t,actions:Nt,hideId:g?.hideIdFromCollection,onCollectionChange:rt,selectionController:Y})},_o=r.jsx(p.Popover,{open:z,onOpenChange:te,enabled:!!g.description,trigger:r.jsxs("div",{className:"flex flex-col items-start",children:[r.jsx(p.Typography,{variant:"subtitle1",className:`leading-none truncate max-w-[160px] lg:max-w-[240px] ${g.description?"cursor-pointer":"cursor-auto"}`,onClick:g.description?j=>{te(!0),j.stopPropagation()}:void 0,children:`${g.name}`}),r.jsx(Sl,{fullPath:t,collection:g,filter:V.filterValues,sortBy:V.sortBy,onCountChange:S})]}),children:g.description&&r.jsx("div",{className:"m-4 text-gray-900 dark:text-white",children:r.jsx(p.Markdown,{source:g.description})})}),G=d.useCallback(({property:j,propertyKey:le,onHover:de})=>{const ce=b.current;return f.plugins?r.jsx(r.Fragment,{children:f.plugins.filter(ke=>ke.collectionView?.HeaderAction).map((ke,Nt)=>{const Pt=ke.collectionView.HeaderAction;return r.jsx(Pt,{onHover:de,propertyKey:le,property:j,fullPath:t,collection:ce,parentCollectionIds:o??[]},`plugin_header_action_${Nt}`)})}):null},[f.plugins,t,o]),Ee=F?function(){return typeof F=="function"?r.jsx(F,{fullPath:t,parentCollectionIds:o??[],collection:g}):null}:void 0,{textSearchLoading:Be,textSearchInitialised:Le,onTextSearchClick:It,textSearchEnabled:Ft}=ao({collection:g,fullPath:he,parentCollectionIds:o});return r.jsxs("div",{className:p.cn("overflow-hidden h-full w-full rounded-md",i),ref:A,children:[r.jsx(to,{additionalFields:Ge,tableController:V,displayedColumnIds:Me,onSizeChanged:se,onEntityClick:O,onColumnResize:ee,onValueChange:re,tableRowActionsBuilder:ko,uniqueFieldValidator:D,title:_o,selectionController:Y,highlightedEntities:k?[k]:[],defaultSize:g.defaultSize,properties:pe.properties,getPropertyFor:fe,onTextSearchClick:Le?void 0:It,textSearchLoading:Be,textSearchEnabled:Ft,actions:r.jsx(an,{parentCollectionIds:o??[],collection:g,tableController:V,onMultipleDeleteClick:q,onNewClick:X,path:t,relativePath:g.path,selectionController:Y,selectionEnabled:P,collectionEntitiesCount:x}),emptyComponent:y&&V.filterValues===void 0&&V.sortBy===void 0?r.jsxs("div",{className:"flex flex-col items-center justify-center",children:[r.jsx(p.Typography,{variant:"subtitle2",children:"So empty..."}),r.jsxs(p.Button,{color:"primary",variant:"outlined",onClick:X,className:"mt-4",children:[r.jsx(p.AddIcon,{}),"Create your first entity"]})]}):r.jsx(p.Typography,{variant:"label",children:"No results with the applied filter/sort"}),hoverRow:T,inlineEditing:Q(),AdditionalHeaderWidget:G,AddColumnComponent:Ee,getIdColumnWidth:vo,additionalIDHeaderWidget:r.jsx(Il,{path:t,collection:g})},`collection_table_${t}`),r.jsx(Cl,{open:!!Z,onClose:oe,cellRect:Z?.cellRect,propertyKey:Z?.propertyKey,collection:g,entity:Z?.entity,tableKey:ie.current,customFieldValidator:D,path:he,onCellValueChange:re,container:A.current},`popup_form_${Z?.propertyKey}_${Z?.entity?.id}`),_&&r.jsx(bn,{entityOrEntitiesToDelete:_,path:t,collection:g,callbacks:g.callbacks,open:!!_,onEntityDelete:K,onMultipleEntitiesDelete:U,onClose:()=>E(void 0)})]})},(e,t)=>$(e.fullPath,t.fullPath)&&$(e.parentCollectionIds,t.parentCollectionIds)&&$(e.isSubCollection,t.isSubCollection)&&$(e.className,t.className)&&$(e.properties,t.properties)&&$(e.propertiesOrder,t.propertiesOrder)&&$(e.hideIdFromCollection,t.hideIdFromCollection)&&$(e.inlineEditing,t.inlineEditing)&&$(e.selectionEnabled,t.selectionEnabled)&&$(e.selectionController,t.selectionController)&&$(e.Actions,t.Actions)&&$(e.defaultSize,t.defaultSize)&&$(e.textSearchEnabled,t.textSearchEnabled)&&$(e.additionalFields,t.additionalFields)&&$(e.forceFilter,t.forceFilter));function Sl({fullPath:e,collection:t,filter:o,sortBy:a,onCountChange:i}){const n=ze(t),s=ue(),[c,l]=d.useState(void 0),[u,m]=d.useState(void 0),h=a?a[0]:void 0,f=a?a[1]:void 0,A=d.useMemo(()=>s.resolveAliasesFrom(e),[e,s.resolveAliasesFrom]);return d.useEffect(()=>{n.countEntities&&n.countEntities({path:A,collection:t,filter:o,orderBy:h,order:f}).then(l).catch(m)},[e,n.countEntities,A,t,o,h,f]),d.useEffect(()=>{i&&i(c??0)},[i,c]),u?null:r.jsx(p.Typography,{className:"w-full text-ellipsis block overflow-hidden whitespace-nowrap max-w-xs text-left w-fit-content",variant:"caption",color:"secondary",children:c!==void 0?`${c} entities`:r.jsx(p.Skeleton,{className:"w-full max-w-[80px] mt-1"})})}function _n(e,t){if(e.includes(".")){const[o,...a]=e.split(".");return{properties:{[o]:_n(a.join("."),t)}}}return{properties:{[e]:{columnWidth:t}}}}function Il({collection:e,path:t}){const[o,a]=d.useState(!1),[i,n]=d.useState(""),s=We();return r.jsx(p.Tooltip,{title:o?void 0:"Find by ID",children:r.jsx(p.Popover,{open:o,onOpenChange:a,trigger:r.jsx(p.IconButton,{size:"small",children:r.jsx(p.SearchIcon,{size:"small"})}),children:r.jsx("form",{noValidate:!0,onSubmit:c=>{if(c.preventDefault(),!!i)return a(!1),s.open({entityId:i,path:t,collection:e,updateUrl:!0})},className:"text-gray-900 dark:text-white w-96 max-w-full",children:r.jsxs("div",{className:"flex p-2 w-full gap-4",children:[r.jsx("input",{autoFocus:o,placeholder:"Find entity by ID",onChange:c=>n(c.target.value),value:i,className:"flex-grow bg-transparent outline-none p-1"}),r.jsx(p.Button,{variant:"outlined",disabled:!i,type:"submit",children:"Go"})]})})})})}function Fl({propertyConfig:e}){const t="h-8 w-8 p-1 rounded-full shadow text-white",o=typeof e?.property=="object"?On(e.property):void 0;return r.jsx("div",{className:t,style:{background:e?.color??o?.color??"#888"},children:e?.Icon?Ut(e,"medium"):Ut(o,"medium")})}function xn(){return r.jsx("div",{className:"flex w-full h-full",children:r.jsxs("div",{className:"m-auto flex items-center flex-col",children:[r.jsx(p.Typography,{variant:"h4",align:"center",gutterBottom:!0,children:"Page not found"}),r.jsx(p.Typography,{align:"center",gutterBottom:!0,children:"This page does not exist or you may not have access to it"}),r.jsx(p.Button,{variant:"text",component:ge.Link,to:"/",children:"Back to home"})]})})}function Nl({open:e,onAccept:t,onCancel:o,title:a,loading:i,body:n}){return r.jsxs(p.Dialog,{open:e,onOpenChange:s=>s?void 0:o(),children:[r.jsxs(p.DialogContent,{children:[r.jsx(p.Typography,{variant:"h6",className:"mb-2",children:a}),n]}),r.jsxs(p.DialogActions,{children:[r.jsx(p.Button,{variant:"text",onClick:o,autoFocus:!0,children:"Cancel"}),r.jsx(p.LoadingButton,{color:"primary",type:"submit",loading:i,onClick:t,children:"Ok"})]})]})}function Cn({width:e,height:t,className:o,style:a}){return r.jsxs("svg",{width:e??"100%",height:t??"100%",viewBox:"0 0 599 599",version:"1.1",style:a,className:o,xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("defs",{children:[r.jsxs("radialGradient",{cx:"28.6213569%",cy:"43.1133328%",fx:"28.6213569%",fy:"43.1133328%",r:"71.5003456%",gradientTransform:"translate(0.286214,0.431133),rotate(3.343450),scale(1.000000,0.996175),translate(-0.286214,-0.431133)",id:"radialGradient-1",children:[r.jsx("stop",{stopColor:"#FF5B79",offset:"0%"}),r.jsx("stop",{stopColor:"#FA5574",offset:"28.0930803%"}),r.jsx("stop",{stopColor:"#EC4C51",offset:"44.7242531%"}),r.jsx("stop",{stopColor:"#9543C1",offset:"71.4578165%"}),r.jsx("stop",{stopColor:"#3857B3",offset:"100%"})]}),r.jsxs("radialGradient",{cx:"53.6205516%",cy:"47.2473036%",fx:"53.6205516%",fy:"47.2473036%",r:"50.8229649%",gradientTransform:"translate(0.536206,0.472473),rotate(90.000000),scale(1.000000,1.206631),translate(-0.536206,-0.472473)",id:"radialGradient-2",children:[r.jsx("stop",{stopColor:"#68294F",stopOpacity:"0",offset:"0%"}),r.jsx("stop",{stopColor:"#5E2548",stopOpacity:"0.04641108",offset:"75.3503173%"}),r.jsx("stop",{stopColor:"#0D060B",stopOpacity:"0.437431709",offset:"100%"})]}),r.jsxs("radialGradient",{cx:"53.8605015%",cy:"48.1990423%",fx:"53.8605015%",fy:"48.1990423%",r:"59.9151549%",gradientTransform:"translate(0.538605,0.481990),rotate(180.000000),scale(1.000000,0.925027),translate(-0.538605,-0.481990)",id:"radialGradient-3",children:[r.jsx("stop",{stopColor:"#68294F",stopOpacity:"0",offset:"0%"}),r.jsx("stop",{stopColor:"#5E2548",stopOpacity:"0.04641108",offset:"84.0867343%"}),r.jsx("stop",{stopColor:"#FF0000",stopOpacity:"0.567324765",offset:"100%"})]})]}),r.jsx("g",{id:"Page-1",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:r.jsxs("g",{id:"firecms_logo",children:[r.jsx("circle",{fill:"url(#radialGradient-1)",cx:"299.5",cy:"299.5",r:"299.5"}),r.jsx("circle",{fill:"url(#radialGradient-2)",cx:"299.5",cy:"299.5",r:"299.5"}),r.jsx("circle",{fill:"url(#radialGradient-3)",cx:"299.5",cy:"299.5",r:"299.5"})]})})]})}const En=function({title:t,endAdornment:o,startAdornment:a,drawerOpen:i,dropDownActions:n,includeDrawer:s,className:c,style:l,user:u}){const m=ue(),h=qe(),{mode:f,toggleMode:A}=zr(),g=De(),b=u??h.user;let y;if(b&&b.photoURL)y=r.jsx(p.Avatar,{src:b.photoURL});else if(b===void 0||h.initialLoading)y=r.jsx("div",{className:"p-1 flex justify-center",children:r.jsx(p.Skeleton,{className:"w-10 h-10 rounded-full"})});else{const k=b?.displayName?b.displayName[0].toUpperCase():b?.email?b.email[0].toUpperCase():"A";y=r.jsx(p.Avatar,{children:k})}return r.jsx("div",{style:l,className:p.cn("pr-2",{"ml-[17rem]":i&&g,"ml-16":s&&!(i&&g)&&!a,"h-16":!0,"z-10":g,"transition-all":!0,"ease-in":!0,"duration-75":!0,"w-full":!s,"w-[calc(100%-64px)]":s&&!(i&&g),"w-[calc(100%-17rem)]":s&&i&&g,"duration-150":i&&g,fixed:!0},c),children:r.jsxs("div",{className:"flex flex-row gap-2 px-4 h-full items-center",children:[a,m&&r.jsx("div",{className:"mr-8 hidden lg:block",children:r.jsx(ge.Link,{className:"visited:text-inherit visited:dark:text-inherit",to:m?.basePath??"/",children:r.jsx(p.Typography,{variant:"subtitle1",noWrap:!0,className:"ml-2 !font-medium",children:t})})}),r.jsx("div",{className:"flex-grow"}),o&&r.jsx(ne,{children:o}),r.jsx(p.IconButton,{color:"inherit","aria-label":"Open drawer",onClick:A,size:"large",children:f==="dark"?r.jsx(p.DarkModeIcon,{}):r.jsx(p.LightModeIcon,{})}),r.jsxs(p.Menu,{trigger:y,children:[b&&r.jsxs("div",{className:"px-4 py-2 mb-2",children:[b.displayName&&r.jsx(p.Typography,{variant:"body1",color:"secondary",children:b.displayName}),b.email&&r.jsx(p.Typography,{variant:"body2",color:"secondary",children:b.email})]}),n,!n&&r.jsxs(p.MenuItem,{onClick:h.signOut,children:[r.jsx(p.LogoutIcon,{}),"Log Out"]})]})]})})},Pl=e=>e&&Array.isArray(e)&&e.length>0?e.map((t,o)=>t?{[hr(t)+o]:Bt()}:{}).reduce((t,o)=>({...t,...o}),{}):{};function Ao({droppableId:e,addLabel:t,value:o,disabled:a=!1,buildEntry:i,size:n="medium",onInternalIdAdded:s,includeAddButton:c,newDefaultEntry:l,onValueChange:u}){const m=o&&Array.isArray(o)&&o.length>0,h=d.useRef(Pl(o)),[f,A]=d.useState(m?Object.values(h.current):[]);d.useEffect(()=>{if(m&&o&&o.length!==f.length){const v=o.map((_,E)=>{const C=hr(_)+E;if(C in h.current)return h.current[C];{const B=Bt();return h.current[C]=B,B}});A(v)}},[m,f.length,o]);const g=v=>{if(v.preventDefault(),a)return;const _=Bt(),E=[...f,_];s&&s(_),A(E),u([...o??[],l])},b=v=>{const _=[...f];_.splice(v,1),A(_),u(o.filter((E,C)=>C!==v))},y=v=>{const _=Bt(),E=o[v],C=[...f.splice(0,v+1),_,...f.splice(v+1,f.length-v-1)];s&&s(_),A(C),u([...o.slice(0,v+1),E,...o.slice(v+1)])},k=v=>{if(!v.destination)return;const _=v.source.index,E=v.destination.index,C=[...f],B=C[_];C[_]=C[E],C[E]=B,A(C),u(Tl(o,_,E))};return r.jsx(at.DragDropContext,{onDragEnd:k,children:r.jsx(at.Droppable,{droppableId:e,renderClone:(v,_,E)=>{const C=E.source.index,B=f[C];return r.jsx(bo,{provided:v,internalId:B,index:C,size:n,disabled:a,buildEntry:i,remove:b,copy:y,isDragging:_.isDragging})},children:(v,_)=>r.jsxs("div",{...v.droppableProps,ref:v.innerRef,children:[m&&f.map((E,C)=>r.jsx(at.Draggable,{draggableId:`array_field_${E}`,isDragDisabled:a,index:C,children:(B,x)=>r.jsx(bo,{provided:B,internalId:E,index:C,size:n,disabled:a,buildEntry:i,remove:b,copy:y,isDragging:x.isDragging})},`array_field_${E}`)),v.placeholder,c&&r.jsx("div",{className:"py-4 justify-center text-left",children:r.jsx(p.Button,{variant:"text",size:n==="small"?"small":"medium",color:"primary",disabled:a,startIcon:r.jsx(p.AddIcon,{}),onClick:g,children:t??"Add"})})]})})})}function bo({provided:e,index:t,internalId:o,size:a,disabled:i,buildEntry:n,remove:s,copy:c,isDragging:l}){const[u,m]=d.useState(!1),h=d.useCallback(()=>m(!0),[]),f=d.useCallback(()=>m(!1),[]);return r.jsx("div",{onMouseEnter:h,onMouseMove:h,onMouseLeave:f,ref:e.innerRef,...e.draggableProps,style:e.draggableProps.style,className:`${l||u?p.fieldBackgroundHoverMixin:""} mb-1 rounded-md opacity-100`,children:r.jsxs("div",{className:"flex items-start",children:[r.jsx("div",{className:"flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark",children:n(t,o)}),r.jsx(Bn,{direction:a==="small"?"row":"column",disabled:i,remove:s,index:t,provided:e,copy:c})]})})}function Bn({direction:e,disabled:t,remove:o,index:a,provided:i,copy:n}){const[s,c]=d.useState(!1),l=d.useRef(null);return p.useOutsideAlerter(l,()=>c(!1)),r.jsx("div",{className:`pl-2 pt-1 pb-4 flex ${e==="row"?"flex-row-reverse":"flex-col"} items-center`,ref:l,...i.dragHandleProps,children:r.jsxs(p.Tooltip,{delayDuration:400,open:s?!1:void 0,side:e==="column"?"left":void 0,title:"Drag to move. Click for more options",children:[r.jsx(p.IconButton,{size:"small",disabled:t,onClick:()=>c(!0),onDragStart:u=>{c(!1)},className:`cursor-${t?"inherit":"grab"}`,children:r.jsx(p.HandleIcon,{})}),r.jsxs(p.Menu,{portalContainer:l.current,open:s,trigger:r.jsx("div",{}),children:[r.jsxs(p.MenuItem,{dense:!0,onClick:u=>{c(!1),o(a)},children:[r.jsx(p.RemoveIcon,{size:"small"}),"Remove"]}),r.jsxs(p.MenuItem,{dense:!0,onClick:()=>{c(!1),n(a)},children:[r.jsx(p.ContentCopyIcon,{size:"small"}),"Copy"]})]})]})})}function Tl(e,t,o){const a=Array.from(e),[i]=a.splice(t,1);return a.splice(o,0,i),a}function Bt(){return Math.floor(Math.random()*Math.floor(Number.MAX_SAFE_INTEGER))}function Ql({name:e,multiselect:t=!1,path:o,disabled:a,value:i,onReferenceSelected:n,onMultipleReferenceSelected:s,previewProperties:c,forceFilter:l,size:u,className:m}){const h=ue(),f=d.useMemo(()=>h.getCollection(o),[o,h.getCollection]),A=d.useCallback(v=>{if(!a&&n){const _=v?Ye(v):null;n?.({reference:_,entity:v})}},[a,n]),g=d.useCallback(v=>{if(!a&&s){const _=v?v.map(E=>Ye(E)):null;s({references:_,entities:v})}},[a,n]),b=At({multiselect:t,path:o,collection:f,onSingleEntitySelected:A,onMultipleEntitiesSelected:g,forceFilter:l});d.useCallback(v=>{v.stopPropagation(),t?g([]):A(null)},[n]);let y;const k=()=>{a||b.open()};return Array.isArray(i)?y=r.jsx("div",{className:"flex flex-col gap-4",children:i.map((v,_)=>r.jsx(Ve,{onClick:k,reference:v,disabled:a,previewProperties:c,size:u},`reference_preview_${_}`))}):i?.isEntityReference&&i?.isEntityReference()&&(y=r.jsx(Ve,{reference:i,onClick:k,disabled:a,previewProperties:c,size:u})),r.jsxs("div",{className:p.cn("text-sm font-medium text-gray-500","min-w-80 flex flex-col gap-4","relative transition-colors duration-200 ease-in rounded font-medium",a?"bg-opacity-50":"hover:bg-opacity-75","text-opacity-50 dark:text-white dark:text-opacity-50",m),children:[y,!i&&r.jsx("div",{className:"justify-center text-left",children:r.jsxs(p.Button,{variant:"outlined",color:"primary",disabled:a,onClick:k,children:["Edit ",e]})})]})}const Dl=220;process.env.NODE_ENV!=="production"&&Object.keys(Fr).forEach(e=>{p.iconKeys.includes(e)||console.warn(`The icon ${e} no longer exists. Remove it from \`icon_synonyms\``)});function Ml({selectedIcon:e="",onIconSelected:t}){const[o,a]=d.useState(null),[i,n]=d.useState(""),s=d.useMemo(()=>p.debounce(l=>{if(!l||l==="")a(null);else{const u=Wt.search(l);a(u.map(m=>m.key))}},Dl),[]);d.useEffect(()=>(s(i),()=>{s.clear()}),[i,s]);const c=o===null?p.coolIconKeys:o;return r.jsxs(r.Fragment,{children:[r.jsx(p.SearchBar,{autoFocus:!0,innerClassName:"w-full sticky top-0 z-10",onTextSearch:l=>n(l??""),placeholder:"Search for more icons…"}),r.jsx("div",{className:"flex max-w-full flex-wrap mt-4",children:c.map(l=>r.jsx(p.Tooltip,{title:l,children:r.jsx(p.IconButton,{shape:"square",toggled:e===l,onClick:t?()=>t(l):void 0,className:"box-content m-1",children:r.jsx(p.Icon,{iconKey:l,size:24})})},l))})]})}function Ol({error:e,children:t}){return t?r.jsx(p.Typography,{variant:"caption",color:e?"error":"secondary",className:"ml-3.5 mt-0.5",children:t}):null}function At(e){const t=ue(),o=_t(),a=d.useCallback(()=>{if(e.path){let n=e.collection;if(n||(n=t.getCollection(e.path)),!n)throw Error("Not able to resolve the collection in useReferenceDialog. Make sure a collection is registered in path "+e.path);o.open({key:`reference_${e.path}`,component:r.jsx(Ra,{collection:n,...e}),width:"90vw",onClose:()=>{e.onClose?.()}})}else throw Error("useReferenceDialog: You are trying to open a reference dialog, but have not declared the `path`")},[t,e,o]),i=d.useCallback(()=>{o.close()},[o]);return{open:a,close:i}}const zl=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAASAAAAEgARslrPgAAB9pJREFUWMONl12obVUVx39jzLk+9j7nHq9y1QT1qpcbSIaXQFGs24PQl3HroSQyqHwJFJF6qaceCsqQoJdELHoIC6EeJCSKsi/TFLGozGsKXksljRLxnrP3WmvOOUYPa+19zsmPWpux5pxrzTX///Exx5hb+B/X1y+/nuIlVKF5m0v1YbQ55tIcKTQXFerNQkumOZ1oTiXCqUH8saR+74L8ZIWWux7+7JuuL2/04s5jJyhWQlXV71KtbhCtr1WtD6s0KlrjNBRaEi3JGzpv6bymQ0sn9mwv9otB7Ls7kn9Xo+U7D9z8/xG4+bz3cs35SjE/HEK8NWr8RBOrs+tQUUlEtAYaijRkbxmY0fuMzucsfcbSWnZQtiWxJL3Uid09iH0jIM8/1f+d3/zuS29M4PvHrmG+cZA8dMdjiLfNYrx6owrMVKlVUQkgkeI1iYbBJ3A2WPpKNtnx+UQisy29L0gPDGKfrwkPn2bJPfd/Zo0ZVp0fvOOdnLGxheX+A/Mq3nGwqS8/q645o4psxkgbhFqdSgqVJKIkghgqjuDoWh+dlm1AI0gUC3o4C9d04idbmZ06euQDPPHMj3YJ3HnkrZx98Fys2PFZ1dxxsJkdPbOecaBqmcWGqBVBIkEiKkoQJ5IJJBTbY8aRgBMwjxgVJoJJwDScnYUrOy2PBamfv/CS4zz9zE+IAIfPuQQzPzyrmq9u1e3RM+qWeaipNCCiE4DjbjgF94xZQj2htpjeK84ImqlIUpO9JllgEKgJDFpfOoh8paN8chbOeQ4g/OTq97PdLXSz3fjiVjO7/sx6g804ow41QWuCrjQPBB3bkZQgAkpBJOMojmIEjIgRKV6RpaYIZHGKQlK5OIv0L8bul8eOfsxjDJGD8613z6rmhq1qxkY1o9YKFUFEEED2xqoE1MNoWgPBwQZMl2SrSbQM9NQyUMlA5S3Rlcqd6E50RdRvPMvn9yE8qP9+9WWtQvXxzdic8xrwPaJrUYJGoq4sVBM1Ukuiln4UBipJVJrGoHUhrARB0XMQ/cizbSd61uaZlzUhXjuvWmqt9oOyAmUPEabnkSDV2j0Rp2YgksZdQpoCtRBwAiN4cKYdw4m3pNnbY9Tw4SZUh9tQEda+ld1WpmThgoivU8fYDbgEggRcleiZ6BOoFNRXLQQX1Eelggsgh8GPx6DhWB2iRgkj2OTuVX8dBzJtMx93BAKK4hIwUUSEID4BGspecWTfDwSCw+UxqByJoqPf9+xmYWQg7H3u+5Poyk3o5BZDxRBxxH29fdkF3YcBXKHgF+m+hLxn4OvbnnbPzMkjsm/+f5cXec2ye6ZfpO6+OX7pE8TqPj1zcN/7Zu8CDm44Bu6skrKjuOs0FlxWCJNMYxMOqLlR3DAvsAKaZo6t7+u7r6nhjN/5RKIQKESKhykhjeIINgJi+0m4Fiuns2WKZQybtJ2AfAWzGu/ayt0wz5gXimeKQyKSPI4kiCMhDxSgyLiOiY9kxnW2NVs+1ZeBbAmzhLmtgd0d8z1k1mIUTxQbKD5gnkmuDN6QvCF5TaIie0UmkIU1id3WcfwZHUo61eWB3gayDdOiZR+JXUuMWmcbyGWcny2RzOi8obeWwRsGrxm8JlGPBHCyOJmpJkwkHHs09pnfL1L60KLqtBKZtprhU+lVmSq9+xRsBfOMW6L4QLFM7zWdz+l8Ru8tA+10YKlJIiSxkcC6dQqlmJc/xaHIvTuZT7UpHalFUHEqL6iGsfKtM8FEzMdy7J4oXui9mk5CczpGErtEKgacQUZJE3gSwzw/i+dfx2G7e6IcOPALCXIkakGkYx4iwceyq+uENPp+RSI7DN7Q+5ylb7JgJLH0+XRGbOlRerWJwNgmnOwJ83Tvq/7KX2KZb1nJfnfp5YRoda7hFC/MQyGI7Mteow2E4pHkDT2zyfS758HV4bSjolOjF2PYS4KBbN2L5vmHZ7DpsWQnDsvfLj1+Lwufy9LSO2y5M1Mnik8OEJxAoSJRk7xhoKX3+URiztI3WPgGS2/p1OnE6CcSvRQGH+htQfH07dPSP7Lp9ajcNy+9DnG/oMT67qqZHz/QtGxVyjworQqVCIjiPiaaTD1ttZZ+fTIeCXQ+Y6HCQm0tO5LYpmfHlyy9/1nCPi3ICw/99JbxUHrdvxr6Q4depdhTfeGapVeH+imKxwhv6ZnR+5zeN0aNGU2+ZIPON0cX0LBQYSnGQgsLSSzoWdiCHVvQ2fLP2fMtwf2vDz50K6TpVPxj/sn7Ni5iu9l6Tof+yd78yoWFQ0uvWYvVLK1h6e34B8RnY9DZnIW3LAijxpLYkZ6Fd+z4km3bYcd2WNry8ezppsZ5ZMd2+MfTv3xtjbr9/PfwyoFDzPvtq7I2t+Vq/m6pt4hxThVaojao1CANRkORmkwkiTCI00thKYWOzJJR+6V1JE8/z2JfqGgfW9jLPPLg7a9Xe8frHs7j5MVXESxfmLS5KYXmxhQ3z/a4icQNRFtEGlwjJkoRIamTmIKNTE+it57kw0sF+1ah3CkSXkiPf42Htl+3WL/2+vIFJ6ishJ3QXD1o9dEhVCcGbS7ModUcakwrigaKChkoYmQK2XMp5L8V/F7DfuDePYrEcv8f7npdnDcksEvkg9RewquhuayTcHzQeCyJXpFVD2fRzSxCFtkuwqks8mjB/ujYr9y6k0gs9528503X/w/F3eUgyIBI4wAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wNS0xMFQxOToyODozMyswMDowMEzeSx4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDUtMTBUMTk6Mjg6MzMrMDA6MDA9g/OiAAAARnRFWHRzb2Z0d2FyZQBJbWFnZU1hZ2ljayA2LjcuOC05IDIwMTQtMDUtMTIgUTE2IGh0dHA6Ly93d3cuaW1hZ2VtYWdpY2sub3Jn3IbtAAAAABh0RVh0VGh1bWI6OkRvY3VtZW50OjpQYWdlcwAxp/+7LwAAABh0RVh0VGh1bWI6OkltYWdlOjpoZWlnaHQAMTkyDwByhQAAABd0RVh0VGh1bWI6OkltYWdlOjpXaWR0aAAxOTLTrCEIAAAAGXRFWHRUaHVtYjo6TWltZXR5cGUAaW1hZ2UvcG5nP7JWTgAAABd0RVh0VGh1bWI6Ok1UaW1lADE2MjA2NzQ5MTMk8oswAAAAD3RFWHRUaHVtYjo6U2l6ZQAwQkKUoj7sAAAAVnRFWHRUaHVtYjo6VVJJAGZpbGU6Ly8vbW50bG9nL2Zhdmljb25zLzIwMjEtMDUtMTAvOGIxNDNhYjgwODhkMjBlZThkYmUzOTFhN2NkNmQ3NmQuaWNvLnBuZ9msgG0AAAAASUVORK5CYII=
|
|
588
|
-
`;function Vl(e,t){d.useEffect(()=>{if(document){document.title=`${e} - FireCMS`;let o=document.querySelector("link[rel~='icon']");o||(o=document.createElement("link"),o.rel="icon",document.getElementsByTagName("head")[0].appendChild(o)),o.href=t??zl}},[e,t])}function Sn(e){const{path:t,collections:o=[],currentFullPath:a}=e,i=me(t).split("/"),n=Dt(i),s=[];for(let c=0;c<n.length;c++){const l=n[c],u=o&&o.find(m=>m.id===l||m.path===l);if(u){const m=u.id??u.path,h=a&&a.length>0?a+"/"+m:m,f=me(me(t).replace(l,"")),A=f.length>0?f.split("/"):[];if(A.length>0){const g=A[0],b=h+"/"+g;if(s.push(new mr(g,h)),A.length>1){const y=A.slice(1).join("/");if(!u)throw Error("collection not found resolving path: "+u);u.subcollections&&s.push(...Sn({path:y,collections:u.subcollections,currentFullPath:b}))}}break}}return s}const Gl="/",Yl="/c";function jl(e){const{basePath:t=Gl,baseCollectionPath:o=Yl,authController:a,collections:i,collectionPermissions:n,views:s,adminViews:c,viewsOrder:l,userConfigPersistence:u,dataSourceDelegate:m,injectCollections:h}=e,f=d.useRef(),A=d.useRef(),g=d.useRef(),[b,y]=d.useState(!1),[k,v]=d.useState(void 0),[_,E]=d.useState(!0),[C,B]=d.useState(void 0),x=me(t),S=me(o),I=x?`/${x}`:"/",Q=x?`/${x}/${S}`:`/${S}`,P=d.useCallback(O=>x?`/${x}/${ar(O)}`:`/${ar(O)}`,[x]),T=d.useCallback(O=>`${me(o)}/${ar(O)}`,[o]),z=d.useCallback((O,X,q,K)=>{let U=[...(O??[]).map(N=>N.hideFromNavigation?void 0:{url:T(N.id??N.path),type:"collection",name:N.name.trim(),path:N.id??N.path,collection:N,description:N.description?.trim(),group:Nn(N)}).filter(Boolean),...(X??[]).map(N=>N.hideFromNavigation?void 0:{url:P(Array.isArray(N.path)?N.path[0]:N.path),name:N.name.trim(),type:"view",path:N.path,view:N,description:N.description?.trim(),group:Nn(N)}).filter(Boolean),...(q??[]).map(N=>N.hideFromNavigation?void 0:{url:P(Array.isArray(N.path)?N.path[0]:N.path),name:N.name.trim(),type:"admin",path:N.path,view:N,description:N.description?.trim(),group:"Admin"}).filter(Boolean)];K&&(U=U.sort((N,ee)=>{const se=K.indexOf(N.path),R=K.indexOf(ee.path);return se===-1&&R===-1?0:se===-1?1:R===-1?-1:se-R}));const F=Object.values(U).map(N=>N.group).filter(Boolean).filter((N,ee,se)=>se.indexOf(N)===ee);return{navigationEntries:U,groups:F}},[P,T]),te=d.useCallback(async()=>{if(!a.initialLoading){try{console.debug("Refreshing navigation",{authController:a});const[O=[],X,q=[]]=await Promise.all([Ul(i,n,a,m,h),Fn(s,a,m),Fn(c,a,m)]);(!$(f.current,O)||!$(A.current,X)||!$(g.current,q)||!$(k,z(O,X,q,l)))&&(f.current=O,A.current=X,g.current=q,v(z(O??[],X,q,l)))}catch(O){console.error(O),B(O)}E(!1),y(!0)}},[i,n,a.user,a.initialLoading,s,c,z,h]);d.useEffect(()=>{te()},[te]);const L=d.useCallback((O,X,q=!1)=>{const K=f.current;if(!K)return;const U=Qt(me(O),K),F=q?u?.getCollectionConfig(O):void 0,N=U?Qe(U,F):void 0;let ee=N;if(N){const se=N.subcollections,R=N.callbacks,D=N.permissions;ee={...ee,subcollections:ee?.subcollections??se,callbacks:ee?.callbacks??R,permissions:ee?.permissions??D}}if(ee)return{...N,...ee}},[u]),Y=d.useCallback(O=>{let q=[...f.current??[]];if(!q)throw Error("Collections have not been initialised yet");for(let K=0;K<O.length;K++){const U=O[K],F=q.find(N=>N.id===U||N.path===U);if(!F)return;if(q=F.subcollections,K===O.length-1)return F}},[]),W=d.useCallback(O=>{let q=[...f.current??[]];if(!q)throw Error("Collections have not been initialised yet");for(let K=0;K<O.length;K++){const U=O[K],F=q.find(N=>N.id===U);if(!F)return;if(q=F.subcollections,K===O.length-1)return F}},[]),M=d.useCallback(O=>me(O+"/").startsWith(me(Q)+"/"),[Q]),J=d.useCallback(O=>{if(O.startsWith(Q))return O.replace(Q,"");throw Error("Expected path starting with "+Q)},[Q]),H=d.useCallback(({path:O})=>`s/edit/${ar(O)}`,[]),V=d.useCallback(O=>{const X=f.current;if(!X)throw Error("Collections have not been initialised yet");return ur(O,X)},[]),ie=d.useCallback(O=>{const X=f.current??[];return Sn({path:O,collections:X})},[]),Z=d.useCallback(O=>{const q=O.split("/").filter((U,F)=>F%2===0);q.pop();const K=[];for(let U=1;U<=q.length;U++)K.push(q.slice(0,U));return K.map(U=>Y(U)?.id).filter(Boolean)},[ie]),oe=d.useCallback(O=>{let q=f.current;const K=[];for(let U=0;U<O.length;U++){const F=O[U],N=q.find(ee=>ee.id===F);if(!N)throw Error(`Collection with id ${F} not found`);K.push(N.path),q=N.subcollections}return K},[W]);return console.debug("Navigation",{initialised:b,navigationLoading:_}),{collections:f.current,views:A.current,adminViews:g.current,loading:!b||_,navigationLoadingError:C,homeUrl:I,basePath:t,baseCollectionPath:o,initialised:b,getCollection:L,getCollectionFromPaths:Y,getCollectionFromIds:W,isUrlCollectionPath:M,urlPathToDataPath:J,buildUrlCollectionPath:T,buildUrlEditCollectionPath:H,buildCMSUrlPath:P,resolveAliasesFrom:V,topLevelNavigation:k,refreshNavigation:te,getParentReferencesFromPath:ie,getParentCollectionIds:Z,convertIdsToPaths:oe}}function Ll(e,t){return t?`${me(e)}/${me(t)}`:me(e)}function ar(e){return encodeURIComponent(me(e)).replaceAll("%2F","/").replaceAll("%23","#")}function In(e,t){return e.filter(o=>o.permissions?kt(o,t,o.path,null)?.read!==!1:!0).map(o=>o.subcollections?{...o,subcollections:In(o.subcollections,t)}:o)}async function Ul(e,t,o,a,i){let n=[];return typeof e=="function"?n=await e({user:o.user,authController:o,dataSource:a}):Array.isArray(e)&&(n=e),n=zo(n,t),n=In(n,o),i&&(n=i(n??[])),n}async function Fn(e,t,o){let a=[];return typeof e=="function"?a=await e({user:t.user,authController:t,dataSource:o}):Array.isArray(e)&&(a=e),a}function Nn(e){const t=e.group?.trim();return!t||t===""?"Views":t??"Views"}function $l(){const[e,t]=d.useState({}),o=d.useCallback(g=>{const b=localStorage.getItem(g);return b?JSON.parse(b):{}},[]),a=d.useCallback(g=>{const b=`collection_config::${Er(g)}`;return e[b]?e[b]:o(b)},[e,o]),i=d.useCallback((g,b)=>{const y=`collection_config::${Er(g)}`;localStorage.setItem(y,JSON.stringify(b)),t(k=>{const v=k[y],_=Qe(v??o(g),b);return Qe(k,_)})},[o]),[n,s]=d.useState([]),[c,l]=d.useState([]),[u,m]=d.useState([]);d.useEffect(()=>{s(localStorage.getItem("recently_visited_paths")?JSON.parse(localStorage.getItem("recently_visited_paths")):[]),l(localStorage.getItem("favourite_paths")?JSON.parse(localStorage.getItem("favourite_paths")):[]),m(localStorage.getItem("collapsed_groups")?JSON.parse(localStorage.getItem("collapsed_groups")):[])},[]);const h=d.useCallback(g=>{localStorage.setItem("recently_visited_paths",JSON.stringify(g)),s(g)},[]),f=d.useCallback(g=>{localStorage.setItem("favourite_paths",JSON.stringify(g)),l(g)},[]),A=d.useCallback(g=>{localStorage.setItem("collapsed_groups",JSON.stringify(g)),m(g)},[]);return{onCollectionModified:i,getCollectionConfig:a,recentlyVisitedPaths:n,setRecentlyVisitedPaths:h,favouritePaths:c,setFavouritePaths:f,collapsedGroups:u,setCollapsedGroups:A}}function ql(){const e=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)"),o=(localStorage.getItem("prefers-dark-mode")!=null?localStorage.getItem("prefers-dark-mode")==="true":null)??e,[a,i]=d.useState(o?"dark":"light");d.useEffect(()=>{i(o?"dark":"light"),c(o?"dark":"light")},[o]);const n=d.useCallback(()=>{i("dark"),c("dark")},[e]),s=d.useCallback(()=>{i("light"),c("light")},[]),c=u=>{document.body.style.setProperty("color-scheme",u),document.documentElement.dataset.theme=u},l=d.useCallback(()=>{a==="light"?(e?localStorage.removeItem("prefers-dark-mode"):localStorage.setItem("prefers-dark-mode","true"),n()):(e?localStorage.setItem("prefers-dark-mode","false"):localStorage.removeItem("prefers-dark-mode"),s())},[a,e]);return{mode:a,setMode:i,toggleMode:l}}function Wl({disabled:e,authController:t,authenticator:o,getAppCheckToken:a,appCheckForceRefresh:i=!1,storageSource:n,dataSourceDelegate:s}){const c=!!o,[l,u]=d.useState(c),[m,h]=d.useState(!1),[f,A]=d.useState(!c||!!t.loginSkipped),g=f&&(!c||!!t.user||!!t.loginSkipped)&&!m;d.useEffect(()=>{t.loginSkipped&&A(!0)},[t.loginSkipped]);const b=d.useRef(),y=d.useCallback(async()=>{if(e||t.initialLoading)return;if(!t.user&&!t.loginSkipped){b.current=void 0,u(!1),A(!1);return}const k=t.user;if(console.debug("Checking authentication for user",k),a)try{await a(i)?console.debug("App Check success."):(h("App Check failed."),t.signOut())}catch(v){h(v.message),t.signOut()}if(o instanceof Function&&k&&!$(b.current?.uid,k.uid)){u(!0);try{await o({user:k,authController:t,dataSourceDelegate:s,storageSource:n})||(t.signOut(),h(!0))}catch(v){h(v),t.signOut()}u(!1),A(!0),b.current=k}else u(!1);!t.initialLoading&&!k&&A(!0)},[e,t,o,a,i,s,n]);return d.useEffect(()=>{y()},[y]),{canAccessMainView:g,authLoading:c&&l,notAllowedError:m,authVerified:f}}const nr="main_##Q$SC^#S6";function Jl({path:e,entityId:t,selectedSubPath:o,copy:a,collection:i,parentCollectionIds:n,onValuesAreModified:s,formWidth:c,onUpdate:l,onClose:u}){i.customId&&i.formAutoSave&&console.warn(`The collection ${i.path} has customId and formAutoSave enabled. This is not supported and formAutoSave will be ignored`);const[m,h]=d.useState(!1),[f,A]=d.useState(void 0);Lt(f,()=>{f&&N({entityId:Z?.id,collection:i,path:e,values:f,closeAfterSave:!1})},!1,2e3);const g=ze(i),b=ir(),y=We(),k=Je(),v=ae(),_=Ae(),E=qe(),[C,B]=d.useState(void 0),[x,S]=d.useState(a?"copy":t?"existing":"new"),I=d.useRef(void 0),Q=I.current,P=(i.subcollections??[]).filter(G=>!G.hideFromNavigation),T=P?.length??0,z=i.entityViews,te=z?.length??0,L=i.formAutoSave&&!i.customId,Y=te>0||T>0,W=o??Cr(i?i.defaultSelectedView:void 0,{status:x,entityId:t}),M=d.useRef(W??nr),J=M.current===nr,{entity:H,dataLoading:V,dataLoadingError:ie}=Mr({path:e,entityId:t,collection:i,useCache:!1}),[Z,oe]=d.useState(H),[O,X]=d.useState(void 0);d.useEffect(()=>{H&&oe(H)},[H]),d.useEffect(()=>{if(x==="new")X(!1);else{const G=Z?Ir(i,E,e,Z??null):!1;Z&&X(!G)}},[E,Z,x]);const q=d.useCallback(G=>{h(!1),k.open({type:"error",message:"Error before saving: "+G?.message}),console.error(G)},[k]),K=d.useCallback(G=>{h(!1),k.open({type:"error",message:"Error after saving (entity is saved): "+G?.message}),console.error(G)},[k]),U=(G,Ee)=>{h(!1),L||k.open({type:"success",message:`${i.singularName??i.name}: Saved correctly`}),oe(G),S("existing"),s(!1),l&&l({entity:G}),Ee?(b.setBlocked(!1),b.close(!0),u?.()):x!=="existing"&&y.replace({path:e,entityId:G.id,selectedSubPath:M.current,updateUrl:!0,collection:i})},F=d.useCallback(G=>{h(!1),k.open({type:"error",message:"Error saving: "+G?.message}),console.error("Error saving entity",e,t),console.error(G)},[t,e,k]),N=({values:G,previousValues:Ee,closeAfterSave:Be,entityId:Le,collection:It,path:Ft})=>{h(!0),Or({path:Ft,entityId:Le,values:G,previousValues:Ee,collection:It,status:x,dataSource:g,context:_,onSaveSuccess:j=>U(j,Be),onSaveFailure:F,onPreSaveHookError:q,onSaveSuccessHookError:K}).then()},ee=async({collection:G,path:Ee,entityId:Be,values:Le,previousValues:It,closeAfterSave:Ft,autoSave:j})=>{x&&(j?A(Le):N({collection:G,path:Ee,entityId:Be,values:Le,previousValues:It,closeAfterSave:Ft}))},se=z?z.map(G=>kr(G,v.entityViews)).filter(Boolean):[],R=z&&se.map((G,Ee)=>{if(!G||M.current!==G.key)return null;const Be=G.Builder;return Be?r.jsx("div",{className:p.cn(p.defaultBorderMixin,"relative flex-grow w-full h-full overflow-auto "),role:"tabpanel",children:r.jsx(ne,{children:C&&r.jsx(Be,{collection:i,entity:Z,modifiedValues:Q??Z?.values,formContext:C})})},`custom_view_${G.key}`):(console.error("customView.Builder is not defined"),null)}).filter(Boolean),D=V&&!Z||(!Z||O===void 0)&&(x==="existing"||x==="copy"),re=D||m,he=P&&P.map((G,Ee)=>{const Be=G.id??G.path,Le=Z?`${e}/${Z?.id}/${me(Be)}`:void 0;return M.current!==Be?null:r.jsxs("div",{className:"relative flex-grow h-full overflow-auto w-full",role:"tabpanel",children:[re&&r.jsx(er,{}),!D&&(Z&&Le?r.jsx(go,{fullPath:Le,parentCollectionIds:[...n,i.id],isSubCollection:!0,...G}):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_${Be}`)}).filter(Boolean),pe=d.useCallback(()=>{s(!1)},[]),fe=G=>{M.current=G,y.replace({path:e,entityId:t,selectedSubPath:G===nr?void 0:G,updateUrl:!0,collection:i})},Me=d.useCallback(G=>{I.current=G},[]),Ge=d.useCallback(G=>{k.open({type:"error",message:"Error updating id, check the console"})},[]),rt=d.useCallback(G=>{oe(Ee=>Ee?{...Ee,id:G}:void 0)},[]),Ne=G=>{L||s(G)};function ot(){const G=v.plugins;let Ee=r.jsx(vn,{status:x,path:e,collection:i,onEntitySaveRequested:ee,onDiscard:pe,onValuesChanged:Me,onModified:Ne,entity:Z,onIdChange:rt,onFormContextChange:B,hideId:i.hideIdFromForm,autoSave:L,onIdUpdateError:Ge});return G&&G.forEach(Be=>{Be.form?.provider&&(Ee=r.jsx(Be.form.provider.Component,{status:x,path:e,collection:i,onDiscard:pe,onValuesChanged:Me,onModified:Ne,entity:Z,context:_,formContext:C,...Be.form.provider.props,children:Ee}))}),r.jsx(ne,{children:Ee})}const vo=O===void 0?r.jsx(r.Fragment,{}):O?r.jsxs(r.Fragment,{children:[r.jsx(p.Typography,{className:"mt-16 mb-8 mx-8",variant:"h4",children:i.singularName??i.name}),r.jsx(Wr,{className:"px-12",entity:Z,path:e,collection:i})]}):ot(),ko=P&&P.map(G=>r.jsx(p.Tab,{className:"text-sm min-w-[140px]",value:G.id,children:G.name},`entity_detail_collection_tab_${G.name}`)),_o=se.map(G=>r.jsx(p.Tab,{className:"text-sm min-w-[140px]",value:G.key,children:G.name},`entity_detail_collection_tab_${G.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?.(),b.close(!1)),size:"large",children:r.jsx(p.CloseIcon,{})})}),r.jsx("div",{className:"flex-grow"}),D&&r.jsx("div",{className:"self-center",children:r.jsx(p.CircularProgress,{size:"small"})}),r.jsxs(p.Tabs,{value:M.current,onValueChange:G=>{fe(G)},className:"pl-4 pr-4 pt-0",children:[r.jsx(p.Tab,{disabled:!Y,value:nr,className:`${Y?"":"hidden"} text-sm min-w-[140px]`,children:i.singularName??i.name}),_o,ko]})]}),r.jsxs("div",{className:"flex-grow h-full flex overflow-auto flex-row w-full ",style:{},children:[r.jsx("div",{role:"tabpanel",hidden:!J,id:`form_${e}`,className:" w-full",children:D?r.jsx(er,{}):vo}),R,he]})]})})}function Hl(e,t){const[o,a]=d.useState(),{navigator:i}=d.useContext(ge.UNSAFE_NavigationContext),n=ge.useNavigate(),s=()=>{a(void 0)},c=()=>{t(),a(void 0),n(-1)},l=d.useCallback(({action:u,location:m,retry:h})=>{switch(u){case"REPLACE":{h();return}case"POP":a(m)}},[]);return d.useEffect(()=>{if(!e||o||!("block"in i))return;const u=i.block(m=>{const h={...m,retry(){u(),m.retry()}};l(h)});return u},[i,l,e,o]),{navigationWasBlocked:!!o,handleCancel:s,handleOk:c}}function Zl({open:e,handleOk:t,handleCancel:o,body:a,title:i}){return r.jsxs(p.Dialog,{open:e,onOpenChange:n=>n?o():t(),children:[r.jsxs(p.DialogContent,{children:[r.jsx(p.Typography,{variant:"h6",children:i}),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 Pn=d.createContext({width:"",blocked:!1,setBlocked:e=>{},setBlockedNavigationMessage:e=>{},close:()=>{}}),ir=()=>d.useContext(Pn);function Xl(){const t=_t().sidePanels,o=[...t];return o.push(void 0),r.jsx(r.Fragment,{children:o.map((a,i)=>r.jsx(Kl,{panel:a,offsetPosition:t.length-i-1},`side_dialog_${i}`))})}function Kl({offsetPosition:e,panel:t}){const[o,a]=d.useState(!1),[i,n]=d.useState(!1),[s,c]=d.useState(),l=d.useRef(t?.width),u=l.current,m=_t(),{navigationWasBlocked:h,handleOk:f,handleCancel:A}=Hl(i&&!o,()=>n(!1));d.useEffect(()=>{t&&(l.current=t.width)},[t]);const g=()=>{n(!1),a(!1),m.close(),t?.onClose?.()},b=()=>{a(!1)},y=k=>{i&&!k?a(!0):(m.close(),t?.onClose?.())};return r.jsxs(Pn.Provider,{value:{blocked:i,setBlocked:n,setBlockedNavigationMessage:c,width:u,close:y},children:[r.jsxs(p.Sheet,{open:!!t,onOpenChange:k=>!k&&y(),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(ne,{children:t.component})}),!t&&r.jsx("div",{style:{width:u}})]}),r.jsx(Zl,{open:h||o,handleOk:o?g:f,handleCancel:o?b:A,body:s})]})}function Rl(e){const{blocked:t,setBlocked:o,setBlockedNavigationMessage:a}=ir(),i=ue(),n=d.useMemo(()=>i.getParentCollectionIds(e.path),[i,e.path]),s=d.useMemo(()=>{if(!e)return;let l=e.collection;const u=i.getCollection(e.path,e.entityId);if(u&&(l=u),!l)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 l},[i,e]);d.useEffect(()=>{function l(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",l),()=>{typeof window<"u"&&window.removeEventListener("beforeunload",l)}},[t,s]);const c=d.useCallback(l=>{o(l),a(l?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(ne,{children:r.jsx(Jl,{...e,formWidth:e.width,collection:s,parentCollectionIds:n,onValuesAreModified:c})})})}const Tn="new";function ec(e,t){if(t)return Si;const o=!e.selectedSubPath,a=typeof e.width=="number"?`${e.width}px`:e.width;return o?a??ta:`calc(${Ii} + ${a??ta})`}const tc=(e,t)=>{const o=ge.useLocation(),a=d.useRef(!1),i=!De();d.useEffect(()=>{if(!e.loading&&!a.current){if(console.debug("Initialising side entity controller"),e.isUrlCollectionPath(o.pathname)){const l=o.hash===`#${Tn}`,u=e.urlPathToDataPath(o.pathname),m=rc(u,e.collections??[],l);for(let h=0;h<m.length;h++){const f=m[h];setTimeout(()=>{h===0?t.replace(sr(f,e,i)):t.open(sr(f,e,i))},1)}}a.current=!0}},[o,e,t,i]);const n=d.useCallback(()=>{t.close()},[t]),s=d.useCallback(l=>{if(l.copy&&!l.entityId)throw Error("If you want to copy an entity you need to provide an entityId");const u=Cr(l.collection?l.collection.defaultSelectedView:void 0,{status:l.copy?"copy":l.entityId?"existing":"new",entityId:l.entityId});t.open(sr({selectedSubPath:u,...l},e,i))},[t,e,i]),c=d.useCallback(l=>{if(l.copy&&!l.entityId)throw Error("If you want to copy an entity you need to provide an entityId");t.replace(sr(l,e,i))},[e,t,i]);return{close:n,open:s,replace:c}};function rc(e,t,o){const a=_r({path:e,collections:t}),i=[];let n="";for(let s=0;s<a.length;s++){const c=a[s];if(c.type==="collection"&&(n=c.path),s>0){const l=a[s-1];if(c.type==="entity")i.push({path:c.path,entityId:c.entityId,copy:!1});else if(c.type==="custom_view"){if(l.type==="entity"){const u=i[i.length-1];u&&(u.selectedSubPath=c.view.key)}}else if(c.type==="collection"&&l.type==="entity"){const u=i[i.length-1];u&&(u.selectedSubPath=c.collection.id??c.collection.path)}}}return o&&i.push({path:n,copy:!1}),i}const sr=(e,t,o)=>{const a=me(e.path),i=e.entityId?t.buildUrlCollectionPath(`${a}/${e.entityId}/${e.selectedSubPath||""}`):t.buildUrlCollectionPath(`${a}#${Tn}`),n=t.resolveAliasesFrom(e.path),s={...e,path:n};return{key:`${e.path}/${e.entityId}`,component:r.jsx(Rl,{...s}),urlPath:i,parentUrlPath:t.buildUrlCollectionPath(a),width:ec(e,o),onClose:e.onClose}};function oc(){const e=ge.useLocation(),t=ge.useNavigate(),[o,a]=d.useState([]),i=d.useRef(o),n=d.useRef({}),s=d.useRef(0),c=h=>{i.current=h,a(h)};d.useEffect(()=>{const A=(e.state?.panels??[]).map(g=>n.current[g]).filter(g=>!!g);$(i.current.map(g=>g.key),A.map(g=>g.key))||c(A)},[e]);const l=d.useCallback(()=>{if(o.length===0)return;const h=o[o.length-1],f=[...o.slice(0,-1)];if(c(f),s.current>0)h.urlPath&&t(-1),s.current--;else if(h.parentUrlPath){const A=e.state?.base_location??e;t(h.parentUrlPath,{replace:!0,state:{base_location:A,panels:f.map(g=>g.key)}})}},[o,t,e]),u=d.useCallback(h=>{const f=Array.isArray(h)?h:[h];f.forEach(b=>{n.current[b.key]=b}),s.current=s.current+f.length;const A=e.state?.base_location??e,g=[...o,...f];c(g),f.forEach(b=>{b.urlPath&&t(b.urlPath,{state:{base_location:A,panels:g.map(y=>y.key)}})})},[e,t,o]),m=d.useCallback(h=>{const f=Array.isArray(h)?h:[h];f.forEach(b=>{n.current[b.key]=b});const A=e.state?.base_location??e,g=[...o.slice(0,-f.length),...f];c(g),f.forEach(b=>{b.urlPath&&t(b.urlPath,{replace:!0,state:{base_location:A,panels:g.map(y=>y.key)}})})},[e,t,o]);return{sidePanels:o,close:l,open:u,replace:m}}function ac(e){d.useEffect(()=>{if(!e)return;const t=Fo[e];t&&(So.registerLocale(e,t),So.setDefaultLocale(e))},[e])}function nc({delegate:e,propertyConfigs:t,navigationController:o}){return{fetchCollection:d.useCallback(({path:a,collection:i,filter:n,limit:s,startAfter:c,searchString:l,orderBy:u,order:m})=>e.fetchCollection({path:a,filter:n,limit:s,startAfter:c,searchString:l,orderBy:u,order:m}),[e]),listenCollection:e.listenCollection?d.useCallback(({path:a,collection:i,filter:n,limit:s,startAfter:c,searchString:l,orderBy:u,order:m,onUpdate:h,onError:f})=>{const A=i??o.getCollection(a),g=!!A?.collectionGroup;if(!e.listenCollection)throw Error("useBuildDataSource delegate not initialised");return e.listenCollection({path:a,filter:n,limit:s,startAfter:c,searchString:l,orderBy:u,order:m,onUpdate:h,onError:f,isCollectionGroup:g,collection:A})},[e,o.getCollection]):void 0,fetchEntity:d.useCallback(({path:a,entityId:i})=>e.fetchEntity({path:a,entityId:i}),[e]),listenEntity:e.listenEntity?d.useCallback(({path:a,entityId:i,collection:n,onUpdate:s,onError:c})=>{if(!e.listenEntity)throw Error("useBuildDataSource delegate not initialised");return e.listenEntity({path:a,entityId:i,onUpdate:s,onError:c})},[e.listenEntity]):void 0,saveEntity:d.useCallback(({path:a,entityId:i,values:n,collection:s,status:c})=>{const l=s??o.getCollection(a),m=(l?Pe({collection:l,path:a,entityId:i,fields:t}):void 0)?.properties,h=yo(n,e.buildReference,e.buildGeoPoint,e.buildDate,e.buildDeleteFieldValue),f=m?Do({inputValues:h,properties:m,status:c,timestampNowValue:e.currentTime(),setDateToMidnight:e.setDateToMidnight}):h;return e.saveEntity({path:a,entityId:i,values:f,status:c}).then(A=>({id:A.id,path:A.path,values:e.delegateToCMSModel(f)}))},[e.saveEntity,o.getCollection]),deleteEntity:d.useCallback(({entity:a})=>e.deleteEntity({entity:a}),[e.deleteEntity]),checkUniqueField:d.useCallback((a,i,n,s)=>e.checkUniqueField(a,i,n,s),[e.checkUniqueField]),generateEntityId:d.useCallback(a=>e.generateEntityId(a),[e.generateEntityId]),countEntities:e.countEntities?async({path:a,collection:i,filter:n,order:s,orderBy:c})=>e.countEntities({path:a,filter:n,orderBy:c,order:s,isCollectionGroup:!!i.collectionGroup}):void 0,isFilterCombinationValid:d.useCallback(({path:a,filterValues:i,sortBy:n})=>e.isFilterCombinationValid?e.isFilterCombinationValid({path:a,filterValues:i,sortBy:n}):!0,[e.isFilterCombinationValid])}}function yo(e,t,o,a,i){return e===void 0?i():e===null?null:Array.isArray(e)?e.map(n=>yo(n,t,o,a,i)):e.isEntityReference&&e.isEntityReference()?t(e):e instanceof Mt?o(e):e instanceof Date?a(e):e&&typeof e=="object"?Object.entries(e).map(([n,s])=>({[n]:yo(s,t,o,a,i)})).reduce((n,s)=>({...n,...s}),{}):e}function bc(e){return e}const ic="https://api-drplyi3b6q-ey.a.run.app";async function sc(e,t){const o=await e.getAuthToken();return fetch(ic+"/access_log",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${o}`},body:JSON.stringify({plugins:t})}).then(async a=>a.json())}function lc(e,t){const[o,a]=d.useState(null),i=d.useRef(null),n=t?.map(s=>s.key).join(",");return d.useEffect(()=>{e.user&&e.user.uid!==i.current&&!e.initialLoading&&(sc(e,n).then(a),i.current=e.user.uid)},[e]),o}function cc(e){const t=zr(),{children:o,entityLinkBuilder:a,userConfigPersistence:i,dateTimeFormat:n,locale:s,authController:c,storageSource:l,dataSourceDelegate:u,plugins:m,onAnalyticsEvent:h,propertyConfigs:f,entityViews:A,components:g,navigationController:b}=e;ac(s);const y=nc({delegate:u,propertyConfigs:f,navigationController:b}),k=oc(),v=tc(b,k),_=m?.some(S=>S.loading)??!1,E=c.initialLoading||b.loading||_,C={dateTimeFormat:n,locale:s,entityLinkBuilder:a,plugins:m,entityViews:A??[],propertyConfigs:f??{},components:g},B=d.useMemo(()=>({onAnalyticsEvent:h}),[]),x=lc(c,m);return b.navigationLoadingError?r.jsx(p.CenteredView,{maxWidth:"md",children:r.jsx(be,{title:"Error loading navigation",error:b.navigationLoadingError})}):c.authError?r.jsx(p.CenteredView,{maxWidth:"md",children:r.jsx(be,{title:"Error loading auth",error:c.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(Tt.Provider,{value:t,children:r.jsx(da.Provider,{value:B,children:r.jsx(ca.Provider,{value:C,children:r.jsx(sa.Provider,{value:i,children:r.jsx(ia.Provider,{value:l,children:r.jsx(ra.Provider,{value:y,children:r.jsx(pr.Provider,{value:c,children:r.jsx(aa.Provider,{value:k,children:r.jsx(na.Provider,{value:v,children:r.jsx(oa.Provider,{value:b,children:r.jsx(Fi,{children:r.jsx(dc,{loading:E,children:o})})})})})})})})})})})})}function dc({loading:e,children:t}){const o=Ae(),a=ae();let i=t({context:o,loading:e});const n=a.plugins;return!e&&n&&n.forEach(s=>{s.provider&&(i=r.jsx(s.provider.Component,{...s.provider.props,context:o,children:i}))}),r.jsx(r.Fragment,{children:i})}function Qn({hovered:e,drawerOpen:t,closeDrawer:o}){const a=pt(),i=ue(),n=e&&!t,s=De(),c=ge.useNavigate(),[l,u]=d.useState(!1);if(!i.topLevelNavigation)throw Error("Navigation not ready in Drawer");const{navigationEntries:m,groups:h}=i.topLevelNavigation,f=m.filter(y=>y.type==="admin")??[],A=h.filter(y=>y!=="Admin"),g=d.useCallback(y=>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:y?y.toUpperCase():"Views".toUpperCase()})}):r.jsx("div",{className:"h-12 w-full"}),[t]),b=y=>{const k=y.type==="collection"?"drawer_navigate_to_collection":y.type==="view"?"drawer_navigate_to_view":"unmapped_event";a.onAnalyticsEvent?.(k,{url:y.url}),s||o()};return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-grow overflow-scroll no-scrollbar",children:A.map(y=>r.jsxs(d.Fragment,{children:[g(y),Object.values(m).filter(k=>k.group===y).map((k,v)=>r.jsx(Dn,{icon:r.jsx(Jt,{collectionOrView:k.collection??k.view}),tooltipsOpen:n,drawerOpen:t,onClick:()=>b(k),url:k.url,name:k.name},`navigation_${v}`))]},`drawer_group_${y}`))}),f.length>0&&r.jsx(p.Menu,{open:l,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:n,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((y,k)=>r.jsxs(p.MenuItem,{onClick:v=>{v.preventDefault(),c(y.path)},children:[r.jsx(Jt,{collectionOrView:y.view}),y.name]},`navigation_${k}`))})]})}function Dn({name:e,icon:t,drawerOpen:o,tooltipsOpen:a,url:i,onClick:n}){const s=r.jsx("div",{className:"text-gray-600 dark:text-gray-500",children:t}),c=r.jsxs(ge.NavLink,{onClick:n,style:{width:o?"280px":"72px",transition:o?"width 150ms ease-in":void 0},className:({isActive:l})=>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",l?"bg-slate-200 bg-opacity-75 dark:bg-gray-800":""),to:i,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:c})}const pc=280,uc=d.memo(function(t){const{children:o,name:a,logo:i,includeDrawer:n=!0,autoOpenDrawer:s,Drawer:c=Qn,drawerProps:l,FireCMSAppBar:u=En,fireCMSAppBarProps:m}=t,h=De(),[f,A]=d.useState(!1),[g,b]=d.useState(!1),y=d.useCallback(()=>b(!0),[]),k=d.useCallback(()=>b(!1),[]),v=d.useCallback(()=>{A(!1)},[]),_=f||!!(h&&s&&g);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:n,drawerOpen:_,...m}),r.jsx(fc,{displayed:n,onMouseEnter:y,onMouseMove:y,onMouseLeave:k,open:_,logo:i,hovered:g,setDrawerOpen:A,children:n&&r.jsx(c,{hovered:g,drawerOpen:_,closeDrawer:v,...l})}),r.jsxs("main",{className:"flex flex-col flex-grow overflow-auto",children:[r.jsx(mc,{}),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(ne,{children:o})})]})]})},$),mc=()=>r.jsx("div",{className:"flex flex-col min-h-[68px]"});function fc(e){const t=ue(),o=e.displayed?e.open?pc: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(Cn,{})})})}),e.children]})]});return De()?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}function Mn(e){return Object.keys(lr).includes(e)}const lr={text_field:{key:"text_field",name:"Text field",description:"Simple short text",Icon:p.ShortTextIcon,color:"#2d7ff9",property:{dataType:"string",Field:gt}},multiline:{key:"multiline",name:"Multiline",description:"Text with multiple lines",Icon:p.SubjectIcon,color:"#2d7ff9",property:{dataType:"string",multiline:!0,Field:gt}},markdown:{key:"markdown",name:"Markdown",description:"Text with advanced markdown syntax",Icon:p.FormatQuoteIcon,color:"#2d7ff9",property:{dataType:"string",markdown:!0,Field:hn}},url:{key:"url",name:"Url",description:"Text with URL validation",Icon:p.HttpIcon,color:"#154fb3",property:{dataType:"string",url:!0,Field:gt}},email:{key:"email",name:"Email",description:"Text with email validation",Icon:p.EmailIcon,color:"#154fb3",property:{dataType:"string",email:!0,Field:gt}},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:ln}},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:so}},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:lo}},number_input:{key:"number_input",name:"Number input",description:"Simple number field with validation",Icon:p.NumbersIcon,color:"#bec920",property:{dataType:"number",Field:gt}},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:so}},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:lo}},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:co}},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:co}},reference:{key:"reference",name:"Reference",description:"The value refers to a different collection",Icon:p.LinkIcon,color:"#ff0042",property:{dataType:"reference",Field:dn}},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:nn}},date_time:{key:"date_time",name:"Date/time",description:"A date time select field",Icon:p.ScheduleIcon,color:"#8b46ff",property:{dataType:"date",Field:cn}},group:{key:"group",name:"Group",description:"Group of multiple fields",Icon:p.BallotIcon,color:"#ff9408",property:{dataType:"map",properties:{},Field:pn}},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:un}},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:mn}},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:gn}},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:fn}}};function On(e){const t=cr(e);if(!t){console.error("No field id found for property",e);return}return lr[t]}function St(e,t){const o=wo(e),a=cr(e);if(!a){console.error("No field id found for property",e);return}const i=lr[a],n=o?t[o]:void 0;return Qe(i??{},n??{})}function cr(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"){if(e.keyValue)return"key_value";if(e.properties)return"group"}else if(e.dataType==="array"){const t=e.of;return e.oneOf?"block":Array.isArray(t)?"custom_array":we(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 wo(e){return e.propertyConfig?e.propertyConfig:cr(e)}const hc=d.memo(function({HomePage:t=on,customRoutes:o}){const a=ge.useLocation(),i=ue();if(!i)return r.jsx(r.Fragment,{});const n=a.state,s=n&&n.base_location?n.base_location:a,c=[];i.views&&i.views.forEach(f=>{Array.isArray(f.path)?c.push(...f.path.map(A=>dr(A,f))):c.push(dr(f.path,f))}),i.adminViews&&i.adminViews.forEach(f=>{Array.isArray(f.path)?c.push(...f.path.map(A=>dr(A,f))):c.push(dr(f.path,f))});const u=[...i.collections??[]].sort((f,A)=>A.path.length-f.path.length).map(f=>{const A=i.buildUrlCollectionPath(f.id??f.path);return r.jsx(ge.Route,{path:A+"/*",element:r.jsx(ne,{children:r.jsx(go,{isSubCollection:!1,parentCollectionIds:[],fullPath:f.id??f.path,...f,Actions:rr(f.Actions)},`collection_view_${f.id??f.path}`)})},`navigation_${f.id??f.path}`)}),m=r.jsx(ge.Route,{path:"/",element:r.jsx(t,{})}),h=r.jsx(ge.Route,{path:"*",element:r.jsx(xn,{})});return r.jsxs(ge.Routes,{location:s,children:[u,c,m,h,o]})}),dr=(e,t)=>r.jsx(ge.Route,{path:e,element:t.view},"navigation_view_"+e);w.ArrayContainer=Ao,w.ArrayContainerItem=bo,w.ArrayCustomShapedFieldBinding=gn,w.ArrayEnumPreview=Ur,w.ArrayItemOptions=Bn,w.ArrayOfMapsPreview=Ri,w.ArrayOfReferencesFieldBinding=nn,w.ArrayOfReferencesPreview=ka,w.ArrayOfStorageComponentsPreview=_a,w.ArrayOfStringsPreview=xa,w.ArrayOneOfPreview=Ca,w.ArrayPropertyEnumPreview=$r,w.ArrayPropertyPreview=Lr,w.AsyncPreviewComponent=es,w.AuthControllerContext=pr,w.BlockFieldBinding=fn,w.BooleanPreview=Sa,w.COLLECTION_PATH_SEPARATOR=Go,w.CircularProgressCenter=er,w.DEFAULT_FIELD_CONFIGS=lr,w.DatePreview=Ba,w.DateTimeFieldBinding=cn,w.DefaultHomePage=on,w.DeleteConfirmationDialog=Nl,w.Drawer=Qn,w.DrawerNavigationItem=Dn,w.EmptyValue=Ke,w.EntityCollectionRowActions=Kt,w.EntityCollectionTable=to,w.EntityCollectionView=go,w.EntityCollectionViewActions=an,w.EntityForm=vn,w.EntityReference=mr,w.EntityView=Wr,w.EnumValuesChip=Se,w.ErrorBoundary=ne,w.ErrorView=be,w.FieldCaption=Ol,w.FieldHelperText=xe,w.FireCMS=cc,w.FireCMSAppBar=En,w.FireCMSLogo=Cn,w.FormikArrayContainer=or,w.GeoPoint=Mt,w.IconForView=Jt,w.ImagePreview=ga,w.KeyValueFieldBinding=un,w.KeyValuePreview=qr,w.LabelWithIcon=Ce,w.MapFieldBinding=pn,w.MapPropertyPreview=Ea,w.MarkdownFieldBinding=hn,w.ModeControllerContext=Tt,w.ModeControllerProvider=Zn,w.MultiSelectBinding=lo,w.NavigationCard=en,w.NavigationCardBinding=rn,w.NavigationGroup=no,w.NavigationRoutes=hc,w.NotFoundPage=xn,w.NumberPropertyPreview=Ia,w.PropertyConfigBadge=Fl,w.PropertyFieldBinding=tt,w.PropertyPreview=ye,w.PropertyTableCell=Ga,w.ReadOnlyFieldBinding=po,w.ReferenceFieldBinding=dn,w.ReferencePreview=Ve,w.ReferenceSelectionTable=Ra,w.ReferenceWidget=Ql,w.RepeatFieldBinding=mn,w.Scaffold=uc,w.SearchIconsView=Ml,w.SelectFieldBinding=so,w.SelectableTable=Xa,w.SideDialogs=Xl,w.SkeletonPropertyComponent=Re,w.SmallNavigationCard=tn,w.SnackbarProvider=Jn,w.StorageThumbnail=Aa,w.StorageThumbnailInternal=ya,w.StorageUploadFieldBinding=co,w.StringPropertyPreview=jr,w.SwitchFieldBinding=ln,w.TextFieldBinding=gt,w.UrlComponentPreview=Ct,w.VirtualTable=qa,w.addInitialSlash=Xn,w.applyPermissionsFunctionIfEmpty=zo,w.buildAdditionalFieldDelegate=Ci,w.buildCollection=bi,w.buildEntityCallbacks=xi,w.buildEnumLabel=Oo,w.buildEnumValueConfig=_i,w.buildEnumValues=ki,w.buildFieldConfig=Ei,w.buildIdColumn=Ps,w.buildProperties=wi,w.buildPropertiesOrBuilder=vi,w.buildProperty=yi,w.canCreateEntity=lt,w.canDeleteEntity=qt,w.canEditEntity=Ir,w.defaultDateFormat=Vo,w.deleteEntityWithCallbacks=pa,w.enumToObjectEntries=Ue,w.flattenObject=Pr,w.fullPathToCollectionSegments=Br,w.getArrayValuesCount=Jo,w.getBracketNotation=mi,w.getCollectionByPathOrId=Qt,w.getCollectionPathsCombinations=Dt,w.getColorForProperty=ui,w.getColorScheme=Mo,w.getColumnKeysForProperty=Rt,w.getDefaultFieldConfig=On,w.getDefaultFieldId=cr,w.getDefaultPropertiesOrder=fi,w.getDefaultValueFor=Vt,w.getDefaultValueForDataType=br,w.getDefaultValuesFor=vt,w.getEntityImagePreviewPropertyKey=Wo,w.getEntityPreviewKeys=qo,w.getEntityTitlePropertyKey=Nr,w.getFieldConfig=St,w.getFieldId=wo,w.getHashValue=hr,w.getIcon=$o,w.getIconForProperty=ve,w.getIconForWidget=Ut,w.getIdIcon=pi,w.getLabelOrConfigFrom=Yt,w.getLastSegment=Kn,w.getPropertiesWithPropertiesOrder=Uo,w.getPropertyInPath=Xe,w.getRandomId=Bt,w.getReferenceFrom=Ye,w.getResolvedPropertyInPath=Sr,w.getSidePanelKey=Ll,w.getValueInPath=Oe,w.hydrateRegExp=jo,w.icon_synonyms=Fr,w.iconsSearch=Wt,w.isDefaultFieldConfigId=Mn,w.isEmptyObject=Ar,w.isEnumValueDisabled=ti,w.isHidden=wt,w.isObject=Ot,w.isPropertyBuilder=we,w.isReadOnly=it,w.isReferenceProperty=Lo,w.isValidRegExp=di,w.joinCollectionLists=Xo,w.makePropertiesEditable=Ho,w.makePropertiesNonEditable=Zo,w.mergeCollection=Ko,w.mergeDeep=Qe,w.pick=To,w.plural=gi,w.printChanged=Qr,w.propertiesToColumns=Ua,w.randomColor=si,w.randomString=st,w.removeFunctions=fr,w.removeInPath=Rn,w.removeInitialAndTrailingSlashes=me,w.removeInitialSlash=No,w.removePropsIfExisting=Qo,w.removeTrailingSlash=Po,w.removeUndefined=gr,w.renderSkeletonCaptionText=qi,w.renderSkeletonIcon=Yr,w.renderSkeletonImageThumbnail=Gr,w.renderSkeletonText=je,w.resolveArrayProperty=$e,w.resolveCollection=Pe,w.resolveCollectionPathIds=ur,w.resolveDefaultSelectedView=Cr,w.resolveEntityView=kr,w.resolveEnumValues=ri,w.resolveNavigationFrom=ua,w.resolvePermissions=kt,w.resolveProperties=wr,w.resolveProperty=Fe,w.resolvePropertyEnum=vr,w.sanitizeData=ei,w.saveEntityWithCallbacks=Or,w.segmentsToStrippedPath=Yo,w.serializeRegExp=ci,w.singular=Ai,w.slugify=jt,w.sortProperties=xr,w.stripCollectionPath=Er,w.toKebabCase=ai,w.toSnakeCase=ii,w.traverseValueProperty=Gt,w.traverseValuesProperties=yr,w.unslugify=li,w.updateDateAutoValues=Do,w.useAuthController=qe,w.useBrowserTitleAndIcon=Vl,w.useBuildLocalConfigurationPersistence=$l,w.useBuildModeController=ql,w.useBuildNavigationController=jl,w.useClearRestoreValue=Te,w.useClipboard=ma,w.useCollectionFetch=Pi,w.useColumnIds=Kr,w.useCustomizationController=ae,w.useDataSource=ze,w.useDataSourceEntityCollectionTableController=ro,w.useDebouncedCallback=Lt,w.useDebouncedData=Ka,w.useEntityFetch=Mr,w.useFireCMSContext=Ae,w.useLargeLayout=De,w.useModeController=zr,w.useNavigationController=ue,w.useReferenceDialog=At,w.useResolvedNavigationFrom=Ti,w.useSelectionController=oo,w.useSideDialogContext=ir,w.useSideDialogsController=_t,w.useSideEntityController=We,w.useSnackbarController=Je,w.useStorageSource=ct,w.useTableSearchHelper=ao,w.useTraceUpdate=Bi,w.useValidateAuthenticator=Wl,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
|
588
|
+
`;function Vl(e,t){d.useEffect(()=>{if(document){document.title=`${e} - FireCMS`;let o=document.querySelector("link[rel~='icon']");o||(o=document.createElement("link"),o.rel="icon",document.getElementsByTagName("head")[0].appendChild(o)),o.href=t??zl}},[e,t])}function Sn(e){const{path:t,collections:o=[],currentFullPath:a}=e,i=me(t).split("/"),n=Dt(i),s=[];for(let c=0;c<n.length;c++){const l=n[c],u=o&&o.find(m=>m.id===l||m.path===l);if(u){const m=u.id??u.path,h=a&&a.length>0?a+"/"+m:m,f=me(me(t).replace(l,"")),A=f.length>0?f.split("/"):[];if(A.length>0){const g=A[0],b=h+"/"+g;if(s.push(new mr(g,h)),A.length>1){const y=A.slice(1).join("/");if(!u)throw Error("collection not found resolving path: "+u);u.subcollections&&s.push(...Sn({path:y,collections:u.subcollections,currentFullPath:b}))}}break}}return s}const Gl="/",Yl="/c";function jl(e){const{basePath:t=Gl,baseCollectionPath:o=Yl,authController:a,collections:i,collectionPermissions:n,views:s,adminViews:c,viewsOrder:l,userConfigPersistence:u,dataSourceDelegate:m,injectCollections:h}=e,f=d.useRef(),A=d.useRef(),g=d.useRef(),[b,y]=d.useState(!1),[k,v]=d.useState(void 0),[_,E]=d.useState(!0),[C,B]=d.useState(void 0),x=me(t),S=me(o),I=x?`/${x}`:"/",Q=x?`/${x}/${S}`:`/${S}`,P=d.useCallback(O=>x?`/${x}/${ar(O)}`:`/${ar(O)}`,[x]),T=d.useCallback(O=>`${me(o)}/${ar(O)}`,[o]),z=d.useCallback((O,X,q,K)=>{let U=[...(O??[]).map(N=>N.hideFromNavigation?void 0:{url:T(N.id??N.path),type:"collection",name:N.name.trim(),path:N.id??N.path,collection:N,description:N.description?.trim(),group:Nn(N)}).filter(Boolean),...(X??[]).map(N=>N.hideFromNavigation?void 0:{url:P(Array.isArray(N.path)?N.path[0]:N.path),name:N.name.trim(),type:"view",path:N.path,view:N,description:N.description?.trim(),group:Nn(N)}).filter(Boolean),...(q??[]).map(N=>N.hideFromNavigation?void 0:{url:P(Array.isArray(N.path)?N.path[0]:N.path),name:N.name.trim(),type:"admin",path:N.path,view:N,description:N.description?.trim(),group:"Admin"}).filter(Boolean)];K&&(U=U.sort((N,ee)=>{const se=K.indexOf(N.path),R=K.indexOf(ee.path);return se===-1&&R===-1?0:se===-1?1:R===-1?-1:se-R}));const F=Object.values(U).map(N=>N.group).filter(Boolean).filter((N,ee,se)=>se.indexOf(N)===ee);return{navigationEntries:U,groups:F}},[P,T]),te=d.useCallback(async()=>{if(!a.initialLoading){try{const[O=[],X,q=[]]=await Promise.all([Ul(i,n,a,m,h),Fn(s,a,m),Fn(c,a,m)]);(!$(f.current,O)||!$(A.current,X)||!$(g.current,q)||!$(k,z(O,X,q,l)))&&(f.current=O,A.current=X,g.current=q,v(z(O??[],X,q,l)))}catch(O){console.error(O),B(O)}E(!1),y(!0)}},[i,n,a.user,a.initialLoading,s,c,z,h]);d.useEffect(()=>{te()},[te]);const L=d.useCallback((O,X,q=!1)=>{const K=f.current;if(!K)return;const U=Qt(me(O),K),F=q?u?.getCollectionConfig(O):void 0,N=U?Qe(U,F):void 0;let ee=N;if(N){const se=N.subcollections,R=N.callbacks,D=N.permissions;ee={...ee,subcollections:ee?.subcollections??se,callbacks:ee?.callbacks??R,permissions:ee?.permissions??D}}if(ee)return{...N,...ee}},[u]),Y=d.useCallback(O=>{let q=[...f.current??[]];if(!q)throw Error("Collections have not been initialised yet");for(let K=0;K<O.length;K++){const U=O[K],F=q.find(N=>N.id===U||N.path===U);if(!F)return;if(q=F.subcollections,K===O.length-1)return F}},[]),W=d.useCallback(O=>{let q=[...f.current??[]];if(!q)throw Error("Collections have not been initialised yet");for(let K=0;K<O.length;K++){const U=O[K],F=q.find(N=>N.id===U);if(!F)return;if(q=F.subcollections,K===O.length-1)return F}},[]),M=d.useCallback(O=>me(O+"/").startsWith(me(Q)+"/"),[Q]),J=d.useCallback(O=>{if(O.startsWith(Q))return O.replace(Q,"");throw Error("Expected path starting with "+Q)},[Q]),H=d.useCallback(({path:O})=>`s/edit/${ar(O)}`,[]),V=d.useCallback(O=>{const X=f.current;if(!X)throw Error("Collections have not been initialised yet");return ur(O,X)},[]),ie=d.useCallback(O=>{const X=f.current??[];return Sn({path:O,collections:X})},[]),Z=d.useCallback(O=>{const q=O.split("/").filter((U,F)=>F%2===0);q.pop();const K=[];for(let U=1;U<=q.length;U++)K.push(q.slice(0,U));return K.map(U=>Y(U)?.id).filter(Boolean)},[ie]),oe=d.useCallback(O=>{let q=f.current;const K=[];for(let U=0;U<O.length;U++){const F=O[U],N=q.find(ee=>ee.id===F);if(!N)throw Error(`Collection with id ${F} not found`);K.push(N.path),q=N.subcollections}return K},[W]);return{collections:f.current,views:A.current,adminViews:g.current,loading:!b||_,navigationLoadingError:C,homeUrl:I,basePath:t,baseCollectionPath:o,initialised:b,getCollection:L,getCollectionFromPaths:Y,getCollectionFromIds:W,isUrlCollectionPath:M,urlPathToDataPath:J,buildUrlCollectionPath:T,buildUrlEditCollectionPath:H,buildCMSUrlPath:P,resolveAliasesFrom:V,topLevelNavigation:k,refreshNavigation:te,getParentReferencesFromPath:ie,getParentCollectionIds:Z,convertIdsToPaths:oe}}function Ll(e,t){return t?`${me(e)}/${me(t)}`:me(e)}function ar(e){return encodeURIComponent(me(e)).replaceAll("%2F","/").replaceAll("%23","#")}function In(e,t){return e.filter(o=>o.permissions?kt(o,t,o.path,null)?.read!==!1:!0).map(o=>o.subcollections?{...o,subcollections:In(o.subcollections,t)}:o)}async function Ul(e,t,o,a,i){let n=[];return typeof e=="function"?n=await e({user:o.user,authController:o,dataSource:a}):Array.isArray(e)&&(n=e),n=zo(n,t),n=In(n,o),i&&(n=i(n??[])),n}async function Fn(e,t,o){let a=[];return typeof e=="function"?a=await e({user:t.user,authController:t,dataSource:o}):Array.isArray(e)&&(a=e),a}function Nn(e){const t=e.group?.trim();return!t||t===""?"Views":t??"Views"}function $l(){const[e,t]=d.useState({}),o=d.useCallback(g=>{const b=localStorage.getItem(g);return b?JSON.parse(b):{}},[]),a=d.useCallback(g=>{const b=`collection_config::${Er(g)}`;return e[b]?e[b]:o(b)},[e,o]),i=d.useCallback((g,b)=>{const y=`collection_config::${Er(g)}`;localStorage.setItem(y,JSON.stringify(b)),t(k=>{const v=k[y],_=Qe(v??o(g),b);return Qe(k,_)})},[o]),[n,s]=d.useState([]),[c,l]=d.useState([]),[u,m]=d.useState([]);d.useEffect(()=>{s(localStorage.getItem("recently_visited_paths")?JSON.parse(localStorage.getItem("recently_visited_paths")):[]),l(localStorage.getItem("favourite_paths")?JSON.parse(localStorage.getItem("favourite_paths")):[]),m(localStorage.getItem("collapsed_groups")?JSON.parse(localStorage.getItem("collapsed_groups")):[])},[]);const h=d.useCallback(g=>{localStorage.setItem("recently_visited_paths",JSON.stringify(g)),s(g)},[]),f=d.useCallback(g=>{localStorage.setItem("favourite_paths",JSON.stringify(g)),l(g)},[]),A=d.useCallback(g=>{localStorage.setItem("collapsed_groups",JSON.stringify(g)),m(g)},[]);return{onCollectionModified:i,getCollectionConfig:a,recentlyVisitedPaths:n,setRecentlyVisitedPaths:h,favouritePaths:c,setFavouritePaths:f,collapsedGroups:u,setCollapsedGroups:A}}function ql(){const e=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)"),o=(localStorage.getItem("prefers-dark-mode")!=null?localStorage.getItem("prefers-dark-mode")==="true":null)??e,[a,i]=d.useState(o?"dark":"light");d.useEffect(()=>{i(o?"dark":"light"),c(o?"dark":"light")},[o]);const n=d.useCallback(()=>{i("dark"),c("dark")},[e]),s=d.useCallback(()=>{i("light"),c("light")},[]),c=u=>{document.body.style.setProperty("color-scheme",u),document.documentElement.dataset.theme=u},l=d.useCallback(()=>{a==="light"?(e?localStorage.removeItem("prefers-dark-mode"):localStorage.setItem("prefers-dark-mode","true"),n()):(e?localStorage.setItem("prefers-dark-mode","false"):localStorage.removeItem("prefers-dark-mode"),s())},[a,e]);return{mode:a,setMode:i,toggleMode:l}}function Wl({disabled:e,authController:t,authenticator:o,getAppCheckToken:a,appCheckForceRefresh:i=!1,storageSource:n,dataSourceDelegate:s}){const c=!!o,[l,u]=d.useState(c),[m,h]=d.useState(!1),[f,A]=d.useState(!c||!!t.loginSkipped),g=f&&(!c||!!t.user||!!t.loginSkipped)&&!m;d.useEffect(()=>{t.loginSkipped&&A(!0)},[t.loginSkipped]);const b=d.useRef(),y=d.useCallback(async()=>{if(e||t.initialLoading)return;if(!t.user&&!t.loginSkipped){b.current=void 0,u(!1),A(!1);return}const k=t.user;if(console.debug("Checking authentication for user",k),a)try{await a(i)?console.debug("App Check success."):(h("App Check failed."),t.signOut())}catch(v){h(v.message),t.signOut()}if(o instanceof Function&&k&&!$(b.current?.uid,k.uid)){u(!0);try{await o({user:k,authController:t,dataSourceDelegate:s,storageSource:n})||(t.signOut(),h(!0))}catch(v){h(v),t.signOut()}u(!1),A(!0),b.current=k}else u(!1);!t.initialLoading&&!k&&A(!0)},[e,t,o,a,i,s,n]);return d.useEffect(()=>{y()},[y]),{canAccessMainView:g,authLoading:c&&l,notAllowedError:m,authVerified:f}}const nr="main_##Q$SC^#S6";function Jl({path:e,entityId:t,selectedSubPath:o,copy:a,collection:i,parentCollectionIds:n,onValuesAreModified:s,formWidth:c,onUpdate:l,onClose:u}){i.customId&&i.formAutoSave&&console.warn(`The collection ${i.path} has customId and formAutoSave enabled. This is not supported and formAutoSave will be ignored`);const[m,h]=d.useState(!1),[f,A]=d.useState(void 0);Lt(f,()=>{f&&N({entityId:Z?.id,collection:i,path:e,values:f,closeAfterSave:!1})},!1,2e3);const g=ze(i),b=ir(),y=We(),k=Je(),v=ae(),_=Ae(),E=qe(),[C,B]=d.useState(void 0),[x,S]=d.useState(a?"copy":t?"existing":"new"),I=d.useRef(void 0),Q=I.current,P=(i.subcollections??[]).filter(G=>!G.hideFromNavigation),T=P?.length??0,z=i.entityViews,te=z?.length??0,L=i.formAutoSave&&!i.customId,Y=te>0||T>0,W=o??Cr(i?i.defaultSelectedView:void 0,{status:x,entityId:t}),M=d.useRef(W??nr),J=M.current===nr,{entity:H,dataLoading:V,dataLoadingError:ie}=Mr({path:e,entityId:t,collection:i,useCache:!1}),[Z,oe]=d.useState(H),[O,X]=d.useState(void 0);d.useEffect(()=>{H&&oe(H)},[H]),d.useEffect(()=>{if(x==="new")X(!1);else{const G=Z?Ir(i,E,e,Z??null):!1;Z&&X(!G)}},[E,Z,x]);const q=d.useCallback(G=>{h(!1),k.open({type:"error",message:"Error before saving: "+G?.message}),console.error(G)},[k]),K=d.useCallback(G=>{h(!1),k.open({type:"error",message:"Error after saving (entity is saved): "+G?.message}),console.error(G)},[k]),U=(G,Ee)=>{h(!1),L||k.open({type:"success",message:`${i.singularName??i.name}: Saved correctly`}),oe(G),S("existing"),s(!1),l&&l({entity:G}),Ee?(b.setBlocked(!1),b.close(!0),u?.()):x!=="existing"&&y.replace({path:e,entityId:G.id,selectedSubPath:M.current,updateUrl:!0,collection:i})},F=d.useCallback(G=>{h(!1),k.open({type:"error",message:"Error saving: "+G?.message}),console.error("Error saving entity",e,t),console.error(G)},[t,e,k]),N=({values:G,previousValues:Ee,closeAfterSave:Be,entityId:Le,collection:It,path:Ft})=>{h(!0),Or({path:Ft,entityId:Le,values:G,previousValues:Ee,collection:It,status:x,dataSource:g,context:_,onSaveSuccess:j=>U(j,Be),onSaveFailure:F,onPreSaveHookError:q,onSaveSuccessHookError:K}).then()},ee=async({collection:G,path:Ee,entityId:Be,values:Le,previousValues:It,closeAfterSave:Ft,autoSave:j})=>{x&&(j?A(Le):N({collection:G,path:Ee,entityId:Be,values:Le,previousValues:It,closeAfterSave:Ft}))},se=z?z.map(G=>kr(G,v.entityViews)).filter(Boolean):[],R=z&&se.map((G,Ee)=>{if(!G||M.current!==G.key)return null;const Be=G.Builder;return Be?r.jsx("div",{className:p.cn(p.defaultBorderMixin,"relative flex-grow w-full h-full overflow-auto "),role:"tabpanel",children:r.jsx(ne,{children:C&&r.jsx(Be,{collection:i,entity:Z,modifiedValues:Q??Z?.values,formContext:C})})},`custom_view_${G.key}`):(console.error("customView.Builder is not defined"),null)}).filter(Boolean),D=V&&!Z||(!Z||O===void 0)&&(x==="existing"||x==="copy"),re=D||m,he=P&&P.map((G,Ee)=>{const Be=G.id??G.path,Le=Z?`${e}/${Z?.id}/${me(Be)}`:void 0;return M.current!==Be?null:r.jsxs("div",{className:"relative flex-grow h-full overflow-auto w-full",role:"tabpanel",children:[re&&r.jsx(er,{}),!D&&(Z&&Le?r.jsx(go,{fullPath:Le,parentCollectionIds:[...n,i.id],isSubCollection:!0,...G}):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_${Be}`)}).filter(Boolean),pe=d.useCallback(()=>{s(!1)},[]),fe=G=>{M.current=G,y.replace({path:e,entityId:t,selectedSubPath:G===nr?void 0:G,updateUrl:!0,collection:i})},Me=d.useCallback(G=>{I.current=G},[]),Ge=d.useCallback(G=>{k.open({type:"error",message:"Error updating id, check the console"})},[]),rt=d.useCallback(G=>{oe(Ee=>Ee?{...Ee,id:G}:void 0)},[]),Ne=G=>{L||s(G)};function ot(){const G=v.plugins;let Ee=r.jsx(vn,{status:x,path:e,collection:i,onEntitySaveRequested:ee,onDiscard:pe,onValuesChanged:Me,onModified:Ne,entity:Z,onIdChange:rt,onFormContextChange:B,hideId:i.hideIdFromForm,autoSave:L,onIdUpdateError:Ge});return G&&G.forEach(Be=>{Be.form?.provider&&(Ee=r.jsx(Be.form.provider.Component,{status:x,path:e,collection:i,onDiscard:pe,onValuesChanged:Me,onModified:Ne,entity:Z,context:_,formContext:C,...Be.form.provider.props,children:Ee}))}),r.jsx(ne,{children:Ee})}const vo=O===void 0?r.jsx(r.Fragment,{}):O?r.jsxs(r.Fragment,{children:[r.jsx(p.Typography,{className:"mt-16 mb-8 mx-8",variant:"h4",children:i.singularName??i.name}),r.jsx(Wr,{className:"px-12",entity:Z,path:e,collection:i})]}):ot(),ko=P&&P.map(G=>r.jsx(p.Tab,{className:"text-sm min-w-[140px]",value:G.id,children:G.name},`entity_detail_collection_tab_${G.name}`)),_o=se.map(G=>r.jsx(p.Tab,{className:"text-sm min-w-[140px]",value:G.key,children:G.name},`entity_detail_collection_tab_${G.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?.(),b.close(!1)),size:"large",children:r.jsx(p.CloseIcon,{})})}),r.jsx("div",{className:"flex-grow"}),D&&r.jsx("div",{className:"self-center",children:r.jsx(p.CircularProgress,{size:"small"})}),r.jsxs(p.Tabs,{value:M.current,onValueChange:G=>{fe(G)},className:"pl-4 pr-4 pt-0",children:[r.jsx(p.Tab,{disabled:!Y,value:nr,className:`${Y?"":"hidden"} text-sm min-w-[140px]`,children:i.singularName??i.name}),_o,ko]})]}),r.jsxs("div",{className:"flex-grow h-full flex overflow-auto flex-row w-full ",style:{},children:[r.jsx("div",{role:"tabpanel",hidden:!J,id:`form_${e}`,className:" w-full",children:D?r.jsx(er,{}):vo}),R,he]})]})})}function Hl(e,t){const[o,a]=d.useState(),{navigator:i}=d.useContext(ge.UNSAFE_NavigationContext),n=ge.useNavigate(),s=()=>{a(void 0)},c=()=>{t(),a(void 0),n(-1)},l=d.useCallback(({action:u,location:m,retry:h})=>{switch(u){case"REPLACE":{h();return}case"POP":a(m)}},[]);return d.useEffect(()=>{if(!e||o||!("block"in i))return;const u=i.block(m=>{const h={...m,retry(){u(),m.retry()}};l(h)});return u},[i,l,e,o]),{navigationWasBlocked:!!o,handleCancel:s,handleOk:c}}function Zl({open:e,handleOk:t,handleCancel:o,body:a,title:i}){return r.jsxs(p.Dialog,{open:e,onOpenChange:n=>n?o():t(),children:[r.jsxs(p.DialogContent,{children:[r.jsx(p.Typography,{variant:"h6",children:i}),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 Pn=d.createContext({width:"",blocked:!1,setBlocked:e=>{},setBlockedNavigationMessage:e=>{},close:()=>{}}),ir=()=>d.useContext(Pn);function Xl(){const t=_t().sidePanels,o=[...t];return o.push(void 0),r.jsx(r.Fragment,{children:o.map((a,i)=>r.jsx(Kl,{panel:a,offsetPosition:t.length-i-1},`side_dialog_${i}`))})}function Kl({offsetPosition:e,panel:t}){const[o,a]=d.useState(!1),[i,n]=d.useState(!1),[s,c]=d.useState(),l=d.useRef(t?.width),u=l.current,m=_t(),{navigationWasBlocked:h,handleOk:f,handleCancel:A}=Hl(i&&!o,()=>n(!1));d.useEffect(()=>{t&&(l.current=t.width)},[t]);const g=()=>{n(!1),a(!1),m.close(),t?.onClose?.()},b=()=>{a(!1)},y=k=>{i&&!k?a(!0):(m.close(),t?.onClose?.())};return r.jsxs(Pn.Provider,{value:{blocked:i,setBlocked:n,setBlockedNavigationMessage:c,width:u,close:y},children:[r.jsxs(p.Sheet,{open:!!t,onOpenChange:k=>!k&&y(),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(ne,{children:t.component})}),!t&&r.jsx("div",{style:{width:u}})]}),r.jsx(Zl,{open:h||o,handleOk:o?g:f,handleCancel:o?b:A,body:s})]})}function Rl(e){const{blocked:t,setBlocked:o,setBlockedNavigationMessage:a}=ir(),i=ue(),n=d.useMemo(()=>i.getParentCollectionIds(e.path),[i,e.path]),s=d.useMemo(()=>{if(!e)return;let l=e.collection;const u=i.getCollection(e.path,e.entityId);if(u&&(l=u),!l)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 l},[i,e]);d.useEffect(()=>{function l(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",l),()=>{typeof window<"u"&&window.removeEventListener("beforeunload",l)}},[t,s]);const c=d.useCallback(l=>{o(l),a(l?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(ne,{children:r.jsx(Jl,{...e,formWidth:e.width,collection:s,parentCollectionIds:n,onValuesAreModified:c})})})}const Tn="new";function ec(e,t){if(t)return Si;const o=!e.selectedSubPath,a=typeof e.width=="number"?`${e.width}px`:e.width;return o?a??ta:`calc(${Ii} + ${a??ta})`}const tc=(e,t)=>{const o=ge.useLocation(),a=d.useRef(!1),i=!De();d.useEffect(()=>{if(!e.loading&&!a.current){if(console.debug("Initialising side entity controller"),e.isUrlCollectionPath(o.pathname)){const l=o.hash===`#${Tn}`,u=e.urlPathToDataPath(o.pathname),m=rc(u,e.collections??[],l);for(let h=0;h<m.length;h++){const f=m[h];setTimeout(()=>{h===0?t.replace(sr(f,e,i)):t.open(sr(f,e,i))},1)}}else console.warn("Location path is not a collection path");a.current=!0}},[o,e,t,i]);const n=d.useCallback(()=>{t.close()},[t]),s=d.useCallback(l=>{if(l.copy&&!l.entityId)throw Error("If you want to copy an entity you need to provide an entityId");const u=Cr(l.collection?l.collection.defaultSelectedView:void 0,{status:l.copy?"copy":l.entityId?"existing":"new",entityId:l.entityId});t.open(sr({selectedSubPath:u,...l},e,i))},[t,e,i]),c=d.useCallback(l=>{if(l.copy&&!l.entityId)throw Error("If you want to copy an entity you need to provide an entityId");t.replace(sr(l,e,i))},[e,t,i]);return{close:n,open:s,replace:c}};function rc(e,t,o){const a=_r({path:e,collections:t}),i=[];let n="";for(let s=0;s<a.length;s++){const c=a[s];if(c.type==="collection"&&(n=c.path),s>0){const l=a[s-1];if(c.type==="entity")i.push({path:c.path,entityId:c.entityId,copy:!1});else if(c.type==="custom_view"){if(l.type==="entity"){const u=i[i.length-1];u&&(u.selectedSubPath=c.view.key)}}else if(c.type==="collection"&&l.type==="entity"){const u=i[i.length-1];u&&(u.selectedSubPath=c.collection.id??c.collection.path)}}}return o&&i.push({path:n,copy:!1}),i}const sr=(e,t,o)=>{const a=me(e.path),i=e.entityId?t.buildUrlCollectionPath(`${a}/${e.entityId}/${e.selectedSubPath||""}`):t.buildUrlCollectionPath(`${a}#${Tn}`),n=t.resolveAliasesFrom(e.path),s={...e,path:n};return{key:`${e.path}/${e.entityId}`,component:r.jsx(Rl,{...s}),urlPath:i,parentUrlPath:t.buildUrlCollectionPath(a),width:ec(e,o),onClose:e.onClose}};function oc(){const e=ge.useLocation(),t=ge.useNavigate(),[o,a]=d.useState([]),i=d.useRef(o),n=d.useRef({}),s=d.useRef(0),c=h=>{i.current=h,a(h)};d.useEffect(()=>{const A=(e.state?.panels??[]).map(g=>n.current[g]).filter(g=>!!g);$(i.current.map(g=>g.key),A.map(g=>g.key))||c(A)},[e]);const l=d.useCallback(()=>{if(o.length===0)return;const h=o[o.length-1],f=[...o.slice(0,-1)];if(c(f),s.current>0)h.urlPath&&t(-1),s.current--;else if(h.parentUrlPath){const A=e.state?.base_location??e;t(h.parentUrlPath,{replace:!0,state:{base_location:A,panels:f.map(g=>g.key)}})}},[o,t,e]),u=d.useCallback(h=>{const f=Array.isArray(h)?h:[h];f.forEach(b=>{n.current[b.key]=b}),s.current=s.current+f.length;const A=e.state?.base_location??e,g=[...o,...f];c(g),f.forEach(b=>{b.urlPath&&t(b.urlPath,{state:{base_location:A,panels:g.map(y=>y.key)}})})},[e,t,o]),m=d.useCallback(h=>{const f=Array.isArray(h)?h:[h];f.forEach(b=>{n.current[b.key]=b});const A=e.state?.base_location??e,g=[...o.slice(0,-f.length),...f];c(g),f.forEach(b=>{b.urlPath&&t(b.urlPath,{replace:!0,state:{base_location:A,panels:g.map(y=>y.key)}})})},[e,t,o]);return{sidePanels:o,close:l,open:u,replace:m}}function ac(e){d.useEffect(()=>{if(!e)return;const t=Fo[e];t&&(So.registerLocale(e,t),So.setDefaultLocale(e))},[e])}function nc({delegate:e,propertyConfigs:t,navigationController:o}){return{fetchCollection:d.useCallback(({path:a,collection:i,filter:n,limit:s,startAfter:c,searchString:l,orderBy:u,order:m})=>e.fetchCollection({path:a,filter:n,limit:s,startAfter:c,searchString:l,orderBy:u,order:m}),[e]),listenCollection:e.listenCollection?d.useCallback(({path:a,collection:i,filter:n,limit:s,startAfter:c,searchString:l,orderBy:u,order:m,onUpdate:h,onError:f})=>{const A=i??o.getCollection(a),g=!!A?.collectionGroup;if(!e.listenCollection)throw Error("useBuildDataSource delegate not initialised");return e.listenCollection({path:a,filter:n,limit:s,startAfter:c,searchString:l,orderBy:u,order:m,onUpdate:h,onError:f,isCollectionGroup:g,collection:A})},[e,o.getCollection]):void 0,fetchEntity:d.useCallback(({path:a,entityId:i})=>e.fetchEntity({path:a,entityId:i}),[e]),listenEntity:e.listenEntity?d.useCallback(({path:a,entityId:i,collection:n,onUpdate:s,onError:c})=>{if(!e.listenEntity)throw Error("useBuildDataSource delegate not initialised");return e.listenEntity({path:a,entityId:i,onUpdate:s,onError:c})},[e.listenEntity]):void 0,saveEntity:d.useCallback(({path:a,entityId:i,values:n,collection:s,status:c})=>{const l=s??o.getCollection(a),m=(l?Pe({collection:l,path:a,entityId:i,fields:t}):void 0)?.properties,h=yo(n,e.buildReference,e.buildGeoPoint,e.buildDate,e.buildDeleteFieldValue),f=m?Do({inputValues:h,properties:m,status:c,timestampNowValue:e.currentTime(),setDateToMidnight:e.setDateToMidnight}):h;return e.saveEntity({path:a,entityId:i,values:f,status:c}).then(A=>({id:A.id,path:A.path,values:e.delegateToCMSModel(f)}))},[e.saveEntity,o.getCollection]),deleteEntity:d.useCallback(({entity:a})=>e.deleteEntity({entity:a}),[e.deleteEntity]),checkUniqueField:d.useCallback((a,i,n,s)=>e.checkUniqueField(a,i,n,s),[e.checkUniqueField]),generateEntityId:d.useCallback(a=>e.generateEntityId(a),[e.generateEntityId]),countEntities:e.countEntities?async({path:a,collection:i,filter:n,order:s,orderBy:c})=>e.countEntities({path:a,filter:n,orderBy:c,order:s,isCollectionGroup:!!i.collectionGroup}):void 0,isFilterCombinationValid:d.useCallback(({path:a,filterValues:i,sortBy:n})=>e.isFilterCombinationValid?e.isFilterCombinationValid({path:a,filterValues:i,sortBy:n}):!0,[e.isFilterCombinationValid])}}function yo(e,t,o,a,i){return e===void 0?i():e===null?null:Array.isArray(e)?e.map(n=>yo(n,t,o,a,i)):e.isEntityReference&&e.isEntityReference()?t(e):e instanceof Mt?o(e):e instanceof Date?a(e):e&&typeof e=="object"?Object.entries(e).map(([n,s])=>({[n]:yo(s,t,o,a,i)})).reduce((n,s)=>({...n,...s}),{}):e}function bc(e){return e}const ic="https://api-drplyi3b6q-ey.a.run.app";async function sc(e,t){const o=await e.getAuthToken();return fetch(ic+"/access_log",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${o}`},body:JSON.stringify({plugins:t})}).then(async a=>a.json())}function lc(e,t){const[o,a]=d.useState(null),i=d.useRef(null),n=t?.map(s=>s.key).join(",");return d.useEffect(()=>{e.user&&e.user.uid!==i.current&&!e.initialLoading&&(sc(e,n).then(a),i.current=e.user.uid)},[e]),o}function cc(e){const t=zr(),{children:o,entityLinkBuilder:a,userConfigPersistence:i,dateTimeFormat:n,locale:s,authController:c,storageSource:l,dataSourceDelegate:u,plugins:m,onAnalyticsEvent:h,propertyConfigs:f,entityViews:A,components:g,navigationController:b}=e;ac(s);const y=nc({delegate:u,propertyConfigs:f,navigationController:b}),k=oc(),v=tc(b,k),_=m?.some(S=>S.loading)??!1,E=c.initialLoading||b.loading||_,C={dateTimeFormat:n,locale:s,entityLinkBuilder:a,plugins:m,entityViews:A??[],propertyConfigs:f??{},components:g},B=d.useMemo(()=>({onAnalyticsEvent:h}),[]),x=lc(c,m);return b.navigationLoadingError?r.jsx(p.CenteredView,{maxWidth:"md",children:r.jsx(be,{title:"Error loading navigation",error:b.navigationLoadingError})}):c.authError?r.jsx(p.CenteredView,{maxWidth:"md",children:r.jsx(be,{title:"Error loading auth",error:c.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(Tt.Provider,{value:t,children:r.jsx(da.Provider,{value:B,children:r.jsx(ca.Provider,{value:C,children:r.jsx(sa.Provider,{value:i,children:r.jsx(ia.Provider,{value:l,children:r.jsx(ra.Provider,{value:y,children:r.jsx(pr.Provider,{value:c,children:r.jsx(aa.Provider,{value:k,children:r.jsx(na.Provider,{value:v,children:r.jsx(oa.Provider,{value:b,children:r.jsx(Fi,{children:r.jsx(dc,{loading:E,children:o})})})})})})})})})})})})}function dc({loading:e,children:t}){const o=Ae(),a=ae();let i=t({context:o,loading:e});const n=a.plugins;return!e&&n&&n.forEach(s=>{s.provider&&(i=r.jsx(s.provider.Component,{...s.provider.props,context:o,children:i}))}),r.jsx(r.Fragment,{children:i})}function Qn({hovered:e,drawerOpen:t,closeDrawer:o}){const a=pt(),i=ue(),n=e&&!t,s=De(),c=ge.useNavigate(),[l,u]=d.useState(!1);if(!i.topLevelNavigation)throw Error("Navigation not ready in Drawer");const{navigationEntries:m,groups:h}=i.topLevelNavigation,f=m.filter(y=>y.type==="admin")??[],A=h.filter(y=>y!=="Admin"),g=d.useCallback(y=>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:y?y.toUpperCase():"Views".toUpperCase()})}):r.jsx("div",{className:"h-12 w-full"}),[t]),b=y=>{const k=y.type==="collection"?"drawer_navigate_to_collection":y.type==="view"?"drawer_navigate_to_view":"unmapped_event";a.onAnalyticsEvent?.(k,{url:y.url}),s||o()};return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-grow overflow-scroll no-scrollbar",children:A.map(y=>r.jsxs(d.Fragment,{children:[g(y),Object.values(m).filter(k=>k.group===y).map((k,v)=>r.jsx(Dn,{icon:r.jsx(Jt,{collectionOrView:k.collection??k.view}),tooltipsOpen:n,drawerOpen:t,onClick:()=>b(k),url:k.url,name:k.name},`navigation_${v}`))]},`drawer_group_${y}`))}),f.length>0&&r.jsx(p.Menu,{open:l,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:n,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((y,k)=>r.jsxs(p.MenuItem,{onClick:v=>{v.preventDefault(),c(y.path)},children:[r.jsx(Jt,{collectionOrView:y.view}),y.name]},`navigation_${k}`))})]})}function Dn({name:e,icon:t,drawerOpen:o,tooltipsOpen:a,url:i,onClick:n}){const s=r.jsx("div",{className:"text-gray-600 dark:text-gray-500",children:t}),c=r.jsxs(ge.NavLink,{onClick:n,style:{width:o?"280px":"72px",transition:o?"width 150ms ease-in":void 0},className:({isActive:l})=>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",l?"bg-slate-200 bg-opacity-75 dark:bg-gray-800":""),to:i,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:c})}const pc=280,uc=d.memo(function(t){const{children:o,name:a,logo:i,includeDrawer:n=!0,autoOpenDrawer:s,Drawer:c=Qn,drawerProps:l,FireCMSAppBar:u=En,fireCMSAppBarProps:m}=t,h=De(),[f,A]=d.useState(!1),[g,b]=d.useState(!1),y=d.useCallback(()=>b(!0),[]),k=d.useCallback(()=>b(!1),[]),v=d.useCallback(()=>{A(!1)},[]),_=f||!!(h&&s&&g);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:n,drawerOpen:_,...m}),r.jsx(fc,{displayed:n,onMouseEnter:y,onMouseMove:y,onMouseLeave:k,open:_,logo:i,hovered:g,setDrawerOpen:A,children:n&&r.jsx(c,{hovered:g,drawerOpen:_,closeDrawer:v,...l})}),r.jsxs("main",{className:"flex flex-col flex-grow overflow-auto",children:[r.jsx(mc,{}),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(ne,{children:o})})]})]})},$),mc=()=>r.jsx("div",{className:"flex flex-col min-h-[68px]"});function fc(e){const t=ue(),o=e.displayed?e.open?pc: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(Cn,{})})})}),e.children]})]});return De()?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}function Mn(e){return Object.keys(lr).includes(e)}const lr={text_field:{key:"text_field",name:"Text field",description:"Simple short text",Icon:p.ShortTextIcon,color:"#2d7ff9",property:{dataType:"string",Field:gt}},multiline:{key:"multiline",name:"Multiline",description:"Text with multiple lines",Icon:p.SubjectIcon,color:"#2d7ff9",property:{dataType:"string",multiline:!0,Field:gt}},markdown:{key:"markdown",name:"Markdown",description:"Text with advanced markdown syntax",Icon:p.FormatQuoteIcon,color:"#2d7ff9",property:{dataType:"string",markdown:!0,Field:hn}},url:{key:"url",name:"Url",description:"Text with URL validation",Icon:p.HttpIcon,color:"#154fb3",property:{dataType:"string",url:!0,Field:gt}},email:{key:"email",name:"Email",description:"Text with email validation",Icon:p.EmailIcon,color:"#154fb3",property:{dataType:"string",email:!0,Field:gt}},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:ln}},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:so}},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:lo}},number_input:{key:"number_input",name:"Number input",description:"Simple number field with validation",Icon:p.NumbersIcon,color:"#bec920",property:{dataType:"number",Field:gt}},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:so}},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:lo}},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:co}},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:co}},reference:{key:"reference",name:"Reference",description:"The value refers to a different collection",Icon:p.LinkIcon,color:"#ff0042",property:{dataType:"reference",Field:dn}},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:nn}},date_time:{key:"date_time",name:"Date/time",description:"A date time select field",Icon:p.ScheduleIcon,color:"#8b46ff",property:{dataType:"date",Field:cn}},group:{key:"group",name:"Group",description:"Group of multiple fields",Icon:p.BallotIcon,color:"#ff9408",property:{dataType:"map",properties:{},Field:pn}},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:un}},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:mn}},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:gn}},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:fn}}};function On(e){const t=cr(e);if(!t){console.error("No field id found for property",e);return}return lr[t]}function St(e,t){const o=wo(e),a=cr(e);if(!a){console.error("No field id found for property",e);return}const i=lr[a],n=o?t[o]:void 0;return Qe(i??{},n??{})}function cr(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"){if(e.keyValue)return"key_value";if(e.properties)return"group"}else if(e.dataType==="array"){const t=e.of;return e.oneOf?"block":Array.isArray(t)?"custom_array":we(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 wo(e){return e.propertyConfig?e.propertyConfig:cr(e)}const hc=d.memo(function({HomePage:t=on,customRoutes:o}){const a=ge.useLocation(),i=ue();if(!i)return r.jsx(r.Fragment,{});const n=a.state,s=n&&n.base_location?n.base_location:a,c=[];i.views&&i.views.forEach(f=>{Array.isArray(f.path)?c.push(...f.path.map(A=>dr(A,f))):c.push(dr(f.path,f))}),i.adminViews&&i.adminViews.forEach(f=>{Array.isArray(f.path)?c.push(...f.path.map(A=>dr(A,f))):c.push(dr(f.path,f))});const u=[...i.collections??[]].sort((f,A)=>A.path.length-f.path.length).map(f=>{const A=i.buildUrlCollectionPath(f.id??f.path);return r.jsx(ge.Route,{path:A+"/*",element:r.jsx(ne,{children:r.jsx(go,{isSubCollection:!1,parentCollectionIds:[],fullPath:f.id??f.path,...f,Actions:rr(f.Actions)},`collection_view_${f.id??f.path}`)})},`navigation_${f.id??f.path}`)}),m=r.jsx(ge.Route,{path:"/",element:r.jsx(t,{})}),h=r.jsx(ge.Route,{path:"*",element:r.jsx(xn,{})});return r.jsxs(ge.Routes,{location:s,children:[u,c,m,h,o]})}),dr=(e,t)=>r.jsx(ge.Route,{path:e,element:t.view},"navigation_view_"+e);w.ArrayContainer=Ao,w.ArrayContainerItem=bo,w.ArrayCustomShapedFieldBinding=gn,w.ArrayEnumPreview=Ur,w.ArrayItemOptions=Bn,w.ArrayOfMapsPreview=Ri,w.ArrayOfReferencesFieldBinding=nn,w.ArrayOfReferencesPreview=ka,w.ArrayOfStorageComponentsPreview=_a,w.ArrayOfStringsPreview=xa,w.ArrayOneOfPreview=Ca,w.ArrayPropertyEnumPreview=$r,w.ArrayPropertyPreview=Lr,w.AsyncPreviewComponent=es,w.AuthControllerContext=pr,w.BlockFieldBinding=fn,w.BooleanPreview=Sa,w.COLLECTION_PATH_SEPARATOR=Go,w.CircularProgressCenter=er,w.DEFAULT_FIELD_CONFIGS=lr,w.DatePreview=Ba,w.DateTimeFieldBinding=cn,w.DefaultHomePage=on,w.DeleteConfirmationDialog=Nl,w.Drawer=Qn,w.DrawerNavigationItem=Dn,w.EmptyValue=Ke,w.EntityCollectionRowActions=Kt,w.EntityCollectionTable=to,w.EntityCollectionView=go,w.EntityCollectionViewActions=an,w.EntityForm=vn,w.EntityReference=mr,w.EntityView=Wr,w.EnumValuesChip=Se,w.ErrorBoundary=ne,w.ErrorView=be,w.FieldCaption=Ol,w.FieldHelperText=xe,w.FireCMS=cc,w.FireCMSAppBar=En,w.FireCMSLogo=Cn,w.FormikArrayContainer=or,w.GeoPoint=Mt,w.IconForView=Jt,w.ImagePreview=ga,w.KeyValueFieldBinding=un,w.KeyValuePreview=qr,w.LabelWithIcon=Ce,w.MapFieldBinding=pn,w.MapPropertyPreview=Ea,w.MarkdownFieldBinding=hn,w.ModeControllerContext=Tt,w.ModeControllerProvider=Zn,w.MultiSelectBinding=lo,w.NavigationCard=en,w.NavigationCardBinding=rn,w.NavigationGroup=no,w.NavigationRoutes=hc,w.NotFoundPage=xn,w.NumberPropertyPreview=Ia,w.PropertyConfigBadge=Fl,w.PropertyFieldBinding=tt,w.PropertyPreview=ye,w.PropertyTableCell=Ga,w.ReadOnlyFieldBinding=po,w.ReferenceFieldBinding=dn,w.ReferencePreview=Ve,w.ReferenceSelectionTable=Ra,w.ReferenceWidget=Ql,w.RepeatFieldBinding=mn,w.Scaffold=uc,w.SearchIconsView=Ml,w.SelectFieldBinding=so,w.SelectableTable=Xa,w.SideDialogs=Xl,w.SkeletonPropertyComponent=Re,w.SmallNavigationCard=tn,w.SnackbarProvider=Jn,w.StorageThumbnail=Aa,w.StorageThumbnailInternal=ya,w.StorageUploadFieldBinding=co,w.StringPropertyPreview=jr,w.SwitchFieldBinding=ln,w.TextFieldBinding=gt,w.UrlComponentPreview=Ct,w.VirtualTable=qa,w.addInitialSlash=Xn,w.applyPermissionsFunctionIfEmpty=zo,w.buildAdditionalFieldDelegate=Ci,w.buildCollection=bi,w.buildEntityCallbacks=xi,w.buildEnumLabel=Oo,w.buildEnumValueConfig=_i,w.buildEnumValues=ki,w.buildFieldConfig=Ei,w.buildIdColumn=Ps,w.buildProperties=wi,w.buildPropertiesOrBuilder=vi,w.buildProperty=yi,w.canCreateEntity=lt,w.canDeleteEntity=qt,w.canEditEntity=Ir,w.defaultDateFormat=Vo,w.deleteEntityWithCallbacks=pa,w.enumToObjectEntries=Ue,w.flattenObject=Pr,w.fullPathToCollectionSegments=Br,w.getArrayValuesCount=Jo,w.getBracketNotation=mi,w.getCollectionByPathOrId=Qt,w.getCollectionPathsCombinations=Dt,w.getColorForProperty=ui,w.getColorScheme=Mo,w.getColumnKeysForProperty=Rt,w.getDefaultFieldConfig=On,w.getDefaultFieldId=cr,w.getDefaultPropertiesOrder=fi,w.getDefaultValueFor=Vt,w.getDefaultValueForDataType=br,w.getDefaultValuesFor=vt,w.getEntityImagePreviewPropertyKey=Wo,w.getEntityPreviewKeys=qo,w.getEntityTitlePropertyKey=Nr,w.getFieldConfig=St,w.getFieldId=wo,w.getHashValue=hr,w.getIcon=$o,w.getIconForProperty=ve,w.getIconForWidget=Ut,w.getIdIcon=pi,w.getLabelOrConfigFrom=Yt,w.getLastSegment=Kn,w.getPropertiesWithPropertiesOrder=Uo,w.getPropertyInPath=Xe,w.getRandomId=Bt,w.getReferenceFrom=Ye,w.getResolvedPropertyInPath=Sr,w.getSidePanelKey=Ll,w.getValueInPath=Oe,w.hydrateRegExp=jo,w.icon_synonyms=Fr,w.iconsSearch=Wt,w.isDefaultFieldConfigId=Mn,w.isEmptyObject=Ar,w.isEnumValueDisabled=ti,w.isHidden=wt,w.isObject=Ot,w.isPropertyBuilder=we,w.isReadOnly=it,w.isReferenceProperty=Lo,w.isValidRegExp=di,w.joinCollectionLists=Xo,w.makePropertiesEditable=Ho,w.makePropertiesNonEditable=Zo,w.mergeCollection=Ko,w.mergeDeep=Qe,w.pick=To,w.plural=gi,w.printChanged=Qr,w.propertiesToColumns=Ua,w.randomColor=si,w.randomString=st,w.removeFunctions=fr,w.removeInPath=Rn,w.removeInitialAndTrailingSlashes=me,w.removeInitialSlash=No,w.removePropsIfExisting=Qo,w.removeTrailingSlash=Po,w.removeUndefined=gr,w.renderSkeletonCaptionText=qi,w.renderSkeletonIcon=Yr,w.renderSkeletonImageThumbnail=Gr,w.renderSkeletonText=je,w.resolveArrayProperty=$e,w.resolveCollection=Pe,w.resolveCollectionPathIds=ur,w.resolveDefaultSelectedView=Cr,w.resolveEntityView=kr,w.resolveEnumValues=ri,w.resolveNavigationFrom=ua,w.resolvePermissions=kt,w.resolveProperties=wr,w.resolveProperty=Fe,w.resolvePropertyEnum=vr,w.sanitizeData=ei,w.saveEntityWithCallbacks=Or,w.segmentsToStrippedPath=Yo,w.serializeRegExp=ci,w.singular=Ai,w.slugify=jt,w.sortProperties=xr,w.stripCollectionPath=Er,w.toKebabCase=ai,w.toSnakeCase=ii,w.traverseValueProperty=Gt,w.traverseValuesProperties=yr,w.unslugify=li,w.updateDateAutoValues=Do,w.useAuthController=qe,w.useBrowserTitleAndIcon=Vl,w.useBuildLocalConfigurationPersistence=$l,w.useBuildModeController=ql,w.useBuildNavigationController=jl,w.useClearRestoreValue=Te,w.useClipboard=ma,w.useCollectionFetch=Pi,w.useColumnIds=Kr,w.useCustomizationController=ae,w.useDataSource=ze,w.useDataSourceEntityCollectionTableController=ro,w.useDebouncedCallback=Lt,w.useDebouncedData=Ka,w.useEntityFetch=Mr,w.useFireCMSContext=Ae,w.useLargeLayout=De,w.useModeController=zr,w.useNavigationController=ue,w.useReferenceDialog=At,w.useResolvedNavigationFrom=Ti,w.useSelectionController=oo,w.useSideDialogContext=ir,w.useSideDialogsController=_t,w.useSideEntityController=We,w.useSnackbarController=Je,w.useStorageSource=ct,w.useTableSearchHelper=ao,w.useTraceUpdate=Bi,w.useValidateAuthenticator=Wl,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
|
589
589
|
//# sourceMappingURL=index.umd.js.map
|