{"version":3,"file":"CMSLibrary.CmjMPRlw.mjs","names":["useRef","useTransition","useMemo"],"sources":["https:/framerusercontent.com/modules/OoGHZMzWDzm2mNN7bmeR/UmOIjvpgKrLZznysVdbK/Store.js","https:/framerusercontent.com/modules/PNm0aYRdp2Urx1MCseUn/ELGxjV92WFMoGKTv2Ojs/CMSLibrary.js"],"sourcesContent":["import{create,shallow}from\"https://framerusercontent.com/modules/XPZpWLgM1p9otlAim6ab/YZGwyfuvWTDLYoiYQunH/zustand.js\";// @ts-ignore\nimport{useRouter}from\"framer\";import{useRef,useTransition,useMemo,useEffect}from\"react\";// Create a function to generate the initial state\nconst createInitialState=()=>({totalItems:0,filters:{},randomizationSeed:null,search:\"\",sortOption:null,defaultSortOption:null,sortingUrlParameter:null,page:0,itemsPerPage:0,paginationType:null,paginationActive:false,paginationButtonsCount:0,searchFields:null});const useBaseStore=create((set,get)=>({instances:{},getState:id=>{const path=getCurrentPath();const state=get().instances[path]?.[id];return state||createInitialState();},setState:(id,updates)=>{const path=getCurrentPath();set(state=>({instances:{...state.instances,[path]:{...state.instances[path],[id]:{...state.getState(id),...updates}}}}));},// Example of how to update a specific state property\n    setTotalItems:(id,totalItems)=>{get().setState(id,{totalItems});},setFilterValue:(id,fieldName,value)=>{const currentFilters=get().getState(id).filters;get().setState(id,{filters:{...currentFilters,[fieldName]:{...currentFilters[fieldName],value}}});},setRandomizationSeed:(id,randomizationSeed)=>{get().setState(id,{randomizationSeed});},setSearch:(id,search)=>{get().setState(id,{search});},setSortOption:(id,sortOption)=>{get().setState(id,{sortOption});},setPage:(id,page)=>{get().setState(id,{page});},setSearchFields:(id,searchFields)=>{get().setState(id,{searchFields});},setPaginationButtonsCount:(id,paginationButtonsCount)=>{get().setState(id,{paginationButtonsCount});},setPaginationType:(id,paginationType)=>{get().setState(id,{paginationType});},deinitializePaginationButton:id=>{get().setState(id,{paginationButtonsCount:get().getState(id).paginationButtonsCount-1});}}));const useSuperfieldsStore=(id,selector,initialize=null)=>{const initializedRef=useRef(false);const[_,startTransition]=useTransition();const{currentRouteId}=useRouter();const previousRouteIdRef=useRef(currentRouteId);// Memoize the function wrappers\nconst memoizedFunctions=useMemo(()=>{const functions={};const state=useBaseStore.getState();for(const key in state){const value=state[key];if(typeof value===\"function\"){if(key.startsWith(\"set\")){functions[key]=(...args)=>{if(typeof window!==\"undefined\"){startTransition(()=>value(id,...args));}else{value(id,...args);}};}else{functions[key]=(...args)=>value(id,...args);}}}return functions;},[id]);// Reset the store when the route changes\nuseEffect(()=>{if(previousRouteIdRef.current!==currentRouteId){// Route has changed, reset the initialized state\npreviousRouteIdRef.current=currentRouteId;// If there's an initialize function, call it with a fresh state\nif(initialize){const state=useBaseStore.getState();const freshState=createInitialState();initialize(freshState);state.setState(id,freshState);}initializedRef.current=true;}},[currentRouteId,id,initialize]);// Initial setup effect\nuseEffect(()=>{if(initialize&&!initializedRef.current){const state=useBaseStore.getState();const currentState=state.getState(id);const initializedState={...currentState};initialize(initializedState);state.setState(id,initializedState);}initializedRef.current=true;},[]);return useBaseStore(state=>{const path=getCurrentPath();if(!state.instances[path]?.[id]){const initialState=createInitialState();state.setState(id,initialState);}let newState={...state.getState(id),...memoizedFunctions};return selector(newState);},shallow);};export default useSuperfieldsStore;const getCurrentPath=()=>{if(typeof window===\"undefined\"){return\"/\";}return window.location.pathname;};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Store.map","export function getCollectionData(collectionList){let queryParent=null;if(collectionList?.props?.query){queryParent=collectionList;}else if(collectionList?.props?.children?.props?.query){queryParent=collectionList.props.children;}else if(collectionList?.props?.children?.props?.children?.props?.query){queryParent=collectionList.props.children.props.children;}const query=queryParent?.props?.query;const from=query?.from;let collections=[];if(from){if(from.type===\"Collection\"){collections.push(from);}else if(from.type===\"LeftJoin\"){processJoin(from.left,collections);processJoin(from.right,collections);}}const select=query?.select;if(collections.length>1&&Array.isArray(select)){for(const field of select){if(field.type==\"Identifier\"&&field.name==\"id\"&&!field.alias){const mainCollection=collections.find(c=>c.alias==field.collection);if(mainCollection){collections=[mainCollection,...collections.filter(c=>c!==mainCollection)];}break;}}}const multiReferenceQueries={};const multiReferenceIdMap={};// Get collections from multi-reference fields\nif(Array.isArray(select)){for(const field of select){if(field.type===\"FunctionCall\"&&(field.functionName===\"ARRAY\"||field.functionName===\"FLAT_ARRAY\")&&Array.isArray(field.arguments)){for(const argument of field.arguments){if(argument.from?.type===\"Collection\"){const alias=argument.from.alias;let fieldId=alias;const right=argument.where?.right;if(right&&right.type===\"Identifier\"&&right.name){fieldId=right.name;}collections.push({...argument.from,fieldId});multiReferenceIdMap[fieldId]=alias;multiReferenceIdMap[alias]=alias;multiReferenceQueries[alias]=argument;}}}}}let queryData=collections[0]?.data;const propertyControlsById={};const propertyControlsByTitle={};for(const collection of collections){const byId={};const byName={};propertyControlsById[collection.alias]=byId;propertyControlsByTitle[collection.alias]=byName;const propertyControls=collection.data?.propertyControls;for(const id of Object.keys(propertyControls)){const control={id,...propertyControls[id]};byId[id]=control;byName[control.title]=control;}}// Get children function\nlet childrenFunction=null;if(collectionList){const clpc=collectionList.props?.children;if(typeof clpc==\"function\"){childrenFunction=clpc;}else if(typeof clpc?.props?.children==\"function\"){childrenFunction=clpc.props.children;}else if(typeof clpc?.props?.children?.props?.children==\"function\"){childrenFunction=clpc.props.children.props.children;}}return{query,queryParent,queryData,collections,propertyControlsById,propertyControlsByTitle,childrenFunction,multiReferenceQueries,multiReferenceIdMap};}function processJoin(join,collections){if(join&&typeof join===\"object\"){if(join.type===\"Collection\"){collections.push(join);}else if(join.type===\"LeftJoin\"){processJoin(join.left,collections);processJoin(join.right,collections);}}}// field: { name: string, referenceFieldName: string }\nexport function addFieldsToSelect(fields,query,propertyControlsByTitle,collections){const select=Array.isArray(query?.select)?[...query.select]:[];for(const field of fields){const selectItem=getSelectItemForField(field.name,field.referenceFieldName,query,propertyControlsByTitle,collections,select);if(selectItem){select.push(selectItem);}}return select;}export function getSelectItemForField(name,referenceFieldName,query,propertyControlsByTitle,collections,select=null// When there is a select, check for a matching existing select item\n){// const mainAlias = query?.from?.alias || \"\"\nconst mainAlias=collections[0]?.alias||\"\";const propertyControl=propertyControlsByTitle[mainAlias]?.[name];if(!propertyControl){return null;}const fieldId=propertyControl?.id;const alias=referenceFieldName?fieldId:mainAlias;const referencedField=referenceFieldName?propertyControlsByTitle[fieldId]?.[referenceFieldName]:null;if(select){let matchFound=false;for(const item of select){if(item.type===\"Identifier\"){if(referenceFieldName){if(referencedField&&item.alias===`${fieldId}.${referencedField.id}`&&item.collection===fieldId&&item.name===referencedField.id){matchFound=true;break;}}else{if(item.name===fieldId&&item.collection===alias){matchFound=true;break;}}}else if(item.type===\"FunctionCall\"){if(item.alias===fieldId){matchFound=true;break;}}}if(matchFound){return null;}}if(referenceFieldName){if(referencedField){return{alias:`${fieldId}.${referencedField.id}`,collection:fieldId,name:referencedField.id,type:\"Identifier\"};}}else{return{collection:alias,name:fieldId,type:\"Identifier\"};}}\nexport const __FramerMetadata__ = {\"exports\":{\"getSelectItemForField\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getCollectionData\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"addFieldsToSelect\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSLibrary.map"],"mappings":"wXAAuH,IACzF,IAA0D,CAClF,OAAwB,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,kBAAkB,KAAK,OAAO,GAAG,WAAW,KAAK,kBAAkB,KAAK,oBAAoB,KAAK,KAAK,EAAE,aAAa,EAAE,eAAe,KAAK,iBAAiB,GAAM,uBAAuB,EAAE,aAAa,KAAK,EAAQ,EAAa,GAAQ,EAAI,KAAO,CAAC,UAAU,EAAE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