1import{j as e}from"./client-6l7EspPw.js";import{f as F,r as f}from"./vendor-react-DrAGubKe.js";import{g as R,b as Y,t as E,d as B,s as k}from"./AuthContext-Da0jsCTA.js";import{l as W}from"./caseErrors-D0obiOnF.js";import{L as q}from"./Logo-DZCcYyPu.js";import{p as z}from"./amountInput-C8o4E8Fw.js";import{c as U}from"./dateInput-B3NeGUYe.js";import{P,F as G,a as H,b as C}from"./statutoryFigures-HphCr-wQ.js";import{c as $}from"./toolState-Cd1-8LYn.js";import{F as J}from"./RegulatoryDisclosure-ClrQ7yEU.js";import{A as K}from"./arrow-left-B_Y9uKBg.js";import{S as Q}from"./shield-BvLKIk6-.js";import{A as w}from"./arrow-right-XiJyea2j.js";import{L as V}from"./loader-2-BclJuvEm.js";import"./vendor-supabase-ClVc2H6D.js";import"./createLucideIcon-DS0XArz4.js";import"./useCase-DbZsBpjn.js";import"./CaseContext-BSmid7v3.js";import"./track-fqGQEj0M.js";const j="smc_sr_onboarding_v1",D={situation:null,incidentDate:null,amount:null},X=[{id:"app",title:"I sent money I shouldnât have",subtitle:"Bank transfer scam â you were tricked into authorising the payment",situations:[{value:"app_fraud",label:"I made a bank transfer to a scammer",hint:"Authorised Push Payment fraud â covered by the PSR mandatory refund scheme since Oct 2024"}]},{id:"investment",title:"I lost money to a fake investment",subtitle:"Crypto, forex, romance-investment, share scams",situations:[{value:"investment_scam",label:"I was scammed into investing",hint:"Fake platform, fake broker, or pressure to put more in to ârelease profitsâ"}]},{id:"card",title:"My card was used without permission",subtitle:"Unauthorised card transactions or stolen card details",situations:[{value:"card_fraud",label:"Unauthorised card transaction",hint:"Charges you didnât make â often via stolen card details or skimming"}]},{id:"refused",title:"My bank refused my refund",subtitle:"You reported fraud and the bank declined to refund",situations:[{value:"refund_refused",label:"My bank said Iâm not eligible for a refund",hint:"The software helps you prepare your own Financial Ombudsman complaint"}]},{id:"other",title:"Something else",subtitle:"A different fraud or scam situation",situations:[{value:"other",label:"My situation doesnât fit the above",hint:"Weâll still help you work out where you stand"}]}];function je(){const n=F(),[i,c]=f.useState(()=>{try{const s=localStorage.getItem(j);if(s)return JSON.parse(s).step??"situation"}catch{}return"situation"}),[t,p]=f.useState(()=>{try{const s=localStorage.getItem(j);if(s)return{...D,...JSON.parse(s).answers}}catch{}return D}),[x,g]=f.useState(null),[h,a]=f.useState(!1),[o,r]=f.useState(null);f.useEffect(()=>{try{localStorage.setItem(j,JSON.stringify({step:i,answers:t}))}catch{}},[i,t]);function l(s,d){p(u=>({...u,...s})),c(d)}function A(){if(i==="situation"){n("/onboarding");return}if(i==="when"){c("situation");return}if(i==="amount"){c("when");return}if(i==="result"){c("amount");return}}function O(){n("/start")}async function T(){var S,_,I;if(h)return;a(!0),r(null);const{data:{session:s}}=await k.auth.getSession(),d=s==null?void 0:s.user;if(!d){a(!1),r("Your session has expired. Please sign out and back in.");return}try{await k.functions.invoke("ensure-profile",{})}catch{}let u=null;const{data:m}=await k.from("cases").select("id, metadata").eq("user_id",d.id).eq("wizard_completed",!1).order("created_at",{ascending:!1}).limit(1);if(m&&m.length>0)u=m[0].id;else{const{data:y,error:b}=await k.from("cases").insert({title:"My Scam Refund Claim",status:"assessment",tier:"free",wizard_step:1,user_id:d.id}).select("id");if(b||!y||y.length===0){if(a(!1),(S=b==null?void 0:b.message)!=null&&S.startsWith("free_case_limit_reached_for_track"))r("You've already opened 3 free scam-refund cases. Open an existing case from the dashboard, or upgrade one to start a new one.");else{const v=W(b,"scam-refund:case-insert",{userId:d.id});r(`Could not create your case. Please sign out, sign back in, and try again.${v}`)}return}u=y[0].id}const L=m&&m.length>0?m[0].metadata??{}:{},N={claim_types:["scam_refund_track"],situation:"other",wizard_step:1,wizard_completed:!0};t.incidentDate&&(N.effective_date_of_termination=t.incidentDate),(t.amount!=null||t.situation)&&(N.metadata={...L,...t.amount!=null?{claim_amount:String(t.amount)}:{},...t.situation?{scam_bucket:t.situation}:{}});const{error:M}=await k.from("cases").update(N).eq("id",u);if(M){a(!1),r("Could not save your case details â please check your connection and try again.");return}k.functions.invoke("send-welcome-email",{body:{email:d.email??"",firstName:((I=(_=d.user_metadata)==null?void 0:_.full_name)==null?void 0:I.split(" ")[0])??void 0,situation:t.situation==="other"?"sr_other":t.situation??"sr_other",caseId:u??void 0}}).catch(()=>{});try{localStorage.removeItem(j)}catch{}try{sessionStorage.setItem("smc_just_finished_onboarding","1")}
1catch{}try{u&&localStorage.setItem("smc_active_case_id",u)}catch{}$("sr");for(let y=0;y<12;y++){const{data:b}=await k.from("cases").select("id").eq("user_id",d.id).eq("wizard_completed",!0).not("situation","is",null).limit(1);if(b&&b.length>0)break;await new Promise(v=>setTimeout(v,250))}window.location.href="/start"}return e.jsxs("div",{className:"min-h-screen bg-surface-page flex flex-col",children:[e.jsx("div",{className:"bg-white border-b border-ink-border",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-5 flex items-center justify-between",children:[e.jsxs("button",{onClick:A,className:"flex items-center gap-1.5 text-sm text-ink-muted hover:text-ink font-medium transition-colors",children:[e.jsx(K,{className:"h-4 w-4"}),i==="situation"?"Pick a different area":"Back"]}),e.jsx(q,{size:"md",variant:"dark",noLink:!0}),e.jsx("button",{onClick:O,className:"text-xs text-ink-muted hover:text-ink font-medium transition-colors",children:"Save and come back later"})]})}),e.jsxs("div",{className:"flex-1 px-4 py-6 sm:px-6 sm:py-10 max-w-lg mx-auto w-full",children:[i==="situation"&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-widest text-ink-soft mb-3",children:"Step 1 · What happened?"}),e.jsx("h1",{className:"text-3xl font-semibold text-ink leading-tight tracking-tight mb-3",children:"Weâre sorry this happened. Here is the route to a refund."}),e.jsx("p",{className:"text-sm text-ink-soft leading-relaxed mb-2",children:"Most fraud victims are entitled to a refund. The path depends on how it happened â pick whichever fits closest."}),e.jsxs("p",{className:"text-[11px] text-ink-muted flex items-center gap-1.5 mb-7",children:[e.jsx(Q,{className:"h-3 w-3"}),"Stays private. We never contact your bank or anyone else without your consent."]}),e.jsx("div",{className:"space-y-2",children:X.map(s=>{const d=x===s.id,u=s.situations.length===1;return e.jsxs("div",{className:`bg-white border rounded-2xl overflow-hidden shadow-sm transition-all ${d?"border-ink ring-1 ring-ink":"border-ink-border hover:border-ink-soft hover:shadow-md"}`,children:[e.jsxs("button",{onClick:()=>{if(u){l({situation:s.situations[0].value},"when");return}g(d?null:s.id)},className:"w-full px-5 py-4 text-left flex items-center justify-between hover:bg-surface-page transition-all group",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-ink mb-0.5",children:s.title}),e.jsx("p",{className:"text-xs text-ink-muted",children:s.subtitle})]}),e.jsx("span",{className:"text-ink-faint text-xl font-light ml-4 group-hover:text-ink-muted transition-colors",children:u?"âº":d?"â":"+"})]}),d&&!u&&e.jsx("div",{className:"border-t border-ink-border bg-ink-bg/50 divide-y divide-ink-border",children:s.situations.map(m=>e.jsxs("button",{onClick:()=>l({situation:m.value},"when"),className:"w-full px-5 py-3.5 text-left flex items-center justify-between hover:bg-white transition-colors",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-ink",children:m.label}),m.hint&&e.jsx("p",{className:"text-xs text-ink-muted mt-0.5",children:m.hint})]}),e.jsx("span",{className:"text-ink-faint text-lg font-light ml-4",children:"âº"})]},m.value))})]},s.id)})})]}),i==="when"&&e.jsx(Z,{value:t.incidentDate,onContinue:s=>l({incidentDate:s},"amount"),onUnsure:()=>l({incidentDate:null},"amount")}),i==="amount"&&e.jsx(ee,{value:t.amount,onContinue:s=>l({amount:s},"result"),onSkip:()=>l({amount:null},"result")}),i==="result"&&e.jsx(te,{answers:t,onContinue:T,saving:h,saveError:o,onSeePricing:()=>n("/scam-recovery/choose-plan")})]}),e.jsx("footer",{className:"border-t border-ink-border bg-white px-6 py-6 mt-auto",children:e.jsx(J,{className:"max-w-3xl mx-auto text-[11px] text-ink-muted leading-relaxed"})})]})}function Z({value:n,onContinue:i,onUnsure:c}){const t=f.useId(),p=`${t}-error`,[x,g]=f.useState(n??""),h=new Date().toISOString().split("T")[0],a=(()=>{const l=new Date;return l.setFullYear(l.getFullYear()-6),l.toISOString().split("T")[0]})(),{valid:o,error:r}=U(x,a,h,"more than six years ago");return e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-widest text-ink-muted mb-3",children:"Step 2 · When"}),e.jsx("h2",{className:"text-2xl font-semibold text-ink leading-tight tracking-tight mb-3",children:"When did the fraud happen?"}),e.jsxs("p",{className:"text-sm text-ink-muted leading-relaxed mb-6",children:["You generally have ",e.jsx("strong",{children:P})," from the last fraudulent payment to claim from the bank under the PSR scheme, and ",e.jsx("strong",{children:G})," from the bankâs final response to escalate to the Financial Ombudsman."]}),e.jsx("label",{htmlFor:t,className:"block text-xs font-bold uppercase tracking-widest text-ink-muted mb-2",children:"Date of the last payment to the scammer"}),e.jsx("input",{id:t,type:"date",value:x,min:a,max:h,onChange:l=>g(l.target.value),"aria-invalid":r?!0:void 0,"aria-describedby":r?p:void 0,className:"w-full px-4 py-3.5 rounded-xl bg-white border border-ink-border focus:border-ink focus:ring-1 focus:ring-ink outline-none text-ink mb-3"}),r&&e.jsx("p",{id:p,role:"alert",className:"text-xs font-medium mb-3 leading-relaxed",style:{color:"#b91c1c"},children:r}),e.jsxs("button",{onClick:()=>o&&i(x),disabled:!o,className:"w-full font-bold text-sm rounded-xl py-4 flex items-center justify-center gap-2 bg-ink text-white hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed mb-2",children:["Continue ",e.jsx(w,{className:"h-4 w-4"})]}),e.jsx("button",{onClick:c,className:"w-full text-center text-xs text-ink-muted hover:text-ink transition-colors font-medium py-2",children:"Iâm not sure"})]})}function ee({value:n,onContinue:i,onSkip:c}){const t=f.useId(),p=`${t}-error`,[x,g]=f.useState(n!=null?String(n):""),{n:h,valid:a,error:o}=z(x,1e6);return e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-widest text-ink-muted mb-3",children:"Step 3 · How much"}),e.jsx("h2",{className:"text-2xl font-semibold text-ink leading-tight tracking-tight mb-3",children:"Roughly how much did you lose?"}),e.jsxs("p",{className:"text-sm text-ink-muted leading-relaxed mb-6",children:["The PSR mandatory refund scheme covers APP fraud up to ",e.jsx("strong",{children:C})," per claim, and the Financial Ombudsman can award up to ",H," if the bank rejects you. Donât worry about exact figures â a rough total is fine."]}),e.jsxs("label",{htmlFor:t,className:"block text-xs font-bold uppercase tracking-widest text-ink-muted mb-2",children:["Amount in £",e.jsx("span",{className:"text-accent ml-0.5","aria-hidden":"true",children:"*"}),e.jsx("span",{className:"sr-only",children:" (required)"})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-ink-muted","aria-hidden":"true",children:"£"}),e.jsx("input",{id:t,required:!0,type:"text",inputMode:"decimal",value:x,onChange:r=>g(r.target.value),placeholder:"e.g. 2500","aria-invalid":o?!0:void 0,"aria-describedby":o?p:void 0,className:"w-full pl-9 pr-4 py-3.5 rounded-xl bg-white border border-ink-border focus:border-ink focus:ring-1 focus:ring-ink outline-none text-ink"})]}),o&&e.jsx("p",{id:p,role:"alert",className:"text-xs font-medium mb-3 leading-relaxed",style:{color:"#b91c1c"},children:o}),e.jsxs("button",{onClick:()=>a&&i(h),disabled:!a,className:"w-full font-bold text-sm rounded-xl py-4 flex items-center justify-center gap-2 bg-ink text-white hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed mb-2",children:["Continue ",e.jsx(w,{className:"h-4 w-4"})]}),e.jsx("button",{onClick:c,className:"w-full text-center text-xs text-ink-muted hover:text-ink transition-colors font-medium py-2",children:"Iâm not sure yet"})]})}function te({answers:n,onContinue:i,saving:c,saveError:t,onSeePricing:p}){const x=(()=>{const a=R();return!a||!Y(a)||E(a)!=="sr"?null:B(a)})(),g={app_fraud:"Authorised Push Payment fraud",investment_scam:"Investment / crypto scam",card_fraud:"Unauthorised card transactions",refund_refused:"Bank refused refund",other:"Other fraud"},h=n.situation;return e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-widest text-ink-muted mb-3",children:"Your case is ready"}),e.jsx("h2",{className:"text-2xl font-semibold text-ink leading-tight tracking-tight mb-3",children:"Here is the route to claiming it back."}),e.jsx("p",{className:"text-sm text-ink-muted leading-relaxed mb-6",children:"You can pause anytime. Nothing is sent to your bank or the Ombudsman until youâre ready."}),e.jsxs("div",{className:"rounded-2xl border border-ink-border p-5 mb-3 bg-white",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-widest text-ink-muted mb-3",children:"What we know"}),e.jsxs("ul",{className:"space-y-2",children:[h&&e.jsxs("li",{className:"text-sm text-ink-soft flex gap-2",children:[e.jsx("span",{className:"text-ink-faint",children:"â¢"}),g[h]]}),n.incidentDate&&e.jsxs("li",{className:"text-sm text-ink-soft flex gap-2",children:[e.jsx("span",{className:"text-ink-faint",children:"â¢"}),"Incident: ",new Date(n.incidentDate).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})]}),n.amount!=null&&e.jsxs("li",{className:"text-sm text-ink-soft flex gap-2",children:[e.jsx("span",{className:"text-ink-faint",children:"â¢"}
1),"Loss: £",n.amount.toLocaleString("en-GB")]})]})]}),(()=>{if(!n.incidentDate)return null;const a=new Date(n.incidentDate);if(isNaN(a.getTime()))return null;const o=new Date(a);o.setMonth(o.getMonth()+13);const r=Math.ceil((o.getTime()-Date.now())/864e5),l=(n.amount??0)<=85e3;return e.jsxs("div",{className:"rounded-2xl border border-blue-200 bg-blue-50 p-5 mb-3",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-widest text-blue-800 mb-3",children:"What we can already tell you â free"}),e.jsxs("ul",{className:"space-y-2.5",children:[r>0?e.jsxs("li",{className:"text-sm text-blue-900 flex gap-2",children:[e.jsx("span",{className:"text-blue-600 font-bold flex-shrink-0",children:"â"}),e.jsxs("span",{children:["You're inside the reporting window. Banks must consider claims made within ",e.jsx("strong",{children:P})," of the payment â for you that's until ",e.jsx("strong",{children:o.toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})}),r<=90?e.jsxs(e.Fragment,{children:[" â ",e.jsxs("strong",{children:[r," days away"]}),", so don't sit on it"]}):null,"."]})]}):e.jsxs("li",{className:"text-sm text-blue-900 flex gap-2",children:[e.jsx("span",{className:"text-blue-600 font-bold flex-shrink-0",children:"!"}),e.jsxs("span",{children:["The standard ",e.jsx("strong",{children:"13-month"})," reporting window from your incident date has passed â but that's not always the end of it. The dashboard walks through the exceptions worth checking before you write it off."]})]}),l&&(n.amount??0)>0&&e.jsxs("li",{className:"text-sm text-blue-900 flex gap-2",children:[e.jsx("span",{className:"text-blue-600 font-bold flex-shrink-0",children:"â"}),e.jsxs("span",{children:["Your £",(n.amount??0).toLocaleString("en-GB")," loss is inside the mandatory reimbursement scheme's ",e.jsx("strong",{children:C})," cap â banks must reimburse eligible authorised push payment fraud, not just as a goodwill gesture."]})]}),e.jsxs("li",{className:"text-sm text-blue-900 flex gap-2",children:[e.jsx("span",{className:"text-blue-600 font-bold flex-shrink-0",children:"â"}),e.jsxs("span",{children:["Every step of this route is ",e.jsx("strong",{children:"free to use"})," â the bank claim costs nothing, and if they refuse, the Financial Ombudsman Service is free and its decisions bind the bank."]})]})]})]})})(),e.jsxs("div",{className:"rounded-2xl border border-ink-border p-5 mb-6 bg-white",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-widest text-ink-muted mb-3",children:"In your dashboard, ready to use"}),e.jsxs("ul",{className:"space-y-2.5",children:[e.jsxs("li",{className:"text-sm text-ink-soft flex items-center gap-3",children:[e.jsx("span",{className:"h-6 w-6 rounded-full bg-ink-bg border border-ink-border flex items-center justify-center text-xs font-bold text-ink-muted flex-shrink-0",children:"1"}),"Bank refund-claim builder (PSR scheme)"]}),e.jsxs("li",{className:"text-sm text-ink-soft flex items-center gap-3",children:[e.jsx("span",{className:"h-6 w-6 rounded-full bg-ink-bg border border-ink-border flex items-center justify-center text-xs font-bold text-ink-muted flex-shrink-0",children:"2"}),"FOS escalation guide + AI Companion drafting"]}),e.jsxs("li",{className:"text-sm text-ink-soft flex items-center gap-3",children:[e.jsx("span",{className:"h-6 w-6 rounded-full bg-ink-bg border border-ink-border flex items-center justify-center text-xs font-bold text-ink-muted flex-shrink-0",children:"3"}),"Action Fraud + Police report templates"]})]})]}),t&&e.jsx("div",{className:"mb-4 px-4 py-3 rounded-xl bg-ink-bg border border-ink-border text-xs text-ink-soft font-medium",children:t}),e.jsx("button",{onClick:i,disabled:c,className:"w-full font-bold text-sm rounded-xl py-4 flex items-center justify-center gap-2 bg-ink text-white hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed mb-2",children:c?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 animate-spin"})," Setting up your caseâ¦"]}):x?e.jsxs(e.Fragment,{children:["Continue to checkout â ",x," ",e.jsx(w,{className:"h-4 w-4"})]}):e.jsxs(e.Fragment,{children:["Take me to my dashboard ",e.jsx(w,{className:"h-4 w-4"})]})}
1),e.jsx("button",{onClick:p,disabled:c,className:"w-full text-center text-xs text-ink-muted hover:text-ink transition-colors font-medium py-2",children:"Or see pricing first"})]})}export{je as ScamRefundOnboarding,je 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.