@useago/sdk 1.5.2 → 1.5.3

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 (50) hide show
  1. package/dist/AgoClient-BGkFSNZF.cjs +8 -0
  2. package/dist/AgoClient-CW-BLT1_.js +1542 -0
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +311 -0
  5. package/dist/angular.d.ts +311 -0
  6. package/dist/angular.js +2 -2
  7. package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
  8. package/dist/{createConversationSession-DPrrr70o.js → createConversationSession-C7cnnWKW.js} +3 -3
  9. package/dist/createFormCollector-iCDwAwYJ.js +279 -0
  10. package/dist/createFormCollector-t_fGyuTD.cjs +1 -0
  11. package/dist/createMockClient-Br0TWgLO.js +97 -0
  12. package/dist/createMockClient-BwNLPjeT.cjs +1 -0
  13. package/dist/devtools.d.cts +311 -0
  14. package/dist/devtools.d.ts +311 -0
  15. package/dist/functions-IGSjjvF4.cjs +1 -0
  16. package/dist/helpers.cjs +1 -1
  17. package/dist/helpers.js +1 -1
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.cts +510 -0
  20. package/dist/index.d.ts +510 -0
  21. package/dist/index.js +95 -90
  22. package/dist/react.cjs +3 -3
  23. package/dist/react.d.cts +375 -0
  24. package/dist/react.d.ts +375 -0
  25. package/dist/react.js +559 -422
  26. package/dist/rolldown-runtime-16Nf8qvH.cjs +1 -0
  27. package/dist/testing.cjs +1 -1
  28. package/dist/testing.d.cts +311 -0
  29. package/dist/testing.d.ts +311 -0
  30. package/dist/testing.js +1 -1
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.d.cts +332 -0
  33. package/dist/vue.d.ts +332 -0
  34. package/dist/vue.js +133 -110
  35. package/dist/widget.cjs +1 -1
  36. package/dist/widget.d.cts +308 -0
  37. package/dist/widget.d.ts +308 -0
  38. package/dist/widget.js +7 -7
  39. package/package.json +1 -1
  40. package/dist/AgoClient-5VGybmvz.cjs +0 -8
  41. package/dist/AgoClient-DXrH2AMi.js +0 -964
  42. package/dist/createConversationSession-0WTqcCLK.cjs +0 -1
  43. package/dist/createFormCollector-1GKKwQV_.cjs +0 -1
  44. package/dist/createFormCollector-DYh90kiG.js +0 -305
  45. package/dist/createMockClient-C-wrjb2C.cjs +0 -1
  46. package/dist/createMockClient-we-XoPom.js +0 -79
  47. package/dist/functions-CPs7omgM.cjs +0 -1
  48. /package/dist/{autoContinue-CP9pJR-V.cjs → autoContinue-CcCTva-D.cjs} +0 -0
  49. /package/dist/{autoContinue-CC8K9mBU.js → autoContinue-D3Mmaaca.js} +0 -0
  50. /package/dist/{functions-tzyOZNp6.js → functions-CApuQZ2b.js} +0 -0
