{"version":3,"file":"shared-lib.BCFYoAXf.mjs","names":["e","t","useState","useMemo"],"sources":["https:/cdn.thenty.io/beta/thenty-sdk.min.js","https:/framerusercontent.com/modules/cY7jJko3MCuTQvBA1qZ1/Hp1tilhknQaW6xKdsxGL/ThentyHelpers.js","https:/framer.com/m/ThentyHelpers-I0Oh.js","https:/framerusercontent.com/modules/UxDvn5G03RN8qZVC0Tk3/taS2hID1bgxORUlBV9uU/Thenty.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","/*\n * ThentyHelpers\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/cY7jJko3MCuTQvBA1qZ1/Hp1tilhknQaW6xKdsxGL/ThentyHelpers.js\"\nexport { default } from \"https://framerusercontent.com/modules/cY7jJko3MCuTQvBA1qZ1/Hp1tilhknQaW6xKdsxGL/ThentyHelpers.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{fetchUserData}from\"https://framer.com/m/ThentyHelpers-I0Oh.js\";import{thentyAuth}from\"https://cdn.thenty.io/beta/thenty-sdk.min.js\";export const withLogout=Component=>props=>/*#__PURE__*/_jsx(Component,{...props,onClick:()=>{thentyAuth.logout();}});export const showWhenLoggedIn=Component=>props=>{const{loggedIn}=fetchUserData();return!loggedIn?null:/*#__PURE__*/_jsx(Component,{...props});};export const hideWhenLoggedIn=Component=>props=>{const{loggedIn}=fetchUserData();return loggedIn?null:/*#__PURE__*/_jsx(Component,{...props});};export const withFirstName=Component=>props=>{const{loggedIn,userData}=fetchUserData();return!loggedIn||!userData?null:/*#__PURE__*/_jsx(Component,{...props,text:userData?.name?.split(\" \")[0]??\"\"});};export const withFullName=Component=>props=>{const{loggedIn,userData}=fetchUserData();return!loggedIn||!userData?null:/*#__PURE__*/_jsx(Component,{...props,text:userData?.name});};export const withEmail=Component=>props=>{const{loggedIn,userData}=fetchUserData();return!loggedIn||!userData?null:/*#__PURE__*/_jsx(Component,{...props,text:userData?.email});};\nexport const __FramerMetadata__ = {\"exports\":{\"hideWhenLoggedIn\":{\"type\":\"reactHoc\",\"name\":\"hideWhenLoggedIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withEmail\":{\"type\":\"reactHoc\",\"name\":\"withEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLogout\":{\"type\":\"reactHoc\",\"name\":\"withLogout\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFullName\":{\"type\":\"reactHoc\",\"name\":\"withFullName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showWhenLoggedIn\":{\"type\":\"reactHoc\",\"name\":\"showWhenLoggedIn\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFirstName\":{\"type\":\"reactHoc\",\"name\":\"withFirstName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Thenty.map"],"mappings":"2OAAM,EAAS,+FAAqG,EAAN,KAAe,CAAC,aAAa,CAAC,QA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