1import{j as e}from"./client-6l7EspPw.js";import{f as He,u as Pe,r as l}from"./vendor-react-DrAGubKe.js";import{u as $e}from"./useCase-DbZsBpjn.js";import{u as Me}from"./useCheckout-QFVSHClh.js";import{d as Ue,u as Ye,e as Fe,c as Le}from"./arrow-right-XiJyea2j.js";import{u as qe,s as g}from"./AuthContext-Da0jsCTA.js";import{a as Ke}from"./ai-CvcIsWpV.js";import{A as Be,a as me,r as Ge}from"./documentReader-CAIiP9Ap.js";import{f as Qe,b as ze}from"./observations-Bw0sHKgo.js";import{i as ge}from"./track-fqGQEj0M.js";import{r as Ze}from"./CaseContext-BSmid7v3.js";import{b as Je}from"./statutoryFigures-HphCr-wQ.js";import{P as Ve}from"./plus-Lb0-KRFM.js";import{M as Xe}from"./message-circle-BgJcQfos.js";import{T as De}from"./trash-2-D_fWyk50.js";import{S as et}from"./sparkles-CPsOKSn7.js";import{C as _}from"./chevron-right-Cyiwl33P.js";import{S as xe}from"./scale-C4Dgi2Ev.js";import{P as F}from"./paperclip-CChyDiph.js";import{Z as be}from"./zap-2hpQToIR.js";import{L as z}from"./loader-2-BclJuvEm.js";import{A as tt}from"./alert-circle-DIPP5_5L.js";import{X as nt}from"./x-D80-oRFr.js";import{S as st}from"./send-Dt4urioQ.js";import{M as rt,r as it}from"./index-5xXurRC5.js";import"./createLucideIcon-DS0XArz4.js";import"./vendor-supabase-ClVc2H6D.js";import"./deadlines-BeAV6-jB.js";const ot=[{group:"Your claim",text:"What are my chances of winning this case?"},{group:"Your claim",text:"What is the difference between unfair and wrongful dismissal?"},{group:"Your claim",text:"Can I claim constructive dismissal if I resigned?"},{group:"Your claim",text:"How long do I have to file an ET1 claim?"},{group:"The process",text:"What happens at an employment tribunal hearing?"},{group:"The process",text:"Do I need a solicitor to represent me at tribunal?"},{group:"The process",text:"What is an ET3 and what should I look for in it?"},{group:"The process",text:"What will happen at a preliminary hearing?"},{group:"Evidence",text:"What evidence do I need to support my claim?"},{group:"Evidence",text:"Can I request documents and emails from my employer?"},{group:"Evidence",text:"How do I write a witness statement for tribunal?"},{group:"Evidence",text:"Check my witness statement and ET1 for inconsistencies â I will upload both documents."},{group:"Remedies",text:"How is compensation calculated for unfair dismissal?"},{group:"Remedies",text:"Should I settle or take my case to tribunal?"},{group:"Remedies",text:"What is an ACAS settlement and how does it work?"},{group:"Remedies",text:"What should I include in my Schedule of Loss?"},{group:"Strategy",text:"What strategic moves can I make to strengthen my position?"},{group:"Strategy",text:"How can I put pressure on my employer to settle?"}],at=[{group:"Your claim",text:"What counts as breach of contract under English law?"},{group:"Your claim",text:"Is my claim suitable for the small claims track?"},{group:"Your claim",text:"What is the difference between small claims, fast track and multi-track?"},{group:"Your claim",text:"How much can I claim in interest under section 69 of the County Courts Act?"},{group:"The process",text:"What happens after I file an N1 claim form?"},{group:"The process",text:"What is a Letter Before Action and why does it matter?"},{group:"The process",text:"How long does a small claims case usually take?"},{group:"The process",text:"What happens at a small claims hearing?"},{group:"Evidence",text:"What evidence do I need to prove my small claim?"},{group:"Evidence",text:"How should I organise documents for the court bundle?"},{group:"Evidence",text:"Can I use emails and text messages as evidence?"},{group:"Costs & enforcement",text:"What court fees will I have to pay?"},{group:"Costs & enforcement",text:"What can I do if the defendant ignores the judgment?"},{group:"Costs & enforcement",text:"What is a CCJ and how does it affect the defendant?"},{group:"Strategy",text:"Should I accept a part-payment offer or hold out for the full amount?"},{group:"Strategy",text:"How do I respond if the defendant counterclaims?"}],lt=[{group:"Your case",text:"How do I check if my landlord has the licence they should have?"},{group:"Your case",text:"What counts as a Rent Repayment Order offence?"}
1,{group:"Your case",text:"How is the RRO award amount decided by the tribunal?"},{group:"Your case",text:"Can I claim for the deposit and rent at the same time?"},{group:"Notices",text:"How do I check if my Section 8 notice is valid?"},{group:"Notices",text:"How do I check if my Form 4A rent increase notice is valid?"},{group:"Notices",text:"What is the difference between a Section 8 notice and a Form 4A, and what happened to Section 21?"},{group:"The process",text:"What happens at a First-tier Tribunal Property Chamber hearing?"},{group:"The process",text:"Do I need a solicitor for an RRO application?"},{group:"The process",text:"How long does an RRO application take from filing to decision?"},{group:"Evidence",text:"What evidence do I need to support an RRO application?"},{group:"Evidence",text:"How do I write a witness statement for the Property Chamber?"},{group:"Evidence",text:"How do I prove unlicensed letting?"},{group:"Defending eviction",text:"How do I defend a Section 8 possession claim on Ground 8?"},{group:"Defending eviction",text:"What is the discretion test for Grounds 10 and 11?"},{group:"Defending eviction",text:"Can I get legal aid for possession defence?"},{group:"Strategy",text:"Should I challenge a rent increase before it takes effect?"},{group:"Strategy",text:"How can I put pressure on my landlord to settle?"}],dt=[{group:"Your refund",text:"Will my bank refund me under the PSR Mandatory Reimbursement Scheme?"},{group:"Your refund",text:"What counts as Authorised Push Payment (APP) fraud?"},{group:"Your refund",text:"What is the "+Je+" cap and does it apply to my claim?"},{group:"Your refund",text:"How long do I have to claim â what is the 13-month rule?"},{group:"The bank",text:'What does "gross negligence" mean and can the bank refuse on those grounds?'},{group:"The bank",text:"What is Confirmation of Payee and does ignoring it count against me?"},{group:"The bank",text:"How long does the bank have to investigate and respond?"},{group:"The bank",text:"What should be in my bank complaint letter?"},{group:"Evidence",text:"What evidence do I need to support my refund claim?"},{group:"Evidence",text:"How do I write a clear chronology of the fraud?"},{group:"Evidence",text:"What screenshots and messages should I preserve?"},{group:"FOS escalation",text:"When can I escalate to the Financial Ombudsman Service?"},{group:"FOS escalation",text:'How does the FOS "fair and reasonable" test work?'},{group:"FOS escalation",text:"How long does the FOS take to decide a case?"},{group:"Other routes",text:"Can I claim under Section 75 or chargeback for card payments?"},{group:"Other routes",text:"What if the payment was an international transfer?"}],he={discrimination:[{group:"Discrimination",text:"What counts as direct discrimination under the Equality Act?"},{group:"Discrimination",text:"What are Vento bands and how is injury to feelings calculated?"},{group:"Discrimination",text:"Can I claim for both unfair dismissal and discrimination?"}],whistleblowing:[{group:"Whistleblowing",text:"What counts as a protected disclosure?"},{group:"Whistleblowing",text:"What protection do I have after making a disclosure?"}],redundancy:[{group:"Redundancy",text:"How is my statutory redundancy payment calculated?"},{group:"Redundancy",text:"What makes a redundancy process unfair?"},{group:"Redundancy",text:"Am I entitled to appeal my redundancy selection?"}],constructive_dismissal:[{group:"Constructive dismissal",text:"What is a fundamental breach of contract?"},{group:"Constructive dismissal",text:"Do I need to raise a grievance before resigning?"}]};function pe(t){switch(t){case"sc":return at;case"sr":return dt;case"rr":return lt;default:return ot}}function ct(t){return t!=="sc_core"&&Le(t)}function E(t,i){return t==="sc"?(i==null?void 0:i.title)??"your small claim":t==="sr"?(i==null?void 0:i.title)??"your refund claim":t==="rr"?(i==null?void 0:i.title)??"your housing case":(i==null?void 0:i.employer_name)??"your employer"}function ut(t,i){return t==="sc"?"I've read your small claim. Ask me anything â what counts as breach of contract, how to draft an N1, court fees, evidence, or what to expect at the hearing.":t==="sr"?`I've read your refund claim against ${E("sr",i)}. Ask me anything â the PSR scheme, the 13-month deadline, gross
1negligence, evidence, or escalating to the Financial Ombudsman.`:t==="rr"?`I've read ${E("rr",i)}. Ask me anything â RRO grounds, notice validity, the 12-month limitation, evidence, or what to expect at the Property Chamber.`:`I've read your case against ${E("et",i)}. Ask me anything â strategy, documents, next steps, or what to expect at tribunal.`}function fe(t){return t==="sc"?"Ask anything about UK small claims, breach of contract, or the County Court process.":t==="sr"?"Ask anything about UK scam refunds, the PSR scheme, or escalating to the Financial Ombudsman.":t==="rr"?"Ask anything about UK renters' rights, Rent Repayment Orders, rent increase challenges, or possession defence at the Property Chamber.":"Ask anything about UK employment law, the tribunal process, or your rights."}function mt(t,i){return t==="sc"?"Ask about your small claimâ¦":t==="sr"?`Ask about your refund claim against ${E("sr",i)}â¦`:t==="rr"?`Ask about ${E("rr",i)}â¦`:`Ask about your case against ${E("et",i)}â¦`}function xt(t,i){return i?t==="sc"?`${i.title??"Small claim"} · Small Claims`:t==="sr"?`${i.title??"Refund claim"} · Scam Refund`:t==="rr"?`${i.title??"Housing case"} · Renters' Rights`:`${i.employer_name??"Your case"} · ${(i.claim_types??[]).map(a=>a.replace(/_/g," ")).join(", ")}`:t==="sc"?"Your UK small claims guide":t==="sr"?"Your UK scam refund guide":t==="rr"?"Your UK renters' rights guide":"Your UK employment law guide"}function ht(t,i){const a=(t==null?void 0:t.wizard_data)??{},d=ge(t),v={track:d,caseId:t==null?void 0:t.id,caseTitle:(t==null?void 0:t.title)??"Untitled case",claimTypes:((t==null?void 0:t.claim_types)??[]).map(L=>L.replace(/_/g," ")).join(", ")||"not yet assessed",tier:i};if(d==="sc")return{...v,defendantName:a.defendantName??(t==null?void 0:t.title)??"the defendant",amountClaimed:a.amountClaimed??"not provided",incidentDate:(t==null?void 0:t.effective_date_of_termination)??"unknown",whatHappened:a.whatHappened??""};if(d==="sr")return{...v,bankName:a.bankName??"the sending bank",amountLost:a.amountLost??"not provided",paymentDate:(t==null?void 0:t.effective_date_of_termination)??"unknown",whatHappened:a.whatHappened??""};if(d==="rr")return{...v,offenceStartDate:(t==null?void 0:t.offence_start_date)??"unknown",whatHappened:a.whatHappened??""};const H=Ze(t);return{...v,employerName:(t==null?void 0:t.employer_name)??"their employer",jobTitle:(t==null?void 0:t.job_title)??"their role",salary:t!=null&&t.annual_salary?String(t.annual_salary):void 0,startDate:(t==null?void 0:t.employment_start_date)??"unknown",edt:(t==null?void 0:t.effective_date_of_termination)??"unknown",acasNumber:(t==null?void 0:t.acas_ec_number)??void 0,whatHappened:H.whatHappened??"",employerReason:a.employerStatedReason??"not provided",characteristics:H.characteristics.join(", ")||"none identified",et1Deadline:t!=null&&t.et1_deadline?`${new Date(t.et1_deadline).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})}`:"not yet calculated"}}function pt({messagesUsed:t,track:i}){const a=i==="sc"?"Upgrade to the Small Claims Full Case (£119) to unlock unlimited conversations and the full small-claims toolkit.":i==="sr"?"Upgrade to the Scam Refund Ombudsman Pack (£99) to unlock unlimited conversations and the full refund toolkit.":i==="rr"?"Upgrade to a Renters' Rights pack (from £89) to unlock unlimited conversations and the matching tribunal toolkit.":"Upgrade to Build (£299) to unlock unlimited conversations and access all document generation tools.";return e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center gap-4",children:[e.jsx("div",{className:"h-14 w-14 rounded-full bg-ink-bg flex items-center justify-center",children:e.jsx(be,{className:"h-7 w-7 text-ink-muted"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-bold text-ink mb-1",children:["You've used all ",t," free messages"]}),e.jsx("p",{className:"text-sm text-ink-muted max-w-xs",children:a})]}),e.jsxs("a",{href:"/pricing",className:"flex items-center gap-2 px-5 py-2.5 rounded-xl bg-ink text-white text-sm font-bold hover:bg-ink transition-colors",children:["See plans ",e.jsx(_,{className:"h-4 w-4"})]}),e.jsx("p",{className:"text-xs text-ink-faint",children:"No subscription needed â pay once per case"})]})}function ft({msg:t,isStreaming:i}){const a=t.role==="user";return e.jsxs("div",{className:`flex gap-3 ${a?"flex-row-reverse":""}`,children:[e.jsx("div",{className:`flex-shrink-0 h-7 w-7 rounded-full flex items-center justify-center text-xs font-bold mt-1 ${a?"bg-ink text-white":"bg-ink-bg text-ink-muted"}`,children:a?"You":"AI"}),e.jsxs("div",{className:`max-w-[80%] rounded-2xl px-4 py-3 ${a?"bg-ink text-white rounded-tr-sm":"bg-white border border-ink-border text-ink rounded-tl-sm"}`,children:[a?e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:t.content}):e.jsx("div",{className:`text-sm leading-relaxed prose prose-sm max-w-none ${i?'after:content-["â"] after:ml-0.5 after:animate-pulse after:text-ink-muted':""}`,children:e.jsx(rt,{remarkPlugins:[it],components:{p:({children:d})=>e.jsx("p",{className:"mb-2 last:mb-0",children:d}),ul:({children:d})=>e.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-1",children:d}),ol:({children:d})=>e.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-1",children:d}),li:({children:d})=>e.jsx("li",{className:"text-sm",children:d}),strong:({children:d})=>e.jsx("strong",{className:"font-semibold text-ink",children:d}),h3:({children:d})=>e.jsx("h3",{className:"font-bold text-ink text-sm mt-3 mb-1",children:d}),code:({children:d})=>e.jsx("code",{className:"bg-ink-bg rounded px-1 text-xs font-mono",children:d})},children:t.content})}),e.jsx("p",{className:`text-xs mt-1.5 ${a?"text-ink-border":"text-ink-faint"}`,children:new Date(t.created_at).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})})]})]})}function Bt(){var ce;const{activeCase:t,deadlines:i}=$e(),{user:a}=qe(),d=He(),[v,H]=Pe();l.useEffect(()=>{const n=document.querySelector("main");
1n&&(n.scrollTop=0)},[]),l.useEffect(()=>{const n=v.get("q");n&&(T(n),H({},{replace:!0}),setTimeout(()=>{var s;return(s=I.current)==null?void 0:s.focus()},100))},[]);const{canSendMessage:L,messagesRemaining:p,incrementMessageCount:Z,tier:ye}=Ue(),J=Ye(),V=ct(J),j=V||L,N=!V&&ye==="free",{startCheckout:ke,loading:P}=Me();function X(){if(!t){window.location.href="/pricing";return}if(m==="rr"){window.location.href="/renters-rights/pricing";return}const n=m==="sc"?"sc_full_case":m==="sr"?"sr_core":"core";ke(t.id,n)}const[we,ve]=l.useState({healthScore:null,journalCount:0,latestOffer:null,documentCount:0,documents:[]});l.useEffect(()=>{t!=null&&t.id&&Qe(t.id).then(ve).catch(n=>console.error("Failed to load case insights:",n))},[t==null?void 0:t.id]);const q=t?ze(t,i,we):[],m=ge(t),je=l.useMemo(()=>{const n=[];if(m==="et"&&(t!=null&&t.claim_types))for(const r of t.claim_types){const c=he[r]??[];n.push(...c)}n.push(...pe(m));const s={};for(const r of n)s[r.group]||(s[r.group]=[]),s[r.group].length<3&&s[r.group].push(r);return s},[m,t==null?void 0:t.claim_types]),[$,S]=l.useState([]),[x,R]=l.useState(null),[b,f]=l.useState([]),[M,T]=l.useState(""),[y,D]=l.useState(!1),[K,B]=l.useState(null),[Ne,ee]=l.useState(!1),[te,ne]=l.useState(!1),[se,A]=l.useState(null),[k,G]=l.useState(null),[re,ie]=l.useState(!1),Se=l.useRef(null),oe=l.useRef(null),I=l.useRef(null),W=l.useRef(null);async function Ie(n){var r;const s=(r=n.target.files)==null?void 0:r[0];if(s){ie(!0);try{const c=await Ge(s);G(c)}catch{A("Could not read that file. Try a PDF, Word document, or plain text file.")}finally{ie(!1),W.current&&(W.current.value="")}}}const C=Fe.free;l.useEffect(()=>{if(!a)return;S([]),R(null),f([]),ne(!0);const n=g.from("conversations").select("*").eq("user_id",a.id).order("updated_at",{ascending:!1});t!=null&&t.id?n.eq("case_id",t.id):n.is("case_id",null),(async()=>{try{const{data:s,error:r}=await n;if(r)A("Could not load your conversations â please refresh and try again.");else{const c=s??[];S(c),c.length>0&&R(c[0].id)}}finally{ne(!1)}})()},[a,t==null?void 0:t.id]),l.useEffect(()=>{x&&(ee(!0),(async()=>{try{const{data:n}=await g.from("chat_messages").select("*").eq("conversation_id",x).order("created_at",{ascending:!0});f(n??[])}finally{ee(!1)}})())},[x]),l.useEffect(()=>{if(b.length===0)return;const n=oe.current;n&&(n.scrollTop=n.scrollHeight)},[b]);function Ce(n){T(n.target.value),n.target.style.height="auto",n.target.style.height=`${Math.min(n.target.scrollHeight,160)}px`}async function ae(){const{data:n,error:s}=await g.from("conversations").insert({user_id:a.id,case_id:(t==null?void 0:t.id)??null,title:"New conversation"}).select().single();if(s||!n)throw new Error("Could not create conversation. Please try again.");const r=n;return S(c=>[r,...c]),R(r.id),f([]),r.id}async function _e(){try{await ae()}catch(n){A(n instanceof Error?n.message:"Could not start a new conversation.")}}async function Ee(n){var r;const{error:s}=await g.from("conversations").delete().eq("id",n).eq("user_id",a.id);if(!s&&(S(c=>c.filter(o=>o.id!==n)),x===n)){const c=$.filter(o=>o.id!==n);R(((r=c[0])==null?void 0:r.id)??null),f([])}}const le=l.useCallback(async()=>{const n=M.trim();if(!n&&!k||y||!j)return;A(null),D(!0),T("");const s=k;G(null),I.current&&(I.current.style.height="auto");try{let r=x;r||(r=await ae());const c=s?`[Attached: ${s.filename}]${n?` 2 3${n}`:""}`:n,o=`temp-user-${Date.now()}`,w={id:o,conversation_id:r,role:"user",content:c,created_at:new Date().toISOString()};if(f(u=>[...u,w]),await g.from("chat_messages").insert({conversation_id:r,role:"user",content:c}),b.length===0){const u=(n||(s==null?void 0:s.filename)||"Document question").slice(0,60);await g.from("conversations").update({title:u,updated_at:new Date().toISOString()}).eq("id",r),S(h=>h.map(O=>O.id===r?{...O,title:u}:O))}await Z();let U;if(s){const u=[];s.source.kind==="pdf"?u.push({type:"document",source:{type:"base64",media_type:"application/pdf",data:s.source.base64}}):u.push({type:"text",text:`[Document: ${s.filename}] 4 5${s.source.text}`}),n&&u.push({type:"text",text:n}),U=u}else U=n;const Te=[...b,{...w,content:U}].slice(-20).map(u=>({role:u.role,content:u.id===o?U:u.content})),Y=`streaming-${Date.now()}`,Ae={id:Y,conversation_id:r,role:"assistant",content:"",created_at:new Date().toISOString()};f(u=>[...u,Ae]),B(Y);const We=ht(t,J),Oe=await Ke({toolKey:"ask_vindivo",context:We,messages:Te,maxTokens:1500},(u,h)=>{f(O=>O.map(Q=>Q.id===Y?{...Q,content:h}:Q))});B(null);const{data:ue}=await g.from("chat_messages").insert({conversation_id:r,role:"assistant",content:Oe}).select().single();ue&&f(u=>u.map(h=>h.id===Y?ue:h)),await g.from("conversations").update({updated_at:new Date().toISOString()}).eq("id",r),S(u=>u.map(h=>h.id===r?{...h,updated_at:new Date().toISOString()}:h))}catch(r){A(r instanceof Error?r.message:"Could not send your message â please check your connection and try again."),B(null)}finally{D(!1)}},[M,y,j,x,b,t,Z,a]);function Re(n){n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),le())}const de=$.find(n=>n.id===x);return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("aside",{className:"hidden lg:flex w-64 xl:w-
572 flex-shrink-0 border-r border-ink-border bg-white flex-col",children:[e.jsx("div",{className:"px-3 py-3 border-b border-ink-border flex-shrink-0",children:e.jsxs("button",{onClick:_e,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg bg-ink text-white text-sm font-semibold hover:opacity-90 transition-opacity",children:[e.jsx(Ve,{className:"h-4 w-4"})," New conversation"]})}),te&&e.jsx("div",{className:"border-b border-ink-border flex-shrink-0 px-4 py-3 space-y-2",children:[0,1].map(n=>e.jsx("div",{className:"h-7 bg-ink-border/40 rounded-lg animate-pulse"},n))}),!te&&$.length>0&&e.jsxs("div",{className:"border-b border-ink-border flex-shrink-0",children:[e.jsx("p",{className:"text-[10px] font-bold text-ink-faint uppercase tracking-widest px-4 pt-3 pb-1",children:"Previous"}),e.jsx("div",{className:"max-h-40 overflow-y-auto py-1 space-y-0.5 px-2",children:$.map(n=>e.jsxs("div",{className:`group flex items-center gap-1 rounded-lg px-2 py-2 cursor-pointer transition-colors ${n.id===x?"bg-ink-bg text-ink":"hover:bg-ink-bg text-ink-soft"}`,onClick:()=>R(n.id),children:[e.jsx(Xe,{className:"h-3.5 w-3.5 flex-shrink-0 opacity-40"}),e.jsx("span",{className:"text-xs flex-1 truncate",children:n.title}),e.jsx("button",{onClick:s=>{s.stopPropagation(),Ee(n.id)},className:"opacity-0 group-hover:opacity-100 text-ink-faint hover:text-accent transition-all",children:e.jsx(De,{className:"h-3 w-3"})})]},n.id))})]}),x?e.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-4 min-h-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1",children:[e.jsx(et,{className:"h-3 w-3 text-accent flex-shrink-0"}),e.jsx("p",{className:"text-[10px] font-bold text-ink-faint uppercase tracking-widest",children:"Suggested questions"})]}),Object.entries(je).map(([n,s])=>e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold text-ink-faint px-1 mb-1",children:n}),e.jsx("div",{className:"space-y-0.5",children:s.map(r=>e.jsxs("button",{onClick:()=>{var c;T(r.text),(c=I.current)==null||c.focus()},disabled:!j,className:"w-full text-left px-2.5 py-2 rounded-lg text-xs text-ink-soft hover:bg-ink-bg hover:text-ink transition-colors flex items-start gap-1.5 group disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(_,{className:"h-3 w-3 flex-shrink-0 mt-0.5 text-ink-faint group-hover:text-accent transition-colors"}),e.jsx("span",{className:"leading-snug",children:r.text})]},r.text))})]},n))]}):e.jsx("div",{className:"flex-1 px-4 py-4 min-h-0",children:e.jsx("p",{className:"text-xs text-ink-muted leading-relaxed",children:"Once you've started a conversation, suggested questions will appear here."})}),N&&e.jsx("div",{className:"px-3 py-3 border-t border-ink-border flex-shrink-0",children:e.jsxs("div",{className:"bg-ink-bg rounded-xl px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-xs font-semibold text-ink-soft",children:"Free messages"}),e.jsxs("span",{className:"text-xs font-bold text-ink",children:[Math.max(0,C-p)," / ",C]})]}),e.jsx("div",{className:"h-1.5 bg-ink-border rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-ink rounded-full transition-all",style:{width:`${Math.min(100,(C-p)/C*100)}%`}})}),p<=2&&p>0&&e.jsxs("p",{className:"text-xs text-ink-soft mt-1.5",children:[p," message",p===1?"":"s"," left ·"," ",e.jsx("button",{type:"button",onClick:X,disabled:P,className:"underline font-semibold text-accent disabled:opacity-60",children:P?"Opening checkoutâ¦":"Upgrade"})]})]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-ink-border bg-white flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-ink flex items-center justify-center flex-shrink-0",children:e.jsx(xe,{className:"h-4 w-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-sm font-bold text-ink",children:de?de.title:"Case Companion"}),e.jsx("p",{className:"text-xs text-ink-muted",children:xt(m,t)})]})]}),!N&&e.jsx("span",{className:"text-xs bg-green-50 text-green-700 border border-green-100 font-semibold px-2.5 py-1 rounded-full flex-shrink-0",children:"Unlimited"})]}),e.jsxs("div",{ref:oe,className:"flex-1 overflow-y-auto px-5 py-5 space-y-5 bg-ink-bg",children:[!x&&(()=>{var c;const s=q.find(o=>o.route==="/email-decoder"&&o.kind==="action")??q[0]??null,r=q.filter(o=>o!==s).slice(0,2);return e.jsxs("div",{className:"flex flex-col gap-5 px-4 py-8 max-w-2xl mx-auto w-full",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-11 w-11 rounded-xl bg-ink flex items-center justify-center flex-shrink-0 shadow-sm",children:e.jsx(xe,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold text-ink",children:"Your case assistant"}),e.jsx("p",{className:"text-xs text-ink-muted leading-relaxed",children:t?ut(m,t):fe(m)})]})]}),s&&e.jsxs("div",{className:"bg-white rounded-2xl border-2 border-ink p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-ink flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(F,{className:"h-4 w-4 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-ink-faint mb-1",children:"Start here"}),e.jsx("p",{className:"text-sm font-bold text-ink leading-snug",children:s.headline}),e.jsx("p",{className:"text-xs text-ink-soft mt-1.5 leading-relaxed",children:s.body})]})]}),s.route==="/email-decoder"?e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("button",{onClick:()=>{var o;return(o=W.current)==null?void 0:o.click()},className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-4 roun
5ded-xl bg-ink text-white text-sm font-bold hover:opacity-90 transition-opacity",children:[e.jsx(F,{className:"h-4 w-4"}),"Upload a file"]}),e.jsxs("button",{onClick:()=>d("/email-decoder"),className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border-2 border-ink text-ink text-sm font-bold hover:bg-ink-bg transition-colors",children:["Paste text instead",e.jsx(_,{className:"h-4 w-4"})]})]}):e.jsxs("button",{onClick:()=>d(s.route),className:"w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl bg-ink text-white text-sm font-bold hover:opacity-90 transition-opacity",children:[s.cta,e.jsx(_,{className:"h-4 w-4"})]})]}),r.length>0&&e.jsxs("div",{className:"bg-white rounded-2xl border border-ink-border px-4 py-3 space-y-1",children:[e.jsx("p",{className:"text-[10px] font-bold text-ink-faint uppercase tracking-widest mb-2",children:"Also worth checking"}),r.map(o=>{const w=o.kind==="critical"?"bg-accent":o.kind==="action"?"bg-amber-500":o.kind==="insight"?"bg-blue-500":"bg-emerald-500";return e.jsxs("button",{onClick:()=>d(o.route),className:"w-full flex items-center gap-2.5 text-left py-2 hover:bg-ink-bg rounded-lg px-2 -mx-2 transition-colors group",children:[e.jsx("span",{className:`h-2 w-2 rounded-full flex-shrink-0 ${w}`}),e.jsx("span",{className:"text-xs text-ink-soft group-hover:text-ink flex-1 leading-snug",children:o.headline}),e.jsx(_,{className:"h-3 w-3 text-ink-faint group-hover:text-ink flex-shrink-0"})]},o.route)})]}),N&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-ink-soft bg-ink-bg border border-ink-border rounded-xl px-3 py-2.5",children:[e.jsx(be,{className:"h-3.5 w-3.5 flex-shrink-0 text-ink-muted"}),e.jsxs("span",{children:[C," free messages included ·"," ",e.jsx("button",{type:"button",onClick:X,disabled:P,className:"underline font-semibold disabled:opacity-60",children:P?"Opening checkoutâ¦":"Upgrade for unlimited"})]})]}),e.jsx("div",{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:(m==="et"?((c=t==null?void 0:t.claim_types)==null?void 0:c.flatMap(o=>he[o]??[]).slice(0,1))??[]:[]).concat(pe(m).slice(0,2)).slice(0,2).map(o=>e.jsx("button",{onClick:()=>{var w;T(o.text),(w=I.current)==null||w.focus()},disabled:!j,className:"text-left text-xs p-3 bg-white border border-ink-border rounded-xl hover:bg-ink-bg hover:text-ink transition-colors text-ink-soft leading-relaxed disabled:opacity-40",children:o.text},o.text))})})]})})(),Ne&&e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(z,{className:"h-5 w-5 animate-spin text-ink-faint"})}),b.map(n=>e.jsx(ft,{msg:n,isStreaming:n.id===K&&n.content.length>0},n.id)),y&&K&&((ce=b.find(n=>n.id===K))==null?void 0:ce.content)===""&&e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex-shrink-0 h-7 w-7 rounded-full bg-ink-bg flex items-center justify-center text-xs font-bold text-ink-muted",children:"AI"}),e.jsx("div",{className:"bg-white border border-ink-border rounded-2xl rounded-tl-sm px-4 py-3",children:e.jsxs("div",{className:"flex gap-1 items-center h-5",children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-ink-border animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-ink-border animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-ink-border animate-bounce",style:{animationDelay:"300ms"}})]})})]}),se&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 bg-accent-light rounded-xl border border-accent/30 text-accent-dark text-sm",children:[e.jsx(tt,{className:"h-4 w-4 flex-shrink-0"}),se]}),!j&&N&&e.jsx(pt,{messagesUsed:C,track:m}),e.jsx("div",{ref:Se})]}),e.jsx("div",{className:"border-t border-ink-border bg-white px-4 py-3 space-y-2",children:!j&&N?e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2",children:[e.jsx("p",{className:"text-sm text-ink-muted",children:"Message limit reached."}),e.jsxs("a",{href:"/pricing",className:"text-sm font-semibold text-ink hover:underline flex items-center gap-1",children:["Upgrade to continue ",e.jsx(_,{className:"h-3.5 w-3.5"})]})]}):e.jsxs(e.Fragment,{children:[k&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-ink-bg border border-ink-border rounded-xl",children:[e.jsx(F,{className:"h-3.5 w-3.5 text-ink-soft flex-shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-ink flex-1 truncate",children:k.filename}),e.jsx("span",{className:"text-xs text-ink-muted",children:k.sizeLabel}),e.jsx("button",{onClick:()=>G(null),"aria-label":"Remove attachment",className:"text-ink-muted hover:text-ink",children:e.jsx(nt,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("input",{ref:W,type:"file",accept:Be,onChange:Ie,className:"hidden"}),e.jsx("button",{onClick:()=>{var n;return(n=W.current)==null?void 0:n.click()},disabled:y||re,title:`Attach ${me}`,"aria-label":`Attach a file (${me})`,className:"flex-shrink-0 h-10 w-10 rounded-xl border border-ink-border text-ink-faint hover:bg-ink-bg hover:text-ink-soft flex items-center justify-center transition-colors disabled:opacity-40",children:re?e.jsx(z,{className:"h-4 w-4 animate-spin"}):e.jsx(F,{className:"h-4 w-4"})}),e.jsx("textarea",{ref:I,value:M,onChange:Ce,onKeyDown:Re,"aria-label":"Type your message to the Companion",placeholder:k?"Ask something about this document, or just send itâ¦":t?mt(m,t):fe(m),rows:1,disabled:y,className:"flex-1 resize-none rounded-xl border border-ink-border px-4 py-2.5 text-sm text-ink placeholder-ink-muted focus:outline-none focus:ring-2 focus:ring-ink focus:border-transparent disabled:opacity-50 min-h-[42px] max-h-40 overflow-y-auto"}),e.jsx("button",{onClick:le,disabled:!M.trim()&&!k||y,"aria-label":"Send message",className:"flex-shrink-0 h-10 w-10 rounded-xl bg-ink text-white flex items-center justify-center hover:bg-ink disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:y?e.jsx(z,{className:"h-4 w-4 animate-spin"}):e.jsx(st,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-ink-faint text-center",children:["Attach a letter, email, or document and ask questions about it · N
5ot legal advice",N&&p>0&&` · ${p} message${p===1?"":"s"} left`]})]})})]})]})}export{Bt as CaseCompanion,ht as buildCaseContext,ct as tierHasUnlimitedCompanion};
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.