{"version":3,"file":"CMS_Protection.eKuitiyP.mjs","names":["useState","useState"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/rguVIZf2CjgcJrHctZiM/38TPyw85f3I3mkkuxANk/CMS_Protection.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","/*\n * createStore (framer/store@1.0.1)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js\"\n","// Copyright by Shams.digital for free production level uses.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{forwardRef,useState,useEffect}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";// Configuration - Update these values\nconst CONFIG={protectedCollections:[\"work\"],password:\"Design\",sessionKey:\"framer_cms_auth\"};// Create Framer store for authentication state\nconst useAuthStore=createStore({isAuthenticated:false,showModal:false,currentPath:\"\"});// Password Protection Modal Component\nconst PasswordModal=({onSubmit,error})=>{const[password,setPassword]=useState(\"\");return /*#__PURE__*/_jsx(\"div\",{style:{position:\"fixed\",top:0,left:0,right:0,bottom:0,backgroundColor:\"rgba(0, 0, 0, 0.85)\",backdropFilter:\"blur(8px)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",zIndex:999999,fontFamily:\"-apple-system, BlinkMacSystemFont, sans-serif\"},children:/*#__PURE__*/_jsxs(\"div\",{style:{backgroundColor:\"#ffffff\",borderRadius:\"16px\",padding:\"48px\",maxWidth:\"420px\",width:\"90%\",boxShadow:\"0 25px 50px -12px rgba(0, 0, 0, 0.25)\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{textAlign:\"center\",marginBottom:\"32px\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{width:\"64px\",height:\"64px\",backgroundColor:\"#f3f4f6\",borderRadius:\"50%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",margin:\"0 auto 16px\",fontSize:\"24px\"},children:\"🔒\"}),/*#__PURE__*/_jsx(\"h2\",{style:{margin:\"0 0 8px 0\",fontSize:\"24px\",fontWeight:\"600\",color:\"#111827\"},children:\"Password Required\"}),/*#__PURE__*/_jsxs(\"p\",{style:{margin:0,fontSize:\"16px\",color:\"#6b7280\"},children:[\"Client work is private — please enter the password or email Tiffany to take a look.\",/*#__PURE__*/_jsx(\"p\",{children:/*#__PURE__*/_jsx(\"a\",{href:\"https://www.tiffanysoohoo.com\",children:\"Back to portfolio\"})})]})]}),/*#__PURE__*/_jsxs(\"form\",{onSubmit:e=>{e.preventDefault();onSubmit(password);},children:[/*#__PURE__*/_jsx(\"input\",{type:\"password\",value:password,onChange:e=>setPassword(e.target.value),placeholder:\"Enter password\",autoFocus:true,style:{width:\"100%\",padding:\"16px\",fontSize:\"16px\",border:error?\"2px solid #ef4444\":\"2px solid #e5e7eb\",borderRadius:\"12px\",marginBottom:\"16px\",outline:\"none\",boxSizing:\"border-box\"}}),error&&/*#__PURE__*/_jsxs(\"div\",{style:{padding:\"12px 16px\",backgroundColor:\"#fef2f2\",border:\"1px solid #fecaca\",borderRadius:\"8px\",marginBottom:\"20px\",fontSize:\"14px\",color:\"#dc2626\",display:\"flex\",alignItems:\"center\",gap:\"8px\"},children:[/*#__PURE__*/_jsx(\"span\",{children:\"⚠️\"}),error]}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",style:{width:\"100%\",padding:\"16px\",fontSize:\"16px\",fontWeight:\"600\",color:\"#ffffff\",backgroundColor:\"#3b82f6\",border:\"none\",borderRadius:\"12px\",cursor:\"pointer\"},children:\"Access Content\"})]})]})});};// Helper function to check if current page is from protected CMS collections\nconst isProtectedCMSPage=()=>{if(typeof window===\"undefined\")return false;const path=window.location.pathname.toLowerCase();const search=window.location.search.toLowerCase();// Remove trailing slash for consistent comparison\nconst cleanPath=path.endsWith(\"/\")&&path.length>1?path.slice(0,-1):path;return CONFIG.protectedCollections.some(collection=>{const slug=collection.toLowerCase();// Check ALL possible CMS URL patterns:\nreturn(// Direct collection access: /cms\ncleanPath===`/${slug}`||// Collection with trailing slash: /cms/\npath===`/${slug}/`||// All collection items: /cms/item1, /cms/item2, /cms/any-content\ncleanPath.startsWith(`/${slug}/`)||// Collection with query parameters: /cms?item=something\ncleanPath===`/${slug}`&&search.length>0||// Collection pagination: /cms-1, /cms-2, etc.\nnew RegExp(`^/${slug}-\\\\d+/?$`).test(cleanPath)||// Any deep nested paths: /cms/category/item\nnew RegExp(`^/${slug}(/.*)?$`).test(cleanPath)||// Query-based CMS access patterns\nsearch.includes(`collection=${slug}`)||search.includes(`cms=${slug}`));});};// Main CMS protection override\nexport function withCMSProtection(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useAuthStore();const[error,setError]=useState(\"\");const[isLoading,setIsLoading]=useState(true);// Check authentication status\nuseEffect(()=>{const checkAuth=()=>{const currentPath=window.location.pathname;if(isProtectedCMSPage()){// This is a protected CMS page, check authentication\nconst stored=sessionStorage.getItem(CONFIG.sessionKey);if(stored===\"authenticated\"){setStore({isAuthenticated:true,showModal:false,currentPath});}else{setStore({isAuthenticated:false,showModal:true,currentPath});}}else{// Not a protected page, allow access\nsetStore({isAuthenticated:true,showModal:false,currentPath});}setIsLoading(false);};// Small delay to ensure DOM and routing are ready\nconst timer=setTimeout(checkAuth,100);return()=>clearTimeout(timer);},[setStore]);// Handle navigation changes\nuseEffect(()=>{const handleNavigationChange=()=>{const currentPath=window.location.pathname;// Re-evaluate protection status on every navigation\nif(isProtectedCMSPage()){const stored=sessionStorage.getItem(CONFIG.sessionKey);if(stored!==\"authenticated\"){setStore({isAuthenticated:false,showModal:true,currentPath});}else{setStore({isAuthenticated:true,showModal:false,currentPath});}}else{setStore({isAuthenticated:true,showModal:false,currentPath});}};// Override browser navigation methods to catch programmatic navigation\nconst originalPushState=window.history.pushState;const originalReplaceState=window.history.replaceState;window.history.pushState=function(...args){originalPushState.apply(window.history,args);setTimeout(handleNavigationChange,50);};window.history.replaceState=function(...args){originalReplaceState.apply(window.history,args);setTimeout(handleNavigationChange,50);};// Listen for browser back/forward navigation\nwindow.addEventListener(\"popstate\",handleNavigationChange);// Listen for hash changes (in case CMS uses hash routing)\nwindow.addEventListener(\"hashchange\",handleNavigationChange);// Check if path has changed since last render\nif(store.currentPath!==window.location.pathname){setTimeout(handleNavigationChange,100);}return()=>{window.history.pushState=originalPushState;window.history.replaceState=originalReplaceState;window.removeEventListener(\"popstate\",handleNavigationChange);window.removeEventListener(\"hashchange\",handleNavigationChange);};},[store.currentPath,setStore]);const handlePasswordSubmit=password=>{if(password===CONFIG.password){setStore({isAuthenticated:true,showModal:false,currentPath:window.location.pathname});setError(\"\");sessionStorage.setItem(CONFIG.sessionKey,\"authenticated\");}else{setError(\"Incorrect password. Please try again.\");// Clear error after 3 seconds\nsetTimeout(()=>setError(\"\"),3e3);}};// Show loading state\nif(isLoading){return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",alignItems:\"center\",justifyContent:\"center\",minHeight:\"200px\",opacity:.5},children:\"Loading...\"});}// CRITICAL: Always check if current page is protected\nconst isCurrentPageProtected=isProtectedCMSPage();// Show password modal for protected pages without authentication\nif(isCurrentPageProtected&&(!store.isAuthenticated||store.showModal)){return /*#__PURE__*/_jsx(PasswordModal,{onSubmit:handlePasswordSubmit,error:error});}// Show component only if:\n// 1. Page is not protected, OR\n// 2. Page is protected AND user is authenticated\nif(!isCurrentPageProtected||isCurrentPageProtected&&store.isAuthenticated){return /*#__PURE__*/_jsx(Component,{ref:ref,...props});}// Fallback: show nothing for protected pages without auth\nreturn null;});}\nexport const __FramerMetadata__ = {\"exports\":{\"withCMSProtection\":{\"type\":\"reactHoc\",\"name\":\"withCMSProtection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMS_Protection.map"],"mappings":"8MAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,CAAM,CAAC,CAAC,CAAC,EACjD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,KAAK,GAAG,EAAU,MAAM,OAAO,OAAO,CAAC,GAAG,EAAU,MAAM,GAAG,CAAQ,CAAC,CAAE,EACjI,EAAW,OAAO,GAAS,SAAS,OAAO,OAAO,CAAC,GAAG,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