{"version":3,"file":"UsePAData.DlnIAGME.mjs","names":["useState","useCallback"],"sources":["https:/framerusercontent.com/modules/Q0tUJYY4S9z0OyDyPJQ6/GzKw5CRqVOcWeFbis3jd/UsePAData.js"],"sourcesContent":["// Framer Code — shared data hook\n// Raison d'Être · Ode by Muno\n//\n// Code → New → Code File, named `usePAData`. Import it from any component:\n//\n//     import { usePAData } from \"./usePAData.tsx\"\n//\n// Handles the parts that are identical on every read page: getting the\n// FrameAuth token, calling the Edge Function, loading and error states, and\n// refetching when the guest returns to the tab.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useCallback,useEffect,useState}from\"react\";import{getAuthToken}from\"https://framerusercontent.com/modules/mfWVTR6nZjP9RcW8OnA4/nKFfdSpNjI4pm0uIQ9mH/paAuth.js\";const BASE=\"https://djrbsgllezbwnnwxfrrb.supabase.co/functions/v1\";/**\n * @param path   endpoint path, e.g. \"/responses?scope=me\" or \"/itinerary\"\n * @param opts   refetchOnFocus: re-read when the guest comes back to the tab.\n *               Default true — a guest returning from Stripe or from a survey\n *               should see fresh state without a manual refresh.\n */export function usePAData(path,opts={}){const{refetchOnFocus=true}=opts;const[data,setData]=useState(null);const[loading,setLoading]=useState(true);const[error,setError]=useState(null);const[tick,setTick]=useState(0);const reload=useCallback(()=>setTick(t=>t+1),[]);useEffect(()=>{let cancelled=false;async function run(){try{const token=await getAuthToken();if(!token)throw new Error(\"no session\");const res=await fetch(`${BASE}${path}`,{headers:{Authorization:`Bearer ${token}`}});if(!res.ok){// 403 carries a reason worth surfacing (not invited,\n// cohort not open yet). Everything else is a status code.\nconst body=await res.json().catch(()=>({}));throw new Error(body.error??String(res.status));}const json=await res.json();if(!cancelled){setData(json);setError(null);}}catch(e){console.error(\"[usePAData]\",path,e);if(!cancelled)setError(String(e instanceof Error?e.message:e));}finally{if(!cancelled)setLoading(false);}}run();return()=>{cancelled=true;};},[path,tick]);useEffect(()=>{if(!refetchOnFocus)return;const onFocus=()=>reload();window.addEventListener(\"focus\",onFocus);return()=>window.removeEventListener(\"focus\",onFocus);},[refetchOnFocus,reload]);return{data,loading,error,reload};}/**\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 200\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export function ProgressSummary(){const{data,loading,error}=usePAData(\"/responses?scope=me\");// Always handle all three states. A component that only renders the happy\n// path shows a blank box when anything goes wrong, which is unhelpful for\n// a guest and impossible to debug from a screenshot.\nif(loading)return /*#__PURE__*/_jsx(\"p\",{style:s.muted,children:\"Loading…\"});if(error)return /*#__PURE__*/_jsx(\"p\",{style:s.muted,children:\"We could not load your progress.\"});if(!data)return null;const pct=Math.round(data.completion.overall*100);return /*#__PURE__*/_jsxs(\"div\",{style:s.wrap,children:[/*#__PURE__*/_jsx(\"span\",{style:s.label,children:\"Your archive\"}),/*#__PURE__*/_jsx(\"div\",{style:s.track,children:/*#__PURE__*/_jsx(\"div\",{style:{...s.fill,width:`${pct}%`}})}),/*#__PURE__*/_jsxs(\"span\",{style:s.pct,children:[pct,\"% complete\"]})]});}const s={wrap:{display:\"flex\",flexDirection:\"column\",gap:10,width:\"100%\"},label:{fontSize:11,letterSpacing:\"0.18em\",textTransform:\"uppercase\",color:\"#8a8a8a\"},track:{height:2,backgroundColor:\"#2a2a2a\",position:\"relative\"},fill:{position:\"absolute\",inset:\"0 auto 0 0\",backgroundColor:\"#B8763A\",transition:\"width .4s ease\"},pct:{fontSize:13,color:\"#8a8a8a\"},muted:{color:\"#6f6f6f\",fontSize:14}};\nexport const __FramerMetadata__ = {\"exports\":{\"ProgressSummary\":{\"type\":\"reactComponent\",\"name\":\"ProgressSummary\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"600\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicHeight\":\"200\"}},\"PAState\":{\"type\":\"tsType\",\"annotations\":{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