{
  "version": 3,
  "sources": ["ssg:https://framer.com/m/framer/store.js@^1.0.0", "ssg:https://framerusercontent.com/modules/xOTCGy1YfVj2KiNPqQcr/ngly9AcEfrYDhCFnwX1f/Pagination.js"],
  "sourcesContent": ["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map", "import{jsx as t,Fragment as e}from\"react/jsx-runtime\";import{useState as r,useEffect as i}from\"react\";import{createStore as n}from\"https://framer.com/m/framer/store.js@^1.0.0\";// Made with love by Cl\u00E9ment. https://lionneclement.com/\n// Full tutorial: https://lionneclement.com/tutorial/how-to-create-pagination-for-cms-collections-in-framer\nlet l=3,o=200,a=\"Previous\",u=\"Previous Disabled\",c=\"Next\",s=\"Next Disabled\",m=\"Page Number\",f=\"Page Number Active\",g=n({limit:3,offset:0,totalItems:0,currentPage:1}),P=()=>{let[t,e]=g();i(()=>{e({limit:3,offset:0,currentPage:1});},[]);};export function withCollectionList(e){return n=>{let[l,o]=g(),[a,u]=r(n);return i(()=>{o({totalItems:n.children.props.query.from.data.length});},[n]),i(()=>{u({...n,children:{...n.children,props:{...n.children.props,query:{...n.children.props.query,limit:{type:\"LiteralValue\",value:l.limit},offset:{type:\"LiteralValue\",value:l.offset}}}}});},[l.offset,l.limit,n]),/*#__PURE__*/t(e,{...a});};}export function withLoadMore(r){return i=>{let[n,l]=g();return P(),/*#__PURE__*/t(e,{children:n.limit<n.totalItems&&/*#__PURE__*/t(r,{...i,onClick:()=>l({limit:n.limit+3})})});};}export function withInfiniteScroll(e){return r=>{let[n,l]=g();P(),i(()=>(window.addEventListener(\"scroll\",o),()=>{window.removeEventListener(\"scroll\",o);}),[n.limit,n.totalItems]);let o=()=>{n.limit<n.totalItems&&window.innerHeight+document.documentElement.scrollTop>=document.documentElement.offsetHeight-200&&l({limit:n.limit+3});};return /*#__PURE__*/t(e,{...r});};}export function withPrevious(e){return r=>{let[i,n]=g();return P(),/*#__PURE__*/t(e,{...r,onClick:()=>{if(i.currentPage>1){let t=i.currentPage-1;n({offset:(t-1)*3,currentPage:t}),window.scrollTo(0,0);}},variant:1!==i.currentPage?\"Previous\":\"Previous Disabled\"});};}export function withNext(e){return r=>{let[i,n]=g();return P(),/*#__PURE__*/t(e,{...r,onClick:()=>{if(3*i.currentPage<i.totalItems){let t=i.currentPage+1;n({offset:(t-1)*3,currentPage:t}),window.scrollTo(0,0);}},variant:3*i.currentPage<i.totalItems?\"Next\":\"Next Disabled\"});};}export function withCurrentPage(e){return n=>{let[l,o]=g();P();let[a,u]=r(()=>l.currentPage.toString()),[c,s]=r(()=>Math.ceil(l.totalItems/3));return i(()=>{u(l.currentPage.toString()),s(Math.ceil(l.totalItems/3));},[l.currentPage,l.totalItems]),/*#__PURE__*/t(e,{...n,page:`${a}/${c}`});};}export function withPageSelector(e){return n=>{let[l,o]=g(),[a,u]=r([]);P(),i(()=>{(()=>{let t=Math.ceil(l.totalItems/3),e=Array.from({length:t},(t,e)=>e+1);u(e);})();},[l.totalItems]);let c=t=>{o({offset:(t-1)*3,currentPage:t}),window.scrollTo(0,0);};return /*#__PURE__*/t(\"div\",{style:{display:\"flex\",flexDirection:\"row\"},children:a.map((r,i)=>/*#__PURE__*/t(e,{...n,page:r.toString(),onClick:()=>c(r),variant:l.currentPage===r?f:m},i))});};}export function withTablePagination(e){return n=>{let[l,o]=g(),[a,u]=r([]);P(),i(()=>{(()=>{let t=Math.ceil(l.totalItems/3),e=1===l.currentPage||l.currentPage===t?2:1,r=[];for(let i=1;i<=t;i++){let n=i>=l.currentPage-e&&i<=l.currentPage+e;1===i||i===t||n?r.push(i):(i===l.currentPage-e-1&&1!==i||i===l.currentPage+e+1&&i!==t)&&r.push(\"...\");}u(r);})();},[l.totalItems,l.currentPage]);let c=t=>{o({offset:(t-1)*3,currentPage:t}),window.scrollTo(0,0);};return /*#__PURE__*/t(\"div\",{style:{display:\"flex\",flexDirection:\"row\"},children:a.map((r,i,o)=>{let a=\"...\"===r;return /*#__PURE__*/t(e,{...n,page:r.toString(),onClick:()=>!a&&c(r),variant:l.currentPage===r||a?f:m},i);})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withNext\":{\"type\":\"reactHoc\",\"name\":\"withNext\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCurrentPage\":{\"type\":\"reactHoc\",\"name\":\"withCurrentPage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withPageSelector\":{\"type\":\"reactHoc\",\"name\":\"withPageSelector\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoadMore\":{\"type\":\"reactHoc\",\"name\":\"withLoadMore\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withInfiniteScroll\":{\"type\":\"reactHoc\",\"name\":\"withInfiniteScroll\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withPrevious\":{\"type\":\"reactHoc\",\"name\":\"withPrevious\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCollectionList\":{\"type\":\"reactHoc\",\"name\":\"withCollectionList\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withTablePagination\":{\"type\":\"reactHoc\",\"name\":\"withTablePagination\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Pagination.map"],
  "mappings": "sGAAqF,SAASA,EAAYC,EAAO,CACjH,IAAMC,EAAUC,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAGF,CAAM,CAAC,CAAC,CAAC,EACjDG,EAAaC,GAAU,CAC1B,OAAOA,GAAW,aAAYA,EAASA,EAASH,EAAU,KAAK,GAAGA,EAAU,MAAM,OAAO,OAAO,CAAC,GAAGA,EAAU,MAAM,GAAGG,CAAQ,CAAC,CAAE,EACjIC,EAAW,OAAOL,GAAS,SAAS,OAAO,OAAO,CAAC,GAAGA,CAAM,CAAC,EAAEA,EAC7DM,EAAa,IAAI,IACjBC,EAAcH,GAAU,CAC3B,OAAOA,GAAW,aAAYA,EAASA,EAASC,CAAU,GAAGA,EAAW,OAAOD,GAAW,SAAS,OAAO,OAAO,CAAC,GAAGC,EAAW,GAAGD,CAAQ,CAAC,EAAEA,EACjJE,EAAa,QAAQE,GAAQA,EAAOH,CAAU,CAAC,CAAE,EACjD,SAASI,GAAU,CACnB,GAAK,CAACC,EAAMC,CAAQ,EAAEC,EAASP,CAAU,EAIzC,OAFAQ,EAAU,KACVP,EAAa,IAAIK,CAAQ,EAAQ,IAAIL,EAAa,OAAOK,CAAQ,GAAI,CAAC,CAAC,EACpEG,EAAe,IAAI,IAAMA,EAAe,EAAQ,CAACb,EAAU,MAAME,CAAY,GAC1E,CAACO,EAAMH,CAAa,CAAG,CAAC,OAAOE,CAAS,CCb9C,IAAmH,EAAEM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,EAAEC,EAAE,IAAI,CAAC,GAAG,CAACC,EAAE,CAAC,EAAE,EAAE,EAAEC,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAE,EAA8rC,SAASC,EAASC,EAAE,CAAC,OAAOC,GAAG,CAAC,GAAG,CAACC,EAAEC,CAAC,EAAE,EAAE,EAAE,OAAOC,EAAE,EAAeC,EAAEL,EAAE,CAAC,GAAGC,EAAE,QAAQ,IAAI,CAAC,GAAG,EAAEC,EAAE,YAAYA,EAAE,WAAW,CAAC,IAAII,EAAEJ,EAAE,YAAY,EAAEC,EAAE,CAAC,QAAQG,EAAE,GAAG,EAAE,YAAYA,CAAC,CAAC,EAAEC,EAAO,SAAS,EAAE,CAAC,EAAG,EAAE,QAAQ,EAAEL,EAAE,YAAYA,EAAE,WAAW,OAAO,eAAe,CAAC,CAAE,CAAE",
  "names": ["createStore", "state1", "dataStore", "Data", "setDataStore", "newState", "storeState", "storeSetters", "setStoreState", "setter", "useStore", "state", "setState", "ye", "ue", "useObserveData", "createStore", "P", "t", "ue", "withNext", "e", "r", "i", "n", "P", "p", "t", "window"]
}
