{
  "version": 3,
  "sources": ["ssg:https://framer.com/m/ThentyHelpers-I0Oh.js"],
  "sourcesContent": ["import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect,useMemo}from\"react\";import{thentyAuth}from\"https://cdn.thenty.io/beta/thenty-sdk.min.js\";export const useThenty=()=>{const metaKey=thentyAuth.fetchMetadataKey();const authKey=thentyAuth.fetchAuthorizationKey();const[authorization,updateAuthorization]=useState(thentyAuth.fetchAuthorization());const[siteMeta,updateSiteMeta]=useState(thentyAuth.fetchMetadata());useEffect(()=>{// Event listener callback\nconst handleStorageChange=event=>{var _event_detail,_event_detail1;var _event_detail_key;const eventKey=(_event_detail_key=(_event_detail=event.detail)===null||_event_detail===void 0?void 0:_event_detail.key)!==null&&_event_detail_key!==void 0?_event_detail_key:event.key;var _event_detail_newValue;const eventNewValue=(_event_detail_newValue=(_event_detail1=event.detail)===null||_event_detail1===void 0?void 0:_event_detail1.newValue)!==null&&_event_detail_newValue!==void 0?_event_detail_newValue:event.newValue;if(eventKey===authKey){updateAuthorization(JSON.parse(eventNewValue));}if(eventKey===metaKey){updateSiteMeta(JSON.parse(eventNewValue));}};window.addEventListener(\"storage\",handleStorageChange);return()=>{window.removeEventListener(\"storage\",handleStorageChange);};},[]);return{authorization,siteMeta};};// TODO - Add to documentation section\nexport const hasTier=(productIds=[])=>{const{authorization}=useThenty();const canAccess=useMemo(()=>{return thentyAuth.checkForProduct(productIds);},[authorization,productIds]);return canAccess;};// TODO - Add to documentation section\nexport const hasProduct=(productIds=[])=>{return hasTier(productIds);};export const fetchUserData=()=>{const{authorization}=useThenty();const userData=useMemo(()=>{if(!authorization)return null;if(authorization===null||authorization===void 0?void 0:authorization.hasOwnProperty(\"member\")){return authorization===null||authorization===void 0?void 0:authorization.member;}else{return null;}},[authorization]);const loggedIn=useMemo(()=>{return!!userData;},[userData]);return{loggedIn,userData};};export const useSSO=planIdOverride=>{const[firstRender,setFirstRender]=useState(true);const ssoQueryParamHandler=()=>{var _window,_window_location,_window1;const searchParams=((_window=window)===null||_window===void 0?void 0:_window.location)?new URLSearchParams((_window1=window)===null||_window1===void 0?void 0:(_window_location=_window1.location)===null||_window_location===void 0?void 0:_window_location.search):{};if(thentyAuth.isGoogleRedirect(searchParams)){thentyAuth.fetchGoogleCallback(planIdOverride,searchParams).catch(err=>console.error(err));}};useEffect(()=>{if(firstRender){ssoQueryParamHandler();setFirstRender(false);}},[firstRender]);};export default function ThentyHelpers(){return /*#__PURE__*/_jsx(_Fragment,{});}\nexport const __FramerMetadata__ = {\"exports\":{\"hasProduct\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"hasTier\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useThenty\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"fetchUserData\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSSO\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"ThentyHelpers\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ThentyHelpers.map"],
  "mappings": "oIAA2L,IAAMA,EAAU,IAAI,CAAC,IAAMC,EAAQC,EAAW,iBAAiB,EAAQC,EAAQD,EAAW,sBAAsB,EAAO,CAACE,EAAcC,CAAmB,EAAEC,EAASJ,EAAW,mBAAmB,CAAC,EAAO,CAACK,EAASC,CAAc,EAAEF,EAASJ,EAAW,cAAc,CAAC,EAAE,OAAAO,EAAU,IAAI,CACld,IAAMC,EAAoBC,GAAO,CAAC,IAAIC,EAAcC,EAAmBC,EAAkB,IAAMC,GAAUD,GAAmBF,EAAcD,EAAM,UAAU,MAAMC,IAAgB,OAAO,OAAOA,EAAc,OAAO,MAAME,IAAoB,OAAOA,EAAkBH,EAAM,IAAI,IAAIK,EAAuB,IAA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CAAY,EAAE,MAAMG,GAAK,QAAQ,MAAMA,CAAG,CAAC,CAAG,EAAEC,EAAU,IAAI,CAAIX,IAAaG,EAAqB,EAAEF,EAAe,EAAK,EAAG,EAAE,CAACD,CAAW,CAAC,CAAE",
  "names": ["useThenty", "metaKey", "thentyAuth", "authKey", "authorization", "updateAuthorization", "ye", "siteMeta", "updateSiteMeta", "ue", "handleStorageChange", "event", "_event_detail", "_event_detail1", "_event_detail_key", "eventKey", "_event_detail_newValue", "eventNewValue", "window", "hasTier", "productIds", "se", "fetchUserData", "authorization", "useThenty", "userData", "se", "useSSO", "planIdOverride", "firstRender", "setFirstRender", "ye", "ssoQueryParamHandler", "_window", "_window_location", "_window1", "searchParams", "window", "thentyAuth", "err", "ue"]
}
