{"version":3,"file":"useSimulatorURL.C2rdEAdI.mjs","names":["useState","React.useMemo"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/SwnDQm82Xt81SD83IHNA/Dn3v2txfpz3cdB4m0R8o/CreditStore.js","https:/framerusercontent.com/modules/6yTW9nDSqM7wcBWAdnDT/Kmp6WULrNb624rnrCLtN/useSimulatorURL.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{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";export const useCreditStore=createStore({credit:1e4,discount:75,index:0,dataset:\"eletronico\"});\nexport const __FramerMetadata__ = {\"exports\":{\"useCreditStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CreditStore.map","import*as React from\"react\";export function useSimulatorURL({destinyURL,staticURL,extraParams,credit}){return React.useMemo(()=>{if(typeof window===\"undefined\")return\"https://simulador.klubi.com.br\";const currentUrl=new URL(window.location.href);const parts=currentUrl.pathname.split(\"/\").filter(Boolean);const rawHost=currentUrl.hostname.replace(/^www\\./,\"\");const HOST_ALIAS={\"relevant-concept-074320.framer.app\":\"parceria.klubi.com.br\",\"delicate-report-871336.framer.app\":\"klubi.com.br\",\"parceria.theklubi.com\":\"parceria.klubi.com.br\",\"theklubi.com\":\"klubi.com.br\",\"parceria.framer.website\":\"parceria.klubi.com.br\",\"klubi.framer.website\":\"klubi.com.br\"};const host=HOST_ALIAS[rawHost]??rawHost;const last=arr=>arr.length?arr[arr.length-1]:\"\";const secondLast=arr=>arr.length>=2?arr[arr.length-2]:\"\";let parceiro=\"\";let categoria=\"\";if(host===\"parceria.klubi.com.br\"){parceiro=last(parts);categoria=secondLast(parts);}else if(host===\"klubi.com.br\"){parceiro=\"klubi\";categoria=last(parts);}else{parceiro=\"klubi\";categoria=last(parts);}if(staticURL&&staticURL!==\"none\"){categoria=staticURL;}if(parceiro.endsWith(\"-simulador\")){parceiro=parceiro.replace(/-simulador$/,\"\");}if(!parceiro||!categoria)return\"https://simulador.klubi.com.br\";const params=new URLSearchParams(currentUrl.search);if(destinyURL!==\"consorcio\"){params.set(\"credito\",String(credit??1e4));}else{params.delete(\"credito\");}if(extraParams?.trim()){const cleaned=extraParams.trim().replace(/^\\?/,\"\");new URLSearchParams(cleaned).forEach((v,k)=>params.set(k,v));}const qs=params.toString();switch(destinyURL){case\"consorcio\":return`https://consorcio.klubi.com.br/${categoria}/selecao-credito?parceiro=${parceiro}&${qs}`;case\"compraplanejada\":return`https://simulador.klubi.com.br/klubi/${categoria}`;case\"seguro\":return`https://simulador.klubi.com.br/seguro/nome?${qs}`;case\"simulador\":default:return`https://simulador.klubi.com.br/${parceiro}/${categoria}?${qs}`;}},[destinyURL,staticURL,extraParams,credit]);}\nexport const __FramerMetadata__ = {\"exports\":{\"useSimulatorURL\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./useSimulatorURL.map"],"mappings":"0LAA8E,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,SAAS,GAAU,CACnB,GAAK,CAAC,EAAM,GAAUA,EAAS,EAAW,CAK1C,OAHA,OACA,EAAa,IAAI,EAAS,KAAW,EAAa,OAAO,EAAS,EAAG,EA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