{
  "version": 3,
  "sources": ["ssg:https://cdn.thenty.io/beta/thenty-sdk.min.js", "ssg:https://framer.com/m/ThentyHelpers-I0Oh.js"],
  "sourcesContent": ["const logStyle=\"color:white;background-color:#FF4A29;font-family:system-ui;font-size:1.2rem;font-weight:bold\";class ThentySDK{constructor(){console.log(\"%cthenty SDK Module\",logStyle),this.apiURL=\"https://api.thenty.io\"}fetchAuthorizationKey(){return(window?.location?new URL(window.location.origin):\"\").host+\".authorization\"}fetchAuthorization(){var e=localStorage.getItem(this.fetchAuthorizationKey());return e?JSON.parse(e):null}setAuthorization(e){var t=this.fetchAuthorizationKey();localStorage.setItem(t,JSON.stringify(e)),window.dispatchEvent(new CustomEvent(\"storage\",{detail:{key:t,newValue:e}}))}fetchMetadataKey(){return(window?.location?new URL(window.location.origin):\"\").host+\".metadata\"}fetchMetadata(){var e=localStorage.getItem(this.fetchMetadataKey());return e?JSON.parse(e):null}logout(e=\"/\"){localStorage.removeItem(this.fetchAuthorizationKey()),window.location.pathname=e}checkForProduct(e=[],t=null){let r=t,o=(r=r||this.fetchAuthorization(),!1);if(r?.hasOwnProperty(\"member\"))for(const a of(r.member.products??[]).map(e=>e.id))if(e.includes(a)){o=!0;break}return o}getDataForCanvas(){var e=this.fetchMetadataKey(),t=this.fetchAuthorizationKey();let r=localStorage.getItem(e),o=localStorage.getItem(t)??null;o=o&&JSON.parse(o),r=r&&JSON.parse(r);var e=o?.hasOwnProperty(\"authorization\")&&o?.hasOwnProperty(\"member\"),t=o?.key?r?.logged_in_access_denied_redirect_path??\"#\":r?.login_redirect_path??\"#\",a=o?.member?.products??[];return{siteMeta:r,authorization:o,isLoggedIn:e,redirect_path:t,memberProducts:a}}isAccessDenied({regex_pattern:e,product_ids:t},r=[],o){e=new RegExp(e),t=!t.length||t.findIndex(e=>r.includes(e));return e.test(o)&&-1===t}assessPathForAccess(e,t=\"\"){var{siteMeta:r,redirect_path:o,memberProducts:a}=this.getDataForCanvas(),i=a.map(e=>e.id),n=e.startsWith(\"/\")?(\"\"+e).slice(1):e;for(const s of r?.protected_pages||[])if(this.isAccessDenied(s,i,n))return o?\"/\"+o:\"/access-denied\";return e+t}getRequestHeaders(e=!1){let t=!1;return e&&(t=this.fetchAuthorization()),{\"Content-Type\":\"application/json\",Accept:\"application/json\",\"x-secret-key\":window.variables.secretKey,\"x-site-key\":window.variables.siteKey,\"x-refresh-token\":window.variables.siteKey,...t&&{authorization:t?.authorization?.key,\"x-refresh-token\":t?.authorization.refresh}}}isGoogleRedirect(e=null){e=e??new URLSearchParams(window.location.search);return e?.has(\"code\")&&e?.has(\"state\")&&\"GOOGLE_LOGIN\"===e?.get(\"state\")}fetchGoogleCallback(e=null,t=null){const r=t??new URLSearchParams(window.location.search);fetch(this.apiURL+\"/oauth/members/callback/google\",{method:\"POST\",headers:this.getRequestHeaders(),body:JSON.stringify({code:r.get(\"code\"),...e&&{planIdOverride:e},...window?.Rewardful?.referral&&{rewardfulClientReferenceId:window.Rewardful.referral}})}).then(async e=>{var t=await e.json();if(200<e.status)throw new Error(t.errorMessage);return t}).then(e=>{r.delete(\"code\"),r.delete(\"state\");var t=new URL(window.location.href);t.search=r.toString(),history.replaceState(null,\"\",t.toString()),this.setAuthorization(e),setTimeout(()=>{window.open(e.redirect_url??\"#\",\"_self\")},500)})}refetchSiteMetadataTrigger=()=>{var e=new URL(window.location.origin);window.dispatchEvent(new CustomEvent(\"storage\",{detail:{key:e.host+\".reauth\",newValue:!0}}))};toggleBookmark(e,t,r=void 0){var o=this.fetchAuthorization();return this.fetchGeneric(\"/bookmarks\",\"POST\",{slug:t,collection:e,...void 0!==r&&{value:r}},o?.authorization?.key).then(this.refetchSiteMetadataTrigger)}fetchGeneric(e,t=\"GET\",r=null,o=null){return fetch(\"\"+this.apiURL+e,{method:t,headers:this.getRequestHeaders(o),...r&&{body:JSON.stringify(r)}}).then(async e=>{var t=await e.json();if(200<e.status)throw new Error(t.errorMessage);return t})}}const thentyAuth=new ThentySDK;\"undefined\"!=typeof window&&(window.thentyAuth=thentyAuth);export{thentyAuth};", "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": "gGAAA,IAAMA,EAAS,+FAAqGC,EAAN,KAAe,CAAC,aAAa,CAAC,QAAQ,IAAI,sBAAsBD,CAAQ,EAAE,KAAK,OAAO,uBAAuB,CAAC,uBAAuB,CAAC,OAAOE,GAAQ,SAAS,IAAI,IAAIA,EAAO,SAAS,MAAM,EAAE,IAAI,KAAK,gBAAgB,CAAC,oBAAoB,CAAC,IAAI,EAAE,aAAa,QAAQ,KAAK,sBAAsB,CAAC,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,KAAK,sBAAsB,EAAE,aAAa,QAAQ,EAAE,KAAK,UAAU,CAAC,CAAC,EAAEA,EAAO,cAAc,IAAI,YAAY,UAAU,CAAC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,EAAW,CAACA,CAAQ,CAAC,EAAkB,SAAAA,CAAQ,CAAE",
  "names": ["logStyle", "ThentySDK", "window", "o", "a", "e", "t", "r", "i", "n", "s", "thentyAuth", "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", "fetchUserData", "authorization", "useThenty", "userData", "se"]
}
