vendor: 12,580 bytes, lines 1-26
1import{c as R,r,f as De,j as e,b as Oe,u as Me,P as V,d as Q,v as Re,o as x,n as Be,t as S,a as k,L as Je,B as b,C as v,l as y,i as Fe,k as Ue,m as q}from"./index-CZE7ptUD.js";import{u as ze,a as Ve}from"./index-CWZP4Ye1.js";import{I as $e}from"./input-Vep9kJkm.js";import{c as pe,R as Ke,I as We}from"./index-CCHn8h0H.js";import{S as le}from"./separator-dt8IlVvb.js";import{A as Ye}from"./arrow-left-3lcFBsx3.js";import{B as T}from"./bot-Cnj3rPCx.js";import{D as Ge}from"./download-BcAGWAZy.js";import{R as U,C as p}from"./refresh-cw-CxQKIcMx.js";import{A as M}from"./activity-BJ82alU2.js";import{C as ne}from"./clock-BZJ_gNj7.js";import{C as z,a as oe}from"./circle-x-S8bixcr5.js";import{Z as H}from"./zap-DbtzdgMG.js";import{S as Z}from"./search-CQLcNv59.js";import{S as ce,a as ie}from"./square-Cgx7Ta1n.js";import{C as Qe}from"./chevron-down-4xJIteQN.js";import{C as qe}from"./chevron-right-C_aA1SG-.js";import"./x-B64YwYlD.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const me=R("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const re=R("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** 12 * @license lucide-react v0.453.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const de=R("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/** 17 * @license lucide-react v0.453.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const xe=R("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/** 22 * @license lucide-react v0.453.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const Ze=R("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var $="Tabs",[Xe]=Oe($,[pe]),Ae=pe(),[es,X]=Xe($),he=r.forwardRef((t,l)=>{const{__scopeTabs:n,value:o,onValueChange:c,defaultValue:a,orientation:i="horizontal",dir:j,activationMode:h="automatic",...E}=t,m=ze(j),[g,C]=De({prop:o,onChange:c,defaultProp:a??"",caller:$});return e.jsx(es,{scope:n,baseId:Me(),value:g,onValueChange:C,orientation:i,dir:m,activationMode:h,children:e.jsx(V.div,{dir:m,"data-orientation":i,...E,ref:l})})});he.displayName=$;var Ce="TabsList",ue=r.forwardRef((t,l)=>{const{__scopeTabs:n,loop:o=!0,...c}=t,a=X(Ce,n),i=Ae(n);return e.jsx(Ke,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:o,children:e.jsx(V.div,{role:"tablist","aria-orientation":a.orientation,...c,ref:l})})});ue.displayName=Ce;var be="TabsTrigger",je=r.forwardRef((t,l)=>{const{__scopeTabs:n,value:o,disabled:c=!1,...a}=t,i=X(be,n),j=Ae(n),h=ve(i.baseId,o),E=ye(i.baseId,o),m=o===i.value;return e.jsx(We,{asChild:!0,...j,focusable:!c,active:m,children:e.jsx(V.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":E,"data-state":m?"active":"inactive","data-disabled":c?"":void 0,disabled:c,id:h,...a,ref:l,onMouseDown:Q(t.onMouseDown,g=>{!c&&g.button===0&&g.ctrlKey===!1?i.onValueChange(o):g.preventDefault()}),onKeyDown:Q(t.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&i.onValueChange(o)}),onFocus:Q(t.onFocus,()=>{const g=i.activationMode!=="manual";!m&&!c&&g&&i.onValueChange(o)})})})});je.displayName=be;var Ne="TabsContent",fe=r.forwardRef((t,l)=>{const{__scopeTabs:n,value:o,forceMount:c,children:a,...i}=t,j=X(Ne,n),h=ve(j.baseId,o),E=ye(j.baseId,o),m=o===j.value,g=r.useRef(m);return r.useEffect(()=>{const C=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(C)},[]),e.jsx(Re,{present:c||m,children:({present:C})=>e.jsx(V.div,{"data-state":m?"active":"inactive","data-orientation":j.orientation,role:"tabpanel","aria-labelledby":h,hidden:!C,id:E,tabIndex:0,...i,ref:l,style:{...t.style,animationDuration:g.current?"0s":void 0},children:C&&a})})});fe.displayName=Ne;function ve(t,l){return`${t}-trigger-${l}`}function ye(t,l){return`${t}-content-${l}`}var ss=he,ts=ue,as=je,ls=fe;function ns({className:t,...l}){return e.jsx(ss,{"data-loc":"client/src/components/ui/tabs.tsx:11","data-slot":"tabs",className:x("flex flex-col gap-2",t),...l})}function os({className:t,...l}){return e.jsx(ts,{"data-loc":"client/src/components/ui/tabs.tsx:24","data-slot":"tabs-list",className:x("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",t),...l})}function D({className:t,...l}){return e.jsx(as,{"data-loc":"client/src/components/ui/tabs.tsx:40","data-slot":"tabs-trigger",className:x("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...l})}function O({className:t,...l}){return e.jsx(ls,{"data-loc":"client/src/components/ui/tabs.tsx:56","data-slot":"tabs-content",className:x("flex-1 outline-none",t),...l})}const we={AI_JOB_DESCRIPTION_START:{label:"AI: Generating job descriptionâ¦",icon:e.jsx(T,{"data-loc":"client/src/pages/AiAgentConsole.tsx:52",className:"w-3.5 h-3.5"}),color:"text-violet-600"},AI_JOB_DESCRIPTION_COMPLETE:{label:"AI: Job description ready",icon:e.jsx(T,{"data-loc":"client/src/pages/AiAgentConsole.tsx:53",className:"w-3.5 h-3.5"}),color:"text-violet-600"},HCP_CUSTOMER_SEARCH:{label:"HCP: Searching for existing customer",icon:e.jsx(Z,{"data-loc":"client/src/pages/AiAgentConsole.tsx:54",className:"w-3.5 h-3.5"}),color:"text-blue-600"},HCP_CUSTOMER_FOUND:{label:"HCP: Customer found â reusing",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:55",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},HCP_CUSTOMER_UPDATED:{label:"HCP: Customer record updated",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:56",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},HCP_CUSTOMER_UPDATE_FAILED:{label:"HCP: Customer update failed",icon:e.jsx(q,{"data-loc":"client/src/pages/AiAgentConsole.tsx:57",className:"w-3.5 h-3.5"}),color:"text-amber-600"},HCP_CUSTOMER_CREATE:{label:"HCP: Creating new customerâ¦",icon:e.jsx(H,{"data-loc":"client/src/pages/AiAgentConsole.tsx:58",className:"w-3.5 h-3.5"}),color:"text-blue-600"},HCP_CUSTOMER_CREATED:{label:"HCP: New customer created",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:59",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},HCP_JOB_CREATE:{label:"HCP: Creating jobâ¦",icon:e.jsx(H,{"data-loc":"client/src/pages/AiAgentConsole.tsx:60",className:"w-3.5 h-3.5"}),color:"text-blue-600"},HCP_JOB_CREATED:{label:"HCP: Job created successfully",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:61",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},SYNC_COMPLETE:{label:"Sync complete â",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:62",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},SYNC_FAILED:{label:"Sync failed â",icon:e.jsx(z,{"data-loc":"client/src/pages/AiAgentConsole.tsx:63",className:"w-3.5 h-3.5"}),color:"text-red-600"},HCP_SYNC_COMPLETE:{label:"HCP Jobs Sync Complete",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:64",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},HCP_SYNC_FAILED:{label:"HCP Jobs Sync Failed",icon:e.jsx(z,{"data-loc":"client/src/pages/AiAgentConsole.tsx:65",className:"w-3.5 h-3.5"}),color:"text-red-600"},HCP_STATUS_CHANGE:{label:"HCP â PICRA status updated",icon:e.jsx(H,{"data-loc":"client/src/pages/AiAgentConsole.tsx:66",className:"w-3.5 h-3.5"}),color:"text-blue-600"},HCP_JOB_AUTO_MATCHED:{label:"HCP: Job auto-matched to PICRA",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:67",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},HCP_JOB_UNMATCHED:{label:"HCP: Job has no matching PICRA",icon:e.jsx(q,{"data-loc":"client/src/pages/AiAgentConsole.tsx:68",className:"w-3.5 h-3.5"}),color:"text-amber-600"},HCP_CUSTOMER_IDENTITY_VERIFY:{label:"AI: Verifying customer identity",icon:e.jsx(T,{"data-loc":"client/src/pages/AiAgentConsole.tsx:69",className:"w-3.5 h-3.5"}),color:"text-violet-600"},HCP_CUSTOMER_MANUALLY_LINKED:{label:"Manual: Customer linked by staff",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:70",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},WEBHOOK_JOB_SCHEDULED:{label:"HCP â Job scheduled",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:71",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},WEBHOOK_JOB_COMPLETED:{label:"HCP â Job completed",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:72",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},WEBHOOK_JOB_CANCELLED:{label:"HCP â Job cancelled",icon:e.jsx(z,{"data-loc":"client/src/pages/AiAgentConsole.tsx:73",className:"w-3.5 h-3.5"}),color:"text-red-600"},WEBHOOK_INVOICE_PAID:{label:"HCP â Invoice paid",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:74",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},WEBHOOK_JOB_STARTED:{label:"HCP â Job started",icon:e.jsx(H,{"data-loc":"client/src/pages/AiAgentConsole.tsx:75",className:"w-3.5 h-3.5"}),color:"text-blue-600"},WEBHOOK_JOB_ON_MY_WAY:{label:"HCP â Technician en route",icon:e.jsx(H,{"data-loc":"client/src/pages/AiAgentConsole.tsx:76",className:"w-3.5 h-3.5"}),color:"text-blue-600"},WEBHOOK_ESTIMATE_SCHEDULED:{label:"HCP â Estimate scheduled",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:77",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},WEBHOOK_ESTIMATE_COMPLETED:{label:"HCP â Estimate completed",icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:78",className:"w-3.5 h-3.5"}),color:"text-emerald-600"},HCP_CUSTOMER_AUTO_LINKED:{label:"AI: Customer auto-linked (strong match)",icon:e.jsx(T,{"data-loc":"client/src/pages/AiAgentConsole.tsx:79",className:"w-3.5 h-3.5"}),color:"text-violet-600"},HCP_CUSTOMER_IDENTITY_MATCH:{label:"AI: Identity match confirmed",icon:e.jsx(T,{"data-loc":"client/src/pages/AiAgentConsole.tsx:80",className:"w-3.5 h-3.5"}),color:"text-violet-600"},HCP_CUSTOMER_IDENTITY_MISMATCH:{label:"AI: Identity mismatch detected",icon:e.jsx(q,{"data-loc":"client/src/pages/AiAgentConsole.tsx:81",className:"w-3.5 h-3.5"}),color:"text-amber-600"}};function cs({decision:t}){const l={auto_approved:{label:"Auto-approved",className:"bg-emerald-50 text-emerald-700 border-emerald-200"},approved:{label:"Approved",className:"bg-emerald-50 text-emerald-700 border-emerald-200"},rejected:{label:"Rejected",className:"bg-red-50 text-red-700 border-red-200"},pending:{label:"Pending",className:"bg-amber-50 text-amber-700 border-amber-200"},skipped:{label:"Skipped",className:"bg-gray-50 text-gray-600 border-gray-200"}},n=l[t]??l.pending;return e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:95",className:x("inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border",n.className),children:n.label})}function Se({value:t}
26){if(t==null)return null;const l=t>=90?"bg-emerald-500":t>=70?"bg-amber-500":"bg-red-500";return e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:106",className:"flex items-center gap-2",children:[e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:107",className:"flex-1 h-1.5 bg-gray-100 rounded-full overflow-hidden",children:e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:108",className:x("h-full rounded-full transition-all",l),style:{width:`${t}%`}})}),e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:110",className:"text-xs text-gray-500 w-8 text-right",children:[t,"%"]})]})}function ge({entry:t,isNew:l}){const[n,o]=r.useState(!1),c=we[t.operation]??{label:t.operation,icon:e.jsx(M,{"data-loc":"client/src/pages/AiAgentConsole.tsx:141",className:"w-3.5 h-3.5"}),color:"text-gray-600"};return e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:146",className:x("border rounded-xl overflow-hidden transition-all",l&&"ring-2 ring-violet-300 ring-offset-1",t.decision==="rejected"||t.operation==="SYNC_FAILED"?"border-red-200 bg-red-50/30":t.decision==="pending"?"border-amber-200 bg-amber-50/20":"border-gray-100 bg-white"),children:[e.jsxs("button",{"data-loc":"client/src/pages/AiAgentConsole.tsx:157",className:"w-full px-4 py-3 flex items-start gap-3 text-left hover:bg-gray-50/50 transition-colors",onClick:()=>o(a=>!a),children:[e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:162",className:x("mt-0.5 shrink-0",c.color),children:c.icon}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:165",className:"flex-1 min-w-0",children:[e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:166",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:167",className:x("text-sm font-medium",c.color),children:c.label}),l&&e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:169",className:"text-xs bg-violet-100 text-violet-700 px-1.5 py-0.5 rounded-full font-medium",children:"NEW"})]}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:172",className:"flex items-center gap-3 mt-1 flex-wrap",children:[t.submissionAddress&&e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:174",className:"text-xs text-gray-500 truncate max-w-[200px]",children:["ð ",t.submissionAddress]}),t.agentName&&e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:177",className:"text-xs text-gray-400",children:["Agent: ",t.agentName]}),t.hcpJobId&&e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:180",className:"text-xs text-blue-500 font-mono",children:["Job: ",t.hcpJobId.slice(0,8),"â¦"]}),t.hcpCustomerId&&e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:183",className:"text-xs text-blue-400 font-mono",children:["Cust: ",t.hcpCustomerId.slice(0,8),"â¦"]}),t.durationMs!==null&&e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:186",className:"text-xs text-gray-400",children:[t.durationMs,"ms"]})]}),t.confidence!==null&&e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:190",className:"mt-1.5 max-w-[200px]",children:e.jsx(Se,{"data-loc":"client/src/pages/AiAgentConsole.tsx:191",value:t.confidence})})]}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:197",className:"shrink-0 flex flex-col items-end gap-1.5",children:[e.jsx(cs,{"data-loc":"client/src/pages/AiAgentConsole.tsx:198",decision:t.decision}),e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:199",className:"text-xs text-gray-400",children:new Date(t.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),n?e.jsx(Qe,{"data-loc":"client/src/pages/AiAgentConsole.tsx:202",className:"w-3.5 h-3.5 text-gray-400"}):e.jsx(qe,{"data-loc":"client/src/pages/AiAgentConsole.tsx:202",className:"w-3.5 h-3.5 text-gray-400"})]})]}),n&&e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:208",className:"px-4 pb-4 space-y-3 border-t border-gray-100 pt-3",children:[t.aiReasoning&&e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:210",children:[e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:211",className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"AI Reasoning"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:212",className:"text-sm text-gray-700 leading-relaxed bg-vi
26olet-50 rounded-lg p-3 border border-violet-100",children:t.aiReasoning})]}),t.errorMessage&&e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:218",children:[e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:219",className:"text-xs font-semibold text-red-500 uppercase tracking-wide mb-1",children:"Error"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:220",className:"text-sm text-red-700 bg-red-50 rounded-lg p-3 border border-red-100 font-mono text-xs",children:t.errorMessage})]}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:225",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.inputData&&Object.keys(t.inputData).length>0&&e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:227",children:[e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:228",className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Sent to HCP"}),e.jsx("pre",{"data-loc":"client/src/pages/AiAgentConsole.tsx:229",className:"text-xs bg-gray-50 rounded-lg p-3 border border-gray-100 overflow-auto max-h-40 text-gray-700",children:JSON.stringify(t.inputData,null,2)})]}),t.outputData&&Object.keys(t.outputData).length>0&&e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:235",children:[e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:236",className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1",children:"Got Back"}),e.jsx("pre",{"data-loc":"client/src/pages/AiAgentConsole.tsx:237",className:"text-xs bg-emerald-50 rounded-lg p-3 border border-emerald-100 overflow-auto max-h-40 text-gray-700",children:JSON.stringify(t.outputData,null,2)})]})]}),t.decidedBy&&e.jsxs("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:244",className:"text-xs text-gray-400",children:["Decided by ",e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:245",className:"font-medium",children:t.decidedBy}),t.decidedAt&&` at ${new Date(t.decidedAt).toLocaleString()}`]})]})]})}function is(){const[t,l]=r.useState(""),{data:n,isLoading:o}=S.aiConsole.getInvoices.useQuery({status:t||void 0,limit:100,offset:0}),c=a=>
26{if(!a)return null;const i={paid:"bg-emerald-100 text-emerald-700",pending:"bg-amber-100 text-amber-700",overdue:"bg-red-100 text-red-700",voided:"bg-gray-100 text-gray-500"};return e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:273",className:x("text-xs font-medium px-2 py-0.5 rounded-full capitalize",i[a]??"bg-gray-100 text-gray-600"),children:a})};return e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:280",className:"space-y-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:281",className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:282",className:"text-sm font-medium text-gray-700",children:"Filter by status:"}),["","pending","paid","overdue","voided"].map(a=>e.jsx("button",{"data-loc":"client/src/pages/AiAgentConsole.tsx:284",onClick:()=>l(a),className:x("text-xs px-3 py-1 rounded-full border transition-colors",t===a?"bg-indigo-600 text-white border-indigo-600":"bg-white text-gray-600 border-gray-200 hover:border-indigo-300"),children:a===""?"All":a.charAt(0).toUpperCase()+a.slice(1)},a)),n&&e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:298",className:"text-xs text-gray-400 ml-auto",children:[n.total," invoice",n.total!==1?"s":""]})]}),o?e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:303",className:"py-16 text-center",children:[e.jsx(U,{"data-loc":"client/src/pages/AiAgentConsole.tsx:304",className:"animate-spin w-6 h-6 mx-auto text-violet-500 mb-2"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:305",className:"text-sm text-gray-400",children:"Loading invoicesâ¦"})]}):n?.items?.length?e.jsx(v,{"data-loc":"client/src/pages/AiAgentConsole.tsx:314",className:"border-gray-100 shadow-sm",children:e.jsx(y,{"data-loc":"client/src/pages/AiAgentConsole.tsx:315",className:"p-0",children:e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:316",className:"overflow-x-auto",children:e.jsxs("table",{"data-loc":"client/src/pages/AiAgentConsole.tsx:317",className:"w-full text-sm",children:[e.jsx("thead",{"data-loc":"client/src/pages/AiAgentConsole.tsx:318",children:e.jsxs("tr",{"data-loc":"client/src/pages/AiAgentConsole.tsx:319",className:"border-b border-gray-100 bg-gray-50",children:[e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:320",className:"text-left px-4 py-2 text-xs font-medium text-gray-500",children:"Agent"}),e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:321",className:"text-left px-4 py-2 text-xs font-medium text-gray-500",children:"Job #"}),e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:322",className:"text-left px-4 py-2 text-xs font-medium text-gray-500",children:"Address"}),e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:323",className:"text-left px-4 py-2 text-xs font-medium text-gray-500",children:"Customer"}),e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:324",className:"text-right px-4 py-2 text-xs font-medium text-gray-500",children:"Invoice Total"}),e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:325",className:"text-center px-4 py-2 text-xs font-medium text-gray-500",children:"Status"}),e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:326",className:"text-right px-4 py-2 text-xs font-medium text-gray-500",children:"Paid At"})]})}),e.jsx("tbody",{"data-loc":"client/src/pages/AiAgentConsole.tsx:329",children:n.items.map(a=>e.jsxs("tr",{"data-loc":"client/src/pages/AiAgentConsole.tsx:331",className:"border-b border-gray-50 hover:bg-gray-50/50",children:[e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:332",className:"px-4 py-2.5 font-medium text-gray-900",children:a.agentName??a.agentEmail??"â"}),e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:333",className:"px-4 py-2.5 text-gray-600",children:a.hcpJobNumber??a.hcpJobId}),e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:334",className:"px-4 py-2.5 text-gray-600 max-w-[180px] truncate",children:a.address??"â"}),e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:335",className:"px-4 py-2.5 text-gray-600",children:a.customerName??"â"}),e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:336",className:"px-4 py-2.5 text-right font-medium text-gray-900",children:a.invoiceTotal?`$${Number(a.invoiceTotal).toLocaleStr
26ing(void 0,{minimumFractionDigits:2})}`:"â"}),e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:339",className:"px-4 py-2.5 text-center",children:c(a.invoiceStatus)}),e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:340",className:"px-4 py-2.5 text-right text-xs text-gray-400",children:a.invoicePaidAt?new Date(a.invoicePaidAt).toLocaleDateString():"â"})]},a.id))})]})})})}):e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:308",className:"py-16 text-center bg-white rounded-2xl border border-gray-100",children:[e.jsx(me,{"data-loc":"client/src/pages/AiAgentConsole.tsx:309",className:"w-10 h-10 mx-auto text-gray-300 mb-3"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:310",className:"text-gray-500",children:"No invoice data yet"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:311",className:"text-gray-400 text-sm mt-1",children:"Invoice data flows in from HCP webhook events."})]})]})}function Es(){const{agentUser:t,loading:l,isAuthenticated:n}=Ve(),[,o]=Be();r.useEffect(()=>{!l&&!n&&o("/login"),!l&&n&&!t?.isAdmin&&o("/crm")},[l,n,t]);const[c,a]=r.useState("live"),[i,j]=r.useState(""),[h,E]=r.useState(!0),[m,g]=r.useState(new Set),[C,ee]=r.useState(0),B=r.useRef(0);r.useRef(null);const[u,L]=r.useState(new Set),Te=s=>L(d=>{const A=new Set(d);return A.has(s)?A.delete(s):A.add(s),A}),Ee=s=>{u.size===s.length?L(new Set):L(new Set(s))},[Ie,se]=r.useState(!1),[J,_e]=r.useState("0.85"),{data:I,refetch:K}=S.aiConsole.getStats.useQuery(void 0,{refetchInterval:h?1e4:!1}),{data:w,refetch:W,isLoading:Pe}=S.aiConsole.getLogs.useQuery({limit:50,offset:0},{refetchInterval:h?4e3:!1}),{data:N,refetch:Y}=S.aiConsole.getPendingApprovals.useQuery(void 0,{refetchInterval:h?8e3:!1}),{data:_,isLoading:ke,refetch:rs}=S.aiConsole.getLogs.useQuery({limit:30,offset:C},{enabled:c==="history"}),{data:P,refetch:He}=S.aiConsole.syncStatus.useQuery(void 0,{refetchInterval:h?3e4:!1}),G=S.aiConsole.decide.useMutation({onSuccess:()=>{Y(),W(),K(),L(new Set),k.success("Decision recorded")},onError:s=>k.error(s.message)}),F=S.aiConsole.batchDecide.useMutation({onSuccess:s=>{Y(),W(),K(),L(new Set),k.success(`${s.updated} decision${s.updated!==1?"s":""} recorded`)},onError:s=>k.error(s.message)}),Le=async()=>{try{const s=await fetch("/api/trpc/aiConsole.exportCsv?input="+encodeURIComponent(JSON.stringify({json:{}})),{headers:{"Content-Type":"application/json"},credentials:"include"});if(!s.ok)throw new Error("Export failed");const d=await s.blob(),A=URL.createObjectURL(d),f=document.createElement("a");f.href=A,f.download=`ai-console-export-${new Date().toISOString().slice(0,10)}.csv`,f.click(),URL.revokeObjectURL(A)}catch{k.error("CSV export failed â try again")}};r.useEffect(()=>{if(!w?.items)return;const s=w.items;if(s.length===0)return;const d=Math.max(...s.map(f=>f.id));if(B.current===0){B.current=d;return}const A=new Set(s.filter(f=>f.id>B.current).map(f=>f.id));A.size>0&&(g(A),B.current=d,setTimeout(()=>g(new Set),8e3))},[w]);const te=(w?.items??[]).filter(s=>{if(!i)return!0;const d=i.toLowerCase();return s.operation.toLowerCase().includes(d)||(s.submissionAddress??"").toLowerCase().includes(d)||(s.agentName??"").toLowerCase().includes(d)||(s.hcpJobId??"").toLowerCase().includes(d)||(s.aiReasoning??"").toLowerCase().includes(d)}),ae=(s,d)=>{G.mutate({logId:s,decision:d,decidedBy:t?.email??t?.name??"admin"})};return e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:495",className:"min-h-screen bg-gray-50",children:[e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:497",className:"bg-white border-b border-gray-200 sticky top-0 z-10",children:e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:498",className:"max-w-6xl mx-auto px-4 py-3 flex items-center gap-3",children:[e.jsx(Je,{"data-loc":"client/src/pages/AiAgentConsole.tsx:499",href:"/admin",children:e.jsxs(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:500",variant:"ghost",size:"sm",className:"gap-1.5 text-gray-500 hover:text-gray-900",children:[e.jsx(Ye,{"data-loc":"client/src/pages/AiAgentConsole.tsx:501",className:"w-4 h-4"}),"Admin"]})}),e.jsx(le,{"data-loc":"client/src/pages/AiAgentConsole.tsx:505",orientation:"vertical",className:"h-5"}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:506",className:"flex items-center gap-2",children:[e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:507",className:"w-8 h-8 rounded-lg bg-gradient-to-br from-violet-500 to-indigo-600 flex items-center justify-center",children:e.jsx(T,{"data-loc":"client/src/pages/AiAgentConsole.tsx:508",className:"w-4 h-4 text-white"})}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:510",children:[e.jsx("h1",{"data-loc":"client/src/pages/AiAgentConsole.tsx:511",className:"font-bold text-gray-900 text-sm leading-tight",children:"AI Agent Console"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:512",className:"text-xs text-gray-500 leading-tight",children:"Housecall Pro sync intelligence"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:515",className:"ml-auto flex items-center gap-2",children:[e.jsx("button",{"data-loc":"client/src/pages/AiAgentConsole.tsx:517",onClick:()=>E(s=>!s),className:x("flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium transition-all",h?"bg-emerald-50 text-emerald-700 border border-emerald-200":"bg-gray-100 text-gray-500 border border-gray-200"),children:h?e.jsxs(e.Fragment,{children:[e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:528",className:"relative flex h-2 w-2",children:[e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:529",className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:530",className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]}),"Live"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{"data-loc":"client/src/pages/AiAgentConsole.tsx:536",className:"w-3 h-3"}),"Paused"]})}),e.jsxs(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:541",variant:"outline",size:"sm",className:"rounded-xl gap-1.5 text-xs",onClick:Le,children:[e.jsx(Ge,{"data-loc":"client/src/pages/AiAgentConsole.tsx:547",className:"w-3.5 h-3.5"}),"Export CSV"]}),e.jsxs(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:550",variant:"outline",size:"sm",className:"rounded-xl gap-1.5 text-xs",onClick:()=>se(s=>!s),children:[e.jsx(re,{"data-loc":"client/src/pages/AiAgentConsole.tsx:556",className:"w-3.5 h-3.5"}),"Threshold"]}),e.jsx(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:559",variant:"outline",size:"sm",className:"rounded-xl",onClick:()=>{W(),K(),Y(),He()},children:e.jsx(U,{"data-loc":"client/src/pages/AiAgentConsole.tsx:560",className:"w-3.5 h-3.5"})})]})]})}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:566",className:"max-w-6xl mx-auto px-4 py-5 space-y-4",children:[e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:568",className:"grid grid-cols-2 md:grid-cols-5 ga
26p-3",children:[{label:"Total Operations",value:I?.total??0,icon:e.jsx(M,{"data-loc":"client/src/pages/AiAgentConsole.tsx:570",className:"w-4 h-4"}),color:"text-gray-600"},{label:"Auto-Approved",value:I?.autoApproved??0,icon:e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:571",className:"w-4 h-4"}),color:"text-emerald-600"},{label:"Pending Review",value:I?.pending??0,icon:e.jsx(ne,{"data-loc":"client/src/pages/AiAgentConsole.tsx:572",className:"w-4 h-4"}),color:"text-amber-600"},{label:"Failed",value:I?.failed??0,icon:e.jsx(z,{"data-loc":"client/src/pages/AiAgentConsole.tsx:573",className:"w-4 h-4"}),color:"text-red-600"},{label:"Last 24h",value:I?.last24h??0,icon:e.jsx(H,{"data-loc":"client/src/pages/AiAgentConsole.tsx:574",className:"w-4 h-4"}),color:"text-violet-600"}].map(s=>e.jsx(v,{"data-loc":"client/src/pages/AiAgentConsole.tsx:576",className:"border-gray-100 shadow-sm",children:e.jsxs(y,{"data-loc":"client/src/pages/AiAgentConsole.tsx:577",className:"p-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:578",className:x("flex items-center gap-1.5 mb-1",s.color),children:[s.icon,e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:580",className:"text-xs font-medium",children:s.label})]}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:582",className:"text-2xl font-bold text-gray-900",children:s.value.toLocaleString()})]})},s.label))}),Ie&&e.jsx(v,{"data-loc":"client/src/pages/AiAgentConsole.tsx:590",className:"border-indigo-200 bg-indigo-50/40",children:e.jsx(y,{"data-loc":"client/src/pages/AiAgentConsole.tsx:591",className:"p-4",children:e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:592",className:"flex items-center gap-4 flex-wrap",children:[e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:593",className:"flex items-center gap-2",children:[e.jsx(re,{"data-loc":"client/src/pages/AiAgentConsole.tsx:594",className:"w-4 h-4 text-indigo-600"}),e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:595",className:"font-semibold text-sm text-indigo-900",children:"Auto-Approve Confidence Threshold"})]}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:597",className:"flex items-center gap-2 flex-1 min-w-[200px]",children:[e.jsx("input",{"data-loc":"client/src/pages/AiAgentConsole.tsx:598",type:"range",min:"0.5",max:"1.0",step:"0.01",value:J,onChange:s=>_e(s.target.value),className:"flex-1 accent-indigo-600"}),e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:607",className:"text-sm font-mono font-bold text-indigo-700 w-12 text-right",children:parseFloat(J).toFixed(2)})]}),e.jsx(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:609",size:"sm",className:"bg-indigo-600 text-white hover:bg-indigo-700 rounded-xl",onClick:()=>{k.success(`Threshold set to ${parseFloat(J).toFixed(2)} â takes effect on next sync`),se(!1)},children:"Apply"}),e.jsxs("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:619",className:"text-xs text-indigo-600 w-full",children:["Operations with AI confidence ⥠",parseFloat(J).toFixed(2)," will be auto-approved. Lower values approve more automatically."]})]})})}),e.jsxs(ns,{"data-loc":"client/src/pages/AiAgentConsole.tsx:628",value:c,onValueChange:a,children:[e.jsxs(os,{"data-loc":"client/src/pages/AiAgentConsole.tsx:629",className:"bg-white border border-gray-200 rounded-xl p-1 flex-wrap h-auto gap-1",children:[e.jsxs(D,{"data-loc":"client/src/pages/AiAgentConsole.tsx:630",value:"live",className:"rounded-lg text-sm gap-1.5",children:[e.jsx(M,{"data-loc":"client/src/pages/AiAgentConsole.tsx:631",className:"w-3.5 h-3.5"}),"Live Log",(w?.total??0)>0&&e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:634",className:"ml-1 bg-gray-100 text-gray-600 text-xs px-1.5 py-0.5 rounded-full",children:w?.total})]}),e.jsxs(D,{"data-loc":"client/src/pages/AiAgentConsole.tsx:639",value:"pending",className:"rounded-lg text-sm gap-1.5",children:[e.jsx(ne,{"data-loc":"client/src/pages/AiAgentConsole.tsx:640",className:"w-3.5 h-3.5"}),"Pending Approvals",(N?.length??0)>0&&e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:643",className:"ml-1 bg-amber-100 text-amber-700 text-xs px-1.5 py-0.5 rounded-full font-medium",children:N?.length})]}),e.jsxs(D,{"data-loc":"client/src/pages/AiAgentConsole.tsx:648",value:"history",className:"rounded-lg text-sm gap-1.5",children:[e.jsx(Z,{"data-loc":"client/src/pages/AiAgentConsole.tsx:649",className:"w-3.5 h-3.5"}),"Full History"]}),e.jsxs(D,{"data-loc":"client/src/pages/AiAgentConsole.tsx:652",value:"sync",className:"rounded-lg text-sm gap-1.5",children:[e.jsx(oe,{"data-loc":"client/src/pages/AiAgentConsole.tsx:653",className:"w-3.5 h-3.5"}),"Sync Status"]}),e.jsxs(D,{"data-loc":"client/src/pages/AiAgentConsole.tsx:656",value:"invoices",className:"rounded-lg text-sm gap-1.5",children:[e.jsx(me,{"data-loc":"client/src/pages/AiAgentConsole.tsx:657",className:"w-3.5 h-3.5"}),"Invoices"]})]}),e.jsxs(O,{"data-loc":"client/src/pages/AiAgentConsole.tsx:663",value:"live",className:"mt-4 space-y-3",children:[e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:664",className:"flex items-center gap-2",children:e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:665",className:"relative flex-1",children:[e.jsx(Z,{"data-loc":"client/src/pages/AiAgentConsole.tsx:666",className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx($e,{"data-loc":"client/src/pages/AiAgentConsole.tsx:667",placeholder:"Search operations, addresses, agents, job IDsâ¦",className:"pl-9 rounded-xl border-gray-200",value:i,onChange:s=>j(s.target.value)})]})}),Pe?e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:677",className:"py-16 text-center",children:[e.jsx(U,{"data-loc":"client/src/pages/AiAgentConsole.tsx:678",className:"animate-spin w-6 h-6 mx-auto text-violet-500 mb-2"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:679",className:"text-sm text-gray-400",children:"Loading AI activityâ¦"})]}):te.length===0?e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:682",className:"py-16 text-center bg-white rounded-2xl border border-gray-100",children:[e.jsx(T,{"data-loc":"client/src/pages/AiAgentConsole.tsx:683",className:"w-10 h-10 mx-auto text-gray-300 mb-3"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:684",className:"text-gray-500 font-medium",children:"No AI activity yet"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:685",className:"text-gray-400 text-sm mt-1",children:"Trigger a sync from the Submissions tab to see the AI agent in action."})]}):e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:690",className:"space-y-2",children:[te.map(s=>e.jsx(ge,{"data-loc":"client/src/pages/AiAgentConsole.tsx:692",entry:s,isNew:m.has(s.id)},s.id)),(w?.total??0)>50&&e.jsxs("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:699",className:"text-xs text-center text-gray-400 py-2",children:["Showing latest 50 of ",w?.total," operations. Use Full History to see all."]})]})]}),e.jsx(O,{"data-loc":"client/src/pages/AiAgentConsole.tsx:708",value:"pending",className:"mt-4",children:!N||N.length===0?e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:710",className:"py-16 text-center bg-white rounded-2xl border border-gray-100",children:[e.jsx(p,{"data-loc":"client/src/pages/AiAgentConsole.tsx:711",className:"w-10 h-10 mx-auto text-emerald-300 mb-3"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:712",className:"text-gray-500 font-medium",children:"All clear â no pending approvals"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:713",className:"text-gray-400 text-sm mt-1",children:"The AI agent is handling everything automatically."})]}):e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:718",className:"space-y-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:720",className:"flex items-center gap-2 bg-amber-50 border border-amber-200 rounded-xl px-4 py-2.5 flex-wrap",children:[e.jsxs("button",{"data-loc":"client/src/pages/AiAgentConsole.tsx:721",onClick:()=>Ee(N.map(s=>s.id)),className:"flex items-center gap-1.5 text-sm text-amber-800 hover:text-amber-900 font-medium",children:[u.size===N.length?e.jsx(ce,{"data-loc":"client/src/pages/AiAgentConsole.tsx:726",className:"w-4 h-4"}):e.jsx(ie,{"data-loc":"client/src/pages/AiAgentConsole.tsx:727",className:"w-4 h-4"}),u.size===N.length?"Deselect all":"Select all"]}),u.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(le,{"data-loc":"client/src/pages/AiAgentConsole.tsx:732",orientation:"vertical",className:"h-4"}),e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:733",className:"text-xs text-amber-700",children:[u.size," selected"]}),e.jsxs(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:734",size:"sm",className:"gap-1.5 bg-emerald-600 text-white hover:bg-emerald-700 rounded-xl ml-auto",onClick:()=>F.mutate({ids:Array.from(u),decision:"approved"}),disabled:F.isPending,children:[e.jsx(xe,{"data-loc":"client/src/pages/AiAgentConsole.tsx:740",className:"w-3.5 h-3.5"}),"Approve ",u.size]}),e.jsxs(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:743",size:"sm",variant:"outline",className:"gap-1.5 border-red-300 text-red-700 hover:bg-red-50 rounded-xl",onClick:()=>F.mutate({ids:Array.from(u),decision:"rejected"}),disabled:F.isPending,children:[e.jsx(de,{"data-loc":"client/src/pages/AiAgentConsole.tsx:750",className:"w-3.5 h-3.5"}),"Reject ",u.size]})]}),u.size===0&&e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:756",className:"text-xs text-amber-700 ml-auto",children:[e.jsx("strong",{"data-loc":"client/src/pages/AiAgentConsole.tsx:757",children:N.length})," operation",N.length!==1?"s":""," need your review."]})]}),N.map(s=>{const d=we[s.operation]??{label:s.operation,icon:e.jsx(M,{"data-loc":"client/src/pages/AiAgentConsole.tsx:762",className:"w-3.5 h-3.5"}),color:"text-gray-600"},A=u.has(s.id);return e.jsx(v,{"data-loc":"client/src/pages/AiAgentConsole.tsx:765",className:x("border-amber-200 bg-amber-50/30 transition-all",A&&"ring-2 ring-indigo-400 border-indigo-300"),children:e.jsx(y,{"data-loc":"client/src/pages/AiAgentConsole.tsx:766",className:"p-4",children:e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:767",className:"flex items-start gap-3",children:[e.jsx("button",{"data-loc":"client/src/pages/AiAgentConsole.tsx:768",onClick:()=>Te(s.id),className:"mt-0.5 shrink-0",children:A?e.jsx(ce,{"data-loc":"client/src/pages/AiAgentConsole.tsx:770",className:"w-4 h-4 text-indigo-600"}):e.jsx(ie,{"data-loc":"client/src/pages/AiAgentConsole.tsx:771",className:"w-4 h-4 text-gray-400"})}),e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:773",className:x("mt-0.5",d.color),children:d.icon}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:774",className:"flex-1 min-w-0",children:[e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:775",className:x("font-medium text-sm",d.color),children:d.label}),s.aiReasoning&&e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:777",className:"text-sm text-gray-600 mt-1 leading-relaxed",children:s.aiReasoning}),s.errorMessage&&e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:780",className:"text-xs text-red-600 mt-1 font-mono bg-red-50 rounded p-2",children:s.errorMessage}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:782",className:"flex items-center gap-3 mt-2 flex-wrap",children:[s.hcpJobId&&e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:783",className:"text-xs text-blue-500 font-mono",children:["Job: ",s.hcpJobId]}),s.hcpCustomerId&&e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:784",className:"text-xs text-blue-400 font-mono",children:["Customer: ",s.hcpCustomerId]}),e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:785",className:"text-xs text-gray-400",children:new Date(s.createdAt).toLocaleStr
26ing()})]}),s.confidence!==null&&e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:788",className:"mt-2 max-w-[200px]",children:e.jsx(Se,{"data-loc":"client/src/pages/AiAgentConsole.tsx:789",value:s.confidence})})]}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:793",className:"shrink-0 flex gap-2",children:[e.jsxs(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:794",size:"sm",variant:"outline",className:"gap-1.5 border-emerald-300 text-emerald-700 hover:bg-emerald-50 rounded-xl",onClick:()=>ae(s.id,"approved"),disabled:G.isPending,children:[e.jsx(xe,{"data-loc":"client/src/pages/AiAgentConsole.tsx:801",className:"w-3.5 h-3.5"}),"Approve"]}),e.jsxs(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:804",size:"sm",variant:"outline",className:"gap-1.5 border-red-300 text-red-700 hover:bg-red-50 rounded-xl",onClick:()=>ae(s.id,"rejected"),disabled:G.isPending,children:[e.jsx(de,{"data-loc":"client/src/pages/AiAgentConsole.tsx:811",className:"w-3.5 h-3.5"}),"Reject"]})]})]})})},s.id)})]})}),e.jsxs(O,{"data-loc":"client/src/pages/AiAgentConsole.tsx:825",value:"sync",className:"mt-4 space-y-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:826",className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsx(v,{"data-loc":"client/src/pages/AiAgentConsole.tsx:827",className:"border-gray-100 shadow-sm",children:e.jsxs(y,{"data-loc":"client/src/pages/AiAgentConsole.tsx:828",className:"p-4",children:[e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:829",className:"text-xs text-gray-500 mb-1",children:"Last Global Sync"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:830",className:"font-bold text-gray-900 text-sm",children:P?.lastSyncAt?new Date(P.lastSyncAt).toLocaleString():"Never"})]})}),e.jsx(v,{"data-loc":"client/src/pages/AiAgentConsole.tsx:837",className:"border-gray-100 shadow-sm",children:e.jsxs(y,{"data-loc":"client/src/pages/AiAgentConsole.tsx:838",className:"p-4",children:[e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:839",className:"text-xs text-gray-500 mb-1",children:"Total Jobs Synced"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:840",className:"font-bold text-gray-900 text-2xl",children:(P?.totalSynced??0).toLocaleString()})]})}),e.jsx(v,{"data-loc":"client/src/pages/AiAgentConsole.tsx:843",className:"border-gray-100 shadow-sm",children:e.jsxs(y,{"data-loc":"client/src/pages/AiAgentConsole.tsx:844",className:"p-4",children:[e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:845",className:"text-xs text-gray-500 mb-1",children:"Agents with HCP Data"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:846",className:"font-bold text-gray-900 text-2xl",children:P?.agentCount??0})]})})]}),(P?.perAgent?.length??0)>0?e.jsxs(v,{"data-loc":"client/src/pages/AiAgentConsole.tsx:853",className:"border-gray-100 shadow-sm",children:[e.jsx(Fe,{"data-loc":"client/src/pages/AiAgentConsole.tsx:854",className:"pb-2 pt-4 px-4",children:e.jsx(Ue,{"data-loc":"client/src/pages/AiAgentConsole.tsx:855",className:"text-sm font-semibold text-gray-700",children:"Per-Agent Sync Breakdown"})}),e.jsx(y,{"data-loc":"client/src/pages/AiAgentConsole.tsx:857",className:"p-0",children:e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:858",className:"overflow-x-auto",children:e.jsxs("table",{"data-loc":"client/src/pages/AiAgentConsole.tsx:859",className:"w-full text-sm",children:[e.jsx("thead",{"data-loc":"client/src/pages/AiAgentConsole.tsx:860",children:e.jsxs("tr",{"data-loc":"client/src/pages/AiAgentConsole.tsx:861",className:"border-b border-gray-100 bg-gray-50",children:[e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:862",className:"text-left px-4 py-2 text-xs font-medium text-gray-500",children:"Agent"}),e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:863",className:"text-right px-4 py-2 text-xs font-medium text-gray-500",children:"Jobs"}),e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:864",className:"text-right px-4 py-2 text-xs font-medium text-gray-500",children:"Matched"}),e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:865",className:"text-right px-4 py-2 text-xs font-medium text-gray-500",children:"Match Rate"}),e.jsx("th",{"data-loc":"client/src/pages/AiAgentConsole.tsx:866",className:"text-right px-4 py-2 text-xs font-medium text-gray-500",children:"Last Sync"})]})}),e.jsx("tbody",{"data-loc":"client/src/pages/AiAgentConsole.tsx:869",children:P?.perAgent?.map(s=>e.jsxs("tr",{"data-loc":"client/src/pages/AiAgentConsole.tsx:871",className:"border-b border-gray-50 hover:bg-gray-50/50",children:[e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:872",className:"px-4 py-2.5 font-medium text-gray-900",children:s.agentName??`Agent #${s.agentId}`}),e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:873",className:"px-4 py-2.5 text-right text-gray-600",children:s.jobCount}),e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:874",className:"px-4 py-2.5 text-right text-emerald-600",children:s.matchedCount}),e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:875",className:"px-4 py-2.5 text-right",children:e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:876",className:x("text-xs font-medium px-1.5 py-0.5 rounded-full",s.jobCount>0&&s.matchedCount/s.jobCount>=.8?"bg-emerald-100 text-emerald-700":s.jobCount>0&&s.matchedCount/s.jobCount>=.5?"bg-amber-100 text-amber-700":"bg-red-100 text-red-700"),children:[s.jobCount>0?Math.round(s.matchedCount/s.jobCount*100):0,"%"]})}),e.jsx("td",{"data-loc":"client/src/pages/AiAgentConsole.tsx:887",className:"px-4 py-2.5 text-right text-xs text-gray-400",children:s.lastSync?new Date(s.lastSync).toLocaleDateString():"â"})]},s.agentId))})]})})})]}):e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:898",className:"py-16 text-center bg-white rounded-2xl border border-gray-100",children:[e.jsx(oe,{"data-loc":"client/src/pages/AiAgentConsole.tsx:899",className:"w-10 h-10 mx-auto text-gray-300 mb-3"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:900",className:"text-gray-500",children:"No sync data yet"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:901",className:"text-gray-400 text-sm mt-1",children:"Run an HCP sync to see per-agent breakdown."})]})]}),e.jsx(O,{"data-loc":"client/src/pages/AiAgentConsole.tsx:907",value:"invoices",className:"mt-4 space-y-4",children:e.jsx(is,{"data-loc":"client/src/pages/AiAgentConsole.tsx:908"})}),e.jsx(O,{"data-loc":"client/src/pages/AiAgentConsole.tsx:912",value:"history",className:"mt-4 space-y-3",children:ke?e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:914",className:"py-16 text-center",children:[e.jsx(U,{"data-loc":"client/src/pages/AiAgentConsole.tsx:915",className:"animate-spin w-6 h-6 mx-auto text-violet-500 mb-2"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:916",className:"text-sm text-gray-400",children:"Loading historyâ¦"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:920",className:"space-y-2",children:[(_?.items??[]).map(s=>e.jsx(ge,{"data-loc":"client/src/pages/AiAgentConsole.tsx:922",entry:s},s.id)),(_?.items??[]).length===0&&e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:925",className:"py-16 text-center bg-white rounded-2xl border border-gray-100",children:[e.jsx(M,{"data-loc":"client/src/pages/AiAgentConsole.tsx:926",className:"w-10 h-10 mx-auto text-gray-300 mb-3"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:927",className:"text-gray-500",children:"No history yet"})]})]}),(_?.total??0)>30&&e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:933",className:"flex items-center justify-between pt-2",children:[e.jsxs("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:934",className:"text-xs text-gray-400",children:["Showing ",C+1,"â",Math.min(C+30,_?.total??0)," of ",_?.total??0]}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:937",className:"flex gap-2",children:[e.jsx(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:938",variant:"outline",size:"sm",className:"rounded-xl",disabled:C===0,onClick:()=>ee(s=>Math.max(0,s-30)),children:"Previous"}),e.jsx(b,{"data-loc":"client/src/pages/AiAgentConsole.tsx:947",variant:"outline",size:"sm",className:"rounded-xl",disabled:C+30>=(_?.total??0),onClick:()=>ee(s=>s+30),children:"Next"})]})]})]})})]}),e.jsx(v,{"data-loc":"client/src/pages/AiAgentConsole.tsx:965",className:"border-violet-200 bg-gradient-to-r from-violet-50 to-indigo-50",children:e.jsx(y,{"data-loc":"client/src/pages/AiAgentConsole.tsx:966",className:"p-4",children:e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:967",className:"flex items-center gap-3",children:[e.jsx("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:968",className:"w-10 h-10 rounded-xl bg-gradient-to-br from-violet-500 to-indigo-600 flex items-center justify-center shrink-0",children:e.jsx(T,{"data-loc":"client/src/pages/AiAgentConsole.tsx:969",className:"w-5 h-5 text-white"})}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:971",className:"flex-1 min-w-0",children:[e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:972",className:"flex items-center gap-2",children:[e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:973",className:"font-semibold text-gray-900 text-sm",children:"Fast PICRAs AI Agent"}),e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:974",className:"flex items-center gap-1 text-xs text-emerald-600 font-medium",children:[e.jsxs("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:975",className:"relative flex h-2 w-2",children:[e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:976",className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{"data-loc":"client/src/pages/AiAgentConsole.tsx:977",className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]}),"Live"]})]}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:982",className:"text-xs text-gray-500 mt-0.5",children:"Monitors PICRA submissions · Syncs to Housecall Pro · Generates AI job descriptions · Deduplicates customers"})]}),e.jsxs("div",{"data-loc":"client/src/pages/AiAgentConsole.tsx:98
266",className:"shrink-0 text-right",children:[e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:987",className:"text-xs text-gray-500",children:"Operations today"}),e.jsx("p",{"data-loc":"client/src/pages/AiAgentConsole.tsx:988",className:"text-xl font-bold text-violet-700",children:I?.last24h??0})]})]})})})]})]})}export{Es 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.