@framerauth/sdk 2.1.8 → 2.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,41 @@
1
- "use strict";(()=>{var Je=Object.defineProperty,Ve=Object.defineProperties,Ge=Object.getOwnPropertyDescriptors,oe=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable,ae=(t,e,r)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,L=(t,e)=>{for(var r in e||(e={}))Ke.call(e,r)&&ae(t,r,e[r]);if(oe)for(var r of oe(e))Qe.call(e,r)&&ae(t,r,e[r]);return t},A=(t,e)=>Ve(t,Ge(e)),Ye=class extends Error{constructor(t,e,r){super(e||t.toString(),{cause:r}),this.status=t,this.statusText=e,this.error=r}},Ze=async(t,e)=>{var r,n,o,a,i,u;let c=e||{},s={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:t,options:c,hooks:s};for(let f of e?.plugins||[]){if(f.init){let v=await((r=f.init)==null?void 0:r.call(f,t.toString(),e));c=v.options||c,t=v.url}s.onRequest.push((n=f.hooks)==null?void 0:n.onRequest),s.onResponse.push((o=f.hooks)==null?void 0:o.onResponse),s.onSuccess.push((a=f.hooks)==null?void 0:a.onSuccess),s.onError.push((i=f.hooks)==null?void 0:i.onError),s.onRetry.push((u=f.hooks)==null?void 0:u.onRetry)}return{url:t,options:c,hooks:s}},ie=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(){return this.options.delay}},Xe=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(t){return Math.min(this.options.maxDelay,this.options.baseDelay*2**t)}};function et(t){if(typeof t=="number")return new ie({type:"linear",attempts:t,delay:1e3});switch(t.type){case"linear":return new ie(t);case"exponential":return new Xe(t);default:throw new Error("Invalid retry strategy")}}var tt=async t=>{let e={},r=async n=>typeof n=="function"?await n():n;if(t?.auth){if(t.auth.type==="Bearer"){let n=await r(t.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(t.auth.type==="Basic"){let n=r(t.auth.username),o=r(t.auth.password);if(!n||!o)return e;e.authorization=`Basic ${btoa(`${n}:${o}`)}`}else if(t.auth.type==="Custom"){let n=r(t.auth.value);if(!n)return e;e.authorization=`${r(t.auth.prefix)} ${n}`}}return e},rt=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function nt(t){let e=t.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return rt.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function ot(t){try{return JSON.parse(t),!0}catch{return!1}}function ce(t){if(t===void 0)return!1;let e=typeof t;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(t)?!0:t.buffer?!1:t.constructor&&t.constructor.name==="Object"||typeof t.toJSON=="function"}function se(t){try{return JSON.parse(t)}catch{return t}}function le(t){return typeof t=="function"}function at(t){if(t?.customFetchImpl)return t.customFetchImpl;if(typeof globalThis<"u"&&le(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&le(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function it(t){let e=new Headers(t?.headers),r=await tt(t);for(let[n,o]of Object.entries(r||{}))e.set(n,o);if(!e.has("content-type")){let n=st(t?.body);n&&e.set("content-type",n)}return e}function st(t){return ce(t)?"application/json":null}function lt(t){if(!t?.body)return null;let e=new Headers(t?.headers);if(ce(t.body)&&!e.has("content-type")){for(let[r,n]of Object.entries(t?.body))n instanceof Date&&(t.body[r]=n.toISOString());return JSON.stringify(t.body)}return t.body}function ct(t,e){var r;if(e?.method)return e.method.toUpperCase();if(t.startsWith("@")){let n=(r=t.split("@")[1])==null?void 0:r.split("/")[0];return ue.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function dt(t,e){let r;return!t?.signal&&t?.timeout&&(r=setTimeout(()=>e?.abort(),t?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var ut=class de extends Error{constructor(e,r){super(r||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,de.prototype)}};async function ht(t,e){let r=await t["~standard"].validate(e);if(r.issues)throw new ut(r.issues);return r.value}var ue=["get","post","put","patch","delete"];function ft(t,e){let{baseURL:r,params:n,query:o}=e||{query:{},params:{},baseURL:""},a=t.startsWith("http")?t.split("/").slice(0,3).join("/"):r||"";if(t.startsWith("@")){let v=t.toString().split("@")[1].split("/")[0];ue.includes(v)&&(t=t.replace(`@${v}/`,"/"))}a.endsWith("/")||(a+="/");let[i,u]=t.replace(a,"").split("?"),c=new URLSearchParams(u);for(let[v,g]of Object.entries(o||{}))g!=null&&c.set(v,String(g));if(n)if(Array.isArray(n)){let v=i.split("/").filter(g=>g.startsWith(":"));for(let[g,V]of v.entries()){let F=n[g];i=i.replace(V,F)}}else for(let[v,g]of Object.entries(n))i=i.replace(`:${v}`,String(g));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let s=c.toString();return s=s.length>0?`?${s}`.replace(/\+/g,"%20"):"",a.startsWith("http")?new URL(`${i}${s}`,a):`${a}${i}${s}`}var h=async(t,e)=>{var r,n,o,a,i,u,c,s;let{hooks:f,url:v,options:g}=await Ze(t,e),V=at(g),F=new AbortController,Ne=(r=g.signal)!=null?r:F.signal,je=ft(v,g),Me=lt(g),$e=await it(g),ze=ct(v,g),p=A(L({},g),{url:je,headers:$e,body:Me,method:ze,signal:Ne});for(let P of f.onRequest)if(P){let b=await P(p);b instanceof Object&&(p=b)}("pipeTo"in p&&typeof p.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in p||(p.duplex="half"));let{clearTimeout:He}=dt(g,F),d=await V(p.url,p);He();let re={response:d,request:p};for(let P of f.onResponse)if(P){let b=await P(A(L({},re),{response:(o=e?.hookOptions)!=null&&o.cloneResponse?d.clone():d}));b instanceof Response?d=b:b instanceof Object&&(d=b.response)}if(d.ok){if(!(p.method!=="HEAD"))return{data:"",error:null};let b=nt(d),E={data:"",response:d,request:p};if(b==="json"||b==="text"){let T=await d.text(),qe=await((a=p.jsonParser)!=null?a:se)(T);E.data=qe}else E.data=await d[b]();p?.output&&p.output&&!p.disableValidation&&(E.data=await ht(p.output,E.data));for(let T of f.onSuccess)T&&await T(A(L({},E),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?d.clone():d}));return e?.throw?E.data:{data:E.data,error:null}}let We=(u=e?.jsonParser)!=null?u:se,C=await d.text(),ne=ot(C),G=ne?await We(C):null,Ie={response:d,responseText:C,request:p,error:A(L({},G),{status:d.status,statusText:d.statusText})};for(let P of f.onError)P&&await P(A(L({},Ie),{response:(c=e?.hookOptions)!=null&&c.cloneResponse?d.clone():d}));if(e?.retry){let P=et(e.retry),b=(s=e.retryAttempt)!=null?s:0;if(await P.shouldAttemptRetry(b,d)){for(let T of f.onRetry)T&&await T(re);let E=P.getDelay(b);return await new Promise(T=>setTimeout(T,E)),await h(t,A(L({},e),{retryAttempt:b+1}))}}if(e?.throw)throw new Ye(d.status,d.statusText,ne?G:C);return{data:null,error:A(L({},G),{status:d.status,statusText:d.statusText})}};var pt="https://core.framerauth.com/v2",N=class{baseURL=null;useBearerAuth=!1;data;state;api;auth;constructor(e){this.baseURL=null,this.data=e.data,this.state=e.state,this.api={fetchBookmarks:async()=>{if(!this.baseURL)throw new Error("Auth client not initialized");let r=await h(`${this.baseURL}/profile/bookmarks`,{...this.authOptions()});if(!r.data)return r;let n=new Set(r.data),o={};for(let a of n)o[a]=!0;return{data:o,error:null}},fetchProject:async()=>await h(`${pt}/public/project/config`)},this.auth={getSession:async()=>{if(!this.baseURL)throw new Error("Auth client not initialized");let r=await h(`${this.baseURL}/get-session`,{method:"GET",...this.authOptions(),query:{disableCookieCache:!0}});return r.data?(this.data.user.set(r.data.user),this.data.session.set(r.data.session),this.data.tags.set(r.data.user.tags??[])):(this.data.user.set(null),this.data.session.set(null),this.data.tags.set([]),this.data.bookmarks.set({}),this.data.bearerToken.set(null)),r},signUp:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let{fetchOptions:n,...o}=r,a=this.authOptions(),i={...a,...n,headers:{...a.headers,...n?.headers}},u=await h(`${this.baseURL}/sign-up/email`,{...i,method:"POST",body:o,onSuccess:c=>{let s=c.response.headers.get("set-auth-token");s&&this.data.bearerToken.set(s)}});return u.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(c=>{this.data.bookmarks.set(c.data??{})})),u},signIn:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let{fetchOptions:n,...o}=r,a=this.authOptions(),i={...a,...n,headers:{...a.headers,...n?.headers}},u=await h(`${this.baseURL}/sign-in/email`,{...i,method:"POST",body:o,onSuccess:c=>{let s=c.response.headers.get("set-auth-token");s&&this.data.bearerToken.set(s)}});return u.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(c=>{this.data.bookmarks.set(c.data??{})})),u},signInSocial:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await h(`${this.baseURL}/sign-in/social`,{method:"POST",...this.authOptions(),body:r});return n.data?.url&&(window.location.href=n.data.url),n},signOut:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await h(`${this.baseURL}/sign-out`,{method:"POST",...this.authOptions(),body:{}});return this.data.user.set(null),this.data.session.set(null),this.data.tags.set([]),this.data.bookmarks.set({}),this.data.bearerToken.set(null),r?.redirectTo&&(window.location.href=r.redirectTo),n},sendOTP:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/email-otp/send-verification-otp`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},signInOTP:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/sign-in/email-otp`,o=await h(n,{body:r,...this.authOptions(),method:"POST",onSuccess:a=>{let i=a.response.headers.get("set-auth-token");i&&this.data.bearerToken.set(i)}});return o.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(a=>{this.data.bookmarks.set(a.data??{})})),o},updateProfile:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile`;return await h(n,{body:r,...this.authOptions(),method:"PATCH"})},updateProfilePicture:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/avatar`;return await h(n,{method:"POST",body:r,...this.authOptions()})},createBookmark:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/bookmarks`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},deleteBookmark:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/bookmarks/${r.bookmark_type}/${r.id}`;return await h(n,{...this.authOptions(),method:"DELETE"})},sendForgotPasswordEmail:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/request-password-reset`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},resetPassword:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/reset-password`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},storeCheckout:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/store/checkout/session`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},storePortal:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/plugins/${r.pluginId}/portal`,o=this.authOptions();return await h(n,{...o,method:"GET",headers:{...o.headers,Accept:"application/json"},query:r.returnURL?{returnURL:r.returnURL}:void 0})},sendVerificationEmail:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/send-verification-email`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},exchangeOneTimeToken:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await h(`${this.baseURL}/one-time-token/verify`,{method:"POST",body:{token:r}});return n.data?.session?.token&&this.data.bearerToken.set(n.data.session.token),n}}}updateBaseURL(e){this.baseURL=e}updateAuthMode(e){this.useBearerAuth=e}async handleOTTFromURL(){if(!this.useBearerAuth)return;let e=new URLSearchParams(window.location.search),r=e.get("ott");if(!r)return;e.delete("ott");let n=e.size?`${window.location.pathname}?${e.toString()}${window.location.hash}`:`${window.location.pathname}${window.location.hash}`;history.replaceState(null,"",n),await this.auth.exchangeOneTimeToken(r)}authOptions(){if(this.useBearerAuth){let e=this.data.bearerToken.get();return e?{headers:{Authorization:`Bearer ${e}`}}:{}}return{credentials:"include"}}};var R=[],O=0,j=4,mt=0,y=t=>{let e=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=e.push(n),()=>{for(let a=O+j;a<R.length;)R[a]===n?R.splice(a,j):a+=j;let o=e.indexOf(n);~o&&(e.splice(o,1),--r.lc||r.off())}},notify(n,o){mt++;let a=!R.length;for(let i of e)R.push(i,r.value,n,o);if(a){for(O=0;O<R.length;O+=j)R[O](R[O+1],R[O+2],R[O+3]);R.length=0}},off(){},set(n){let o=r.value;o!==n&&(r.value=n,r.notify(o))},subscribe(n){let o=r.listen(n);return n(r.value),o},value:t};return r};var gt=5,M=6,$=10,yt=(t,e,r,n)=>(t.events=t.events||{},t.events[r+$]||(t.events[r+$]=n(o=>{t.events[r].reduceRight((a,i)=>(i(a),a),{shared:{},...o})})),t.events[r]=t.events[r]||[],t.events[r].push(e),()=>{let o=t.events[r],a=o.indexOf(e);o.splice(a,1),o.length||(delete t.events[r],t.events[r+$](),delete t.events[r+$])});var he=1e3,K=(t,e)=>yt(t,n=>{let o=e(n);o&&t.events[M].push(o)},gt,n=>{let o=t.listen;t.listen=(...i)=>(!t.lc&&!t.active&&(t.active=!0,n()),o(...i));let a=t.off;return t.events[M]=[],t.off=()=>{a(),setTimeout(()=>{if(t.active&&!t.lc){t.active=!1;for(let i of t.events[M])i();t.events[M]=[]}},he)},()=>{t.listen=o,t.off=a}});var z=(t={})=>{let e=y(t);return e.setKey=function(r,n){let o=e.value;typeof n>"u"&&r in e.value?(e.value={...e.value},delete e.value[r],e.notify(o,r)):e.value[r]!==n&&(e.value={...e.value,[r]:n},e.notify(o,r))},e};var fe=t=>t,D={},Q={addEventListener(){},removeEventListener(){}};function bt(){try{return typeof localStorage<"u"}catch{return!1}}bt()&&(D=localStorage);var vt={addEventListener(t,e,r){window.addEventListener("storage",e),window.addEventListener("pageshow",r)},removeEventListener(t,e,r){window.removeEventListener("storage",e),window.removeEventListener("pageshow",r)}};typeof window<"u"&&(Q=vt);function k(t,e=void 0,r={}){let n=r.encode||fe,o=r.decode||fe,a=y(e),i=a.set;a.set=s=>{let f=n(s);typeof f>"u"?delete D[t]:D[t]=f,i(s)};function u(s){s.key===t?s.newValue===null?i(e):i(o(s.newValue)):D[t]||i(e)}function c(){a.set(D[t]?o(D[t]):e)}return K(a,()=>{if(c(),r.listen!==!1)return Q.addEventListener(t,u,c),()=>{Q.removeEventListener(t,u,c)}}),a}var Pt="framerauth_v2_",pe=new TextEncoder,kt=new TextDecoder;function me(){let t=typeof window<"u"?window.location.hostname:"1f8cXd6c7b4a3vL4z5746oUgQ28190adbef";return pe.encode(Pt+t)}function wt(t){let e=me(),r=pe.encode(t),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r[o]^e[o%e.length];return n}function St(t){let e=wt(t),r=Array.from(e,n=>String.fromCharCode(n)).join("");return btoa(r)}function Rt(t){let e=me(),r=atob(t),n=Uint8Array.from(r,a=>a.charCodeAt(0)),o=new Uint8Array(n.length);for(let a=0;a<n.length;a++)o[a]=n[a]^e[a%e.length];return kt.decode(o)}function w({obfuscate:t}){return e=>{let r=JSON.stringify(e);return t&&(r=St(r)),r}}function S({deobfuscate:t,fallback:e,validator:r}){return n=>{try{if(!n)return e;t&&(n=Rt(n));let o=JSON.parse(n);if(r){let a=r(o);return a===null?e:a}return o}catch{return e}}}var ge=k("fa-project",null,{encode:w({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:null})}),ye=y(!1);var be=k("fa-tags",[],{encode:w({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:[]})}),ve=y(!1);function Pe(t){return Array.isArray(t)?t.length===0?!0:t.every(e=>e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.name=="string"):!1}function Et(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.id!="string"||typeof e.email!="string"||typeof e.name!="string"||typeof e.email_verified!="boolean"||!(e.created_at instanceof Date||typeof e.created_at=="string")||!(e.updated_at instanceof Date||typeof e.updated_at=="string")?!1:Pe(e.tags)}function Tt(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.id=="string"&&typeof e.user_id=="string"&&typeof e.token=="string"&&(e.expires_at instanceof Date||typeof e.expires_at=="string")&&(e.created_at instanceof Date||typeof e.created_at=="string")&&(e.updated_at instanceof Date||typeof e.updated_at=="string")}function ke(t){if(!t||typeof t!="object")return null;let e=t;return Pe(e.tags)||(e.tags=[]),Et(e)?e:null}function we(t){return Tt(t)?t:null}function Ot(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.entries(t).every(([e,r])=>typeof e=="string"&&typeof r=="boolean")}function Se(t){return!t||typeof t!="object"||Array.isArray(t)?{}:Ot(t)?t:{}}var Re=k("fa-user",null,{encode:w({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:null,validator:ke})}),Ee=y(!1);var Te=k("fa-session",null,{encode:w({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:null,validator:we})}),Oe=y(!1);var Le=y(!0);var Y=class t extends HTMLElement{static styles=`
1
+ "use strict";(()=>{var Ze=Object.defineProperty,Xe=Object.defineProperties,et=Object.getOwnPropertyDescriptors,ce=Object.getOwnPropertySymbols,tt=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable,de=(t,e,r)=>e in t?Ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,x=(t,e)=>{for(var r in e||(e={}))tt.call(e,r)&&de(t,r,e[r]);if(ce)for(var r of ce(e))rt.call(e,r)&&de(t,r,e[r]);return t},U=(t,e)=>Xe(t,et(e)),nt=class extends Error{constructor(t,e,r){super(e||t.toString(),{cause:r}),this.status=t,this.statusText=e,this.error=r}},ot=async(t,e)=>{var r,n,o,a,i,u;let c=e||{},s={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:t,options:c,hooks:s};for(let f of e?.plugins||[]){if(f.init){let v=await((r=f.init)==null?void 0:r.call(f,t.toString(),e));c=v.options||c,t=v.url}s.onRequest.push((n=f.hooks)==null?void 0:n.onRequest),s.onResponse.push((o=f.hooks)==null?void 0:o.onResponse),s.onSuccess.push((a=f.hooks)==null?void 0:a.onSuccess),s.onError.push((i=f.hooks)==null?void 0:i.onError),s.onRetry.push((u=f.hooks)==null?void 0:u.onRetry)}return{url:t,options:c,hooks:s}},ue=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(){return this.options.delay}},at=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(t){return Math.min(this.options.maxDelay,this.options.baseDelay*2**t)}};function it(t){if(typeof t=="number")return new ue({type:"linear",attempts:t,delay:1e3});switch(t.type){case"linear":return new ue(t);case"exponential":return new at(t);default:throw new Error("Invalid retry strategy")}}var st=async t=>{let e={},r=async n=>typeof n=="function"?await n():n;if(t?.auth){if(t.auth.type==="Bearer"){let n=await r(t.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(t.auth.type==="Basic"){let n=r(t.auth.username),o=r(t.auth.password);if(!n||!o)return e;e.authorization=`Basic ${btoa(`${n}:${o}`)}`}else if(t.auth.type==="Custom"){let n=r(t.auth.value);if(!n)return e;e.authorization=`${r(t.auth.prefix)} ${n}`}}return e},lt=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function ct(t){let e=t.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return lt.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function dt(t){try{return JSON.parse(t),!0}catch{return!1}}function pe(t){if(t===void 0)return!1;let e=typeof t;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(t)?!0:t.buffer?!1:t.constructor&&t.constructor.name==="Object"||typeof t.toJSON=="function"}function he(t){try{return JSON.parse(t)}catch{return t}}function fe(t){return typeof t=="function"}function ut(t){if(t?.customFetchImpl)return t.customFetchImpl;if(typeof globalThis<"u"&&fe(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&fe(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function ht(t){let e=new Headers(t?.headers),r=await st(t);for(let[n,o]of Object.entries(r||{}))e.set(n,o);if(!e.has("content-type")){let n=ft(t?.body);n&&e.set("content-type",n)}return e}function ft(t){return pe(t)?"application/json":null}function pt(t){if(!t?.body)return null;let e=new Headers(t?.headers);if(pe(t.body)&&!e.has("content-type")){for(let[r,n]of Object.entries(t?.body))n instanceof Date&&(t.body[r]=n.toISOString());return JSON.stringify(t.body)}return t.body}function mt(t,e){var r;if(e?.method)return e.method.toUpperCase();if(t.startsWith("@")){let n=(r=t.split("@")[1])==null?void 0:r.split("/")[0];return ge.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function gt(t,e){let r;return!t?.signal&&t?.timeout&&(r=setTimeout(()=>e?.abort(),t?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var bt=class me extends Error{constructor(e,r){super(r||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,me.prototype)}};async function yt(t,e){let r=await t["~standard"].validate(e);if(r.issues)throw new bt(r.issues);return r.value}var ge=["get","post","put","patch","delete"];function vt(t,e){let{baseURL:r,params:n,query:o}=e||{query:{},params:{},baseURL:""},a=t.startsWith("http")?t.split("/").slice(0,3).join("/"):r||"";if(t.startsWith("@")){let v=t.toString().split("@")[1].split("/")[0];ge.includes(v)&&(t=t.replace(`@${v}/`,"/"))}a.endsWith("/")||(a+="/");let[i,u]=t.replace(a,"").split("?"),c=new URLSearchParams(u);for(let[v,g]of Object.entries(o||{}))g!=null&&c.set(v,String(g));if(n)if(Array.isArray(n)){let v=i.split("/").filter(g=>g.startsWith(":"));for(let[g,Q]of v.entries()){let C=n[g];i=i.replace(Q,C)}}else for(let[v,g]of Object.entries(n))i=i.replace(`:${v}`,String(g));i=i.split("/").map(encodeURIComponent).join("/"),i.startsWith("/")&&(i=i.slice(1));let s=c.toString();return s=s.length>0?`?${s}`.replace(/\+/g,"%20"):"",a.startsWith("http")?new URL(`${i}${s}`,a):`${a}${i}${s}`}var h=async(t,e)=>{var r,n,o,a,i,u,c,s;let{hooks:f,url:v,options:g}=await ot(t,e),Q=ut(g),C=new AbortController,Ie=(r=g.signal)!=null?r:C.signal,We=vt(v,g),qe=pt(g),Je=await ht(g),Ve=mt(v,g),p=U(x({},g),{url:We,headers:Je,body:qe,method:Ve,signal:Ie});for(let k of f.onRequest)if(k){let y=await k(p);y instanceof Object&&(p=y)}("pipeTo"in p&&typeof p.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in p||(p.duplex="half"));let{clearTimeout:Ge}=gt(g,C),d=await Q(p.url,p);Ge();let se={response:d,request:p};for(let k of f.onResponse)if(k){let y=await k(U(x({},se),{response:(o=e?.hookOptions)!=null&&o.cloneResponse?d.clone():d}));y instanceof Response?d=y:y instanceof Object&&(d=y.response)}if(d.ok){if(!(p.method!=="HEAD"))return{data:"",error:null};let y=ct(d),O={data:"",response:d,request:p};if(y==="json"||y==="text"){let E=await d.text(),Ye=await((a=p.jsonParser)!=null?a:he)(E);O.data=Ye}else O.data=await d[y]();p?.output&&p.output&&!p.disableValidation&&(O.data=await yt(p.output,O.data));for(let E of f.onSuccess)E&&await E(U(x({},O),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?d.clone():d}));return e?.throw?O.data:{data:O.data,error:null}}let Ke=(u=e?.jsonParser)!=null?u:he,B=await d.text(),le=dt(B),Y=le?await Ke(B):null,Qe={response:d,responseText:B,request:p,error:U(x({},Y),{status:d.status,statusText:d.statusText})};for(let k of f.onError)k&&await k(U(x({},Qe),{response:(c=e?.hookOptions)!=null&&c.cloneResponse?d.clone():d}));if(e?.retry){let k=it(e.retry),y=(s=e.retryAttempt)!=null?s:0;if(await k.shouldAttemptRetry(y,d)){for(let E of f.onRetry)E&&await E(se);let O=k.getDelay(y);return await new Promise(E=>setTimeout(E,O)),await h(t,U(x({},e),{retryAttempt:y+1}))}}if(e?.throw)throw new nt(d.status,d.statusText,le?Y:B);return{data:null,error:U(x({},Y),{status:d.status,statusText:d.statusText})}};var kt="https://core.framerauth.com/v2",j=class{baseURL=null;useBearerAuth=!1;data;state;api;auth;constructor(e){this.baseURL=null,this.data=e.data,this.state=e.state,this.api={fetchBookmarks:async()=>{if(!this.baseURL)throw new Error("Auth client not initialized");let r=await h(`${this.baseURL}/profile/bookmarks`,{...this.authOptions()});if(!r.data)return r;let n=new Set(r.data),o={};for(let a of n)o[a]=!0;return{data:o,error:null}},fetchProject:async()=>await h(`${kt}/public/project/config`)},this.auth={getSession:async()=>{if(!this.baseURL)throw new Error("Auth client not initialized");let r=await h(`${this.baseURL}/get-session`,{method:"GET",...this.authOptions(),query:{disableCookieCache:!0}});return r.data?(this.data.user.set(r.data.user),this.data.session.set(r.data.session),this.data.tags.set(r.data.user.tags??[])):(this.data.user.set(null),this.data.session.set(null),this.data.tags.set([]),this.data.bookmarks.set({}),this.data.bearerToken.set(null)),r},signUp:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let{fetchOptions:n,...o}=r,a=this.authOptions(),i={...a,...n,headers:{...a.headers,...n?.headers}},u=await h(`${this.baseURL}/sign-up/email`,{...i,method:"POST",body:o,onSuccess:c=>{let s=c.response.headers.get("set-auth-token");s&&this.data.bearerToken.set(s)}});return u.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(c=>{this.data.bookmarks.set(c.data??{})})),u},signIn:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let{fetchOptions:n,...o}=r,a=this.authOptions(),i={...a,...n,headers:{...a.headers,...n?.headers}},u=await h(`${this.baseURL}/sign-in/email`,{...i,method:"POST",body:o,onSuccess:c=>{let s=c.response.headers.get("set-auth-token");s&&this.data.bearerToken.set(s)}});return u.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(c=>{this.data.bookmarks.set(c.data??{})})),u},signInSocial:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await h(`${this.baseURL}/sign-in/social`,{method:"POST",...this.authOptions(),body:r});return n.data?.url&&(window.location.href=n.data.url),n},signOut:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await h(`${this.baseURL}/sign-out`,{method:"POST",...this.authOptions(),body:{}});return this.data.user.set(null),this.data.session.set(null),this.data.tags.set([]),this.data.bookmarks.set({}),this.data.bearerToken.set(null),r?.redirectTo&&(window.location.href=r.redirectTo),n},sendOTP:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/email-otp/send-verification-otp`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},signInOTP:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/sign-in/email-otp`,o=await h(n,{body:r,...this.authOptions(),method:"POST",onSuccess:a=>{let i=a.response.headers.get("set-auth-token");i&&this.data.bearerToken.set(i)}});return o.error||(await this.auth.getSession(),this.api.fetchBookmarks().then(a=>{this.data.bookmarks.set(a.data??{})})),o},updateProfile:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile`;return await h(n,{body:r,...this.authOptions(),method:"PATCH"})},updateProfilePicture:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/avatar`;return await h(n,{method:"POST",body:r,...this.authOptions()})},createBookmark:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/bookmarks`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},deleteBookmark:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/profile/bookmarks/${r.bookmark_type}/${r.id}`;return await h(n,{...this.authOptions(),method:"DELETE"})},sendForgotPasswordEmail:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/request-password-reset`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},resetPassword:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/reset-password`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},storeCheckout:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/store/checkout/session`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},storePortal:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/plugins/${r.pluginId}/portal`,o=this.authOptions();return await h(n,{...o,method:"GET",headers:{...o.headers,Accept:"application/json"},query:r.returnURL?{returnURL:r.returnURL}:void 0})},sendVerificationEmail:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=`${this.baseURL}/send-verification-email`;return await h(n,{body:r,...this.authOptions(),method:"POST"})},exchangeOneTimeToken:async r=>{if(!this.baseURL)throw new Error("Auth client not initialized");let n=await h(`${this.baseURL}/one-time-token/verify`,{method:"POST",body:{token:r}});return n.data?.session?.token&&this.data.bearerToken.set(n.data.session.token),n}}}updateBaseURL(e){this.baseURL=e}updateAuthMode(e){this.useBearerAuth=e}async handleOTTFromURL(){if(!this.useBearerAuth)return;let e=new URLSearchParams(window.location.search),r=e.get("ott");if(!r)return;e.delete("ott");let n=e.size?`${window.location.pathname}?${e.toString()}${window.location.hash}`:`${window.location.pathname}${window.location.hash}`;history.replaceState(null,"",n),await this.auth.exchangeOneTimeToken(r)}authOptions(){if(this.useBearerAuth){let e=this.data.bearerToken.get();return e?{headers:{Authorization:`Bearer ${e}`}}:{}}return{credentials:"include"}}};var R=[],L=0,N=4,wt=0,b=t=>{let e=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(n){return r.lc=e.push(n),()=>{for(let a=L+N;a<R.length;)R[a]===n?R.splice(a,N):a+=N;let o=e.indexOf(n);~o&&(e.splice(o,1),--r.lc||r.off())}},notify(n,o){wt++;let a=!R.length;for(let i of e)R.push(i,r.value,n,o);if(a){for(L=0;L<R.length;L+=N)R[L](R[L+1],R[L+2],R[L+3]);R.length=0}},off(){},set(n){let o=r.value;o!==n&&(r.value=n,r.notify(o))},subscribe(n){let o=r.listen(n);return n(r.value),o},value:t};return r};var Pt=5,M=6,H=10,St=(t,e,r,n)=>(t.events=t.events||{},t.events[r+H]||(t.events[r+H]=n(o=>{t.events[r].reduceRight((a,i)=>(i(a),a),{shared:{},...o})})),t.events[r]=t.events[r]||[],t.events[r].push(e),()=>{let o=t.events[r],a=o.indexOf(e);o.splice(a,1),o.length||(delete t.events[r],t.events[r+H](),delete t.events[r+H])});var be=1e3,Z=(t,e)=>St(t,n=>{let o=e(n);o&&t.events[M].push(o)},Pt,n=>{let o=t.listen;t.listen=(...i)=>(!t.lc&&!t.active&&(t.active=!0,n()),o(...i));let a=t.off;return t.events[M]=[],t.off=()=>{a(),setTimeout(()=>{if(t.active&&!t.lc){t.active=!1;for(let i of t.events[M])i();t.events[M]=[]}},be)},()=>{t.listen=o,t.off=a}});var $=(t={})=>{let e=b(t);return e.setKey=function(r,n){let o=e.value;typeof n>"u"&&r in e.value?(e.value={...e.value},delete e.value[r],e.notify(o,r)):e.value[r]!==n&&(e.value={...e.value,[r]:n},e.notify(o,r))},e};var ye=t=>t,_={},X={addEventListener(){},removeEventListener(){}};function Rt(){try{return typeof localStorage<"u"}catch{return!1}}Rt()&&(_=localStorage);var Ot={addEventListener(t,e,r){window.addEventListener("storage",e),window.addEventListener("pageshow",r)},removeEventListener(t,e,r){window.removeEventListener("storage",e),window.removeEventListener("pageshow",r)}};typeof window<"u"&&(X=Ot);function w(t,e=void 0,r={}){let n=r.encode||ye,o=r.decode||ye,a=b(e),i=a.set;a.set=s=>{let f=n(s);typeof f>"u"?delete _[t]:_[t]=f,i(s)};function u(s){s.key===t?s.newValue===null?i(e):i(o(s.newValue)):_[t]||i(e)}function c(){a.set(_[t]?o(_[t]):e)}return Z(a,()=>{if(c(),r.listen!==!1)return X.addEventListener(t,u,c),()=>{X.removeEventListener(t,u,c)}}),a}var Et="framerauth_v2_",ve=new TextEncoder,Lt=new TextDecoder;function ke(){let t=typeof window<"u"?window.location.hostname:"1f8cXd6c7b4a3vL4z5746oUgQ28190adbef";return ve.encode(Et+t)}function Tt(t){let e=ke(),r=ve.encode(t),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r[o]^e[o%e.length];return n}function At(t){let e=Tt(t),r=Array.from(e,n=>String.fromCharCode(n)).join("");return btoa(r)}function xt(t){let e=ke(),r=atob(t),n=Uint8Array.from(r,a=>a.charCodeAt(0)),o=new Uint8Array(n.length);for(let a=0;a<n.length;a++)o[a]=n[a]^e[a%e.length];return Lt.decode(o)}function P({obfuscate:t}){return e=>{let r=JSON.stringify(e);return t&&(r=At(r)),r}}function S({deobfuscate:t,fallback:e,validator:r}){return n=>{try{if(!n)return e;t&&(n=xt(n));let o=JSON.parse(n);if(r){let a=r(o);return a===null?e:a}return o}catch{return e}}}var we=w("fa-project",null,{encode:P({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:null})}),Pe=b(!1);var Se=w("fa-tags",[],{encode:P({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:[]})}),Re=b(!1);function Oe(t){return Array.isArray(t)?t.length===0?!0:t.every(e=>e!==null&&typeof e=="object"&&typeof e.id=="string"&&typeof e.name=="string"):!1}function Ut(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.id!="string"||typeof e.email!="string"||typeof e.name!="string"||typeof e.email_verified!="boolean"||!(e.created_at instanceof Date||typeof e.created_at=="string")||!(e.updated_at instanceof Date||typeof e.updated_at=="string")?!1:Oe(e.tags)}function _t(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.id=="string"&&typeof e.user_id=="string"&&typeof e.token=="string"&&(e.expires_at instanceof Date||typeof e.expires_at=="string")&&(e.created_at instanceof Date||typeof e.created_at=="string")&&(e.updated_at instanceof Date||typeof e.updated_at=="string")}function Ee(t){if(!t||typeof t!="object")return null;let e=t;return Oe(e.tags)||(e.tags=[]),Ut(e)?e:null}function Le(t){return _t(t)?t:null}function Dt(t){return!t||typeof t!="object"||Array.isArray(t)?!1:Object.entries(t).every(([e,r])=>typeof e=="string"&&typeof r=="boolean")}function Te(t){return!t||typeof t!="object"||Array.isArray(t)?{}:Dt(t)?t:{}}var Ae=w("fa-user",null,{encode:P({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:null,validator:Ee})}),xe=b(!1);var Ue=w("fa-session",null,{encode:P({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:null,validator:Le})}),_e=b(!1);var De=b(!0);var Fe="This page is restricted.",Ft={lock:`
2
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
3
+ <path
4
+ d="M 2 7.5 L 14 7.5 L 14 12.5 C 14 14.157 12.657 15.5 11 15.5 L 5 15.5 C 3.343 15.5 2 14.157 2 12.5 Z"
5
+ fill="currentColor"
6
+ ></path>
7
+ <path
8
+ d="M 3 6.5 C 3 3.739 5.239 1.5 8 1.5 L 8 1.5 C 10.761 1.5 13 3.739 13 6.5 L 13 9.5 C 13 12.261 10.761 14.5 8 14.5 L 8 14.5 C 5.239 14.5 3 12.261 3 9.5 Z"
9
+ fill="transparent"
10
+ stroke-width="2"
11
+ stroke="currentColor"
12
+ ></path>
13
+ </svg>
14
+ `,warning:`
15
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
16
+ <path
17
+ d="M 6.7 1.75 C 7.278 0.75 8.722 0.75 9.3 1.75 L 15.36 12.25 C 15.938 13.25 15.216 14.5 14.061 14.5 L 1.939 14.5 C 0.784 14.5 0.062 13.25 0.64 12.25 Z"
18
+ fill="transparent"
19
+ stroke-width="1.5"
20
+ stroke="currentColor"
21
+ stroke-linejoin="round"
22
+ ></path>
23
+ <path
24
+ d="M 8 5 L 8 9"
25
+ fill="transparent"
26
+ stroke-width="1.5"
27
+ stroke="currentColor"
28
+ stroke-linecap="round"
29
+ ></path>
30
+ <path
31
+ d="M 8 11.75 L 8 11.75"
32
+ fill="transparent"
33
+ stroke-width="1.75"
34
+ stroke="currentColor"
35
+ stroke-linecap="round"
36
+ ></path>
37
+ </svg>
38
+ `},ee=class t extends HTMLElement{static styles=`
2
39
  :host {
3
40
  --color-primary: #f9f9f9;
4
41
  --color-secondary: #333333;
@@ -22,12 +59,24 @@
22
59
  visibility: visible;
23
60
  }
24
61
 
62
+ :host([theme="warning"]) {
63
+ --color-sheet: #fff7f0;
64
+ --color-border: #c77126;
65
+ --color-heading: #c77126;
66
+ --color-secondary: #c77126;
67
+ --button-background-color: #c77126;
68
+ --button-background-hover-color: #b3671f;
69
+ --button-background-active-color: #9e5b1b;
70
+ --button-title-color: #ffffff;
71
+ }
72
+
25
73
  .section {
26
74
  width: 100%;
27
75
  height: 100%;
28
76
  display: flex;
29
77
  justify-content: center;
30
78
  align-items: center;
79
+ outline: none;
31
80
  }
32
81
 
33
82
  main {
@@ -52,6 +101,15 @@
52
101
  color: var(--color-secondary);
53
102
  }
54
103
 
104
+ .heading {
105
+ color: var(--color-heading, var(--color-secondary));
106
+ margin-bottom: 8px;
107
+ line-height: 1.4em;
108
+ text-align: center;
109
+ font-size: 16px;
110
+ font-weight: 600;
111
+ }
112
+
55
113
  .description {
56
114
  color: var(--color-tertiary);
57
115
  margin-bottom: 30px;
@@ -116,28 +174,16 @@
116
174
  opacity: 1;
117
175
  background-color: var(--button-background-active-color);
118
176
  }
119
- `;shadow;config={message:"This page is restricted."};handleBack=()=>{history.back()};static get observedAttributes(){return["message"]}constructor(){super(),this.shadow=this.attachShadow({mode:"closed"})}attributeChangedCallback(e,r,n){e==="message"&&(this.config.message=n||"This page is restricted."),this.render()}connectedCallback(){this.style.fontFamily=getComputedStyle(document.body).fontFamily,this.render()}render(){let e=document.createElement("template");e.innerHTML=`
177
+ `;shadow;config={heading:"",message:Fe,actionLabel:"",actionHref:"",icon:"lock"};onAction;handleAction=()=>{this.onAction?.()};static get observedAttributes(){return["heading","message","action-label","action-href","icon"]}constructor(){super(),this.shadow=this.attachShadow({mode:"closed"})}attributeChangedCallback(e,r,n){switch(e){case"heading":this.config.heading=n||"";break;case"message":this.config.message=n||Fe;break;case"action-label":this.config.actionLabel=n||"";break;case"action-href":this.config.actionHref=n||"";break;case"icon":this.config.icon=n==="warning"?"warning":"lock";break}this.isConnected&&this.render()}connectedCallback(){this.style.fontFamily=getComputedStyle(document.body).fontFamily,this.render(),this.focusInitial()}focusInitial(){(this.shadow.querySelector(".btn--action")??this.shadow.querySelector(".section"))?.focus()}renderAction(){return this.config.actionLabel?this.config.actionHref?'<a class="btn--action" target="_blank" rel="noopener noreferrer"></a>':this.onAction?'<button class="btn--action" type="button"></button>':"":""}render(){let e=this.config.heading.length>0,r=e?'aria-labelledby="fa-overlay-heading" aria-describedby="fa-overlay-description"':'aria-labelledby="fa-overlay-description"',n=document.createElement("template");n.innerHTML=`
120
178
  <style>${t.styles}</style>
121
- <div class="section" role="dialog" aria-modal="true" aria-labelledby="fa-access-denied-description">
179
+ <div class="section" role="dialog" aria-modal="true" tabindex="-1" ${r}>
122
180
  <main>
123
- <div class="icon" aria-hidden="true">
124
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
125
- <path
126
- d="M 2 7.5 L 14 7.5 L 14 12.5 C 14 14.157 12.657 15.5 11 15.5 L 5 15.5 C 3.343 15.5 2 14.157 2 12.5 Z"
127
- fill="currentColor"
128
- ></path>
129
- <path
130
- d="M 3 6.5 C 3 3.739 5.239 1.5 8 1.5 L 8 1.5 C 10.761 1.5 13 3.739 13 6.5 L 13 9.5 C 13 12.261 10.761 14.5 8 14.5 L 8 14.5 C 5.239 14.5 3 12.261 3 9.5 Z"
131
- fill="transparent"
132
- stroke-width="2"
133
- stroke="currentColor"
134
- ></path>
135
- </svg>
136
- </div>
181
+ <div class="icon" aria-hidden="true">${Ft[this.config.icon]}</div>
137
182
  <div id="container">
138
- <div class="description" id="fa-access-denied-description"></div>
139
- <button class="btn--action" type="button">Back</button>
183
+ ${e?'<div class="heading" id="fa-overlay-heading"></div>':""}
184
+ <div class="description" id="fa-overlay-description"></div>
185
+ ${this.renderAction()}
140
186
  </div>
141
187
  </main>
142
188
  </div>
143
- `,this.shadow.replaceChildren(e.content.cloneNode(!0));let r=this.shadow.querySelector(".description");r&&(r.textContent=this.config.message),this.shadow.querySelector(".btn--action")?.addEventListener("click",this.handleBack)}},H="fa-access-denied";function Ae(){customElements.get(H)||customElements.define(H,Y)}function x(){document.body.style.visibility="hidden"}function U(){document.body.style.visibility="visible"}var Lt="/sign-in",At="This page is restricted.",W=null;function I(t,e){let n=document.querySelector(`meta[name="${t}"]`)?.content.trim();return n||e&&document.querySelector(`meta[name="${e}"]`)?.content.trim()||null}function xt(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function Z(){return W||(W={errorPath:m(I("fa:error-path","framerauth:error-path")??Lt),boostPatterns:xt(I("fa:boost","framerauth:boost")),router:I("fa:router"),accessDeniedMessage:I("fa:access-denied-message")??At},W)}function Ut(){return Z().errorPath}function m(t){let r=(t??"").trim();if(r.includes("://"))try{r=new URL(r).pathname}catch{}return r=r.split("#")[0]??"",r=r.split("?")[0]??"",r.length===0&&(r="/"),r.startsWith("/")||(r=`/${r}`),r!=="/"&&r.endsWith("/")&&(r=r.slice(0,-1)),r}function Dt(t,e){return m(t)===m(e)}function X(t=window.location.pathname){return m(t)==="/"}function _(t=window.location.pathname,e=Ut()){return Dt(t,e)}function xe(t){let e=t.map(r=>r.trim()).filter(Boolean).map(r=>{if(r==="*"||r==="/*")return{kind:"all"};let n=r.startsWith("/")?r:`/${r}`;return n.endsWith("/**")?{kind:"deep",base:m(n.slice(0,-3))}:n.endsWith("/*")?{kind:"oneSegment",base:m(n.slice(0,-2))}:n.endsWith("*")?{kind:"prefixPathSegment",base:m(n.slice(0,-1))}:{kind:"exact",base:m(n)}});return r=>{let n=m(r);return e.some(o=>{if(o.kind==="all")return!0;if(o.kind==="exact")return n===o.base;if(o.kind==="deep")return n.startsWith(`${o.base}/`);if(o.kind==="oneSegment"){if(!n.startsWith(`${o.base}/`))return!1;let a=n.slice(o.base.length+1);return a.length>0&&!a.includes("/")}return n===o.base||n.startsWith(`${o.base}/`)})}}var q=class{hasAccess;isPublicPath;errorPath;forceFallbackOverlay;accessDeniedMessage;onError;originalPushState;originalReplaceState;isMonkeyPatched=!1;navigationHandler=null;navigationSuccessHandler=null;fallbackPopStateHandler=null;lockedOverlay=null;shouldReloadAfterErrorRedirect=!1;isObservingNavigation=!1;constructor(e){this.hasAccess=e.hasAccess,this.isPublicPath=e.isPublicPath,this.errorPath=e.errorPath,this.forceFallbackOverlay=e.forceFallbackOverlay,this.accessDeniedMessage=e.accessDeniedMessage,this.onError=e.onError,this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history)}normalizeToPath(e){if(e instanceof URL)return m(e.pathname);if(e.startsWith("./"))return m(e.slice(1));if(e.startsWith("/"))return m(e);try{let r=new URL(e);return m(r.pathname)}catch{return m(e.startsWith("/")?e:"/"+e)}}normalizePathInput(e){let r=e.startsWith("/")?e:`/${e}`;return m(r)}checkAccess(e){let r=this.normalizePathInput(e);if(_(r,this.errorPath)||this.isPublicPath(r))return!0;try{return this.hasAccess(r)}catch{return!1}}isOnErrorPage(){let e=this.normalizePathInput(window.location.pathname);return _(e,this.errorPath)}redirectToError(){if(this.isOnErrorPage()){U();return}window.location.replace(this.errorPath)}handleAccessDenied(e){e&&this.onError&&this.onError(e),this.redirectToError()}monkeyPatchHistory(){if(this.isMonkeyPatched)return;let e=this;history.pushState=function(r,n,o){if(o){let a=e.normalizeToPath(o);e.checkAccess(a)||(x(),e.isObservingNavigation||e.renderLockedOverlay())}return e.originalPushState.call(this,r,n,o)},history.replaceState=function(r,n,o){if(o){let a=e.normalizeToPath(o);e.checkAccess(a)||(x(),e.isObservingNavigation||e.renderLockedOverlay())}return e.originalReplaceState.call(this,r,n,o)},this.isMonkeyPatched=!0}startObservingNavigation(){if(this.forceFallbackOverlay)return!1;let e=window.navigation;return!e||this.navigationHandler?!1:(this.navigationHandler=r=>{let n=r,o=n.destination?.url;if(!o)return;let a=new URL(o);if(!(a.origin!==window.location.origin||this.checkAccess(a.pathname))){if(x(),n.canIntercept&&r.cancelable&&typeof n.intercept=="function"){n.intercept({precommitHandler:u=>{u.redirect(this.errorPath,{history:n.navigationType==="push"?"push":"replace"}),this.shouldReloadAfterErrorRedirect=!0}});return}this.renderLockedOverlay()}},this.navigationSuccessHandler=()=>{this.shouldReloadAfterErrorRedirect&&this.isOnErrorPage()&&(this.shouldReloadAfterErrorRedirect=!1,window.location.reload())},e.addEventListener("navigate",this.navigationHandler),e.addEventListener("navigatesuccess",this.navigationSuccessHandler),this.isObservingNavigation=!0,!0)}stopObservingNavigation(){let e=window.navigation;!e||!this.navigationHandler||(e.removeEventListener("navigate",this.navigationHandler),this.navigationSuccessHandler&&e.removeEventListener("navigatesuccess",this.navigationSuccessHandler),this.navigationHandler=null,this.navigationSuccessHandler=null,this.shouldReloadAfterErrorRedirect=!1,this.isObservingNavigation=!1)}startObservingFallbackPopState(){this.fallbackPopStateHandler||(this.fallbackPopStateHandler=()=>{if(!this.checkAccess(window.location.pathname)){x(),this.renderLockedOverlay();return}this.removeLockedOverlay(),U()},window.addEventListener("popstate",this.fallbackPopStateHandler))}stopObservingFallbackPopState(){this.fallbackPopStateHandler&&(window.removeEventListener("popstate",this.fallbackPopStateHandler),this.fallbackPopStateHandler=null)}renderLockedOverlay(){if(this.lockedOverlay)return;this.startObservingFallbackPopState(),Ae();let e=document.createElement(H);e.id="fa-access-denied",e.setAttribute("message",this.accessDeniedMessage),document.documentElement.appendChild(e),this.lockedOverlay=e}removeLockedOverlay(){this.lockedOverlay?.remove(),this.lockedOverlay=null}restoreHistory(){this.isMonkeyPatched&&(history.pushState=this.originalPushState,history.replaceState=this.originalReplaceState,this.isMonkeyPatched=!1)}start(){this.stop(),this.startObservingNavigation(),this.monkeyPatchHistory()}stop(){this.restoreHistory(),this.stopObservingNavigation(),this.stopObservingFallbackPopState(),this.removeLockedOverlay(),U()}};var Ue=k("fa-bookmarks",z(),{encode:w({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:{},validator:Se})}),De=y(!1);var _e=k("fa-bearer-token",null,{encode:w({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:null})});var Be=(t,e)=>{let r=m(e),n=t.data.user.get(),o=t.data.session.get(),a=t.data.project.get();if(!a)return!1;if(!Object.prototype.hasOwnProperty.call(a.pages,r))return!0;if(!n||!o)return!1;let u=a.pages[r];return u.length===0?!0:u.some(c=>n.tags.find(s=>s.id===c))};console.log("FramerAuth SDK (JavaScript): 2.1.8");var _t="/v2",Bt=0,l=new N({data:{user:Re,project:ge,tags:be,bookmarks:Ue,session:Te,bearerToken:_e},state:{initializing:Le,userLoading:Ee,projectLoading:ye,tagsLoading:ve,bookmarksLoading:De,sessionLoading:Oe}});window.FramerAuth=l;var B=Z(),Fe=xe(B.boostPatterns);function Ft(){return _()?!0:l.data.project.get()!==null&&Fe(window.location.pathname)}function J(t){let e=Ce(t);if(!e)throw new Error("Unable to initialize FramerAuth: project tenantHost is missing");l.updateBaseURL(`https://${e}${_t}`),l.updateAuthMode(Ct(t))}function Ct(t){return t.sessionTransport==="bearer"}function Ce(t){if(t.customDomain)return t.customDomain;let e=Nt(t);return e?`${t.slug}.${e}`:null}function Nt(t){return Bt||t.tenantHost||null}function ee(){l.api.fetchBookmarks().then(({data:t})=>{l.data.bookmarks.set(t??{})})}function jt(){return new q({hasAccess:t=>Be(l,t),isPublicPath:t=>X(t)||Fe(t),errorPath:B.errorPath,forceFallbackOverlay:B.router==="overlay",accessDeniedMessage:B.accessDeniedMessage,onError:t=>{console.error("[Router] Error in router:",t)}})}function te(){let t=jt();return t.checkAccess(window.location.pathname)?(t.start(),!0):(t.handleAccessDenied(),!1)}function Mt(){let t=l.data.project.get();return t&&Ce(t)?(J(t),l.api.fetchProject().then(e=>{e.data&&(l.data.project.set(e.data),J(e.data))}).catch(e=>{console.error("Failed to refresh FramerAuth project:",e)}),l.handleOTTFromURL().then(()=>l.auth.getSession()).then(e=>{e.data!==null&&ee()}).catch(e=>{console.error("Failed to refresh FramerAuth session:",e)})):(l.state.projectLoading.set(!0),l.api.fetchProject().then(e=>{if(e.data)return l.data.project.set(e.data),J(e.data),l.state.projectLoading.set(!1),l.handleOTTFromURL().then(()=>l.auth.getSession());l.state.projectLoading.set(!1)}).then(e=>{e?.data!==null&&ee()}).catch(e=>{console.error("Failed to initialize FramerAuth in the background:",e),l.state.projectLoading.set(!1)})),te()}async function $t(){x();let t=l.data.project.get(),e=await l.api.fetchProject();if(e.data)t=e.data,l.data.project.set(t);else if(!t)throw new Error(e.error.message||"Unable to load FramerAuth project!");J(t),await l.handleOTTFromURL(),(await l.auth.getSession()).data!==null&&ee();let n=te();return n&&U(),n}async function zt(){l.state.initializing.set(!0);try{(Ft()?Mt():await $t())&&window.dispatchEvent(new CustomEvent("framerauth:initialized"))}catch(t){console.error("Failed to initialize FramerAuth:",t),X()||_(window.location.pathname,B.errorPath)?(te(),U()):window.location.replace(B.errorPath),window.dispatchEvent(new CustomEvent("framerauth:initialization-failed",{detail:{error:t}}))}finally{l.state.initializing.set(!1)}}zt();})();
189
+ `,this.shadow.replaceChildren(n.content.cloneNode(!0));let o=this.shadow.querySelector(".heading");o&&(o.textContent=this.config.heading);let a=this.shadow.querySelector(".description");a&&(a.textContent=this.config.message);let i=this.shadow.querySelector(".btn--action");i&&(i.textContent=this.config.actionLabel,i instanceof HTMLAnchorElement?i.href=this.config.actionHref:i.addEventListener("click",this.handleAction))}},te="fa-overlay";function Ct(){customElements.get(te)||customElements.define(te,ee)}function z(t){Ct();let e=document.createElement(te);return t.onAction&&(e.onAction=t.onAction),t.heading&&e.setAttribute("heading",t.heading),e.setAttribute("message",t.message),t.actionLabel&&e.setAttribute("action-label",t.actionLabel),t.actionHref&&e.setAttribute("action-href",t.actionHref),t.icon&&e.setAttribute("icon",t.icon),t.theme&&e.setAttribute("theme",t.theme),e}function T(){document.body.style.visibility="hidden"}function A(){document.body.style.visibility="visible"}var Bt="/sign-in",jt="This page is restricted.",I=null;function W(t,e){let n=document.querySelector(`meta[name="${t}"]`)?.content.trim();return n||e&&document.querySelector(`meta[name="${e}"]`)?.content.trim()||null}function Nt(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function re(){return I||(I={errorPath:m(W("fa:error-path","framerauth:error-path")??Bt),boostPatterns:Nt(W("fa:boost","framerauth:boost")),router:W("fa:router"),accessDeniedMessage:W("fa:access-denied-message")??jt},I)}function Mt(){return re().errorPath}function m(t){let r=(t??"").trim();if(r.includes("://"))try{r=new URL(r).pathname}catch{}return r=r.split("#")[0]??"",r=r.split("?")[0]??"",r.length===0&&(r="/"),r.startsWith("/")||(r=`/${r}`),r!=="/"&&r.endsWith("/")&&(r=r.slice(0,-1)),r}function Ht(t,e){return m(t)===m(e)}function q(t=window.location.pathname){return m(t)==="/"}function D(t=window.location.pathname,e=Mt()){return Ht(t,e)}function Ce(t){let e=t.map(r=>r.trim()).filter(Boolean).map(r=>{if(r==="*"||r==="/*")return{kind:"all"};let n=r.startsWith("/")?r:`/${r}`;return n.endsWith("/**")?{kind:"deep",base:m(n.slice(0,-3))}:n.endsWith("/*")?{kind:"oneSegment",base:m(n.slice(0,-2))}:n.endsWith("*")?{kind:"prefixPathSegment",base:m(n.slice(0,-1))}:{kind:"exact",base:m(n)}});return r=>{let n=m(r);return e.some(o=>{if(o.kind==="all")return!0;if(o.kind==="exact")return n===o.base;if(o.kind==="deep")return n.startsWith(`${o.base}/`);if(o.kind==="oneSegment"){if(!n.startsWith(`${o.base}/`))return!1;let a=n.slice(o.base.length+1);return a.length>0&&!a.includes("/")}return n===o.base||n.startsWith(`${o.base}/`)})}}var J=class{hasAccess;isPublicPath;errorPath;forceFallbackOverlay;accessDeniedMessage;onError;originalPushState;originalReplaceState;isMonkeyPatched=!1;navigationHandler=null;navigationSuccessHandler=null;fallbackPopStateHandler=null;lockedOverlay=null;shouldReloadAfterErrorRedirect=!1;isObservingNavigation=!1;constructor(e){this.hasAccess=e.hasAccess,this.isPublicPath=e.isPublicPath,this.errorPath=e.errorPath,this.forceFallbackOverlay=e.forceFallbackOverlay,this.accessDeniedMessage=e.accessDeniedMessage,this.onError=e.onError,this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history)}normalizeToPath(e){if(e instanceof URL)return m(e.pathname);if(e.startsWith("./"))return m(e.slice(1));if(e.startsWith("/"))return m(e);try{let r=new URL(e);return m(r.pathname)}catch{return m(e.startsWith("/")?e:"/"+e)}}normalizePathInput(e){let r=e.startsWith("/")?e:`/${e}`;return m(r)}checkAccess(e){let r=this.normalizePathInput(e);if(D(r,this.errorPath)||this.isPublicPath(r))return!0;try{return this.hasAccess(r)}catch{return!1}}isOnErrorPage(){let e=this.normalizePathInput(window.location.pathname);return D(e,this.errorPath)}redirectToError(){if(this.isOnErrorPage()){A();return}window.location.replace(this.errorPath)}handleAccessDenied(e){e&&this.onError&&this.onError(e),this.redirectToError()}monkeyPatchHistory(){if(this.isMonkeyPatched)return;let e=this;history.pushState=function(r,n,o){if(o){let a=e.normalizeToPath(o);e.checkAccess(a)||(T(),e.isObservingNavigation||e.renderLockedOverlay())}return e.originalPushState.call(this,r,n,o)},history.replaceState=function(r,n,o){if(o){let a=e.normalizeToPath(o);e.checkAccess(a)||(T(),e.isObservingNavigation||e.renderLockedOverlay())}return e.originalReplaceState.call(this,r,n,o)},this.isMonkeyPatched=!0}startObservingNavigation(){if(this.forceFallbackOverlay)return!1;let e=window.navigation;return!e||this.navigationHandler?!1:(this.navigationHandler=r=>{let n=r,o=n.destination?.url;if(!o)return;let a=new URL(o);if(!(a.origin!==window.location.origin||this.checkAccess(a.pathname))){if(T(),n.canIntercept&&r.cancelable&&typeof n.intercept=="function"){n.intercept({precommitHandler:u=>{u.redirect(this.errorPath,{history:n.navigationType==="push"?"push":"replace"}),this.shouldReloadAfterErrorRedirect=!0}});return}this.renderLockedOverlay()}},this.navigationSuccessHandler=()=>{this.shouldReloadAfterErrorRedirect&&this.isOnErrorPage()&&(this.shouldReloadAfterErrorRedirect=!1,window.location.reload())},e.addEventListener("navigate",this.navigationHandler),e.addEventListener("navigatesuccess",this.navigationSuccessHandler),this.isObservingNavigation=!0,!0)}stopObservingNavigation(){let e=window.navigation;!e||!this.navigationHandler||(e.removeEventListener("navigate",this.navigationHandler),this.navigationSuccessHandler&&e.removeEventListener("navigatesuccess",this.navigationSuccessHandler),this.navigationHandler=null,this.navigationSuccessHandler=null,this.shouldReloadAfterErrorRedirect=!1,this.isObservingNavigation=!1)}startObservingFallbackPopState(){this.fallbackPopStateHandler||(this.fallbackPopStateHandler=()=>{if(!this.checkAccess(window.location.pathname)){T(),this.renderLockedOverlay();return}this.removeLockedOverlay(),A()},window.addEventListener("popstate",this.fallbackPopStateHandler))}stopObservingFallbackPopState(){this.fallbackPopStateHandler&&(window.removeEventListener("popstate",this.fallbackPopStateHandler),this.fallbackPopStateHandler=null)}renderLockedOverlay(){if(this.lockedOverlay)return;this.startObservingFallbackPopState();let e=z({message:this.accessDeniedMessage,actionLabel:"Back",onAction:()=>history.back()});e.id="fa-access-denied",document.documentElement.appendChild(e),this.lockedOverlay=e}removeLockedOverlay(){this.lockedOverlay?.remove(),this.lockedOverlay=null}restoreHistory(){this.isMonkeyPatched&&(history.pushState=this.originalPushState,history.replaceState=this.originalReplaceState,this.isMonkeyPatched=!1)}start(){this.stop(),this.startObservingNavigation(),this.monkeyPatchHistory()}stop(){this.restoreHistory(),this.stopObservingNavigation(),this.stopObservingFallbackPopState(),this.removeLockedOverlay(),A()}};var Be=w("fa-bookmarks",$(),{encode:P({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:{},validator:Te})}),je=b(!1);var Ne=w("fa-bearer-token",null,{encode:P({obfuscate:!0}),decode:S({deobfuscate:!0,fallback:null})});var Me=(t,e)=>{let r=m(e),n=t.data.user.get(),o=t.data.session.get(),a=t.data.project.get();if(!a)return!1;if(!Object.prototype.hasOwnProperty.call(a.pages,r))return!0;if(!n||!o)return!1;let u=a.pages[r];return u.length===0?!0:u.some(c=>n.tags.find(s=>s.id===c))};console.log("FramerAuth SDK (JavaScript): 2.1.10");var $t="/v2",zt=0,He="https://frameauth.com/guides-v2/configuration-error",l=new j({data:{user:Ae,project:we,tags:Se,bookmarks:Be,session:Ue,bearerToken:Ne},state:{initializing:De,userLoading:xe,projectLoading:Pe,tagsLoading:Re,bookmarksLoading:je,sessionLoading:_e}});window.FramerAuth=l;var F=re(),$e=Ce(F.boostPatterns),V=null,ne=!1;function oe(t){return t?.status===404}function ae(){if(ne)return;if(ne=!0,l.data.project.set(null),l.state.projectLoading.set(!1),q()){console.warn(`FramerAuth: this domain is not linked to a FramerAuth project. The home page is shown signed-out; other pages show a warning. Fix: ${He}`),V||K(),A();return}V?.stop(),V=null,T();let t=z({heading:"FrameAuth can\u2019t verify this domain",message:"This site has FrameAuth installed which handles sign-up, sign-in, user accounts, and member-only content. Access stays locked until this domain is verified.",actionLabel:"Fix this",actionHref:He,icon:"warning",theme:"warning"});t.id="fa-project-not-configured",document.documentElement.appendChild(t)}function It(){return D()?!0:l.data.project.get()!==null&&$e(window.location.pathname)}function G(t){let e=ze(t);if(!e)throw new Error("Unable to initialize FramerAuth: project tenantHost is missing");l.updateBaseURL(`https://${e}${$t}`),l.updateAuthMode(Wt(t))}function Wt(t){return t.sessionTransport==="bearer"}function ze(t){if(t.customDomain)return t.customDomain;let e=qt(t);return e?`${t.slug}.${e}`:null}function qt(t){return zt||t.tenantHost||null}function ie(){l.api.fetchBookmarks().then(({data:t})=>{l.data.bookmarks.set(t??{})})}function Jt(){return new J({hasAccess:t=>Me(l,t),isPublicPath:t=>q(t)||$e(t),errorPath:F.errorPath,forceFallbackOverlay:F.router==="overlay",accessDeniedMessage:F.accessDeniedMessage,onError:t=>{console.error("[Router] Error in router:",t)}})}function K(){let t=Jt();return t.checkAccess(window.location.pathname)?(t.start(),V=t,!0):(t.handleAccessDenied(),!1)}function Vt(){let t=l.data.project.get();return t&&ze(t)?(G(t),l.api.fetchProject().then(e=>{e.data?(l.data.project.set(e.data),G(e.data)):oe(e.error)&&ae()}).catch(e=>{console.error("Failed to refresh FramerAuth project:",e)}),l.handleOTTFromURL().then(()=>ne?null:l.auth.getSession()).then(e=>{e&&e.data!==null&&ie()}).catch(e=>{console.error("Failed to refresh FramerAuth session:",e)})):(l.state.projectLoading.set(!0),l.api.fetchProject().then(e=>{if(e.data)return l.data.project.set(e.data),G(e.data),l.state.projectLoading.set(!1),l.handleOTTFromURL().then(()=>l.auth.getSession());if(oe(e.error)){ae();return}l.state.projectLoading.set(!1)}).then(e=>{e&&e.data!==null&&ie()}).catch(e=>{console.error("Failed to initialize FramerAuth in the background:",e),l.state.projectLoading.set(!1)})),K()}async function Gt(){T();let t=l.data.project.get(),e=await l.api.fetchProject();if(e.data)t=e.data,l.data.project.set(t);else{if(oe(e.error))return ae(),!1;if(!t)throw new Error(e.error.message||"Unable to load FramerAuth project!")}G(t),await l.handleOTTFromURL(),(await l.auth.getSession()).data!==null&&ie();let n=K();return n&&A(),n}async function Kt(){l.state.initializing.set(!0);try{(It()?Vt():await Gt())&&window.dispatchEvent(new CustomEvent("framerauth:initialized"))}catch(t){console.error("Failed to initialize FramerAuth:",t),q()||D(window.location.pathname,F.errorPath)?(K(),A()):window.location.replace(F.errorPath),window.dispatchEvent(new CustomEvent("framerauth:initialization-failed",{detail:{error:t}}))}finally{l.state.initializing.set(!1)}}Kt();})();
@@ -1 +1 @@
1
- var he=()=>typeof window<"u",ge=()=>window.location.host.endsWith("framercanvas.com"),w="FramerAuth snippet missing from start of <body>",v=()=>!he()||ge()||!window?.FramerAuth?null:window.FramerAuth;async function Ge(){let t=v();if(!t)return{data:null,error:{message:w}};try{return await t.auth.getSession()}catch(e){return{data:null,error:{message:e instanceof Error?e.message:"Unknown error"}}}}async function Qe(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signUp(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Ye(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signIn(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Xe(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signInOTP(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Ze(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendOTP(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function et(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signOut(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function tt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.updateProfile(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function rt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.updateProfilePicture(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function nt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendForgotPasswordEmail(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function at(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.resetPassword(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function ot(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signInSocial(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function st(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.storeCheckout(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function it(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.storePortal(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function ut(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendVerificationEmail(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}var ye=Object.defineProperty,we=Object.defineProperties,ve=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,Q=(t,e,r)=>e in t?ye(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,O=(t,e)=>{for(var r in e||(e={}))ke.call(e,r)&&Q(t,r,e[r]);if(G)for(var r of G(e))Pe.call(e,r)&&Q(t,r,e[r]);return t},A=(t,e)=>we(t,ve(e)),be=class extends Error{constructor(t,e,r){super(e||t.toString(),{cause:r}),this.status=t,this.statusText=e,this.error=r}},Te=async(t,e)=>{var r,n,o,a,s,c;let i=e||{},u={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:t,options:i,hooks:u};for(let f of e?.plugins||[]){if(f.init){let l=await((r=f.init)==null?void 0:r.call(f,t.toString(),e));i=l.options||i,t=l.url}u.onRequest.push((n=f.hooks)==null?void 0:n.onRequest),u.onResponse.push((o=f.hooks)==null?void 0:o.onResponse),u.onSuccess.push((a=f.hooks)==null?void 0:a.onSuccess),u.onError.push((s=f.hooks)==null?void 0:s.onError),u.onRetry.push((c=f.hooks)==null?void 0:c.onRetry)}return{url:t,options:i,hooks:u}},Y=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(){return this.options.delay}},Se=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(t){return Math.min(this.options.maxDelay,this.options.baseDelay*2**t)}};function xe(t){if(typeof t=="number")return new Y({type:"linear",attempts:t,delay:1e3});switch(t.type){case"linear":return new Y(t);case"exponential":return new Se(t);default:throw new Error("Invalid retry strategy")}}var Oe=async t=>{let e={},r=async n=>typeof n=="function"?await n():n;if(t?.auth){if(t.auth.type==="Bearer"){let n=await r(t.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(t.auth.type==="Basic"){let n=r(t.auth.username),o=r(t.auth.password);if(!n||!o)return e;e.authorization=`Basic ${btoa(`${n}:${o}`)}`}else if(t.auth.type==="Custom"){let n=r(t.auth.value);if(!n)return e;e.authorization=`${r(t.auth.prefix)} ${n}`}}return e},Ae=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ee(t){let e=t.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Ae.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function Re(t){try{return JSON.parse(t),!0}catch{return!1}}function ee(t){if(t===void 0)return!1;let e=typeof t;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(t)?!0:t.buffer?!1:t.constructor&&t.constructor.name==="Object"||typeof t.toJSON=="function"}function X(t){try{return JSON.parse(t)}catch{return t}}function Z(t){return typeof t=="function"}function _e(t){if(t?.customFetchImpl)return t.customFetchImpl;if(typeof globalThis<"u"&&Z(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&Z(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Ue(t){let e=new Headers(t?.headers),r=await Oe(t);for(let[n,o]of Object.entries(r||{}))e.set(n,o);if(!e.has("content-type")){let n=Fe(t?.body);n&&e.set("content-type",n)}return e}function Fe(t){return ee(t)?"application/json":null}function je(t){if(!t?.body)return null;let e=new Headers(t?.headers);if(ee(t.body)&&!e.has("content-type")){for(let[r,n]of Object.entries(t?.body))n instanceof Date&&(t.body[r]=n.toISOString());return JSON.stringify(t.body)}return t.body}function Le(t,e){var r;if(e?.method)return e.method.toUpperCase();if(t.startsWith("@")){let n=(r=t.split("@")[1])==null?void 0:r.split("/")[0];return re.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Ce(t,e){let r;return!t?.signal&&t?.timeout&&(r=setTimeout(()=>e?.abort(),t?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var Ie=class te extends Error{constructor(e,r){super(r||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,te.prototype)}};async function Be(t,e){let r=await t["~standard"].validate(e);if(r.issues)throw new Ie(r.issues);return r.value}var re=["get","post","put","patch","delete"];function $e(t,e){let{baseURL:r,params:n,query:o}=e||{query:{},params:{},baseURL:""},a=t.startsWith("http")?t.split("/").slice(0,3).join("/"):r||"";if(t.startsWith("@")){let l=t.toString().split("@")[1].split("/")[0];re.includes(l)&&(t=t.replace(`@${l}/`,"/"))}a.endsWith("/")||(a+="/");let[s,c]=t.replace(a,"").split("?"),i=new URLSearchParams(c);for(let[l,m]of Object.entries(o||{}))m!=null&&i.set(l,String(m));if(n)if(Array.isArray(n)){let l=s.split("/").filter(m=>m.startsWith(":"));for(let[m,x]of l.entries()){let y=n[m];s=s.replace(x,y)}}else for(let[l,m]of Object.entries(n))s=s.replace(`:${l}`,String(m));s=s.split("/").map(encodeURIComponent).join("/"),s.startsWith("/")&&(s=s.slice(1));let u=i.toString();return u=u.length>0?`?${u}`.replace(/\+/g,"%20"):"",a.startsWith("http")?new URL(`${s}${u}`,a):`${a}${s}${u}`}var M=async(t,e)=>{var r,n,o,a,s,c,i,u;let{hooks:f,url:l,options:m}=await Te(t,e),x=_e(m),y=new AbortController,U=(r=m.signal)!=null?r:y.signal,B=$e(l,m),ue=je(m),le=await Ue(m),ce=Le(l,m),p=A(O({},m),{url:B,headers:le,body:ue,method:ce,signal:U});for(let P of f.onRequest)if(P){let h=await P(p);h instanceof Object&&(p=h)}("pipeTo"in p&&typeof p.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in p||(p.duplex="half"));let{clearTimeout:fe}=Ce(m,y),d=await x(p.url,p);fe();let J={response:d,request:p};for(let P of f.onResponse)if(P){let h=await P(A(O({},J),{response:(o=e?.hookOptions)!=null&&o.cloneResponse?d.clone():d}));h instanceof Response?d=h:h instanceof Object&&(d=h.response)}if(d.ok){if(!(p.method!=="HEAD"))return{data:"",error:null};let h=Ee(d),b={data:"",response:d,request:p};if(h==="json"||h==="text"){let T=await d.text(),pe=await((a=p.jsonParser)!=null?a:X)(T);b.data=pe}else b.data=await d[h]();p?.output&&p.output&&!p.disableValidation&&(b.data=await Be(p.output,b.data));for(let T of f.onSuccess)T&&await T(A(O({},b),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?d.clone():d}));return e?.throw?b.data:{data:b.data,error:null}}let de=(c=e?.jsonParser)!=null?c:X,F=await d.text(),K=Re(F),$=K?await de(F):null,me={response:d,responseText:F,request:p,error:A(O({},$),{status:d.status,statusText:d.statusText})};for(let P of f.onError)P&&await P(A(O({},me),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?d.clone():d}));if(e?.retry){let P=xe(e.retry),h=(u=e.retryAttempt)!=null?u:0;if(await P.shouldAttemptRetry(h,d)){for(let T of f.onRetry)T&&await T(J);let b=P.getDelay(h);return await new Promise(T=>setTimeout(T,b)),await M(t,A(O({},e),{retryAttempt:h+1}))}}if(e?.throw)throw new be(d.status,d.statusText,K?$:F);return{data:null,error:A(O({},$),{status:d.status,statusText:d.statusText})}};function q(t,e,r){let n=new Set(e).add(void 0);return t.listen((o,a,s)=>{n.has(s)&&r(o,a,s)})}import{useCallback as Me,useRef as qe,useSyncExternalStore as He}from"react";var H=(t,e)=>r=>{t.current!==r&&(t.current=r,e())};function S(t,{keys:e,deps:r=[t,e]}={}){let n=qe();n.current=t.get();let o=Me(s=>(H(n,s)(t.value),e?.length>0?q(t,e,H(n,s)):t.listen(H(n,s))),r),a=()=>n.current;return He(o,a,a)}import{useState as ne}from"react";var Ne="https://core.framerauth.com/v2",R=()=>typeof window<"u",j=()=>window.location.host.endsWith("framercanvas.com"),We=()=>{let t=Object.keys(window.parent);for(let e=t.length-1;e>=0;e--)try{let r=new URLSearchParams(window.parent[t[e]].location.search).get("siteId");if(r)return r}catch{}},Ve=async()=>{let t=We()||"";return await M(`${Ne}/public/project/config`,{headers:{"x-framer-project-id":t}})};function St(){if(!R()||j()||!window?.FramerAuth)return{initializing:!0,setInitializing:()=>{}};let t=window.FramerAuth;return{initializing:S(t.state.initializing)}}function E(){if(!R()||j()||!window?.FramerAuth)return{session:null,loading:!1,setSession:()=>{},setLoading:()=>{}};let t=window.FramerAuth,e=S(t.data.session),r=S(t.state.sessionLoading);return{session:e,loading:r,setSession:a=>t.data.session.set(a),setLoading:a=>t.state.sessionLoading.set(a)}}function L(){if(!R()||j()||!window?.FramerAuth)return{user:null,loading:!1,setUser:()=>{},setLoading:()=>{}};let t=window.FramerAuth,e=S(t.data.user),r=S(t.state.userLoading),n=a=>t.data.user.set(a),o=a=>t.state.userLoading.set(a);return e&&!Object.prototype.hasOwnProperty.call(e,"tags")&&(e.tags=[]),{user:e,loading:r,setUser:n,setLoading:o}}function xt(){let[t,e]=ne(null),[r,n]=ne(!1);if(!R())return{project:null,loading:!1,setProject:()=>{},setLoading:()=>{},fetchProject:async()=>({data:null,error:{message:"Browser not available"}})};if(!window?.FramerAuth){let l=y=>e(y),m=y=>n(y);return{project:t,loading:r,setProject:l,setLoading:m,fetchProject:async()=>{m(!0);let y=await Ve();return y.data&&l(y.data),m(!1),y}}}let a=window.FramerAuth,s=S(a.data.project),c=S(a.state.projectLoading),i=l=>a.data.project.set(l),u=l=>a.state.projectLoading.set(l);return{project:s,loading:c,setProject:i,setLoading:u,fetchProject:async()=>{u(!0);let l=await a.api.fetchProject();return l.data&&i(l.data),u(!1),l}}}function C(t){if(!R()||j()||!window?.FramerAuth)return{bookmarks:null,loading:!1,createBookmark:a=>{},deleteBookmark:a=>{},setLoading:()=>{}};let e=window.FramerAuth;return{bookmarks:S(e.data.bookmarks,{keys:t}),createBookmark:a=>{let c={...e.data.bookmarks.get(),[a]:!0};e.data.bookmarks.set(c)},deleteBookmark:a=>{let c={...e.data.bookmarks.get()};delete c[a],e.data.bookmarks.set(c)}}}import{useEffect as V,useMemo as k,useRef as D}from"react";import{useRouter as De,RenderTarget as oe,inferInitialRouteFromPath as ze}from"framer";function ae(t){return t.toLowerCase()}function N(t,e="any"){return t==="all"||t==="any"?t:e}function _(t){return t!==null}function I(t,e,r="all"){if(!_(t))return!1;if(e.length===0)return t.tags.length>0;let n=t.tags.map(a=>ae(a.name)),o=e.map(ae);return r==="any"?o.some(a=>n.includes(a)):o.every(a=>n.includes(a))}import{jsx as g}from"react/jsx-runtime";typeof window<"u"&&window.FramerAuth&&console.log("FramerAuth SDK (React): 2.1.8");function se(t){let e=t;return typeof e?.displayName=="string"&&e.displayName.length>0&&typeof e?.defaultProps=="object"&&e.defaultProps!==null}function ie(t,e){return e?t.parentElement:t}function W(t){let e;if(typeof t=="string")e=t.split(",");else if(Array.isArray(t))e=t.filter(n=>typeof n=="string");else return null;let r=e.map(n=>n.trim()).filter(Boolean);return r.length>0?r:null}function z(t,e){return e!==void 0?typeof e=="string"||Array.isArray(e)||e===null?{tags:W(e),operator:"any"}:{tags:W(e.tags),operator:N(e.require)}:{tags:W(t?.tags),operator:N(t?.require)}}function Lt(t){return e=>{let{session:r}=E();return r?g(t,{...e}):null}}function Ct(t){return e=>{let{session:r}=E();return r?null:g(t,{...e})}}function It(t){return e=>{let{session:r}=E(),n=r?null:e?.variant;return g(t,{...e,variant:n})}}function Bt(t,e){let r=se(t);return n=>{let{user:o}=L(),a=D(null),{tags:s,operator:c}=k(()=>z(n,e),[n?.tags,n?.require,e]),i=k(()=>_(o)?s?I(o,s,c):o.tags.length>0:!1,[o,s,c]);return V(()=>{if(a.current){let f=ie(a.current,r);if(!f)return;i?f.style.display="":f.style.display="none"}},[a.current,i]),k(()=>i!==!0?g("div",{ref:a}):g(t,{ref:a,...n}),[n,i,void 0])}}function $t(t,e){let r=se(t);return n=>{let{user:o}=L(),a=D(null),{tags:s,operator:c}=k(()=>z(n,e),[n?.tags,n?.require,e]),i=k(()=>_(o)?s?I(o,s,c):o.tags.length>0:!1,[o,s,c]);return V(()=>{if(a.current){let f=ie(a.current,r);if(!f)return;i?f.style.display="none":f.style.display=""}},[a.current,i]),k(()=>i===!0?g("div",{ref:a}):g(t,{ref:a,...n}),[n,i,void 0])}}function Mt(t,e){return r=>{let{user:n}=L(),o=r?.variant,{tags:a,operator:s}=z(r,e);if(!a){let u=null;return(!_(n)||n.tags.length===0)&&(u=o),g(t,{...r,variant:u})}let i=I(n,a,s)?null:o;return g(t,{...r,variant:i})}}function qt(t,e="saved-for-later"){return r=>{let{bookmarks:n}=C(),a=k(()=>n?Object.keys(n).some(c=>c.startsWith(`${e}:`)):!1,[n])?null:"Empty State";return g(t,{...r,variant:a})}}function Ht(t,e="saved-for-later"){return r=>{let{bookmarks:n}=C(),o=D(null),a=k(()=>`${e}:${r?.slug}`,[r]),s=k(()=>Je()?!0:n?a in n:!1,[n?.[a],a]);return V(()=>{if(o.current){let i=o.current.parentElement;if(!i)return;s?i.style.display="":i.style.display="none"}},[o.current,s]),k(()=>s?g(t,{ref:o,...r}):g("div",{ref:o}),[r,s,void 0])}}function Nt(t,e="saved-for-later"){return r=>{let n=De(),{session:o}=E(),{bookmarks:a,createBookmark:s,deleteBookmark:c}=C([`${e}:${r?.slug}`]),i=k(()=>`${e}:${r?.slug}`,[r]),u=k(()=>a?i in a:!1,[a?.[i],i]),f=async m=>{try{if(u)c(i),window?.FramerAuth.auth.deleteBookmark({id:r?.slug,bookmark_type:e});else if(s(i),window?.FramerAuth.auth.createBookmark({id:r?.slug,bookmark_type:e}),r?.link){let[x,y]=r.link.split("#"),{routeId:U,pathVariables:B}=ze(n.routes,x);U&&n.navigate(U,y,B)}}catch(x){console.error(x)}},l=k(()=>u?r?.variant:void 0,[u,r?.variant]);return o?g(t,{...r,variant:l,onClick:f}):null}}function Wt(t){return e=>g(t,{...e,onClick:async n=>{window?.FramerAuth.auth.signInSocial({provider:"github",callbackURL:window.location.origin+"/account"})}})}function Vt(t,e){return r=>{let{session:n}=E();return n?g(t,{...r,onClick:async a=>{window?.FramerAuth.auth.signOut({redirectTo:e.redirectTo})}}):null}}function Je(){return oe.current()===oe.canvas}export{Wt as buttonSignInSocial,Vt as buttonSignOut,Ge as getSession,Je as isCanvas,at as resetPassword,nt as sendForgotPasswordEmail,Ze as sendOTP,ut as sendVerificationEmail,Lt as showIfSignedIn,Ct as showIfSignedOut,Bt as showIfWithTag,$t as showIfWithoutTag,Ye as signIn,Xe as signInOTP,ot as signInSocial,et as signOut,Qe as signUp,st as storeCheckout,it as storePortal,It as toggleVariant,Mt as toggleVariantIfWithTag,tt as updateProfile,rt as updateProfilePicture,C as useBookmarks,St as useIsInitializing,xt as useProject,E as useSession,L as useUser,qt as withBookmarks,Ht as withIsBookmarked,Nt as withToggleBookmark};
1
+ var he=()=>typeof window<"u",ge=()=>window.location.host.endsWith("framercanvas.com"),w="FramerAuth snippet missing from start of <body>",v=()=>!he()||ge()||!window?.FramerAuth?null:window.FramerAuth;async function Ge(){let t=v();if(!t)return{data:null,error:{message:w}};try{return await t.auth.getSession()}catch(e){return{data:null,error:{message:e instanceof Error?e.message:"Unknown error"}}}}async function Qe(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signUp(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Ye(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signIn(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Xe(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signInOTP(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function Ze(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendOTP(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function et(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signOut(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function tt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.updateProfile(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function rt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.updateProfilePicture(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function nt(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendForgotPasswordEmail(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function at(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.resetPassword(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function ot(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.signInSocial(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function st(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.storeCheckout(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function it(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.storePortal(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}async function ut(t){let e=v();if(!e)return{data:null,error:{message:w}};try{return await e.auth.sendVerificationEmail(t)}catch(r){return{data:null,error:{message:r instanceof Error?r.message:"Unknown error"}}}}var ye=Object.defineProperty,we=Object.defineProperties,ve=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,Q=(t,e,r)=>e in t?ye(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,O=(t,e)=>{for(var r in e||(e={}))ke.call(e,r)&&Q(t,r,e[r]);if(G)for(var r of G(e))Pe.call(e,r)&&Q(t,r,e[r]);return t},A=(t,e)=>we(t,ve(e)),be=class extends Error{constructor(t,e,r){super(e||t.toString(),{cause:r}),this.status=t,this.statusText=e,this.error=r}},Te=async(t,e)=>{var r,n,o,a,s,c;let i=e||{},u={onRequest:[e?.onRequest],onResponse:[e?.onResponse],onSuccess:[e?.onSuccess],onError:[e?.onError],onRetry:[e?.onRetry]};if(!e||!e?.plugins)return{url:t,options:i,hooks:u};for(let f of e?.plugins||[]){if(f.init){let l=await((r=f.init)==null?void 0:r.call(f,t.toString(),e));i=l.options||i,t=l.url}u.onRequest.push((n=f.hooks)==null?void 0:n.onRequest),u.onResponse.push((o=f.hooks)==null?void 0:o.onResponse),u.onSuccess.push((a=f.hooks)==null?void 0:a.onSuccess),u.onError.push((s=f.hooks)==null?void 0:s.onError),u.onRetry.push((c=f.hooks)==null?void 0:c.onRetry)}return{url:t,options:i,hooks:u}},Y=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(){return this.options.delay}},Se=class{constructor(t){this.options=t}shouldAttemptRetry(t,e){return this.options.shouldRetry?Promise.resolve(t<this.options.attempts&&this.options.shouldRetry(e)):Promise.resolve(t<this.options.attempts)}getDelay(t){return Math.min(this.options.maxDelay,this.options.baseDelay*2**t)}};function xe(t){if(typeof t=="number")return new Y({type:"linear",attempts:t,delay:1e3});switch(t.type){case"linear":return new Y(t);case"exponential":return new Se(t);default:throw new Error("Invalid retry strategy")}}var Oe=async t=>{let e={},r=async n=>typeof n=="function"?await n():n;if(t?.auth){if(t.auth.type==="Bearer"){let n=await r(t.auth.token);if(!n)return e;e.authorization=`Bearer ${n}`}else if(t.auth.type==="Basic"){let n=r(t.auth.username),o=r(t.auth.password);if(!n||!o)return e;e.authorization=`Basic ${btoa(`${n}:${o}`)}`}else if(t.auth.type==="Custom"){let n=r(t.auth.value);if(!n)return e;e.authorization=`${r(t.auth.prefix)} ${n}`}}return e},Ae=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ee(t){let e=t.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!e)return"json";let n=e.split(";").shift()||"";return Ae.test(n)?"json":r.has(n)||n.startsWith("text/")?"text":"blob"}function Re(t){try{return JSON.parse(t),!0}catch{return!1}}function ee(t){if(t===void 0)return!1;let e=typeof t;return e==="string"||e==="number"||e==="boolean"||e===null?!0:e!=="object"?!1:Array.isArray(t)?!0:t.buffer?!1:t.constructor&&t.constructor.name==="Object"||typeof t.toJSON=="function"}function X(t){try{return JSON.parse(t)}catch{return t}}function Z(t){return typeof t=="function"}function _e(t){if(t?.customFetchImpl)return t.customFetchImpl;if(typeof globalThis<"u"&&Z(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&Z(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function Ue(t){let e=new Headers(t?.headers),r=await Oe(t);for(let[n,o]of Object.entries(r||{}))e.set(n,o);if(!e.has("content-type")){let n=Fe(t?.body);n&&e.set("content-type",n)}return e}function Fe(t){return ee(t)?"application/json":null}function je(t){if(!t?.body)return null;let e=new Headers(t?.headers);if(ee(t.body)&&!e.has("content-type")){for(let[r,n]of Object.entries(t?.body))n instanceof Date&&(t.body[r]=n.toISOString());return JSON.stringify(t.body)}return t.body}function Le(t,e){var r;if(e?.method)return e.method.toUpperCase();if(t.startsWith("@")){let n=(r=t.split("@")[1])==null?void 0:r.split("/")[0];return re.includes(n)?n.toUpperCase():e?.body?"POST":"GET"}return e?.body?"POST":"GET"}function Ce(t,e){let r;return!t?.signal&&t?.timeout&&(r=setTimeout(()=>e?.abort(),t?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var Ie=class te extends Error{constructor(e,r){super(r||JSON.stringify(e,null,2)),this.issues=e,Object.setPrototypeOf(this,te.prototype)}};async function Be(t,e){let r=await t["~standard"].validate(e);if(r.issues)throw new Ie(r.issues);return r.value}var re=["get","post","put","patch","delete"];function $e(t,e){let{baseURL:r,params:n,query:o}=e||{query:{},params:{},baseURL:""},a=t.startsWith("http")?t.split("/").slice(0,3).join("/"):r||"";if(t.startsWith("@")){let l=t.toString().split("@")[1].split("/")[0];re.includes(l)&&(t=t.replace(`@${l}/`,"/"))}a.endsWith("/")||(a+="/");let[s,c]=t.replace(a,"").split("?"),i=new URLSearchParams(c);for(let[l,m]of Object.entries(o||{}))m!=null&&i.set(l,String(m));if(n)if(Array.isArray(n)){let l=s.split("/").filter(m=>m.startsWith(":"));for(let[m,x]of l.entries()){let y=n[m];s=s.replace(x,y)}}else for(let[l,m]of Object.entries(n))s=s.replace(`:${l}`,String(m));s=s.split("/").map(encodeURIComponent).join("/"),s.startsWith("/")&&(s=s.slice(1));let u=i.toString();return u=u.length>0?`?${u}`.replace(/\+/g,"%20"):"",a.startsWith("http")?new URL(`${s}${u}`,a):`${a}${s}${u}`}var M=async(t,e)=>{var r,n,o,a,s,c,i,u;let{hooks:f,url:l,options:m}=await Te(t,e),x=_e(m),y=new AbortController,U=(r=m.signal)!=null?r:y.signal,B=$e(l,m),ue=je(m),le=await Ue(m),ce=Le(l,m),p=A(O({},m),{url:B,headers:le,body:ue,method:ce,signal:U});for(let P of f.onRequest)if(P){let h=await P(p);h instanceof Object&&(p=h)}("pipeTo"in p&&typeof p.pipeTo=="function"||typeof((n=e?.body)==null?void 0:n.pipe)=="function")&&("duplex"in p||(p.duplex="half"));let{clearTimeout:fe}=Ce(m,y),d=await x(p.url,p);fe();let J={response:d,request:p};for(let P of f.onResponse)if(P){let h=await P(A(O({},J),{response:(o=e?.hookOptions)!=null&&o.cloneResponse?d.clone():d}));h instanceof Response?d=h:h instanceof Object&&(d=h.response)}if(d.ok){if(!(p.method!=="HEAD"))return{data:"",error:null};let h=Ee(d),b={data:"",response:d,request:p};if(h==="json"||h==="text"){let T=await d.text(),pe=await((a=p.jsonParser)!=null?a:X)(T);b.data=pe}else b.data=await d[h]();p?.output&&p.output&&!p.disableValidation&&(b.data=await Be(p.output,b.data));for(let T of f.onSuccess)T&&await T(A(O({},b),{response:(s=e?.hookOptions)!=null&&s.cloneResponse?d.clone():d}));return e?.throw?b.data:{data:b.data,error:null}}let de=(c=e?.jsonParser)!=null?c:X,F=await d.text(),K=Re(F),$=K?await de(F):null,me={response:d,responseText:F,request:p,error:A(O({},$),{status:d.status,statusText:d.statusText})};for(let P of f.onError)P&&await P(A(O({},me),{response:(i=e?.hookOptions)!=null&&i.cloneResponse?d.clone():d}));if(e?.retry){let P=xe(e.retry),h=(u=e.retryAttempt)!=null?u:0;if(await P.shouldAttemptRetry(h,d)){for(let T of f.onRetry)T&&await T(J);let b=P.getDelay(h);return await new Promise(T=>setTimeout(T,b)),await M(t,A(O({},e),{retryAttempt:h+1}))}}if(e?.throw)throw new be(d.status,d.statusText,K?$:F);return{data:null,error:A(O({},$),{status:d.status,statusText:d.statusText})}};function q(t,e,r){let n=new Set(e).add(void 0);return t.listen((o,a,s)=>{n.has(s)&&r(o,a,s)})}import{useCallback as Me,useRef as qe,useSyncExternalStore as He}from"react";var H=(t,e)=>r=>{t.current!==r&&(t.current=r,e())};function S(t,{keys:e,deps:r=[t,e]}={}){let n=qe();n.current=t.get();let o=Me(s=>(H(n,s)(t.value),e?.length>0?q(t,e,H(n,s)):t.listen(H(n,s))),r),a=()=>n.current;return He(o,a,a)}import{useState as ne}from"react";var Ne="https://core.framerauth.com/v2",R=()=>typeof window<"u",j=()=>window.location.host.endsWith("framercanvas.com"),We=()=>{let t=Object.keys(window.parent);for(let e=t.length-1;e>=0;e--)try{let r=new URLSearchParams(window.parent[t[e]].location.search).get("siteId");if(r)return r}catch{}},Ve=async()=>{let t=We()||"";return await M(`${Ne}/public/project/config`,{headers:{"x-framer-project-id":t}})};function St(){if(!R()||j()||!window?.FramerAuth)return{initializing:!0,setInitializing:()=>{}};let t=window.FramerAuth;return{initializing:S(t.state.initializing)}}function E(){if(!R()||j()||!window?.FramerAuth)return{session:null,loading:!1,setSession:()=>{},setLoading:()=>{}};let t=window.FramerAuth,e=S(t.data.session),r=S(t.state.sessionLoading);return{session:e,loading:r,setSession:a=>t.data.session.set(a),setLoading:a=>t.state.sessionLoading.set(a)}}function L(){if(!R()||j()||!window?.FramerAuth)return{user:null,loading:!1,setUser:()=>{},setLoading:()=>{}};let t=window.FramerAuth,e=S(t.data.user),r=S(t.state.userLoading),n=a=>t.data.user.set(a),o=a=>t.state.userLoading.set(a);return e&&!Object.prototype.hasOwnProperty.call(e,"tags")&&(e.tags=[]),{user:e,loading:r,setUser:n,setLoading:o}}function xt(){let[t,e]=ne(null),[r,n]=ne(!1);if(!R())return{project:null,loading:!1,setProject:()=>{},setLoading:()=>{},fetchProject:async()=>({data:null,error:{message:"Browser not available"}})};if(!window?.FramerAuth){let l=y=>e(y),m=y=>n(y);return{project:t,loading:r,setProject:l,setLoading:m,fetchProject:async()=>{m(!0);let y=await Ve();return y.data&&l(y.data),m(!1),y}}}let a=window.FramerAuth,s=S(a.data.project),c=S(a.state.projectLoading),i=l=>a.data.project.set(l),u=l=>a.state.projectLoading.set(l);return{project:s,loading:c,setProject:i,setLoading:u,fetchProject:async()=>{u(!0);let l=await a.api.fetchProject();return l.data&&i(l.data),u(!1),l}}}function C(t){if(!R()||j()||!window?.FramerAuth)return{bookmarks:null,loading:!1,createBookmark:a=>{},deleteBookmark:a=>{},setLoading:()=>{}};let e=window.FramerAuth;return{bookmarks:S(e.data.bookmarks,{keys:t}),createBookmark:a=>{let c={...e.data.bookmarks.get(),[a]:!0};e.data.bookmarks.set(c)},deleteBookmark:a=>{let c={...e.data.bookmarks.get()};delete c[a],e.data.bookmarks.set(c)}}}import{useEffect as V,useMemo as k,useRef as D}from"react";import{useRouter as De,RenderTarget as oe,inferInitialRouteFromPath as ze}from"framer";function ae(t){return t.toLowerCase()}function N(t,e="any"){return t==="all"||t==="any"?t:e}function _(t){return t!==null}function I(t,e,r="all"){if(!_(t))return!1;if(e.length===0)return t.tags.length>0;let n=t.tags.map(a=>ae(a.name)),o=e.map(ae);return r==="any"?o.some(a=>n.includes(a)):o.every(a=>n.includes(a))}import{jsx as g}from"react/jsx-runtime";typeof window<"u"&&window.FramerAuth&&console.log("FramerAuth SDK (React): 2.1.10");function se(t){let e=t;return typeof e?.displayName=="string"&&e.displayName.length>0&&typeof e?.defaultProps=="object"&&e.defaultProps!==null}function ie(t,e){return e?t.parentElement:t}function W(t){let e;if(typeof t=="string")e=t.split(",");else if(Array.isArray(t))e=t.filter(n=>typeof n=="string");else return null;let r=e.map(n=>n.trim()).filter(Boolean);return r.length>0?r:null}function z(t,e){return e!==void 0?typeof e=="string"||Array.isArray(e)||e===null?{tags:W(e),operator:"any"}:{tags:W(e.tags),operator:N(e.require)}:{tags:W(t?.tags),operator:N(t?.require)}}function Lt(t){return e=>{let{session:r}=E();return r?g(t,{...e}):null}}function Ct(t){return e=>{let{session:r}=E();return r?null:g(t,{...e})}}function It(t){return e=>{let{session:r}=E(),n=r?null:e?.variant;return g(t,{...e,variant:n})}}function Bt(t,e){let r=se(t);return n=>{let{user:o}=L(),a=D(null),{tags:s,operator:c}=k(()=>z(n,e),[n?.tags,n?.require,e]),i=k(()=>_(o)?s?I(o,s,c):o.tags.length>0:!1,[o,s,c]);return V(()=>{if(a.current){let f=ie(a.current,r);if(!f)return;i?f.style.display="":f.style.display="none"}},[a.current,i]),k(()=>i!==!0?g("div",{ref:a}):g(t,{ref:a,...n}),[n,i,void 0])}}function $t(t,e){let r=se(t);return n=>{let{user:o}=L(),a=D(null),{tags:s,operator:c}=k(()=>z(n,e),[n?.tags,n?.require,e]),i=k(()=>_(o)?s?I(o,s,c):o.tags.length>0:!1,[o,s,c]);return V(()=>{if(a.current){let f=ie(a.current,r);if(!f)return;i?f.style.display="none":f.style.display=""}},[a.current,i]),k(()=>i===!0?g("div",{ref:a}):g(t,{ref:a,...n}),[n,i,void 0])}}function Mt(t,e){return r=>{let{user:n}=L(),o=r?.variant,{tags:a,operator:s}=z(r,e);if(!a){let u=null;return(!_(n)||n.tags.length===0)&&(u=o),g(t,{...r,variant:u})}let i=I(n,a,s)?null:o;return g(t,{...r,variant:i})}}function qt(t,e="saved-for-later"){return r=>{let{bookmarks:n}=C(),a=k(()=>n?Object.keys(n).some(c=>c.startsWith(`${e}:`)):!1,[n])?null:"Empty State";return g(t,{...r,variant:a})}}function Ht(t,e="saved-for-later"){return r=>{let{bookmarks:n}=C(),o=D(null),a=k(()=>`${e}:${r?.slug}`,[r]),s=k(()=>Je()?!0:n?a in n:!1,[n?.[a],a]);return V(()=>{if(o.current){let i=o.current.parentElement;if(!i)return;s?i.style.display="":i.style.display="none"}},[o.current,s]),k(()=>s?g(t,{ref:o,...r}):g("div",{ref:o}),[r,s,void 0])}}function Nt(t,e="saved-for-later"){return r=>{let n=De(),{session:o}=E(),{bookmarks:a,createBookmark:s,deleteBookmark:c}=C([`${e}:${r?.slug}`]),i=k(()=>`${e}:${r?.slug}`,[r]),u=k(()=>a?i in a:!1,[a?.[i],i]),f=async m=>{try{if(u)c(i),window?.FramerAuth.auth.deleteBookmark({id:r?.slug,bookmark_type:e});else if(s(i),window?.FramerAuth.auth.createBookmark({id:r?.slug,bookmark_type:e}),r?.link){let[x,y]=r.link.split("#"),{routeId:U,pathVariables:B}=ze(n.routes,x);U&&n.navigate(U,y,B)}}catch(x){console.error(x)}},l=k(()=>u?r?.variant:void 0,[u,r?.variant]);return o?g(t,{...r,variant:l,onClick:f}):null}}function Wt(t){return e=>g(t,{...e,onClick:async n=>{window?.FramerAuth.auth.signInSocial({provider:"github",callbackURL:window.location.origin+"/account"})}})}function Vt(t,e){return r=>{let{session:n}=E();return n?g(t,{...r,onClick:async a=>{window?.FramerAuth.auth.signOut({redirectTo:e.redirectTo})}}):null}}function Je(){return oe.current()===oe.canvas}export{Wt as buttonSignInSocial,Vt as buttonSignOut,Ge as getSession,Je as isCanvas,at as resetPassword,nt as sendForgotPasswordEmail,Ze as sendOTP,ut as sendVerificationEmail,Lt as showIfSignedIn,Ct as showIfSignedOut,Bt as showIfWithTag,$t as showIfWithoutTag,Ye as signIn,Xe as signInOTP,ot as signInSocial,et as signOut,Qe as signUp,st as storeCheckout,it as storePortal,It as toggleVariant,Mt as toggleVariantIfWithTag,tt as updateProfile,rt as updateProfilePicture,C as useBookmarks,St as useIsInitializing,xt as useProject,E as useSession,L as useUser,qt as withBookmarks,Ht as withIsBookmarked,Nt as withToggleBookmark};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@framerauth/sdk",
3
3
  "license": "MIT",
4
- "version": "2.1.8",
4
+ "version": "2.1.10",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",