1import{s as l,j as e}from"./index-v5JK2qZg.js";import{c as s}from"./react-vendor-fTGEjNcT.js";import{L as ne,m as ae}from"./Login-Dc60d5rq.js";import"./supabase-CbCDwtWw.js";const re=[{id:"starter",price:"$5",credits:50,perCheck:"0.10"},{id:"pro",price:"$10",credits:120,perCheck:"0.08"},{id:"power",price:"$20",credits:400,perCheck:"0.05"}],ie=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:"shrink-0 text-gray-700",children:e.jsx("path",{d:"M4.29628 1.3335C3.60492 1.51003 2.2222 2.2338 2.2222 3.71665C2.2222 5.40212 2.00783 7.52548 0.994314 8.09583C0.871882 8.16473 0.826808 8.35495 0.92635 8.45408C1.31482 8.84097 1.75263 9.42731 1.96294 10.0717C2.2222 10.8661 2.2222 15.3676 5.33331 14.5732M12.2222 1.3335C12.8148 1.51003 14 2.2338 14 3.71665C14 5.40269 14.1838 7.52692 15.0533 8.09641C15.1639 8.16883 15.2091 8.34076 15.1224 8.44054C14.7866 8.82722 14.4046 9.41975 14.2222 10.0717C14 10.8661 14 15.3676 11.3333 14.5732M8.38093 4.66683L7.95633 8.01058M7.95633 8.01058L7.95196 8.04498M7.95633 8.01058L7.93994 8.03236M7.95633 8.01058L9.3968 6.0954M7.95196 8.04498L7.94556 8.0954M7.95196 8.04498L7.93994 8.03236M7.95196 8.04498L7.99998 8.0954M7.94556 8.0954L7.61903 10.6668M7.94556 8.0954H7.89253M7.94556 8.0954H7.99998M5.33331 8.0954H7.89253M7.89253 8.0954L6.60315 9.80969M7.89253 8.0954L7.93994 8.03236M7.99998 8.0954H10.6666M7.99998 8.0954L9.90474 10.0954M6.09522 6.0954L7.93994 8.03236",stroke:"currentColor",strokeLinecap:"round"})}),le=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:"shrink-0 text-gray-700",children:e.jsx("path",{d:"M15 12.6324V4.12387M7.33774 14.924V5.05228M1 2.84906V2.80208C1 2.77769 1.01654 2.75641 1.04017 2.75042L7.9401 1.00163C7.95042 0.999013 7.9613 0.999557 7.97131 1.00319L14.8136 3.48667C14.8646 3.50519 14.8585 3.57934 14.8051 3.58917L7.39432 4.95347M1 2.84906L1.03931 12.7159C1.03982 12.844 1.11711 12.9567 1.22994 12.9939L1.24014 12.9973L1.64606 13.1314L1.90302 13.2163L2.15998 13.3012L2.6516 13.4637L3.09702 13.6108L3.45964 13.7307L3.79094 13.8401L4.19602 13.974L4.53515 14.086L4.92486 14.2148L5.33611 14.3507L5.60456 14.4393L5.87301 14.528L6.2033 14.6372L6.48691 14.7309L6.77052 14.8246L7.05413 14.9183L7.26313 14.9873C7.31187 15.0035 7.36381 15.0042 7.41293 14.9895L14.857 12.7625M1 2.84906L1.24014 2.9281L1.64606 3.06169L1.90302 3.14625L2.15998 3.23082L2.6516 3.39262L3.09702 3.53921L3.45964 3.65854L3.79094 3.76758L4.19602 3.90089L4.53515 4.0125L4.92486 4.14076L5.33611 4.2761L5.60456 4.36445L5.87301 4.4528L6.2033 4.5615L6.50106 4.65949L6.79881 4.75748L7.09656 4.85548L7.39432 4.95347M7.39432 4.95347L7.33774 4.96388M7.39432 4.95347L7.42764 4.96444M9.63132 12.3347L13.2678 11.1416M10.1682 10.545L12.3158 9.94844M9.63132 8.75531L13.3896 7.56219M9.63132 6.96563L13.2678 5.7725",stroke:"currentColor",strokeLinecap:"round"})}),oe=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:"shrink-0 text-gray-700",children:e.jsx("path",{d:"M4.30143 6.1947C4.36782 6.18539 5.97492 5.98282 5.90798 4.57028C5.90183 4.4405 5.8847 4.32244 5.85807 4.21542M4.30143 6.1947C5.1823 6.1397 5.62991 5.81366 5.83023 5.42291M4.30143 6.1947C4.1948
16 6.20965 4.08495 6.20846 3.97622 6.19219M5.85807 4.21542C5.82474 4.08143 5.77652 3.96474 5.71633 3.86401M5.85807 4.21542C5.97808 4.5295 6.0409 5.01199 5.83023 5.42291M5.71633 3.86401C5.22293 3.0382 3.92533 3.28491 3.43122 3.86401C3.23733 4.09144 2.83099 4.6682 3.02901 5.38916C3.15314 5.84109 3.55587 6.1293 3.97622 6.19219M5.71633 3.86401C5.90408 4.11322 6.17648 4.69683 5.9436 5.22609M5.83023 5.42291C5.87684 5.35869 5.91423 5.29282 5.9436 5.22609M3.97622 6.19219C4.53207 6.28356 5.70373 6.21825 5.9436 5.22609M14.0938 0.994685C11.6202 0.509944 3.893 0.606942 1.66675 0.994735M15.0214 1.47948C15.0814 3.29811 15.161 5.73924 15.2247 8.10229M0.666748 1.25309C1.0171 5.52083 1.1658 12.1799 0.961586 13.2053C0.712955 14.4538 1.19701 14.151 3.08036 14.151C3.78759 14.151 5.4647 14.1844 7.33341 14.2761M8.01147 11.9998H2.97598C1.70207 11.9998 4.75945 8.87026 5.01423 8.62952C5.26902 8.38878 6.03336 9.35175 6.28814 9.83323C6.49197 10.2184 6.71278 9.99372 6.7977 9.83323C7.56205 8.70975 9.1417 6.41465 9.34552 6.22206C9.54935 6.02947 9.77016 6.30231 9.85508 6.4628L10.9395 7.99984M10.9698 12.3332H12.3334M12.3334 12.3332H13.6971M12.3334 12.3332V13.6968M12.3334 12.3332V10.9695M12.0439 15.3112C12.1797 15.2918 15.4661 14.8686 15.3293 11.9176C15.3167 11.6465 15.2816 11.3999 15.2272 11.1763C15.159 10.8964 15.0604 10.6526 14.9373 10.4422C13.9283 8.71695 11.2748 9.23235 10.2644 10.4422C9.86788 10.9173 9.03691 12.1222 9.44186 13.6284C9.69571 14.5725 10.5193 15.1746 11.3789 15.306C11.6012 15.34 11.826 15.3425 12.0439 15.3112Z",stroke:"currentColor",strokeLinecap:"round"})});function ue(){const[a,d]=s.useState(void 0),[o,m]=s.useState(""),[L,x]=s.useState(!1),[U,M]=s.useState(!1),[S,P]=s.useState(0),[T,I]=s.useState(10),[q,E]=s.useState(null),[c,y]=s.useState(!1),[_,R]=s.useState(null),[A,C]=s.useState(null),[u,G]=s.useState(null),[J,k]=s.useState(!1),[Y,w]=s.useState(!1),[h,B]=s.useState(""),[p,F]=s.useState(""),[H,O]=s.useState(!1),[Z,$]=s.useState(!1),[V,N]=s.useState(""),g=s.useRef(null);s.useEffect(()=>{const t=new URLSearchParams(window.location.search);if(t.get("payment")==="success"){const n=t.get("credits");G(n?`Purchase complete! +${n} credits are being added â this usually takes a few seconds.`:"Purchase complete! Credits are being added â this usually takes a few seconds."),window.history.replaceState({},"",window.location.pathname)}},[]),s.useEffect(()=>{l.auth.getSession().then(({data:n})=>d(n.session));const{data:t}=l.auth.onAuthStateChange(async(n,r)=>{if(d(r),(n==="SIGNED_IN"||n==="INITIAL_SESSION")&&r?.user?.id){const i=r.access_token;fetch("/api/ensure-profile",{method:"POST",headers:{Authorization:`Bearer ${i}`}}).catch(()=>{})}});return()=>t.subscription.unsubscribe()},[]),s.useEffect(()=>{const t=setTimeout(()=>{d(n=>n===void 0?null:n)},15e3);return()=>clearTimeout(t)},[]),s.useEffect(()=>{let t=!0,n=0;async function r(){if(a?.user?.id){if(g.current!==a.user.id||!o){for(x(!0);n<10&&t;){const{data:i,error:j}=await l.from("profiles").select("token").eq("id",a.user.id).single();if(j){m("error"),x(!1);return}if(i?.token){m(i.token),x(!1),g.current=a.user.id;return}n++,await new Promise(v=>setTimeout(v,1e3))}m("not-found"),x(!1)}}else m(""),x(!1),g.current=null}return r(),()=>{t=!1}},[a]);const b=a?.user?.id,f=s.useCallback(async()=>{if(!b){P(0),I(5),E(null);return}y(!0);const t=new AbortController,n=setTimeout(()=>{t.abort(),y(!1)},12e3);try{const{data:r}=await l.auth.getSession(),i=r.session?.access_token,[j,{data:v}]=await Promise.all([fetch(`/api/account-balance?user_id=${b}`,{headers:i?{Authorization:`Bearer ${i}`}:{},signal:t.signal}),l.from("profiles").select("plugin_connected_at").eq("id",b).single()]),W=await j.json();j.ok&&(P(W.premium_credits??0),I(W.free_uses_remaining??10)),E(v?.plugin_connected_at||null)}finally{clearTimeout(n),y(!1)}},[b]);s.useEffect(()=>{f()},[f,u]),s.useEffect(()=>{if(!u)return;let t=0;const n=setInterval(()=>{t++,f(),t>=4&&clearInterval(n)},3e3);return()=>clearInterval(n)},[u]);const K=()=>{z&&(navigator.clipboard.writeText(o),M(!0),setTimeout(()=>M(!1),1500))},Q=async t=>{R(t),C(null);try{const r=await(await fetch("/api/create-checkout-session",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:a.user.id,userEmail:a.user.email,tier:t})})).json();r.url?window.location.href=r.url:C("Failed to start checkout. Please try again.")}catch{C("Payment error. Check your connection and try again.")}finally{R(null)}},X=async()=>{try{await Promise.race([l.auth.signOut(),new Promise((t,n)=>setTimeout(()=>n(new Error("timeout")),3e3))])}catch{}d(null),m(""),g.current=null,k(!1)},ee=async t=>{if(t.preventDefault(),!(!h||!p.trim())){O(!0),N("");try{if(!(await fetch("/api/submit-feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:h,message:p.trim(),email:a.user.email,source:"web_app"})})).ok)throw new Error("Failed to submit");$(!0),F(""),B("")}catch{N("Something went wrong. Please try again.")}finally{O(!1)}}},z=o&&o!=="error"&&o!=="not-found",D=!!q,te=S+T,se=S>0;return a===void 0?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx("p",{className:"text-gray-400 text-sm",children:"Loading..."})}):a?e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",onClick:()=>k(!1),children:[e.jsx("header",{className:"w-full px-6 py-5",children:e.jsxs("div",{className:"max-w-6xl mx-auto flex items-center justify-between",children:[e.jsx("img",{src:ae,alt:"Checklist Design",className:"h-6"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{w(!0),$(!1),N("")},className:"flex items-center justify-center w-8 h-8 rounded-md bg-white hover:bg-gray-50 text-gray-500 hover:text-gray-800 transition-colors",title:"Contact support",children:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),e.jsx("circle",{cx:"12",cy:"17",r:".5",fill:"currentColor"})]})}),e.jsxs("div",{className:"relative",onClick:t=>t.stopPropagation(),children:[e.jsxs("button",{onClick:()=>k(t=>
1!t),className:"flex items-center gap-2 bg-white rounded-md px-4 py-2 text-xs text-gray-500 hover:bg-gray-50 hover:text-gray-800 transition-colors cursor-pointer",children:[a.user?.email,e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",className:"text-gray-400 shrink-0",children:e.jsx("path",{d:"M2.5 4.5L6 8l3.5-3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),J&&e.jsx("div",{className:"absolute right-0 top-full mt-1.5 bg-white rounded-xl shadow-md overflow-hidden z-50 min-w-[120px]",children:e.jsx("button",{onClick:X,className:"btn btn-md btn-ghost w-full justify-start",children:"Log out"})})]})]})]})}),Y&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:()=>w(!1),children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md mx-4 p-6 flex flex-col gap-5",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-base font-semibold text-text-main",children:"Contact support"}),e.jsx("button",{onClick:()=>w(!1),className:"text-gray-400 hover:text-gray-600 transition-colors",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l12 12M14 2L2 14"})})})]}),Z?e.jsx("p",{className:"text-sm text-text-muted text-center py-4",children:"Thanks â we'll be in touch if needed."}):e.jsxs("form",{onSubmit:ee,className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-muted",children:"Reason"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{value:"report-bug",label:"Report a bug"},{value:"give-feedback",label:"Give feedback"},{value:"make-suggestion",label:"Make a suggestion"},{value:"something-else",label:"Something else"}].map(t=>e.jsxs("label",{className:`flex items-center gap-2 border rounded-lg px-3 py-2 cursor-pointer text-xs transition-colors ${h===t.value?"border-primary bg-primary/5 text-primary":"border-gray-200 text-text-main hover:border-gray-300"}`,children:[e.jsx("input",{type:"radio",name:"supportType",value:t.value,checked:h===t.value,onChange:()=>B(t.value),className:"sr-only"}),t.label]},t.value))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs font-medium text-text-muted",children:"Message"}),e.jsxs("span",{className:"text-xs text-text-muted",children:[p.length,"/300"]})]}),e.jsx("textarea",{value:p,onChange:t=>t.target.value.length<=300&&F(t.target.value),placeholder:"Tell us what's on your mindâ¦",rows:5,required:!0,className:"w-full border border-gray-200 rounded-xl px-3 py-2.5 text-sm text-text-main resize-none focus:outline-none focus:border-primary transition-colors"})]}),V&&e.jsx("p",{className:"text-xs text-red-500",children:V}),e.jsx("button",{type:"submit",disabled:H||!h||!p.trim(),className:"btn btn-xl btn-dark w-full",children:H?"Sendingâ¦":"Send message"})]})]})}),e.jsx("main",{className:"flex-1 w-full px-6 pb-12",children:e.jsxs("div",{className:"max-w-6xl mx-auto flex flex-col gap-4",children:[u&&e.jsxs("div",{className:"bg-green-50 border border-green-200 text-green-800 rounded-xl px-4 py-3 text-sm flex items-center justify-between gap-4",children:[e.jsxs("span",{className:"font-medium",children:["â
",u]}),e.jsx("button",{onClick:f,disabled:c,className:"btn btn-sm btn-ghost shrink-0 text-green-800 hover:bg-green-100",children:c?"Refreshing...":"Refresh balance"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_2fr] gap-4 items-start",children:[e.jsxs("div",{className:"bg-surface rounded-2xl p-10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ie,{}),e.jsx("h2",{className:"text-base font-semibold text-text-main",children:"API key"})]}),e.jsx("p",{className:"text-sm text-text-muted mb-4",children:"This is your personal API key for access, do not share it with anyone else."}),e.jsxs("div",{className:"border border-gray-200 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[e.jsxs("span",{className:"text-sm text-text-main flex items-center gap-2",children:["Status:Â ",L||c?e.jsx("span",{className:"text-text-muted font-normal",children:"Loading..."}):D?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-success shrink-0"}),e.jsx("span",{className:"font-medium",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-gray-300 shrink-0"}),e.jsx("span",{className:"font-medium text-text-muted",children:"Not connected"})]})]}
1),e.jsx("button",{onClick:f,disabled:c,className:"btn btn-sm btn-ghost",children:c?"Refreshing...":"Refresh"})]}),e.jsx("div",{className:"flex items-center justify-between px-4 py-3 gap-4 bg-gray-100",children:L?e.jsx("span",{className:"text-sm text-text-muted",children:"Loadingâ¦"}):z?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-text-main font-medium truncate",children:o}),e.jsx("button",{onClick:K,className:"btn btn-sm btn-ghost shrink-0",children:U?"Copied!":"Copy"})]}):e.jsx("span",{className:"text-sm text-text-muted",children:"Unable to load key â try logging out and back in."})})]})]}),e.jsx("div",{className:"bg-surface rounded-2xl p-10",children:c?e.jsx("div",{className:"flex items-center justify-center h-48",children:e.jsxs("svg",{className:"animate-spin w-5 h-5 text-gray-400",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]})}):e.jsxs(e.Fragment,{children:[!D&&e.jsxs("div",{className:"flex items-start gap-2 bg-amber-50 border border-amber-200 rounded-md px-3 py-2.5 mb-6",children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:"shrink-0 mt-0.5 text-amber-600",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 6V8.66667M8 11H8.00667M6.86 2.57333L1.21333 12C1.09323 12.2018 1.02976 12.4313 1.02941 12.6652C1.02906 12.8992 1.09185 13.1288 1.21135 13.331C1.33085 13.5331 1.50276 13.7006 1.70969 13.8162C1.91662 13.9318 2.15128 13.9914 2.38933 13.9893H13.6107C13.8487 13.9914 14.0834 13.9318 14.2903 13.8162C14.4972 13.7006 14.6692 13.5331 14.7887 13.331C14.9082 13.1288 14.9709 12.8992 14.9706 12.6652C14.9702 12.4313 14.9068 12.2018 14.7867 12L9.14 2.57333C9.01736 2.37742 8.84485 2.21654 8.63951 2.10578C8.43417 1.99501 8.20317 1.9375 7.96833 1.9375C7.7335 1.9375 7.5025 1.99501 7.29716 2.10578C7.09182 2.21654 6.91264 2.37742 6.79 2.57333H6.86Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("p",{className:"text-sm text-amber-800 leading-snug font-medium",children:"Your Figma plugin is not connected. Any credits you purchase will not be available in the plugin until you connect your API key."})]}),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(le,{}),e.jsx("h2",{className:"text-base font-semibold text-text-main",children:"Balance"})]}),se?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-xl font-medium text-text-main mb-1",children:[te," checks remaining"]}),e.jsx("p",{className:"text-sm text-text-muted",children:"This includes 10 free checks every month"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-2xl font-medium text-text-main mb-1",children:[T," / 10 free checks remaining"]}),e.jsx("p",{className:"text-sm text-text-muted",children:"Resets to 10 free checks at the start of next month"})]}),e.jsx("hr",{className:"border-gray-200 my-7"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(oe,{}),e.jsx("h2",{className:"text-base font-semibold text-text-main",children:"Add additional checks"})]}),e.jsx("p",{className:"text-sm text-text-muted mb-4",children:"These will never expire. You will also continue to receive 10 free checks per month."}),e.jsx("div",{className:"flex gap-3",children:re.map(t=>e.jsxs("div",{className:"flex-1 border border-gray-200 rounded-xl px-5 pt-6 pb-5 flex flex-col items-center text-center",children:[e.jsx("div",{className:"text-2xl font-medium text-text-main mb-1",children:t.price}),e.jsxs("div",{className:"text-base text-text-main mb-3",children:[t.credits," checks"]}),e.jsxs("div",{className:"text-xs text-text-muted mb-5",children:[t.perCheck," / check"]}),e.jsx("button",{className:"btn btn-lg btn-outline w-full",onClick:()=>Q(t.id),disabled:_!==null,children:_===t.id?"Redirecting...":"Select"})]},t.id))}),e.jsxs("p",{className:"text-xs text-text-muted mt-4",children:["By purchasing, you agree to our"," ",e.jsx("a",{href:"https://www.checklist.design/terms",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-main",children:"terms of service"}),"."," ","All sales are final â credits are non-refundable."]}),A&&e.jsx("p",{className:"text-red-500 text-sm mt-3",children:A})]})})]})]})}),e.jsx("footer",{className:"text-center py-6",children:e.jsx("a",{href:"https://www.checklist.design/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-text-muted hover:text-text-main underline",children:"Privacy Policy"})})]}):e.jsx(ne,{onLogin:async()=>{const{data:t}=await l.auth.getSession();d(t.session)}})}export{ue as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.