1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/aurora-voice-S2ydCitH.js","assets/index-DP61GySm.js","assets/vendor-shared-C5tCw9rW.js","assets/index-BJf8nW0N.css","assets/index-MuG4xkEZ.js","assets/loader-circle-eo-mph3g.js","assets/utils-hQAQiId-.js","assets/x-D235ZOFZ.js","assets/shield-check-BQHCFnRX.js","assets/App-0t6TVAR4.js","assets/use-toast-C6aFH3Eg.js","assets/toaster-BDyw2x6L.js","assets/triangle-alert-CaKCF_Nq.js","assets/section-chips-C68mRSIN.js","assets/chevron-right-qcpptIv2.js","assets/chevron-down-C8mjF8sg.js","assets/trademark-screen-DYufZ-CB.js","assets/sparkles-B4yqwNG6.js","assets/waypoints-C6gFN1cM.js","assets/dialog-B9xd4dRw.js","assets/privacy-I8Fotoxq.js","assets/image-off-CpRV4JaY.js","assets/trial-copy-BQN_0jwW.js","assets/unicorniq-logo-B9mOeuD0.js","assets/App-Bri3Sjey.css","assets/use-live-voice-CicYznrM.js","assets/use-reduced-motion-Dfod_7YK.js","assets/proxy-vcxmOnCc.js","assets/radio-BCn28_eD.js","assets/layout-dashboard-Bx_VpmEh.js"])))=>i.map(i=>d[i]); 2import{_ as Ce}from"./vendor-shared-C5tCw9rW.js";import{r as d,j as e}from"./index-DP61GySm.js";import{u as Q,b as Se,L as Ae}from"./index-MuG4xkEZ.js";import{z as Pe,u as Te,fG as Oe,hB as _e,fH as J,hC as Le,hD as $e,hE as Z,E as g,a2 as N,ai as pe,hF as Ee,ax as qe}from"./loader-circle-eo-mph3g.js";import{u as xe,C as U,c as z,E as te}from"./use-toast-C6aFH3Eg.js";import{a7 as Re,H as Be,a8 as Ve,a9 as Ie,aa as D,ab as he,ac as Ge,ad as Me,ae as Fe,A as se,B as K,af as ge,ag as Ue,ah as le,ai as ze,aj as De}from"./App-0t6TVAR4.js";import{A as Ke}from"./ai-provider-step-Cc-0z4sv.js";import{P as Qe}from"./party-popper-DDctXdYD.js";import{b as ee,k as He}from"./section-chips-C68mRSIN.js";import{X as We}from"./x-D235ZOFZ.js";import{M as Ye}from"./mouse-pointer-click-BCV1_GTS.js";import{S as fe}from"./sparkles-B4yqwNG6.js";import{S as ye}from"./shield-check-BQHCFnRX.js";import{L as Je,K as Xe,e as Ze}from"./toaster-BDyw2x6L.js";import"./utils-hQAQiId-.js";import"./triangle-alert-CaKCF_Nq.js";import"./trademark-screen-DYufZ-CB.js";import"./waypoints-C6gFN1cM.js";import"./dialog-B9xd4dRw.js";import"./privacy-I8Fotoxq.js";import"./chevron-right-qcpptIv2.js";import"./chevron-down-C8mjF8sg.js";import"./image-off-CpRV4JaY.js";import"./trial-copy-BQN_0jwW.js";import"./unicorniq-logo-B9mOeuD0.js";import"./key-setup-wizard-CXUfihLw.js";import"./key-validation-Co8m_zCc.js";function be(s){return s.trim().replace(/^\[?\s*step\s+/i,"").replace(/\s*\]?$/,"").replace(/^["']|["']$/g,"").trim()}function ue(s){const n=be(s.step);return s.confirmed?!s.current||s.current.step!==n?{kind:"reject",code:"nothing_pending"}:{kind:"apply",pending:s.current}:s.proposal?{kind:"stage",pending:{step:n,...s.proposal}}:{kind:"reject",code:"nothing_pending"}}const et=d.lazy(()=>Ce(()=>import("./aurora-voice-S2ydCitH.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])).then(s=>({default:s.AuroraVoice})));function X({children:s}){return e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto","data-testid":"page-start-scroll",children:s})}function G(s,n){const i=s?.data;return typeof i?.error=="string"&&i.error||n}function tt(s){const n=s?.status;return typeof n=="number"?n:null}function st(s,n){return s.replace("{answer}",n)}function at(s,n,i,l){const r=n.trim().toLowerCase();switch(s.id){case"who":case"interests":case"pricing":return{kind:"screen",message:"This step was already answered during signup."};case"intro":return/\b(yes|yep|yeah|sure|ready|ok|okay|go|sounds good|let'?s)\b/.test(r)?{kind:"answer",body:{acknowledged:!0},summary:"ready to start setup"}:{kind:"unclear",message:'Say "ready" when theyâd like to move on.'};case"chiefOfStaff":return/\b(yes|yep|yeah|sure|ok|okay|got it|makes sense|sounds good|go|continue|next|ready)\b/.test(r)?{kind:"answer",body:{acknowledged:!0},summary:"chief-of-staff routing understood"}:{kind:"unclear",message:'Say "got it" to continue.'};case"card":return i.billing.cardCaptured?{kind:"answer",body:{method:"card_captured"},summary:"use the card already on file"}:i.billing.stripeConfigured?{kind:"screen",message:'The card is entered on the secure payment page â ask them to tap "Add card" on screen, then come back to this step.'}:{kind:"answer",body:{method:"billing_unconfigured"},summary:"continue without a card (billing is not configured in this environment)"};case"ai":return/\b(own|bring|byo|my key|have a key|api key)\b/.test(r)&&!/\bdon'?t\b/.test(r)?i.ai.byoConfigured?{kind:"answer",body:{mode:"byo"},summary:"use their own validated key"}:{kind:"screen",message:"Bringing their own key needs the on-screen key entry â ask them to add and validate the key on screen, then this
2step can be confirmed."}:/\b(handle|manage|you do it|take care|don'?t know|no idea|bill me|managed|you provide)\b/.test(r)||r==="no"?{kind:"answer",body:{mode:"managed"},summary:"have Vera handle the AI and bill for usage"}:{kind:"unclear",message:'Say "handle it for me" or "Iâll bring my own key".'};case"routing":return/\b(quality|best|strongest|smartest)\b/.test(r)?{kind:"answer",body:{policy:"quality"},summary:"quality first"}:/\b(cost|cheap|cheapest|save|frugal|low)\b/.test(r)?{kind:"answer",body:{policy:"cost"},summary:"cost first"}:/\b(balance|balanced|middle|both|mix)\b/.test(r)?{kind:"answer",body:{policy:"balanced"},summary:"balanced"}:{kind:"unclear",message:"Say quality, cost, or balanced."};case"providers":{if(/^(no|none|nope|nothing|no exclusions?|skip|all good|no thanks?)\b/.test(r))return{kind:"answer",body:{excludedProviders:[],excludedTags:[],acknowledgedConsequences:!1,embeddingCarveOut:null},summary:"no exclusions"};if(!l)return{kind:"unclear",message:"One moment â the provider list is still loading. Ask again."};const o=l.view.providers.filter(u=>r.includes(u.displayName.toLowerCase())||r.includes(u.slug.toLowerCase())).map(u=>u.slug),a=l.view.jurisdictionTags.filter(u=>r.includes(u.label.toLowerCase())||r.includes(u.key.toLowerCase())).map(u=>u.key);if(o.length===0&&a.length===0)return{kind:"unclear",message:'Name the provider or jurisdiction to exclude (or say "none"). For anything more detailed, the on-screen list shows every option.'};const v=[...l.view.providers.filter(u=>o.includes(u.slug)).map(u=>u.displayName),...l.view.jurisdictionTags.filter(u=>a.includes(u.key)).map(u=>u.label)];return{kind:"answer",body:{excludedProviders:o,excludedTags:a,acknowledgedConsequences:!0,embeddingCarveOut:null},summary:`exclude ${v.join(", ")}`}}case"connectors":return/\b(skip|later|not now|no)\b/.test(r)?{kind:"answer",body:{action:"skipped"},summary:"skip connectors for now"}:/\b(yes|sure|open|connect|show|visit|let'?s)\b/.test(r)?{kind:"answer",body:{action:"visited"},summary:"open the connector list"}
2:{kind:"unclear",message:'Say "open the list" or "skip for now".'};case"branding":return/\b(skip|later|not now|no)\b/.test(r)?{kind:"answer",body:{action:"skipped"},summary:"skip branding for now"}:/\b(yes|sure|open|visit|show|let'?s|customize|brand)\b/.test(r)?{kind:"answer",body:{action:"visited"},summary:"open the branding page"}:{kind:"unclear",message:'Say "open branding" or "skip for now".'};case"finish":return/\b(yes|ready|go|done|finish|start|let'?s)\b/.test(r)?{kind:"answer",body:{done:!0},summary:"finish setup and start chatting"}:{kind:"unclear",message:'Say "yes" when theyâre ready to finish.'};default:return{kind:"unclear",message:`Unknown step "${s.id}".`}}}function T({step:s,children:n}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold",children:s.title}),e.jsx("p",{className:"mt-0.5",children:s.question}),s.help&&e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.help})]}),n]})}function rt({view:s,step:n,busy:i,submit:l}){const r=Ee(),{toast:o}=xe(),{billing:a}=s;return e.jsxs(T,{step:n,children:[e.jsxs("div",{className:"rounded-xl border border-border p-4 space-y-1.5",children:[e.jsx("p",{className:"text-sm","data-testid":"text-card-seat-line",children:s.pricing.seatLine}),e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-card-tokens-line",children:s.pricing.tokensLine}),s.pricing.packLine&&e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-card-pack-line",children:s.pricing.packLine}),e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-card-starter-pack",children:s.pricing.starterPackLine}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.pricing.storageLine})]}),e.jsxs("p",{className:"text-sm flex items-start gap-2","data-testid":"text-card-payment-security",children:[e.jsx(ye,{className:"w-4 h-4 mt-0.5 shrink-0 text-primary"}),e.jsxs("span",{children:[s.pricing.paymentSecurityLine," ",e.jsxs("a",{href:s.pricing.paymentSecurityUrl,target:"_blank",rel:"noreferrer",className:"underline underline-offset-4 hover:text-foreground text-muted-foreground","data-testid":"link-payment-security",children:["How Stripe protects card data",e.jsx(te,{className:"w-3 h-3 ml-1 inline-block align-[-1px]"})]})]})]}),a.stripeConfigured?a.cardCaptured?e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs(K,{variant:"secondary",className:"w-fit","data-testid":"badge-card-on-file",children:[e.jsx(ge,{className:"w-3.5 h-3.5 mr-1.5"}),"Card on file",a.cardLast4?` â¢â¢â¢â¢ ${a.cardLast4}`:""]}),e.jsxs(g,{onClick:()=>l({method:"card_captured"}),disabled:i,"data-testid":"button-card-continue",children:[i&&e.jsx(N,{className:"w-4 h-4 mr-2 animate-spin"}),"Continue ",e.jsx(se,{className:"w-4 h-4 ml-1.5"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs(g,{onClick:async()=>{try{const v=await r.mutateAsync({data:{context:"onboarding"}});window.location.href=v.url}catch(v){o({title:"Card setup",description:G(v,"Couldnât open the secure card page."),variant:"destructive"})}},disabled:r.isPending,"data-testid":"button-card-add",children:[r.isPending?e.jsx(N,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Je,{className:"w-4 h-4 mr-2"}),"Add card on Stripe's secure page"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You'll come right back here. Abandoning the card page charges nothing and saves nothing."})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-card-unconfigured",children:"Billing isn't configured in this environment, so there's no card to add â you can continue without one."}),e.jsxs(g,{variant:"outline",onClick:()=>l({method:"billing_unconfigured"}),disabled:i,"data-testid":"button-card-skip",children:[i&&e.jsx(N,{className:"w-4 h-4 mr-2 animate-spin"}),"Continue without a card"]})]})]})}function nt({view:s,step:n,busy:i,submit:l,errText:r}){const[o,a]=d.useState(()=>s.ai.byoConfigured?"byo":s.ai.managedAvailable?"managed":null),[v,u]=d.useState([]),_=n.options?.find(C=>C.value==="managed"),b=n.options?.find(C=>C.value==="byo");return e.jsxs(T,{step:n,children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[_&&e.jsxs("button",{type:"button",disabled:!s.ai.managedAvailable,onClick:()=>a("managed"),className:`rounded-xl border p-4 text-left transition-colors disabled:opacity-50 ${o==="managed"?"border-primary bg-primary/5 ring-1 ring-primary":"border-border hover:border-primary/50"}`,"data-testid":"option-ai-managed",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(Ue,{className:"w-4 h-4 text-primary"})," ",_.label,o==="managed"&&e.jsx(ee,{className:"w-4 h-4 ml-auto text-primary"})]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:_.description}),s.ai.managedAvailable?e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Usage is billed to your card with a $",s.ai.managedCapUsd,"/month cap you can change later."]}):e.jsx("p",{className:"mt-2 text-xs text-destructive",children:"Not available right now â the platform holds no managed key. Bring your own key instead."})]}),b&&e.jsxs("button",{type:"button",onClick:()=>a("byo"),className:`rounded-xl border p-4 text-left transition-colors ${o==="byo"?"border-primary bg-primary/5 ring-1 ring-primary":"border-border hover:border-primary/50"}`,"data-testid":"option-ai-byo",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(Xe,{className:"w-4 h-4 text-primary"})," ",b.label,o==="byo"&&e.jsx(ee,{className:"w-4 h-4 ml-auto text-primary"})]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:b.description}),s.ai.byoConfigured&&e.jsxs("p",{className:"mt-2 text-xs text-emerald-600 dark:text-emerald-400 flex items-center gap-1",children:[e.jsx(pe,{className:"w-3.5 h-3.5"})," A validated key is already in place."]})]})]}),o==="byo"&&!s.ai.byoConfigured&&e.jsx("div",{className:"rounded-xl border border-border p-4",children:e.jsx(Ke,{selected:v,onToggleProvider:(C,O)=>u(S=>
2O?[...S,C]:S.filter(f=>f!==C)),togglePending:!1})}),r&&e.jsx("p",{className:"text-sm text-destructive","data-testid":"text-ai-error",children:r}),e.jsxs(g,{disabled:!o||i||o==="managed"&&!s.ai.managedAvailable,onClick:()=>o&&l({mode:o}),"data-testid":"button-ai-continue",children:[i&&e.jsx(N,{className:"w-4 h-4 mr-2 animate-spin"}),o==="managed"?"Confirm managed AI":o==="byo"?"Confirm my own key":"Continue"," ",e.jsx(se,{className:"w-4 h-4 ml-1.5"})]})]})}function me({step:s,busy:n,submit:i,continueLabel:l}){return e.jsxs(T,{step:s,children:[(s.options??[]).length>0&&e.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:(s.options??[]).map(r=>e.jsxs("div",{className:"rounded-xl border border-border p-4","data-testid":`highlight-${s.id}-${r.value}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(fe,{className:"w-4 h-4 text-primary"})," ",r.label]}),r.description&&e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r.description})]},r.value))}),e.jsxs(g,{disabled:n,onClick:()=>i({acknowledged:!0}),"data-testid":`button-${s.id}-continue`,children:[n&&e.jsx(N,{className:"w-4 h-4 mr-2 animate-spin"}),l," ",e.jsx(se,{className:"w-4 h-4 ml-1.5"})]})]})}function it({step:s,busy:n,submit:i}){const[,l]=Q();return e.jsxs(T,{step:s,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(g,{disabled:n,onClick:()=>i({action:"visited"},()=>l("/branding")),"data-testid":"button-branding-open",children:[e.jsx(De,{className:"w-4 h-4 mr-2"})," Open the branding page",e.jsx(te,{className:"w-3.5 h-3.5 ml-1.5"})]}),e.jsx(g,{variant:"outline",disabled:n,onClick:()=>i({action:"skipped"}),"data-testid":"button-branding-skip",children:"Skip for now"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You can restyle the workspace any time â Setup keeps your place."})]})}function dt({step:s,busy:n,submit:i,showAdvancedDoor:l}){const[,r]=Q(),o=a=>a;return e.jsxs(T,{step:s,children:[e.jsx("div",{className:"grid sm:grid-cols-3 gap-3",children:(s.options??[]).map(a=>e.jsxs("button",{type:"button",disabled:n,onClick:()=>i({policy:o(a.value)}),className:"rounded-xl border border-border p-4 text-left transition-colors hover:border-primary/60 hover:bg-primary/5 disabled:opacity-60","data-testid":`option-routing-${a.value}`,children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(Ze,{className:"w-4 h-4 text-primary"})," ",a.label]}),a.description&&e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a.description})]},a.value))}),l&&e.jsx("button",{type:"button",className:"text-xs text-muted-foreground underline underline-offset-4 hover:text-foreground",onClick:()=>r("/model-routing"),"data-testid":"link-routing-advanced",children:"Advanced routing controls"})]})}function ot({step:s,busy:n,submit:i,errText:l}){const[r,o]=d.useState(!1),[a,v]=d.useState([]),[u,_]=d.useState([]),[b,C]=d.useState(null),[O,S]=d.useState(!1),[f,V]=d.useState(null),[E,j]=d.useState(!1);d.useEffect(()=>{if(!r)return;let c=!1;j(!0);const k=window.setTimeout(async()=>{try{const A=await Z({excludedProviders:a,excludedTags:u,carveOutProvider:b});c||V(A)}catch{c||V(null)}finally{c||j(!1)}},300);return()=>{c=!0,window.clearTimeout(k)}},[r,a,u,b]);const L=a.length>0||u.length>0,q=f?.carveOutRequired===!0,R=!L||O&&f!=null&&(!q||b!=null);return e.jsx(T,{step:s,children:r?e.jsxs("div",{className:"space-y-4",children:[f==null&&E&&e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(N,{className:"w-4 h-4 animate-spin mr-2"})," Loading providersâ¦"]}),f&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Providers"}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-1.5",children:f.view.providers.map(c=>{const k=a.includes(c.slug);return e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer rounded-md border border-border px-3 py-2",children:[e.jsx(le,{checked:k,onCheckedChange:A=>v($=>A===!0?[...$,c.slug]:$.filter(M=>M!==c.slug)),"data-testid":`checkbox-exclude-${c.slug}`}),e.jsx("span",{children:c.displayName}),c.deniedBy&&e.jsx(K,{variant:"secondary",className:"ml-auto text-[10px]",children:"excluded"})]},c.slug)})})]}),f.view.jurisdictionTags.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Jurisdictions"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.view.jurisdictionTags.map(c=>{const k=u.includes(c.key);return e.jsx("button",{type:"button",onClick:()=>_(A=>k?A.filter($=>$!==c.key):[...A,c.key]),className:`rounded-full border px-3 py-1 text-xs transition-colors ${k?"border-destructive bg-destructive/10 text-destructive":"border-border hover:border-foreground
2/40"}`,"data-testid":`toggle-jurisdiction-${c.key}`,children:c.label},c.key)})})]}),L&&e.jsxs("div",{className:"rounded-xl border border-amber-500/40 bg-amber-500/5 p-4 space-y-2","data-testid":"panel-providers-consequences",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ye,{className:"w-4 h-4"})," What this costs you â computed live",E&&e.jsx(N,{className:"w-3.5 h-3.5 animate-spin ml-1"})]}),f.lostCapabilities.length>0?e.jsx("ul",{className:"text-sm text-muted-foreground list-disc pl-5 space-y-0.5",children:f.lostCapabilities.map((c,k)=>e.jsx("li",{"data-testid":`text-lost-capability-${k}`,children:c},k))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing is lost â every capability is still served by the remaining providers."}),q&&e.jsxs("div",{className:"space-y-2 pt-1","data-testid":"panel-carve-out",children:[e.jsx("p",{className:"text-sm",children:f.carveOutText??"These exclusions leave no provider for filing your knowledge â pick one narrow exception used only for that."}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.carveOutCandidates.map(c=>e.jsx("button",{type:"button",onClick:()=>C(c.slug),className:`rounded-full border px-3 py-1 text-xs ${b===c.slug?"border-primary bg-primary/10":"border-border"}`,"data-testid":`option-carve-out-${c.slug}`,children:c.displayName},c.slug))})]}),e.jsxs("label",{className:"flex items-start gap-2.5 text-sm cursor-pointer pt-1",children:[e.jsx(le,{checked:O,onCheckedChange:c=>S(c===!0),className:"mt-0.5","data-testid":"checkbox-providers-ack"}),e.jsxs("span",{children:["I understand what these exclusions cost",q?" and agree to the knowledge-filing exception above":"","."]})]})]})]}),l&&e.jsx("p",{className:"text-sm text-destructive","data-testid":"text-providers-error",children:l}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(g,{disabled:n||!R,onClick:()=>i({excludedProviders:a,excludedTags:u,acknowledgedConsequences:L?O:!1,embeddingCarveOut:q&&b?{providerSlug:b}:null}),"data-testid":"button-providers-apply",children:[n&&e.jsx(N,{className:"w-4 h-4 mr-2 animate-spin"}),L?"Apply these rules":"No exclusions â continue"]}),e.jsx(g,{variant:"ghost",onClick:()=>o(!1),children:"Back"})]})]}):e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(g,{disabled:n,onClick:()=>i({excludedProviders:[],excludedTags:[],acknowledgedConsequences:!1,embeddingCarveOut:null}),"data-testid":"button-providers-none",children:[n&&e.jsx(N,{className:"w-4 h-4 mr-2 animate-spin"}),"Nothing off-limits â continue"]}),e.jsx(g,{variant:"outline",onClick:()=>o(!0),"data-testid":"button-providers-exclude",children:"I want to exclude something"})]})})}function ct({step:s,busy:n,submit:i}){const[,l]=Q();return e.jsxs(T,{step:s,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(g,{disabled:n,onClick:()=>i({action:"visited"},()=>l("/connectors")),"data-testid":"button-connectors-open",children:[e.jsx(ze,{className:"w-4 h-4 mr-2"})," Open the connector list",e.jsx(te,{className:"w-3.5 h-3.5 ml-1.5"})]}),e.jsx(g,{variant:"outline",disabled:n,onClick:()=>i({action:"skipped"}),"data-testid":"button-connectors-skip",children:"Skip for now"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"If you open the list, come back to Setup any time â your progress is saved."})]})}function lt({view:s,step:n,busy:i,submit:l,errText:r}){const o=s.ai.byoConfigured||s.ai.managedActive;return e.jsxs(T,{step:n,children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{variant:s.billing.cardCaptured||!s.billing.stripeConfigured?"secondary":"outline",children:[e.jsx(ge,{className:"w-3.5 h-3.5 mr-1"}),s.billing.cardCaptured?"Card on file":s.billing.stripeConfigured?"No card yet":"Billing not configured"]}),e.jsxs(K,{variant:o?"secondary":"outline","data-testid":"badge-finish-ai",children:[e.jsx(fe,{className:"w-3.5 h-3.5 mr-1"}),s.ai.byoConfigured?"AI ready (your key)":s.ai.managedActive?"AI ready (managed)":"AI not ready"]})]}),r&&e.jsx("p",{className:"text-sm text-destructive","data-testid":"text-finish-error",children:r}),e.jsxs(g,{size:"lg",disabled:i,onClick:()=>l({done:!0}),"data-testid":"button-finish",children:[i?e.jsx(N,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(he,{className:"w-4 h-4 mr-2"}
2),"Finish & start chatting"]})]})}function Vt(){const{data:s}=Pe({query:{queryKey:qe()}}),n=Te(),{toast:i}=xe(),[,l]=Q(),r=Re(s),o=Oe({query:{queryKey:J(),retry:!1,enabled:!!s?.tenantId}}),a=o.data??null,v=d.useRef(a);v.current=a;const u=_e(),[_,b]=d.useState({}),[C,O]=d.useState(!1),S=a&&a.status!=="completed"?a.currentStep:null,f=d.useRef(null);d.useEffect(()=>{const t=f.current;if(f.current=S,!S||t===null||t===S)return;const p=document.querySelector(`[data-testid="step-${S}"]`);!p||p.offsetParent===null||p.scrollIntoView({behavior:Be()?"auto":"smooth",block:"start"})},[S]);const[V,E]=d.useState(!1);d.useEffect(()=>{const t=new URLSearchParams(globalThis.location.search);if(t.get("card")==="1"&&E(!0),t.get("card_cancelled")==="1"&&i({title:"Card setup cancelled",description:"Nothing was charged and nothing was saved. Add a card whenever youâre ready."}),t.has("card")||t.has("card_cancelled")){t.delete("card"),t.delete("card_cancelled");const p=t.toString();window.history.replaceState(null,"",globalThis.location.pathname+(p?`?${p}`:""))}},[]),d.useEffect(()=>{if(!V)return;if(a?.billing.cardCaptured){E(!1);return}let t=0;const p=window.setInterval(()=>{if(t+=1,t>15){window.clearInterval(p),E(!1);return}o.refetch()},2e3);return()=>window.clearInterval(p)},[V,a?.billing.cardCaptured]);const j=d.useCallback((t,p,y)=>{b(x=>({...x,[t]:""})),u.mutate({data:{stepId:t,lane:"visual",answer:p}},{onSuccess:x=>
2{if(n.setQueryData(J(),x.flow),t==="finish"){l(r);return}y?.()},onError:x=>{b(m=>({...m,[t]:G(x,"That didnât save â try again.")}))}})},[u,n,l,r]),L=Le(),[q,R]=d.useState(!1),[c,k]=d.useState(!1),[A,$]=d.useState(!1),[M,ve]=d.useState(()=>Ve()),je=t=>{const p={...M,voice:t};ve(p),Fe(p)},I=a?.voice.available===!0&&!A,ae=!A&&a?.voice.note||a?.fork.voiceUnavailableNote||"",ke=d.useCallback(async()=>{try{const t=await L.mutateAsync({data:{guidedOnboarding:!0}});return $(!1),{session:t,conversationId:null}}catch(t){return tt(t)===409&&$(!0),i({title:"Voice setup",description:G(t,"Couldnât start a live voice session."),variant:"destructive"}),null}},[L,i]);d.useEffect(()=>{a?.status==="completed"&&R(!1)},[a?.status]);const B=d.useRef(null),[re,H]=d.useState(null),W=d.useRef(null),Y=d.useCallback(async(t,p,y)=>{try{const x=await $e({stepId:t,lane:"voice",answer:p});if(n.setQueryData(J(),x.flow),B.current=null,H(null),t==="finish")return window.setTimeout(()=>l(r),600),{status:"applied",summary:x.summary,next:"Setup is complete â taking them to their first chat."};const m=x.flow.currentStep,h=m?x.flow.steps.find(w=>w.id===m):null;return{status:"applied",summary:x.summary,...h?{next_step:h.id,next_ask:h.voiceAsk}:{next:"Every step is answered â ask if theyâre ready to finish."}}}catch(x){return{error:"apply_failed",message:G(x,`The ${t} answer could not be applied.`)+` (${y})`}}},[n,l,r]),ne=d.useCallback(async(t,p,y)=>{const x=v.current;if(!x)return{error:"not_ready",message:"Setup is still loading."};const m=be(t),h=x.steps.find(P=>P.id===m);if(!h)return{error:"unknown_step",message:`No setup step called "${t}".`};if(h.answered&&h.id!=="finish")return{status:"already_answered",message:`The ${h.id} step is already done: ${h.summary??""}`};if(y){const P=ue({current:B.current,step:h.id,confirmed:!0});return P.kind!=="apply"?{error:"nothing_pending",message:"Propose the answer first (confirmed=false), read it back, and get their yes."}:Y(h.id,P.pending.payload,P.pending.summary)}if(h.id==="providers"&&!W.current)try{W.current=await Z({excludedProviders:[],excludedTags:[]})}catch{}const w=at(h,p,x,W.current);if(w.kind==="screen")return{status:"screen_required",message:w.message};if(w.kind==="unclear")return{status:"unclear",message:w.message};let F;if(h.id==="providers"){const P=w.body;if(P.excludedProviders.length>0||P.excludedTags.length>0)try{const ce=await Z({excludedProviders:P.excludedProviders,excludedTags:P.excludedTags});if(ce.carveOutRequired)return{status:"screen_required",message:"These exclusions leave no provider for filing their knowledge â that trade-off needs the on-screen step, where the exception is spelled out and agreed explicitly."};F=ce.lostCapabilities}catch{return{status:"unclear",message:"Couldnât compute what those exclusions would cost â try again."}}}const oe=ue({current:B.current,step:h.id,confirmed:!1,proposal:{payload:w.body,summary:w.summary}});return oe.kind!=="stage"?{error:"nothing_pending",message:"The answer could not be staged."}:(B.current=oe.pending,H({step:h.id,summary:w.summary}),{status:"needs_confirmation",confirm:st(h.voiceConfirm,w.summary),...F&&F.length>0?{consequences_to_read_first:F}:{}})},[Y]);if(d.useEffect(()=>{},[ne]),o.isError)return Ie(o.error)?e.jsx(Se,{to:"/"}):e.jsx(X,{children:e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-16 text-center space-y-3","data-testid":"card-start-unavailable",children:[e.jsx("p",{className:"text-destructive",children:G(o.error,"Couldnât load your setup.")}),e.jsx(g,{variant:"outline",onClick:()=>o.refetch(),"data-testid":"button-start-retry",children:"Try again"})]})});if(!a)return e.jsx(X,{children:e.jsxs("div",{className:"flex items-center justify-center py-24 text-muted-foreground","data-testid":"loading-start",children:[e.jsx(N,{className:"w-5 h-5 animate-spin mr-2"})," Loading your setupâ¦"]})});const ie=a.steps.filter(t=>t.answered).length,we=a.status==="completed"?null:a.currentStep,Ne=a.steps.some(t=>t.answered&&!["who","interests","pricing"].includes(t.id)),de=a.status!=="completed"&&!Ne&&!C;return e.jsx(X,{children:e.jsxs("div",{className:"max-w-2xl mx-auto px-4 sm:px-6 py-8 sm:py-12 space-y-6","data-testid":"page-start",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl sm:text-3xl font-bold",children:"Let's set up your workspace"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[ie," of ",a.steps.length," steps done â pick up any time, nothing is lost."]})]}),I&&e.jsxs(g,{variant:"outline",className:"shrink-0",onClick:()=>{k(!0),R(!0)},"data-testid":"button-start-voice","data-feature-anchor":"guided-onboarding-voice-toggle",children:[e.jsx(D,{className:"w-4 h-4 mr-2"})," Talk it through"]})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-border overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.round(ie/a.steps.length*100)}%`}})}),!I&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1.5","data-testid":"text-voice-unavailable-reason","data-reason":A?"runtime":a.voice.reason??"unknown",children:[e.jsx(D,{className:"w-3.5 h-3.5"}),ae]})]}),a.status==="completed"&&e.jsx(U,{"data-testid":"card-start-completed",children:e.jsxs(z,{className:"pt-6 text-center space-y-3",children:[e.jsx(Qe,{className:"w-8 h-8 mx-auto text-primary"}),e.jsx("p",{className:"font-medium",children:"Setup is complete â your workspace is ready."}),e.jsxs(g,{onClick:()=>l(r),"data-testid":"button-start-go-chat",children:[e.jsx(he,{className:"w-4 h-4 mr-2"})," ",Ge(s,"go")]})]})}),re&&e.jsx(U,{className:"border-primary/50","data-testid":"card-voice-pending",children:e.jsxs(z,{className:"pt-4 pb-4 flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsxs("p",{className:"font-medium flex items-center gap-1.5",children:[e.jsx(D,{className:"w-4 h-4 text-primary"})," Vera heard:"]}),e.jsx("p",{className:"text-muted-foreground mt-0.5","data-testid":"text-voice-pending-summary",children:re.summary})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(g,{size:"sm",onClick:()=>{const t=B.current;t&&Y(t.step,t.payload,t.summary)},"data-testid":"button-voice-pending-confirm",children:[e.jsx(ee,{className:"w-4 h-4 mr-1"})," Confirm"]}),e.jsx(g,{size:"sm",variant:"ghost",onClick:()=>{B.current=null,H(null)},"data-testid":"button-voice-pending-cancel",children:e.jsx(We,{className:"w-4 h-4"})})]})]})}),de&&e.jsx(U,{"data-testid":"card-start-fork",children:e.jsxs(z,{className:"pt-6 pb-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold",children:a.fork.title}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:a.fork.question})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>O(!0),className:"rounded-xl border border-border p-4 text-left transition-colors hover:border-primary/60 hover:bg-primary/5","data-testid":"button-fork-visual",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(Ye,{className:"w-4 h-4 text-primary"})," ",a.fork.visualLabel]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a.fork.visualDescription})]}),e.jsxs("button",{type:"button",disabled:!I,onClick:()=>{O(!0),k(!0),R(!0)},className:"rounded-xl border border-border p-4 text-left transition-colors hover:border-primary/60 hover:bg-primary/5 disabled:opacity-60 disabled:hover:border-border disabled:hover:bg-transparent","data-testid":"button-fork-voice",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(D,{className:"w-4 h-4 text-primary"})," ",a.fork.voiceLabel]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a.fork.voiceDescription}),!I&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground","data-testid":"text-fork-voice-unavailable",children:ae})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"text-fork-typing-note",children:a.fork.typingNote}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Prefer the checklist?"," ",e.jsx(Ae,{href:"/setup?classic=1",className:"underline underline-offset-2 hover:text-foreground","data-testid":"link-classic-setup",children:"Open classic setup"})," ","(the step-by-step admin checklist; you can come back here any time)."]})]})}),e.jsx("ol",{className:de?"hidden":"space-y-3","data-testid":"list-start-steps","data-feature-anchor":"guided-onboarding-step-card",children:a.steps.map(t=>{const p=t.id===we,y=u.isPending,x=_[t.id]||null;return e.jsx("li",{children:e.jsx(U,{className:p?"border-primary/60 shadow-sm":t.answered?"opacity-90":"opacity-60","data-testid":`step-${t.id}`,children:e.jsxs(z,{className:p?"pt-6 pb-6":"py-3.5",children:[!p&&e.jsxs("div",{className:"flex items-center gap-3",children:[t.answered?e.jsx(pe,{className:"w-5 h-5 text-primary shrink-0","data-testid":`icon-done-${t.id}`}
2):e.jsx(He,{className:"w-5 h-5 text-muted-foreground/50 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:t.title}),t.answered&&t.summary&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate","data-testid":`text-summary-${t.id}`,children:[t.summary,t.lane==="voice"&&" · answered by voice"]})]})]}),p&&e.jsxs(e.Fragment,{children:[t.id==="intro"&&e.jsx(me,{step:t,busy:y,submit:m=>j("intro",m),continueLabel:"Sounds good â let's set up"}),t.id==="chiefOfStaff"&&e.jsx(me,{step:t,busy:y,submit:m=>j("chiefOfStaff",m),continueLabel:"Got it â pick my policy"}),t.id==="card"&&e.jsx(rt,{view:a,step:t,busy:y,submit:m=>j("card",m)}),t.id==="ai"&&e.jsx(nt,{view:a,step:t,busy:y,submit:m=>j("ai",m),errText:x}),t.id==="routing"&&e.jsx(dt,{step:t,busy:y,submit:m=>j("routing",m),showAdvancedDoor:!Me(s,"/model-routing")}),t.id==="providers"&&e.jsx(ot,{step:t,busy:y,submit:m=>j("providers",m),errText:x}),t.id==="connectors"&&e.jsx(ct,{step:t,busy:y,submit:(m,h)=>j("connectors",m,h)}),t.id==="branding"&&e.jsx(it,{step:t,busy:y,submit:(m,h)=>j("branding",m,h)}),t.id==="finish"&&e.jsx(lt,{view:a,step:t,busy:y,submit:m=>j("finish",m),errText:x}),["who","interests","pricing"].includes(t.id)&&e.jsx(T,{step:t,children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This was answered during signup",t.summary?`: ${t.summary}`:"","."]})}),x&&!["ai","providers","finish"].includes(t.id)&&e.jsx("p",{className:"text-sm text-destructive mt-3","data-testid":`text-error-${t.id}`,children:x})]})]})})},t.id)})}),c&&e.jsx(d.Suspense,{fallback:null,children:e.jsx(et,{open:q,onClose:()=>R(!1),accent:"#7c3aed",voice:M.voice,onChangeVoice:je,conversationId:null,sendTurn:async()=>null,realtimeAvailable:I,mintSession:ke,defaultEngine:"live",onOnboardingAnswer:ne})})]})})}export{Vt 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.