{"version":3,"file":"Examples.P1bqXynW.mjs","names":["useStore","useState"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/cTyWfQxq4LLDPNRKXuTc/UZhIphp0iOchlo0Mh32Q/Examples.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","import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";// Learn more: https://www.framer.com/developers/overrides/\n// const useStore = createStore({\n//     background: \"#0099FF\",\n// })\nexport const useStore=createStore({currentPrice:\"120\",selected:1,soldToday:17,cachedQuery:false,confirmText:\"Potwierdź i zapłać\",confirmText2:\"Zamawiam z obowiązkiem odbioru przesyłki.\",zaPobraniem:false});export function usePriceOverride(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,text:Math.floor(.8*store.currentPrice)+\",00 zł\"});});}export function confirmButtonOverride(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,text:store.confirmText});});}export function useOldPriceOverride(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,text:store.currentPrice+\",00 zł\"});});}export function confirmCODText(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,text:store.zaPobraniem?store.confirmText2:\"\"});});}export function pobranieClickOverride(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();const cena=Math.floor(.8*store.currentPrice)+25;return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onChange:event=>{console.log(\"Wysylka za pobraniem: \"+event.target.checked);setStore({zaPobraniem:event.target.checked,confirmText:event.target.checked?\"Zam\\xf3w za pobraniem: \"+cena+\" zł\":\"Potwierdź i zapłać\"});}});});}export function useSelectOverride(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,defaultValue:store.selected,onChange:event=>{console.log(\"trigger update\");const cena=Math.floor(.8*event.target.value*120)+25;setStore({currentPrice:event.target.value*120,selected:event.target.value,confirmText:store.zaPobraniem?\"Zam\\xf3w z obowiązkiem odbioru: \"+cena+\" zł\":\"Potwierdź i zapłać\"});}});});}export function createOrder(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();const handleClick=async event=>{console.log(event.target.pobranie);let kurier=15;if(event.target.pobranie.checked===true){kurier=25;}const getParams={name:event.target.first.value,last:event.target.last.value,street:event.target.street.value,city:event.target.city.value,code:event.target.code.value,email:event.target.email.value,phone:event.target.phone.value,price:Math.floor(.8*store.currentPrice)+kurier+\"\",count:store.selected};if(event.target.pobranie.checked===true){getParams[\"pobranie\"]=true;}const searchParams=new URLSearchParams(getParams);const url=\"https://05uourksjf.execute-api.eu-central-1.amazonaws.com/alpha?\"+searchParams.toString();console.log(url);gtag(\"event\",\"conversion\",{send_to:\"AW-17018093418/AIfwCLnhh8waEOr-7bI_\"});window.location.href=url;};return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onSubmit:handleClick});});}export function soldOrdersToday(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();let data;const getCount=async()=>{const getParams={start:new Date(new Date().setHours(0,0,0,0)).getTime()/1e3+\"\"};const apiParams=new URLSearchParams(getParams);const url=\"https://05uourksjf.execute-api.eu-central-1.amazonaws.com/alpha/ordersCount?\"+apiParams.toString();data=fetch(url).then(res=>res.json()).then(data=>{setStore({soldToday:store.soldToday+parseInt(data.count),cachedQuery:true});});};if(!store.cachedQuery){getCount();}return /*#__PURE__*/_jsx(Component,{ref:ref,...props,//onLoad={getCount}\ntext:\"Dzisiaj sprzedano \"+store.soldToday+\" zestaw\\xf3w\"});});}\nexport const __FramerMetadata__ = {\"exports\":{\"confirmButtonOverride\":{\"type\":\"reactHoc\",\"name\":\"confirmButtonOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSelectOverride\":{\"type\":\"reactHoc\",\"name\":\"useSelectOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"createOrder\":{\"type\":\"reactHoc\",\"name\":\"createOrder\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"soldOrdersToday\":{\"type\":\"reactHoc\",\"name\":\"soldOrdersToday\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"confirmCODText\":{\"type\":\"reactHoc\",\"name\":\"confirmCODText\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useOldPriceOverride\":{\"type\":\"reactHoc\",\"name\":\"useOldPriceOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"usePriceOverride\":{\"type\":\"reactHoc\",\"name\":\"usePriceOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"pobranieClickOverride\":{\"type\":\"reactHoc\",\"name\":\"pobranieClickOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Examples.map"],"mappings":"kMAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,CAAC,CAClD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,MAAM,EAAE,EAAU,MAAM,OAAO,OAAO,CAAC,GAAG,EAAU,MAAM,GAAG,EAAS,CAAC,EAChI,EAAW,OAAO,GAAS,SAAS,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,EAC7D,EAAa,IAAI,IACjB,EAAc,GAAU,CAC3B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAW,EAAE,EAAW,OAAO,GAAW,SAAS,OAAO,OAAO,CAAC,GAAG,EAAW,GAAG,EAAS,CAAC,CAAC,EACjJ,EAAa,QAAQ,GAAQ,EAAO,EAAW,CAAC,EAChD,SAASA,GAAU,CACnB,GAAK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