{"version":3,"file":"Conditional_wechat_in_form.CCArcd95.mjs","names":["useStore","useState"],"sources":["https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/x3kTSGYJ2vGyO1PgDs9O/CLIPUy49Wwz6mpaUJdIE/Conditional_wechat_in_form.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","// /code/Conditional_wechat_in_form.tsx\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const useStore=createStore({country:\"\"});export function withCountrySelect(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();return /*#__PURE__*/_jsx(Component,{ref:ref,...props,value:store.country,onValueChange:v=>setStore({country:v}),onChange:e=>setStore({country:e?.target?.value})});});}export function withShowIfChina(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store]=useStore();const isChina=store.country===\"China\";if(!isChina)return null;return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withCountrySelect\":{\"type\":\"reactHoc\",\"name\":\"withCountrySelect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withShowIfChina\":{\"type\":\"reactHoc\",\"name\":\"withShowIfChina\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Conditional_wechat_in_form.map"],"mappings":"qQAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,EAAO,EAAE,EACjD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,QAAQ,EAAU,MAAM,OAAO,OAAO,CAAC,GAAG,EAAU,MAAM,GAAG,EAAS,CAAG,EAClI,EAAW,OAAO,GAAS,SAAS,OAAO,OAAO,CAAC,GAAG,EAAO,EAAE,EAC7D,EAAa,IAAI,IACjB,EAAc,GAAU,CAC3B,OAAO,GAAW,aAAY,EAAS,EAAS,IAAa,EAAW,OAAO,GAAW,SAAS,OAAO,OAAO,CAAC,GAAG,EAAW,GAAG,EAAS,EAAE,EACjJ,EAAa,QAAQ,GAAQ,EAAO,GAAc,EAClD,SAASA,GAAU,CACnB,GAAK,CAAC,EAAM,EAAS,CAACC,EAAS,GAK/B,OAHA,OACA,EAAa,IAAI,OAAoB,EAAa,OAAO,IAAY,EAAE,EACpE,MAAmB,IAAM,IAAuB,CAAC,EAAU,MAAM,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