PageSourceSearch

https://cridergpt.com/assets/ProfilePanel-CjRs8qSo.js

js cridergpt.com collected 2026-09-24 14:41:05 UTC 25,281 bytes, 11 lines download raw bytes

1import{f as H,r as t,a as K,u as D,j as e,C as _,b as P,c as T,cF as se,g as z,e as k,E as Y,G as J,H as Q,J as X,N as R,B as S,w as ae,s as b,d as L,cL as M,cn as te,cD as ne,c1 as re,ah as v,c$ as ie,M as ce,y as C,d0 as oe,a6 as A,dm as Z,T as le,Q as W,aa as de,ab as ue,dx as he,dy as me,dz as xe,o as fe,av as pe,d8 as ge,dA as je}from"./index-CgMUx9S8.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ye=H("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const ve=H("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);function be(){const[s,r]=t.useState(""),[i,u]=t.useState(!1),{toast:d}=K(),{user:c}=D(),o=async()=>{if(!c||!s){d({title:"Error",description:"Please select a plan to fix.",variant:"destructive"});return}u(!0);try{const{data:g,error:j}=await b.functions.invoke("fix-user-plan",{body:{plan:s}});if(j)throw j;d({title:"Plan Fixed!",description:`Your plan has been manually updated to ${s}. Please refresh the page to see changes.`}),setTimeout(()=>{window.location.reload()},2e3)}catch(g){console.error("Error fixing plan:",g),d({title:"Fix Failed",description:"Failed to fix plan. Please contact support.",variant:"destructive"})}finally{u(!1)}};return c?e.jsxs(_,{className:"max-w-md mx-auto",children:[e.jsxs(P,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-5 w-5 text-amber-500"}),"Manual Plan Fix"]}),e.jsx(z,{children:"If you purchased a plan but it's not showing correctly, use this to fix it manually."})]}),e.jsxs(k,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"What plan did you purchase?"}),e.jsxs(Y,{value:s,onValueChange:r,children:[e.jsx(J,{children:e.jsx(Q,{placeholder:"Select the plan you bought"})}),e.jsxs(X,{children:[e.jsx(R,{value:"plus",children:"CriderGPT Plus"}),e.jsx(R,{value:"pro",children:"CriderGPT Pro"}),e.jsx(R,{value:"free",children:"Reset to Free"})]})]})]}),e.jsx(S,{onClick:o,disabled:i||!s,className:"w-full",children:i?e.jsx(e.Fragment,{children:"Fixing Plan..."}):e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),"Fix My Plan"]})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("strong",{children:"Note:"})," This is a temporary fix. The underlying webhook issue has been resolved for future purchases."]})]})]}):null}const U={free:0,plus:50,pro:200,lifetime:-1};function we(){const{user:s}=D(),{toast:r}=K(),[i,u]=t.useState({harvest_helper_enabled:!1,tech_tillage_enabled:!1,innovator_enabled:!1,savannah_tone_enabled:!1}),[d,c]=t.useState({}),[o,g]=t.useState("free"),[j,h]=t.useState(!0);t.useEffect(()=>{s&&(m(),y(),l())},[s]);const m=async()=>{try{const{data:n,error:f}=await b.from("feature_settings").select("*").eq("user_id",s==null?void 0:s.id).single();if(f&&f.code!=="PGRST116"){console.error("Error loading settings:",f);return}n&&u(n)}catch(n){console.error("Error loading settings:",n)}},y=async()=>{try{const n=new Date().toISOString().split("T")[0],{data:f,error:a}=await b.from("feature_usage").select("feature_name").eq("user_id",s==null?void 0:s.id).gte("timestamp",n);if(a){console.error("Error loading usage:",a);return}const w={};f.forEach(G=>{w[G.feature_name]=(w[G.feature_name]||0)+1}),c(w)}catch(n){console.error("Error loading usage:",n)}},l=async()=>{try{const{data:n,error:f}=await b.from("ai_usage").select("user_plan").eq("user_id",s==null?void 0:s.id).single();if(f){console.error("Error loading user plan:",f);return}g((n==null?void 0:n.user_plan)||"free")}catch(n){console.error("Error loading user plan:",n)}finally{h(!1)}},p=async(n,f)=>{try{await b.from("feature_usage").insert({user_id:s==null?void 0:s.id,feature_name:n,status:f,timestamp:new Date().toISOString()})}catch(a){console.error("Error logging feature usage:",a)}},N=async(n,f)=>{if(s){if(f&&n!=="savannah_tone_enabled"){const a=d[n.replace("_enabled","")]||0,w=U[o];if(w!==-1&&a>=w){r({title:"Usage Limit Reached",description:`You've reached your daily limit of ${w} uses for this feature.`,variant:"destructive"});return}}try{const{error:a}=await b.from("feature_settings").upsert({user_id:s.id,[n]:f},{onConflict:"user_id"});if(a){console.error("Error updating setting:",a),r({title:"Error",description:"Failed to update setting",variant:"destructive"});return}u(w=>({...w,[n]:f})),await p(n,f?"enabled":"disabled"),f&&c(w=>({...w,[n.replace("_enabled","")]:(w[n.replace("_enabled","")]||0)+1}
11)),r({title:f?"Feature Enabled":"Feature Disabled",description:`${n.replace("_enabled","").replace("_"," ")} has been ${f?"enabled":"disabled"}.`})}catch(a){console.error("Error updating setting:",a),r({title:"Error",description:"Failed to update setting",variant:"destructive"})}}},E=n=>{const f=d[n]||0,a=U[o];return a===-1?"Unlimited":a===0?"Not available":`${f}/${a}`},F=n=>{if(o==="lifetime")return!1;const f=d[n]||0,a=U[o];return a!==-1&&f>=a};if(j)return e.jsx("div",{className:"flex justify-center p-4",children:"Loading feature settings..."});const x=[{key:"harvest_helper_enabled",name:"Harvest Helper",icon:te,emoji:"🌾",description:"Fast insight gatherer for agricultural data",usageKey:"harvest_helper"},{key:"tech_tillage_enabled",name:"Tech Tillage",icon:ne,emoji:"🔧",description:"Lays foundation for digital growth",usageKey:"tech_tillage"},{key:"innovator_enabled",name:"InnoVator",icon:re,emoji:"🚀",description:"Drives innovation & transformation",usageKey:"innovator"}];return e.jsx("div",{className:"space-y-4",children:e.jsxs(_,{children:[e.jsx(P,{children:e.jsx(T,{children:"Feature Toggles"})}),e.jsxs(k,{className:"space-y-4",children:[x.map(n=>{const f=n.icon,a=F(n.usageKey);return e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(f,{className:"h-5 w-5"}),e.jsx("span",{className:"text-lg",children:n.emoji})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),e.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[e.jsxs(L,{variant:"outline",children:["Usage: ",E(n.usageKey)]}),a&&e.jsx(L,{variant:"destructive",children:"Limit Reached"})]})]})]}),e.jsx(M,{checked:i[n.key],onCheckedChange:w=>N(n.key,w),disabled:a&&!i[n.key]})]},n.key)}),e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("span",{className:"text-lg",children:"💬"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Savannah Tone"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"CriderGPT responds in Savannah's tone, style, and phrasing"}),e.jsx(L,{variant:"outline",children:"No usage limits"})]})]}),e.jsx(M,{checked:i.savannah_tone_enabled,onCheckedChange:n=>N("savannah_tone_enabled",n)})]})]})]})})}function Ne(){const{user:s}=D(),[r,i]=t.useState("default"),[u,d]=t.useState(!1),c=typeof window<"u"&&"Notification"in window&&"serviceWorker"in navigator&&"PushManager"in window;t.useEffect(()=>{c&&i(Notification.permission)},[c]);const o=t.useCallback(async()=>{var p,N;if(!c){v.error("Push notifications not supported on this device");return}if(!s){v.error("Sign in first");return}const j=await Notification.requestPermission();if(i(j),j!=="granted")return;const h=await navigator.serviceWorker.ready,l=(await h.pushManager.getSubscription()??await h.pushManager.subscribe({userVisibleOnly:!0})).toJSON();await b.from("push_subscriptions").upsert({user_id:s.id,endpoint:l.endpoint,p256dh:((p=l.keys)==null?void 0:p.p256dh)??"",auth:((N=l.keys)==null?void 0:N.auth)??"",device_label:navigator.userAgent.
11slice(0,80),enabled:!0},{onConflict:"user_id,endpoint"}),d(!0),v.success("Notifications enabled")},[c,s]),g=t.useCallback(async()=>{if(!s)return;const h=await(await navigator.serviceWorker.ready).pushManager.getSubscription();h&&(await h.unsubscribe(),await b.from("push_subscriptions").update({enabled:!1}).eq("endpoint",h.endpoint)),d(!1),v.success("Notifications disabled")},[s]);return{supported:c,permission:r,subscribed:u,enable:o,disable:g}}function Se(){const{user:s}=D(),[r,i]=t.useState({weekly_enabled:!0,day_of_week:0}),[u,d]=t.useState(!0);t.useEffect(()=>{s&&b.from("digest_preferences").select("weekly_enabled,day_of_week").eq("user_id",s.id).maybeSingle().then(({data:o})=>{o&&i(o),d(!1)})},[s]);const c=t.useCallback(async o=>{if(!s)return;i(o);const{error:g}=await b.from("digest_preferences").upsert({user_id:s.id,...o});g?v.error(g.message):v.success("Saved")},[s]);return{prefs:r,save:c,loading:u}}const _e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function ke(){const s=Ne(),{prefs:r,save:i}=Se();return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(_,{children:[e.jsx(P,{children:e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-5 w-5"})," Push notifications"]})}),e.jsxs(k,{className:"space-y-3",children:[s.supported?s.permission==="granted"||s.subscribed?e.jsx(S,{variant:"outline",onClick:s.disable,children:"Disable notifications"}):e.jsx(S,{onClick:s.enable,children:"Enable notifications"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not supported on this device."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Streak reminders, FFA event alerts, livestock check-ins."})]})]}),e.jsxs(_,{children:[e.jsx(P,{children:e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"})," Weekly digest email"]})}),e.jsxs(k,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{children:"Send me a weekly recap"}),e.jsx(M,{checked:r.weekly_enabled,onCheckedChange:u=>i({...r,weekly_enabled:u})})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-sm",children:"Day of week"}),e.jsx("div",{className:"flex gap-1 mt-1",children:_e.map((u,d)=>e.jsx(S,{size:"sm",variant:r.day_of_week===d?"default":"outline",onClick:()=>i({...r,day_of_week:d}),children:u},u))})]})]})]})]})}async function Ce(s){const r=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(s.trim().toLowerCase()));return Array.from(new Uint8Array(r)).map(i=>i.toString(16).padStart(2,"0")).join("")}function ee(){const{user:s}=D(),[r,i]=t.useState([]),[u,d]=t.useState(!1),c=t.useCallback(async()=>{if(!s)return;d(!0);const{data:m}=await b.from("owner_passphrases").select("id,label,action_type,payload,enabled,last_used_at,created_at").eq("user_id",s.id).order("created_at",{ascending:!1});i(m??[]),d(!1)},[s]),o=t.useCallback(async(m,y,l,p={})=>{if(!s)return;const N=await Ce(y),{error:E}=await b.from("owner_passphrases").insert({user_id:s.id,label:m,passphrase_hash:N,action_type:l,payload:p});return E?(v.error(E.message),!1):(v.success("Passphrase saved"),await c(),!0)},[s,c]),g=t.useCallback(async m=>{const{error:y}=await b.from("owner_passphrases").delete().eq("id",m);if(y)return v.error(y.message);v.success("Removed"),await c()},[c]),j=t.useCallback(async(m,y)=>{await b.from("owner_passphrases").update({enabled:y}).eq("id",m),await c()},[c]),h=t.useCallback(async m=>{const{data:y,error:l}=await b.functions.invoke("passphrase-verify",{body:{phrase:m}});return l?(v.error(l.message),null):y},[]);return{list:r,loading:u,refresh:c,create:o,remove:g,toggle:j,verify:h}}const q={unlock_dev:"Unlock dev/owner mode",switch_mode:"Switch AI personality/mode",secret_command:"Trigger a secret command",verify_action:"Verify it's really you"};function Pe(){const{list:s,refresh:r,create:i,remove:u,toggle:d,verify:c}=ee(),[o,g]=t.useState(""),[j,h]=t.useState(""),[m,y]=t.useState("unlock_dev"),[l,p]=t.useState(""),[N,E]=t.useState(""),[F,x]=t.useState(null);t.useEffect(()=>{r()},[r]);const n=async()=>{if(!o.trim()||!j.trim())return;let a={};if(l.trim())try{a=JSON.parse(l)}catch{a={value:l}}await i(o.trim(),j,m,a)&&(g(""),h(""),p(""))},f=async()=>{x(null);const a=await c(N);a&&x(a.matched?`✓ Matched: ${a.label} → ${a.action_type}`:"✗ No match")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(_,{children:[e.jsxs(P,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5"})," Passphrases"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Secret words that unlock dev mode, switch AI personality, run commands, or verify it's really you. Stored as a one-way hash — never readable, even by the server."})]}),e.jsxs(k,{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(C,{children:"Label"}),e.jsx(A,{value:o,onChange:a=>g(a.target.value),placeholder:"e.g. Owner unlock"})]}),e.jsxs("div",{children:[e.jsx(C,{children:"Action"}),e.jsxs(Y,{value:m,onValueChange:a=>y(a),children:[e.jsx(J,{children:e.jsx(Q,{})}),e.jsx(X,{children:Object.entries(q).map(([a,w])=>e.jsx(R,{value:a,children:w},a))})]})]})]}),e.jsxs("div",{children:[e.jsx(C,{children:"Passphrase"}),e.jsx(A,{type:"password",value:j,onChange:a=>h(a.target.value),placeholder:"e.g. open sesame jessie"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Case-insensitive. Trimmed."})]}),e.jsxs("div",{children:[e.jsx(C,{children:"Payload (optional)"}
11),e.jsx(A,{value:l,onChange:a=>p(a.target.value),placeholder:'e.g. {"mode":"agi"} or just a string'})]}),e.jsx(S,{onClick:n,children:"Save passphrase"})]})]}),e.jsxs(_,{children:[e.jsx(P,{children:e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-5 w-5"})," Test a passphrase"]})}),e.jsxs(k,{className:"space-y-2",children:[e.jsx(A,{type:"password",value:N,onChange:a=>E(a.target.value),placeholder:"say it…"}),e.jsx(S,{variant:"secondary",onClick:f,children:"Verify"}),F&&e.jsx("p",{className:"text-sm",children:F})]})]}),e.jsxs(_,{children:[e.jsx(P,{children:e.jsxs(T,{children:["Active passphrases (",s.length,")"]})}),e.jsxs(k,{className:"space-y-2",children:[s.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"None yet."}),s.map(a=>e.jsxs("div",{className:"flex items-center justify-between border rounded p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:a.label}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[e.jsx(L,{variant:"outline",children:q[a.action_type]}),a.last_used_at&&e.jsxs("span",{children:["used ",new Date(a.last_used_at).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{checked:a.enabled,onCheckedChange:w=>d(a.id,w)}),e.jsx(S,{size:"icon",variant:"ghost",onClick:()=>u(a.id),children:e.jsx(le,{className:"h-4 w-4"})})]})]},a.id))]})]})]})}const O="cridergpt:dev_unlocked",I="Owner unlock (test)",V="CriderGPT2025!";function Te(){const{list:s,refresh:r,create:i,verify:u}=ee(),[d,c]=t.useState(""),[o,g]=t.useState(()=>sessionStorage.getItem(O)==="1"),[j,h]=t.useState([]),[m,y]=t.useState(!1);t.useEffect(()=>{r()},[r]),t.useEffect(()=>{if(m||!s.length)return;s.some(n=>n.label===I)||p()},[s.length]);const l=(x,n)=>h(f=>[{ts:new Date().toLocaleTimeString(),kind:x,msg:n},...f].slice(0,20)),p=async()=>{y(!0);const x=await i(I,V,"unlock_dev",{source:"test_flow"});y(!1),x&&l("info",`Seeded default passphrase "${I}"`)},N=async()=>{if(!d.trim()){v.error("Type a passphrase first");return}const x=await u(d);if(!x){l("fail","Verify call failed");return}x.matched&&x.action_type==="unlock_dev"?(sessionStorage.setItem(O,"1"),g(!0),l("ok",`Unlocked via "${x.label}"`),v.success("Dev mode unlocked")):x.matched?(l("info",`Matched but action is "${x.action_type}", not unlock_dev`),v.message(`Matched action: ${x.action_type}`)):(l("fail","No match — dev mode stays locked"),v.error("Wrong passphrase")),c("")},E=()=>{sessionStorage.removeItem(O),g(!1),l("info","Locked dev mode")},F=()=>{if(!o){l("fail","Blocked: dev mode is locked"),v.error("Blocked — unlock first");return}l("ok","Ran protected command: ping_owner_tools()"),v.success("Protected command executed")};return e.jsxs(_,{children:[e.jsx(P,{children:e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"h-5 w-5"})," Passphrase Test Flow",e.jsx(L,{variant:o?"default":"secondary",className:"ml-auto",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3 w-3 mr-1"})," Dev unlocked"]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"h-3 w-3 mr-1"})," Dev locked"]})})]})}),e.jsxs(k,{className:"space-y-4",children:[e.jsx(de,{children:e.jsxs(ue,{className:"text-sm",children:["Default test passphrase: ",e.jsx("code",{className:"font-mono",children:V})," ","— bound to action ",e.jsx("code",{children:"unlock_dev"}),". Auto-seeded on first load."]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Enter passphrase"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(A,{type:"password",value:d,onChange:x=>c(x.target.value),onKeyDown:x=>x.key==="Enter"&&N(),placeholder:"say it…"}),e.jsxs(S,{onClick:N,children:[e.jsx(Z,{className:"h-4 w-4 mr-1"})," Verify"]})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-2",children:[e.jsxs(S,{variant:"secondary",onClick:F,children:[e.jsx(he,{className:"h-4 w-4 mr-1"})," Run protected command"]}),e.jsxs(S,{variant:"outline",onClick:E,disabled:!o,children:[e.jsx(W,{className:"h-4 w-4 mr-1"})," Lock dev mode"]})]}),!s.some(x=>x.label===I)&&e.jsx(S,{variant:"ghost",size:"sm",onClick:p,disabled:m,children:"Re-seed default passphrase"}),e.jsxs("div",{children:[e.jsx(C,{className:"text-xs text-muted-foreground",children:"Test log"}),e.jsxs("div",{className:"mt-1 border rounded p-2 max-h-48 overflow-y-auto text-xs space-y-1 font-mono",children:[j.length===0&&e.jsx("div",{className:"text-muted-foreground",children:"No events yet."}),j.map((x,n)=>e.jsxs("div",{className:x.kind==="ok"?"text-green-600":x.kind==="fail"?"text-destructive":"text-muted-foreground",children:["[",x.ts,"] ",x.msg]},n))]})]})]})]})}const Ee="2026-05-22",Le=8;function B(){const[s,r,i]=Ee.split("-").map(Number),u=new Date(s,r-1,i,Le,0,0,0),d=new Date,c=u.getTime()-d.getTime();if(c<=0)return null;const o=Math.floor(c/864e5),g=Math.floor(c%864e5/36e5),j=Math.floor(c%36e5/6e4),h=Math.floor(c%6e4/1e3);return{days:o,hours:g,mins:j,secs:h,target:u}}function Fe(){const[s,r]=t.useState(B());return t.useEffect(()=>{const i=setInterval(()=>r(B()),1e3);return()=>clearInterval(i)},[]),s?e.jsx(_,{className:"bg-gradient-to-br from-primary/15 to-accent/10 border-primary/30",children:e.jsxs(k,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"rounded-full bg-primary/20 p-2",children:e.jsx(me,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:"Graduation Countdown"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"May 22 · Practice 8:00 AM"})]})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2 text-center",children:[{v:s.days,l:"days"},{v:s.hours,l:"hrs"},{v:s.mins,l:"min"},{v:s.secs,l:"sec"}].map(i=>e.jsxs("div",{className:"rounded-md bg-background/60 py-2",children:[e.jsx("div",{className:"text-xl font-bold tabular-nums",children:i.v}),e.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:i.l})]},i.l))})]})}):null}const $={free:{maxReasoningSteps:2,maxToolCallsPerTurn:2,allowAutoSideEffects:!1},plus:{maxReasoningSteps:5,maxToolCallsPerTurn:5,allowAutoSideEffects:!1},pro:{maxReasoningSteps:10,maxToolCallsPerTurn:8,allowAutoSideEffects:!1},lifetime:{maxReasoningSteps:25,maxToolCallsPerTurn:15,allowAutoSideEffects:!0}};function Ae(){const{plan:s}=xe();return t.useMemo(()=>{const r=(s||"free").toLowerCase(),i=$[r]||$.free;return{enabled:!0,plan:r,...i}},[s])}const Me=$;function De(){const s=Ae();return e.jsxs(_,{children:[e.jsx(P,{className:"pb-3",children:e.jsxs(T,{className:"flex items-center gap-2 text-base",children:[e.jsx(fe,{className:"h-4 w-4 text-primary"}),"Free Will (always on)"]})}),e.jsxs(k,{className:"space-y-3 text-sm",children:[e.jsx("p",{className:"text-muted-foreground",children:"Every CriderGPT model thinks autonomously by default. Your plan decides how deep it can go in one turn."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{variant:"secondary",className:"capitalize",children:s.plan}),e.jsxs(L,{variant:"outline",children:[s.maxReasoningSteps," reasoning steps"]}),e.jsxs(L,{variant:"outline",children:[s.maxToolCallsPerTurn," tools/turn"]}),s.allowAutoSideEffects&&e.jsx(L,{children:"auto SMS/writes"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2 pt-2 text-xs",children:Object.entries(Me).map(([r,i])=>
11e.jsxs("div",{className:`rounded border p-2 ${r===s.plan?"border-primary bg-primary/5":"border-border"}`,children:[e.jsx("div",{className:"font-semibold capitalize",children:r}),e.jsxs("div",{className:"text-muted-foreground",children:[i.maxReasoningSteps," steps · ",i.maxToolCallsPerTurn," tools"]})]},r))})]})]})}function Ie(){const[s,r]=t.useState(null),[i,u]=t.useState(!0),[d,c]=t.useState(!1),o=t.useCallback(async()=>{u(!0);const{data:h}=await b.auth.getUser();if(!h.user){u(!1);return}const{data:m}=await b.from("sms_settings").select("phone_number, notifications_enabled, verified, twilio_from_number").eq("user_id",h.user.id).maybeSingle();r(m),u(!1)},[]);t.useEffect(()=>{o()},[o]);const g=t.useCallback(async h=>{c(!0);const{data:m}=await b.auth.getUser();if(!m.user)return c(!1),{error:"Not signed in"};const y={user_id:m.user.id,phone_number:h.phone_number,notifications_enabled:h.notifications_enabled??!0,twilio_from_number:h.twilio_from_number??null},{error:l}=await b.from("sms_settings").upsert(y,{onConflict:"user_id"});return c(!1),l||await o(),{error:l==null?void 0:l.message}},[o]),j=t.useCallback(async(h="Hey — CriderGPT is wired up and can text you. 🤠")=>{const{data:m,error:y}=await b.functions.invoke("cridergpt-sms",{body:{message:h}});return{data:m,error:y==null?void 0:y.message}},[]);return{settings:s,loading:i,saving:d,save:g,sendTest:j,reload:o}}function Re(){const{settings:s,loading:r,saving:i,save:u,sendTest:d}=Ie(),[c,o]=t.useState(""),[g,j]=t.useState(!0),[h,m]=t.useState(!1);t.useEffect(()=>{s&&(o(s.phone_number||""),j(s.notifications_enabled))},[s]);const y=async()=>{if(!/^\+\d{8,15}$/.test(c)){v.error("Use E.164 format, e.g. +15555551234");return}const{error:p}=await u({phone_number:c,notifications_enabled:g});p?v.error(p):v.success("SMS settings saved")},l=async()=>{m(!0);const{data:p,error:N}=await d();if(m(!1),N){v.error(N);return}(p==null?void 0:p.status)==="pending_config"?v.warning("Wired up — connect Twilio to actually send."):v.success(`Sent! ${p!=null&&p.sid?`SID: ${p.sid}`:""}`)};return e.jsxs(_,{children:[e.jsxs(P,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"h-5 w-5"}),"CriderGPT can text you"]}),e.jsx(z,{children:"Save your phone number so CriderGPT can send important updates over SMS."})]}),e.jsxs(k,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"sms-phone",children:"Phone number (E.164)"}),e.jsx(A,{id:"sms-phone",placeholder:"+15555551234",value:c,onChange:p=>o(p.target.value),disabled:r})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{htmlFor:"sms-enabled",children:"SMS notifications enabled"}),e.jsx(M,{id:"sms-enabled",checked:g,onCheckedChange:j})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{onClick:y,disabled:i||r,children:i?"Saving…":"Save"}),e.jsxs(S,{variant:"secondary",onClick:l,disabled:h||!(s!=null&&s.phone_number),children:[e.jsx(ge,{className:"h-4 w-4 mr-2"}),h?"Sending…":"Send test SMS"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Twilio connector + a verified FROM number are required to actually send. Until then, messages log as ",e.jsx("code",{children:"pending_config"}),"."]})]})]})}function Oe(){const[s,r]=t.useState(!0);return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Fe,{}),e.jsxs("div",{className:"bg-card p-6 rounded-lg border",children:[e.jsx("h2",{className:"text-2xl font-bold mb-4",children:"Profile & Settings"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Manage your account settings, preferences, and view your usage statistics."})]}),e.jsx(De,{}),e.jsx(Re,{}),e.jsx(we,{}),e.jsx(ke,{}),e.jsx(Pe,{}),e.jsx(Te,{}),e.jsx(be,{}),e.jsx(je,{open:s,onOpenChange:r,defaultTab:"account"})]})}export{Oe as ProfilePanel};

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.