1import{aq as ue,c as _,r as h,W as E,F as P,q as L,Q as A,j as e,b8 as G,C as g,K as k,b_ as ee,N as S,aa as U,a as f,B as N,O as C,$ as re,ac as ne,a7 as J,a0 as ie,a1 as le,a2 as de,T as $,am as he,c4 as se,G as pe,p as Y,M as je,aB as ge,o as ce,a4 as I,E as ye,b as X,I as we,Z as Ce,ap as ke,c9 as Se,ca as Te,cb as Ae,L as fe,X as Ee,aP as De,f as Pe,ao as Be}from"./index-tc5-nNLC.js";import{C as Ie}from"./chainCapabilities-B-1iRMBp.js";import{T as Fe,a as Le,b as O,c as R}from"./tabs-D2OfY7RH.js";import{P as te}from"./progress-CJIgvptw.js";import{S as z}from"./switch-B37nBmXq.js";import{L as q}from"./label-MwGx_WS4.js";import{S as V,a as K,b as W,c as M,d as T}from"./select-Bsa-6vNv.js";import{G as $e}from"./globe-CrY5Q3gB.js";import{P as Oe}from"./piggy-bank-GWWx7iyl.js";import{C as Re}from"./coins-B0XOg3gp.js";import{G as Ne}from"./gift-CcGpxH7x.js";import{S as qe}from"./send-B0Xv9vwc.js";import{A as ve}from"./arrow-up-right-_tEZZH8K.js";import{S as Ue}from"./settings-2-CKQWlrE-.js";import{C as be}from"./circle-check-big-CUgqPmz6.js";import{L as Ve}from"./lock-CWiCoas5.js";import{C as Ke}from"./circle-x-BO-W5S7j.js";import{S as We}from"./shield-check-LwYRIJhL.js";import{C as Me}from"./credit-card-B0XDcUdX.js";import{B as _e}from"./beer-Bw6boWpQ.js";import{E as He}from"./external-link-wMXh6D17.js";import{H as oe}from"./hash-B1pZho-G.js";import{C as Qe}from"./chevron-up-1gTexUQn.js";import{C as ze}from"./chevron-down-DOFZ7rzv.js";import{L as Ge}from"./log-in-DrADV0ef.js";import"./index-C-y5wYFI.js";/** 2 * @license lucide-react v0.453.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 ae=ue("ArrowDownLeft",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);/** 7 * @license lucide-react v0.453.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 Ye=ue("Barcode",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M8 5v14",key:"1ybrkv"}],["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"M17 5v14",key:"ycjyhj"}],["path",{d:"M21 5v14",key:"nzette"}]]),Z="slant_wallet_explainer_dismissed";function Xe(){const[s,r]=h.useState(()=>{try{return sessionStorage.getItem(Z)==="open"}catch{return!1}}),d=Ie.find(o=>o.id==="wallet");if(!d)return null;const l=()=>{try{sessionStorage.setItem(Z,"open")}catch{}r(!0)},i=()=>{try{sessionStorage.removeItem(Z)}catch{}r(!1)};return s?e.jsxs("div",{className:"rounded-xl border border-amber-200 dark:border-amber-800/40 bg-amber-50 dark:bg-amber-950/20 overflow-hidden","data-testid":"wallet-how-it-works-explainer",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-amber-200 dark:border-amber-800/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),e.jsx("span",{className:"text-sm font-semibold text-amber-900 dark:text-amber-300",children:"How credits & passes work"})]}),e.jsx("button",{type:"button",onClick:i,className:"text-xs text-amber-600 dark:text-amber-500 hover:text-amber-900 dark:hover:text-amber-300 transition-colors","data-testid":"wallet-explainer-dismiss",children:"Got it"})]}),e.jsx("ul",{className:"divide-y divide-amber-100 dark:divide-amber-800/20",children:d.items.map(o=>e.jsxs("li",{className:"px-4 py-3 flex items-start gap-3",children:[e.jsx(ee,{className:"h-4 w-4 mt-0.5 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-200 leading-snug",children:o.title}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-500 mt-0.5 leading-relaxed",children:o.description})]})]},o.id))})]}):e.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors","data-testid":"wallet-explainer-reopen",children:[e.jsx(Y,{className:"h-3.5 w-3.5"}),"How credits & passes work"]})}function Je(){const{toast:s}=_(),[r,d]=h.useState(""),[l,i]=h.useState(""),[o,m]=h.useState("1"),{data:p,isLoading:v}=E({queryKey:["/api/wallet/chain-credits"]}),{data:j}=E({queryKey:["/api/wallet/chain-credit-packs"]}),x=()=>{L.invalidateQueries({queryKey:["/api/wallet/chain-credits"]}),L.invalidateQueries({queryKey:["/api/wallet"]})},t=P({mutationFn:a=>A("POST","/api/wallet/chain-credits/checkout",{packId:a}),onSuccess:async a=>{const D=await a.json();D.url&&(window.location.href=D.url)},onError:()=>s({title:"Checkout unavailable",description:"Please try again.",variant:"destructive"})}),b=P({mutationFn:()=>A("POST","/api/wallet/redeem-code",{code:r}),onSuccess:async a=>{const D=await a.json();d(""),x(),s({title:"Code redeemed",description:`${D.creditsAdded} chain credit${D.creditsAdded===1?"":"s"} added.`})},onError:()=>s({title:"Could not redeem code",description:"Check the code and try again.",variant:"destructive"})}),c=P({mutationFn:()=>A("POST","/api/wallet/transfer",{recipientEmail:l,amount:Number(o),idempotencyKey:`wallet-transfer-${Date.now()}`}),onSuccess:()=>{i(""),m("1"),x(),s({title:"Credits transferred",description:"The recipient can use them to create chains."})},onError:()=>s({title:"Transfer failed",description:"Check the recipient and
11your available balance.",variant:"destructive"})}),y=(p==null?void 0:p.chainCredits)??0;return e.jsxs(g,{"data-testid":"chain-credit-wallet-card",className:"border-primary/30",children:[e.jsx(k,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs(S,{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-5 w-5 text-primary"}),"Chain credits"]}),e.jsxs(U,{children:["One credit creates one chain. Buy, redeem, or delegate credits from here.",e.jsx(ce,{href:"/credits",className:"ml-1 font-medium text-primary underline underline-offset-2","data-testid":"wallet-credit-store-link",children:"View credit store"})]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("div",{className:"text-3xl font-bold text-primary","data-testid":"chain-credit-balance",children:v?"â":y}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"available"})]})]})}),e.jsxs(f,{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Top up"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:((j==null?void 0:j.packs)||[]).map(a=>e.jsxs(N,{variant:"outline",className:"h-auto py-2 flex-col items-start",onClick:()=>t.mutate(a.id),disabled:t.isPending,"data-testid":`buy-chain-credits-${a.id}`,children:[e.jsxs("span",{className:"font-semibold",children:[a.label," · $",(a.priceCents/100).toFixed(2)]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a.description})]},a.id))})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("form",{className:"space-y-2",onSubmit:a=>{a.preventDefault(),r.trim()&&b.mutate()},children:[e.jsxs(q,{htmlFor:"chain-credit-code",className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"})," Redeem a retail code ",e.jsx(ce,{href:"/redeem",className:"ml-auto text-xs font-normal text-primary underline underline-offset-2",children:"Open full form"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(I,{id:"chain-credit-code",value:r,onChange:a=>d(a.target.value),placeholder:"Enter code","data-testid":"chain-credit-code-input"}),e.jsx(N,{type:"submit",variant:"secondary",disabled:!r.trim()||b.isPending,children:"Redeem"})]})]}),e.jsxs("form",{className:"space-y-2",onSubmit:a=>{a.preventDefault(),l&&Number(o)>0&&c.mutate()},children:[e.jsxs(q,{htmlFor:"chain-credit-recipient",className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"})," Delegate credits"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(I,{id:"chain-credit-recipient",type:"email",value:l,onChange:a=>i(a.target.value),placeholder:"Operator email","data-testid":"chain-credit-recipient-input"}),e.jsx(I,{className:"w-20",type:"number",min:"1",max:"50",value:o,onChange:a=>m(a.target.value),"aria-label":"Credits to transfer"}),e.jsx(N,{type:"submit",variant:"secondary",disabled:!l||c.isPending,children:"Send"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Transfers require verified accounts and are limited to 50 credits per day."})]})]}),(p==null?void 0:p.transactions)&&p.transactions.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Recent credit activity"}),e.jsx("div",{className:"divide-y rounded-md border",children:p.transactions.slice(0,5).map(a=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 text-sm",children:[e.jsx("span",{className:"capitalize",children:a.type.replaceAll("_"," ")}),e.jsxs("span",{className:a.amount>0?"text-emerald-600 dark:text-emerald-400 font-medium":"text-muted-foreground",children:[a.amount>0?"+":"",a.amount]})]},a.id))})]})]})]})}function Ze({userId:s}){var a,D,H,F;const{toast:r}=_(),[d,l]=h.useState(!1),[i,o]=h.useState(!1),{data:m,isLoading:p,refetch:v}=E({queryKey:["/api/wallet"]}),{data:j}=E({queryKey:["/api/wallet/currencies"]}),{data:x}=E({queryKey:["/api/wallet/recommendations"],enabled:!!(m!=null&&m.wallet)}),{data:t}=E({queryKey:["/api/wallet/alerts"],enabled:!!(m!=null&&m.wallet)}
11),b=P({mutationFn:async n=>A("POST","/api/wallet/create",{baseCurrency:n}),onSuccess:()=>{L.invalidateQueries({queryKey:["/api/wallet"]}),r({title:"Wallet created successfully!"})},onError:()=>{r({title:"Failed to create wallet",variant:"destructive"})}}),c=m==null?void 0:m.wallet,y=(n,Q="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:Q}).format(n/100);return p?e.jsx("div",{className:"flex justify-center items-center h-64",children:e.jsx(G,{className:"h-8 w-8 animate-spin text-primary"})}):c?e.jsxs("div",{className:"space-y-6","data-testid":"wallet-dashboard",children:[e.jsx(Xe,{}),e.jsx(Je,{}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(g,{className:"md:col-span-2","data-testid":"wallet-balance-card",children:[e.jsxs(k,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsxs("div",{children:[e.jsx(S,{className:"text-sm font-medium text-muted-foreground",children:"Total Balance"}),e.jsx("div",{className:"text-3xl font-bold text-primary","data-testid":"wallet-balance",children:y(c.balanceCents,c.baseCurrency)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(C,{variant:"outline",className:"gap-1",children:[e.jsx($e,{className:"h-3 w-3"}),c.baseCurrency]}),e.jsx(N,{variant:"outline",size:"icon",onClick:()=>v(),children:e.jsx(G,{className:"h-4 w-4"})})]})]}),e.jsx(f,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(re,{open:d,onOpenChange:l,children:[e.jsx(ne,{asChild:!0,children:e.jsxs(N,{className:"gap-2","data-testid":"add-deposit-btn",children:[e.jsx(J,{className:"h-4 w-4"}),"Add Funds"]})}),e.jsxs(ie,{children:[e.jsx(le,{children:e.jsx(de,{children:"Add Transaction"})}),e.jsx(is,{walletCurrency:c.baseCurrency,currencies:(j==null?void 0:j.currencies)||[],onSuccess:()=>{l(!1),L.invalidateQueries({queryKey:["/api/wallet"]})}})]})]}),e.jsxs(N,{variant:"outline",className:"gap-2","data-testid":"record-expense-btn",children:[e.jsx(ae,{className:"h-4 w-4"}),"Record Expense"]})]})})]}),e.jsxs(g,{"data-testid":"wallet-quick-stats",children:[e.jsx(k,{className:"pb-2",children:e.jsx(S,{className:"text-sm font-medium text-muted-foreground",children:"Quick Stats"})}),e.jsxs(f,{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm",children:"Active Budgets"}),e.jsx(C,{children:((a=c.budgets)==null?void 0:a.filter(n=>n.status==="active").length)||0})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm",children:"Recent Transactions"}),e.jsx(C,{variant:"outline",children:((D=c.transactions)==null?void 0:D.length)||0})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm",children:"Unread Alerts"}),e.jsx(C,{variant:(H=t==null?void 0:t.alerts)!=null&&H.some(n=>!n.readAt)?"destructive":"outline",children:((F=t==null?void 0:t.alerts)==null?void 0:F.filter(n=>!n.readAt).length)||0})]})]})]})]}),e.jsxs(Fe,{defaultValue:"overview",className:"w-full",children:[e.jsxs(Le,{className:"w-full justify-start",children:[e.jsx(O,{value:"overview","data-testid":"tab-overview",children:"Overview"}),e.jsx(O,{value:"transactions","data-testid":"tab-transactions",children:"Transactions"}),e.jsx(O,{value:"budgets","data-testid":"tab-budgets",children:"Budgets"}),e.jsx(O,{value:"recommendations","data-testid":"tab-recommendations",children:"AI Suggestions"}),e.jsx(O,{value:"alerts","data-testid":"tab-alerts",children:"Alerts"}),e.jsxs(O,{value:"pass","data-testid":"tab-pass",children:[e.jsx($,{className:"h-4 w-4 mr-1"}),"Pass"]})]}),e.jsx(R,{value:"overview",className:"mt-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(g,{"data-testid":"recent-transactions",children:[e.jsx(k,{children:e.jsxs(S,{className:"text-lg flex items-center gap-2",children:[e.jsx(he,{className:"h-5 w-5"}),"Recent Activity"]})}),e.jsx(f,{children:c.transactions&&c.transactions.length>0?e.jsx("div",{className:"space-y-3",children:c.transactions.slice(0,5).map(n=>e.jsx(me,{transaction:n,currency:c.baseCurrency},n.id))}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No transactions yet"})})]}),e.jsxs(g,{"data-testid":"budget-overview",children:[e.jsxs(k,{className:"flex flex-row items-center justify-between",children:[e.jsxs(S,{className:"text-lg flex items-center gap-2",children:[e.jsx(se,{className:"h-5 w-5"}),"Budget Progress"]}),e.jsxs(re,{open:i,onOpenChange:o,children:[e.jsx(ne,{asChild:!0,children:e.jsxs(N,{size:"sm",variant:"outline",className:"gap-1",children:[e.jsx(J,{className:"h-4 w-4"}),"Add"]})}),e.jsxs(ie,{children:[e.jsx(le,{children:e.jsx(de,{children:"Create Budget"})}),e.jsx(ls,{walletCurrency:c.baseCurrency,currencies:(j==null?void 0:j.currencies)||[],onSuccess:()=>{o(!1),L.invalidateQueries({queryKey:["/api/wallet"]})}})]})]})]}),e.jsx(f,{children:c.budgets&&c.budgets.filter(n=>n.status==="active").length>0?e.jsx("div",{className:"space-y-4",children:c.budgets.filter(n=>n.status==="active").slice(0,3).map(n=>e.jsx(ss,{budget:n},n.id))}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No active budgets"})})]})]})}),e.jsx(R,{value:"transactions",className:"mt-4",children:e.jsxs(g,{"data-testid":"all-transactions",children:[e.jsx(k,{children:e.jsx(S,{children:"Transaction History"})}),e.jsx(f,{children:c.transactions&&c.transactions.length>0?e.jsx("div",{className:"space-y-3",children:c.transactions.map(n=>e.jsx(me,{transaction:n,currency:c.baseCurrency},n.id))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(pe,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No transactions yet"})]})})]})}),e.jsx(R,{value:"budgets",className:"mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Your Budgets"}),e.jsxs(N,{onClick:()=>o(!0),className:"gap-2","data-testid":"create-budget-btn",children:[e.jsx(J,{className:"h-4 w-4"}),"Create Budget"]}
11)]}),c.budgets&&c.budgets.length>0?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:c.budgets.map(n=>e.jsx(ts,{budget:n},n.id))}):e.jsx(g,{children:e.jsxs(f,{className:"text-center py-8",children:[e.jsx(Oe,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No budgets created yet"})]})})]})}),e.jsx(R,{value:"recommendations",className:"mt-4",children:e.jsxs(g,{"data-testid":"ai-recommendations",children:[e.jsxs(k,{children:[e.jsxs(S,{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-5 w-5 text-amber-500"}),"AI-Powered Recommendations"]}),e.jsx(U,{children:"Destinations and activities tailored to your budget"})]}),e.jsx(f,{children:x!=null&&x.recommendations&&x.recommendations.length>0?e.jsx("div",{className:"space-y-4",children:x.recommendations.map(n=>e.jsx(as,{recommendation:n},n.id))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(je,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"Add funds to your wallet to get personalized recommendations"})]})})]})}),e.jsx(R,{value:"alerts",className:"mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(ns,{walletId:c.id}),e.jsxs(g,{"data-testid":"alerts-list",children:[e.jsx(k,{children:e.jsxs(S,{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"h-5 w-5"}),"Recent Alerts"]})}),e.jsx(f,{children:t!=null&&t.alerts&&t.alerts.length>0?e.jsx("div",{className:"space-y-3",children:t.alerts.map(n=>e.jsx(rs,{alert:n},n.id))}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No alerts yet"})})]})]})}),e.jsx(R,{value:"pass",className:"mt-4",children:e.jsx(es,{userId:s})})]})]}):e.jsxs(g,{className:"max-w-md mx-auto","data-testid":"wallet-create-prompt",children:[e.jsxs(k,{className:"text-center",children:[e.jsx(ee,{className:"h-16 w-16 mx-auto text-primary mb-4"}),e.jsx(S,{children:"Create Your Travel Wallet"}),e.jsx(U,{children:"Track your travel budget, manage expenses, and get AI-powered destination recommendations."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs(V,{defaultValue:"USD",onValueChange:n=>b.mutate(n),children:[e.jsx(K,{"data-testid":"currency-select",children:e.jsx(W,{placeholder:"Select base currency"})}),e.jsx(M,{children:((j==null?void 0:j.currencies)||["USD","EUR","GBP","JPY"]).map(n=>e.jsx(T,{value:n,children:n},n))})]}),e.jsx(N,{className:"w-full",onClick:()=>b.mutate("USD"),disabled:b.isPending,"data-testid":"create-wallet-btn",children:b.isPending?"Creating...":"Create Wallet"})]})]})}function es({userId:s}){const{data:r,isLoading:d}=E({queryKey:["/api/wallet/entitlements"],enabled:!!s}),{data:l,isLoading:i}=E({queryKey:["/api/wallet/claims"],enabled:!!s}),o=(r==null?void 0:r.data)||[],m=(l==null?void 0:l.data)||[],p=o.filter(t=>t.status==="ACTIVE"),v=o.filter(t=>t.status!=="ACTIVE");function j(t){switch(t){case"COUNT":return e.jsx(_e,{className:"h-4 w-4"});case"CREDIT":return e.jsx(Me,{className:"h-4 w-4"});case"ACCESS":return e.jsx(We,{className:"h-4 w-4"});case"BOUNTY":return e.jsx(Ce,{className:"h-4 w-4"});default:return e.jsx($,{className:"h-4 w-4"})}}function x(t){const b={ACTIVE:"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-400",LOCKED:"bg-slate-100 text-slate-600 dark:bg-slate-500/20 dark:text-slate-400",EXPIRED:"bg-red-100 text-red-600 dark:bg-red-500/20 dark:text-red-400",DEPLETED:"bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-400",REVOKED:"bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-400"};return e.jsx(C,{className:b[t]||"bg-slate-100 text-slate-600","data-testid":`badge-entitlement-status-${t}`,children:t})}return d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(G,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[p.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold mb-3 flex items-center gap-2","data-testid":"text-active-passes",children:[e.jsx($,{className:"h-5 w-5 text-emerald-500"}),"Active Pass Benefits"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:p.map(t=>e.jsx(g,{className:"border-emerald-200 dark:border-emerald-500/30","data-testid":`card-entitlement-${t.id}`,children:e.jsxs(f,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[j(t.type),e.jsx("span",{className:"font-medium","data-testid":`text-entitlement-name-${t.id}`,children:t.name})]}),x(t.status)]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:t.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[t.type==="COUNT"||t.type==="ACCESS"||t.type==="BOUNTY"?e.jsxs("span",{className:"flex items-center gap-1","data-testid":`text-remaining-count-${t.id}`,children:[e.jsx(se,{className:"h-3 w-3"}),t.remainingCount??0," / ",t.defaultValue," remaining"]}):t.type==="CREDIT"?e.jsxs("span",{className:"flex items-center gap-1","data-testid":`text-remaining-credit-${t.id}`,children:[e.jsx(pe,{className:"h-3 w-3"}),"$",((t.remainingCredit??0)/100).toFixed(2)," remaining"]}):null,t.validTo&&e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(we,{className:"h-3 w-3"}),"Expires ",new Date(t.validTo).toLocaleDateString()]})]}),(t.type==="COUNT"||t.type==="ACCESS")&&t.remainingCount!=null&&e.jsx(te,{value:t.remainingCount/t.defaultValue*100,className:"mt-2 h-1.5"})]})},t.id))})]}),v.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium text-muted-foreground mb-2 flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),"Other Benefits"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:v.map(t=>e.jsx(g,{className:"opacity-60","data-testid":`card-entitlement-inactive-${t.id}`,children:e.jsxs(f,{className:"p-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[j(t.type),e.jsx("span",{className:"text-sm",children:t.name})]}),x(t.status)]})},t.id))})]}),o.length===0&&e.jsx(g,{"data-testid":"card-no-entitlements",children:e.jsxs(f,{className:"py-8 text-center",children:[e.jsx($,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("h3",{className:"font-semibold mb-1",children:"No Pass Benefits"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Join a chain or campaign to receive pass benefits and entitlements."})]})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold mb-3 flex items-center gap-2","data-testid":"text-claim-history",children:[e.jsx(he,{className:"h-5 w-5"}),"Claim History"]}),i?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(G,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):m.length>0?e.jsx(g,{children:e.jsx(f,{className:"p-0",children:e.jsx("div",{className:"divide-y",children:m.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3","data-testid":`claim-row-${t.id}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[t.status==="APPROVED"?e.jsx(be,{className:"h-4 w-4 text-emerald-500"}):e.jsx(Ke,{className:"h-4 w-4 text-red-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.entitlementName||"Unknown"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.createdAt?new Date(t.createdAt).toLocaleStr
11ing():"â",t.venueId&&` · Venue: ${t.venueId.slice(0,8)}...`]})]})]}),e.jsx("div",{className:"text-right",children:t.status==="APPROVED"?e.jsx(C,{className:"bg-emerald-100 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-400",children:t.amountCount?`Ã${t.amountCount}`:t.amountCredit?`$${(t.amountCredit/100).toFixed(2)}`:"Approved"}):e.jsx(C,{variant:"destructive",className:"text-xs",children:t.denyReason||"Denied"})})]},t.id))})})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4","data-testid":"text-no-claims",children:"No claims yet. Present your pass at a venue to get started."})]})]})}function me({transaction:s,currency:r}){const d=s.type==="deposit";return e.jsxs("div",{className:"flex items-center justify-between py-2 border-b last:border-0","data-testid":`transaction-${s.id}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-full ${d?"bg-green-100 text-green-600":"bg-red-100 text-red-600"}`,children:d?e.jsx(ae,{className:"h-4 w-4"}):e.jsx(ve,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s.description||(d?"Deposit":"Expense")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(s.createdAt).toLocaleDateString()})]})]}),e.jsxs("div",{className:`font-semibold ${d?"text-green-600":"text-red-600"}`,children:[d?"+":"-",new Intl.NumberFormat("en-US",{style:"currency",currency:s.currency}).format(s.amountCents/100)]})]})}function ss({budget:s}){const r=s.spentAmountCents/s.targetAmountCents*100;return e.jsxs("div",{className:"space-y-2","data-testid":`budget-progress-${s.id}`,children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"font-medium text-sm",children:s.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[Math.round(r),"%"]})]}),e.jsx(te,{value:Math.min(r,100),className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:new Intl.NumberFormat("en-US",{style:"currency",currency:s.currency}).format(s.spentAmountCents/100)}),e.jsx("span",{children:new Intl.NumberFormat("en-US",{style:"currency",currency:s.currency}).format(s.targetAmountCents/100)})]})]})}function ts({budget:s}){const r=s.spentAmountCents/s.targetAmountCents*100,d=r>100;return e.jsxs(g,{"data-testid":`budget-card-${s.id}`,children:[e.jsx(k,{className:"pb-2",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx(S,{className:"text-base",children:s.name}),e.jsxs(U,{className:"capitalize",children:[s.scope," budget"]})]}),e.jsx(C,{variant:d?"destructive":s.status==="active"?"default":"secondary",children:d?"Over Budget":s.status})]})}),e.jsxs(f,{className:"space-y-4",children:[e.jsx(te,{value:Math.min(r,100),className:`h-3 ${d?"bg-red-100":""}`}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Spent: "}),e.jsx("span",{className:"font-medium",children:new Intl.NumberFormat("en-US",{style:"currency",currency:s.currency}).format(s.spentAmountCents/100)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Target: "}),e.jsx("span",{className:"font-medium",children:new Intl.NumberFormat("en-US",{style:"currency",currency:s.currency}).format(s.targetAmountCents/100)})]})]}),s.endDate&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(ye,{className:"h-3 w-3"}),e.jsxs("span",{children:["Ends ",new Date(s.endDate).toLocaleDateString()]})]})]})]})}function as({recommendation:s}){return e.jsx(g,{className:"bg-gradient-to-br from-amber-50 to-orange-50 dark:from-amber-950/20 dark:to-orange-950/20","data-testid":`recommendation-${s.id}`,children:e.jsx(f,{className:"pt-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-amber-100 dark:bg-amber-900",children:s.type==="destination"?e.jsx(je,{className:"h-5 w-5 text-amber-600"}):s.type==="activity"?e.jsx(Y,{className:"h-5 w-5 text-amber-600"}):e.jsx(se,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.description}),s.estimatedCostCents>0&&e.jsxs("p",{className:"text-sm font-medium text-primary mt-2",children:["Est. ",new Intl.NumberFormat("en-US",{style:"currency",currency:s.currency}).format(s.estimatedCostCents/100)]}),e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsxs(C,{variant:"outline",className:"text-xs",children:[Math.round(s.confidence*100),"% match"]})})]})]})})})}function rs({alert:s}){const r=P({mutationFn:async()=>{await A("PATCH",`/api/wallet/alerts/${s.id}/read`)},onSuccess:()=>{L.invalidateQueries({queryKey:["/api/wallet/alerts"]})}});return e.jsxs("div",{className:`flex items-start gap-3 p-3 rounded-lg ${s.readAt?"bg-muted/30":"bg-muted"}`,"data-testid":`alert-${s.id}`,children:[e.jsx("div",{className:`p-2 rounded-full ${s.alertType==="budget_exceeded"?"bg-red-100 text-red-600":s.alertType==="budget_warning"?"bg-amber-100 text-amber-600":"bg-blue-100 text-blue-600"}`,children:s.alertType==="budget_exceeded"?e.jsx(X,{className:"h-4 w-4"}):s.alertType==="budget_warning"?e.jsx(ge,{className:"h-4 w-4"}):e.jsx(be,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-sm",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.message}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:new Date(s.createdAt).toLocaleStr
11ing()})]}),!s.readAt&&e.jsx(N,{size:"sm",variant:"ghost",onClick:()=>r.mutate(),children:"Mark read"})]})}function ns({walletId:s}){const{data:r}=E({queryKey:["/api/wallet/alerts/preferences"]}),d=P({mutationFn:async i=>A("PATCH","/api/wallet/alerts/preferences",i),onSuccess:()=>{L.invalidateQueries({queryKey:["/api/wallet/alerts/preferences"]})}}),l=r==null?void 0:r.preferences;return e.jsxs(g,{"data-testid":"alert-preferences",children:[e.jsx(k,{children:e.jsxs(S,{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"h-5 w-5"}),"Alert Preferences"]})}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(q,{htmlFor:"alertsEnabled",children:"Enable Alerts"}),e.jsx(z,{id:"alertsEnabled",checked:(l==null?void 0:l.alertsEnabled)??!0,onCheckedChange:i=>d.mutate({alertsEnabled:i})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(q,{htmlFor:"lowBalanceAlert",children:"Low Balance Alerts"}),e.jsx(z,{id:"lowBalanceAlert",checked:(l==null?void 0:l.lowBalanceAlert)??!0,onCheckedChange:i=>d.mutate({lowBalanceAlert:i})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(q,{htmlFor:"budgetWarningAlert",children:"Budget Warnings"}),e.jsx(z,{id:"budgetWarningAlert",checked:(l==null?void 0:l.budgetWarningAlert)??!0,onCheckedChange:i=>d.mutate({budgetWarningAlert:i})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(q,{htmlFor:"aiRecommendationsEnabled",children:"AI Recommendations"}),e.jsx(z,{id:"aiRecommendationsEnabled",checked:(l==null?void 0:l.aiRecommendationsEnabled)??!0,onCheckedChange:i=>d.mutate({aiRecommendationsEnabled:i})})]})]})]})}function is({walletCurrency:s,currencies:r,onSuccess:d}){const{toast:l}=_(),[i,o]=h.useState("deposit"),[m,p]=h.useState(""),[v,j]=h.useState(s),[x,t]=h.useState(""),[b,c]=h.useState(""),y=P({mutationFn:async()=>A("POST","/api/wallet/transactions",{type:i,amountCents:Math.round(parseFloat(m)*100),currency:v,description:x,category:b}),onSuccess:()=>{l({title:"Transaction added!"}),d()},onError:()=>{l({title:"Failed to add transaction",variant:"destructive"})}});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(N,{variant:i==="deposit"?"default":"outline",onClick:()=>o("deposit"),className:"flex-1",children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),"Deposit"]}),e.jsxs(N,{variant:i==="spend"?"default":"outline",onClick:()=>o("spend"),className:"flex-1",children:[e.jsx(ve,{className:"h-4 w-4 mr-2"}),"Expense"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(I,{type:"number",placeholder:"Amount",value:m,onChange:a=>p(a.target.value),className:"flex-1","data-testid":"transaction-amount"}),e.jsxs(V,{value:v,onValueChange:j,children:[e.jsx(K,{className:"w-24",children:e.jsx(W,{})}),e.jsx(M,{children:(r.length>0?r:[s]).map(a=>e.jsx(T,{value:a,children:a},a))})]})]}),e.jsx(I,{placeholder:"Description (optional)",value:x,onChange:a=>t(a.target.value),"data-testid":"transaction-description"}),e.jsxs(V,{value:b,onValueChange:c,children:[e.jsx(K,{children:e.jsx(W,{placeholder:"Category (optional)"})}),e.jsxs(M,{children:[e.jsx(T,{value:"accommodation",children:"Accommodation"}),e.jsx(T,{value:"transport",children:"Transport"}),e.jsx(T,{value:"food",children:"Food & Dining"}),e.jsx(T,{value:"activities",children:"Activities"}),e.jsx(T,{value:"shopping",children:"Shopping"}),e.jsx(T,{value:"other",children:"Other"})]})]}),e.jsx(N,{onClick:()=>y.mutate(),disabled:!m||y.isPending,className:"w-full","data-testid":"submit-transaction",children:y.isPending?"Adding...":"Add Transaction"})]})}function ls({walletCurrency:s,currencies:r,onSuccess:d}){const{toast:l}=_(),[i,o]=h.useState(""),[m,p]=h.useState("trip"),[v,j]=h.useState(""),[x,t]=h.useState(s),[b,c]=h.useState(""),y=P({mutationFn:async()=>A("POST","/api/wallet/budgets",{name:i,scope:m,targetAmountCents:Math.round(parseFloat(v)*100),currency:x,endDate:b||void 0}),onSuccess:()=>{l({title:"Budget created!"}),d()},onError:()=>{l({title:"Failed to create budget",variant:"destructive"})}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(I,{placeholder:"Budget name",value:i,onChange:a=>o(a.target.value),"data-testid":"budget-name"}),e.jsxs(V,{value:m,onValueChange:a=>p(a),children:[e.jsx(K,{children:e.jsx(W,{placeholder:"Budget type"})}),e.jsxs(M,{children:[e.jsx(T,{value:"trip",children:"Trip Budget"}),e.jsx(T,{value:"daily",children:"Daily Budget"}),e.jsx(T,{value:"category",children:"Category Budget"})]})]}
11),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(I,{type:"number",placeholder:"Target amount",value:v,onChange:a=>j(a.target.value),className:"flex-1","data-testid":"budget-amount"}),e.jsxs(V,{value:x,onValueChange:t,children:[e.jsx(K,{className:"w-24",children:e.jsx(W,{})}),e.jsx(M,{children:(r.length>0?r:[s]).map(a=>e.jsx(T,{value:a,children:a},a))})]})]}),e.jsx(I,{type:"date",placeholder:"End date (optional)",value:b,onChange:a=>c(a.target.value),"data-testid":"budget-end-date"}),e.jsx(N,{onClick:()=>y.mutate(),disabled:!i||!v||y.isPending,className:"w-full","data-testid":"submit-budget",children:y.isPending?"Creating...":"Create Budget"})]})}function ds({ticket:s}){var i;const[r,d]=h.useState(!1);if(!((i=s.presentation)!=null&&i.allowed))return e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50/70 p-3 text-sm text-amber-800 dark:border-amber-900 dark:bg-amber-950/20 dark:text-amber-300",children:[e.jsx(X,{className:"h-4 w-4 shrink-0 mt-0.5"}),e.jsx("span",{children:"Credential hidden until provider provenance and compliance review are verified. This wallet entry is not authoritative proof of entry."})]});if(!s.credentialValue)return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground italic",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx("span",{children:"Credential pending â check back closer to the event"})]});const l=s.credentialType==="qr"?e.jsx(De,{className:"h-4 w-4 shrink-0"}):s.credentialType==="barcode"?e.jsx(Ye,{className:"h-4 w-4 shrink-0"}):e.jsx(oe,{className:"h-4 w-4 shrink-0"});return s.credentialType==="reference"?e.jsxs("div",{className:"flex items-center gap-2",children:[l,e.jsx("code",{className:"text-sm font-mono bg-muted px-2 py-1 rounded select-all",children:s.credentialValue})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>d(o=>!o),className:"flex items-center gap-2 text-sm text-primary hover:underline",children:[l,e.jsx("span",{children:r?"Hide credential":"Show credential for scanning"}),r?e.jsx(Qe,{className:"h-3 w-3"}):e.jsx(ze,{className:"h-3 w-3"})]}),r&&e.jsx("div",{className:"bg-white p-4 rounded-lg border flex items-center justify-center",children:e.jsx("code",{className:"text-xs font-mono break-all text-center max-w-xs select-all leading-relaxed",children:s.credentialValue})})]})}function xe({ticket:s,onClaim:r,isClaiming:d}){const l=s.source==="donated",i=s.status==="offered",o=s.status==="used",m=s.verificationStatus==="verified"&&s.complianceStatus==="verified",p=s.eventDate?new Date(s.eventDate).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric"}):null;return e.jsxs(g,{className:`relative overflow-hidden transition-all ${i?"border-amber-200 bg-amber-50/30 dark:bg-amber-950/10":o?"opacity-60":""}`,"data-testid":`ticket-card-${s.id}`,children:[e.jsx("div",{className:`absolute left-0 top-0 bottom-0 w-1 ${i?"bg-amber-400":o?"bg-muted-foreground/30":"bg-primary"}`}),e.jsxs(f,{className:"pl-5 pr-4 py-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"space-y-0.5 min-w-0",children:[e.jsx("p",{className:"font-semibold truncate","data-testid":`ticket-event-name-${s.id}`,children:s.eventName??"Event Ticket"}),s.venue&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:s.venue}),p&&e.jsx("p",{className:"text-xs text-muted-foreground",children:p})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[i&&e.jsx(C,{variant:"outline",className:"text-amber-600 border-amber-300 text-xs",children:"Reserved for you"}),o&&e.jsx(C,{variant:"secondary",className:"text-xs",children:"Used"}),s.dualVerifiedAt&&e.jsx(C,{className:"text-xs bg-green-600",children:"â Verified at door"}),!i&&!m&&e.jsx(C,{variant:"outline",className:"text-amber-700 border-amber-300 text-xs",children:"Pending review"}),l&&!i&&e.jsxs(C,{variant:"outline",className:"text-xs",children:[e.jsx(Ne,{className:"h-3 w-3 mr-1"}),"Reserved ticket"]})]})]}),i&&l&&e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-400",children:"A ticket has been reserved for you by a fellow chain member."}),!i&&e.jsx(ds,{ticket:s}),i&&e.jsxs(N,{size:"sm",onClick:()=>r(s.id),disabled:d,"data-testid":`ticket-claim-btn-${s.id}`,children:[d?e.jsx(fe,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx($,{className:"h-4 w-4 mr-2"}),"Add ticket to wallet"]}),s.externalBookingRef&&!i&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Provider reference:"," ",e.jsx("code",{className:"font-mono",children:s.externalBookingRef})]})]})]})}function cs({chainId:s,onDismiss:r}){return e.jsx(g,{className:"border-dashed border-primary/40 bg-primary/5","data-testid":"missing-ticket-nudge",children:e.jsxs(f,{className:"py-4 px-4 flex items-start gap-3",children:[e.jsx(X,{className:"h-5 w-5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Don't forget your ticket"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You have travel booked for this chain â pick up your event ticket and it'll live right here in your wallet."}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(N,{size:"sm",variant:"outline",className:"text-xs",asChild:!0,children:e.jsxs("a",{href:`/chain/${s}/ticket-options`,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(He,{className:"h-3 w-3 mr-1.5"}),"Find tickets"]})}),e.jsxs("button",{type:"button",onClick:r,className:"text-xs text-muted-foreground hover:text-foreground flex items-center gap-1","data-testid":"dismiss-nudge-btn",children:[e.jsx(Ee,{className:"h-3 w-3"}),"Not now"]})]})]})]})})}function os({userId:s,activeChainId:r}){const{toast:d}=_(),l=ke(),[i,o]=h.useState([]),[m,p]=h.useState(!navigator.onLine),[v,j]=h.useState(!1);h.useEffect(()=>{const u=()=>p(!1),B=()=>p(!0);return window.addEventListener("online",u),window.addEventListener("offline",B),()=>{window.removeEventListener("online",u),window.removeEventListener("offline",B)}},[]),h.useEffect(()=>{Se(s).then(o).catch(()=>{})},[s]);const{data:x,isLoading:t,error:b}=E({queryKey:["/api/ticket-wallet",s],queryFn:()=>A("/api/ticket-wallet"),enabled:!m,staleTime:1e3*60*2});h.useEffect(()=>{var u;if((u=x==null?void 0:x.tickets)!=null&&u.length){const B=x.tickets.filter(w=>w.status==="confirmed"||w.status==="offered").map(w=>({id:w.id,userId:w.userId,chainId:w.chainId,stopId:w.stopId,credentialType:w.credentialType,eventName:w.eventName,eventDate:w.eventDate,venue:w.venue,source:w.source,status:w.status,provenanceType:w.provenanceType,verificationStatus:w.verificationStatus,complianceStatus:w.
11complianceStatus,presentation:{allowed:!1,state:"offline_metadata_only"},cachedAt:Date.now()}));Te(s).then(()=>Ae(B)).catch(()=>{})}},[x,s]);const{data:c}=E({queryKey:["/api/ticket-wallet/nudge",r],queryFn:()=>A(`/api/ticket-wallet/nudge/${r}`),enabled:!!r&&!m&&!v,staleTime:1e3*60*5}),y=P({mutationFn:u=>A(`/api/ticket-wallet/${u}/claim`,{method:"PATCH",body:{}}),onSuccess:()=>{l.invalidateQueries({queryKey:["/api/ticket-wallet",s]}),d({title:"Ticket added to your wallet"})},onError:()=>{d({title:"Could not claim ticket",variant:"destructive"})}}),a=P({mutationFn:()=>A("/api/ticket-wallet/nudge-dismiss-for-chain",{method:"POST",body:{chainId:r}}),onSuccess:()=>j(!0)}),D=h.useCallback(()=>{j(!0),a.mutate()},[a]),H=(x==null?void 0:x.tickets)??[],F=m?i:H,n=F.filter(u=>u.status!=="expired"),Q=!!r&&(c==null?void 0:c.shouldNudge)===!0&&!v&&!n.some(u=>u.chainId===r&&u.status!=="expired");return t?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground py-4",children:[e.jsx(fe,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading ticketsâ¦"})]}):e.jsxs("div",{className:"space-y-4","data-testid":"ticket-wallet-section",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5 text-primary"}),e.jsx("h2",{className:"font-semibold text-lg",children:"Event Tickets"}),m&&e.jsx(C,{variant:"outline",className:"text-xs text-muted-foreground",children:"Offline"})]}),n.length>0&&e.jsx(C,{variant:"secondary",className:"text-xs",children:n.length})]}),e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-amber-200 bg-amber-50/70 p-3 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950/20 dark:text-amber-200","data-testid":"ticket-wallet-compliance-gate",children:[e.jsx(X,{className:"h-4 w-4 shrink-0 mt-0.5"}),e.jsxs("p",{children:[e.jsx("strong",{children:"Ticket custody is verification-gated."})," User-entered credentials are retained for review only and are never treated as authoritative. Ticketmaster-compatible presentation is unavailable pending counsel approval."]})]}),Q&&e.jsx(cs,{chainId:r,onDismiss:D}),n.length===0&&!Q?e.jsxs("div",{className:"text-center py-8 text-muted-foreground space-y-2","data-testid":"no-tickets-state",children:[e.jsx($,{className:"h-10 w-10 mx-auto opacity-30"}),e.jsx("p",{className:"text-sm",children:"No event tickets in your wallet yet."}),e.jsx("p",{className:"text-xs",children:"Buy or access tickets through a chain stop and they'll appear here."})]}):e.jsx("div",{className:"space-y-3",children:n.map(u=>e.jsx(xe,{ticket:u,onClaim:B=>y.mutate(B),isClaiming:y.isPending&&y.variables===u.id},u.id))}),F.filter(u=>u.status==="used").length>0&&e.jsxs("details",{className:"text-sm text-muted-foreground","data-testid":"used-tickets-section",children:[e.jsxs("summary",{className:"cursor-pointer hover:text-foreground select-none",children:["Past tickets (",F.filter(u=>u.status==="used").length,")"]}),e.jsx("div",{className:"mt-3 space-y-3",children:F.filter(u=>u.status==="used").map(u=>e.jsx(xe,{ticket:u,onClaim:B=>y.mutate(B),isClaiming:!1},u.id))})]})]})}function Os(){const{user:s,isLoading:r}=Pe();return h.useEffect(()=>{document.title="Travel Wallet | Slant"},[]),r?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-2 border-primary border-t-transparent"})}):s?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold","data-testid":"wallet-page-title",children:"Travel Wallet"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Track your travel budget and get smart recommendations"})]}),e.jsx(Ze,{userId:s.id}),e.jsx(Be,{className:"my-8"}),e.jsx(os,{userId:s.id})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",children:e.jsxs(g,{className:"max-w-md w-full","data-testid":"wallet-login-prompt",children:[e.jsxs(k,{className:"text-center",children:[e.jsx(ee,{className:"h-16 w-16 mx-auto text-primary mb-4"}),e.jsx(S,{children:"Travel Wallet"}),e.jsx(U,{children:"Sign in to access your travel wallet, manage budgets, and get personalized recommendations."})]}),e.jsx(f,{children:e.jsxs(N,{className:"w-full gap-2",onClick:()=>window.location.href="/api/login","data-testid":"wallet-login-btn",children:[e.jsx(Ge,{className:"h-4 w-4"}),"Sign In to Continue"]})})]})})}export{Os 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.