1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BI8zDb0y.js","assets/index-Dpy3xW5J.js","assets/index-D3zwz73d.css"])))=>i.map(i=>d[i]); 2import{l as ge,g as E,h as _,r as s,j as e,x as Et,_ as Bt,n as Wt,f as Dt,i as ue,o as Lt,m as Nt,y as qt,s as Ot}from"./index-Dpy3xW5J.js";import{p as Te,P as Ze,r as Ht,R as et,F as Ut,A as Yt,S as _t,a as Qt,C as Pe,b as Ve,c as $t,d as Jt,u as Gt,e as Vt,f as Kt,g as Xt,h as Zt,i as er,j as tr,k as rr,s as nr,l as or,m as sr,T as ir,n as ar,o as lr,q as dr,t as cr,v as pr}from"./ReportCard-BMynxhXM.js";import{m as Re,u as Me,a as tt}from"./autoLinkContacts-ZGYtnIzi.js";import{M as xe,r as fe}from"./index-2zZQYxaQ.js";import{u as ur}from"./useVoiceAgent-BRGcvpae.js";import{M as gr}from"./McpHandoffCard-C35981-f.js";import{A as xr}from"./AuthModal-DL4up1yH.js";const fr=[{id:"real-estate",label:"Real Estate",shortLabel:"Real Estate",icon:"layers",description:"Property, violations, tax, ownership",placeholder:"Ask about any NYC property...",suggestedPrompts:[{text:"Who owns 1000 Grand Concourse and what's wrong with their buildings?",mobile:"Who owns 1000 Grand Concourse?",cat:"Owner Research"},{text:"Find properties in the Bronx where 421-a expires in the next 18 months",mobile:"421-a expirations in the Bronx",cat:"Tax Cliff"},{text:"Run a full property report on BBL 2024610090",mobile:"Property report for BBL 2024610090",cat:"Property Report"},{text:"What's the risk profile for buildings owned by VORNADO?",mobile:"Risk profile for VORNADO properties",cat:"Risk Assessment"}]},{id:"lobbying",label:"Lobbying & Land Use",shortLabel:"Lobbying",icon:"users",description:"Council, campaigns, lobbying, legislation",placeholder:"Ask about any council member, district, or issue...",suggestedPrompts:[{text:"Give me a district briefing for Council District 15",mobile:"District briefing for CD 15",cat:"District Intel"},{text:"Who lobbies Council Member Salamanca and on what issues?",mobile:"Who lobbies CM Salamanca?",cat:"Lobbying"},{text:"What's the regulatory pipeline for housing in Manhattan?",mobile:"Housing regulatory pipeline in Manhattan",cat:"Regulations"},{text:"Map the stakeholders around Council District 34",mobile:"Stakeholder map for CD 34",cat:"Stakeholders"}]},{id:"legal",label:"Legal",shortLabel:"Legal",icon:"shield",description:"Conflicts, evidence, entity tracing",placeholder:"Ask about any entity, property, or conflict...",suggestedPrompts:[{text:"Scan REBNY for conflicts across campaign finance, lobbying, and contracts",mobile:"Conflict scan for REBNY",cat:"Conflict Scan"},{text:"Build an evidence pack for BBL 2024610090",mobile:"Evidence pack for BBL 2024610090",cat:"Evidence Pack"},{text:"Map all government connections for Catholic Charities",mobile:"Entity web for Catholic Charities",cat:"Entity Tracing"}]},{id:"procurement",label:"Procurement",shortLabel:"Procurement",icon:"compass",de
2scription:"Contracts, vendors, M/WBE, spending",placeholder:"Ask about contracts, vendors, or solicitations...",suggestedPrompts:[{text:"What contracts are expiring at DYCD in the next 6 months?",mobile:"DYCD contracts expiring soon",cat:"Expiring Contracts"},{text:"Profile Accenture â contracts, payments, M/WBE status, lobbying",mobile:"Vendor profile for Accenture",cat:"Vendor Profile"},{text:"Show me the construction pipeline in Manhattan Community Board 7",mobile:"Construction pipeline in Manhattan CB7",cat:"Construction"}]},{id:"funding",label:"Funding",shortLabel:"Funding",icon:"dollarSign",description:"Grants, foundations, nonprofits, awards",placeholder:"Ask about grants, funding, or organizations...",suggestedPrompts:[{text:"What's the funding landscape for mental health programs in NYC?",mobile:"Mental health funding landscape",cat:"Landscape"},{text:"Match Korean Community Services to open grants based on their mission",mobile:"Grant match for KCS",cat:"Grant Match"},{text:"Run a due diligence check on United Way â financials, audits, compliance",mobile:"Due diligence on United Way",cat:"Due Diligence"},{text:"What federal funding closes in the next 30 days for youth programs?",mobile:"Youth grants closing in 30 days",cat:"Deadlines"}]},{id:"finance",label:"Finance",shortLabel:"Finance",icon:"chart",description:"Budgets, tax cliffs, distressed properties",placeholder:"Ask about budgets, tax exposure, or spending...",suggestedPrompts:[{text:"Find distressed multifamily buildings in Brooklyn with high violation scores",mobile:"Distressed buildings in Brooklyn",cat:"Distressed"},{text:"Give me the full budget picture for NYPD",mobile:"NYPD budget breakdown",cat:"Budget"},{text:"Where are the tax cliffs in Queens for buildings with 50+ units?",mobile:"Tax cliffs in Queens (50+ units)",cat:"Tax Cliff"}]}],Ke=[{text:"Who are the top recipients of NYC council funding?",mobile:"Top NYC council funding recipients?",cat:"Follow the Money"},{text:"Show me United Way's full profile",mobile:"United Way's full profile",cat:"Research Orgs"},{text:"What NYC funding sources are open for youth programs?",mobile:"NYC funding for youth programs?",cat:"Find Funding"},{text:"Who lobbies the Department of Education?",mobile:"Who lobbies the Dept. of Education?",cat:"Track Power"}];function hr(t){return t?fr.find(u=>u.id===t)?.suggestedPrompts??Ke:Ke}function mr(t){const p=Date.now()-t,u=Math.floor(p/6e4);if(u<60)return u<=1?"just now":`${u}m`;const g=Math.floor(u/60);if(g<24)return`${g}h`;const i=Math.floor(g/24);return i<30?`${i}d`:`${Math.floor(i/30)}mo`}function yr({userId:t,activeSessionId:p,onNewConversation:u,onRestore:g}){const i=ge(E.profiles.getSessionList,t?{userId:t}:"skip"),l=ge(E.profiles.getArchivedSessions,t?{userId:t}:"skip"),P=_(E.profiles.archiveSession),T=_(E.profiles.unarchiveSession),R=_(E.profiles.deleteSession),[S,k]=s.useState(null),[w,M]=s.useState(null),[z,j]=s.useState(!1),n=s.useRef(null);s.useEffect(()=>{function o(f){n.current&&!n.current.contains(f.target)&&k(null)}if(S)return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[S]);const d=async o=>{if(o!==p)try{const{ConvexHttpClient:f}=await Bt(async()=>{const{ConvexHttpClient:h}=await import("./index-BI8zDb0y.js");return{ConvexHttpClient:h}},__vite__mapDeps([0,1,2])),F="https://fastidious-starfish-508.convex.cloud",m=await new f(F).query(E.profiles.getSessionTurns,{sessionId:o});if(!m||m.length===0)return;const H=m.flatMap(h=>[{role:"user",content:h.query},{role:"assistant",content:h.answer}]),K=m.map(h=>({query:h.query,parsed:Te(h.answer),thinking:null}));g(H,K,o)}catch(f){console.error("Failed to load session turns:",f)}},y=async o=>{t&&(k(null),await P({sessionId:o,userId:t}),o===p&&u())},A=async o=>{k(null),await T({sessionId:o})},b=async o=>{t&&(M(null),k(null),await R({sessionId:o,userId:t}),o===p&&u())},v=l&&l.length>0;return e.jsxs("aside",{className:"hidden lg:flex",style:{width:"240px",flexShrink:0,flexDirection:"column",background:"#0d1420",borderRight:"1px solid var(--border)",position:"sticky",top:0,height:"100%",overflowY:"auto"},children:[e.jsx("div",{style:{padding:"12px"},children:e.jsxs("button",{onClick:u,style:{width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border)",background:"transparent",curs
2or:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"13px",color:"var(--text-secondary)",transition:"background 0.15s, border-color 0.15s"},onMouseEnter:o=>{o.currentTarget.style.background="rgba(184,98,27,0.08)",o.currentTarget.style.borderColor="rgba(184,98,27,0.3)"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.borderColor="var(--border)"},children:[e.jsx("span",{style:{fontSize:"16px",lineHeight:1},children:"+"}),"New conversation"]})}),t&&e.jsx("div",{style:{padding:"4px 16px 6px",fontFamily:"JetBrains Mono, monospace",fontSize:"9px",fontWeight:700,letterSpacing:"0.12em",color:"var(--text-muted)",textTransform:"uppercase"},children:"Recent"}),t?e.jsx("div",{style:{flex:1,overflowY:"auto"},children:i===void 0?e.jsx("div",{style:{padding:"12px 16px",fontFamily:"JetBrains Mono, monospace",fontSize:"11px",color:"var(--text-muted)"},children:"Loading..."}):i.length===0&&!v?e.jsx("div",{style:{padding:"12px 16px",fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-muted)",lineHeight:1.5},children:"Your conversations will appear here."}):e.jsxs(e.Fragment,{children:[i.map(o=>{const f=o.sessionId===p,F=S===o.sessionId,C=w===o.sessionId;return e.jsxs("div",{style:{position:"relative"},onMouseEnter:m=>{const H=m.currentTarget.querySelector("[data-dots]");H&&!F&&(H.style.opacity="1")},onMouseLeave:m=>{const H=m.currentTarget.querySelector("[data-dots]");H&&!F&&(H.style.opacity="0")},children:[e.jsxs("button",{onClick:()=>d(o.sessionId),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",padding:"8px 32px 8px 12px",background:f?"rgba(184,98,27,0.08)":"transparent",border:"none",borderLeft:f?"2px solid var(--amber)":"2px solid transparent",cursor:"pointer",textAlign:"left",transition:"background 0.1s"},onMouseEnter:m=>{f||(m.currentTarget.style.background="rgba(255,255,255,0.03)")},onMouseLeave:m=>{f||(m.currentTarget.style.background="transparent")},children:[e.jsx("span",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"13px",color:f?"var(--text-primary)":"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:o.title}),e.jsx("span",{style:{fontFamily:"JetBrains Mono, monospace",fontSize:"10px",color:"var(--text-muted)",flexShrink:0},children:mr(o.lastActivity)})]}),e.jsx("button",{"data-dots":!0,onClick:m=>{m.stopPropagation(),k(F?null:o.sessionId),M(null)},style:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",width:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:"14px",borderRadius:"4px",opacity:F?"1":"0",transition:"opacity 0.15s, background 0.1s"},onMouseEnter:m=>{m.currentTarget.style.background="rgba(255,255,255,0.08)"},onMouseLeave:m=>{m.currentTarget.style.background="none"},children:"â¯"}),F&&!C&&e.jsxs("div",{ref:n,style:{position:"absolute",right:"6px",top:"100%",zIndex:50,background:"#1a2233",border:"1px solid var(--border)",borderRadius:"6px",padding:"4px 0",minWidth:"130px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)"},children:[e.jsxs("button",{onClick:m=>{m.stopPropagation(),y(o.sessionId)},style:{width:"100%",padding:"7px 12px",background:"none",border:"none",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-secondary)",textAlign:"left",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:m=>{m.currentTarget.style.background="rgba(255,255,255,0.05)"},onMouseLeave:m=>{m.currentTarget.style.background="none"},children:[e.jsx("span",{style:{fontSize:"13px"},children:"ð¦"})," Archive"]}),e.jsxs("button",{onClick:m=>{m.stopPropagation(),M(o.sessionId)},style:{width:"100%",padding:"7px 12px",background:"none",border:"none",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"#ef4444",textAlign:"left",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:m=>{m.currentTarget.style.background="rgba(239,68,68,0.08)"},onMouseLeave:m=>{m.currentTarget.style.background="none"},children:[e.jsx("span",{style:{fontSize:"13px"},children:"ð"})," Delete"]})]}),C&&e.jsxs("div",{ref:n,style:{position:"absolute",right:"6px",top:"100%",zIndex:50,background:"#1a2233",border:"1px solid rgba(239,68,68,0.3)",borderRadius:"6px",padding:"10px 12px",minWidth:"180px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)"},children:[e.jsx("div",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:"Delete this conversation?"}),e.jsxs("div",{style:{display:"flex",gap:"6px"},children:[e.jsx("button",{onClick:m=>{m.stopPropagation(),M(null),k(null)},style:{flex:1,padding:"5px 8px",borderRadius:"4px",border:"1px solid var(--border)",background:"transparent",curs
2or:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"11px",color:"var(--text-secondary)"},children:"Cancel"}),e.jsx("button",{onClick:m=>{m.stopPropagation(),b(o.sessionId)},style:{flex:1,padding:"5px 8px",borderRadius:"4px",border:"1px solid rgba(239,68,68,0.4)",background:"rgba(239,68,68,0.12)",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"11px",color:"#ef4444",fontWeight:600},children:"Delete"})]})]})]},o.sessionId)}),v&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>j(!z),style:{width:"100%",display:"flex",alignItems:"center",gap:"6px",padding:"10px 16px 6px",background:"none",border:"none",cursor:"pointer",fontFamily:"JetBrains Mono, monospace",fontSize:"9px",fontWeight:700,letterSpacing:"0.12em",color:"var(--text-muted)",textTransform:"uppercase"},children:[e.jsx("span",{style:{fontSize:"8px",transition:"transform 0.15s",transform:z?"rotate(90deg)":"rotate(0deg)"},children:"â¶"}),"Archived (",l.length,")"]}),z&&l.map(o=>{const f=S===o.sessionId,F=w===o.sessionId;return e.jsxs("div",{style:{position:"relative",opacity:.6},onMouseEnter:C=>{C.currentTarget.style.opacity="1";const m=C.currentTarget.querySelector("[data-dots]");m&&!f&&(m.style.opacity="1")},onMouseLeave:C=>{C.currentTarget.style.opacity="0.6";const m=C.currentTarget.querySelector("[data-dots]");m&&!f&&(m.style.opacity="0")},children:[e.jsx("div",{style:{width:"100%",display:"flex",alignItems:"center",gap:"8px",padding:"7px 32px 7px 12px",borderLeft:"2px solid transparent"},children:e.jsx("span",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,fontStyle:"italic"},children:o.title})}),e.jsx("button",{"data-dots":!0,onClick:C=>{C.stopPropagation(),k(f?null:o.sessionId),M(null)},style:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",width:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:"14px",borderRadius:"4px",opacity:f?"1":"0",transition:"opacity 0.15s"},children:"â¯"}),f&&!F&&e.jsxs("div",{ref:n,style:{position:"absolute",right:"6px",bottom:"100%",zIndex:50,background:"#1a2233",border:"1px solid var(--border)",borderRadius:"6px",padding:"4px 0",minWidth:"130px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)"},children:[e.jsxs("button",{onClick:C=>{C.stopPropagation(),A(o.sessionId)},style:{width:"100%",padding:"7px 12px",background:"none",border:"none",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-secondary)",textAlign:"left",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:C=>{C.currentTarget.style.background="rgba(255,255,255,0.05)"},onMouseLeave:C=>{C.currentTarget.style.background="none"},children:[e.jsx("span",{style:{fontSize:"13px"},children:"â©"})," Unarchive"]}),e.jsxs("button",{onClick:C=>{C.stopPropagation(),M(o.sessionId)},style:{width:"100%",padding:"7px 12px",background:"none",border:"none",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"#ef4444",textAlign:"left",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:C=>{C.currentTarget.style.background="rgba(239,68,68,0.08)"},onMouseLeave:C=>{C.currentTarget.style.background="none"},children:[e.jsx("span",{style:{fontSize:"13px"},children:"ð"})," Delete"]})]}),F&&e.jsxs("div",{ref:n,style:{position:"absolute",right:"6px",bottom:"100%",zIndex:50,background:"#1a2233",border:"1px solid rgba(239,68,68,0.3)",borderRadius:"6px",padding:"10px 12px",minWidth:"180px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)"},children:[e.jsx("div",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:"Permanently delete?"}),e.jsxs("div",{style:{display:"flex",gap:"6px"},children:[e.jsx("button",{onClick:C=>{C.stopPropagation(),M(null),k(null)},style:{flex:1,padding:"5px 8px",borderRadius:"4px",border:"1px solid var(--border)",background:"transparent",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"11px",color:"var(--text-secondary)"},children:"Cancel"}),e.jsx("button",{onClick:C=>{C.stopPropagation(),b(o.sessionId)},style:{flex:1,padding:"5px 8px",borderRadius:"4px",border:"1px solid rgba(239,68,68,0.4)",background:"rgba(239,68,68,0.12)",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"11px",color:"#ef4444",fontWeight:600},children:"Delete"})]})]})]},o.sessionId)})]})]})}):e.jsx("div",{style:{padding:"16px",marginTop:"auto"},children:e.jsx("p",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-muted)",margin:0,lineHeight:1.6},children:"Ask a question to start your first conversation."})}),t&&Et(t)&&e.jsx("div",{style:{padding:"10px 16px",borderTop:"1px solid var(--border)",fontFamily:"Public Sans, sans-serif",fontSize:"11px",color:"var(--text-muted)",lineHeight:1.5},children:"Sign in to keep history across devices"})]})}
2const Ce=["Akil searches source-backed NYC public records and keeps answers tied to citations.","Reports include structured citations with dataset names and record counts.","You can save any report as a PDF using the button in the panel header.","Try the voice agent â click Talk to have a conversation with your data.","Akil covers real estate, lobbying, procurement, funding, legal, and finance.","Every data point is sourced from official NYC, NYS, or federal public records."];function br({onQuery:t,queryText:p}){const[u,g]=s.useState(Math.floor(Math.random()*Ce.length)),[i,l]=s.useState(0);return s.useEffect(()=>{const P=setInterval(()=>{g(T=>(T+1)%Ce.length)},6e3);return()=>clearInterval(P)},[]),s.useEffect(()=>{const P=setInterval(()=>l(T=>T+1),1e3);return()=>clearInterval(P)},[]),e.jsxs("div",{style:{padding:"48px 24px",maxWidth:520,margin:"0 auto",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[p&&e.jsx("div",{style:{fontFamily:"'Public Sans', sans-serif",fontSize:18,fontWeight:500,color:"var(--text-primary, #f1f5f9)",marginBottom:24,lineHeight:1.5},children:p}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:32},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"#D4742A",animation:"voice-pulse 1.5s ease-in-out infinite"}}),e.jsxs("span",{style:{fontFamily:"'JetBrains Mono', monospace",fontSize:12,color:"#D4742A",textTransform:"uppercase",letterSpacing:"0.08em"},children:["Generating report",i>0?` · ${i<60?`${i}s`:`${Math.floor(i/60)}m ${(i%60).toString().padStart(2,"0")}s`}`:""]})]}),e.jsx("div",{style:{width:"100%",maxWidth:280,height:2,background:"rgba(255,255,255,0.06)",borderRadius:1,overflow:"hidden",marginBottom:40},children:e.jsx("div",{style:{width:"30%",height:"100%",background:"linear-gradient(90deg, transparent, #D4742A, transparent)",borderRadius:1,animation:"shimmer 2s ease-in-out infinite"}})}),e.jsx("div",{style:{fontFamily:"'Public Sans', sans-serif",fontSize:13,color:"var(--text-muted, #6b7280)",lineHeight:1.6,maxWidth:360,opacity:0,animation:"fade-in 0.5s ease forwards"},children:Ce[u]},u),i>=45&&e.jsx("div",{style:{marginTop:24,fontFamily:"'Public Sans', sans-serif",fontSize:12,color:i>=120?"#D4742A":"var(--text-muted, #6b7280)",lineHeight:1.6,opacity:0,animation:"fade-in 0.5s ease forwards"},children:i>=120?"This is a large report with many data sources â almost done.":"Complex reports can take up to 2 minutes. Still working on it."}),e.jsx("style",{children:` 3 @keyframes shimmer { 4 0% { transform: translateX(-100%); } 5 100% { transform: translateX(400%); } 6 } 7 @keyframes fade-in { 8 from { opacity: 0; transform: translateY(4px); } 9 to { opacity: 1; transform: translateY(0); } 10 } 11 `})]})}function vr({panel:t,onClose:p,onConfirm:u,onReportSubmit:g}){const[i,l]=s.useState(!1),[P,T]=s.useState(!1),[R,S]=s.useState(!1),[k,w]=s.useState(""),M=s.useRef(null),z=t.mode==="voice"?"Voice Conversation":t.mode==="loading"&&t.queryText?t.queryText.length>60?t.queryText.slice(0,57)+"...":t.queryText:t.reportType?t.reportType.replace(/-/g," ").replace(/\b\w/g,n=>n.toUpperCase()):"Analysis",j=()=>{t.mode==="report"&&(navigator.clipboard.writeText(t.markdown),l(!0),setTimeout(()=>l(!1),2e3))};return e.jsxs("div",{style:O.panel,children:[e.jsx("style",{children:Sr}),e.jsxs("div",{style:O.header,children:[e.jsxs("div",{style:O.headerLeft,children:[e.jsx("div",{style:O.headerIcon,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("rect",{x:"2",y:"1",width:"12",height:"14",rx:"2",stroke:"#D4742A",strokeWidth:"1.5"}),e.jsx("line",{x1:"5",y1:"5",x2:"11",y2:"5",stroke:"#D4742A",strokeWidth:"1"}),e.jsx("line",{x1:"5",y1:"8",x2:"11",y2:"8",stroke:"#D4742A",strokeWidth:"1"}),e.jsx("line",{x1:"5",y1:"11",x2:"9",y2:"11",stroke:"#D4742A",strokeWidth:"1"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:O.headerTitle,children:z}),e.jsx("div",{style:O.headerSub,children:t.mode==="loading"?"Generating...":t.mode==="voice"?t.voiceState==="processing"?t.activeToolName?`Looking up ${t.activeToolName.replace(/^akil_/,"").replace(/_/g," ")}...`:"Thinking...":t.voiceState==="speaking"?"Speaking...":t.voiceState==="connecting"?"Connecting...":"Listening...":"Akil Intelligence"})]})]}),e.jsxs("div",{style:O.headerRight,children:[t.mode==="report"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>T(!0),style:O.headerActionPrimary,children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",style:{marginRight:5},children:e.jsx("path",{d:"M8 2v8m0 0l-3-3m3 3l3-3M3 12h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Save PDF"]}),e.jsxs("button",{onClick:j,style:O.headerActionSecondary,children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",style:{marginRight:5}
11,children:[e.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("path",{d:"M10 4V3a2 2 0 0 0-2-2H3a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h1",stroke:"currentColor",strokeWidth:"1.2"})]}),i?"Copied!":"Copy"]})]}),e.jsx("button",{onClick:p,style:O.closeButton,title:"Close panel",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:e.jsx("path",{d:"M5 5l8 8M13 5l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]}),e.jsx("div",{ref:M,style:O.body,children:t.mode==="voice"?e.jsxs("div",{style:{padding:"24px 32px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:t.messages.length===0?"48px 0 32px":"16px 0 12px",transition:"padding 0.3s ease"},children:[e.jsxs("div",{style:{width:t.messages.length===0?100:56,height:t.messages.length===0?100:56,borderRadius:"50%",background:t.voiceState==="speaking"?"radial-gradient(circle, rgba(184,98,27,0.4) 0%, rgba(184,98,27,0.1) 70%)":t.voiceState==="processing"?"radial-gradient(circle, rgba(184,98,27,0.2) 0%, rgba(184,98,27,0.05) 70%)":"radial-gradient(circle, rgba(184,98,27,0.3) 0%, rgba(184,98,27,0.08) 70%)",border:`2px solid ${t.voiceState==="speaking"?"rgba(184,98,27,0.6)":t.voiceState==="processing"?"rgba(184,98,27,0.3)":"rgba(184,98,27,0.4)"}`,display:"flex",alignItems:"center",justifyContent:"center",animation:t.voiceState==="listening"?"voice-orb-pulse 2s ease-in-out infinite":t.voiceState==="speaking"?"voice-orb-breathe 1.2s ease-in-out infinite":t.voiceState==="processing"?"voice-orb-think 2s linear infinite":"none",transition:"all 0.3s ease",cursor:t.voiceState==="speaking"?"pointer":"default",position:"relative"},title:t.voiceState==="speaking"?"Click to interrupt":void 0,children:[t.voiceState==="processing"&&e.jsx("div",{style:{position:"absolute",inset:-4,borderRadius:"50%",border:"2px solid transparent",borderTopColor:"#D4742A",animation:"voice-orb-spin 1s linear infinite"}}),e.jsxs("svg",{width:t.messages.length===0?28:20,height:t.messages.length===0?28:20,viewBox:"0 0 24 24",fill:"none",stroke:"#D4742A",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transition:"all 0.3s ease"},children:[e.jsx("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),e.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),e.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})]}),e.jsx("div",{style:{fontFamily:"'Public Sans', sans-serif",fontSize:t.messages.length===0?16:12,color:t.voiceState==="speaking"?"#D4742A":"var(--text-muted, #6b7280)",marginTop:t.messages.length===0?16:8,transition:"all 0.3s ease",textAlign:"center"},children:t.voiceState==="processing"?t.activeToolName?`Looking up ${t.activeToolName.replace(/^akil_/,"").replace(/_/g," ")}...`:"Thinking...":t.voiceState==="speaking"?"Speaking...":t.voiceState==="connecting"?"Connecting...":"Listening..."}),t.voiceState==="speaking"&&e.jsx("div",{style:{fontFamily:"'JetBrains Mono', monospace",fontSize:10,color:"rgba(184,98,27,0.5)",marginTop:4,animation:"voice-hint-fade 2s ease-in-out infinite"},children:"Click to interrupt"}),t.messages.length===0&&e.jsx("div",{style:{fontFamily:"'JetBrains Mono', monospace",fontSize:12,color:"var(--text-muted, #6b7280)",marginTop:8},children:"Ask anything about NYC civic data"})]}),t.messages.length===0?null:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.messages.map((n,d)=>{const y=n.role==="assistant",A=y&&!t.messages.slice(d+1).some(f=>f.role==="assistant"),b=t.messages.filter(f=>f.role==="assistant").length,v=y&&/\b(full (?:written )?report|detailed report|comprehensive report|put together a.*report)\b/i.test(n.content),o=A&&!R&&t.voiceState!=="processing"&&(v||b>=2);return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:n.role==="user"?"flex-end":"flex-start"},children:[e.jsx("div",{style:{fontSize:10,fontFamily:"'JetBrains Mono', monospace",color:"var(--text-muted, #6b7280)",marginBottom:4,textTransform:"uppercase",letterSpacing:"0.05em"},children:n.role==="user"?"You":"Akil"}),e.jsx("div",{style:{maxWidth:"85%",padding:"12px 16px",borderRadius:n.role==="user"?"14px 14px 4px 14px":"14px 14px 14px 4px",background:n.role==="user"?"rgba(184,98,27,
110.15)":"rgba(255,255,255,0.05)",border:`1px solid ${n.role==="user"?"rgba(184,98,27,0.3)":"rgba(255,255,255,0.08)"}`,fontSize:15,lineHeight:1.6,fontFamily:"'Public Sans', sans-serif",color:"var(--text-primary, #f1f5f9)",whiteSpace:"pre-wrap"},children:n.content})]}),o&&e.jsxs("button",{onClick:()=>{const f=t.messages.filter(F=>F.role==="user").pop()?.content??"";w(f?`Full report on ${f}`:""),S(!0)},style:{display:"inline-flex",alignItems:"center",gap:6,marginTop:8,padding:"6px 12px",borderRadius:16,background:"rgba(184,98,27,0.08)",border:"1px solid rgba(184,98,27,0.2)",color:"#D4742A",fontSize:12,fontFamily:"'JetBrains Mono', monospace",cursor:"pointer",transition:"background 0.15s"},onMouseEnter:f=>f.currentTarget.style.background="rgba(184,98,27,0.15)",onMouseLeave:f=>f.currentTarget.style.background="rgba(184,98,27,0.08)",children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("rect",{x:"2",y:"1",width:"12",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("line",{x1:"5",y1:"5",x2:"11",y2:"5",stroke:"currentColor",strokeWidth:"1"}),e.jsx("line",{x1:"5",y1:"8",x2:"11",y2:"8",stroke:"currentColor",strokeWidth:"1"})]}),"Generate full report"]})]},d)}),t.voiceState==="processing"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[e.jsx("div",{style:{fontSize:10,fontFamily:"'JetBrains Mono', monospace",color:"var(--text-muted, #6b7280)",marginBottom:4,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Akil"}),e.jsx("div",{style:{padding:"12px 16px",borderRadius:"14px 14px 14px 4px",background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.08)",fontSize:14,fontFamily:"'JetBrains Mono', monospace",color:"#D4742A",display:"flex",alignItems:"center",gap:8},children:e.jsx("span",{style:{animation:"voice-pulse 1.5s ease-in-out infinite"},children:t.activeToolName?`Looking up ${t.activeToolName.replace(/^akil_/,"").replace(/_/g," ")}...`:"Thinking..."})})]})]}),R&&e.jsxs("div",{style:{marginTop:16,padding:16,borderRadius:12,background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.08)"},children:[e.jsx("div",{style:{fontSize:13,fontFamily:"'Public Sans', sans-serif",color:"var(--text-secondary, #94a3b8)",marginBottom:10},children:"What do you want the report to cover?"}),e.jsx("textarea",{value:k,onChange:n=>w(n.target.value),placeholder:"e.g., Full profile on Sandra Ung...",rows:2,autoFocus:!0,style:{width:"100%",padding:"10px 12px",borderRadius:8,background:"rgba(0,0,0,0.2)",border:"1px solid rgba(255,255,255,0.1)",color:"var(--text-primary, #f1f5f9)",fontSize:14,fontFamily:"'Public Sans', sans-serif",resize:"none",outline:"none"},onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&k.trim()&&(n.preventDefault(),g?.(k.trim()),S(!1),w(""))}}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[e.jsx("button",{onClick:()=>{S(!1),w("")},style:{padding:"8px 14px",borderRadius:8,background:"transparent",border:"1px solid rgba(255,255,255,0.1)",color:"var(--text-muted, #6b7280)",fontSize:13,fontFamily:"'Public Sans', sans-serif",cursor:"pointer"},children:"Cancel"}),e.jsx("button",{onClick:()=>{k.trim()&&(g?.(k.trim()),S(!1),w(""))},disabled:!k.trim(),style:{flex:1,padding:"8px 14px",borderRadius:8,background:k.trim()?"#D4742A":"rgba(184,98,27,0.3)",border:"none",color:k.trim()?"#fff":"rgba(255,255,255,0.4)",fontSize:13,fontWeight:600,fontFamily:"'Public Sans', sans-serif",cursor:k.trim()?"pointer":"default"},children:"Generate Report"})]})]})]}):t.mode==="loading"?e.jsx("div",{style:O.progressWrapper,children:e.jsx(Ze,{workflowId:t.workflowId,onConfirm:u,originalQuery:t.mode==="loading"?t.queryText:void 0},t.workflowId)}):(()=>{const n=t.markdown.replace("<!-- REPORT_COMPLETE -->","").trim(),d=n.match(/\n(#{1,3}\s*Sources\s*(?:&|and)\s*Methodology.*)/s),y=d?n.slice(0,d.index).trim():n,A=d?d[1].trim():null,b=({children:v,...o})=>e.jsx("div",{style:{overflowX:"auto",margin:"16px 0"},children:e.jsx("table",{...o,style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:v})});return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:O.reportContent,className:"akil-prose",children:e.jsx(xe,{remarkPlugins:[fe],urlTransform:Me,components:{...Re,table:b},children:tt(y)})}),A&&e.jsx("div",{style:{marginTop:32,paddingTop:20,borderTop:"1px solid rgba(255,255,255,0.06)",fontSize:11,lineHeight:1.6,color:"var(--text-muted, #6b7280)",fontFamily:"'JetBrains Mono', monospace"},className:"akil-prose",children:e.jsx(xe,{remarkPlugins:[fe],urlTransform:Me,components:{...Re,table:b,h2:({children:v})=>e.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-muted, #6b7280)",marginBottom:8},children:v}),h3:({children:v})=>e.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-muted, #6b7280)",marginBottom:8},children:v}),p:({children:v})=>e.jsx("p",{style:{fontSize:11,color:"var(--text-muted, #6b7280)",margin:"4px 0",lineHeight:1.5},children:v}),li:({children:v})=>e.jsx("li",{style:{fontSize:11,color:"var(--text-muted, #6b7280)",marginBottom:2},children:v}),strong:({children:v})=>e.jsx("strong",{style:{color:"var(--text-secondary, #94a3b8)"},children:v}),a:({href:v,children:o})=>e.jsx("a",{href:v??"#",target:"_blank",rel:"noopener noreferrer",style:{color:"rgba(184,98,27,
110.6)",textDecoration:"none"},children:o})},children:A})})]})})()}),P&&t.mode==="report"&&Ht.createPortal(e.jsx(et,{markdown:t.markdown,onClose:()=>T(!1)}),document.body)]})}const Sr=` 12@keyframes rp-slide-in { 13 from { transform: translateX(20px); opacity: 0; } 14 to { transform: translateX(0); opacity: 1; } 15} 16@keyframes voice-orb-pulse { 17 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(184,98,27,0.3); } 18 50% { transform: scale(1.08); box-shadow: 0 0 20px 8px rgba(184,98,27,0.15); } 19} 20@keyframes voice-orb-breathe { 21 0%, 100% { transform: scale(1); } 22 50% { transform: scale(1.05); } 23} 24@keyframes voice-orb-think { 25 0%, 100% { opacity: 0.7; } 26 50% { opacity: 1; } 27} 28@keyframes voice-orb-spin { 29 from { transform: rotate(0deg); } 30 to { transform: rotate(360deg); } 31} 32@keyframes voice-hint-fade { 33 0%, 100% { opacity: 0.4; } 34 50% { opacity: 0.8; } 35} 36@keyframes voice-pulse { 37 0%, 100% { opacity: 0.6; } 38 50% { opacity: 1; } 39} 40`,O={panel:{display:"flex",flexDirection:"column",flex:1,minWidth:0,borderLeft:"1px solid rgba(184,98,27,0.15)",background:"rgba(10,15,26,0.6)",animation:"rp-slide-in 0.3s ease forwards",height:"100%"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",borderBottom:"1px solid rgba(255,255,255,0.06)",background:"rgba(10,15,26,0.8)",backdropFilter:"blur(12px)",position:"sticky",top:0,zIndex:10,flexShrink:0},headerLeft:{display:"flex",alignItems:"center",gap:10},headerIcon:{width:28,height:28,borderRadius:6,background:"rgba(184,98,27,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},headerTitle:{fontFamily:"'Public Sans', sans-serif",fontSize:14,fontWeight:600,color:"var(--text-primary, #f1f5f9)"},headerSub:{fontFamily:"'JetBrains Mono', monospace",fontSize:10,color:"var(--text-muted, #6b7280)",letterSpacing:"0.03em"},headerRight:{display:"flex",alignItems:"center",gap:8},headerActionPrimary:{display:"flex",alignItems:"center",padding:"7px 14px",borderRadius:8,border:"none",background:"#B8621B",color:"#fff",fontSize:12,fontWeight:600,fontFamily:"'Public Sans', sans-serif",cursor:"pointer",transition:"all 0.2s",whiteSpace:"nowrap"},headerActionSecondary:{display:"flex",alignItems:"center",padding:"7px 12px",borderRadius:8,border:"1px solid rgba(184,98,27,0.3)",background:"rgba(184,98,27,0.08)",color:"#D4742A",fontSize:12,fontWeight:500,fontFamily:"'Public Sans', sans-serif",cursor:"pointer",transition:"all 0.2s",whiteSpace:"nowrap"},closeButton:{width:32,height:32,borderRadius:8,border:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.03)",color:"var(--text-muted, #6b7280)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s"},body:{flex:1,overflowY:"auto",padding:"24px 28px"},progressWrapper:{maxWidth:520,margin:"0 auto"},reportContent:{fontSize:14,lineHeight:1.7,color:"var(--text-primary, #f1f5f9)"}};function kr({user:t,profile:p,activeTab:u,onTabChange:g,onOpenAuth:i,onOpenProfile:l,onTogglePersonalization:P,onSignOut:T}){const[R,S]=s.useState(!1),[k,w]=s.useState(!1),M=()=>e.jsxs("span",{style:{fontFamily:"Archivo, sans-serif",fontWeight:700,fontSize:"20px",color:"var(--text-primary)",cursor:"pointer",letterSpacing:"-0.02em"},children:["Akil",e.jsx("span",{style:{color:"var(--amber)"},children:"."})]}),z=()=>t?p?.personalizationEnabled&&p.onboardingComplete?e.jsxs("button",{onClick:P,style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"var(--radius-full)",border:"1px solid rgba(107, 124, 62, 0.4)",background:"rgba(107, 124, 62, 0.1)",cursor:"pointer",fontSize:"12px",color:"#a3b565",fontFamily:"Public Sans, sans-serif",fontWeight:500,whiteSpace:"nowrap"},title:"Click to turn off personalization",children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--green)",display:"inline-block"}}),p.orgName?.split(" ")[0]??"Profile"]}):e.jsxs("button",{onClick:P,style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 12px",borderRadius:"var(--radius-full)",border:"1px solid var(--border)",background:"transparent",curs
40or:"pointer",fontSize:"12px",color:"var(--text-muted)",fontFamily:"Public Sans, sans-serif",whiteSpace:"nowrap"},title:"Click to turn on personalization",children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#4b5563",display:"inline-block"}}),"General search"]}):null,j=t?.email?.[0]?.toUpperCase()??"?";return e.jsxs(e.Fragment,{children:[e.jsxs("header",{style:{height:"56px",borderBottom:"1px solid var(--border)",display:"flex",alignItems:"center",padding:"0 20px",gap:"16px",position:"sticky",top:0,background:"rgba(10, 15, 26, 0.95)",backdropFilter:"blur(8px)",zIndex:50,flexShrink:0},children:[e.jsx("a",{href:"/",style:{textDecoration:"none"},children:e.jsx(M,{})}),e.jsx("div",{className:"hidden md:flex",style:{fontSize:"10px",fontWeight:700,letterSpacing:"0.1em",color:"#D4742A",fontFamily:"'JetBrains Mono', monospace",background:"rgba(212, 116, 42, 0.08)",border:"1px solid rgba(212, 116, 42, 0.2)",padding:"3px 8px",borderRadius:"4px",whiteSpace:"nowrap"},children:"NEW YORK CITY EDITION"}),e.jsx("div",{style:{flex:1}}),e.jsx("div",{className:"hidden md:flex",style:{display:"flex",alignItems:"center",gap:28},children:[{label:"About",href:"/about"},{label:"MCP",href:"/mcp"},{label:"Pricing",href:"/pricing"},...t?.email==="[email protected]"?[{label:"Admin",href:"/admin"}]:[]].map(n=>e.jsx("a",{href:n.href,style:{fontFamily:"Public Sans, sans-serif",fontSize:"14px",fontWeight:500,color:"var(--text-muted)",textDecoration:"none",transition:"color 0.15s"},onMouseEnter:d=>d.currentTarget.style.color="var(--text-secondary)",onMouseLeave:d=>d.currentTarget.style.color="var(--text-muted)",children:n.label},n.label))}),e.jsx("div",{style:{flex:1}}),e.jsx("div",{className:"hidden sm:block",children:z()}),t?e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>w(!k),style:{width:"32px",height:"32px",borderRadius:"50%",background:"var(--amber-soft)",border:"1px solid var(--amber)",color:"var(--amber)",fontFamily:"Public Sans, sans-serif",fontSize:"13px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:j}),k&&e.jsxs("div",{className:"fade-in",style:{position:"absolute",top:"calc(100% + 8px)",right:0,background:"var(--surface)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",minWidth:"160px",zIndex:60,overflow:"hidden"},children:[[{label:"Edit Profile",action:()=>{l(),w(!1)}}].map(({label:n,action:d})=>e.jsx("button",{onClick:d,style:{display:"block",width:"100%",padding:"10px 16px",background:"none",border:"none",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"14px",color:"var(--text-secondary)",textAlign:"left",transition:"background 0.1s"},onMouseEnter:y=>y.currentTarget.style.background="rgba(255,255,255,0.04)",onMouseLeave:y=>y.currentTarget.style.background="none",children:n},n)),e.jsx("div",{style:{height:1,background:"var(--border)"}}),e.jsx("button",{onClick:()=>{T(),w(!1)},style:{display:"block",width:"100%",padding:"10px 16px",background:"none",border:"none",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"14px",color:"var(--text-muted)",textAlign:"left",transition:"background 0.1s"},onMouseEnter:n=>n.currentTarget.style.background="rgba(255,255,255,0.04)",onMouseLeave:n=>n.currentTarget.style.background="none",children:"Sign out"})]})]}):e.jsx("button",{onClick:i,style:{background:"none",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text-secondary)",fontFamily:"Public Sans, sans-serif",fontSize:"14px",fontWeight:500,padding:"7px 16px",cursor:"pointer",transition:"border-color 0.15s"},onMouseEnter:n=>n.currentTarget.style.borderColor="var(--border-light)",onMouseLeave:n=>n.currentTarget.style.borderColor="var(--border)",children:"Sign in"}),t&&e.jsx("button",{onClick:()=>S(!R),className:"block sm:hidden",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary)",fontSize:"18px",padding:"4px"},children:R?"â":"â°"}),k&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:55},onClick:()=>w(!1)})]}),R&&t&&e.jsxs("div",{className:"block sm:hidden fade-in",style:{background:"var(--surface)",borderBottom:"1px solid var(--border)",padding:"16px 20px",zIndex:49},children:[[{label:"ð¬ Chat",tab:"chat"}].map(({label:n,tab:d})=>e.jsx("button",{onClick:()=>{g(d),S(!1)},style:{display:"block",width:"100%",padding:"12px 0",background:"none",border:"none",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"16px",color:u===d?"var(--text-primary)":"var(--text-muted)",fontWeight:u===d?600:400,textAlign:"left"},children:n},d)),e.jsx("div",{style:{height:1,background:"var(--border)",margin:"8px 0"}}),e.jsx("button",{onClick:()=>{l(),S(!1)},style:{display:"block",width:"100%",padding:"12px 0",background:"none",border:"none",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"15px",color:"var(--text-muted)",textAlign:"left"},children:"Edit Profile"}),e.jsx("button",{onClick:()=>{T(),S(!1)},style:{display:"block",width:"100%",padding:"12px 0",background:"none",border:"none",cursor:"pointer",fontFamily:"Public Sans, sans-serif",fontSize:"15px",color:"var(--text-muted)",textAlign:"left"},children:"Sign out"})]})]})}function wr({enabled:t,onToggle:p,disabled:u=!1}){return e.jsxs("button",{onClick:p,disabled:u,"aria-pressed":t,"aria-label":t?"Research mode on â click to disable":"Enable research mode",title:t?"Research mode ON â deeper, slower answers. Click to turn off.":"Research mode â full pipeline (Planner â Collector â Writer). Slower but deeper.",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",height:36,borderRadius:10,background:t?"rgba(184, 98, 27, 0.18)":"transparent",border:`1px solid ${t?"rgba(184, 98, 27, 0.5)":"rgba(255,255,255,0.08)"}`,color:t?"#D4742A":"var(--text-muted)",cursor:u?"default":"pointer",flexShrink:0,transition:"all 0.2s",fontFamily:"Public Sans, sans-serif",fontSize:13,fontWeight:t?600:500,opacity:u?.5:1},onMouseEnter:g=>{u||t||(g.currentTarget.style.background="rgba(255,255,255,0.06)",g.currentTarget.style.color="#D4742A")},onMouseLeave:g=>{u||t||(g.currentTarget.style.background="transparent",g.currentTarget.style.color="var(--text-muted)")},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("polygon",{points:"14.5 9.5 9.5 11.5 11.5 16.5 16.5 14.5",fill:"currentColor",stroke:"none",opacity:t?.9:.7})]}),"Research"]})}function rt({onSubmit:t,loading:p=!1,placeholder:u="Ask Akil...",autoFocus:g=!1,attachedFile:i,onFileSelect:l,onFileRemove:P,onFileError:T,onStop:R,voiceActive:S=!1,voiceState:k="idle",onVoiceToggle:w,researchMode:M,onResearchModeToggle:z}){const[j,n]=s.useState(""),[d,y]=s.useState(!1),[A,b]=s.useState(!1),v=s.useRef(null),o=s.useRef(null),f=s.useRef(null),F=s.useRef(null);s.useEffect(()=>{g&&v.current&&v.current.focus()},[g]),s.useEffect(()=>{if(!d)return;const h=Y=>{f.current&&!f.current.contains(Y.target)&&F.current&&!F.current.contains(Y.target)&&y(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[d]);const C=()=>{const h=j.trim();!h||p||(t(h),n(""),v.current&&(v.current.style.height="auto"))},m=h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),C())},H=()=>{const h=v.current;h&&(h.style.height="auto",h.style.height=Math.min(h.scrollHeight,160)+"px")},K=async h=>{const Y=h.target.files?.[0];if(Y){h.target.value="";try{const Z=await Qt(Y);l?.(Z)}catch(Z){T?.(Z.message??"Failed to process file.")}}};return e.jsxs("div",{children:[i&&P&&e.jsx(Ut,{file:i,onRemove:P}
40),e.jsxs("div",{style:{border:`1px solid ${A?"rgba(184,98,27,0.5)":"#2D3748"}`,borderRadius:20,overflow:"visible",background:"#111827",boxShadow:A?"0 8px 40px rgba(184,98,27,0.12), 0 0 0 1px rgba(184,98,27,0.15)":"0 8px 40px rgba(0,0,0,0.4)",transition:"border-color 0.2s, box-shadow 0.2s",position:"relative"},children:[e.jsx("div",{style:{padding:"18px 20px 8px 20px"},children:e.jsx("textarea",{ref:v,value:j,onChange:h=>n(h.target.value),onKeyDown:m,onInput:H,onFocus:()=>b(!0),onBlur:()=>b(!1),placeholder:u,rows:1,style:{width:"100%",background:"transparent",border:"none",outline:"none",resize:"none",color:"var(--text-primary)",fontFamily:"Public Sans, sans-serif",fontSize:"16px",lineHeight:"1.5",maxHeight:"160px",overflowY:"auto",padding:0},className:"placeholder:text-[var(--text-muted)]"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"6px 10px 10px 10px",gap:4},children:[e.jsx("button",{ref:F,onClick:()=>y(h=>!h),disabled:p,style:{background:"none",border:"1px solid rgba(255,255,255,0.08)",borderRadius:10,color:d||i?"var(--amber)":"var(--text-muted)",fontSize:"20px",width:36,height:36,cursor:p?"default":"pointer",flexShrink:0,transition:"color 0.15s, transform 0.2s, background 0.15s",lineHeight:1,transform:d?"rotate(45deg)":"none",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:h=>{p||(h.currentTarget.style.background="rgba(255,255,255,0.06)")},onMouseLeave:h=>{h.currentTarget.style.background="none"},"aria-label":"Attach options","aria-expanded":d,children:"+"}),d&&e.jsx("div",{ref:f,style:{position:"absolute",bottom:"calc(100% + 8px)",left:0,background:"#1a2236",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"12px",padding:"6px",minWidth:"220px",boxShadow:"0 12px 40px rgba(0,0,0,0.5)",zIndex:50,animation:"menu-fade-in 0.15s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",opacity:.35},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48"})}),e.jsxs("span",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"13px",color:"var(--text-muted)"},children:["Add file",e.jsx("span",{style:{fontFamily:"'JetBrains Mono', monospace",fontSize:"9px",marginLeft:"6px",padding:"1px 5px",background:"rgba(255,255,255,0.06)",borderRadius:"4px",verticalAlign:"middle"},children:"SOON"})]})]})}),z&&e.jsx(wr,{enabled:M??!1,onToggle:z,disabled:p}),e.jsx("input",{ref:o,type:"file",accept:Yt.join(","),onChange:K,style:{display:"none"}}),e.jsx("div",{style:{flex:1}}),w&&e.jsxs("button",{onClick:w,disabled:p,style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 14px",borderRadius:10,background:S?"rgba(184,98,27,0.15)":"transparent",border:S?"1px solid rgba(184,98,27,0.4)":"1px solid rgba(255,255,255,0.08)",color:S?"#D4742A":"var(--text-muted)",cursor:p?"default":"pointer",flexShrink:0,transition:"all 0.2s",fontFamily:"'Public Sans', sans-serif",fontSize:"13px",fontWeight:500,height:36,animation:k==="listening"?"voice-pulse 1.5s ease-in-out infinite":"none"},onMouseEnter:h=>{S||(h.currentTarget.style.background="rgba(255,255,255,0.06)",h.currentTarget.style.color="#D4742A")},onMouseLeave:h=>{S||(h.currentTarget.style.background="transparent",h.currentTarget.style.color="var(--text-muted)")},"aria-label":S?"Stop voice":"Start voice",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("rect",{x:"1",y:"6",width:"2",height:"4",rx:"1",fill:"currentColor",opacity:S?"1":"0.6"}),e.jsx("rect",{x:"4.5",y:"3",width:"2",height:"10",rx:"1",fill:"currentColor",opacity:S?"1":"0.7"}),e.jsx("rect",{x:"8",y:"5",width:"2",height:"6",rx:"1",fill:"currentColor",opacity:S?"1":"0.8"}),e.jsx("rect",{x:"11.5",y:"4",width:"2",height:"8",rx:"1",fill:"currentColor"})]}),S?"End":"Talk"]}),e.jsx("button",{onClick:p?R:C,disabled:!1,style:{width:36,height:36,borderRadius:"50%",background:p?"rgba(184,98,27,
400.5)":"#B8621B",border:"none",color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"background 0.2s"},onMouseEnter:h=>{h.currentTarget.style.background=p?"rgba(184,98,27,0.65)":"#D4742A"},onMouseLeave:h=>{h.currentTarget.style.background=p?"rgba(184,98,27,0.5)":"#B8621B"},"aria-label":p?"Stop":"Send",children:p?e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"})}):e.jsx(_t,{size:18,color:"#fff"})})]})]})]})}const Xe=["Pulling from public record sources...","Analyzing tax filings and financial records...","Cross-referencing city payments with federal awards...","Matching against NYC Checkbook and audit records...","Compiling findings from public records..."],jr=[{after:10,text:"Searching across multiple databases..."},{after:20,text:"Cross-referencing records takes a moment..."},{after:35,text:"Complex queries can take up to 60 seconds..."},{after:50,text:"Almost there â compiling results..."},{after:70,text:"Still working â this is a thorough search..."},{after:90,text:"Wrapping up â finalizing your report..."},{after:105,text:"This is taking longer than expected â you can stop and try a simpler question."}];function Cr({queryId:t,query:p,onStop:u}){const[g,i]=s.useState(0),[l,P]=s.useState(0),T=s.useRef(Date.now());s.useEffect(()=>{T.current=Date.now(),P(0);const b=setInterval(()=>{P(Math.floor((Date.now()-T.current)/1e3))},1e3);return()=>clearInterval(b)},[t]),s.useEffect(()=>{if(!u)return;const b=setTimeout(()=>u(),12e4);return()=>clearTimeout(b)},[t,u]),s.useEffect(()=>{const b=setInterval(()=>{i(v=>(v+1)%Xe.length)},3e3);return()=>clearInterval(b)},[]);const R=ge(E.queryStatus.getStatus,t?{queryId:t}:"skip"),S=R?.steps??[],k=S.findLast(b=>b.status==="active"),w=S.filter(b=>b.status==="done"),M=S.length,z=R?.status==="generating",j=R?.status==="enriching",n=R?.planText;let d=null;z?d="Compiling findings into your report...":j&&!k?d="Gathering additional public records...":k&&(d=k.label+"...");const y=jr.filter(b=>l>=b.after).pop(),A=b=>{if(b<60)return`${b}s`;const v=Math.floor(b/60),o=b%60;return`${v}m ${o}s`};return e.jsxs("div",{style:{background:"rgba(184,98,27,0.04)",border:"1px solid rgba(184,98,27,0.2)",borderRadius:"14px",padding:"24px",display:"flex",flexDirection:"column",alignItems:"center",gap:"14px"},className:"fade-in",children:[p&&e.jsx("p",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"14px",lineHeight:1.6,color:"var(--text-primary)",margin:0,alignSelf:"stretch",paddingBottom:"10px",borderBottom:"1px solid rgba(184,98,27,0.12)"},children:p}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"12px",width:"100%"},children:[e.jsx("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[0,1,2].map(b=>e.jsx("span",{className:`dot-${b+1}`,style:{width:8,height:8,borderRadius:"50%",background:"var(--amber)",display:"inline-block"}},b))}),l>=3&&e.jsx("span",{style:{fontFamily:"JetBrains Mono, monospace",fontSize:"11px",color:"rgba(184,98,27,0.45)",letterSpacing:"0.04em"},children:A(l)})]}),e.jsx("p",{style:{fontFamily:"JetBrains Mono, monospace",fontSize:"12px",color:"var(--amber)",margin:0,letterSpacing:"0.04em",transition:"opacity 0.3s",textAlign:"center"},children:d??Xe[g]}),M>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",maxWidth:"260px"},children:[e.jsx("div",{style:{flex:1,height:"3px",background:"rgba(184,98,27,0.12)",borderRadius:"2px",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",background:"var(--amber)",borderRadius:"2px",width:`${M>0?w.length/Math.max(M,w.length+1)*100:0}%`,transition:"width 0.5s ease"}})}),e.jsxs("span",{style:{fontFamily:"JetBrains Mono, monospace",fontSize:"10px",color:"rgba(184,98,27,0.4)",whiteSpace:"nowrap"},children:[w.length,"/",M," sources"]})]}),y&&!z&&e.jsx("p",{className:"fade-in",style:{fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-secondary)",margin:0,opacity:.7,textAlign:"center"},children:y.text},y.after),n&&e.jsx("p",{className:"fade-in",style:{fontFamily:"Public Sans, sans-serif",fontSize:"14px",lineHeight:1.7,color:"var(--text-secondary)",margin:0,alignSelf:"stretch",borderTop:"1px solid rgba(184,98,27,
400.12)",paddingTop:"12px"},children:n}),w.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px",alignSelf:"stretch",borderTop:"1px solid rgba(184,98,27,0.12)",paddingTop:"12px"},children:w.map((b,v)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",fontFamily:"JetBrains Mono, monospace",fontSize:"11px",color:"rgba(184,98,27,0.5)"},children:[e.jsx(Pe,{size:12,color:"rgba(184,98,27,0.5)",style:{flexShrink:0}}),e.jsx("span",{children:b.label})]},v))})]})}function Tr({profile:t,onClick:p}){return e.jsxs("div",{onClick:p,style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 10px",borderRadius:"var(--radius-full)",background:"var(--olive-soft)",border:"1px solid rgba(107, 124, 62, 0.3)",fontSize:"12px",color:"#a3b565",marginBottom:"12px",cursor:p?"pointer":"default"},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--green)",display:"inline-block",flexShrink:0}}),e.jsxs("span",{style:{fontFamily:"Public Sans, sans-serif",fontWeight:500},children:["Personalized for ",t.orgName,t.focusAreas?.length?` · ${t.focusAreas[0]}`:"",t.borough?` · ${t.borough}`:""]})]})}function Pr({parsed:t,thinking:p,profile:u,isAuthenticated:g,onOpenAuth:i,onOpenProfile:l,model:P,reportInPanel:T}){const[R,S]=s.useState(!1),[k,w]=s.useState(!1),M=t.mainText.includes("<!-- REPORT_COMPLETE -->"),z=M?t.bodyText.replace("<!-- REPORT_COMPLETE -->","").trim():t.bodyText,j=async()=>{const n=t.mainText;try{await navigator.clipboard.writeText(n)}catch{const d=document.createElement("textarea");d.value=n,d.style.position="fixed",d.style.left="-9999px",document.body.appendChild(d),d.select(),document.execCommand("copy"),document.body.removeChild(d)}S(!0),setTimeout(()=>S(!1),2e3)};if(T){const n=z.match(/^#+\s+(.+)/m),d=n?n[1]:"Analysis Complete",y=z.split(/\s+/).length;return e.jsx("div",{className:"fade-in",children:e.jsxs("div",{style:{background:"rgba(184,98,27,0.05)",border:"1px solid rgba(184,98,27,0.2)",borderRadius:14,padding:"20px 24px"},children:[e.jsx("div",{style:{fontFamily:"'JetBrains Mono', monospace",fontSize:10,fontWeight:700,color:"#D4742A",textTransform:"uppercase",letterSpacing:"0.12em",marginBottom:12},children:"â Report Generated"}),e.jsx("div",{style:{fontFamily:"'Archivo', sans-serif",fontSize:16,fontWeight:600,color:"var(--text-primary, #f1f5f9)",marginBottom:8,lineHeight:1.4},children:d}),e.jsxs("div",{style:{fontFamily:"'JetBrains Mono', monospace",fontSize:11,color:"var(--text-muted, #6b7280)",marginBottom:16,display:"flex",gap:12},children:[e.jsxs("span",{children:[y.toLocaleString()," words"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[t.sourceNames.length," source",t.sourceNames.length!==1?"s":""]})]}),e.jsxs("div",{style:{fontSize:13,color:"var(--text-muted, #6b7280)",display:"flex",alignItems:"center",gap:6},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:[e.jsx("path",{d:"M5 7l2 2 4-4",stroke:"#D4742A",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("circle",{cx:"7",cy:"7",r:"6",stroke:"#D4742A",strokeWidth:"1.2"})]}),e.jsx("span",{children:"Full report is displayed in the panel â"})]})]})})}return e.jsxs("div",{className:"fade-in",children:[e.jsxs("div",{style:{background:"rgba(184,98,27,0.05)",border:"1px solid rgba(184,98,27,0.35)",borderRadius:"14px",boxShadow:"0 0 48px rgba(184,98,27,0.10)",padding:"clamp(16px, 3vw, 24px)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsxs("div",{style:{fontFamily:"'JetBrains Mono', monospace",fontSize:"10px",fontWeight:700,color:"#D4742A",textTransform:"uppercase",letterSpacing:"0.12em",background:"rgba(212,116,42,0.1)",border:"1px solid rgba(212,116,42,0.25)",borderRadius:"4px",padding:"3px 8px"},children:["â Akil Intelligence",P==="grok"?" · Grok":""]}),e.jsx("button",{onClick:j,style:{background:"none",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text-muted)",fontFamily:"Public Sans, sans-serif",fontSize:"11px",padding:"4px 10px",cursor:"pointer",transition:"all 0.15s"},onMouseEnter:n=>
40{n.currentTarget.style.borderColor="var(--border-light)",n.currentTarget.style.color="var(--text-secondary)"},onMouseLeave:n=>{n.currentTarget.style.borderColor="var(--border)",n.currentTarget.style.color="var(--text-muted)"},children:R?e.jsx(Pe,{size:14}):e.jsx(Ve,{size:14})})]}),u?.personalizationEnabled&&u.onboardingComplete&&e.jsx(Tr,{profile:u,onClick:l}),e.jsx("div",{className:"akil-prose",children:e.jsx(xe,{remarkPlugins:[fe],urlTransform:Me,components:Re,children:tt(z)})}),e.jsx($t,{sourceNames:t.sourceNames,verifyUrls:t.verifyUrls}),e.jsx(gr,{isAuthenticated:g,onRequireAuth:i}),e.jsx(Jt,{thinking:p,isAuthenticated:g,onOpenAuth:i}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"16px",paddingTop:"12px",borderTop:"1px solid rgba(184,98,27,0.15)"},children:e.jsx("button",{onClick:j,style:{background:"none",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text-muted)",fontFamily:"Public Sans, sans-serif",fontSize:"11px",padding:"4px 10px",cursor:"pointer",transition:"all 0.15s"},onMouseEnter:n=>{n.currentTarget.style.borderColor="var(--border-light)",n.currentTarget.style.color="var(--text-secondary)"},onMouseLeave:n=>{n.currentTarget.style.borderColor="var(--border)",n.currentTarget.style.color="var(--text-muted)"},children:R?e.jsx(Pe,{size:14}):e.jsx(Ve,{size:14})})})]}),k&&M&&e.jsx(et,{markdown:t.mainText,onClose:()=>w(!1)}),M&&e.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:16},children:e.jsxs("button",{onClick:()=>w(!0),style:{background:"rgba(184,98,27,0.12)",border:"1px solid rgba(184,98,27,0.4)",borderRadius:10,color:"#D4742A",fontFamily:"Public Sans, sans-serif",fontSize:14,fontWeight:600,padding:"12px 28px",cursor:"pointer",transition:"all 0.2s",display:"flex",alignItems:"center",gap:8},onMouseEnter:n=>{n.currentTarget.style.background="rgba(184,98,27,0.2)"},onMouseLeave:n=>{n.currentTarget.style.background="rgba(184,98,27,0.12)"},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M8 2v8m0 0l-3-3m3 3l3-3M3 12h10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Download Report (PDF)"]})})]})}function Rr({questions:t,onSelect:p}){return t.length?e.jsxs("div",{children:[e.jsx("p",{style:{fontFamily:"'JetBrains Mono', monospace",fontSize:"10px",fontWeight:700,color:"var(--amber)",textTransform:"uppercase",letterSpacing:"0.1em",marginBottom:"10px"},children:"Explore further"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:t.map((u,g)=>e.jsxs("button",{onClick:()=>p(u),style:{background:"rgba(15,23,42,0.6)",border:"1px solid #1E293B",borderRadius:"10px",color:"var(--text-secondary)",fontFamily:"Public Sans, sans-serif",fontSize:"14px",padding:"12px 16px",cursor:"pointer",textAlign:"left",transition:"all 0.2s",width:"100%",display:"flex",alignItems:"flex-start",gap:"10px"},onMouseEnter:i=>{const l=i.currentTarget;l.style.background="rgba(184,98,27,0.1)",l.style.borderColor="rgba(184,98,27,0.35)",l.style.color="#D4742A"},onMouseLeave:i=>{const l=i.currentTarget;l.style.background="rgba(15,23,42,0.6)",l.style.borderColor="#1E293B",l.style.color="var(--text-secondary)"},children:[e.jsx("span",{style:{fontFamily:"'JetBrains Mono', monospace",fontSize:"11px",color:"var(--amber)",flexShrink:0,marginTop:"1px"},children:"â"}),u]},g))})]}):null}function Mr({pastResults:t}){const[p,u]=s.useState(null);return t.length?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:t.map((g,i)=>e.jsxs("div",{children:[e.jsxs("div",{onClick:()=>u(p===i?null:i),style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",background:"rgba(17, 24, 39, 0.5)",border:"1px solid rgba(31, 41, 55, 0.5)",borderRadius:"var(--radius-sm)",cursor:"pointer",transition:"color 0.15s"},onMouseEnter:l=>l.currentTarget.style.borderColor="var(--border)",onMouseLeave:l=>l.currentTarget.style.borderColor="rgba(31, 41, 55, 0.5)",children:[e.jsxs("span",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"14px",color:"var(--text-muted)"},children:["⺠",g.query.length>70?g.query.slice(0,70)+"...":g.query]}),e.jsx("span",{style:{fontFamily:"JetBrains Mono, monospace",fontSize:"11px",color:"var(--text-muted)"},children:p===i?"[-]":"[+]"})]}),p===i&&e.jsx("div",{className:"fade-in akil-prose",style:{padding:"16px",background:"var(--surface-card)",border:"1px solid var(--border)",borderRadius:"0 0 var(--radius-sm) var(--radius-sm)",marginTop:"-1px"},children:e.jsx(xe,{remarkPlugins:[fe],components:{a:({href:l,children:P,...T})=>e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",...T,children:P})},children:g.parsed.mainText})})]},i))}):null}function zr({onPersonalize:t}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 16px",background:"rgba(184, 98, 27, 0.05)",borderBottom:"1px solid rgba(184, 98, 27, 0.2)",fontSize:"12px"},children:[e.jsx("span",{style:{color:"rgba(224, 123, 58, 0.8)",fontFamily:"Public Sans, sans-serif"},children:"Complete your profile for personalized answers"}),e.jsx("button",{onClick:t,style:{background:"none",border:"none",cursor:"pointer",color:"#e07b3a",fontFamily:"Public Sans, sans-serif",fontWeight:500,fontSize:"12px",padding:0,transition:"color 0.15s"},onMouseEnter:p=>p.target.style.color="#c96e32",onMouseLeave:p=>p.target.style.color="#e07b3a",children:"Personalize â"})]})}const Fr=["Senior Services","Immigration","Mental Health","Housing","Youth Development","Legal Services","Food Access","Education","Workforce","Disability","Public Safety","Economic Development","Environment","Health","Transportation"],Ir=["Manhattan","Brooklyn","Queens","Bronx","Staten Island","Citywide"];function Ar({profile:t,onSave:p,onClose:u}){const[g,i]=s.useState(t?.orgName??""),[l,P]=s.useState(t?.role??""),[T,R]=s.useState(t?.focusAreas??[]),[S,k]=s.useState(t?.borough??""),[w,M]=s.useState(t?.personalizationEnabled??!0),[z,j]=s.useState(!1),[n,d]=s.useState(!1),y=async()=>{j(!0),await p({orgName:g||void 0,role:l||void 0,focusAreas:T.length?T:void 0,borough:S||void 0,personalizationEnabled:w,onboardingComplete:!0}),j(!1),d(!0),setTimeout(()=>d(!1),2e3)},A=o=>{R(f=>f.includes(o)?f.filter(F=>F!==o):[...f,o])},b={width:"100%",background:"rgba(255,255,255,0.04)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text-primary)",fontFamily:"Public Sans, sans-serif",fontSize:"14px",padding:"10px 14px",outline:"none",boxSizing:"border-box"},v={display:"block",fontFamily:"Public Sans, sans-serif",fontSize:"12px",fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"8px"};return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100,padding:"16px",overflowY:"auto"},onClick:o=>o.target===o.currentTarget&&u(),children:e.jsxs("div",{className:"fade-in",style:{background:"var(--surface)",border:"1px solid var(--border)",borderRadius:"var(--radius)",padding:"32px",width:"100%",maxWidth:"480px",position:"relative",maxHeight:"90vh",overflowY:"auto"},children:[e.jsx("button",{onClick:u,style:{position:"absolute",top:"16px",right:"16px",background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:"18px"},children:"â"}),e.jsx("h2",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"16px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 24px"},children:"Edit Profile"}
40),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("span",{style:v,children:"Organization"}),e.jsx("input",{type:"text",value:g,onChange:o=>i(o.target.value),placeholder:"Organization name",style:b,onFocus:o=>o.target.style.borderColor="var(--border-light)",onBlur:o=>o.target.style.borderColor="var(--border)"})]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("span",{style:v,children:"Role"}),e.jsx("input",{type:"text",value:l,onChange:o=>P(o.target.value),placeholder:"e.g. Executive Director",style:b,onFocus:o=>o.target.style.borderColor="var(--border-light)",onBlur:o=>o.target.style.borderColor="var(--border)"})]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("span",{style:v,children:"Focus Areas"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:Fr.map(o=>{const f=T.includes(o);return e.jsx("button",{onClick:()=>A(o),style:{background:f?"var(--amber-soft)":"transparent",border:`1px solid ${f?"var(--amber)":"var(--border)"}`,borderRadius:"var(--radius-sm)",color:f?"#e07b3a":"var(--text-muted)",fontFamily:"Public Sans, sans-serif",fontSize:"12px",padding:"5px 10px",cursor:"pointer",transition:"all 0.15s"},children:o},o)})})]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("span",{style:v,children:"Borough"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:Ir.map(o=>{const f=S===o;return e.jsx("button",{onClick:()=>k(f?"":o),style:{background:f?"var(--amber-soft)":"transparent",border:`1px solid ${f?"var(--amber)":"var(--border)"}`,borderRadius:"var(--radius-sm)",color:f?"#e07b3a":"var(--text-muted)",fontFamily:"Public Sans, sans-serif",fontSize:"12px",padding:"5px 10px",cursor:"pointer",transition:"all 0.15s"},children:o},o)})})]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"16px",marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"13px",fontWeight:500,color:"var(--text-primary)",marginBottom:"2px"},children:"Personalization"}),e.jsx("div",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-muted)"},children:"Use my profile to personalize answers"})]}),e.jsx("button",{onClick:()=>M(!w),style:{background:w?"var(--green)":"var(--border-light)",border:"none",borderRadius:"var(--radius-full)",width:"44px",height:"24px",cursor:"pointer",position:"relative",transition:"background 0.2s",flexShrink:0},children:e.jsx("span",{style:{position:"absolute",top:"3px",left:w?"22px":"3px",width:"18px",height:"18px",background:"#fff",borderRadius:"50%",transition:"left 0.2s"}})})]}),e.jsx("button",{onClick:y,disabled:z,style:{width:"100%",background:"var(--amber)",border:"none",borderRadius:"var(--radius-sm)",color:"#fff",fontFamily:"Public Sans, sans-serif",fontSize:"14px",fontWeight:500,padding:"12px",cursor:z?"wait":"pointer"},children:n?"Saved â":z?"Saving...":"Save Changes"})]})})}function Er(t){const u=Date.now()-t,g=new Date(t);if(u<6e4)return"Just now";if(u<36e5)return`${Math.floor(u/6e4)}m ago`;const i=new Date;return g.getDate()===i.getDate()&&g.getMonth()===i.getMonth()&&g.getFullYear()===i.getFullYear()?g.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):g.toLocaleDateString([],{month:"short",day:"numeric"})}function Br({history:t,isLoading:p,onRestore:u}){return p?e.jsx("div",{style:{padding:"40px 16px",textAlign:"center"},children:e.jsx("p",{style:{color:"var(--text-muted)",fontFamily:"Public Sans, sans-serif",fontSize:"14px"},children:"Loading history..."})}):t.length?e.jsxs("div",{style:{padding:"16px",maxWidth:"720px",margin:"0 auto"},children:[e.jsx("h2",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"16px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 6px"},children:"Recent Questions"}),e.jsxs("p",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"13px",color:"var(--text-muted)",margin:"0 0 20px"},children:["Last ",t.length," question",t.length!==1?"s":""]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map(g=>e.jsxs("div",{style:{background:"var(--surface-card)",border:"1px solid var(--border)",borderRadius:"var(--radius)",padding:"16px",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"16px",transition:"border-color 0.15s"},onMouseEnter:i=>i.currentTarget.style.borderColor="var(--border-light)",onMouseLeave:i=>i.currentTarget.style.borderColor="var(--border)",children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"14px",fontWeight:500,color:"var(--text-primary)",margin:"0 0 6px",lineHeight:1.5},children:g.query}),e.jsxs("p",{style:{fontFamily:"JetBrains Mono, monospace",fontSize:"11px",color:"var(--text-muted)",margin:0},children:[Er(g.createdAt),g.sources.length>0&&` · ${g.sources.length} source${g.sources.length!==1?"s":""}`,g.personalizationEnabled?" · Personalized":" · General search"]})]}),e.jsx("button",{onClick:()=>u(g),style:{background:"none",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text-muted)",fontFamily:"Public Sans, sans-serif",fontSize:"12px",fontWeight:500,padding:"6px 12px",cursor:"pointer",whiteSpace:"nowrap",flexShrink:0,transition:"all 0.15s"},onMouseEnter:i=>{const l=i.currentTarget;l.style.borderColor="var(--border-light)",l.style.color="var(--text-secondary)"},onMouseLeave:i=>{const l=i.currentTarget;l.style.borderColor="var(--border)",l.style.color="var(--text-muted)"},children:"Open â"})]},g._id))})]}):e.jsxs("div",{style:{padding:"60px 16px",textAlign:"center"},children:[e.jsx("p",{style:{color:"var(--text-muted)",fontFamily:"Public Sans, sans-serif",fontSize:"14px",marginBottom:"6px"},children:"No questions yet"}),e.jsx("p",{style:{color:"var(--text-muted)",fontFamily:"Public Sans, sans-serif",fontSize:"13px"},children:"Your recent questions will appear here"})]})}function Jr(){Wt();const[t,p]=s.useState(null),[u,g]=s.useState(!1),[i,l]=s.useState("landing"),[P,T]=s.useState("chat"),[R,S]=s.useState(()=>new URLSearchParams(window.location.search).get("segment")),[k,w]=s.useState(null),[M,z]=s.useState(null),[j,n]=s.useState(null),[d,y]=s.useState(null),[A,b]=s.useState([]),[v,o]=s.useState(0),[f,F]=s.useState(!1),[C,m]=s.useState(window.innerWidth);s.useEffect(()=>{const r=()=>m(window.innerWidth);return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]);const[H,K]=s.useState("signin"),[h,Y]=s.useState(null),[Z,he]=s.useState(!1),[nt,ze]=s.useState(!1),[me,ee]=s.useState(null),[Fe,te]=s.useState(null),ye=s.useRef(null),ot=_(E.profiles.migrateAnonymousHistory),st=_(E.visitorTracking.recordVisit),it=_(E.visitorTracking.markConversion),Ie=_(E.pipeline.optionB.trigger.start),at=_(E.pipeline.optionB.grokNative.start),Ae=_(E.pipeline.optionB.trigger.scopeAndContinue),Ee=_(E.pipeline.optionB.trigger.approveAndExecute),Be=_(E.profiles.saveQueryHistory),We=Dt(E.stripe.createCheckoutSession),D=t?.id??ue(),{profile:X,rawProfile:re,isLoading:De,updateProfile:be,togglePersonalization:lt}=Gt(t?.id??null),{history:dt,isLoading:ct}=Vt(D),{messages:B,setMessages:Le,setResults:pt,loading:U,error:$,sessionId:ve,currentLogId:Ne,activeQueryId:ut,updateQuerySignals:gt,submit:xt,cancel:Se,reset:ft,startNewConversation:qe,restoreConversation:Oe,injectResponse:ke,currentResult:I,pastResults:He}=Kt(),W=Xt(),ne=s.useRef(!1),ht=s.useRef(!1),[Ue,ie]=s.useState(!1),{selectedModel:Ye,provider:J,queryMode:mt,setModel:yt,setQueryMode:bt,isAdmin:vt,isAutoMode:St}=Zt(t?.email),{modelTier:G}=er(t?.email);tr();const _e=s.useRef(""),Qe=s.useRef(""),[$e,we]=s.useState(null),{state:ae,isActive:le,startVoice:kt,stopVoice:je}=ur({onTranscript:(r,c)=>{if(c&&r.trim()){const a=r.trim();Qe.current=a,Le(x=>x.length>0&&x[x.length-1].role==="user"&&x[x.length-1].content===a?x:[...x,{role:"user",content:a}]),l("chat-results"),_e.current="",we(null)}},onAgentText:(r,c)=>{if(_e.current=r,Le(a=>{if(a.length>0&&a[a.length-1].role==="assistant"&&!c){const x=[...a];return x[x.length-1]={role:"assistant",content:r},x}if(a.length>0&&a[a.length-1].role==="user")return[...a,{role:"assistant",content:r}];if(a.length>0&&a[a.length-1].role==="assistant"){const x=[...a];return x[x.length-1]={role:"assistant",content:r},x}return a}),c&&r.trim()){const a=Qe.current||"Voice query";pt(x=>[...x,{query:a,parsed:Te(r),thinking:null}]),D&&Be({userId:D,sessionId:ve,query:a,answer:r,sources:[],followUpQuestions:[]}).catch(()=>{})}},onMcpEvent:r=>{console.log("[Voice MCP]",r.type,r.toolName??""),r.type==="tool_call_start"?we(r.toolName??null):r.type==="tool_call_complete"&&we(null)},onReportRequest:async(r,c)=>{console.log("[Voice] Report handoff:",r,c),je();try{const a=await Ie({query:r,provider:J??"claude",userId:D??void 0,segment:R??void 0,reportType:c??k??void 0,tier:G});n(a.workflowId),y({mode:"loading",workflowId:a.workflowId,reportType:c??k??"anal
40ysis",queryText:r}),l("chat-loading")}catch(a){console.warn("[Voice] Pipeline handoff failed:",a.message)}},onError:r=>console.warn("[Voice]",r)}),Je=()=>{le?(je(),B.length===0&&y(null)):(kt(),y({mode:"voice",messages:[],voiceState:"connecting",activeToolName:null}))};s.useEffect(()=>{d?.mode==="voice"&&y({mode:"voice",messages:[...B],voiceState:ae,activeToolName:$e})},[B,ae,$e]);const q=ge(j?E.pipeline.optionB.trigger.getWorkflowStatus:"skip",j?{workflowId:j}:"skip");s.useEffect(()=>{if(!q||!j)return;const r=q.find(x=>x.step==="plan"&&x.status==="complete");if(!r?.data)return;const c=r.data.queryType,a=(r.data.dataSources??[]).length;!d&&(c==="report"||c==="analysis"&&a>=3)&&y({mode:"loading",workflowId:j,reportType:r.data.reportType??"analysis",queryText:r.query})},[q,j]),s.useEffect(()=>{if(!q||!j)return;const r=q.find(c=>c.step==="write"&&c.status==="complete");if(r?.data?.markdown){const c=r.data.markdown,a=q.find(L=>L.step==="plan"),x=a?.query??B.filter(L=>L.role==="user").pop()?.content??"Report",V=a?.data?.queryType;n(null),l("chat-results");const de=q.find(L=>L.step==="gate"&&L.status==="complete");z(de?.data??null);const oe=q.find(L=>L.step==="collect"),zt=(oe?.subSteps??[]).filter(L=>L.status==="complete"&&(L.recordCount??0)>0).length;if(V==="report"||V==="analysis"&&zt>=3){const L=c.split(/\s+/).length,ce=(oe?.subSteps??[]).filter(se=>se.status==="complete").length,pe=r.data?.unverified===!0?" *Data collected by AI â not independently verified.*":"";ke(x,`*Report generated â ${L} words, ${ce} sources. Full report is displayed in the panel.*${pe}`),y({mode:"report",markdown:c,reportType:a?.data?.reportType??"analysis"})}else ke(x,c),y(null);if(D){const L=q.find(N=>N.step==="collect"),ce=q.find(N=>N.step==="check"),Ge=q.find(N=>N.step==="gap_fill"),pe=q.find(N=>N.step==="verify"),se=L?.subSteps??[],Ft=se.filter(N=>N.status==="complete").map(N=>N.source),It=q.reduce((N,At)=>N+(At.durationMs??0),0);Be({userId:D,sessionId:ve,query:x,answer:c,sources:Ft,followUpQuestions:[],workflowId:j,pipelineMetrics:{queryType:a?.data?.queryType??void 0,reportType:a?.data?.reportType??void 0,segment:a?.data?.segment??a?.segment??void 0,sourcesQueried:se.length,sourcesWithData:se.filter(N=>N.status==="complete").length,checkerScore:ce?.data?.score??void 0,gapsFound:ce?.data?.gaps?.length??0,gapsFilled:Ge?.data?.queriesRun??0,verifierPassed:pe?.data?.passed??void 0,verifierCorrections:pe?.data?.issueCount??0,totalDurationMs:It,wordCount:r?.data?.wordCount??void 0}}).catch(()=>{})}}},[q,j]),s.useEffect(()=>{const r=ue();r&&(sessionStorage.getItem("akil_visit_logged")||rr().then(c=>{st({deviceId:r,platform:"desktop",referrer:document.referrer||void 0,ipAddress:c?.ip||void 0,city:c?.city||void 0,region:c?.region||void 0,country:c?.country||void 0}).then(()=>sessionStorage.setItem("akil_visit_logged","1")).catch(()=>{})}))},[]),s.useEffect(()=>{const{data:{subscription:r}}=Lt(c=>{if(p(c),g(!0),c){const a=ue();a&&(ot({anonId:a,realUserId:c.id}).then(()=>qt()).catch(()=>{}),it({deviceId:a,userId:c.id}).catch(()=>{})),nt&&c.email&&(ze(!1),We({email:c.email}).then(x=>{x?.url&&(window.location.href=x.url)}).catch(x=>console.error("Stripe checkout error:",x)))}});return Nt().then(({data:{session:c}})=>{p(c?.user??null),g(!0)}),()=>r?.unsubscribe()},[]),s.useEffect(()=>{t?.id&&t?.email&&be({email:t.email}).catch(()=>{})},[t?.id]),s.useEffect(()=>{if(!u)return;const c=new URLSearchParams(window.location.search).get("action");c&&(window.history.replaceState({},"","/"),c==="signup"&&!t?Y("free"):c==="upgrade"&&(t?.email?We({email:t.email}).then(a=>{a?.url&&(window.location.href=a.url)}).catch(a=>{console.error("Stripe error:",a),alert("Something went wrong. Please try again.")}):(ze(!0),Y("pro"))))},[u,t?.id]),s.useEffect(()=>{if(u){if(!t){U||j?l("chat-loading"):I||$&&B.length>0?l("chat-results"):l("landing");return}if(De){l("chat-empty");return}if(!re){l("chat-empty");return}if(P==="history"){l("history");return}if(U||j){l("chat-loading");return}if(I){l("chat-results");return}if($&&B.length>0){l("chat-results");return}l("chat-empty")}},[u,t,re,De,U,I,$,B,P,j]),s.useEffect(()=>{U&&ye.current&&(ye.current.scrollTop=0)},[U]),s.useEffect(()=>
40{I&&!U&&(nr(I.query),or()||sr())},[I,U]),s.useEffect(()=>{W.isStreaming&&(ht.current=!0)},[W.isStreaming]);const Q=async(r,c)=>{if(U)return;T("chat"),z(null);const a=me;ee(null),te(null);const x=c??k;if(w(null),!x){ne.current=!0,ie(!0),l("chat-results"),W.submit(r,R??void 0,D??void 0,ue()??void 0);return}{l("chat-loading");try{const V=B.slice(-8).map(oe=>`${oe.role==="user"?"User":"Akil"}: ${oe.content.slice(0,300)}`).join(` 41`),de=G==="grok-native"?await at({query:r,provider:"grok",userId:D??void 0,conversationContext:V||void 0}):await Ie({query:r,provider:J??"claude",userId:D??void 0,segment:R??void 0,reportType:x??void 0,tier:G,conversationContext:V||void 0});n(de.workflowId),x&&y({mode:"loading",workflowId:de.workflowId,reportType:x,queryText:r})}catch(V){console.warn("Pipeline failed, falling back to standard:",V.message),n(null),y(null),await xt(r,X,D??void 0,a??void 0,J,St?void 0:Ye,R,x??void 0)}return}},wt=r=>{Ne&>({logId:Ne,followUpClicked:r}).catch(()=>{}),Q(r)},jt=r=>{Oe([{role:"user",content:r.query},{role:"assistant",content:r.answer}],[{query:r.query,parsed:Te(r.answer),thinking:null}],r._id),ie(!1),ne.current=!1,T("chat")},Ct=(r,c,a)=>{Oe(r,c,a),ie(!1),ne.current=!1,T("chat")},Tt=r=>{T(r)},Pt=()=>{!t||!X||lt(!X.personalizationEnabled)},Rt=()=>{Ot(),ft()},Mt=t&&re&&re.onboardingSkipped&&!re.onboardingComplete;return s.useEffect(()=>{const c=new URLSearchParams(window.location.search).get("q");c&&u&&i!=="chat-loading"&&i!=="chat-results"&&(Q(c),window.history.replaceState({},"",window.location.pathname))},[u]),u?e.jsxs("div",{style:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsx(kr,{user:t,profile:X,activeTab:P,onTabChange:Tt,onOpenAuth:()=>F(!0),onOpenProfile:()=>he(!0),onTogglePersonalization:Pt,onSignOut:Rt}),Mt&&e.jsx(zr,{onPersonalize:()=>be({onboardingSkipped:!1,onboardingComplete:!1})}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[!(d&&C<1280)&&e.jsx(yr,{userId:D,activeSessionId:ve,onNewConversation:()=>{qe(),W.startNewConversation(),ie(!1),ne.current=!1,n(null),y(null),l("landing")},onRestore:Ct}),!(d&&C<1024)&&e.jsxs("main",{ref:ye,style:{flex:d?"0 0 380px":"1",minWidth:d?320:void 0,overflowY:"auto",paddingBottom:I||i==="chat-loading"?"0":t?"72px":"0",transition:"flex 0.3s ease",display:i==="landing"||i==="chat-empty"?"flex":void 0,flexDirection:i==="landing"||i==="chat-empty"?"column":void 0},children:[i==="history"&&e.jsx(Br,{history:dt,isLoading:ct,onRestore:jt}),(i==="landing"||i==="chat-empty")&&e.jsx(Lr,{isMobile:window.innerWidth<640,onSubmit:Q,onInjectResponse:ke,queryLoading:U,attachedFile:me,onFileSelect:r=>{ee(r),te(null)},onFileRemove:()=>ee(null),onFileError:r=>te(r),onStop:Se,isAdminUser:vt,selectedModel:Ye,queryMode:mt,onModelChange:yt,onModeChange:bt,activeSegment:R,onSegmentChange:S,onReportSelect:w,voiceActive:le,voiceState:ae,onVoiceToggle:Je,researchMode:W.researchMode,onResearchModeToggle:W.toggleResearchMode}),i==="chat-loading"&&e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"100%",padding:"24px 16px"},children:e.jsx("div",{style:{maxWidth:"680px",width:"100%"},children:ne.current?e.jsxs("div",{style:{padding:"32px 0",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[e.jsx("p",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"16px",color:"var(--text-primary)",textAlign:"center",margin:0,lineHeight:1.5},children:B.filter(r=>r.role==="user").pop()?.content}),e.jsx(ir,{label:W.toolCallInProgress??"Looking that up..."})]}):j&&d?e.jsx(br,{onQuery:r=>{qe(),W.startNewConversation(),n(null),y(null),setTimeout(()=>Q(r),100)},queryText:d.mode==="loading"?d.queryText:void 0}):j?e.jsx(Ze,{workflowId:j,originalQuery:B.filter(r=>r.role==="user").pop()?.content,onConfirm:async r=>{if(r.type==="scoping"){const c=[...A,{round:r.round,question:r.question,answer:r.answer}];b(c),o(r.round+1);const a=d?.queryText||B.filter(x=>x.role==="user").pop()?.content||"";try{const x=await Ae({originalQuery:a,provider:J??"claude",scopingContext:JSON.stringify(c),scopingRound:r.round+1,userId:D??void 0,tier:G});n(x.workflowId)}catch(x){console.error("scopeAndContinue failed:",x)}}else if(r.type==="plan_approval"){const c=d?.queryText||B.filter(a=>a.role==="user").pop()?.content||"";b([]),o(0),n(null);try{const a=await Ee({approvedPlan:JSON.stringify(r.plan),originalQuery:c,provider:J??"claude",userId:D??void 0,tier:G});n(a.workflowId),y({mode:"loading",workflowId:a.workflowId,reportType:r.plan.reportType??"analysis",queryText:c})}catch(a){console.error("approveAndExecute failed:",a)}}else if(r.type==="clarification")n(null),y(null),Q(r.label);else{n(null),y(null);const c=r.bbl?`Property report on BBL ${r.bbl}`:r.label;Q(c)}}}):e.jsx(Cr,{queryId:ut,query:B.filter(r=>r.role==="user").pop()?.content,onStop:Se})})}),i==="chat-results"&&Ue&&e.jsx(ar,{messages:W.messages,isStreaming:W.isStreaming,toolCallInProgress:W.toolCallInProgress,userInitial:t?.email?.[0]?.toUpperCase()??"?",sessionId:W.sessionId,userEmail:t?.email??null,activeWorkflowId:W.activeWorkflowId}),(i==="chat-results"||I&&i!=="history")&&(I||$)&&e.jsxs("div",{style:{maxWidth:(I?.parsed?.mainText?.includes("<!-- REPORT_COMPLETE -->")||(I?.parsed?.mainText?.length??0)>2e3)&&!d?"960px":"680px",margin:"0 auto",padding:"24px 16px",display:"flex",flexDirection:"column",gap:"16px",transition:"max-width 0.3s ease"},children:[He.length>0&&e.jsx(Mr,{pastResults:He}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",ga
41p:"12px"},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",background:"var(--amber-soft)",border:"1px solid rgba(184,98,27,0.4)",color:"var(--amber)",fontSize:"12px",fontFamily:"Public Sans, sans-serif",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t?.email?.[0]?.toUpperCase()??"?"}),e.jsx("p",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"16px",color:"var(--text-primary)",margin:0,lineHeight:1.5,paddingTop:"4px"},children:I?.query??B.filter(r=>r.role==="user").pop()?.content??""})]}),I&&(lr(I.parsed.mainText)?e.jsx(dr,{answer:I.parsed.mainText}):e.jsx(Pr,{parsed:I.parsed,thinking:I.thinking,profile:X,isAuthenticated:!!t,onOpenAuth:()=>F(!0),onOpenProfile:()=>he(!0),model:I.modelDisplayName,reportInPanel:!!(d&&d.mode==="report")})),M&&I&&!U&&e.jsx(cr,{match:M,onGenerateReport:r=>{const c=r.resolvedEntities?.bbl??"",a=encodeURIComponent(r.resolvedEntities?.address??"");window.location.href=`/reports/property-intelligence?bbl=${c}&address=${a}`}}),$&&e.jsxs("div",{style:{background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",borderRadius:"var(--radius)",padding:"16px"},children:[e.jsx("div",{style:{color:"var(--red)",fontFamily:"Public Sans, sans-serif",fontSize:"14px",fontWeight:500,marginBottom:"4px"},children:"Something went wrong"}),e.jsxs("div",{style:{color:"var(--text-muted)",fontFamily:"Public Sans, sans-serif",fontSize:"12px"},children:[$,". Try rephrasing your question."]})]}),I&&I.parsed.followUpQuestions.length>0&&e.jsx(Rr,{questions:I.parsed.followUpQuestions,onSelect:wt}),!t&&e.jsxs("div",{style:{border:"1px solid rgba(59, 130, 246, 0.2)",background:"rgba(59, 130, 246, 0.05)",borderRadius:"var(--radius)",padding:"16px"},children:[e.jsx("div",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"13px",fontWeight:500,color:"#60a5fa",marginBottom:"8px"},children:"Get personalized answers"}),e.jsxs("div",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"13px",color:"var(--text-muted)",marginBottom:"12px",lineHeight:1.8},children:[e.jsx("div",{children:"⦠See which NYC funding sources your org has received"}),e.jsx("div",{children:"⦠Filter automatically by your borough and focus areas"}),e.jsx("div",{children:"⦠Save your conversation history"})]}),e.jsx("button",{onClick:()=>F(!0),style:{background:"none",border:"1px solid rgba(59, 130, 246, 0.4)",borderRadius:"var(--radius-full)",color:"#60a5fa",fontFamily:"Public Sans, sans-serif",fontSize:"13px",padding:"6px 16px",cursor:"pointer",transition:"background 0.15s"},onMouseEnter:r=>r.currentTarget.style.background="rgba(59, 130, 246, 0.1)",onMouseLeave:r=>r.currentTarget.style.background="none",children:"Create free account â"})]})]})]}),d&&e.jsx(vr,{panel:d,onClose:()=>{y(null),n(null)},onConfirm:async r=>{if(r.type==="scoping"){const c=[...A,{round:r.round,question:r.question,answer:r.answer}];b(c),o(r.round+1);const a=d?.queryText||B.filter(x=>x.role==="user").pop()?.content||"";try{const x=await Ae({originalQuery:a,provider:J??"claude",scopingContext:JSON.stringify(c),scopingRound:r.round+1,userId:D??void 0,tier:G});console.log("[Scoping] Round 2 started, new workflowId:",x.workflowId),n(x.workflowId),y({mode:"loading",workflowId:x.workflowId,reportType:"analysis",queryText:a})}catch(x){console.error("scopeAndContinue failed:",x)}}else if(r.type==="plan_approval"){const c=d?.queryText||B.filter(a=>a.role==="user").pop()?.content||"";b([]),o(0),n(null);try{const a=await Ee({approvedPlan:JSON.stringify(r.plan),originalQuery:c,provider:J??"claude",userId:D??void 0,tier:G});n(a.workflowId),y({mode:"loading",workflowId:a.workflowId,reportType:r.plan.reportType??"analysis",queryText:c})}catch(a){console.error("approveAndExecute failed:",a)}}else if(r.type==="clarification")y(null),n(null),Q(r.label);else{y(null),n(null);const c=r.bbl?`Property report on BBL ${r.bbl}`:r.label;Q(c)}},onReportSubmit:r=>{le&&je(),Q(r)}})]}),(I||$||i==="chat-loading"||Ue)&&i!=="history"&&e.jsxs("div",{className:t?"pb-14 sm:pb-0":"",style:{flexShrink:0,borderTop:"1px solid var(--border)",background:"rgba(10, 15, 26, 0.95)",backdropFilter:"blur(8px)",paddingTop:"12px",paddingBottom:"12px",paddingLeft:"16px",paddingRight:"16px",position:"relative"},children:[U&&e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",background:"rgba(184,98,27,
410.15)",overflow:"hidden"},children:e.jsx("div",{className:"loading-sweep"})}),Fe&&e.jsx("div",{style:{maxWidth:"680px",margin:"0 auto 8px",padding:"8px 12px",background:"rgba(220,38,38,0.1)",border:"1px solid rgba(220,38,38,0.3)",borderRadius:"8px",fontSize:"13px",color:"#f87171",fontFamily:"Public Sans, sans-serif"},children:Fe}),e.jsxs("div",{style:{maxWidth:"680px",margin:"0 auto"},children:[e.jsx(rt,{onSubmit:Q,loading:U||W.isStreaming,placeholder:"Ask a follow-up...",attachedFile:me,onFileSelect:r=>{ee(r),te(null)},onFileRemove:()=>ee(null),onFileError:r=>te(r),onStop:Se,voiceActive:le,voiceState:ae,onVoiceToggle:Je,researchMode:W.researchMode,onResearchModeToggle:W.toggleResearchMode}),e.jsx("div",{style:{textAlign:"center",marginTop:8,fontFamily:"'JetBrains Mono', monospace",fontSize:11,color:"#64748b",letterSpacing:"0.01em"},children:"Akil can make mistakes. Please double check responses."})]})]}),!I&&i!=="chat-loading"&&e.jsx(Nr,{}),f&&e.jsx(xr,{onClose:()=>{F(!1),K("signin")},initialMode:H}),h&&e.jsx(pr,{variant:h,onClose:()=>Y(null),isMobile:window.innerWidth<768}),Z&&e.jsx(Ar,{profile:X,onSave:async r=>{await be(r)},onClose:()=>he(!1)})]}):e.jsx("div",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("div",{style:{fontFamily:"JetBrains Mono, monospace",fontSize:"12px",color:"var(--text-muted)"},children:"Loading..."})})}function Wr(){const t=new Date().getHours();return t<12?"Good morning.":t<17?"Good afternoon.":"Good evening."}const Dr=["Property records","Violations","Campaign finance","Lobbying","Grants","Budgets","Contracts","Nonprofits"];function Lr({isMobile:t,onSubmit:p,onInjectResponse:u,queryLoading:g,attachedFile:i,onFileSelect:l,onFileRemove:P,onFileError:T,onStop:R,isAdminUser:S,selectedModel:k,queryMode:w,onModelChange:M,onModeChange:z,activeSegment:j,onSegmentChange:n,onReportSelect:d,voiceActive:y,voiceState:A,onVoiceToggle:b,researchMode:v,onResearchModeToggle:o}){const[f,F]=s.useState(null),[C,m]=s.useState(!1),[H,K]=s.useState(null);return hr(j??null),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:t?"24px 16px 100px":"0 24px 0",position:"relative",zIndex:1},children:[e.jsx("h1",{style:{fontFamily:"Archivo, sans-serif",fontSize:t?32:40,fontWeight:500,color:"var(--cream, #FAF9F5)",margin:"0 0 40px 0",letterSpacing:"-0.02em",lineHeight:1.2,textAlign:"center"},children:Wr()}),e.jsx("div",{style:{width:"100%",maxWidth:640,marginBottom:16}
41,children:e.jsx(rt,{onSubmit:p,loading:g,autoFocus:!0,attachedFile:i,onFileSelect:l,onFileRemove:P,onFileError:T,onStop:R,voiceActive:y,voiceState:A,onVoiceToggle:b,researchMode:v,onResearchModeToggle:o})}),e.jsx("div",{style:{display:"flex",gap:t?6:8,flexWrap:"wrap",justifyContent:"center",maxWidth:560,marginBottom:20},children:Dr.map((h,Y)=>e.jsx("span",{style:{padding:t?"6px 12px":"5px 14px",borderRadius:6,background:"rgba(184, 98, 27, 0.08)",border:"1px solid rgba(184, 98, 27, 0.18)",color:"#D4742A",fontFamily:"Public Sans, sans-serif",fontSize:t?12:13,fontWeight:500,letterSpacing:"0.01em"},children:h},Y))}),e.jsx("div",{style:{textAlign:"center",fontFamily:"'JetBrains Mono', monospace",fontSize:11,color:"#64748b",letterSpacing:"0.01em"},children:"Akil can make mistakes. Please double check responses."})]})}function Nr(){return e.jsxs("footer",{style:{borderTop:"1px solid rgba(31, 41, 55, 0.5)",padding:"16px 24px",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[e.jsxs("span",{style:{fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-muted)"},children:["Powered by"," ",e.jsx("a",{href:"https://akilventures.com",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--text-secondary)",textDecoration:"none"},onMouseEnter:t=>t.target.style.color="var(--text-primary)",onMouseLeave:t=>t.target.style.color="var(--text-secondary)",children:"Akil Ventures"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",fontFamily:"Public Sans, sans-serif",fontSize:"12px",color:"var(--text-muted)"},children:[e.jsx("a",{href:"/privacy",style:{color:"inherit",textDecoration:"none"},children:"Privacy"}),e.jsx("a",{href:"/terms",style:{color:"inherit",textDecoration:"none"},children:"Terms"}),e.jsx("span",{children:"© 2026 Akil Ventures"})]})]})}export{Jr 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.