@kubed.io/cdn 0.0.1 → 0.0.4

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 (62) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +33 -5
  3. package/dist/chunks/define-XzEniRJH.js +10 -0
  4. package/dist/chunks/define-XzEniRJH.js.map +1 -0
  5. package/dist/chunks/element-ChNBLJ5X.js +632 -0
  6. package/dist/chunks/element-ChNBLJ5X.js.map +1 -0
  7. package/dist/chunks/kd-Bbw0GeQ5.js +1149 -0
  8. package/dist/chunks/kd-Bbw0GeQ5.js.map +1 -0
  9. package/dist/chunks/scene-CUr0fSXC.js +240 -0
  10. package/dist/chunks/scene-CUr0fSXC.js.map +1 -0
  11. package/dist/k8s/elements/events.d.ts +54 -0
  12. package/dist/k8s/elements/object.d.ts +47 -0
  13. package/dist/k8s/elements/ref.d.ts +45 -0
  14. package/dist/k8s/events.d.ts +63 -0
  15. package/dist/k8s/icons.d.ts +18 -0
  16. package/dist/k8s/index.d.ts +13 -0
  17. package/dist/k8s/links.d.ts +72 -0
  18. package/dist/k8s/map.d.ts +114 -0
  19. package/dist/k8s.js +909 -0
  20. package/dist/k8s.js.map +1 -0
  21. package/dist/kd/cell.d.ts +45 -0
  22. package/dist/kd/define.d.ts +0 -0
  23. package/dist/kd/element.d.ts +32 -0
  24. package/dist/kd/elements/bar.d.ts +33 -0
  25. package/dist/kd/elements/data.d.ts +27 -0
  26. package/dist/kd/elements/groups.d.ts +32 -0
  27. package/dist/kd/elements/link.d.ts +67 -0
  28. package/dist/kd/elements/mask.d.ts +22 -0
  29. package/dist/kd/elements/meter.d.ts +37 -0
  30. package/dist/kd/elements/pill.d.ts +15 -0
  31. package/dist/kd/elements/sheet.d.ts +28 -0
  32. package/dist/kd/elements/steps.d.ts +30 -0
  33. package/dist/kd/elements/table.d.ts +38 -0
  34. package/dist/kd/elements/tabs.d.ts +27 -0
  35. package/dist/kd/elements/tile.d.ts +19 -0
  36. package/dist/kd/helpers.d.ts +12 -0
  37. package/dist/kd/index.d.ts +30 -0
  38. package/dist/kd/parts.d.ts +15 -0
  39. package/dist/kd/scene.d.ts +178 -0
  40. package/dist/kd/theme.d.ts +2 -0
  41. package/dist/kd/yaml.d.ts +17 -0
  42. package/dist/kd.css +0 -0
  43. package/dist/kd.js +5 -64
  44. package/dist/n8n/config.d.ts +57 -0
  45. package/dist/n8n/fetch.d.ts +35 -0
  46. package/dist/n8n/history.d.ts +8 -0
  47. package/dist/n8n/index.d.ts +8 -0
  48. package/dist/n8n/metadata.d.ts +10 -0
  49. package/dist/n8n/mount.d.ts +29 -0
  50. package/dist/n8n/state.d.ts +44 -0
  51. package/dist/n8n/stream.d.ts +17 -0
  52. package/dist/n8n/styles.d.ts +1 -0
  53. package/dist/n8n.js +384 -0
  54. package/dist/n8n.js.map +1 -0
  55. package/dist/openapi/describe.d.ts +20 -0
  56. package/dist/openapi/index.d.ts +6 -0
  57. package/dist/openapi/model.d.ts +154 -0
  58. package/dist/openapi/schema.d.ts +52 -0
  59. package/dist/openapi.js +504 -0
  60. package/dist/openapi.js.map +1 -0
  61. package/package.json +18 -2
  62. package/dist/kd.js.map +0 -1
