PageSourceSearch

https://repsshield.com/assets/AgenticOnboarding-DtBgazvw.js

js repsshield.com collected 2026-09-24 14:18:29 UTC 29,392 bytes, 4 lines download raw bytes

1import{j as e,aI as S,f as R,cF as re,B as M,cG as se,H as ne,m as ae,U as oe,bv as ie,a3 as z,cH as le,ag as de,ah as ce,l as ue,n as me,cI as pe,aJ as xe,cJ as fe,cK as he}from"./index-Byg2HWAE.js";import{r as c}from"./vendor-Qgthw7N1.js";import{C as V}from"./calendar-days-CZv4Giu2.js";import{U as ye}from"./user-plus-DIMyHSLg.js";const ge=new Set(["showSelector","showNumberInput","connectCalendar","presentQuestionnaire","prepareTimeEntry","presentSelectForm"]);function be(t){for(const r of t)for(const a of r.parts)if(typeof a.type=="string"&&a.type==="tool-completeOnboarding"&&a.state==="output-available")return!0;return!1}const P=["Tax Profile","Add Property","Connect Calendar","Invite Team"];function ve(t){return t.invitationsSent>0||t.completedModules.includes("invite_team")?4:t.connectedProviders.length>0||t.completedModules.includes("connect_calendar")?3:t.propertiesAdded>0||t.completedModules.includes("add_property")?2:0}function je(){const t=c.useRef(!1),r=c.useRef(new Map),[a,s]=c.useState([]),n=c.useRef([]);n.current=a;const[m,x]=c.useState(!1),[o,l]=c.useState(!1),[p,y]=c.useState(),[i,f]=c.useState(null),[N,g]=c.useState(null),[b,L]=c.useState(0),[$,d]=c.useState(null);c.useEffect(()=>{const E=localStorage.getItem("accessToken"),I={};E&&(I.Authorization=`Bearer ${E}`),fetch("/api/onboarding/session",{credentials:"include",headers:I}).then(v=>v.ok?v.json():null).then(v=>{v&&L(ve(v))}).catch(()=>{})},[]);const h=c.useCallback(async E=>{var D;r.current.clear();const I={id:`user-${Date.now()}`,role:"user",parts:[{type:"text",text:E}]};s(C=>[...C,I]),x(!0),l(!0),y(void 0),f("streaming"),g("Thinking…");const v=`assistant-${Date.now()}`,Q={id:v,role:"assistant",parts:[],metadata:{status:"streaming"}};s(C=>[...C,Q]);try{const C=localStorage.getItem("accessToken"),U={"Content-Type":"application/json"};C&&(U.Authorization=`Bearer ${C}`);const W=new AbortController,Y=setTimeout(()=>W.abort(),9e4);let F;try{F=await fetch("/api/onboarding/chat",{method:"POST",credentials:"include",headers:U,signal:W.signal,body:JSON.stringify({messages:n.current.concat(I)})})}finally{clearTimeout(Y)}if(!F.ok)throw new Error(`HTTP error: ${F.status}`);const q=(D=F.body)==null?void 0:D.getReader();if(!q)throw new Error("No response body");const J=new TextDecoder;let B="",H="";for(;;){const{done:X,value:Z}=await q.read();if(X)break;B+=J.decode(Z,{stream:!0});const K=B.split(`
2
3`);B=K.pop()??"";for(const ee of K){const te=ee.split(`
4`);for(const G of te)if(G.startsWith("data: "))try{const u=JSON.parse(G.slice(6));if(u.type==="text")H+=u.content,f(null),g(null),s(A=>A.map(T=>{if(T.id!==v)return T;const j=T.parts.filter(O=>O.type!=="text");return{...T,parts:[...j,{type:"text",text:H}]}}));else if(u.type==="tool-call")if(f("tool-call"),g(u.toolName),u.actualToolName&&ge.has(u.actualToolName)){const A={type:`tool-${u.actualToolName}`,toolCallId:u.toolCallId,input:u.input,state:"output-available"};s(T=>T.map(j=>j.id===v?{...j,parts:[...j.parts,A]}:j))}else u.toolCallId&&r.current.set(u.toolCallId,u.input);else if(u.type==="tool-result"){const A=r.current.get(u.toolCallId);r.current.delete(u.toolCallId);const T={type:`tool-${u.toolName}`,toolCallId:u.toolCallId,input:A,output:u.output,state:"output-available"};s(j=>j.map(O=>O.id===v?{...O,parts:[...O.parts,T]}:O))}else if(u.type==="status")f(u.status),g(u.label);else if(u.type==="done"){f(null),g(null);const A=new Date().toISOString();s(T=>T.map(j=>j.id===v?{...j,metadata:{...j.metadata??{},provider:u.provider,model:u.model,status:"done",completedAt:A}}:j))}else u.type==="error"&&y(u.error)}catch(u){console.error("[Onboarding] Failed to parse SSE data:",u)}}}}catch(C){console.error("[Onboarding] Stream error:",C),y(C instanceof Error?C.message:"Stream failed")}finally{x(!1),l(!1),f(null),g(null)}},[]);c.useEffect(()=>{if(t.current)return;t.current=!0;const I=new URLSearchParams(window.location.search).get("calendar_connected");if(I){window.history.replaceState({},"",window.location.pathname),d(I);const v=I==="google"?"Google Calendar":"Outlook Calendar",Q={id:`ack-oauth-${Date.now()}`,role:"assistant",parts:[{type:"text",text:`${v}
4 is now connected — REPSShield will start pulling in your property hours automatically.`}]};s([Q]),h("")}else h("")},[]);function k(){s([]),y(void 0),t.current=!1}const w=be(a);return{messages:a,send:h,clearMessages:k,setMessages:s,isLoading:m,isStreaming:o,error:p,isComplete:w,pipelineStatus:i,pipelineStatusLabel:N,totalSteps:P.length,modules:P,isFallbackRequired:!!p,sessionStepFloor:b,calendarConnectedViaOAuth:$}}function Ne({currentStep:t}){const r=P.length;return e.jsx("div",{className:"flex items-start gap-0",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":r,"aria-label":`Onboarding step ${t+1} of ${r}: ${P[t]??"Complete"}`,children:P.map((a,s)=>{const n=s<t,m=s===t,x=s===P.length-1;return e.jsxs("div",{className:"flex-1 flex flex-col items-center",children:[e.jsxs("div",{className:"flex items-center w-full",children:[e.jsx("div",{className:S("flex-1 h-px transition-colors duration-300",s===0?"invisible":n||m?"bg-primary/50":"bg-border/60"),"aria-hidden":!0}),e.jsx("div",{className:S("relative shrink-0 flex items-center justify-center rounded-full transition-all duration-300",n?"h-6 w-6 bg-primary text-primary-foreground":m?"h-6 w-6 bg-primary text-primary-foreground shadow-[0_0_0_3px_hsl(var(--primary)/0.18)]":"h-5 w-5 bg-muted border border-border/60 text-muted-foreground/50"),children:n?e.jsx(R,{className:"h-3 w-3",strokeWidth:2.5,"aria-hidden":!0}):m?e.jsx("span",{className:"text-[10px] font-bold",children:s+1}):e.jsx("span",{className:"text-[9px] font-medium",children:s+1})}),e.jsx("div",{className:S("flex-1 h-px transition-colors duration-300",x?"invisible":n?"bg-primary/50":"bg-border/60"),"aria-hidden":!0})]}),e.jsx("span",{className:S("mt-1.5 text-center leading-tight px-0.5 transition-colors duration-300",n||m?"text-[11px] font-medium":"text-[10px] font-normal",n?"text-primary":m?"text-foreground":"text-muted-foreground/40"),children:a})]},a)})})}function we({toolName:t,args:r,onSubmit:a,disabled:s=!1}){if(t==="showSelector")return e.jsx(Se,{args:r,onSubmit:a,disabled:s});if(t==="showNumberInput")return e.jsx(ke,{args:r,onSubmit:a,disabled:s});if(t==="presentQuestionnaire"){const n=r;return!(n!=null&&n.steps)||!Array.isArray(n.steps)||n.steps.length===0?null:e.jsx("div",{className:"mt-2 max-w-[90%] overflow-hidden",children:e.jsx(re,{toolCallId:`onboarding-${n.questionnaireId}`,schema:n,onSubmit:a})})}return t==="showSummary"?e.jsx(Ae,{args:r,onSubmit:a,disabled:s}):t==="connectCalendar"?e.jsx(Te,{args:r,disabled:s}):t==="addProperty"?e.jsx(Ce,{args:r}):t==="inviteTeamMember"?e.jsx(Ee,{args:r}):null}function Se({args:t,onSubmit:r,disabled:a}){const[s,n]=c.useState(null),m=t.options??[];function x(o){a||s!==null||(n(o.id),r(o.label))}return e.jsxs("div",{className:"mt-3 space-y-2.5",children:[t.title&&e.jsx("p",{className:"text-sm font-medium text-foreground",children:t.title}),t.instruction&&e.jsx("p",{className:"text-xs text-muted-foreground/70",children:t.instruction}),e.jsx("div",{className:"flex flex-col gap-2",children:m.map(o=>{const l=s===o.id,p=a||s!==null&&!l;return e.jsxs("button",{type:"button",disabled:p,onClick:()=>x(o),className:S("flex items-start gap-2.5 rounded-xl px-4 py-3 text-sm font-medium w-full text-left","border transition-all duration-150 select-none","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",l?"bg-primary text-primary-foreground border-primary shadow-sm":p?"border-border/40 bg-muted/20 text-muted-foreground/40 cursor-not-allowed":"border-border/60 bg-background text-foreground hover:border-primary/40 hover:bg-primary/5 curs
4or-pointer shadow-sm"),"aria-pressed":l,children:[e.jsx("span",{className:S("mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",l?"border-primary-foreground/60 bg-primary-foreground/20":"border-border/50"),children:l&&e.jsx(R,{className:"h-2.5 w-2.5 text-primary-foreground",strokeWidth:3,"aria-hidden":!0})}),e.jsxs("span",{className:"flex flex-col gap-0.5 min-w-0",children:[e.jsx("span",{className:"leading-snug",children:o.label}),o.description&&e.jsx("span",{className:S("text-xs font-normal leading-snug",l?"text-primary-foreground/70":"text-muted-foreground/60"),children:o.description})]})]},o.id)})})]})}function ke({args:t,onSubmit:r,disabled:a}){const[s,n]=c.useState(""),[m,x]=c.useState(!1);function o(){const p=s.trim();!p||m||(x(!0),r(p))}function l(p){p.key==="Enter"&&o()}return m?e.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-xl border border-primary/40 bg-primary/5 px-4 py-3 text-sm text-foreground shadow-sm",children:[e.jsx(R,{className:"h-4 w-4 text-primary shrink-0","aria-hidden":!0}),e.jsx("span",{className:"font-medium",children:s})]}):e.jsxs("div",{className:"mt-3 space-y-2.5",children:[t.question&&e.jsx("p",{className:"text-sm font-medium text-foreground",children:t.question}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:s,onChange:p=>n(p.target.value),onKeyDown:l,placeholder:t.placeholder??"",min:t.min,max:t.max,disabled:a||m,className:S("h-9 w-32 rounded-xl border border-border/60 bg-background px-3 text-sm text-foreground shadow-sm","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","disabled:cursor-not-allowed disabled:opacity-50","[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none")}),e.jsx(M,{type:"button",size:"sm",disabled:a||m||s.trim()==="",onClick:o,className:"rounded-xl text-xs h-9 px-4 bg-primary hover:bg-primary/90 text-primary-foreground",children:"Save"})]})]})}function Ce({args:t}){const r=(t==null?void 0:t.nickname)??(t==null?void 0:t.address)??(t==null?void 0:t.propertyName)??"Property";return(t==null?void 0:t.error)!=null?e.jsx("div",{className:"mt-2 flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/5 px-3 py-2.5 text-sm text-destructive",children:e.jsxs("span",{children:["Could not add ",r,". Please try again."]})}):e.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2.5 text-sm text-foreground",children:[e.jsx(R,{className:"h-4 w-4 text-primary shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:r})," added successfully."]})]})}function Te({args:t,disabled:r}){const{openCalendarAuth:a}=ie(),s=(t==null?void 0:t.provider)??"both",n=s==="google"||s==="both",m=s==="microsoft"||s==="both";function x(){a("/onboarding?calendar_connected=google")}function o(){fetch("/api/auth/microsoft/calendar/auth",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({returnUrl:"/onboarding?calendar_connected=microsoft"})}).then(l=>l.json()).then(l=>{l.authUrl&&(window.location.href=l.authUrl)}).catch(console.error)}return e.jsxs("div",{className:"mt-3 space-y-3",children:[(t==null?void 0:t.message)&&e.jsx("p",{className:"text-sm text-muted-foreground/80",children:t.message}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[n&&e.jsxs(M,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:x,className:"flex items-center gap-2 text-sm w-full sm:w-auto rounded-xl border-border/60 hover:border-primary/40 hover:bg-primary/5 shadow-sm",children:[e.jsx(V,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"Connect Google Calendar",e.jsx(z,{className:"h-3.5 w-3.5 shrink-0 opacity-40 ml-auto sm:ml-0","aria-hidden":!0})]}),m&&e.jsxs(M,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:o,className:"flex items-center gap-2 text-sm w-full sm:w-auto rounded-xl border-border/60 hover:border-primary/40 hover:bg-primary/5 shadow-sm",children:[e.jsx(V,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"Connect Outlook Calendar",e.jsx(z,{className:"h-3.5 w-3.5 shrink-0 opacity-40 ml-auto sm:ml-0","aria-hidden":!0})]})]})]})}function Ee({args:t}){const r=(t==null?void 0:t.email)??(t==null?void 0:t.inviteeEmail)??"team member";return(t==null?void 0:t.error)!=null||(t==null?void 0:t.success)===!1?e.jsx("div",{className:"mt-2 flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/5 px-3 py-2.5 text-sm text-destructive",children:e.jsxs("span",{children:["Could not send invitation to ",r,". Please try again."]})}):e.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2.5 text-sm text-foreground",children:[e.jsx(ye,{className:"h-4 w-4 text-primary shrink-0","aria-hidden":!0}),e.jsxs("span",{children:["Invitation sent to ",e.jsx("span",{className:"font-medium",children:r}),"."]})]})}const Ie={filingStatus:"Filing Status",repType:"REP Type",primaryQualifier:"Primary Qualifier",taxYearGoal:"Tax Year Goal",employmentType:"Employment Type",agiRange:"AGI Range",involvementStyle:"Involvement Style",netRentalIncomeLoss:"Net Rental Income/Loss",primaryGoal:"Primary Goal",priorityFocus:"Priority Focus",trackingHabit:"Tracking Habit",priorYearRepsQualified:"Prior Year REPS",hasActiveCpa:"Active CPA",allowPushback:"AI Coaching",w2HoursPerWeek:"W-2 Hours/Week",otherWorkHoursPerWeek:"Other Work Hours/Week",spouseEmploymentStatus:"Spouse Employment",spouseHoursPerWeek:"Spouse Hours/Week",pmHoursEstimate:"PM Hours Estimate"};function Pe(t){return t==null?"—":typeof t=="boolean"?t?"Yes":"No":String(t).replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function Ae({args:t,onSubmit:r,disabled:a}){const[s,n]=c.useState(!1),m=t.taxProfile??{},x=Object.entries(m).filter(([,f])=>f!=null&&f!==""),o=t.propertiesAdded??0,l=t.calendarConnected??!1,p=t.teamMembersInvited??0;function y(){n(!0),r("Looks good — everything is correct.")}function i(){r("Actually, I'd like to make some changes.")}return s?e.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-xl border border-primary/40 bg-primary/5 px-4 py-3 text-sm text-foreground",children:[e.jsx(R,{className:"h-4 w-4 text-primary shrink-0","aria-hidden":!0}),e.jsx("span",{className:"font-medium",children:"All set! Taking you to your dashboard."})]}):e.jsxs("div",{className:"mt-3 space-y-3 max-w-[92%]",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Here's a summary of your setup — does everything look right?"}),e.jsxs("div",{className:"rounded-xl border border-border/50 bg-muted/30 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border/40 bg-muted/40",children:[e.jsx(se,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Tax Profile"}),x.length>0&&e.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[x.length," fields"]})]}),x.length===0?e.jsx("p",{className:"px-4 py-2.5 text-xs text-muted-foreground",children:"Skipped"}):e.jsx("div",{className:"px-4 py-2 grid grid-cols-2 gap-x-4 gap-y-1",children:x.map(([f,N])=>e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Ie[f]??f}),e.jsx("span",{className:"text-xs font-medium text-foreground leading-tight",children:Pe(N)})]},f))})]}),e.jsx("div",{className:"rounded-xl border border-border/50 bg-muted/30 overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5",children:[e.jsx(ne,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Properties"}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:o===0?"None added":`${o} added`})]})}),e.jsx("div",{className:"rounded-xl border border-border/50 bg-muted/30 overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5",children:[e.jsx(ae,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Calendar & Email"}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:l?"Connected":"Not connected"})]})}),e.jsx("div",{className:"rounded-xl border border-border/50 bg-muted/30 overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5",children:[e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Team"}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:p===0?"No invites sent":`${p} invited`})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(M,{size:"sm",disabled:a,onClick:y,className:"bg-primary hover:bg-primary/90 text-primary-foreground rounded-xl text-xs h-8 px-4",children:[e.jsx(R,{className:"h-3.5 w-3.5 mr-1.5","aria-hidden":!0}),"Looks good!"]}),e.jsx(M,{size:"sm",variant:"outline",disabled:a,onClick:i,className:"rounded-xl text-xs h-8 px-4 border-border/60",children:"Make changes"})]})]})}const Oe=new Set(["tool-showSelector","tool-showNumberInput","tool-presentQuestionnaire","tool-addProperty","tool-connectCalendar","tool-inviteTeamMember","tool-showSummary"]),Re={h1:({children:t})=>e.jsx("p",{className:"font-bold text-sm mt-3 mb-1",children:t}),h2:({children:t})=>e.jsx("p",{className:"font-bold text-sm mt-3 mb-1",children:t}),h3:({children:t})=>e.jsx("p",{className:"font-semibold text-sm mt-2 mb-1",children:t}),h4:({children:t})=>e.jsx("p",{className:"font-semibold text-sm mt-2 mb-0.5",children:t}),ul:({children:t})=>e.jsx("ul",{className:"list-disc pl-4 my-1.5 space-y-0.5",children:t}),ol:({children:t})=>e.jsx("ol",{className:"list-decimal pl-4 my-1.5 space-y-0.5",children:t}),li:({children:t})=>e.jsx("li",{className:"text-sm",children:t}),p:({children:t})=>e.jsx("p",{className:"my-1",children:t}),strong:({children:t})=>e.jsx("strong",{className:"font-semibold",children:t}),a:({href:t,children:r})=>e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline underline-offset-2",children:r}),code:({children:t})=>e.jsx("code",{className:"bg-background rounded px-1 py-0.5 text-xs",children:t})};function Me(){return e.jsx("span",{className:"inline-flex items-center gap-0.5 h-4","aria-label":"Loading",children:[0,1,2].map(t=>e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current opacity-60",style:{animation:`pulse 1.2s ease-in-out ${t*.2}s infinite`}},t))})}function _e({message:t,isLatest:r,onToolSubmit:a}){const s=t.role==="user",n=t.parts.filter(i=>i.type==="text").map(i=>i.text).join("").trim(),m=t.parts.filter(i=>!(typeof i.type!="string"||!Oe.has(i.type)||i.input==null&&i.args==null)),x=n.length>0||m.length>0,o=r&&!s,l=o&&!x,p=le(n,o),y=o||p.length<n.length;return s&&!n||s&&(n.startsWith("[QUESTIONNAIRE_SUBMIT ")||n.startsWith("[FORM_SUBMIT ")||n.startsWith("[REMEDIATION_
4SUBMIT "))||!s&&!x&&!l?null:s?e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[78%] rounded-2xl rounded-br-md bg-primary text-primary-foreground px-4 py-2.5 text-sm break-words leading-relaxed shadow-sm",children:n})}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[(n||l)&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"max-w-[85%] rounded-2xl rounded-bl-md bg-muted/70 border border-border/30 px-4 py-2.5 text-sm text-foreground break-words overflow-hidden leading-relaxed shadow-sm",children:n?e.jsx("div",{className:"[&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:y?e.jsx("span",{className:"whitespace-pre-wrap",children:p}):e.jsx(de,{remarkPlugins:[ce],disallowedElements:["details","summary"],unwrapDisallowed:!0,components:Re,children:n})}):e.jsx(Me,{})})}),m.map(i=>{const f=i.toolCallId??i.id??i.type,N=i.type.replace(/^tool-/,""),g=i.input??i.args??{};if(N==="addProperty"){if(i.state!=="output-available")return null;const b=i.output;if(!b||typeof b!="object")return null}if(N==="presentQuestionnaire"){const b=i.input??i.args;if(!(b!=null&&b.steps)||!Array.isArray(b.steps))return null}return e.jsx(we,{toolName:N,args:g,onSubmit:a,disabled:!r},`${t.id}-${f}`)})]})}const Le={single:"Single",mfj:"Married Filing Jointly",mfs:"Married Filing Separately",hoh:"Head of Household",qw:"Qualifying Widow(er)"},Fe={longTerm:"Long-Term Rentals",shortTerm:"Short-Term Rentals"},$e={w2:"W-2 Employee",self_employed:"Self-Employed",business_owner:"Business Owner",retired:"Retired",full_time_re:"Full-Time Real Estate",selfEmployed:"Self-Employed",w2Employee:"W-2 Employee",unemployed:"Unemployed"};function _({label:t,value:r}){const a=r!=null&&r!=="";return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/60 font-medium",children:t}),e.jsx("span",{className:S("text-xs font-medium",a?"text-foreground":"text-muted-foreground/40 italic"),children:a?r:"—"})]})}function Qe(){const{user:t}=ue(),[r,a]=c.useState(!1),{data:s}=me({queryKey:["/api/properties"],queryFn:async()=>{const g=localStorage.getItem("accessToken"),b=await fetch("/api/properties",{credentials:"include",headers:g?{Authorization:`Bearer ${g}`}:{}});return b.ok?b.json():[]},staleTime:3e4}),n=t!=null&&t.filingStatus?Le[t.filingStatus]??t.filingStatus:null,m=t!=null&&t.repType?Fe[t.repType]??t.repType:null,x=t!=null&&t.employmentType?$e[t.employmentType]??t.employmentType:null,o=(s==null?void 0:s.length)??null,l=!!(t!=null&&t.googleCalendarAccessToken),p=!!(t!=null&&t.microsoftAccessToken),y=l&&p?"Google + Outlook":l?"Google Calendar":p?"Outlook Calendar":null,i=5,f=[n,m,x,o!==null&&o>0?"set":null,y].filter(Boolean).length,N=Math.round(f/i*100);return e.jsxs("div",{className:"border-y border-border/25 bg-muted/20",children:[e.jsxs("button",{type:"button",onClick:()=>a(g=>!g),className:"flex items-center justify-between w-full px-5 sm:px-8 py-2.5 text-muted-foreground hover:text-foreground transition-colors","aria-expanded":r,"aria-controls":"onboarding-summary-panel",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/70",children:"Setup Summary"}),e.jsx("div",{className:"w-16 h-1 rounded-full bg-border/50 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-primary/60 transition-all duration-500",style:{width:`${N}%`}})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground/50",children:[N,"%"]}),e.jsx(pe,{className:S("h-3.5 w-3.5 shrink-0 transition-transform duration-200",r&&"rotate-180"),"aria-hidden":!0})]})]}),r&&e.jsx("div",{id:"onboarding-summary-panel",className:"px-5 sm:px-8 pb-3 pt-0.5",children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-2.5",children:[e.jsx(_,{label:"Filing Status",value:n}),e.jsx(_,{label:"REP Type",value:m}),e.jsx(_,{label:"Employment",value:x}),e.jsx(_,{label:"Properties",value:o!==null?o===1?"1 property":`${o} properties`:null}),e.jsx(_,{label:"Calendar",value:y})]})})]})}function Be({onComplete:t}){const r=xe(),a=c.useRef(null),s=c.useRef(null),[n,m]=c.useState(""),x=c.useRef(!1),o=c.useRef(new Set),{messages:l,send:p,isLoading:y,isComplete:i,calendarConnectedViaOAuth:f,sessionStepFloor:N}=je(),g=(()=>
4{if(!y)return!1;const d=[...l].reverse().find(h=>h.role==="assistant");return d?d.parts.some(h=>typeof h.type=="string"&&h.type==="tool-showSelector"):!1})(),b=(()=>{var h;if(i)return P.length;let d=Math.max(N,f?3:0);for(const k of l)for(const w of k.parts){if(typeof w.type!="string")continue;const E=w.state;w.type==="tool-saveFields"&&E==="output-available"&&((h=w.output)==null?void 0:h.taxProfileComplete)===!0?d=Math.max(d,1):w.type==="tool-addProperty"&&E==="output-available"?d=Math.max(d,2):w.type==="tool-inviteTeamMember"&&E==="output-available"&&(d=Math.max(d,4))}return Math.min(d,P.length)})();c.useEffect(()=>{f&&(r.invalidateQueries({queryKey:["/api/integrations/calendar-status"]}),r.invalidateQueries({queryKey:["/api/auth/user"]}))},[f,r]),c.useEffect(()=>{var d;(d=a.current)==null||d.scrollIntoView({behavior:"smooth"})},[l]),c.useEffect(()=>{for(const d of l)for(const h of d.parts){if(typeof h.type!="string")continue;const k=h.toolCallId??h.id??"";if(o.current.has(k))continue;const w=h.state;h.type==="tool-saveFields"&&w==="output-available"&&(o.current.add(k),r.invalidateQueries({queryKey:["/api/auth/user"]})),h.type==="tool-addProperty"&&w==="output-available"&&(o.current.add(k),r.invalidateQueries({queryKey:["/api/properties"]})),h.type==="tool-connectCalendar"&&(o.current.add(k),r.invalidateQueries({queryKey:["/api/integrations/calendar-status"]}),r.invalidateQueries({queryKey:["/api/auth/user"]})),h.type==="tool-inviteTeamMember"&&w==="output-available"&&(o.current.add(k),r.invalidateQueries({queryKey:["/api/integrations/calendar-status"]}),r.invalidateQueries({queryKey:["/api/auth/user"]}))}},[l,r]),c.useEffect(()=>{if(!i||x.current)return;x.current=!0,r.invalidateQueries({queryKey:["/api/auth/user"]});const d=setTimeout(()=>{t()},1200);return()=>clearTimeout(d)},[i,r,t]);function L(){const d=n.trim();!d||y||(m(""),p(d))}function $(d){d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),L())}return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx("div",{className:"shrink-0 px-5 sm:px-8 pt-5 sm:pt-6 pb-4",children:e.jsx(Ne,{currentStep:b})}),e.jsx("div",{className:"shrink-0",children:e.jsx(Qe,{})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto","aria-live":"polite","aria-label":"Onboarding conversation",children:e.jsxs("div",{className:"px-5 sm:px-8 pt-4 pb-4 space-y-4",children:[l.map((d,h)=>e.jsx(_e,{message:d,isLatest:h===l.length-1,onToolSubmit:k=>p(k)},d.id)),i&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"max-w-[85%] rounded-2xl bg-primary/10 border border-primary/20 px-4 py-3 text-sm text-foreground",children:e.jsx("p",{className:"font-medium text-primary",children:"All set — taking you to your dashboard."})})}),e.jsx("div",{ref:a})]})}),e.jsxs("div",{className:"shrink-0 border-t border-border/40 px-5 sm:px-8 pt-3",style:{paddingBottom:"max(env(safe-area-inset-bottom), 1rem)"},children:[e.jsxs("div",{className:S("flex gap-2 items-center",g&&"opacity-50"),children:[e.jsx("input",{ref:s,type:"text",value:n,onChange:d=>m(d.target.value),onKeyDown:$,placeholder:i?"Onboarding complete":g?"Or type your answer…":"Type a message…",disabled:y||i,className:S("flex-1 h-11 rounded-xl border border-input bg-background px-4 text-sm","placeholder:text-muted-foreground/60","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-1","transition-colors disabled:opacity-40 disabled:cursor-not-allowed","shadow-sm"),"aria-label":"Type your message"}),e.jsx(M,{size:"icon",onClick:L,disabled:!n.trim()||y||i,className:"h-11 w-11 shrink-0 rounded-xl bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm disabled:opacity-30","aria-label":"Send message",children:e.jsx(fe,{className:"h-4 w-4"})})]}),!i&&!y&&e.jsx("div",{className:"flex justify-center mt-2",children:e.jsx("button",{type:"button",onClick:()=>
4p("Skip everything and take me to the dashboard"),className:"text-xs text-muted-foreground/50 hover:text-muted-foreground transition-colors underline-offset-2 hover:underline",children:"Skip remaining setup"})})]})]})}function He({onComplete:t}){const r=c.useRef(!1);async function a(){if(!r.current){r.current=!0;try{await fetch("/api/onboarding/complete",{method:"POST",credentials:"include",headers:(()=>{const s=localStorage.getItem("accessToken");return s?{Authorization:`Bearer ${s}`}:{}})()})}catch{}t()}}return e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-background",style:{height:"100dvh"},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle at 30% 20%, hsl(var(--primary)) 0%, transparent 60%), radial-gradient(circle at 75% 80%, hsl(var(--primary)) 0%, transparent 55%)"},"aria-hidden":!0}),e.jsxs("header",{className:"relative shrink-0 flex items-center justify-between px-5 sm:px-8",style:{paddingTop:"max(env(safe-area-inset-top), 1rem)",paddingBottom:"0.875rem"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/repsshield-logo-main.png",alt:"REPSShield",className:"h-7 w-auto"}),e.jsx("span",{className:"font-semibold text-sm tracking-tight text-foreground",children:"REPSShield"})]}),e.jsx("button",{type:"button",onClick:a,className:"text-xs text-muted-foreground hover:text-foreground transition-colors px-2.5 py-1.5 -mr-1 rounded-lg hover:bg-muted/60",children:"Skip for now"})]}),e.jsx("div",{className:"relative shrink-0 h-px bg-border/40"}),e.jsx(he,{children:e.jsx("div",{className:"relative flex-1 min-h-0 flex items-center justify-center overflow-hidden px-0 sm:px-4 py-4 sm:py-6",children:e.jsx("div",{className:"w-full max-w-2xl flex flex-col min-h-0 max-h-full overflow-hidden rounded-none sm:rounded-2xl sm:border sm:border-border/40 sm:shadow-lg bg-background",children:e.jsx(Be,{onComplete:t})})})})]})}export{He 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.