@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.
- package/dist/AgoClient-BGkFSNZF.cjs +8 -0
- package/dist/AgoClient-CW-BLT1_.js +1542 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +311 -0
- package/dist/angular.d.ts +311 -0
- package/dist/angular.js +2 -2
- package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
- package/dist/{createConversationSession-DPrrr70o.js → createConversationSession-C7cnnWKW.js} +3 -3
- package/dist/createFormCollector-iCDwAwYJ.js +279 -0
- package/dist/createFormCollector-t_fGyuTD.cjs +1 -0
- package/dist/createMockClient-Br0TWgLO.js +97 -0
- package/dist/createMockClient-BwNLPjeT.cjs +1 -0
- package/dist/devtools.d.cts +311 -0
- package/dist/devtools.d.ts +311 -0
- package/dist/functions-IGSjjvF4.cjs +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +510 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +95 -90
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +375 -0
- package/dist/react.d.ts +375 -0
- package/dist/react.js +559 -422
- package/dist/rolldown-runtime-16Nf8qvH.cjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +311 -0
- package/dist/testing.d.ts +311 -0
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +332 -0
- package/dist/vue.d.ts +332 -0
- package/dist/vue.js +133 -110
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +308 -0
- package/dist/widget.d.ts +308 -0
- package/dist/widget.js +7 -7
- package/package.json +1 -1
- package/dist/AgoClient-5VGybmvz.cjs +0 -8
- package/dist/AgoClient-DXrH2AMi.js +0 -964
- package/dist/createConversationSession-0WTqcCLK.cjs +0 -1
- package/dist/createFormCollector-1GKKwQV_.cjs +0 -1
- package/dist/createFormCollector-DYh90kiG.js +0 -305
- package/dist/createMockClient-C-wrjb2C.cjs +0 -1
- package/dist/createMockClient-we-XoPom.js +0 -79
- package/dist/functions-CPs7omgM.cjs +0 -1
- /package/dist/{autoContinue-CP9pJR-V.cjs → autoContinue-CcCTva-D.cjs} +0 -0
- /package/dist/{autoContinue-CC8K9mBU.js → autoContinue-D3Mmaaca.js} +0 -0
- /package/dist/{functions-tzyOZNp6.js → functions-CApuQZ2b.js} +0 -0
package/dist/vue.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { computed as
|
|
3
|
-
var N = /* @__PURE__ */ Symbol("ago-client"), b = { install(t,
|
|
4
|
-
const
|
|
5
|
-
t.provide(N,
|
|
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
|
|
8
|
-
if (t) return new
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
return
|
|
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
|
|
14
|
-
const
|
|
15
|
-
s.value || (s.value =
|
|
16
|
-
},
|
|
17
|
-
const i =
|
|
18
|
-
i >= 0 && (
|
|
19
|
-
...
|
|
20
|
-
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
|
-
},
|
|
23
|
-
const i =
|
|
24
|
-
i >= 0 ?
|
|
25
|
-
},
|
|
26
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
}),
|
|
31
|
-
|
|
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
|
|
34
|
-
|
|
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:
|
|
38
|
+
content: a,
|
|
39
39
|
role: "user",
|
|
40
40
|
status: "DONE",
|
|
41
41
|
createdAt: /* @__PURE__ */ new Date()
|
|
42
|
-
},
|
|
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
|
-
|
|
50
|
+
n.value.push(v, L);
|
|
51
51
|
try {
|
|
52
|
-
const u = await
|
|
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),
|
|
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
|
|
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
|
|
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
|
-
|
|
68
|
+
n.value = [], s.value = void 0, r.value = null;
|
|
69
69
|
}
|
|
70
70
|
return {
|
|
71
|
-
messages:
|
|
72
|
-
isLoading:
|
|
73
|
-
error:
|
|
71
|
+
messages: n,
|
|
72
|
+
isLoading: o,
|
|
73
|
+
error: r,
|
|
74
74
|
conversationId: s,
|
|
75
|
-
sendMessage:
|
|
75
|
+
sendMessage: g,
|
|
76
76
|
clearMessages: w
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
function P(t = {}) {
|
|
80
|
-
const
|
|
81
|
-
async function
|
|
82
|
-
|
|
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
|
|
85
|
-
} catch (
|
|
86
|
-
|
|
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
|
-
|
|
88
|
+
r.value = !1;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
async function
|
|
92
|
-
|
|
91
|
+
async function h(g) {
|
|
92
|
+
r.value = !0, c.value = null;
|
|
93
93
|
try {
|
|
94
|
-
|
|
94
|
+
o.value = await e.getConversation(g);
|
|
95
95
|
} catch (w) {
|
|
96
|
-
|
|
96
|
+
c.value = w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation");
|
|
97
97
|
} finally {
|
|
98
|
-
|
|
98
|
+
r.value = !1;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
101
|
+
function C() {
|
|
102
|
+
o.value = null;
|
|
103
103
|
}
|
|
104
|
-
return
|
|
105
|
-
|
|
104
|
+
return d(() => {
|
|
105
|
+
n && p();
|
|
106
106
|
}), {
|
|
107
107
|
conversations: s,
|
|
108
|
-
currentConversation:
|
|
109
|
-
isLoading:
|
|
110
|
-
error:
|
|
111
|
-
selectConversation:
|
|
112
|
-
startNewConversation:
|
|
113
|
-
refreshConversations:
|
|
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
|
|
117
|
+
const e = R({
|
|
118
118
|
client: t.client,
|
|
119
119
|
conversationId: t.conversationId
|
|
120
|
-
}),
|
|
120
|
+
}), n = P({
|
|
121
121
|
client: t.client,
|
|
122
122
|
autoLoad: t.autoLoad
|
|
123
|
-
}), s =
|
|
123
|
+
}), s = M(() => e.error.value || n.error.value);
|
|
124
124
|
return {
|
|
125
|
-
messages:
|
|
126
|
-
isLoading:
|
|
125
|
+
messages: e.messages,
|
|
126
|
+
isLoading: e.isLoading,
|
|
127
127
|
error: s,
|
|
128
|
-
sendMessage:
|
|
129
|
-
clearMessages:
|
|
130
|
-
conversationId:
|
|
131
|
-
conversations:
|
|
132
|
-
currentConversation:
|
|
133
|
-
isConversationsLoading:
|
|
134
|
-
selectConversation:
|
|
135
|
-
startNewConversation:
|
|
136
|
-
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,
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
description:
|
|
144
|
-
parameters:
|
|
145
|
-
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
|
-
}),
|
|
148
|
-
|
|
147
|
+
}), m(() => {
|
|
148
|
+
n.unregisterFunction(t);
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
function _(t,
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}),
|
|
156
|
-
|
|
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,
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}),
|
|
164
|
-
|
|
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,
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}),
|
|
172
|
-
|
|
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
|
|
177
|
-
return
|
|
178
|
-
|
|
179
|
-
})),
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
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={"&":"&","<":"<",">":">",'"':""","'":"'"};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(`
|