package/dist/n8n.js ADDED
@@ -0,0 +1,384 @@
1
+ import { t as e } from "./chunks/define-XzEniRJH.js";
2
+ import { _ as t, a as n, c as r, d as i, f as a, h as o, i as s, n as c, o as l, s as u, u as d } from "./chunks/scene-CUr0fSXC.js";
3
+ //#region src/n8n/config.ts
4
+ var f = "1.39.2";
5
+ function p(e) {
6
+ return typeof e == "string" ? e.startsWith("${") ? "" : e : "";
7
+ }
8
+ function m(e) {
9
+ return e.split(",").map((e) => e.trim()).filter(Boolean);
10
+ }
11
+ function h(e) {
12
+ let t = {};
13
+ for (let n of e.split("|")) {
14
+ let e = n.indexOf("=");
15
+ e > 0 && (t[n.slice(0, e).trim().toLowerCase()] = n.slice(e + 1).trim());
16
+ }
17
+ return t;
18
+ }
19
+ function g(e) {
20
+ return {
21
+ icon: p(e.icon),
22
+ label: p(e.label),
23
+ link: p(e.link),
24
+ webhook: p(e.webhook).trim(),
25
+ title: p(e.title),
26
+ subtitle: p(e.subtitle),
27
+ greeting: p(e.greeting).split("|").map((e) => e.trim()).filter(Boolean),
28
+ context: m(p(e.context)).map((e) => {
29
+ if (!e.includes("=")) return [e, e];
30
+ let [t, n] = e.split("=").map((e) => e.trim());
31
+ return [t, n];
32
+ }),
33
+ settable: m(p(e.settable)),
34
+ groups: h(p(e.groups)),
35
+ stream: e.stream === !0 || p(e.stream) === "true",
36
+ user: p(e.user),
37
+ auth: p(e.auth),
38
+ chatVersion: p(e.chatVersion).trim() || "1.39.2"
39
+ };
40
+ }
41
+ //#endregion
42
+ //#region src/n8n/fetch.ts
43
+ function _(e) {
44
+ if (e.n8nChatFetchWrapped) return;
45
+ e.n8nChatFetchWrapped = !0;
46
+ let t = e.fetch.bind(e);
47
+ e.fetch = async (n, r) => {
48
+ let i = await t(n, r), a = e.n8nChat, o = typeof n == "string" ? n : n instanceof URL ? n.href : String(n?.url ?? ""), s = typeof r?.body == "string" ? r.body : "";
49
+ if (!a || !a.webhook || !o.includes(a.webhook)) return i;
50
+ if (s.includes("\"sendMessage\"")) return a.stream && i.body ? new Response(a.filterStream(i.body), {
51
+ status: i.status,
52
+ statusText: i.statusText,
53
+ headers: i.headers
54
+ }) : (a.settable.length && i.clone().json().then((e) => {
55
+ let t = e?.dashboard_variables;
56
+ typeof t == "string" && (t = JSON.parse(t)), a.setVariables(t, a.settable);
57
+ }).catch(() => {}), i);
58
+ if (s.includes("\"loadPreviousSession\"")) try {
59
+ let e = a.cleanHistory(await i.clone().json());
60
+ return new Response(JSON.stringify(e), {
61
+ status: i.status,
62
+ headers: i.headers
63
+ });
64
+ } catch {
65
+ return i;
66
+ }
67
+ return i;
68
+ };
69
+ }
70
+ //#endregion
71
+ //#region src/n8n/history.ts
72
+ var v = [
73
+ "ToolMessage",
74
+ "SystemMessage",
75
+ "FunctionMessage"
76
+ ];
77
+ function y(e) {
78
+ return typeof e == "string" ? e : Array.isArray(e) ? e.map((e) => typeof e == "string" ? e : e?.text || "").join("") : "";
79
+ }
80
+ function b(e) {
81
+ return Array.isArray(e?.id) ? String(e.id[e.id.length - 1]) : "";
82
+ }
83
+ function x(e) {
84
+ let t = e?.data;
85
+ if (!Array.isArray(t)) return e;
86
+ let n = t.flatMap((e) => {
87
+ if (v.includes(b(e))) return [];
88
+ let t = y(e?.kwargs?.content);
89
+ return t.trim() ? [{
90
+ ...e,
91
+ kwargs: {
92
+ ...e.kwargs,
93
+ content: t
94
+ }
95
+ }] : [];
96
+ });
97
+ return {
98
+ ...e,
99
+ data: n
100
+ };
101
+ }
102
+ //#endregion
103
+ //#region src/n8n/metadata.ts
104
+ function S(e, t) {
105
+ return e.map((e) => {
106
+ let n = `${e.panels.length} ${e.panels.length === 1 ? "panel" : "panels"}`, r = `- ${e.name} (${e.kind}, ${n}${e.open ? ", OPEN" : ""}${e.focusable ? "" : ", pinned"})`, i = t[e.name.toLowerCase()];
107
+ return i ? `${r}: ${i}` : r;
108
+ }).join("\n");
109
+ }
110
+ function C(e, i, a) {
111
+ let c = {
112
+ dashboard: a.split("/")[2] || "unknown",
113
+ user: i.user,
114
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
115
+ }, l = (e, t) => {
116
+ Object.defineProperty(c, e, {
117
+ enumerable: !0,
118
+ configurable: !0,
119
+ get: t
120
+ });
121
+ };
122
+ l("dashboardUrl", () => e.location.href), l("timestamp", () => (/* @__PURE__ */ new Date()).toISOString()), l("timeFrom", () => o(e)?.from ?? ""), l("timeTo", () => o(e)?.to ?? ""), l("timeFromIso", () => o(e)?.fromIso ?? ""), l("timeToIso", () => o(e)?.toIso ?? ""), l("refresh", () => {
123
+ let t = u(e);
124
+ return t === null ? "" : t || "off";
125
+ }), l("refreshSeconds", () => n(u(e))), l("refreshIntervals", () => r(e).join(",")), l("groups", () => S(s(e), i.groups)), l("openGroups", () => s(e).filter((e) => e.open && e.focusable).map((e) => e.name).join(", "));
126
+ for (let [n, r] of i.context) l(n, () => t(e, r));
127
+ return c;
128
+ }
129
+ //#endregion
130
+ //#region src/n8n/state.ts
131
+ var w = [
132
+ "time_from",
133
+ "time_to",
134
+ "refresh",
135
+ "focus"
136
+ ], T = {
137
+ timeFrom: "time_from",
138
+ timeTo: "time_to"
139
+ }, E = ["", ".*"];
140
+ function D(e, t) {
141
+ let n = {}, r = null, i = null;
142
+ for (let a of e?.tools ?? []) for (let [e, o] of Object.entries(a?.args ?? {})) if (!(o == null || E.includes(String(o)))) {
143
+ if (e === "panelId") i = String(o);
144
+ else if (e === "focus") r = String(o);
145
+ else {
146
+ let r = T[e] ?? e;
147
+ t.includes(r) && (n[r] = String(o));
148
+ }
149
+ }
150
+ return n.time_from && !n.time_to && (n.time_to = "now"), {
151
+ vars: n,
152
+ focus: t.includes("focus") ? r ?? i : null
153
+ };
154
+ }
155
+ function O(e, t, n) {
156
+ let r = {};
157
+ if (!t || typeof t != "object") return r;
158
+ let o = null, s = null;
159
+ for (let i of n) {
160
+ let n = t[i];
161
+ if (n != null && n !== "") {
162
+ if (i === "time_from") o = String(n);
163
+ else if (i === "time_to") s = String(n);
164
+ else if (i === "refresh") {
165
+ let t = d(e, String(n));
166
+ t !== null && (r.refresh = t);
167
+ } else if (i !== "focus") {
168
+ let t = a(e, i, n);
169
+ t !== null && (r[i] = t);
170
+ }
171
+ }
172
+ }
173
+ if (o || s) {
174
+ let t = i(e, o, s);
175
+ t && (r.time_from = t.from, r.time_to = t.to);
176
+ }
177
+ return r;
178
+ }
179
+ function k(e, t, n, r) {
180
+ let i = [];
181
+ (t.time_from || t.time_to) && i.push(["time", `${t.time_from || "now"} → ${t.time_to || "now"}`]);
182
+ for (let [e, n] of Object.entries(t)) e !== "time_from" && e !== "time_to" && i.push([e, n]);
183
+ if (!i.length && !n) return null;
184
+ let a = e.createElement("div");
185
+ a.className = "n8n-chat-state";
186
+ let o = e.createElement("span");
187
+ o.className = "ncs-head", o.textContent = n && !i.length ? "Moved your dashboard" : "Changed your dashboard", a.append(o);
188
+ let s = (t, n, r) => {
189
+ let i = e.createElement(t);
190
+ i.className = t === "button" ? "ncs-chip ncs-go" : "ncs-chip", t === "button" && (i.type = "button");
191
+ let o = e.createElement("b");
192
+ o.textContent = n;
193
+ let s = e.createElement("i");
194
+ return s.textContent = r, i.append(o, s), a.append(i), i;
195
+ };
196
+ for (let [e, t] of i) s("span", e, t);
197
+ if (n) {
198
+ let e = n.panel == null ? n.group : `${n.group} · panel ${n.panel}`, t = s("button", n.kind === "tab" ? "tab" : "section", e);
199
+ t.title = "Show me that again", t.addEventListener("click", () => r(n.panel == null ? n.group : String(n.panel)));
200
+ }
201
+ return a;
202
+ }
203
+ function A(e, t) {
204
+ let n = e.querySelectorAll(".chat-message-from-bot"), r = n.length ? n[n.length - 1] : e.querySelector(".chat-messages-list") || e.querySelector(".chat-body");
205
+ return r ? (t.classList.toggle("ncs-loose", !n.length), r.append(t), t.scrollIntoView?.({ block: "nearest" }), !0) : !1;
206
+ }
207
+ function j(e, t, n) {
208
+ if (!n.length) return;
209
+ let r = D(t, n), i = Object.keys(r.vars).length ? O(e, r.vars, n) : {}, a = r.focus ? c(e, r.focus) : null, o = l(e);
210
+ if (!o) return;
211
+ let s = k(o.document, i, a, (e) => c(o, e));
212
+ s && o.setTimeout(() => A(o.document, s), 150);
213
+ }
214
+ //#endregion
215
+ //#region src/n8n/stream.ts
216
+ var M = "Dashboard State";
217
+ function N(e, t = M) {
218
+ let n = new TextDecoder(), r = new TextEncoder(), i = "", a = (n, i) => {
219
+ if (!n.trim()) return;
220
+ let a;
221
+ try {
222
+ a = JSON.parse(n);
223
+ } catch {
224
+ i.enqueue(r.encode(n + "\n"));
225
+ return;
226
+ }
227
+ if (a?.metadata?.nodeName === t) {
228
+ if (a.type === "item" && a.content) try {
229
+ e(JSON.parse(a.content));
230
+ } catch (e) {
231
+ console.warn("[n8n-chat] unreadable control chunk", a.content, e);
232
+ }
233
+ } else i.enqueue(r.encode(n + "\n"));
234
+ };
235
+ return new TransformStream({
236
+ transform(e, t) {
237
+ i += n.decode(e, { stream: !0 });
238
+ let r = i.split("\n");
239
+ i = r.pop() ?? "";
240
+ for (let e of r) a(e, t);
241
+ },
242
+ flush(e) {
243
+ i += n.decode(), i.trim() && a(i, e);
244
+ }
245
+ });
246
+ }
247
+ var P = [
248
+ "[data-testid=\"public-dashboard-footer\"]{position:fixed!important;left:0;right:0;bottom:0}",
249
+ "#n8n-chat .chat-window-wrapper,.n8n-chat-widget{z-index:2147483647!important}",
250
+ "#n8n-chat{--n8n-chat-top:14px;--n8n-chat-reserve:92px;--chat--window--width:min(760px,calc(100vw - 2rem));--chat--window--height:max(320px,calc(100vh - var(--n8n-chat-top) - var(--n8n-chat-reserve)))}",
251
+ "#n8n-chat .chat-window-wrapper{top:var(--n8n-chat-top);justify-content:flex-end}",
252
+ "@media (max-width:900px){#n8n-chat{--chat--window--width:calc(100vw - 1.5rem);--chat--window--height:calc(100vh - 5rem)}}",
253
+ "#n8n-chat .chat-message-markdown{overflow-wrap:anywhere}",
254
+ "#n8n-chat .chat-message-from-bot{max-width:94%}",
255
+ "#n8n-chat .chat-message-markdown pre,#n8n-chat .chat-message-markdown table{display:block;max-width:100%;overflow-x:auto}",
256
+ "#n8n-chat .chat-message-markdown pre code{overflow-wrap:normal;white-space:pre}",
257
+ "#n8n-chat .chat-message-markdown table{border-collapse:collapse;font-size:12px;white-space:nowrap}",
258
+ "#n8n-chat .chat-message-markdown th,#n8n-chat .chat-message-markdown td{border:1px solid var(--chat--color-light-shade-100,#d4d8dd);padding:3px 8px;text-align:left}",
259
+ "#n8n-chat .chat-message-markdown img{max-width:100%;height:auto}",
260
+ "#n8n-chat{--chat--message--pre--background:#f6f8fa}",
261
+ "#n8n-chat .chat-message-markdown pre,#n8n-chat .chat-message-markdown code{color:#1f2328!important;background:#f6f8fa}",
262
+ "#n8n-chat .chat-message-markdown pre{border:1px solid #d0d7de}",
263
+ "#n8n-chat .chat-message-markdown :not(pre)>code{background:#eaeef2;border:1px solid #d0d7de;border-radius:4px;padding:1px 5px;font-size:.92em}",
264
+ "#n8n-chat textarea{background:#fff!important;color:#14161a!important;-webkit-text-fill-color:#14161a!important;caret-color:#14161a!important;border:1px solid #c7ccd1!important;opacity:1!important}",
265
+ "#n8n-chat textarea::placeholder{color:#6b7280!important;-webkit-text-fill-color:#6b7280!important;opacity:1!important}",
266
+ "#n8n-chat .chat-input-send-button{color:#14161a!important}",
267
+ ".n8n-chat-tile{display:block;text-align:center;text-decoration:none;padding-top:6px;color:inherit}",
268
+ ".n8n-chat-tile .icon{font-size:30px;line-height:1;height:30px}",
269
+ ".n8n-chat-tile img{height:30px}",
270
+ ".n8n-chat-tile .label{display:block;font-size:12px;font-weight:inherit;line-height:inherit;opacity:.75;margin-top:6px;padding:0;background:none;color:inherit;border-radius:0;text-shadow:none;white-space:normal}",
271
+ ".n8n-chat-state{display:flex;flex-wrap:wrap;align-items:center;gap:5px 6px;margin:10px 0 0;padding:8px 0 0;border-top:1px solid var(--chat--color-medium,#d2d4d9);color:var(--chat--color-dark,#101330);font-size:12px;line-height:1.4}",
272
+ ".n8n-chat-state.ncs-loose{margin:2px 0 10px;padding:8px 10px;border:1px solid var(--chat--color-medium,#d2d4d9);border-left:3px solid #5794f2;border-radius:4px;background:var(--chat--message--bot--background,#fff)}",
273
+ ".n8n-chat-state .ncs-head{width:100%;margin-bottom:2px;font-size:11px;font-weight:600;letter-spacing:.02em;opacity:.62}",
274
+ ".n8n-chat-state .ncs-chip{display:inline-flex;align-items:baseline;gap:6px;margin:0;padding:3px 9px;border-radius:11px;border:1px solid var(--chat--color-medium,#d2d4d9);background:var(--chat--color-light,#f2f4f8);font:inherit;color:inherit}",
275
+ ".n8n-chat-state .ncs-chip b{font-weight:600;font-size:10px;text-transform:uppercase;letter-spacing:.05em;opacity:.62}",
276
+ ".n8n-chat-state .ncs-chip i{font-style:normal}",
277
+ ".n8n-chat-state button.ncs-go{cursor:pointer}",
278
+ ".n8n-chat-state button.ncs-go:hover{border-color:#5794f2;background:rgba(87,148,242,.12)}"
279
+ ].join("\n"), F = (e) => `https://cdn.jsdelivr.net/npm/@n8n/chat@${e}/dist/chat.bundle.es.js`, I = (e) => `https://cdn.jsdelivr.net/npm/@n8n/chat@${e}/dist/style.css`, L = "[data-testid=\"data-testid dashboard controls\"]", R = 900;
280
+ function z(t) {
281
+ let n = t.head.querySelector("style[data-n8n-chat-tile]");
282
+ n?.dataset.n8nChatTile !== "0.0.4" && (n || (n = t.createElement("style"), t.head.append(n)), n.dataset.n8nChatTile = e, n.textContent = P);
283
+ }
284
+ function B(e, t) {
285
+ let n = I(t), r = e.head.querySelector("link[data-n8n-chat-style]");
286
+ r?.getAttribute("href") !== n && (r || (r = e.createElement("link"), r.rel = "stylesheet", r.setAttribute("data-n8n-chat-style", ""), e.head.append(r)), r.href = n);
287
+ }
288
+ function V(e, t) {
289
+ let n = /^https?:/.test(t.link);
290
+ if (e.localName === "kd-tile") {
291
+ for (let [n, r] of [
292
+ ["icon", t.icon],
293
+ ["label", t.label],
294
+ ["href", t.link]
295
+ ]) r ? e.setAttribute(n, r) : e.removeAttribute(n);
296
+ return;
297
+ }
298
+ let r = e.querySelector(".icon");
299
+ if (r) {
300
+ if (/^(https?:)?\//.test(t.icon)) {
301
+ let n = e.ownerDocument.createElement("img");
302
+ n.src = t.icon, n.alt = "", r.replaceChildren(n);
303
+ } else r.textContent = t.icon;
304
+ }
305
+ let i = e.querySelector(".label");
306
+ i && (i.textContent = t.label), t.link ? e.setAttribute("href", t.link) : e.removeAttribute("href"), n ? (e.setAttribute("target", "_blank"), e.setAttribute("rel", "noopener")) : (e.removeAttribute("target"), e.removeAttribute("rel"));
307
+ }
308
+ function H(e) {
309
+ let t = e.document, n = t.getElementById("n8n-chat");
310
+ if (!n) return;
311
+ let r = n.querySelector(".chat-window-wrapper"), i = t.querySelector(L)?.getBoundingClientRect();
312
+ if (!r || !i || !i.height || e.innerWidth <= R) {
313
+ n.style.removeProperty("--n8n-chat-top"), n.style.removeProperty("--n8n-chat-reserve");
314
+ return;
315
+ }
316
+ let a = e.getComputedStyle(r), o = n.querySelector(".chat-window-toggle"), s = (parseFloat(a.bottom) || 14) + (o ? o.getBoundingClientRect().height : 64) + (parseFloat(a.rowGap || a.gap) || 14);
317
+ n.style.setProperty("--n8n-chat-top", `${Math.round(i.bottom + 10)}px`), n.style.setProperty("--n8n-chat-reserve", `${Math.round(s)}px`);
318
+ }
319
+ function U(e) {
320
+ e.querySelectorAll("#n8n-chat, .n8n-chat-widget").forEach((e) => e.remove());
321
+ }
322
+ function W(e) {
323
+ let t = e.tile;
324
+ if (t && typeof t == "object") return {
325
+ win: e.window ?? t.ownerDocument.defaultView ?? window,
326
+ tile: t
327
+ };
328
+ let n = e.window ?? window;
329
+ return {
330
+ win: n,
331
+ tile: typeof t == "string" ? n.document.querySelector(t) : t === null ? null : n.document.getElementById("n8n-chat-tile")
332
+ };
333
+ }
334
+ var G = (e) => import(
335
+ /* @vite-ignore */
336
+ e
337
+ );
338
+ function K(e = {}, t = G) {
339
+ let { win: n, tile: r } = W(e), i = n.document, a = g(e);
340
+ if (z(i), r && V(r, a), n.dashboardFocus = (e) => c(n, e), !a.webhook) return U(i), n.clearInterval(n.n8nChatWatch), n.n8nChat = null, n.n8nChatMount = void 0, Promise.resolve();
341
+ let o = n.location.pathname, { auth: s, ...l } = a, u = JSON.stringify([o, l]), d = n.n8nChatMount;
342
+ if (d?.key === u && (!d.done || i.getElementById("n8n-chat"))) return d.ready;
343
+ U(i), n.clearInterval(n.n8nChatWatch), n.n8nChatWatch = n.setInterval(() => {
344
+ n.location.pathname === o ? n.n8nChatFit?.() : (U(i), n.clearInterval(n.n8nChatWatch), n.n8nChat = null, n.n8nChatMount = void 0);
345
+ }, 1e3), B(i, a.chatVersion), n.n8nChatResize || (n.n8nChatResize = !0, n.addEventListener("resize", () => n.n8nChatFit?.())), n.n8nChat = {
346
+ webhook: a.webhook,
347
+ settable: a.settable,
348
+ stream: a.stream,
349
+ setVariables: (e, t) => O(n, e, t),
350
+ cleanHistory: x,
351
+ filterStream: (e) => e.pipeThrough(N((e) => j(n, e, a.settable)))
352
+ }, _(n);
353
+ let f = {
354
+ key: u,
355
+ done: !1,
356
+ ready: Promise.resolve()
357
+ };
358
+ return n.n8nChatMount = f, f.ready = (async () => {
359
+ try {
360
+ let { createChat: e } = await t(F(a.chatVersion));
361
+ if (n.n8nChatMount !== f || n.location.pathname !== o) return;
362
+ n.n8nChatFit = () => H(n), e({
363
+ webhookUrl: a.webhook,
364
+ webhookConfig: { headers: a.auth ? { Authorization: a.auth } : {} },
365
+ chatSessionKey: "sessionId",
366
+ loadPreviousSession: !0,
367
+ enableStreaming: a.stream,
368
+ metadata: C(n, a, o),
369
+ showWelcomeScreen: !0,
370
+ initialMessages: a.greeting,
371
+ i18n: { en: {
372
+ title: a.title,
373
+ subtitle: a.subtitle
374
+ } }
375
+ }), n.setTimeout(() => n.n8nChatFit?.(), 200);
376
+ } finally {
377
+ f.done = !0;
378
+ }
379
+ })(), f.ready;
380
+ }
381
+ //#endregion
382
+ export { f as CHAT_VERSION, M as CONTROL_NODE, w as RESERVED, e as VERSION, O as applyState, j as applyToolCalls, F as chatBundle, C as chatMetadata, I as chatStyle, x as cleanHistory, N as controlFilter, S as describeGroups, V as fillTile, H as fitChat, z as injectStyles, K as mount, A as placeCard, D as readToolCalls, g as settings, k as stateCard };
383
+
384
+ //# sourceMappingURL=n8n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"n8n.js","names":["VERSION","variableValue","intervalSeconds","refreshIntervals","setTimeRange","setVariable","timeRange","groups","focusPanel","pageWindow","refresh","setRefresh","CHAT_VERSION","text","value","list","x","groupNotes","notes","part","eq","settings","config","pair","key","name","wrapFetch","win","base","response","input","init","chat","url","body","vars","reply","cleaned","HIDDEN","textOf","content","p","kindOf","m","cleanHistory","data","kept","describeGroups","count","g","head","note","chatMetadata","meta","home","s","live","r","RESERVED","ALIAS","NOT_A_VALUE","readToolCalls","asked","read","call","payload","settable","applyState","applied","values","from","to","set","page","raw","stateCard","chips","k","v","focused","card","doc","chip","el","tag","b","label","i","where","go","onGo","placeCard","bots","host","applyToolCalls","state","target","CONTROL_NODE","controlFilter","decoder","encoder","carry","pass","line","chunk","node","bytes","lines","out","STYLES","chatBundle","version","chatStyle","CONTROLS","NARROW","injectStyles","style","chatStylesheet","href","link","fillTile","external","tile","icon","img","fitChat","root","wrapper","box","cs","toggle","reserve","removeChat","pageOf","given","load","mount","_auth","visible","current","names","loader","createChat"],"sources":["../src/n8n/config.ts","../src/n8n/fetch.ts","../src/n8n/history.ts","../src/n8n/metadata.ts","../src/n8n/state.ts","../src/n8n/stream.ts","../src/n8n/styles.ts","../src/n8n/mount.ts"],"sourcesContent":["/**\n * What the library panel passes to `mount`: its `chat_*` constants (decoded),\n * the viewer, and the Authorization header. A field that arrives as a literal\n * `${...}` (a dashboard without that variable) reads as empty.\n */\nexport interface ChatConfig {\n /** An emoji, or an image URL. */\n icon?: string;\n label?: string;\n /** Where the tile goes; an http(s) link opens a new tab. */\n link?: string;\n /** The n8n Chat Trigger URL. Empty means tile only, and any leftover bubble is removed. */\n webhook?: string;\n title?: string;\n subtitle?: string;\n /** Greeting lines, split on `|`. */\n greeting?: string;\n /** Extra metadata as `key=variable` pairs, read live on every send: `pod=pod,database=datname`. */\n context?: string;\n /** The names the agent may set, in applied order. `time_from`, `time_to`, `refresh` and `focus` are reserved. */\n settable?: string;\n /** Each group's purpose, `Name=purpose` pairs joined by `|` (Grafana has no description on a tab or a row). */\n groups?: string;\n /** Stream the reply. Must match the Chat Trigger's responseMode, or nothing renders. */\n stream?: boolean | string;\n /** The viewer's login, sent as metadata. */\n user?: string;\n /** The Authorization header value. Kept in Grafana and passed in, never in this package. */\n auth?: string;\n /** The `@n8n/chat` version loaded from jsDelivr. */\n chatVersion?: string;\n /** The tile: an element, a selector, or by default `#n8n-chat-tile`. An `<a>` or a `<kd-tile>`. */\n tile?: Element | string | null;\n /** The page; by default the tile's, else the global window. */\n window?: Window;\n}\n\nexport const CHAT_VERSION = '1.39.2';\n\nexport interface Settings {\n icon: string;\n label: string;\n link: string;\n webhook: string;\n title: string;\n subtitle: string;\n greeting: string[];\n context: [key: string, variable: string][];\n settable: string[];\n groups: Record<string, string>;\n stream: boolean;\n user: string;\n auth: string;\n chatVersion: string;\n}\n\nfunction text(value: unknown): string {\n if (typeof value !== 'string') return '';\n return value.startsWith('${') ? '' : value;\n}\n\nexport function list(value: string): string[] {\n return value\n .split(',')\n .map((x) => x.trim())\n .filter(Boolean);\n}\n\n/** `Name=purpose|Other=purpose` -> lower-cased name to purpose. */\nexport function groupNotes(value: string): Record<string, string> {\n const notes: Record<string, string> = {};\n for (const part of value.split('|')) {\n const eq = part.indexOf('=');\n if (eq > 0) notes[part.slice(0, eq).trim().toLowerCase()] = part.slice(eq + 1).trim();\n }\n return notes;\n}\n\nexport function settings(config: ChatConfig): Settings {\n return {\n icon: text(config.icon),\n label: text(config.label),\n link: text(config.link),\n webhook: text(config.webhook).trim(),\n title: text(config.title),\n subtitle: text(config.subtitle),\n greeting: text(config.greeting)\n .split('|')\n .map((x) => x.trim())\n .filter(Boolean),\n context: list(text(config.context)).map((pair): [string, string] => {\n if (!pair.includes('=')) return [pair, pair];\n const [key, name] = pair.split('=').map((x) => x.trim());\n return [key, name];\n }),\n settable: list(text(config.settable)),\n groups: groupNotes(text(config.groups)),\n stream: config.stream === true || text(config.stream) === 'true',\n user: text(config.user),\n auth: text(config.auth),\n chatVersion: text(config.chatVersion).trim() || CHAT_VERSION,\n };\n}\n","import type { Focused } from '../kd/scene';\n\n/**\n * What the fetch wrapper acts for: the chat on screen. Kept on the page window\n * as `n8nChat` in the shape the pre-package library panel used, so a wrapper\n * installed by either one serves the other.\n */\nexport interface ChatHandle {\n webhook: string;\n settable: string[];\n stream: boolean;\n setVariables(vars: Record<string, unknown> | null | undefined, names: string[]): Record<string, string>;\n cleanHistory<T>(reply: T): T;\n filterStream(body: ReadableStream<Uint8Array>): ReadableStream<Uint8Array>;\n}\n\n/** The page globals the chat keeps. They outlive this module across SPA navigation and package versions. */\nexport interface ChatWindow extends Window {\n n8nChat?: ChatHandle | null;\n n8nChatWatch?: number;\n n8nChatFetchWrapped?: boolean;\n n8nChatFit?: () => void;\n n8nChatResize?: boolean;\n n8nChatMount?: { key: string; done: boolean; ready: Promise<void> };\n /** The resolver the agent navigates with, for the dashboard's own buttons (Torrent's use it). */\n dashboardFocus?: (target: string | number) => Focused | null;\n}\n\n/**\n * Wraps the page's fetch, once per page. The wrapper reads `n8nChat` on every\n * call, which each mount replaces, so it acts for the dashboard on screen and\n * only for its webhook.\n */\nexport function wrapFetch(win: ChatWindow): void {\n if (win.n8nChatFetchWrapped) return;\n win.n8nChatFetchWrapped = true;\n const base = win.fetch.bind(win);\n win.fetch = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n const response = await base(input, init);\n const chat = win.n8nChat;\n const url = typeof input === 'string' ? input : input instanceof URL ? input.href : String(input?.url ?? '');\n const body = typeof init?.body === 'string' ? init.body : '';\n if (!chat || !chat.webhook || !url.includes(chat.webhook)) return response;\n if (body.includes('\"sendMessage\"')) {\n // n8n sends the NDJSON stream as application/json too, so the setting\n // decides, not the content type. Filtered even with nothing settable: the\n // control chunk must never render as a message.\n if (chat.stream && response.body) {\n return new Response(chat.filterStream(response.body), {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n // responseMode lastNode: the variables ride on the JSON reply.\n if (chat.settable.length) {\n response\n .clone()\n .json()\n .then((reply: { dashboard_variables?: unknown }) => {\n let vars = reply?.dashboard_variables;\n if (typeof vars === 'string') vars = JSON.parse(vars);\n chat.setVariables(vars as Record<string, unknown>, chat.settable);\n })\n .catch(() => {});\n }\n return response;\n }\n if (body.includes('\"loadPreviousSession\"')) {\n try {\n const cleaned = chat.cleanHistory(await response.clone().json());\n return new Response(JSON.stringify(cleaned), { status: response.status, headers: response.headers });\n } catch {\n return response;\n }\n }\n return response;\n };\n}\n","interface StoredMessage {\n id?: unknown;\n kwargs?: { content?: unknown; [key: string]: unknown };\n [key: string]: unknown;\n}\n\n// LangChain tags each stored message's class in `id`, e.g.\n// ['langchain_core', 'messages', 'ToolMessage']; that is the only reliable\n// discriminator, as kwargs.type is absent on these.\nconst HIDDEN = ['ToolMessage', 'SystemMessage', 'FunctionMessage'];\n\nfunction textOf(content: unknown): string {\n if (typeof content === 'string') return content;\n if (!Array.isArray(content)) return '';\n return content.map((p) => (typeof p === 'string' ? p : (p as { text?: string } | null)?.text || '')).join('');\n}\n\nfunction kindOf(m: StoredMessage | null | undefined): string {\n return Array.isArray(m?.id) ? String(m.id[m.id.length - 1]) : '';\n}\n\n/**\n * Cleans a `loadPreviousSession` reply for the widget, whose markdown renderer\n * throws on anything but a string. Tool, system and function messages are\n * dropped (a tool message's content is the tool's raw JSON, a non-empty string\n * that would otherwise fill the reloaded chat); array content is flattened to\n * its text, and a message left with no text is dropped.\n */\nexport function cleanHistory<T>(reply: T): T {\n const data = (reply as { data?: unknown } | null)?.data;\n if (!Array.isArray(data)) return reply;\n const kept = (data as StoredMessage[]).flatMap((m) => {\n if (HIDDEN.includes(kindOf(m))) return [];\n const text = textOf(m?.kwargs?.content);\n return text.trim() ? [{ ...m, kwargs: { ...m.kwargs, content: text } }] : [];\n });\n return { ...reply, data: kept };\n}\n","import { groups, intervalSeconds, refresh, refreshIntervals, timeRange, variableValue, type Group } from '../kd/scene';\nimport type { Settings } from './config';\n\n/** The navigation map for the agent: one line per group, with its purpose from `chat_groups`. */\nexport function describeGroups(list: Group[], notes: Record<string, string>): string {\n return list\n .map((g) => {\n const count = `${g.panels.length} ${g.panels.length === 1 ? 'panel' : 'panels'}`;\n const head = `- ${g.name} (${g.kind}, ${count}${g.open ? ', OPEN' : ''}${g.focusable ? '' : ', pinned'})`;\n const note = notes[g.name.toLowerCase()];\n return note ? `${head}: ${note}` : head;\n })\n .join('\\n');\n}\n\n/**\n * The metadata sent with every message. @n8n/chat serialises this same object\n * on each send, so every live field is a getter: the agent hears about the\n * window, refresh and layout on screen at send time, not at page load.\n */\nexport function chatMetadata(win: Window, s: Settings, home: string): Record<string, unknown> {\n const meta: Record<string, unknown> = {\n dashboard: home.split('/')[2] || 'unknown',\n user: s.user,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n };\n const live = (key: string, get: () => unknown): void => {\n Object.defineProperty(meta, key, { enumerable: true, configurable: true, get });\n };\n live('dashboardUrl', () => win.location.href);\n live('timestamp', () => new Date().toISOString());\n // Raw is what to say to a person (\"now-24h\"); ISO is what a query needs.\n live('timeFrom', () => timeRange(win)?.from ?? '');\n live('timeTo', () => timeRange(win)?.to ?? '');\n live('timeFromIso', () => timeRange(win)?.fromIso ?? '');\n live('timeToIso', () => timeRange(win)?.toIso ?? '');\n live('refresh', () => {\n const r = refresh(win);\n return r === null ? '' : r || 'off';\n });\n live('refreshSeconds', () => intervalSeconds(refresh(win)));\n // The only intervals the picker accepts; anything else blanks it.\n live('refreshIntervals', () => refreshIntervals(win).join(','));\n live('groups', () => describeGroups(groups(win), s.groups));\n live('openGroups', () =>\n groups(win)\n .filter((g) => g.open && g.focusable)\n .map((g) => g.name)\n .join(', '),\n );\n for (const [key, name] of s.context) live(key, () => variableValue(win, name));\n return meta;\n}\n","import { focusPanel, pageWindow, setRefresh, setTimeRange, setVariable, type Focused, type Page } from '../kd/scene';\n\n/** Names in `chat_settable` that are not template variables. */\nexport const RESERVED = ['time_from', 'time_to', 'refresh', 'focus'];\n\n// The read tool spells the window timeFrom/timeTo; the picker's names are time_from/time_to.\nconst ALIAS: Record<string, string> = { timeFrom: 'time_from', timeTo: 'time_to' };\n\n// `.*` is the panel-data tool's \"all databases\" default; a dropdown's own\n// all-value is $__all, so `.*` would match no option. It means nothing to set.\nconst NOT_A_VALUE = ['', '.*'];\n\nexport interface ToolCalls {\n tools?: { args?: Record<string, unknown> | null }[];\n}\n\nexport interface DashboardState {\n /** Settable names to values; a later call in the turn wins. */\n vars: Record<string, string>;\n /** What to bring on screen: an explicit `focus`, else the last panel read. Null unless `focus` is settable. */\n focus: string | null;\n}\n\n/**\n * Maps a turn's tool calls onto the dashboard. An argument named like a\n * settable name IS that name, so no dashboard-specific mapping lives in n8n.\n * `panelId` is how the agent says which panel it read, so reading a panel is a\n * focus; an explicit `focus` argument beats it.\n */\nexport function readToolCalls(payload: ToolCalls | null | undefined, settable: string[]): DashboardState {\n const vars: Record<string, string> = {};\n let asked: string | null = null;\n let read: string | null = null;\n for (const call of payload?.tools ?? []) {\n for (const [key, value] of Object.entries(call?.args ?? {})) {\n if (value === null || value === undefined || NOT_A_VALUE.includes(String(value))) continue;\n if (key === 'panelId') read = String(value);\n else if (key === 'focus') asked = String(value);\n else {\n const name = ALIAS[key] ?? key;\n if (settable.includes(name)) vars[name] = String(value);\n }\n }\n }\n // Half a window would leave the picker inverted.\n if (vars.time_from && !vars.time_to) vars.time_to = 'now';\n return { vars, focus: settable.includes('focus') ? (asked ?? read) : null };\n}\n\n/**\n * Applies `values` to the page: only the `settable` names, in that order.\n * `refresh` snaps to an offered interval; `time_from`/`time_to` are applied\n * together at the end in one call, both ends reported even when one was asked\n * for. `focus` is not applied here.\n *\n * @returns what really changed, for the state card\n */\nexport function applyState(page: Page, values: Record<string, unknown> | null | undefined, settable: string[]): Record<string, string> {\n const applied: Record<string, string> = {};\n if (!values || typeof values !== 'object') return applied;\n let from: string | null = null;\n let to: string | null = null;\n for (const name of settable) {\n const value = values[name];\n if (value === undefined || value === null || value === '') continue;\n if (name === 'time_from') from = String(value);\n else if (name === 'time_to') to = String(value);\n else if (name === 'refresh') {\n const set = setRefresh(page, String(value));\n if (set !== null) applied.refresh = set;\n } else if (name !== 'focus') {\n const set = setVariable(page, name, value);\n if (set !== null) applied[name] = set;\n }\n }\n if (from || to) {\n const raw = setTimeRange(page, from, to);\n if (raw) {\n applied.time_from = raw.from;\n applied.time_to = raw.to;\n }\n }\n return applied;\n}\n\n/**\n * The card saying what the agent just did to the dashboard, or null when it\n * did nothing. Every value came from the model, so all of it is text, never\n * markup. The focused group is a button that goes back there.\n */\nexport function stateCard(\n doc: Document,\n applied: Record<string, string>,\n focused: Focused | null,\n onGo: (target: string) => void,\n): HTMLElement | null {\n const chips: [string, string][] = [];\n if (applied.time_from || applied.time_to) {\n chips.push(['time', `${applied.time_from || 'now'} → ${applied.time_to || 'now'}`]);\n }\n for (const [k, v] of Object.entries(applied)) {\n if (k !== 'time_from' && k !== 'time_to') chips.push([k, v]);\n }\n if (!chips.length && !focused) return null;\n\n const card = doc.createElement('div');\n card.className = 'n8n-chat-state';\n const head = doc.createElement('span');\n head.className = 'ncs-head';\n head.textContent = focused && !chips.length ? 'Moved your dashboard' : 'Changed your dashboard';\n card.append(head);\n\n const chip = (tag: 'span' | 'button', label: string, value: string): HTMLElement => {\n const el = doc.createElement(tag);\n el.className = tag === 'button' ? 'ncs-chip ncs-go' : 'ncs-chip';\n if (tag === 'button') (el as HTMLButtonElement).type = 'button';\n const b = doc.createElement('b');\n b.textContent = label;\n const i = doc.createElement('i');\n i.textContent = value;\n el.append(b, i);\n card.append(el);\n return el;\n };\n for (const [label, value] of chips) chip('span', label, value);\n if (focused) {\n const where = focused.panel != null ? `${focused.group} · panel ${focused.panel}` : focused.group;\n const go = chip('button', focused.kind === 'tab' ? 'tab' : 'section', where);\n go.title = 'Show me that again';\n go.addEventListener('click', () => onGo(focused.panel != null ? String(focused.panel) : focused.group));\n }\n return card;\n}\n\n/**\n * Puts the card inside the last bot message. The widget's Vue list reorders\n * foreign children of the list itself to below every later message; inside a\n * message they are that message's own subtree and scroll away with its turn.\n */\nexport function placeCard(doc: Document, card: HTMLElement): boolean {\n const bots = doc.querySelectorAll('.chat-message-from-bot');\n const host = bots.length\n ? bots[bots.length - 1]\n : doc.querySelector('.chat-messages-list') || doc.querySelector('.chat-body');\n if (!host) return false;\n card.classList.toggle('ncs-loose', !bots.length);\n host.append(card);\n card.scrollIntoView?.({ block: 'nearest' });\n return true;\n}\n\n/** Applies one turn's control chunk: the settable values, then the focus, then the card. */\nexport function applyToolCalls(page: Page, payload: ToolCalls | null | undefined, settable: string[]): void {\n if (!settable.length) return;\n const state = readToolCalls(payload, settable);\n const applied = Object.keys(state.vars).length ? applyState(page, state.vars, settable) : {};\n const focused = state.focus ? focusPanel(page, state.focus) : null;\n const win = pageWindow(page);\n if (!win) return;\n const card = stateCard(win.document, applied, focused, (target) => focusPanel(win, target));\n // The control chunk ends the stream, but the widget may still be committing\n // the reply it belongs to.\n if (card) win.setTimeout(() => placeCard(win.document, card), 150);\n}\n","/**\n * The node whose chunks drive the dashboard. Each agent workflow ends with a\n * `Dashboard State` node that writes one chunk carrying the turn's tool calls\n * as JSON, and n8n stamps every chunk with the node that wrote it.\n */\nexport const CONTROL_NODE = 'Dashboard State';\n\ninterface Chunk {\n type?: string;\n content?: string;\n metadata?: { nodeName?: string };\n}\n\n/**\n * Rewrites n8n's NDJSON stream on its way to the widget. The control node's\n * chunks are recognised by their author and swallowed whole - begin, item and\n * end alike, since a begin/end that got through would render an empty bubble -\n * and each item's content is handed to `onControl`. Every other line passes\n * untouched.\n *\n * Chunks split anywhere, so a partial line is held back until its newline\n * arrives (or the stream ends): a half-received control chunk never leaks.\n */\nexport function controlFilter(\n onControl: (payload: unknown) => void,\n node: string = CONTROL_NODE,\n): TransformStream<Uint8Array, Uint8Array> {\n const decoder = new TextDecoder();\n const encoder = new TextEncoder();\n let carry = '';\n const pass = (line: string, out: TransformStreamDefaultController<Uint8Array>): void => {\n if (!line.trim()) return;\n let chunk: Chunk;\n try {\n chunk = JSON.parse(line) as Chunk;\n } catch {\n out.enqueue(encoder.encode(line + '\\n'));\n return;\n }\n if (chunk?.metadata?.nodeName === node) {\n if (chunk.type === 'item' && chunk.content) {\n try {\n onControl(JSON.parse(chunk.content));\n } catch (e) {\n console.warn('[n8n-chat] unreadable control chunk', chunk.content, e);\n }\n }\n return;\n }\n out.enqueue(encoder.encode(line + '\\n'));\n };\n return new TransformStream<Uint8Array, Uint8Array>({\n transform(bytes, out) {\n carry += decoder.decode(bytes, { stream: true });\n const lines = carry.split('\\n');\n carry = lines.pop() ?? '';\n for (const line of lines) pass(line, out);\n },\n flush(out) {\n carry += decoder.decode();\n if (carry.trim()) pass(carry, out);\n },\n });\n}\n","// The chat tile's page-global stylesheet, injected once into <head>: the bubble\n// lives on <body>, outside any panel, so these rules cannot be scoped to one.\n// Every rule is under #n8n-chat, .n8n-chat-widget or .n8n-chat-*, except the\n// kiosk footer fix.\n//\n// The colour literals are deliberate. @n8n/chat renders light even on a dark\n// Grafana, so its insides are pinned to light values, and the state card binds to\n// the widget's own --chat--* properties rather than to the page's theme.\n\nconst parts = [\n // Kiosk embeds: the \"Powered by\" footer is sticky inside a container fixed to\n // the first viewport height, so it floats up once the page scrolls.\n `[data-testid=\"public-dashboard-footer\"]{position:fixed!important;left:0;right:0;bottom:0}`,\n `#n8n-chat .chat-window-wrapper,.n8n-chat-widget{z-index:2147483647!important}`,\n\n // Size. The widget defaults to 400x600 with no media queries. On a desktop the\n // window's top sits under Grafana's controls row, measured into --n8n-chat-top by\n // the mount (these are fallbacks); --n8n-chat-reserve is what sits below the\n // window inside the widget's fixed wrapper (toggle, gap, inset).\n `#n8n-chat{--n8n-chat-top:14px;--n8n-chat-reserve:92px;` +\n `--chat--window--width:min(760px,calc(100vw - 2rem));` +\n `--chat--window--height:max(320px,calc(100vh - var(--n8n-chat-top) - var(--n8n-chat-reserve)))}`,\n // flex-end: the wrapper is a column of window then toggle, and a closed chat\n // hides the window with display:none, so without it the toggle rides up to the\n // controls row. It also makes an overlong window grow upwards.\n `#n8n-chat .chat-window-wrapper{top:var(--n8n-chat-top);justify-content:flex-end}`,\n // Narrow: full bleed. The mount stops setting the inline properties below 900px.\n `@media (max-width:900px){#n8n-chat{--chat--window--width:calc(100vw - 1.5rem);--chat--window--height:calc(100vh - 5rem)}}`,\n\n // Overflow: pod names, image refs and URLs have no break opportunity, and\n // break-word will not break a token on a line that already has content.\n `#n8n-chat .chat-message-markdown{overflow-wrap:anywhere}`,\n `#n8n-chat .chat-message-from-bot{max-width:94%}`,\n // Code and tables scroll rather than wrap: a wrapped command copies wrong.\n `#n8n-chat .chat-message-markdown pre,#n8n-chat .chat-message-markdown table{display:block;max-width:100%;overflow-x:auto}`,\n `#n8n-chat .chat-message-markdown pre code{overflow-wrap:normal;white-space:pre}`,\n `#n8n-chat .chat-message-markdown table{border-collapse:collapse;font-size:12px;white-space:nowrap}`,\n `#n8n-chat .chat-message-markdown th,#n8n-chat .chat-message-markdown td{border:1px solid var(--chat--color-light-shade-100,#d4d8dd);padding:3px 8px;text-align:left}`,\n `#n8n-chat .chat-message-markdown img{max-width:100%;height:auto}`,\n\n // Code contrast: Grafana's dark theme styles <code>/<pre> near-white globally,\n // which wins inside the light bubble. Elements only, so highlight.js spans keep\n // their colours.\n `#n8n-chat{--chat--message--pre--background:#f6f8fa}`,\n `#n8n-chat .chat-message-markdown pre,#n8n-chat .chat-message-markdown code{color:#1f2328!important;background:#f6f8fa}`,\n `#n8n-chat .chat-message-markdown pre{border:1px solid #d0d7de}`,\n `#n8n-chat .chat-message-markdown :not(pre)>code{background:#eaeef2;border:1px solid #d0d7de;border-radius:4px;padding:1px 5px;font-size:.92em}`,\n\n // Grafana styles every <textarea> globally: dark background, dark chat text.\n // -webkit-text-fill-color overrides color on WebKit.\n `#n8n-chat textarea{background:#fff!important;color:#14161a!important;-webkit-text-fill-color:#14161a!important;caret-color:#14161a!important;border:1px solid #c7ccd1!important;opacity:1!important}`,\n `#n8n-chat textarea::placeholder{color:#6b7280!important;-webkit-text-fill-color:#6b7280!important;opacity:1!important}`,\n `#n8n-chat .chat-input-send-button{color:#14161a!important}`,\n\n `.n8n-chat-tile{display:block;text-align:center;text-decoration:none;padding-top:6px;color:inherit}`,\n `.n8n-chat-tile .icon{font-size:30px;line-height:1;height:30px}`,\n `.n8n-chat-tile img{height:30px}`,\n // Grafana's legacy `.badge, .label` rule would paint this a grey box; this selector outranks it.\n `.n8n-chat-tile .label{display:block;font-size:12px;font-weight:inherit;line-height:inherit;opacity:.75;margin-top:6px;padding:0;background:none;color:inherit;border-radius:0;text-shadow:none;white-space:normal}`,\n\n // The state card. Colours come from the widget's own properties: .chat-body\n // inherits Grafana's dark-theme text colour, which measured 1.5:1 on the bubble.\n `.n8n-chat-state{display:flex;flex-wrap:wrap;align-items:center;gap:5px 6px;margin:10px 0 0;padding:8px 0 0;` +\n `border-top:1px solid var(--chat--color-medium,#d2d4d9);color:var(--chat--color-dark,#101330);font-size:12px;line-height:1.4}`,\n // With no reply to hang under, the card carries its own edges.\n `.n8n-chat-state.ncs-loose{margin:2px 0 10px;padding:8px 10px;border:1px solid var(--chat--color-medium,#d2d4d9);` +\n `border-left:3px solid #5794f2;border-radius:4px;background:var(--chat--message--bot--background,#fff)}`,\n `.n8n-chat-state .ncs-head{width:100%;margin-bottom:2px;font-size:11px;font-weight:600;letter-spacing:.02em;opacity:.62}`,\n `.n8n-chat-state .ncs-chip{display:inline-flex;align-items:baseline;gap:6px;margin:0;padding:3px 9px;border-radius:11px;` +\n `border:1px solid var(--chat--color-medium,#d2d4d9);background:var(--chat--color-light,#f2f4f8);font:inherit;color:inherit}`,\n `.n8n-chat-state .ncs-chip b{font-weight:600;font-size:10px;text-transform:uppercase;letter-spacing:.05em;opacity:.62}`,\n `.n8n-chat-state .ncs-chip i{font-style:normal}`,\n `.n8n-chat-state button.ncs-go{cursor:pointer}`,\n `.n8n-chat-state button.ncs-go:hover{border-color:#5794f2;background:rgba(87,148,242,.12)}`,\n];\n\nexport const STYLES = parts.join('\\n');\n","import { VERSION } from '../kd/define';\nimport { focusPanel } from '../kd/scene';\nimport { settings, type ChatConfig, type Settings } from './config';\nimport { wrapFetch, type ChatHandle, type ChatWindow } from './fetch';\nimport { cleanHistory } from './history';\nimport { chatMetadata } from './metadata';\nimport { applyState, applyToolCalls, type ToolCalls } from './state';\nimport { controlFilter } from './stream';\nimport { STYLES } from './styles';\n\nexport type CreateChat = (options: Record<string, unknown>) => unknown;\nexport type ChatLoader = (url: string) => Promise<{ createChat: CreateChat }>;\n\n// dist/ on purpose, for both files: the package root's chat.bundle.es.js has no\n// stream reader, and its style.css has no .chat-inputs rules.\nexport const chatBundle = (version: string): string => `https://cdn.jsdelivr.net/npm/@n8n/chat@${version}/dist/chat.bundle.es.js`;\nexport const chatStyle = (version: string): string => `https://cdn.jsdelivr.net/npm/@n8n/chat@${version}/dist/style.css`;\n\nconst CONTROLS = '[data-testid=\"data-testid dashboard controls\"]';\nconst NARROW = 900;\n\n/** Injects the tile's page-global stylesheet once; a newer build's replaces an older one's. */\nexport function injectStyles(doc: Document): void {\n let style = doc.head.querySelector<HTMLStyleElement>('style[data-n8n-chat-tile]');\n if (style?.dataset.n8nChatTile === VERSION) return;\n if (!style) {\n style = doc.createElement('style');\n doc.head.append(style);\n }\n style.dataset.n8nChatTile = VERSION;\n style.textContent = STYLES;\n}\n\nfunction chatStylesheet(doc: Document, version: string): void {\n const href = chatStyle(version);\n let link = doc.head.querySelector<HTMLLinkElement>('link[data-n8n-chat-style]');\n if (link?.getAttribute('href') === href) return;\n if (!link) {\n link = doc.createElement('link');\n link.rel = 'stylesheet';\n link.setAttribute('data-n8n-chat-style', '');\n doc.head.append(link);\n }\n link.href = href;\n}\n\n/** Fills the tile: an `<a>` with `.icon` and `.label` children, or a `<kd-tile>` by its attributes. */\nexport function fillTile(tile: Element, s: Pick<Settings, 'icon' | 'label' | 'link'>): void {\n const external = /^https?:/.test(s.link);\n if (tile.localName === 'kd-tile') {\n for (const [name, value] of [['icon', s.icon], ['label', s.label], ['href', s.link]]) {\n if (value) tile.setAttribute(name, value);\n else tile.removeAttribute(name);\n }\n return;\n }\n const icon = tile.querySelector('.icon');\n if (icon) {\n if (/^(https?:)?\\//.test(s.icon)) {\n const img = tile.ownerDocument.createElement('img');\n img.src = s.icon;\n img.alt = '';\n icon.replaceChildren(img);\n } else {\n icon.textContent = s.icon;\n }\n }\n const label = tile.querySelector('.label');\n if (label) label.textContent = s.label;\n if (s.link) tile.setAttribute('href', s.link);\n else tile.removeAttribute('href');\n if (external) {\n tile.setAttribute('target', '_blank');\n tile.setAttribute('rel', 'noopener');\n } else {\n tile.removeAttribute('target');\n tile.removeAttribute('rel');\n }\n}\n\n/**\n * Pins the chat window's top under Grafana's controls row, which is measured\n * because it grows when the variables wrap and is absent in a kiosk embed. With\n * no row, or below 900px, the inline values go so the stylesheet's apply.\n */\nexport function fitChat(win: Window): void {\n const doc = win.document;\n const root = doc.getElementById('n8n-chat');\n if (!root) return;\n const wrapper = root.querySelector('.chat-window-wrapper');\n const box = doc.querySelector(CONTROLS)?.getBoundingClientRect();\n if (!wrapper || !box || !box.height || win.innerWidth <= NARROW) {\n root.style.removeProperty('--n8n-chat-top');\n root.style.removeProperty('--n8n-chat-reserve');\n return;\n }\n const cs = win.getComputedStyle(wrapper);\n const toggle = root.querySelector('.chat-window-toggle');\n const reserve =\n (parseFloat(cs.bottom) || 14) +\n (toggle ? toggle.getBoundingClientRect().height : 64) +\n (parseFloat(cs.rowGap || cs.gap) || 14);\n root.style.setProperty('--n8n-chat-top', `${Math.round(box.bottom + 10)}px`);\n root.style.setProperty('--n8n-chat-reserve', `${Math.round(reserve)}px`);\n}\n\nfunction removeChat(doc: Document): void {\n doc.querySelectorAll('#n8n-chat, .n8n-chat-widget').forEach((el) => el.remove());\n}\n\nfunction pageOf(config: ChatConfig): { win: ChatWindow; tile: Element | null } {\n const given = config.tile;\n if (given && typeof given === 'object') {\n return { win: (config.window ?? given.ownerDocument.defaultView ?? window) as ChatWindow, tile: given };\n }\n const win = (config.window ?? window) as ChatWindow;\n const tile =\n typeof given === 'string' ? win.document.querySelector(given) : given === null ? null : win.document.getElementById('n8n-chat-tile');\n return { win, tile };\n}\n\nconst load: ChatLoader = (url) => import(/* @vite-ignore */ url);\n\n/**\n * Mounts the chat tile and its n8n chat on the page.\n *\n * Idempotent: the core text panel re-runs its script on every mount, so a\n * repeat call for the same dashboard and settings keeps the chat that is there.\n * Grafana is a single-page app, so the chat lives on `<body>` only while the URL\n * stays on this dashboard. With no webhook it fills the tile and removes any\n * leftover chat.\n *\n * @returns once the chat is created (or at once, tile only)\n */\nexport function mount(config: ChatConfig = {}, loader: ChatLoader = load): Promise<void> {\n const { win, tile } = pageOf(config);\n const doc = win.document;\n const s = settings(config);\n\n injectStyles(doc);\n if (tile) fillTile(tile, s);\n win.dashboardFocus = (target) => focusPanel(win, target);\n\n if (!s.webhook) {\n removeChat(doc);\n win.clearInterval(win.n8nChatWatch);\n win.n8nChat = null;\n win.n8nChatMount = undefined;\n return Promise.resolve();\n }\n\n const home = win.location.pathname;\n const { auth: _auth, ...visible } = s;\n const key = JSON.stringify([home, visible]);\n const current = win.n8nChatMount;\n if (current?.key === key && (!current.done || doc.getElementById('n8n-chat'))) return current.ready;\n\n removeChat(doc);\n win.clearInterval(win.n8nChatWatch);\n win.n8nChatWatch = win.setInterval(() => {\n if (win.location.pathname !== home) {\n removeChat(doc);\n win.clearInterval(win.n8nChatWatch);\n win.n8nChat = null;\n win.n8nChatMount = undefined;\n return;\n }\n // Also re-measures the controls row, whose height changes fire no event.\n win.n8nChatFit?.();\n }, 1000);\n chatStylesheet(doc, s.chatVersion);\n if (!win.n8nChatResize) {\n win.n8nChatResize = true;\n win.addEventListener('resize', () => win.n8nChatFit?.());\n }\n\n const handle: ChatHandle = {\n webhook: s.webhook,\n settable: s.settable,\n stream: s.stream,\n setVariables: (vars, names) => applyState(win, vars, names),\n cleanHistory,\n filterStream: (body) => body.pipeThrough(controlFilter((payload) => applyToolCalls(win, payload as ToolCalls, s.settable))),\n };\n win.n8nChat = handle;\n wrapFetch(win);\n\n const state: NonNullable<ChatWindow['n8nChatMount']> = { key, done: false, ready: Promise.resolve() };\n win.n8nChatMount = state;\n state.ready = (async () => {\n try {\n // Imported after the setup above, so the page is ready before the bundle arrives.\n const { createChat } = await loader(chatBundle(s.chatVersion));\n // A later mount, or leaving the dashboard, while the bundle loaded.\n if (win.n8nChatMount !== state || win.location.pathname !== home) return;\n win.n8nChatFit = () => fitChat(win);\n createChat({\n webhookUrl: s.webhook,\n webhookConfig: { headers: s.auth ? { Authorization: s.auth } : {} },\n chatSessionKey: 'sessionId',\n loadPreviousSession: true,\n enableStreaming: s.stream,\n metadata: chatMetadata(win, s, home),\n showWelcomeScreen: true,\n initialMessages: s.greeting,\n i18n: { en: { title: s.title, subtitle: s.subtitle } },\n });\n // createChat mounts asynchronously.\n win.setTimeout(() => win.n8nChatFit?.(), 200);\n } finally {\n state.done = true;\n }\n })();\n return state.ready;\n}\n"],"mappings":";;;AAqCA,IAAaY,IAAe;AAmB5B,SAASC,EAAK,GAAwB;CAEpC,OADI,OAAOC,KAAU,WACdA,EAAM,WAAW,IAAI,IAAI,KAAKA,IADC;AAExC;AAEA,SAAgBC,EAAK,GAAyB;CAC5C,OAAOD,EACJ,MAAM,GAAG,CAAC,CACV,KAAK,MAAME,EAAE,KAAK,CAAC,CAAC,CACpB,OAAO,OAAO;AACnB;AAGA,SAAgBC,EAAW,GAAuC;CAChE,IAAMC,IAAgC,CAAC;CACvC,KAAK,IAAMC,KAAQL,EAAM,MAAM,GAAG,GAAG;EACnC,IAAMM,IAAKD,EAAK,QAAQ,GAAG;EAC3B,AAAIC,IAAK,MAAG,EAAMD,EAAK,MAAM,GAAGC,CAAE,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,KAAKD,EAAK,MAAMC,IAAK,CAAC,CAAC,CAAC,KAAK;CACtF;CACA,OAAOF;AACT;AAEA,SAAgBG,EAAS,GAA8B;CACrD,OAAO;EACL,MAAMR,EAAKS,EAAO,IAAI;EACtB,OAAOT,EAAKS,EAAO,KAAK;EACxB,MAAMT,EAAKS,EAAO,IAAI;EACtB,SAAST,EAAKS,EAAO,OAAO,CAAC,CAAC,KAAK;EACnC,OAAOT,EAAKS,EAAO,KAAK;EACxB,UAAUT,EAAKS,EAAO,QAAQ;E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E,kBAAe,MAAM8C,EAAO/B,EAAWvD,EAAE,WAAW,CAAC;GAE7D,IAAI5B,EAAI,iBAAiBoE,KAASpE,EAAI,SAAS,aAAa2B,GAAM;GAclE,AAbA,EAAI,mBAAmBuE,EAAQlG,CAAG,GAClCmH,EAAW;IACT,YAAYvF,EAAE;IACd,eAAe,EAAE,SAASA,EAAE,OAAO,EAAE,eAAeA,EAAE,KAAK,IAAI,CAAC,EAAE;IAClE,gBAAgB;IAChB,qBAAqB;IACrB,iBAAiBA,EAAE;IACnB,UAAUH,EAAazB,GAAK4B,GAAGD,CAAI;IACnC,mBAAmB;IACnB,iBAAiBC,EAAE;IACnB,MAAM,EAAE,IAAI;KAAE,OAAOA,EAAE;KAAO,UAAUA,EAAE;IAAS,EAAE;GACvD,CAAC,GAED5B,EAAI,iBAAiBA,EAAI,aAAa,GAAG,GAAG;EAC9C,UAAU;GACR,EAAM,OAAO;EACf;CACF,EAAA,CAAG,GACIoE,EAAM;AACf"}
@@ -0,0 +1,20 @@
1
+ import { type Keywords } from './model';
2
+ /** A Kubernetes behaviour of a field: a short tag and the why behind it. */
3
+ export interface Behaviour {
4
+ label: string;
5
+ why: string;
6
+ }
7
+ /**
8
+ * The value limits, shown beside the type: `default`, `one of`, `format`,
9
+ * `pattern`, `range`, `multiple of`, `length`, `items`, `unique items`, `keys`,
10
+ * `nullable`. An empty-object default (Kubernetes puts `default: {}` on every
11
+ * `allOf` wrapper) says nothing and is left out.
12
+ */
13
+ export declare function constraints(k: Keywords): string[];
14
+ /**
15
+ * How Kubernetes treats the field - server-side apply, strategic merge,
16
+ * pruning, embedded objects - as tags with the why on hover.
17
+ */
18
+ export declare function behaviours(k: Keywords): Behaviour[];
19
+ /** A combinator branch (`anyOf`, `oneOf`, `allOf`, `not`) in a few words. */
20
+ export declare function brief(schema: unknown): string;
@@ -0,0 +1,6 @@
1
+ import './schema';
2
+ export { VERSION } from '../kd/define';
3
+ export { applyTheme } from '../kd/theme';
4
+ export { KEYWORDS, find, normalize, shortName, type GroupVersionKind, type Keywords, type OpenApiDocument, type Root, type Schema, type SchemaNode, type Union, type Validation, } from './model';
5
+ export { behaviours, brief, constraints, type Behaviour } from './describe';
6
+ export { KdSchema } from './schema';