vpschatbotwidget 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +385 -47
  2. package/dist-lib/types/App.d.ts +2 -0
  3. package/dist-lib/types/chatbot/api/chatbot-api.d.ts +25 -0
  4. package/dist-lib/types/chatbot/api/chatbot-types.d.ts +125 -0
  5. package/dist-lib/types/chatbot/chatbot.test.d.ts +1 -0
  6. package/dist-lib/types/chatbot/config/colors.d.ts +165 -0
  7. package/dist-lib/types/chatbot/config/suggestions.d.ts +3 -0
  8. package/dist-lib/types/chatbot/core/ChatContext.d.ts +28 -0
  9. package/dist-lib/types/chatbot/core/ChatEmptyState.d.ts +2 -0
  10. package/dist-lib/types/chatbot/core/ChatError.d.ts +7 -0
  11. package/dist-lib/types/chatbot/core/ChatHeader.d.ts +22 -0
  12. package/dist-lib/types/chatbot/core/ChatInput.d.ts +8 -0
  13. package/dist-lib/types/chatbot/core/ChatMarkdown.d.ts +4 -0
  14. package/dist-lib/types/chatbot/core/ChatMessage.d.ts +7 -0
  15. package/dist-lib/types/chatbot/core/ChatMessageList.d.ts +2 -0
  16. package/dist-lib/types/chatbot/core/ChatPanel.d.ts +14 -0
  17. package/dist-lib/types/chatbot/core/ChatProvider.d.ts +19 -0
  18. package/dist-lib/types/chatbot/core/ChatSuggestions.d.ts +11 -0
  19. package/dist-lib/types/chatbot/core/ChatTicketConfirmation.d.ts +2 -0
  20. package/dist-lib/types/chatbot/core/ChatTypingIndicator.d.ts +4 -0
  21. package/dist-lib/types/chatbot/core/ticket-intent.d.ts +2 -0
  22. package/dist-lib/types/chatbot/embedded/EmbeddedChatbot.d.ts +27 -0
  23. package/dist-lib/types/chatbot/embedded/EmbeddedChatbotPanel.d.ts +12 -0
  24. package/dist-lib/types/chatbot/embedded/EmbeddedChatbotTrigger.d.ts +6 -0
  25. package/dist-lib/types/chatbot/hooks/useChatbot.d.ts +1 -0
  26. package/dist-lib/types/chatbot/index.d.ts +10 -0
  27. package/dist-lib/types/chatbot/widget/ChatbotWidget.d.ts +26 -0
  28. package/dist-lib/types/chatbot/widget/ChatbotWidgetPanel.d.ts +10 -0
  29. package/dist-lib/types/chatbot/widget/ChatbotWidgetTrigger.d.ts +7 -0
  30. package/dist-lib/types/components/AgentSummaryCard.d.ts +8 -0
  31. package/dist-lib/types/components/ChatHeader.d.ts +20 -0
  32. package/dist-lib/types/components/ChatInput.d.ts +9 -0
  33. package/dist-lib/types/components/ChatWidget.d.ts +14 -0
  34. package/dist-lib/types/components/ConnectingStatus.d.ts +6 -0
  35. package/dist-lib/types/components/EnvBadge.d.ts +31 -0
  36. package/dist-lib/types/components/FeedbackRatingCard.d.ts +7 -0
  37. package/dist-lib/types/components/MessageItem.d.ts +12 -0
  38. package/dist-lib/types/components/MessageList.d.ts +21 -0
  39. package/dist-lib/types/components/OrderTrackingCard.d.ts +13 -0
  40. package/dist-lib/types/components/QuickPrompts.d.ts +11 -0
  41. package/dist-lib/types/components/ResponseIconMapper.d.ts +26 -0
  42. package/dist-lib/types/components/SourceCitations.d.ts +7 -0
  43. package/dist-lib/types/components/ToolCallBadge.d.ts +7 -0
  44. package/dist-lib/types/components/TypingProgressBar.d.ts +21 -0
  45. package/dist-lib/types/components/ui/message-scroller.d.ts +9 -0
  46. package/dist-lib/types/lib/cn.d.ts +1 -0
  47. package/dist-lib/types/lib/gibberishDetector.d.ts +26 -0
  48. package/dist-lib/types/lib/textHighlighter.d.ts +15 -0
  49. package/dist-lib/types/main.d.ts +1 -0
  50. package/dist-lib/types/services/api.d.ts +12 -0
  51. package/dist-lib/types/test/message-scroller-stub.d.ts +36 -0
  52. package/dist-lib/types/test/setup.d.ts +1 -0
  53. package/dist-lib/types/types/chat.d.ts +59 -0
  54. package/dist-lib/vps-chatbot.cjs +101 -0
  55. package/dist-lib/vps-chatbot.js +2179 -0
  56. package/package.json +30 -3
  57. package/src/chatbot/chatbot.test.tsx +87 -0
  58. package/src/chatbot/core/ChatContext.tsx +6 -0
  59. package/src/chatbot/core/ChatProvider.tsx +29 -7
  60. package/src/chatbot/embedded/EmbeddedChatbot.tsx +63 -2
  61. package/src/chatbot/index.ts +25 -5
  62. package/src/chatbot/widget/ChatbotWidget.tsx +64 -2
  63. package/Chatbot.svg +0 -1
  64. package/dist/assets/index-C0fUDi2s.css +0 -1
  65. package/dist/assets/index-foGq5_Av.js +0 -159
  66. package/dist/index.html +0 -17
  67. package/index.html +0 -16
  68. package/src/App.tsx +0 -85
  69. package/src/main.tsx +0 -10
  70. package/src/services/api.ts +0 -74
  71. package/src/test/message-scroller-stub.tsx +0 -60
  72. package/src/test/setup.ts +0 -8
  73. package/src/vite-env.d.ts +0 -14
  74. package/tsconfig.json +0 -21
  75. package/vite.config.ts +0 -28
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { ToolCall } from "../types/chat";
3
+ interface ToolCallBadgeProps {
4
+ toolCalls?: ToolCall[];
5
+ }
6
+ export declare const ToolCallBadge: React.FC<ToolCallBadgeProps>;
7
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * TypingProgressBar.tsx
3
+ *
4
+ * A slim, bottom-anchored animated progress strip that is shown while the
5
+ * AI is generating a response. It cycles through contextual phase labels
6
+ * with a fade-in → hold → fade-out rhythm so the user always knows the
7
+ * system is actively working.
8
+ *
9
+ * Features
10
+ * ─────────
11
+ * • Smooth shimmer fill bar (CSS animation)
12
+ * • Rotating phase labels that fade in/out every 2.2 s
13
+ * • Dynamic icon from lucide-react that matches the current phase
14
+ * • Mounts with a slide-up animation, unmounts with slide-down
15
+ */
16
+ import React from "react";
17
+ interface TypingProgressBarProps {
18
+ isVisible: boolean;
19
+ }
20
+ export declare const TypingProgressBar: React.FC<TypingProgressBarProps>;
21
+ export {};
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ import { MessageScroller as MessageScrollerPrimitive, useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVisibility } from "@shadcn/react/message-scroller";
3
+ declare function MessageScrollerProvider(props: React.ComponentProps<typeof MessageScrollerPrimitive.Provider>): React.JSX.Element;
4
+ declare function MessageScroller({ className, ...props }: React.ComponentProps<typeof MessageScrollerPrimitive.Root>): React.JSX.Element;
5
+ declare function MessageScrollerViewport({ className, ...props }: React.ComponentProps<typeof MessageScrollerPrimitive.Viewport>): React.JSX.Element;
6
+ declare function MessageScrollerContent({ className, ...props }: React.ComponentProps<typeof MessageScrollerPrimitive.Content>): React.JSX.Element;
7
+ declare function MessageScrollerItem({ className, scrollAnchor, ...props }: React.ComponentProps<typeof MessageScrollerPrimitive.Item>): React.JSX.Element;
8
+ declare function MessageScrollerButton({ direction, className, children, ...props }: React.ComponentProps<typeof MessageScrollerPrimitive.Button>): React.JSX.Element;
9
+ export { MessageScrollerProvider, MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, useMessageScroller, useMessageScrollerScrollable, useMessageScrollerVisibility, };
@@ -0,0 +1 @@
1
+ export declare function cn(...inputs: Array<string | false | null | undefined>): string;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * gibberishDetector.ts
3
+ *
4
+ * Detects unreadable / gibberish / random text that is not worth
5
+ * sending to the AI backend (saves LLM tokens).
6
+ *
7
+ * Strategy:
8
+ * 1. Entropy check – high Shannon entropy → likely random chars
9
+ * 2. Consonant-cluster ratio – too many consecutive consonants → not human words
10
+ * 3. No-vowel ratio – excessive sequences with no vowels
11
+ * 4. Keyboard-smash patterns – e.g. "asdfgh", "qwerty" runs
12
+ * 5. Minimum meaningful length – ignore very short strings (handled upstream)
13
+ *
14
+ * Returns { isGibberish: boolean, reason: string }
15
+ */
16
+ export interface GibberishResult {
17
+ isGibberish: boolean;
18
+ reason: string;
19
+ }
20
+ /**
21
+ * Main export.
22
+ *
23
+ * @param input Raw user-typed string
24
+ * @returns { isGibberish, reason }
25
+ */
26
+ export declare function detectGibberish(input: string): GibberishResult;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * textHighlighter.tsx
3
+ *
4
+ * Dynamically highlights:
5
+ * - Double-quoted strings "..." → amber/yellow
6
+ * - Single-quoted strings '...' → sky/blue
7
+ * - ISO dates & human-readable dates 2026-09-11 / Sep 11, 2026 → green
8
+ * - Times 14:41:29 / 2:30 PM → purple
9
+ * - URLs / links https://... → platform-aware badge (LinkedIn, YouTube, etc.)
10
+ *
11
+ * Usage:
12
+ * renderHighlightedText("Check ticket 'TCK-1001' created on 2026-09-11")
13
+ */
14
+ import React from "react";
15
+ export declare function renderHighlightedText(text: string): React.ReactNode;
@@ -0,0 +1 @@
1
+ import "./index.css";
@@ -0,0 +1,12 @@
1
+ import { ChatApiResponse, Message } from "../types/chat";
2
+ export declare class ChatService {
3
+ static setBaseUrl(url: string): void;
4
+ static getBaseUrl(): string;
5
+ static createSession(): Promise<string>;
6
+ static sendMessage(sessionId: string, message: string): Promise<ChatApiResponse>;
7
+ static getHistory(sessionId: string): Promise<Message[]>;
8
+ static closeSession(sessionId: string): Promise<void>;
9
+ static checkHealth(): Promise<boolean>;
10
+ static getCustomers(): Promise<any[]>;
11
+ static getTickets(): Promise<any[]>;
12
+ }
@@ -0,0 +1,36 @@
1
+ import React, { type ReactNode } from "react";
2
+ type Props = {
3
+ children?: ReactNode;
4
+ className?: string;
5
+ "aria-label"?: string;
6
+ "aria-busy"?: boolean;
7
+ messageId?: string;
8
+ scrollAnchor?: boolean;
9
+ autoScroll?: boolean;
10
+ defaultScrollPosition?: string;
11
+ scrollPreviousItemPeek?: number;
12
+ direction?: string;
13
+ };
14
+ declare function PassThrough({ children, className, ...props }: Props): React.JSX.Element;
15
+ export declare const MessageScroller: {
16
+ Provider: typeof PassThrough;
17
+ Root: typeof PassThrough;
18
+ Viewport: typeof PassThrough;
19
+ Content: typeof PassThrough;
20
+ Item: typeof PassThrough;
21
+ Button: ({ children, className, ...props }: Props) => React.JSX.Element;
22
+ };
23
+ export declare function useMessageScroller(): {
24
+ scrollToEnd: () => boolean;
25
+ scrollToMessage: () => boolean;
26
+ scrollToStart: () => boolean;
27
+ };
28
+ export declare function useMessageScrollerScrollable(): {
29
+ start: boolean;
30
+ end: boolean;
31
+ };
32
+ export declare function useMessageScrollerVisibility(): {
33
+ currentAnchorId: null;
34
+ visibleMessageIds: string[];
35
+ };
36
+ export {};
@@ -0,0 +1 @@
1
+ import "@testing-library/jest-dom/vitest";
@@ -0,0 +1,59 @@
1
+ export interface Source {
2
+ chunk_id: string;
3
+ source: string;
4
+ score: number;
5
+ }
6
+ export interface ToolCall {
7
+ tool_name: string;
8
+ arguments: Record<string, any>;
9
+ result: Record<string, any>;
10
+ }
11
+ export interface TokenUsage {
12
+ model: string;
13
+ prompt_tokens: number;
14
+ completion_tokens: number;
15
+ total_tokens: number;
16
+ }
17
+ export interface Message {
18
+ id: string;
19
+ role: "user" | "assistant" | "system";
20
+ content: string;
21
+ timestamp: string;
22
+ sources?: Source[];
23
+ tool_calls?: ToolCall[];
24
+ usage?: TokenUsage;
25
+ error?: boolean;
26
+ }
27
+ export interface Customer {
28
+ customer_id: string;
29
+ name: string;
30
+ company: string;
31
+ email: string;
32
+ phone?: string | null;
33
+ plan: string;
34
+ vessels_count: number;
35
+ transformers_count: number;
36
+ }
37
+ export interface Ticket {
38
+ ticket_id: string;
39
+ customer_id: string;
40
+ customer_email: string;
41
+ subject: string;
42
+ description: string;
43
+ priority: "low" | "medium" | "high" | "urgent" | string;
44
+ status: "open" | "in_progress" | "resolved" | "closed" | string;
45
+ created_at: string;
46
+ updated_at: string;
47
+ }
48
+ export interface SessionResponse {
49
+ session_id: string;
50
+ created_at: string;
51
+ }
52
+ export interface ChatApiResponse {
53
+ request_id: string;
54
+ session_id: string;
55
+ answer: string;
56
+ sources: Source[];
57
+ tool_calls: ToolCall[];
58
+ usage: TokenUsage;
59
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),b=require("react");var me=typeof document<"u"?document.currentScript:null;function ft(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const c=ft(b),pt={};function K(e){if(e!=null&&e.trim()!=="")return e.trim().replace(/\/+$/,"");const t=(typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:me&&me.tagName.toUpperCase()==="SCRIPT"&&me.src||new URL("vps-chatbot.cjs",document.baseURI).href}<"u"&&pt,"");return String(t).trim().replace(/\/+$/,"")}function xe(e,t){const r=K(e);if(!r)return t;if(r.endsWith("/api")&&t.startsWith("/api/"))return`${r}${t.slice(4)}`;if(r.endsWith("/api")&&t==="/health"){const o=r.slice(0,-4);return o?`${o}/health`:"/health"}const n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}function ht(e){return e&&typeof e=="object"&&"data"in e&&e.success!==!1?e.data:e}function mt(e,t,r){var l,a,i;const n=e,o=(l=n==null?void 0:n.error)==null?void 0:l.message;return o&&!gt(o)?{code:(a=n==null?void 0:n.error)==null?void 0:a.code,message:o,requestId:(i=n==null?void 0:n.error)==null?void 0:i.request_id}:r>=500?{message:"I couldn't process that request right now."}:r===0?{message:"Something went wrong while connecting. Please try again."}:{message:t}}function gt(e){return/traceback|sql|exception|stack|api[_ ]?key|password/i.test(e)}function bt(e){return{chunkId:e.chunk_id,source:e.source,score:e.score}}function xt(e){return{toolName:e.tool_name,arguments:e.arguments??{},result:e.result??{}}}function vt(e){return{model:e.model,promptTokens:e.prompt_tokens,completionTokens:e.completion_tokens,totalTokens:e.total_tokens}}function yt(e){const t=e.role==="user"||e.role==="system"?e.role:"assistant";return{id:String(e.id),role:t,content:e.content,createdAt:e.created_at||new Date().toISOString(),status:"complete",usage:e.model?{model:e.model,promptTokens:e.prompt_tokens||0,completionTokens:e.completion_tokens||0,totalTokens:(e.prompt_tokens||0)+(e.completion_tokens||0)}:void 0}}async function _t(e){const t=await e.text();if(!t)return{};try{return JSON.parse(t)}catch{return{}}}function _e(e){const t=K(e);async function r(n,o){let l;const a=xe(t,n);try{l=await fetch(a,{...o,headers:{"Content-Type":"application/json",...(o==null?void 0:o.headers)??{}}})}catch{throw{message:"Something went wrong while connecting. Please try again."}}if(l.status===204)return;const i=await _t(l);if(!l.ok)throw mt(i,"I couldn't process that request right now.",l.status);return ht(i)}return{apiBaseUrl:t,async createSession(){const n=await r("/api/v1/sessions",{method:"POST",body:JSON.stringify({})});return{sessionId:n.session_id,createdAt:n.created_at}},async sendMessage(n,o){const l=await r(`/api/v1/sessions/${n}/messages`,{method:"POST",body:JSON.stringify({message:o})});return{requestId:l.request_id,sessionId:l.session_id,answer:l.answer,sources:(l.sources||[]).map(bt),toolCalls:(l.tool_calls||[]).map(xt),usage:vt(l.usage)}},async getHistory(n){try{return((await r(`/api/v1/sessions/${n}/messages`)).messages||[]).map(yt)}catch{return[]}},async closeSession(n){try{await r(`/api/v1/sessions/${n}`,{method:"DELETE"})}catch{}},async createTicket(){throw new Error("Ticket creation has been removed.")},async checkHealth(){try{const n=xe(t,"/health");return(await fetch(n)).ok}catch{return!1}}}}const wt=_e(),Ct=[{label:"How do I access my reports?",query:"How do I access my reports in the VPS Customer Portal?"},{label:"Where can I find sample status?",query:"Where can I find my sample status?"},{label:"How do I pre-register a sample?",query:"How do I pre-register a sample in the portal?"},{label:"How do I contact VPS Support?",query:"How can I contact VPS Customer Support?"}],we=b.createContext(null);function Je(){const e=b.useContext(we);if(!e)throw new Error("useChatbot must be used inside ChatProvider.");return e}function Ce(){return b.useContext(we)}function Ge(e){return`${e}-${crypto.randomUUID()}`}function St(e){if(e&&typeof e=="object"&&"message"in e){const t=String(e.message);if(t&&!/traceback|sql|exception|stack|api[_ ]?key|password/i.test(t))return t}return"I couldn't process that request right now."}const Se=({children:e,userContext:t={},suggestions:r=Ct,disableSuggestions:n=!1,initialMessage:o,apiBaseUrl:l,apiUrl:a,proxyUrl:i,api:d})=>{const p=l??a??i,m=b.useMemo(()=>d??_e(p),[d,p]),[y,f]=b.useState(null),[u,g]=b.useState([]),[F,v]=b.useState("idle"),[A,V]=b.useState(null),P=b.useRef(null),U=b.useRef(!1),I=b.useCallback(async()=>{if(y)return y;v("connecting");const _=await m.createSession();return f(_.sessionId),_.sessionId},[y,m]),D=b.useCallback(async _=>{P.current=_;const S={id:Ge("user"),role:"user",content:_,createdAt:new Date().toISOString(),status:"complete"},k=Ge("asst"),T={id:k,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"pending"};g(R=>[...R,S,T]),v("awaiting"),V(null);try{const R=await I(),j=await m.sendMessage(R,_);g(W=>W.map(z=>z.id===k?{...z,id:j.requestId||k,content:j.answer,status:"complete",sources:j.sources,toolCalls:j.toolCalls,usage:j.usage}:z)),v("idle")}catch(R){const j=St(R);g(W=>W.map(z=>z.id===k?{...z,content:j,status:"error"}:z)),V(j),v("error")}},[I,m]),E=b.useCallback(async _=>{const S=_.trim();!S||F==="awaiting"||F==="connecting"||await D(S)},[D,F]),L=b.useCallback(async()=>{const _=P.current;_&&(g(S=>S.filter(k=>k.status!=="error")),await D(_))},[D]),M=b.useCallback(async()=>{},[]),Z=b.useCallback(()=>{},[]),$=b.useCallback(async()=>{y&&await m.closeSession(y),f(null),g([]),v("idle"),V(null),P.current=null},[y,m]);b.useEffect(()=>{!o||U.current||(U.current=!0,E(o))},[o,E]);const x=b.useMemo(()=>({messages:u,status:F,error:A,sessionId:y,pendingTicket:null,ticketBusy:!1,lastTicket:null,suggestions:r,showSuggestions:!n&&u.length===0,suggestionBadgesEnabled:!n,userContext:t,apiBaseUrl:m.apiBaseUrl,sendMessage:E,retryLast:L,confirmTicket:M,cancelTicket:Z,resetConversation:$}),[u,F,A,y,r,n,t,m.apiBaseUrl,E,L,M,Z,$]);return s.jsx(we.Provider,{value:x,children:e})};function ne(){return Je()}const kt=({message:e,onRetry:t})=>s.jsxs("div",{className:"mx-4 mb-2 rounded-lg border border-[var(--error-border)] bg-[var(--error-bg)] px-3 py-2 text-[12.5px] text-[var(--error-text)]",role:"alert",children:[s.jsx("p",{children:e}),t&&s.jsx("button",{type:"button",onClick:t,className:"mt-1.5 text-[12px] font-semibold underline underline-offset-2",children:"Try again"})]});/**
2
+ * @license lucide-react v0.468.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 jt=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ke=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim();/**
7
+ * @license lucide-react v0.468.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
+ */var Ft={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
12
+ * @license lucide-react v0.468.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 Et=b.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:o="",children:l,iconNode:a,...i},d)=>b.createElement("svg",{ref:d,...Ft,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Ke("lucide",o),...i},[...a.map(([p,m])=>b.createElement(p,m)),...Array.isArray(l)?l:[l]]));/**
17
+ * @license lucide-react v0.468.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 O=(e,t)=>{const r=b.forwardRef(({className:n,...o},l)=>b.createElement(Et,{ref:l,iconNode:t,className:Ke(`lucide-${jt(e)}`,n),...o}));return r.displayName=`${e}`,r};/**
22
+ * @license lucide-react v0.468.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 Rt=O("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const Tt=O("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const At=O("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const Xe=O("BotMessageSquare",[["path",{d:"M12 6V2H8",key:"1155em"}],["path",{d:"m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z",key:"w2lp3e"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M9 11v2",key:"1ueba0"}],["path",{d:"M15 11v2",key:"i11awn"}],["path",{d:"M20 12h2",key:"1q8mjw"}]]);/**
42
+ * @license lucide-react v0.468.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const Bt=O("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
47
+ * @license lucide-react v0.468.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const Dt=O("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
52
+ * @license lucide-react v0.468.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const Mt=O("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
57
+ * @license lucide-react v0.468.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const It=O("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/**
62
+ * @license lucide-react v0.468.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const Nt=O("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
67
+ * @license lucide-react v0.468.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const Pt=O("FlaskConical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);/**
72
+ * @license lucide-react v0.468.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const Qe=O("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
77
+ * @license lucide-react v0.468.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */const Lt=O("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/**
82
+ * @license lucide-react v0.468.0 - ISC
83
+ *
84
+ * This source code is licensed under the ISC license.
85
+ * See the LICENSE file in the root directory of this source tree.
86
+ */const Ot=O("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
87
+ * @license lucide-react v0.468.0 - ISC
88
+ *
89
+ * This source code is licensed under the ISC license.
90
+ * See the LICENSE file in the root directory of this source tree.
91
+ */const zt=O("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
92
+ * @license lucide-react v0.468.0 - ISC
93
+ *
94
+ * This source code is licensed under the ISC license.
95
+ * See the LICENSE file in the root directory of this source tree.
96
+ */const qt=O("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);/**
97
+ * @license lucide-react v0.468.0 - ISC
98
+ *
99
+ * This source code is licensed under the ISC license.
100
+ * See the LICENSE file in the root directory of this source tree.
101
+ */const Ht=O("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Gt={alpha:{label:"Alpha",Icon:Pt,variant:"env-badge--alpha",tooltip:"Alpha build — internal testing only"},beta:{label:"Beta",Icon:qt,variant:"env-badge--beta",tooltip:"Beta build — public pre-release"},gamma:{label:"Gamma",Icon:Lt,variant:"env-badge--gamma",tooltip:"Gamma / Release Candidate"},qa:{label:"QA",Icon:It,variant:"env-badge--qa",tooltip:"Quality Assurance build"}},Vt=({stage:e,pulse:t=!0,className:r=""})=>{if(!e)return null;const{label:n,Icon:o,variant:l,tooltip:a}=Gt[e];return s.jsxs("span",{className:`env-badge ${l} ${r} text-[var(--vps-orange)] font-medium text-[10px] leading-[12px] px-1.5 py-0.5 rounded-full border border-[var(--border)] bg-[var(--orange-50)] hover:bg-[var(--grey-200)] cursor-pointer hover:text-foreground flex items-center gap-1 `,title:a,"aria-label":`${n} build`,role:"status",children:[s.jsx(o,{size:10,className:"env-badge-icon","aria-hidden":"true"}),s.jsx("span",{className:"text-[var(--text-primary)] font-medium text-[10px] leading-[12px]",children:n})]})},Wt=e=>s.jsx("svg",{width:e.width||"24px",height:e.height||"24px",viewBox:"0 0 24 24",role:"img",xmlns:"http://www.w3.org/2000/svg",fill:e.Color||"currentColor",...e,children:s.jsx("path",{d:"M11.999 0c-2.25 0-4.5.06-6.6.21a5.57 5.57 0 0 0-5.19 5.1c-.24 3.21-.27 6.39-.06 9.6a5.644 5.644 0 0 0 5.7 5.19h3.15v-3.9h-3.15c-.93.03-1.74-.63-1.83-1.56-.18-3-.15-6 .06-9 .06-.84.72-1.47 1.56-1.53 2.04-.15 4.2-.21 6.36-.21s4.32.09 6.36.18c.81.06 1.5.69 1.56 1.53.24 3 .24 6 .06 9-.12.93-.9 1.62-1.83 1.59h-3.15l-6 3.9V24l6-3.9h3.15c2.97.03 5.46-2.25 5.7-5.19.21-3.18.18-6.39-.03-9.57a5.57 5.57 0 0 0-5.19-5.1c-2.13-.18-4.38-.24-6.63-.24zm-5.04 8.76c-.36 0-.66.3-.66.66v2.34c0 .33.18.63.48.78 1.62.78 3.42 1.2 5.22 1.26 1.8-.06 3.6-.48 5.22-1.26.3-.15.48-.45.48-.78V9.42c0-.09-.03-.15-.09-.21a.648.648 0 0 0-.87-.36c-1.5.66-3.12 1.02-4.77 1.05-1.65-.03-3.27-.42-4.77-1.08a.566.566 0 0 0-.24-.06z"})}),Ut=({title:e="VPS AI Assistant",subtitle:t="Customer portal support",onClose:r,onReset:n,onBack:o,showMinimize:l=!1,envStage:a,envPulse:i=!0})=>s.jsxs("header",{className:"flex items-center justify-between border-b border-border bg-card px-5 py-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[o&&s.jsx("button",{type:"button",onClick:o,className:"flex h-8 w-8 items-center justify-center rounded-full border border-border bg-muted text-muted-foreground hover:bg-[var(--grey-100)]","aria-label":"Back",children:s.jsx(Tt,{size:16})}),s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-primary text-primary-foreground","aria-hidden":"true",children:s.jsx(Wt,{width:"16px",height:"16px",Color:"white"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("h2",{className:"text-[16px] font-bold tracking-tight text-foreground",children:e}),s.jsx(Vt,{stage:a,pulse:i})]}),s.jsx("p",{className:"text-[12px] text-muted-foreground font-medium text-[var(--text-subtle)]",children:t||"Customer portal support"})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[n&&s.jsx("button",{type:"button",onClick:n,className:"flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-subtle)] hover:bg-muted hover:text-foreground","aria-label":"Start a new conversation",title:"New conversation",children:s.jsx(zt,{size:15})}),r&&s.jsx("button",{type:"button",onClick:r,className:"flex h-7 w-7 items-center justify-center rounded-md text-[var(--text-subtle)] hover:bg-muted hover:text-foreground","aria-label":l?"Minimize chat":"Close chat",children:s.jsx(Ot,{size:16})})]})]});function $t(e,t){const r=b.useRef(e);b.useEffect(()=>{var n;r.current&&!e&&((n=t.current)==null||n.focus()),r.current=e},[e,t])}function et(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(r=et(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Yt(){for(var e,t,r=0,n="",o=arguments.length;r<o;r++)(e=arguments[r])&&(t=et(e))&&(n&&(n+=" "),n+=t);return n}function G(...e){return Yt(e)}function Zt(e,t){const r=t.trim().toLowerCase();return r?e.filter(n=>n.label.toLowerCase().includes(r)||n.query.toLowerCase().includes(r)):e}const Jt=({suggestions:e,onSelect:t,disabled:r,variant:n="list"})=>e.length?n==="badge"?s.jsx("ul",{className:"mb-2 flex flex-wrap gap-1.5","aria-label":"Suggested questions",children:e.map(o=>s.jsx("li",{className:"max-w-full",children:s.jsx("button",{type:"button",disabled:r,onClick:()=>t(o),title:o.query,className:G("max-w-full truncate rounded-full border border-border bg-card px-2.5 py-1 text-left text-[11.5px] font-semibold text-foreground","hover:border-primary hover:bg-[var(--tint-solus-10)] hover:text-primary","disabled:cursor-not-allowed disabled:opacity-50"),children:o.label})},o.query))}):s.jsx("div",{className:"mt-3 flex flex-col gap-2",children:e.map(o=>s.jsx("button",{type:"button",disabled:r,onClick:()=>t(o),className:"rounded-lg border border-border bg-card px-3.5 py-2.5 text-left text-[13px] font-semibold text-foreground shadow-[0_1px_3px_rgba(0,0,0,0.02)] transition hover:-translate-y-px hover:border-vps-light-grey hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none motion-reduce:hover:translate-y-0",children:o.label},o.query))}):null,Kt=({onSend:e,disabled:t=!1,placeholder:r="Ask something…"})=>{const{suggestions:n,showSuggestions:o,suggestionBadgesEnabled:l}=ne(),[a,i]=b.useState(""),d=b.useRef(null),p=u=>{u&&(u.style.height="auto",u.style.height=`${Math.min(u.scrollHeight,96)}px`)};$t(t,d),b.useEffect(()=>{p(d.current)},[a]);const m=b.useMemo(()=>{if(!l||t)return[];const u=a.trim();return u?Zt(n,u):o?n:[]},[t,o,l,n,a]),y=u=>{i(u.query);const g=d.current;g==null||g.focus()},f=()=>{const u=a.trim();!u||t||(e(u),i(""),d.current&&(d.current.style.height="auto"))};return s.jsxs("div",{className:"bg-card px-4 pb-3 pt-2",children:[s.jsx(Jt,{variant:"badge",suggestions:m,onSelect:y,disabled:t}),s.jsx("label",{htmlFor:"vps-chat-input",className:"sr-only",children:"Chat message"}),s.jsxs("div",{className:"flex items-end gap-2 rounded-xl bg-[var(--input-bg)] px-2.5 py-1.5",children:[s.jsx("textarea",{id:"vps-chat-input",ref:d,rows:1,value:a,disabled:t,placeholder:r,onChange:u=>{i(u.target.value),p(u.target)},onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),f())},className:"max-h-24 flex-1 resize-none bg-transparent py-1.5 text-[13.5px] text-foreground outline-none placeholder:text-[var(--text-subtle)] disabled:opacity-60"}),s.jsx("button",{type:"button",onClick:f,disabled:t||!a.trim(),"aria-label":"Send message",className:"mb-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-action text-action-foreground hover:bg-[var(--action-hover)] disabled:cursor-not-allowed disabled:opacity-40",children:s.jsx(At,{size:16})})]}),s.jsxs("p",{className:"mt-2 text-center text-[11px] font-medium text-[var(--text-subtle)]",children:["Powered by ",s.jsx("span",{className:"text-primary font-bold hover:underline cursor-pointer",children:"VPS Veritas AI"})]})]})};function Xt({defaultTagName:e,props:t,render:r,state:n={},stateAttributesMapping:o}){let l=ve(Qt(n,o),t);if(!r)return c.createElement(e,l);if(typeof r=="function")return r(l,n);if(!c.isValidElement(r))return null;let a=r.props,i={...ve(l,a),ref:se(l.ref,a.ref)};return c.cloneElement(r,i)}function ve(...e){let t={};for(let r of e){if(!r)continue;let n=r;for(let o of Object.keys(n)){let l=n[o];if(l===void 0)continue;let a=t[o];o==="className"?t[o]=[a,l].filter(Boolean).join(" "):o==="style"?t[o]={...a,...l}:o==="ref"?t[o]=se(a,l):tr(o)&&typeof a=="function"&&typeof l=="function"?t[o]=er(l,a):t[o]=l}}return t}function Qt(e,t){var n;let r={};for(let o of Object.keys(e)){let l=e[o],a=(n=t==null?void 0:t[o])==null?void 0:n.call(t,l);if(a){Object.assign(r,a);continue}if(o==="slot"){r["data-slot"]=l;continue}let i=`data-${String(o).replace(/[A-Z]/g,d=>`-${d.toLowerCase()}`)}`;typeof l=="boolean"?r[i]=l?"":void 0:l!=null&&(r[i]=String(l))}return r}function er(e,t){return function(r){e(r),r.defaultPrevented||t(r)}}function tr(e){return/^on[A-Z]/.test(e)}function se(...e){let t=e.filter(Boolean);if(t.length!==0)return r=>{for(let n of t)typeof n=="function"?n(r):n&&(n.current=r)}}var rr=8,nr=64,sr=0,pe=.5,or=180,lr=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),tt={start:!1,end:!1},ar=[],he={currentAnchorId:null,visibleMessageIds:ar};function ir({content:e,scrollEdgeThreshold:t,spacer:r,viewport:n}){if(!n||!e)return tt;let o=ke({content:e,spacer:r,viewport:n});return{start:n.scrollTop>t,end:o-n.scrollTop-n.clientHeight>t}}function cr({content:e,scrollMargin:t,scrollPreviousItemPeek:r,spacer:n,viewport:o,visibleMessageIds:l}){if(!e||!o)return he;let a=o.getBoundingClientRect(),i=a.top+t+r,d=typeof IntersectionObserver>"u",p=[],m=null;for(let y of re(e,n)){let f=y.dataset.messageId;if(!f)continue;let u=y.dataset.scrollAnchor==="true",g=u||d?y.getBoundingClientRect():null;(d&&g?g.bottom>i&&g.top<a.bottom:l.has(f))&&p.push(f),u&&g&&g.top<=i+pe&&(m=f)}return p.length===0&&m===null?he:{currentAnchorId:m,visibleMessageIds:p}}function re(e,t){return Array.from(e.children).filter(r=>r instanceof HTMLElement&&r!==t)}function ur(e,t){for(let r=t;r<e.length;r++){let n=e[r];if((n==null?void 0:n.dataset.scrollAnchor)==="true")return n}return null}function dr(e,t){for(let r of e)if(r.dataset.scrollAnchor==="true"&&!t.has(r))return r;return null}function fr(e,t){var n;let r=0;for(let o=t;o<e.length;o++)if(((n=e[o])==null?void 0:n.dataset.scrollAnchor)==="true"&&(r+=1,r>1))return!0;return!1}function pr(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if((r==null?void 0:r.dataset.scrollAnchor)==="true")return r}return null}function hr({content:e,spacer:t,viewport:r}){let n=r.getBoundingClientRect();for(let o of re(e,t)){if(!o.dataset.messageId)continue;let l=o.getBoundingClientRect();if(l.bottom>n.top&&l.top<n.bottom)return o}return null}function mr({align:e,element:t,scrollMargin:r,spacer:n,viewport:o}){let l=rt(t,o),a=t.getBoundingClientRect().height,i=xr(n);if(e==="center"){let d=Math.max(0,o.clientHeight-i.start-i.end);return l-i.start-(d-a)/2-r}if(e==="end")return l-o.clientHeight+a+i.end+r;if(e==="nearest"){let d=l+a,p=o.scrollTop+i.start,m=o.scrollTop+o.clientHeight-i.end;return l>=p&&d<=m?o.scrollTop:l<p?l-i.start-r:d-o.clientHeight+i.end+r}return l-i.start-r}function rt(e,t){let r=e.getBoundingClientRect(),n=t.getBoundingClientRect();return r.top-n.top+t.scrollTop}function de(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function gr({content:e,scrollTop:t,spacer:r,viewport:n}){let o=ke({content:e,spacer:r,viewport:n});return t+n.clientHeight-o}function ke({content:e,spacer:t,viewport:r}){let n=re(e,t),o=nt(e),l=r.getBoundingClientRect(),a=r.scrollTop,i=o.start+o.end;for(let d of n){let p=d.getBoundingClientRect();i=Math.max(i,p.bottom-l.top+a+o.end)}return i}function br(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function nt(e){let t=window.getComputedStyle(e);return{end:ye(t.paddingBlockEnd||t.paddingBottom),start:ye(t.paddingBlockStart||t.paddingTop)}}function xr(e){let t=e==null?void 0:e.parentElement;return t?nt(t):{end:0,start:0}}function vr(e){if(!e)return 0;let t=window.getComputedStyle(e),r=t.rowGap==="normal"?t.gap:t.rowGap;return ye(r)}function ye(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function st(e,t){let r=e,n=new Set;return{getSnapshot:()=>r,hasListeners:()=>n.size>0,setSnapshot:o=>{t(r,o)||(r=o,n.forEach(l=>l()))},subscribe:(o,l,a)=>{let i=n.size===0;return n.add(o),i&&(l==null||l()),()=>{n.delete(o),n.size===0&&(a==null||a())}}}}function Ve(e,t){return st(e,t)}function yr(){return st(he,wr)}function _r(e,t){return e.start===t.start&&e.end===t.end}function wr(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((r,n)=>r===t.visibleMessageIds[n])}function Cr({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:r,scrollMargin:n,scrollPreviousItemPeek:o}){let l=c.useRef(e),a=c.useRef(!1),i=c.useRef(null),d=c.useRef(!1),p=c.useRef(r),m=c.useRef(0),y=c.useRef(null),f=c.useRef(0),u=c.useRef(e?"following-bottom":"free-scrolling"),g=c.useRef(new Map),F=c.useRef(null),v=c.useRef(null),A=c.useRef(null),V=c.useRef(o),P=c.useRef(!0),U=c.useRef(null),I=c.useRef(n),D=c.useRef(null),E=c.useRef(0),L=c.useRef(0),M=c.useRef(null),Z=c.useRef(null),$=c.useRef(null),x=c.useRef(null),_=c.useRef(null),S=c.useRef(null),k=c.useRef(null),T=c.useRef(null),R=c.useRef(null),j=c.useRef(new Set),W=c.useRef(new WeakSet);return $.current===null&&($.current=Ve(t==="end"||t==="last-anchor",(z,le)=>z===le)),x.current===null&&(x.current=Ve(tt,_r)),R.current===null&&(R.current=yr()),l.current=e,p.current=r,I.current=n,V.current=o,{autoScrollRef:l,autoscrollingRef:a,autoscrollingTimeoutRef:_,streamingTurnRef:A,contentRef:i,defaultScrollPositionAppliedRef:d,firstItemRef:y,itemCountRef:m,lastScrollTopRef:f,messageElementsRef:g,modeRef:u,pendingScrollFrameRef:D,pendingScrollToMessageRef:F,prependRestoreRef:v,preserveScrollOnPrependRef:P,pendingDefaultScrollStore:$.current,rootRef:U,scrollEdgeThresholdRef:p,scrollMarginRef:I,scrollPreviousItemPeekRef:V,spacerGapRef:E,spacerHeightRef:L,spacerRef:M,stateFrameRef:Z,stateStore:x.current,viewportRef:S,visibilityFrameRef:k,visibilityObserverRef:T,visibilityStore:R.current,visibleMessageIdsRef:j,handledScrollAnchorsRef:W}}function ot(e){e.pendingDefaultScrollStore.setSnapshot(!1)}function fe(e){e.defaultScrollPositionAppliedRef.current=!0,ot(e)}function Sr({refs:e,commitScrollState:t,scheduleStateCommit:r,scheduleVisibilitySync:n}){let{streamingTurnRef:o,autoScrollRef:l,autoscrollingRef:a,autoscrollingTimeoutRef:i,contentRef:d,itemCountRef:p,messageElementsRef:m,modeRef:y,pendingScrollToMessageRef:f,prependRestoreRef:u,scrollMarginRef:g,scrollPreviousItemPeekRef:F,spacerGapRef:v,spacerHeightRef:A,spacerRef:V,viewportRef:P}=e,U=c.useCallback(x=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null),a.current!==x&&(a.current=x,t()),x&&(i.current=window.setTimeout(()=>{i.current=null,a.current=!1,t()},or))},[t]),I=c.useCallback(x=>{let _=V.current;if(!_)return;let S=Math.max(0,Math.ceil(x));A.current!==S&&(A.current=S,_.hidden=S===0,_.style.height=`${S}px`,_.style.marginTop=S>0?`${-v.current}px`:"")},[]),D=c.useCallback((x,{behavior:_="auto",autoscrolling:S=!1}={})=>{let k=P.current;if(!k)return;let T=Math.max(0,x);if(Math.abs(k.scrollTop-T)<=pe){k.scrollTop=T,t();return}S&&U(!0),k.scrollTo({top:T,behavior:_}),r()},[t,r,U]),E=c.useCallback(({behavior:x="auto"}={})=>P.current?(I(0),o.current=null,y.current="free-scrolling",D(0,{behavior:x}),n(),!0):!1,[n,D,I]),L=c.useCallback(({behavior:x="auto"}={})=>{let _=P.current;return _?(I(0),o.current=null,y.current=l.current?"following-bottom":"free-scrolling",D(br(_),{autoscrolling:!0,behavior:x}),n(),!0):!1},[n,D,I]),M=c.useCallback((x,{align:_="start",behavior:S="auto",scrollMargin:k=g.current}={},{keepPreviousPeek:T=!1}={})=>{let R=d.current,j=P.current;if(!R||!j||!R.contains(x))return!1;let W=mr({align:_,element:x,scrollMargin:T?k+F.current:k,spacer:V.current,viewport:j}),z=gr({content:R,scrollTop:W,spacer:V.current,viewport:j});return I(z),u.current={element:x,viewportTop:de(x,j)},y.current=T?"anchored-to-message":"settling-jump",o.current=T?x:null,D(W,{behavior:S}),n(),!0},[n,D,I]),Z=c.useCallback(()=>{let x=o.current;return!x||!x.isConnected||y.current!=="anchored-to-message"?!1:M(x,{align:"start"},{keepPreviousPeek:!0})},[M]),$=c.useCallback((x,_)=>{let S=m.current.get(x);return S?(fe(e),M(S,_)?(f.current=null,!0):(f.current={messageId:x,options:_},!0)):p.current===0?(f.current={messageId:x,options:_},fe(e),!0):!1},[M]);return{flushPendingScrollToMessage:c.useCallback(()=>{let x=f.current;if(!x)return!1;let _=m.current.get(x.messageId);return!_||!M(_,x.options)?!1:(f.current=null,fe(e),!0)},[M]),reanchorToAnchoredMessage:Z,scrollToElement:M,scrollToEnd:L,scrollToMessage:$,scrollToStart:E}}function We(e,t){return c.useCallback(r=>{e.current=r,r&&t()},[e,t])}function kr({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:r=rr,scrollPreviousItemPeek:n=nr,scrollMargin:o=sr}){let l=Cr({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:r,scrollMargin:o,scrollPreviousItemPeek:n}),{streamingTurnRef:a,autoScrollRef:i,autoscrollingRef:d,autoscrollingTimeoutRef:p,contentRef:m,defaultScrollPositionAppliedRef:y,firstItemRef:f,itemCountRef:u,lastScrollTopRef:g,messageElementsRef:F,modeRef:v,pendingScrollFrameRef:A,pendingScrollToMessageRef:V,prependRestoreRef:P,preserveScrollOnPrependRef:U,pendingDefaultScrollStore:I,rootRef:D,scrollEdgeThresholdRef:E,scrollMarginRef:L,scrollPreviousItemPeekRef:M,spacerGapRef:Z,spacerHeightRef:$,spacerRef:x,stateFrameRef:_,stateStore:S,viewportRef:k,visibilityFrameRef:T,visibilityObserverRef:R,visibilityStore:j,visibleMessageIdsRef:W,handledScrollAnchorsRef:z}=l,le=c.useRef(t);le.current!==t&&(le.current=t,y.current=!1);let ae=c.useCallback(h=>{let w=D.current,C=k.current,B=[h.start&&"start",h.end&&"end"].filter(Boolean).join(" "),J=d.current;for(let H of[w,C])H&&(B?H.setAttribute("data-scrollable",B):H.removeAttribute("data-scrollable"),H.toggleAttribute("data-autoscrolling",J))},[]),Fe=c.useCallback(h=>{var B;let w=((B=k.current)==null?void 0:B.scrollTop)??0,C=w<g.current-pe;g.current=w,i.current&&!h.end&&v.current!=="settling-jump"&&v.current!=="anchored-to-message"?v.current="following-bottom":v.current==="following-bottom"&&h.end&&C&&!d.current&&(v.current="free-scrolling")},[]),Y=c.useCallback(()=>{let h=ir({content:m.current,scrollEdgeThreshold:E.current,spacer:x.current,viewport:k.current});Fe(h);let w=v.current==="following-bottom"?{...h,end:!1}:h;ae(w),S.setSnapshot(w)},[Fe,S,ae]),ee=c.useCallback(()=>{_.current===null&&(_.current=window.requestAnimationFrame(()=>{_.current=null,Y()}))},[Y]),N=c.useCallback(()=>{j.hasListeners()&&T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null,j.hasListeners()&&j.setSnapshot(cr({content:m.current,scrollMargin:L.current,scrollPreviousItemPeek:M.current,spacer:x.current,viewport:k.current,visibleMessageIds:W.current}))}))},[j]),{flushPendingScrollToMessage:ie,reanchorToAnchoredMessage:Ee,scrollToElement:te,scrollToEnd:q,scrollToMessage:Re,scrollToStart:ce}=Sr({refs:l,commitScrollState:Y,scheduleStateCommit:ee,scheduleVisibilitySync:N}),Te=c.useCallback(()=>{let h=P.current,w=k.current;if(!h||!w||!h.element.isConnected)return!1;let C=de(h.element,w)-h.viewportTop;return Math.abs(C)<=pe?!1:(w.scrollTop+=C,h.viewportTop=de(h.element,w),ee(),N(),!0)},[ee,N]),X=c.useCallback(()=>{let h=m.current,w=k.current;if(!h||!w){P.current=null;return}let C=hr({content:h,spacer:x.current,viewport:w});P.current=C?{element:C,viewportTop:de(C,w)}:null},[]),Ae=c.useCallback(()=>{A.current===null&&(A.current=window.requestAnimationFrame(()=>{A.current=null,ie()&&X()}))},[X,ie]),ue=c.useCallback(()=>{if(!t||y.current||u.current===0)return!1;let h=!1;if(t==="last-anchor"){let w=m.current,C=k.current,B=w&&C?pr(re(w,x.current)):null;if(!w||!C||!B)h=q({behavior:"auto"});else{let J=rt(B,C);h=ke({content:w,spacer:x.current,viewport:C})-J<=C.clientHeight?q({behavior:"auto"}):te(B,{align:"start"},{keepPreviousPeek:!0})}}else h=t==="end"?q({behavior:"auto"}):ce({behavior:"auto"});return h?(fe(l),!0):!1},[t,te,q,ce]),Be=c.useCallback(()=>{let h=m.current;if(!h)return;let w=re(h,x.current),C=u.current,B=f.current;u.current=w.length,f.current=w[0]??null,(()=>{if(ie())return;if(C===0){if(ue()||w.length>0&&i.current&&q({behavior:"auto"}))return;Y(),N();return}let J=B?w.indexOf(B):-1;if(U.current&&J>0){Te();return}if(w.length>C){let H=ur(w,C);if(H){if(i.current&&v.current==="following-bottom"&&fr(w,C)){q({behavior:"auto"});return}te(H,{align:"start"},{keepPreviousPeek:!0}),z.current.add(H);return}}if(w.length===C){let H=dr(w,z.current);if(H){te(H,{align:"start"},{keepPreviousPeek:!0}),z.current.add(H);return}}v.current==="following-bottom"&&i.current?q({behavior:"auto"}):(Y(),N())})(),X()},[ue,X,Y,ie,Te,N,te,q]),De=c.useCallback(()=>{if(v.current==="following-bottom"&&i.current){q({behavior:"auto"});return}let h=$.current;if(Ee()){i.current&&h>0&&$.current===0&&q({behavior:"auto"});return}ee(),N()},[Ee,ee,N,q]),Me=c.useCallback(()=>{let h=k.current;if(!(!h||!j.hasListeners())){if(typeof IntersectionObserver>"u"){N();return}R.current||(R.current=new IntersectionObserver(w=>{for(let C of w){let B=C.target.dataset.messageId;B&&(C.isIntersecting?W.current.add(B):W.current.delete(B))}N()},{root:h,rootMargin:`${-(L.current+M.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),F.current.forEach(w=>{var C;(C=R.current)==null||C.observe(w)}),N()}},[N,j]),Ie=c.useCallback(()=>{var h;T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),(h=R.current)==null||h.disconnect(),R.current=null,W.current.clear(),j.setSnapshot(he)},[j]),ut=c.useCallback((h,w,C)=>{var B,J,H;if(w){F.current.set(h,w),(B=R.current)==null||B.observe(w),N(),((J=V.current)==null?void 0:J.messageId)===h&&Ae();return}C&&F.current.get(h)===C&&(F.current.delete(h),W.current.delete(h),(H=R.current)==null||H.unobserve(C),N())},[Ae,N]),Ne=c.useCallback(()=>{(v.current==="following-bottom"||v.current==="anchored-to-message"||v.current==="settling-jump")&&(a.current=null,v.current="free-scrolling")},[]),Pe=c.useCallback(()=>ae(S.getSnapshot()),[S,ae]),Le=We(D,Pe),Oe=We(k,Pe),ze=c.useCallback(h=>{m.current=h},[]),qe=c.useCallback(h=>{x.current=h,Z.current=vr((h==null?void 0:h.parentElement)??null)},[]),He=c.useCallback(()=>{Y(),N(),X()},[X,Y,N]),dt=c.useMemo(()=>({handleContentChange:Be,handleResize:De,observeVisibility:Me,pendingDefaultScrollStore:I,preserveScrollOnPrependRef:U,scrollToEnd:q,scrollToMessage:Re,scrollToStart:ce,setContentElement:ze,setRootElement:Le,setSpacerElement:qe,setViewportElement:Oe,stateStore:S,syncAfterScroll:He,unobserveVisibility:Ie,userScrollIntent:Ne,viewportRef:k,visibilityStore:j}),[Be,De,Me,I,q,Re,ce,ze,Le,qe,Oe,S,He,Ie,Ne,j]);return c.useLayoutEffect(()=>{ue()||u.current===0&&ot(l)},[ue]),c.useEffect(()=>()=>{var h;_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null),T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),p.current!==null&&(window.clearTimeout(p.current),p.current=null),A.current!==null&&(window.cancelAnimationFrame(A.current),A.current=null),(h=R.current)==null||h.disconnect(),R.current=null},[]),c.useLayoutEffect(()=>{if(e&&v.current==="following-bottom"&&u.current>0){q({behavior:"auto"});return}Y()},[e,Y,q]),{context:dt,registerMessage:ut}}function jr(e){let t=c.useRef(e);return t.current=e,t}var lt=c.createContext(null),at=c.createContext(null);function oe(){let e=c.useContext(lt);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function Fr(){let e=c.useContext(at);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function Er({autoScroll:e=!1,children:t,defaultScrollPosition:r="end",scrollEdgeThreshold:n,scrollPreviousItemPeek:o,scrollMargin:l}){let{context:a,registerMessage:i}=kr({autoScroll:e,defaultScrollPosition:r,scrollEdgeThreshold:n,scrollPreviousItemPeek:o,scrollMargin:l});return s.jsx(lt.Provider,{value:a,children:s.jsx(at.Provider,{value:i,children:t})})}function it(){let{pendingDefaultScrollStore:e}=oe();return c.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function Rr({children:e,...t}){let{setRootElement:r}=oe(),n=it();return s.jsx("div",{ref:r,...t,...n?{"data-pending-scroll":""}:null,children:e})}function Tr({"aria-label":e,children:t,onKeyDown:r,onScroll:n,onTouchMove:o,onWheel:l,preserveScrollOnPrepend:a=!0,ref:i,role:d,tabIndex:p,...m}){let{handleResize:y,preserveScrollOnPrependRef:f,setViewportElement:u,syncAfterScroll:g,userScrollIntent:F,viewportRef:v}=oe(),A=it();f.current=a;let V=c.useCallback(E=>{var L;u(E),(L=se(i))==null||L(E)},[i,u]);function P(E){g(),n==null||n(E)}function U(E){F(),l==null||l(E)}function I(E){F(),o==null||o(E)}function D(E){lr.has(E.key)&&F(),r==null||r(E)}return c.useEffect(()=>{let E=v.current;if(!E||typeof ResizeObserver>"u")return;let L=0,M=new ResizeObserver(()=>{window.cancelAnimationFrame(L),L=window.requestAnimationFrame(y)});return M.observe(E),()=>{window.cancelAnimationFrame(L),M.disconnect()}},[y,v]),s.jsx("div",{ref:V,role:d??"region","aria-label":e??"Messages",tabIndex:p??0,onKeyDown:D,onScroll:P,onTouchMove:I,onWheel:U,...m,...A?{"data-pending-scroll":""}:null,children:t})}function Ar({"aria-relevant":e,children:t,ref:r,role:n,spacerClassName:o,...l}){let{handleContentChange:a,handleResize:i,setContentElement:d,setSpacerElement:p}=oe(),m=c.useRef(null),y=c.useCallback(f=>{var u;m.current=f,d(f),(u=se(r))==null||u(f)},[r,d]);return c.useLayoutEffect(()=>{let f=m.current;if(!f||(a(),typeof MutationObserver>"u"))return;let u=new MutationObserver(()=>{a()});return u.observe(f,{childList:!0}),()=>u.disconnect()},[a]),c.useEffect(()=>{let f=m.current;if(!f||typeof ResizeObserver>"u")return;let u=0,g=new ResizeObserver(()=>{window.cancelAnimationFrame(u),u=window.requestAnimationFrame(i)});return g.observe(f),()=>{window.cancelAnimationFrame(u),g.disconnect()}},[i]),s.jsxs("div",{ref:y,role:n??"log","aria-relevant":e??"additions",...l,children:[t,s.jsx("div",{ref:p,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function Br({messageId:e,ref:t,scrollAnchor:r=!1,...n}){let o=Fr(),l=c.useRef(null),a=c.useCallback(i=>{var p;let d=l.current;l.current=i,e&&o(e,i,d),(p=se(t))==null||p(i)},[e,t,o]);return s.jsx("div",{ref:a,"data-message-id":e,"data-scroll-anchor":r?"true":"false",...n})}function Dr({behavior:e="smooth",children:t,direction:r="end",onClick:n,render:o,tabIndex:l,type:a="button",...i}){let{scrollToEnd:d,scrollToStart:p,stateStore:m}=oe(),y=jr(n),f=c.useCallback(v=>m.subscribe(v),[m]),u=c.useCallback(()=>{let v=m.getSnapshot();return r==="start"?v.start:v.end},[r,m]),g=c.useSyncExternalStore(f,u,u),F=c.useCallback(v=>{var A;g&&((A=y.current)==null||A.call(y,v),v.defaultPrevented||(v.currentTarget.blur(),r==="start"?p({behavior:e}):d({behavior:e})))},[e,r,g,y,d,p]);return Xt({defaultTagName:"button",props:ve({type:a,inert:!g,tabIndex:g?l:-1,children:t??s.jsxs("span",{children:["Scroll to ",r]}),onClick:F},i),render:o,state:{active:g,direction:r},stateAttributesMapping:{active:v=>({"data-active":v?"true":"false"})}})}var Q={Provider:Er,Root:Rr,Viewport:Tr,Content:Ar,Item:Br,Button:Dr};function Mr(e){return s.jsx(Q.Provider,{...e})}function Ir({className:e,...t}){return s.jsx(Q.Root,{"data-slot":"message-scroller",className:G("group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function Nr({className:e,...t}){return s.jsx(Q.Viewport,{"data-slot":"message-scroller-viewport",className:G("size-full min-h-0 min-w-0 overflow-y-auto overscroll-contain","data-[pending-scroll]:invisible",e),...t})}function Pr({className:e,...t}){return s.jsx(Q.Content,{"data-slot":"message-scroller-content",className:G("flex h-max min-h-full flex-col gap-4 px-4 py-4",e),...t})}function Ue({className:e,scrollAnchor:t=!1,...r}){return s.jsx(Q.Item,{"data-slot":"message-scroller-item",scrollAnchor:t,className:G("min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]",e),...r})}function Lr({direction:e="end",className:t,children:r,...n}){return s.jsx(Q.Button,{"data-slot":"message-scroller-button",direction:e,className:G("absolute left-1/2 z-10 flex h-9 w-9 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-card text-foreground shadow-md transition-[opacity,transform] duration-200","hover:bg-[var(--input-bg)]","data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0","data-[active=true]:scale-100 data-[active=true]:opacity-100","data-[direction=end]:bottom-3 data-[direction=start]:top-3","motion-reduce:transition-none",t),...n,children:r??s.jsxs(s.Fragment,{children:[s.jsx(Rt,{size:16,"aria-hidden":"true",className:e==="start"?"rotate-180":void 0}),s.jsx("span",{className:"sr-only",children:e==="end"?"Jump to latest":"Jump to start"})]})})}const Or=()=>s.jsxs("div",{className:"flex items-start gap-2.5",children:[s.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground","aria-hidden":"true",children:s.jsx(Xe,{size:15})}),s.jsx("div",{className:"max-w-[82%] rounded-2xl rounded-tl-sm border border-border bg-[var(--bubble-assistant-bg)] px-3.5 py-2.5 text-[13.5px] leading-[1.55] text-foreground",children:s.jsx("p",{children:"Hello — I am the VPS Veritas assistant. Ask about reports, sample status, registration, or support, or choose a question below the text box."})})]});function ge(e){return e.split(/(\*\*[^*]+\*\*|`[^`]+`|https?:\/\/[^\s]+)/g).map((r,n)=>r.startsWith("**")&&r.endsWith("**")?s.jsx("strong",{children:r.slice(2,-2)},n):r.startsWith("`")&&r.endsWith("`")?s.jsx("code",{className:"rounded bg-[var(--input-bg)] px-1 py-0.5 font-mono text-[12px] text-foreground",children:r.slice(1,-1)},n):/^https?:\/\//.test(r)?s.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-2",children:r},n):s.jsx(b.Fragment,{children:r},n))}function zr({text:e}){if(!e)return null;const t=e.split(/\n\n+/);return s.jsx(s.Fragment,{children:t.map((r,n)=>{if(r.trim().startsWith("- ")||r.trim().startsWith("* ")){const o=r.split(/\n/).filter(l=>l.trim().startsWith("- ")||l.trim().startsWith("* "));return s.jsx("ul",{className:"my-1.5 ml-4 list-disc space-y-0.5",children:o.map((l,a)=>s.jsx("li",{children:ge(l.replace(/^[-*]\s+/,""))},a))},n)}if(/^\d+\.\s+/.test(r.trim())){const o=r.split(/\n/).filter(l=>/^\d+\.\s+/.test(l.trim()));return s.jsx("ol",{className:"my-1.5 ml-4 list-decimal space-y-0.5",children:o.map((l,a)=>s.jsx("li",{children:ge(l.replace(/^\d+\.\s+/,""))},a))},n)}if(r.startsWith("```")){const o=r.replace(/^```[a-zA-Z]*\n?/,"").replace(/```$/,"");return s.jsx("pre",{className:"my-2 overflow-x-auto rounded-lg bg-[var(--code-bg)] p-3 font-mono text-[12px] text-primary-foreground",children:s.jsx("code",{children:o})},n)}return s.jsx("p",{className:"mb-2 last:mb-0 whitespace-pre-wrap",children:ge(r)},n)})})}const qr=({className:e})=>s.jsxs("div",{className:G("flex items-center gap-1 py-0.5",e),role:"status","aria-label":"Assistant is preparing a reply",children:[s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--text-subtle)] motion-safe:animate-pulse"}),s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--text-subtle)] motion-safe:animate-pulse [animation-delay:150ms]"}),s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--text-subtle)] motion-safe:animate-pulse [animation-delay:300ms]"})]});function Hr(e){return e==="create_ticket"?"Support ticket processed":e==="get_customer"?"Account verified":e==="get_ticket"?"Ticket status loaded":"Information retrieved"}function Gr({sources:e}){const[t,r]=b.useState(!1);return e.length?s.jsxs("div",{className:"mt-2 border-t border-border pt-1.5",children:[s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 text-[11.5px] font-semibold text-muted-foreground hover:text-foreground",onClick:()=>r(n=>!n),"aria-expanded":t,children:[s.jsx(Nt,{size:12,"aria-hidden":"true"}),e.length," grounded source",e.length>1?"s":"",t?s.jsx(Mt,{size:12}):s.jsx(Dt,{size:12})]}),t&&s.jsx("ul",{className:"mt-1.5 space-y-1",children:e.map(n=>s.jsxs("li",{className:"flex items-center justify-between rounded-md border border-border bg-muted px-2 py-1 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"truncate",title:n.source,children:n.source.split(/[/\\]/).pop()||n.source}),s.jsxs("span",{className:"ml-2 font-semibold text-success",children:[Math.round(n.score*100),"%"]})]},n.chunkId))})]}):null}function Vr({toolCalls:e}){return e.length?s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.map((t,r)=>s.jsx("span",{className:"inline-flex items-center rounded-full border border-border bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:Hr(t.toolName)},`${t.toolName}-${r}`))}):null}const Wr=({message:e})=>{const t=e.role==="user",r=e.status==="error";return s.jsxs("div",{className:G("flex items-start gap-2.5",t&&"flex-row-reverse"),children:[!t&&s.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground","aria-hidden":"true",children:s.jsx(Xe,{size:15})}),s.jsxs("div",{className:G("flex max-w-[82%] flex-col",t&&"items-end"),children:[s.jsxs("div",{className:G("rounded-2xl px-3.5 py-2.5 text-[13.5px] leading-[1.55]",t&&"rounded-tr-sm bg-[var(--bubble-user-bg)] text-[var(--bubble-user-text)] font-medium",!t&&!r&&"rounded-tl-sm border border-border bg-[var(--bubble-bot-message-bg)] text-foreground",r&&"rounded-tl-sm border border-[var(--error-border)] bg-[var(--error-bg)] text-[var(--error-text)]"),children:[e.status==="pending"?s.jsx(qr,{}):t?s.jsx("p",{className:"whitespace-pre-wrap",children:e.content}):s.jsx(zr,{text:e.content}),e.toolCalls?s.jsx(Vr,{toolCalls:e.toolCalls}):null,e.sources?s.jsx(Gr,{sources:e.sources}):null]}),t&&e.status!=="error"&&s.jsx(Bt,{size:13,className:"mt-1 text-success","aria-hidden":"true"})]})]})},Ur=()=>{const{messages:e,status:t,showSuggestions:r}=ne(),n=t==="awaiting"||t==="connecting";return s.jsx(Mr,{autoScroll:!0,defaultScrollPosition:"last-anchor",scrollPreviousItemPeek:64,children:s.jsxs(Ir,{children:[s.jsx(Nr,{"aria-label":"Chat messages",children:s.jsxs(Pr,{"aria-busy":n,children:[r&&s.jsx(Ue,{messageId:"welcome",children:s.jsx(Or,{})}),e.map(o=>s.jsx(Ue,{messageId:o.id,scrollAnchor:o.role==="user",children:s.jsx(Wr,{message:o})},o.id))]})}),s.jsx(Lr,{})]})})},$r=()=>{const{pendingTicket:e,ticketBusy:t,userContext:r,confirmTicket:n,cancelTicket:o}=ne(),l=!r.customerId&&!r.email,[a,i]=b.useState("");return e?s.jsxs("div",{className:"mx-4 mb-3 rounded-xl border border-border bg-card p-4 shadow-sm",role:"region","aria-label":"Create support ticket",children:[s.jsx("h3",{className:"text-[13.5px] font-bold text-foreground",children:"Create support ticket?"}),s.jsx("p",{className:"mt-1.5 text-[12.5px] leading-5 text-muted-foreground",children:"I can open a support request for you. Nothing is created until you confirm."}),s.jsx("p",{className:"mt-2 rounded-md bg-muted px-2.5 py-2 text-[12.5px] text-foreground",children:e.description}),l&&s.jsxs("label",{className:"mt-3 block text-[12px] font-semibold text-foreground",children:["Customer ID or email",s.jsx("input",{value:a,onChange:d=>i(d.target.value),className:"mt-1 w-full rounded-md border border-border px-2.5 py-2 text-[13px] font-normal outline-none focus-visible:ring-2 focus-visible:ring-primary",placeholder:"CUST-1001 or you@company.com",autoComplete:"email"})]}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:o,disabled:t,className:"rounded-lg border border-border bg-card px-3.5 py-1.5 text-[12.5px] font-semibold text-muted-foreground hover:bg-muted",children:"Cancel"}),s.jsx("button",{type:"button",onClick:()=>void n(a),disabled:t||l&&!a.trim(),className:"rounded-lg bg-action px-3.5 py-1.5 text-[12.5px] font-semibold text-action-foreground hover:bg-[var(--action-hover)] disabled:opacity-40",children:t?"Creating…":"Create ticket"})]})]}):null},je=({className:e,onClose:t,showMinimize:r,title:n,subtitle:o,envStage:l,envPulse:a=!0})=>{const{sendMessage:i,status:d,error:p,resetConversation:m,retryLast:y,pendingTicket:f}=ne(),u=d==="awaiting"||d==="connecting"||!!f;return s.jsxs("section",{className:G("flex h-full min-h-0 flex-col overflow-hidden bg-card",e),"aria-label":"VPS AI Assistant",children:[s.jsx(Ut,{title:n,subtitle:o,onClose:t,onReset:()=>void m(),showMinimize:r,envStage:l,envPulse:a}),s.jsx("div",{className:"relative min-h-0 flex-1",children:s.jsx(Ur,{})}),p&&d==="error"&&s.jsx(kt,{message:p,onRetry:()=>void y()}),s.jsx($r,{}),s.jsx(Kt,{onSend:g=>void i(g),disabled:u})]})},Yr=({open:e,onClose:t,envStage:r,envPulse:n=!0})=>e?s.jsx("div",{id:"vps-chatbot-widget-panel",className:G("fixed bottom-[98px] right-7 z-[999] flex h-[min(660px,calc(100vh-120px))] w-[min(420px,calc(100vw-32px))] flex-col overflow-hidden rounded-[20px] border border-border bg-card","shadow-[0_20px_40px_-15px_rgba(0,0,0,0.12)]","origin-bottom-right animate-[chat-pop_180ms_ease-out] motion-reduce:animate-none"),children:s.jsx(je,{onClose:t,showMinimize:!0,title:"VPS AI Assistant",envStage:r,envPulse:n})}):null,Zr=({open:e,onToggle:t})=>s.jsx("button",{type:"button",onClick:t,"aria-expanded":e,"aria-controls":"vps-chatbot-widget-panel","aria-label":e?"Close assistant":"Open assistant",className:G("fixed bottom-7 right-7 z-[1000] flex h-[58px] w-[58px] items-center justify-center rounded-xl text-primary-foreground","bg-primary hover:bg-[var(--primary-hover)]","shadow-md","transition duration-200 motion-reduce:transition-none motion-reduce:hover:scale-100","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary"),children:e?s.jsx(Ht,{size:22}):s.jsx(Qe,{size:24})}),$e=({defaultOpen:e=!1,open:t,onOpenChange:r,envStage:n,envPulse:o=!0})=>{const[l,a]=b.useState(e),i=t??l,d=p=>{r==null||r(p),t===void 0&&a(p)};return s.jsxs(s.Fragment,{children:[s.jsx(Yr,{open:i,onClose:()=>d(!1),envStage:n,envPulse:o}),s.jsx(Zr,{open:i,onToggle:()=>d(!i)})]})},Jr=({apiBaseUrl:e,apiUrl:t,proxyUrl:r,userContext:n,suggestions:o,disableSuggestions:l,initialMessage:a,...i})=>{const d=Ce(),p=e??t??r;return!!d&&(!p||K(p)===K(d==null?void 0:d.apiBaseUrl))&&!n&&!o&&l===void 0&&!a?s.jsx($e,{...i}):s.jsx(Se,{apiBaseUrl:p,userContext:n,suggestions:o,disableSuggestions:l,initialMessage:a,children:s.jsx($e,{...i})})},Kr=({open:e,onClose:t,subtitle:r,title:n,envStage:o,envPulse:l=!0})=>s.jsxs(s.Fragment,{children:[s.jsx("div",{className:G("fixed inset-0 z-[90] bg-[var(--overlay)] sm:hidden",e?"opacity-100":"pointer-events-none opacity-0","transition-opacity duration-200 motion-reduce:transition-none"),hidden:!e,onClick:t,"aria-hidden":"true"}),s.jsx("aside",{id:"vps-embedded-chat-panel",className:G("fixed inset-y-0 right-0 z-[100] flex w-full max-w-[440px] flex-col border-l border-border bg-card shadow-xl","transition-transform duration-300 ease-out motion-reduce:transition-none",e?"translate-x-0":"translate-x-full"),"aria-hidden":!e,children:e&&s.jsx(je,{onClose:t,title:n||"VPS AI Assistant",subtitle:r,envStage:o,envPulse:l})})]}),Xr=5,be=8,ct="vps-embedded-assistant-top";function Qr(e,t,r){return Math.min(r,Math.max(t,e))}function Ye(e,t){const r=Math.max(be,window.innerHeight-t-be);return Qr(e,be,r)}function en(){try{const e=window.localStorage.getItem(ct);if(!e)return null;const t=Number(e);return Number.isFinite(t)?t:null}catch{return null}}function tn(e){try{window.localStorage.setItem(ct,String(e))}catch{}}const rn=({onOpen:e})=>{const t=b.useRef(null),r=b.useRef({pointerId:null,startY:0,startTop:0,moved:!1}),[n,o]=b.useState(()=>typeof window>"u"?null:en()),l=b.useRef(n),a=b.useRef(!1),[i,d]=b.useState(!1);b.useEffect(()=>{l.current=n},[n]),b.useEffect(()=>{const f=t.current;if(!f)return;const u=()=>{o(g=>{const F=g??Math.round(window.innerHeight/2-f.offsetHeight/2),v=Ye(F,f.offsetHeight);return l.current=v,v})};return u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]);const p=f=>{if(f.button!==0)return;const u=f.currentTarget,g=u.getBoundingClientRect();r.current={pointerId:f.pointerId,startY:f.clientY,startTop:g.top,moved:!1};try{u.setPointerCapture(f.pointerId)}catch{}},m=f=>{if(r.current.pointerId!==f.pointerId)return;const u=f.clientY-r.current.startY;if(!r.current.moved&&Math.abs(u)<Xr)return;r.current.moved=!0,d(!0);const g=Ye(r.current.startTop+u,f.currentTarget.offsetHeight);l.current=g,o(g)},y=f=>{var g,F;if(r.current.pointerId!==f.pointerId)return;try{(F=(g=f.currentTarget).hasPointerCapture)!=null&&F.call(g,f.pointerId)&&f.currentTarget.releasePointerCapture(f.pointerId)}catch{}const u=r.current.moved;r.current.pointerId=null,r.current.moved=!1,d(!1),u&&(a.current=!0,l.current!=null&&tn(l.current))};return s.jsxs("button",{ref:t,type:"button",onPointerDown:p,onPointerMove:m,onPointerUp:y,onPointerCancel:y,onClick:()=>{if(a.current){a.current=!1;return}e()},"aria-expanded":!1,"aria-controls":"vps-embedded-chat-panel","aria-label":"Assistant",className:`fixed right-0 z-[80] flex touch-none items-center gap-2 rounded-l-lg bg-action px-3 py-2.5 text-[12.5px] font-semibold text-action-foreground shadow-lg hover:bg-[var(--action-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${i?"cursor-grabbing":"cursor-grab"}`,style:{top:n??"50%",transform:n==null?"translateY(-50%)":void 0},children:[s.jsx(Qe,{size:16}),"Assistant"]})},Ze=({defaultOpen:e=!1,open:t,onOpenChange:r,showTrigger:n=!0,envStage:o,envPulse:l=!0})=>{const[a,i]=b.useState(e),d=t??a,p=m=>{r==null||r(m),t===void 0&&i(m)};return s.jsxs(s.Fragment,{children:[n&&!d&&s.jsx(rn,{onOpen:()=>p(!0)}),s.jsx(Kr,{open:d,onClose:()=>p(!1),envStage:o,envPulse:l})]})},nn=({apiBaseUrl:e,apiUrl:t,proxyUrl:r,userContext:n,suggestions:o,disableSuggestions:l,initialMessage:a,...i})=>{const d=Ce(),p=e??t??r;return!!d&&(!p||K(p)===K(d==null?void 0:d.apiBaseUrl))&&!n&&!o&&l===void 0&&!a?s.jsx(Ze,{...i}):s.jsx(Se,{apiBaseUrl:p,userContext:n,suggestions:o,disableSuggestions:l,initialMessage:a,children:s.jsx(Ze,{...i})})},sn={Colors:{VPS_White:"#fff",VPS_Dark_Blue:"#1A1A31",VPS_Light_Blue:"#353552",VPS_Light_Grey:"#D1D1D6",VPS_Orange:"#FF4717",Dark_Blue_50:"#F1F5FC",Dark_Blue_100:"#E5EBFA",Dark_Blue_200:"#D1DAF4",Dark_Blue_300:"#B4C2ED",Dark_Blue_400:"#96A2E3",Dark_Blue_500:"#7C84D8",Dark_Blue_600:"#6262C9",Dark_Blue_700:"#5351B1",Dark_Blue_800:"#44448F",Dark_Blue_900:"#3C3D73",Dark_Blue_950:"#1A1A31",Light_Blue_50:"#F4F6FA",Light_Blue_100:"#E6E9F3",Light_Blue_200:"#D3D8EA",Light_Blue_300:"#B4BEDC",Light_Blue_400:"#909DCA",Light_Blue_500:"#7580BC",Light_Blue_600:"#6369AD",Light_Blue_700:"#575A9E",Light_Blue_800:"#4B4B82",Light_Blue_900:"#404168",Light_Blue_950:"#353552",Grey_50:"#F6F6F7",Grey_100:"#EFEFF0",Grey_200:"#E2E1E4",Grey_300:"#D1D1D6",Grey_400:"#B9B9C0",Grey_500:"#A7A6AE",Grey_600:"#93919A",Grey_700:"#7E7D85",Grey_800:"#67666D",Grey_900:"#56555A",Grey_950:"#323234",Orange_50:"#FFF3ED",Orange_100:"#FFE4D4",Orange_200:"#FFC5A8",Orange_300:"#FF9D70",Orange_400:"#FF6837",Orange_500:"#FF4717",Orange_600:"#F02706",Orange_700:"#C71807",Orange_800:"#9E150E",Orange_900:"#7F150F",Orange_950:"#450605",Success_50:"#F1FCF5",Success_100:"#DEFAEA",Success_200:"#BEF4D4",Success_300:"#8BEAB3",Success_400:"#52D689",Success_500:"#2ECC71",Success_600:"#1D9C53",Success_700:"#1B7A43",Success_800:"#1A6139",Success_900:"#175031",Success_950:"#072C18",Warning_50:"#FFFEEA",Warning_100:"#FFF9C5",Warning_200:"#FFF485",Warning_300:"#FFE846",Warning_400:"#FFD81B",Warning_500:"#FFB800",Warning_600:"#E28D00",Warning_700:"#BB6302",Warning_800:"#984C08",Warning_900:"#7C3F0B",Warning_950:"#482000",Error_50:"#FFF1F1",Error_100:"#FFDFDF",Error_200:"#FFC5C5",Error_300:"#FF9D9D",Error_400:"#FF6464",Error_500:"#FF2E2E",Error_600:"#ED1515",Error_700:"#C80D0D",Error_800:"#A50F0F",Error_900:"#881414",Error_950:"#4B0404",Netural_25:"#FDFDFD",Netural_50:"#FAFAFA",Netural_100:"#F5F5F5",Netural_200:"#E9EAEC",Netural_300:"#D6D7DB",Netural_400:"#A4A7AE",Netural_500:"#727681",Netural_600:"#545863",Netural_700:"#424651",Netural_800:"#252B37",Netural_900:"#191D28",Netural_950:"#0A0D12",Tint_Dark_Blue_100:"#1A1A31",Tint_Dark_Blue_90:"#313146",Tint_Dark_Blue_80:"#48485A",Tint_Dark_Blue_70:"#5F5F6F",Tint_Dark_Blue_60:"#767683",Tint_Dark_Blue_50:"#8C8C98",Tint_Dark_Blue_40:"#A3A3AD",Tint_Dark_Blue_30:"#BABAC1",Tint_Dark_Blue_20:"#D1D1D6",Tint_Dark_Blue_10:"#E8E8EA",Tint_Dark_Blue_5:"#F4F4F5",Tint_Light_Blue_100:"#353552",Tint_Light_Blue_90:"#494963",Tint_Light_Blue_80:"#5D5D75",Tint_Light_Blue_70:"#727286",Tint_Light_Blue_60:"#868697",Tint_Light_Blue_50:"#9A9AA8",Tint_Light_Blue_40:"#AEAEBA",Tint_Light_Blue_30:"#C2C2CB",Tint_Light_Blue_20:"#D7D7DC",Tint_Light_Blue_10:"#EBEBEE",Tint_Light_Blue_5:"#F5F5F6",Tint_Grey_100:"#D1D1D6",Tint_Grey_90:"#D6D6DA",Tint_Grey_80:"#DADADE",Tint_Grey_70:"#DFDFE2",Tint_Grey_60:"#E3E3E6",Tint_Grey_50:"#E8E8EB",Tint_Grey_40:"#EDEDEF",Tint_Grey_30:"#F1F1F3",Tint_Grey_20:"#F6F6F7",Tint_Grey_10:"#FAFAFB",Tint_Grey_5:"#FDFDFD",Tint_Solus_100:"#FF4717",Tint_Solus_90:"#FF592E",Tint_Solus_80:"#FF6C45",Tint_Solus_70:"#FF7E5D",Tint_Solus_60:"#FF9174",Tint_Solus_50:"#FFA38B",Tint_Solus_40:"#FFB5A2",Tint_Solus_30:"#FFC8B9",Tint_Solus_20:"#FFDAD1",Tint_Solus_10:"#FFEDE8",Tint_Solus_5:"#FFF6F3",Other_Color:"#00ABC9"},StatusColor:{tested:"#3E4784",received:"#EE46BC",InTransit:"#6938EF",registered:"#1570EF",reported:"#2ECC71",noStatus:"#727681",Action:"#FF2E2E",Caution:"#FFB800",Pass:"#2ECC71",No_Rating:"#FF6837",Received:"#EE46BC",Tested:"#3E4784",Reported:"#2ECC71",No_Status:"#6938EF",Overdue:"#FF2E2E",Duesoon:"#FFB800",Scheduled:"#1570EF",Good:"#2ECC71",NotApplicable:"#353552"}};exports.ChatPanel=je;exports.ChatProvider=Se;exports.ChatbotWidget=Jr;exports.ColorPalette=sn;exports.EmbeddedChatbot=nn;exports.buildApiUrl=xe;exports.chatApi=wt;exports.createChatApi=_e;exports.resolveApiBaseUrl=K;exports.useChatContext=Je;exports.useChatbot=ne;exports.useOptionalChatContext=Ce;