package/dist/vue.js CHANGED
@@ -1,45 +1,45 @@
1
- import { t as A } from "./AgoClient-DXrH2AMi.js";
2
- import { computed as L, inject as M, onMounted as f, onScopeDispose as F, onUnmounted as h, ref as c, shallowRef as S } from "vue";
3
- var N = /* @__PURE__ */ Symbol("ago-client"), b = { install(t, n) {
4
- const e = new A(n);
5
- t.provide(N, e);
1
+ import { t as E } from "./AgoClient-CW-BLT1_.js";
2
+ import { computed as M, inject as F, onMounted as d, onScopeDispose as S, onUnmounted as m, ref as l, shallowRef as A } from "vue";
3
+ var N = /* @__PURE__ */ Symbol("ago-client"), b = { install(t, e) {
4
+ const n = new E(e);
5
+ t.provide(N, n);
6
6
  } };
7
- function g(t) {
8
- if (t) return new A(t);
9
- const n = M(N);
10
- if (!n) throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");
11
- return n;
7
+ function f(t) {
8
+ if (t) return new E(t);
9
+ const e = F(N);
10
+ if (!e) throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");
11
+ return e;
12
12
  }
13
- function x(t = {}) {
14
- const n = t.client ?? g(), e = c([]), s = c(t.conversationId), r = c(!1), a = c(null), l = (o) => {
15
- s.value || (s.value = o.conversationId);
16
- }, m = (o) => {
17
- const i = e.value.findIndex((v) => v.id === o.messageId);
18
- i >= 0 && (e.value[i] = {
19
- ...e.value[i],
20
- content: e.value[i].content + o.content
13
+ function R(t = {}) {
14
+ const e = t.client ?? f(), n = l([]), s = l(t.conversationId), o = l(!1), r = l(null), c = (a) => {
15
+ s.value || (s.value = a.conversationId);
16
+ }, p = (a) => {
17
+ const i = n.value.findIndex((v) => v.id === a.messageId);
18
+ i >= 0 && (n.value[i] = {
19
+ ...n.value[i],
20
+ content: n.value[i].content + a.content
21
21
  });
22
- }, C = (o) => {
23
- const i = e.value.findIndex((v) => v.id === o.id);
24
- i >= 0 ? e.value[i] = o : e.value.push(o), r.value = !1;
25
- }, p = (o) => {
26
- a.value = new Error(o.error), r.value = !1;
22
+ }, h = (a) => {
23
+ const i = n.value.findIndex((v) => v.id === a.id);
24
+ i >= 0 ? n.value[i] = a : n.value.push(a), o.value = !1;
25
+ }, C = (a) => {
26
+ r.value = new Error(a.error), o.value = !1;
27
27
  };
28
- f(() => {
29
- n.on("message:start", l), n.on("message:chunk", m), n.on("message:complete", C), n.on("message:error", p);
30
- }), h(() => {
31
- n.off("message:start", l), n.off("message:chunk", m), n.off("message:complete", C), n.off("message:error", p);
28
+ d(() => {
29
+ e.on("message:start", c), e.on("message:chunk", p), e.on("message:complete", h), e.on("message:error", C);
30
+ }), m(() => {
31
+ e.off("message:start", c), e.off("message:chunk", p), e.off("message:complete", h), e.off("message:error", C);
32
32
  });
33
- async function d(o, i) {
34
- r.value = !0, a.value = null;
33
+ async function g(a, i) {
34
+ o.value = !0, r.value = null;
35
35
  const v = {
36
36
  id: `temp-${Date.now()}`,
37
37
  conversationId: s.value || "",
38
- content: o,
38
+ content: a,
39
39
  role: "user",
40
40
  status: "DONE",
41
41
  createdAt: /* @__PURE__ */ new Date()
42
- }, y = {
42
+ }, L = {
43
43
  id: `temp-assistant-${Date.now()}`,
44
44
  conversationId: s.value || "",
45
45
  content: "",
@@ -47,141 +47,163 @@ function x(t = {}) {
47
47
  status: "IN_PROGRESS",
48
48
  createdAt: /* @__PURE__ */ new Date()
49
49
  };
50
- e.value.push(v, y);
50
+ n.value.push(v, L);
51
51
  try {
52
- const u = await n.sendMessage(o, {
52
+ const u = await e.sendMessage(a, {
53
53
  conversationId: s.value,
54
54
  files: i
55
55
  });
56
- u.conversationId && !s.value && (s.value = u.conversationId), e.value = e.value.filter((E) => !E.id.startsWith("temp-"));
56
+ u.conversationId && !s.value && (s.value = u.conversationId), n.value = n.value.filter((y) => !y.id.startsWith("temp-"));
57
57
  const I = {
58
58
  ...v,
59
59
  id: v.id.replace("temp-", "user-"),
60
60
  conversationId: u.conversationId
61
61
  };
62
- return e.value.some((E) => E.id === u.id) ? e.value.push(I) : e.value.push(I, u), u;
62
+ return n.value.some((y) => y.id === u.id) ? n.value.push(I) : n.value.push(I, u), u;
63
63
  } catch (u) {
64
- return a.value = u instanceof Error ? u : /* @__PURE__ */ new Error("Failed to send"), r.value = !1, e.value = e.value.filter((I) => !I.id.startsWith("temp-")), null;
64
+ return r.value = u instanceof Error ? u : /* @__PURE__ */ new Error("Failed to send"), o.value = !1, n.value = n.value.filter((I) => !I.id.startsWith("temp-")), null;
65
65
  }
66
66
  }
67
67
  function w() {
68
- e.value = [], s.value = void 0, a.value = null;
68
+ n.value = [], s.value = void 0, r.value = null;
69
69
  }
70
70
  return {
71
- messages: e,
72
- isLoading: r,
73
- error: a,
71
+ messages: n,
72
+ isLoading: o,
73
+ error: r,
74
74
  conversationId: s,
75
- sendMessage: d,
75
+ sendMessage: g,
76
76
  clearMessages: w
77
77
  };
78
78
  }
79
79
  function P(t = {}) {
80
- const n = t.client ?? g(), e = t.autoLoad ?? !0, s = c([]), r = c(null), a = c(!1), l = c(null);
81
- async function m() {
82
- a.value = !0, l.value = null;
80
+ const e = t.client ?? f(), n = t.autoLoad ?? !0, s = l([]), o = l(null), r = l(!1), c = l(null);
81
+ async function p() {
82
+ r.value = !0, c.value = null;
83
83
  try {
84
- s.value = await n.getConversations();
85
- } catch (d) {
86
- l.value = d instanceof Error ? d : /* @__PURE__ */ new Error("Failed to load conversations");
84
+ s.value = await e.getConversations();
85
+ } catch (g) {
86
+ c.value = g instanceof Error ? g : /* @__PURE__ */ new Error("Failed to load conversations");
87
87
  } finally {
88
- a.value = !1;
88
+ r.value = !1;
89
89
  }
90
90
  }
91
- async function C(d) {
92
- a.value = !0, l.value = null;
91
+ async function h(g) {
92
+ r.value = !0, c.value = null;
93
93
  try {
94
- r.value = await n.getConversation(d);
94
+ o.value = await e.getConversation(g);
95
95
  } catch (w) {
96
- l.value = w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation");
96
+ c.value = w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation");
97
97
  } finally {
98
- a.value = !1;
98
+ r.value = !1;
99
99
  }
100
100
  }
101
- function p() {
102
- r.value = null;
101
+ function C() {
102
+ o.value = null;
103
103
  }
104
- return f(() => {
105
- e && m();
104
+ return d(() => {
105
+ n && p();
106
106
  }), {
107
107
  conversations: s,
108
- currentConversation: r,
109
- isLoading: a,
110
- error: l,
111
- selectConversation: C,
112
- startNewConversation: p,
113
- refreshConversations: m
108
+ currentConversation: o,
109
+ isLoading: r,
110
+ error: c,
111
+ selectConversation: h,
112
+ startNewConversation: C,
113
+ refreshConversations: p
114
114
  };
115
115
  }
116
116
  function k(t = {}) {
117
- const n = x({
117
+ const e = R({
118
118
  client: t.client,
119
119
  conversationId: t.conversationId
120
- }), e = P({
120
+ }), n = P({
121
121
  client: t.client,
122
122
  autoLoad: t.autoLoad
123
- }), s = L(() => n.error.value || e.error.value);
123
+ }), s = M(() => e.error.value || n.error.value);
124
124
  return {
125
- messages: n.messages,
126
- isLoading: n.isLoading,
125
+ messages: e.messages,
126
+ isLoading: e.isLoading,
127
127
  error: s,
128
- sendMessage: n.sendMessage,
129
- clearMessages: n.clearMessages,
130
- conversationId: n.conversationId,
131
- conversations: e.conversations,
132
- currentConversation: e.currentConversation,
133
- isConversationsLoading: e.isLoading,
134
- selectConversation: e.selectConversation,
135
- startNewConversation: e.startNewConversation,
136
- refreshConversations: e.refreshConversations
128
+ sendMessage: e.sendMessage,
129
+ clearMessages: e.clearMessages,
130
+ conversationId: e.conversationId,
131
+ conversations: n.conversations,
132
+ currentConversation: n.currentConversation,
133
+ isConversationsLoading: n.isLoading,
134
+ selectConversation: n.selectConversation,
135
+ startNewConversation: n.startNewConversation,
136
+ refreshConversations: n.refreshConversations
137
137
  };
138
138
  }
139
- function O(t, n) {
140
- const e = g();
141
- f(() => {
142
- e.registerFunction(t, n.handler, {
143
- description: n.description,
144
- parameters: n.parameters,
145
- maxResultBytes: n.maxResultBytes
139
+ function O(t, e) {
140
+ const n = f();
141
+ d(() => {
142
+ n.registerFunction(t, e.handler, {
143
+ description: e.description,
144
+ parameters: e.parameters,
145
+ maxResultBytes: e.maxResultBytes
146
146
  });
147
- }), h(() => {
148
- e.unregisterFunction(t);
147
+ }), m(() => {
148
+ n.unregisterFunction(t);
149
149
  });
150
150
  }
151
- function _(t, n) {
152
- const e = g();
153
- f(() => {
154
- e.registerNavigationFunction(t, n);
155
- }), h(() => {
156
- e.unregisterNavigationFunction();
151
+ function _(t, e) {
152
+ const n = f();
153
+ d(() => {
154
+ n.registerNavigationFunction(t, e);
155
+ }), m(() => {
156
+ n.unregisterNavigationFunction();
157
157
  });
158
158
  }
159
- function B(t, n) {
160
- const e = g(), s = n?.functionName ?? "setPageState";
161
- f(() => {
162
- e.registerPageStateFunction(t, { functionName: s });
163
- }), h(() => {
164
- e.unregisterPageStateFunction(s);
159
+ function B(t, e) {
160
+ const n = f(), s = e?.functionName ?? "setPageState";
161
+ d(() => {
162
+ n.registerPageStateFunction(t, { functionName: s });
163
+ }), m(() => {
164
+ n.unregisterPageStateFunction(s);
165
165
  });
166
166
  }
167
- function G(t, n) {
168
- const e = g();
169
- f(() => {
170
- e.on(t, n);
171
- }), h(() => {
172
- e.off(t, n);
167
+ function G(t, e) {
168
+ const n = f();
169
+ d(() => {
170
+ n.on(t, e);
171
+ }), m(() => {
172
+ n.off(t, e);
173
173
  });
174
174
  }
175
175
  function U(t) {
176
- const n = S(t.get());
177
- return F(t.subscribe((e) => {
178
- n.value = e;
179
- })), n;
176
+ const e = A(t.get());
177
+ return S(t.subscribe((n) => {
178
+ e.value = n;
179
+ })), e;
180
+ }
181
+ function W() {
182
+ const t = f(), e = A(null), n = (o) => {
183
+ e.value = o, t.proactive?.shown(o);
184
+ }, s = ({ nudge: o }) => {
185
+ e.value?.id === o.id && (e.value = null);
186
+ };
187
+ return d(() => {
188
+ t.on("nudge:ready", n), t.on("nudge:accepted", s), t.on("nudge:dismissed", s);
189
+ }), m(() => {
190
+ t.off("nudge:ready", n), t.off("nudge:accepted", s), t.off("nudge:dismissed", s);
191
+ }), {
192
+ nudge: e,
193
+ accept: async () => {
194
+ const o = e.value;
195
+ o && (e.value = null, await t.proactive?.accept(o));
196
+ },
197
+ dismiss: () => {
198
+ const o = e.value;
199
+ o && (e.value = null, t.proactive?.dismiss(o));
200
+ }
201
+ };
180
202
  }
181
203
  export {
182
204
  N as AGO_CLIENT_KEY,
183
205
  b as AgoPlugin,
184
- g as useAgo,
206
+ f as useAgo,
185
207
  G as useAgoEvents,
186
208
  O as useAgoFunction,
187
209
  _ as useAgoNavigation,
@@ -189,5 +211,6 @@ export {
189
211
  U as useAgoStore,
190
212
  k as useChat,
191
213
  P as useConversation,
192
- x as useMessages
214
+ R as useMessages,
215
+ W as useProactiveNudge
193
216
  };
package/dist/widget.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("./AgoClient-5VGybmvz.cjs"),mt=require("./createFormCollector-1GKKwQV_.cjs"),Xt=require("./createConversationSession-0WTqcCLK.cjs");var Yt='"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',Ie=`var(--ago-font, ${Yt})`,gt={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},_e="var(--ago-brand-color, #03182f)",Le="var(--ago-brand-text-color, #fff)",Qt="var(--ago-header-background, var(--ago-brand-color, #03182f))",ht="var(--ago-header-text-color, #e8f0fe)",te="var(--ago-panel-background, #fff)",Ct="var(--ago-messages-background, #fbfbfb)",ee="var(--ago-text-color, #30373e)",Et="var(--ago-muted-text-color, #6b6d6f)",N="var(--ago-border-color, #dee3e8)",Fe="var(--ago-accent-color, #1b5fc4)",xt="var(--ago-agent-bubble-background, #f1f3f5)",Zt="var(--ago-radius, 16px)",Pe="var(--ago-message-radius, 16px)",Jt="var(--ago-message-radius, 20px)";function en(t,o){if(o)for(const i of Object.keys(gt)){const r=o[i];r!=null&&t.style.setProperty(gt[i],r)}}function v(t,o){Object.assign(t.style,o)}function h(t={}){const o=document.createElement("div");return v(o,t),o}var bt="ago-chat-widget-keyframes";function tn(){if(typeof document>"u"||document.getElementById(bt))return;const t=document.createElement("style");t.id=bt,t.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }",document.head.appendChild(t)}function nn(t){let o=[];const i=document.createElement("form");v(i,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${N}`,backgroundColor:te}),i.className="ago-chat-input";const r=h({display:"flex",flexWrap:"wrap",gap:"6px"}),b=h({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=t.placeholder,a.setAttribute("aria-label",t.placeholder),a.rows=1,v(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${N}`,borderRadius:"12px",fontSize:"16px",fontFamily:Ie,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const C=()=>{a.style.height="auto";const c=Math.min(a.scrollHeight+2,110);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{C(),I()});const m='<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',x='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,v(p,{flexShrink:"0",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:_e,color:Le,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let f=!1;const I=()=>{const l=a.value.trim()!==""||o.length>0,c=f||!l;p.disabled=c,p.innerHTML=f?x:m,p.style.opacity=c&&!f?"0.5":"1",p.style.cursor=c?"default":"pointer"};let R=null,A=null;t.allowFiles&&(R=document.createElement("input"),R.type="file",R.multiple=!0,v(R,{display:"none"}),A=document.createElement("button"),A.type="button",A.setAttribute("aria-label","Attach file"),A.textContent="📎",v(A,{padding:"10px 12px",border:`1px solid ${N}`,borderRadius:"12px",backgroundColor:te,cursor:"pointer",fontSize:"14px"}),A.addEventListener("click",()=>R?.click()),R.addEventListener("change",()=>{o=[...o,...Array.from(R?.files??[])],Q()}));function Q(){r.replaceChildren(),o.forEach((l,c)=>{const w=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${N}`,borderRadius:"8px",fontSize:"12px"}),B=document.createElement("span");B.textContent=l.name;const k=document.createElement("button");k.type="button",k.setAttribute("aria-label",`Remove ${l.name}`),k.textContent="×",v(k,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),k.addEventListener("click",()=>{o=o.filter((j,V)=>V!==c),Q()}),w.append(B,k),r.appendChild(w)}),I()}const D=()=>{const l=a.value,c=o;return a.value="",C(),o=[],Q(),{content:l,files:c}},g=()=>{const{content:l,files:c}=D();(l.trim()||c.length>0)&&t.onSend(l.trim(),c.length>0?c:void 0)};return i.addEventListener("submit",l=>{l.preventDefault(),g()}),a.addEventListener("keydown",l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),g())}),A&&b.appendChild(A),b.append(a,p),R&&i.appendChild(R),i.append(r,b),I(),{inputRow:i,getValueAndClear:D,setDisabled:l=>{a.disabled=l,f=l,I()},focus:()=>a.focus()}}var on={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ae(t){return t.replace(/[&<>"']/g,o=>on[o])}function vt(t){const o=t.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var St='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Re="";function ne(t){const o=[],i=b=>(o.push(b),`${Re}${o.length-1}${Re}`);let r=t;return r=r.replace(/`([^`]+)`/g,(b,a)=>i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${St}">${ae(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=vt(C);return m?i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):b}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=vt(C);return m?i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ne(a)}</a>`):b}),r=ae(r),r=r.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),r=r.replace(new RegExp(`${Re}(\\d+)${Re}`,"g"),(b,a)=>o[Number(a)]),r}function O(t,o,i){const r=document.createElement(t);return Object.assign(r.style,o),i!==void 0&&(r.innerHTML=i),r}var Rt=/^ {0,3}([-*_])( *\1){2,} *$/,kt=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,It=/^ {0,3}(```+|~~~+)/,Ae=/^ {0,3}>\s?/,le=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,rn=["20px","18px","16px","15px","14px","13px"],He=t=>t.match(/^\s*/)?.[0].length??0;function an(t){return t.trim()===""||Rt.test(t)||kt.test(t)||It.test(t)||Ae.test(t)||le.test(t)}function At(t){const o=t[0].match(le),i=o[1].length,r=/\d/.test(o[2]),b=O(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<t.length;){const C=t[a].match(le),m=[];for(a++;a<t.length&&He(t[a])>i;)m.push(t[a]),a++;const x=O("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),p=C[3].match(/^\[([ xX])\]\s+(.*)$/);p?(x.style.listStyleType="none",x.style.marginLeft="-20px",x.innerHTML=`<span style="margin-right:6px">${p[1].toLowerCase()==="x"?"☑":"☐"}</span>${ne(p[2])}`):x.innerHTML=ne(C[3]),m.filter(f=>le.test(f)).length>0&&x.appendChild(At(m.filter(f=>f.trim()!==""))),b.appendChild(x)}return b}function sn(t){const o=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(x=>x.trim()),i=O("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=O("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),b=document.createElement("thead"),a=document.createElement("tr");for(const m of o(t[0]))a.appendChild(O("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},ne(m)));b.appendChild(a),r.appendChild(b);const C=document.createElement("tbody");for(const m of t.slice(2)){const x=document.createElement("tr");for(const p of o(m))x.appendChild(O("td",{border:"1px solid #dee3e8",padding:"6px 10px"},ne(p)));C.appendChild(x)}return r.appendChild(C),i.appendChild(r),i}var ln=t=>!!t&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(t);function Ne(t){const o=document.createDocumentFragment(),i=t.replace(/\r\n?/g,`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("./AgoClient-BGkFSNZF.cjs"),Xt=require("./createConversationSession-BCb0D6bt.cjs"),mt=require("./createFormCollector-t_fGyuTD.cjs");var Yt='"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',Ie=`var(--ago-font, ${Yt})`,gt={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},_e="var(--ago-brand-color, #03182f)",Le="var(--ago-brand-text-color, #fff)",Qt="var(--ago-header-background, var(--ago-brand-color, #03182f))",ht="var(--ago-header-text-color, #e8f0fe)",te="var(--ago-panel-background, #fff)",Ct="var(--ago-messages-background, #fbfbfb)",ee="var(--ago-text-color, #30373e)",Et="var(--ago-muted-text-color, #6b6d6f)",N="var(--ago-border-color, #dee3e8)",Fe="var(--ago-accent-color, #1b5fc4)",xt="var(--ago-agent-bubble-background, #f1f3f5)",Zt="var(--ago-radius, 16px)",Pe="var(--ago-message-radius, 16px)",Jt="var(--ago-message-radius, 20px)";function en(t,o){if(o)for(const i of Object.keys(gt)){const r=o[i];r!=null&&t.style.setProperty(gt[i],r)}}function v(t,o){Object.assign(t.style,o)}function h(t={}){const o=document.createElement("div");return v(o,t),o}var bt="ago-chat-widget-keyframes";function tn(){if(typeof document>"u"||document.getElementById(bt))return;const t=document.createElement("style");t.id=bt,t.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }",document.head.appendChild(t)}function nn(t){let o=[];const i=document.createElement("form");v(i,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${N}`,backgroundColor:te}),i.className="ago-chat-input";const r=h({display:"flex",flexWrap:"wrap",gap:"6px"}),b=h({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=t.placeholder,a.setAttribute("aria-label",t.placeholder),a.rows=1,v(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${N}`,borderRadius:"12px",fontSize:"16px",fontFamily:Ie,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const C=()=>{a.style.height="auto";const c=Math.min(a.scrollHeight+2,110);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{C(),I()});const m='<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',x='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,v(p,{flexShrink:"0",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:_e,color:Le,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let f=!1;const I=()=>{const l=a.value.trim()!==""||o.length>0,c=f||!l;p.disabled=c,p.innerHTML=f?x:m,p.style.opacity=c&&!f?"0.5":"1",p.style.cursor=c?"default":"pointer"};let R=null,A=null;t.allowFiles&&(R=document.createElement("input"),R.type="file",R.multiple=!0,v(R,{display:"none"}),A=document.createElement("button"),A.type="button",A.setAttribute("aria-label","Attach file"),A.textContent="📎",v(A,{padding:"10px 12px",border:`1px solid ${N}`,borderRadius:"12px",backgroundColor:te,cursor:"pointer",fontSize:"14px"}),A.addEventListener("click",()=>R?.click()),R.addEventListener("change",()=>{o=[...o,...Array.from(R?.files??[])],Q()}));function Q(){r.replaceChildren(),o.forEach((l,c)=>{const w=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${N}`,borderRadius:"8px",fontSize:"12px"}),B=document.createElement("span");B.textContent=l.name;const k=document.createElement("button");k.type="button",k.setAttribute("aria-label",`Remove ${l.name}`),k.textContent="×",v(k,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),k.addEventListener("click",()=>{o=o.filter((j,V)=>V!==c),Q()}),w.append(B,k),r.appendChild(w)}),I()}const D=()=>{const l=a.value,c=o;return a.value="",C(),o=[],Q(),{content:l,files:c}},g=()=>{const{content:l,files:c}=D();(l.trim()||c.length>0)&&t.onSend(l.trim(),c.length>0?c:void 0)};return i.addEventListener("submit",l=>{l.preventDefault(),g()}),a.addEventListener("keydown",l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),g())}),A&&b.appendChild(A),b.append(a,p),R&&i.appendChild(R),i.append(r,b),I(),{inputRow:i,getValueAndClear:D,setDisabled:l=>{a.disabled=l,f=l,I()},focus:()=>a.focus()}}var on={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ae(t){return t.replace(/[&<>"']/g,o=>on[o])}function vt(t){const o=t.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var St='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Re="";function ne(t){const o=[],i=b=>(o.push(b),`${Re}${o.length-1}${Re}`);let r=t;return r=r.replace(/`([^`]+)`/g,(b,a)=>i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${St}">${ae(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=vt(C);return m?i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):b}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=vt(C);return m?i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ne(a)}</a>`):b}),r=ae(r),r=r.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),r=r.replace(new RegExp(`${Re}(\\d+)${Re}`,"g"),(b,a)=>o[Number(a)]),r}function O(t,o,i){const r=document.createElement(t);return Object.assign(r.style,o),i!==void 0&&(r.innerHTML=i),r}var Rt=/^ {0,3}([-*_])( *\1){2,} *$/,kt=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,It=/^ {0,3}(```+|~~~+)/,Ae=/^ {0,3}>\s?/,le=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,rn=["20px","18px","16px","15px","14px","13px"],He=t=>t.match(/^\s*/)?.[0].length??0;function an(t){return t.trim()===""||Rt.test(t)||kt.test(t)||It.test(t)||Ae.test(t)||le.test(t)}function At(t){const o=t[0].match(le),i=o[1].length,r=/\d/.test(o[2]),b=O(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<t.length;){const C=t[a].match(le),m=[];for(a++;a<t.length&&He(t[a])>i;)m.push(t[a]),a++;const x=O("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),p=C[3].match(/^\[([ xX])\]\s+(.*)$/);p?(x.style.listStyleType="none",x.style.marginLeft="-20px",x.innerHTML=`<span style="margin-right:6px">${p[1].toLowerCase()==="x"?"☑":"☐"}</span>${ne(p[2])}`):x.innerHTML=ne(C[3]),m.filter(f=>le.test(f)).length>0&&x.appendChild(At(m.filter(f=>f.trim()!==""))),b.appendChild(x)}return b}function sn(t){const o=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(x=>x.trim()),i=O("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=O("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),b=document.createElement("thead"),a=document.createElement("tr");for(const m of o(t[0]))a.appendChild(O("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},ne(m)));b.appendChild(a),r.appendChild(b);const C=document.createElement("tbody");for(const m of t.slice(2)){const x=document.createElement("tr");for(const p of o(m))x.appendChild(O("td",{border:"1px solid #dee3e8",padding:"6px 10px"},ne(p)));C.appendChild(x)}return r.appendChild(C),i.appendChild(r),i}var ln=t=>!!t&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(t);function Ne(t){const o=document.createDocumentFragment(),i=t.replace(/\r\n?/g,`
2
2
  `).split(`
3
3
  `);let r=0;for(;r<i.length;){const a=i[r];if(a.trim()===""){r++;continue}const C=a.match(It);if(C){const p=C[1][0],f=[];for(r++;r<i.length&&!new RegExp(`^ {0,3}${p==="`"?"`{3,}":"~{3,}"}\\s*$`).test(i[r]);)f.push(i[r]),r++;r++;const I=O("pre",{margin:"0 0 8px 0"});I.appendChild(O("code",{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:St,whiteSpace:"pre"},ae(f.join(`
4
4
  `)))),o.appendChild(I);continue}if(Rt.test(a)){o.appendChild(O("hr",{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"})),r++;continue}const m=a.match(kt);if(m){const p=m[1].length;o.appendChild(O(`h${p}`,{margin:"16px 0 8px 0",fontSize:rn[p-1],fontWeight:"600",lineHeight:"1.3"},ne(m[2]))),r++;continue}if(Ae.test(a)){const p=[];for(;r<i.length&&Ae.test(i[r]);)p.push(i[r].replace(Ae,"")),r++;const f=O("blockquote",{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"});f.appendChild(Ne(p.join(`