likec4 1.59.4 → 1.61.0
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/README.md +2 -0
- package/__app__/codegen/react.mjs +4 -10
- package/__app__/codegen/webcomponent.mjs +6 -131
- package/__app__/index.html +15 -15
- package/__app__/src/aichat/index.mjs +11 -7
- package/__app__/src/chunks/AIChat.mjs +1355 -739
- package/__app__/src/chunks/ErrorComponent.mjs +444 -0
- package/__app__/src/chunks/Header.mjs +269 -0
- package/__app__/src/chunks/ViewReact.mjs +438 -0
- package/__app__/src/chunks/find.mjs +38 -0
- package/__app__/src/chunks/hooks.mjs +158 -472
- package/__app__/src/chunks/libs/@tabler/icons-react.mjs +340 -0
- package/__app__/src/chunks/libs/@tanstack-ai.mjs +11841 -1417
- package/__app__/src/chunks/libs/@tanstack.mjs +5110 -2404
- package/__app__/src/chunks/libs/fast-equals.mjs +507 -214
- package/__app__/src/chunks/libs/html-to-image.mjs +613 -0
- package/__app__/src/chunks/libs/nanostores.mjs +170 -0
- package/__app__/src/chunks/libs/react-resizable-panels.mjs +2792 -0
- package/__app__/src/chunks/react.mjs +22 -0
- package/__app__/src/chunks/rolldown-runtime.mjs +16 -29
- package/__app__/src/chunks/router.mjs +106 -0
- package/__app__/src/chunks/scope.mjs +106 -0
- package/__app__/src/chunks/searchParams.mjs +29 -0
- package/__app__/src/chunks/single-index.mjs +465 -0
- package/__app__/src/chunks/styled-system.mjs +1826 -2528
- package/__app__/src/chunks/useAsync.mjs +69 -0
- package/__app__/src/chunks/useSyncedRef.mjs +16 -0
- package/__app__/src/components/ColorSchemeToggle.mjs +124 -0
- package/__app__/src/components/CopyToClipboard.mjs +53 -0
- package/__app__/src/components/ErrorComponent.mjs +1 -0
- package/__app__/src/components/NavigationPanel.mjs +63 -0
- package/__app__/src/components/NotFound.mjs +155 -0
- package/__app__/src/components/ViewOutlet.mjs +9 -0
- package/__app__/src/components/model-diff/CompareModelProvider.mjs +44 -0
- package/__app__/src/components/model-diff/ModelDiffPanel.mjs +179 -0
- package/__app__/src/components/model-diff/compare-model.mjs +76 -0
- package/__app__/src/components/model-diff/state.mjs +45 -0
- package/__app__/src/components/search/OverviewSearch.mjs +92 -0
- package/__app__/src/components/search/OverviewSearchAdapter.mjs +94 -0
- package/__app__/src/components/sidebar/DiagramTree.css.mjs +48 -0
- package/__app__/src/components/sidebar/DiagramsTree.mjs +304 -0
- package/__app__/src/components/sidebar/Drawer.mjs +178 -0
- package/__app__/src/components/sidebar/SidebarBurger.mjs +28 -0
- package/__app__/src/components/sidebar/data.mjs +94 -0
- package/__app__/src/components/sidebar/state.mjs +16 -0
- package/__app__/src/components/view-page/Header.mjs +1 -0
- package/__app__/src/components/view-page/SelectProject.mjs +258 -0
- package/__app__/src/components/view-page/ShareModal.mjs +111 -0
- package/__app__/src/components/view-page/share-modal/AlertLocalhost.mjs +31 -0
- package/__app__/src/components/view-page/share-modal/CopyButtonChild.mjs +36 -0
- package/__app__/src/components/view-page/share-modal/EmbedPanel.mjs +100 -0
- package/__app__/src/components/view-page/share-modal/WebcomponentsPanel.mjs +264 -0
- package/__app__/src/components/view-page/state.mjs +17 -0
- package/__app__/src/context/LikeC4CustomizationContext.mjs +26 -0
- package/__app__/src/context/LikeC4IconRendererContext.mjs +29 -0
- package/__app__/src/context/LikeC4ModelContext.mjs +34 -0
- package/__app__/src/context/LikeC4ProjectsContext.mjs +40 -0
- package/__app__/src/context/ModelDiffsContext.mjs +33 -0
- package/__app__/src/context/safeCtx.mjs +14 -0
- package/__app__/src/fonts.css +112 -1
- package/__app__/src/hooks.mjs +1 -0
- package/__app__/src/main.mjs +6 -29151
- package/__app__/src/pages/EmbedPage.mjs +93 -0
- package/__app__/src/pages/ExportPage.mjs +691 -0
- package/__app__/src/pages/ProjectsOverview.mjs +23 -0
- package/__app__/src/pages/ViewAsD2.mjs +105 -0
- package/__app__/src/pages/ViewAsDot.mjs +65 -0
- package/__app__/src/pages/ViewAsMmd.mjs +109 -0
- package/__app__/src/pages/ViewAsPuml.mjs +105 -0
- package/__app__/src/pages/ViewEditor.mjs +220 -0
- package/__app__/src/pages/ViewReact.mjs +1 -0
- package/__app__/src/pages/export-layout.mjs +95 -0
- package/__app__/src/pages/export-page-params.mjs +9 -0
- package/__app__/src/pages/styles.css.mjs +23 -0
- package/__app__/src/routeTree.gen.mjs +105 -0
- package/__app__/src/router.mjs +1 -0
- package/__app__/src/routes/__root.mjs +65 -0
- package/__app__/src/routes/index.css.mjs +29 -0
- package/__app__/src/routes/index.mjs +32 -0
- package/__app__/src/routes/project._projectId/-components.mjs +100 -0
- package/__app__/src/routes/project._projectId/embed._viewId.mjs +5 -0
- package/__app__/src/routes/project._projectId/export._viewId.mjs +24 -0
- package/__app__/src/routes/project._projectId/index.mjs +14 -0
- package/__app__/src/routes/project._projectId/route.mjs +93 -0
- package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +34 -0
- package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +41 -0
- package/__app__/src/routes/project._projectId/view._viewId.index.mjs +7 -0
- package/__app__/src/routes/project._projectId/view._viewId.mjs +23 -0
- package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +39 -0
- package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +34 -0
- package/__app__/src/routes/projects.mjs +36 -0
- package/__app__/src/routes/single-index.mjs +1 -0
- package/__app__/src/routes/webcomponent._.mjs +94 -0
- package/__app__/src/style.css +18497 -1
- package/config/schema.json +146 -97
- package/dist/app/render-view-client.css +1 -1
- package/dist/app/render-view-client.js +394 -238
- package/dist/chunks/enableServer.mjs +1 -1
- package/dist/chunks/filenames.mjs +25 -17
- package/dist/chunks/generate-likec4.mjs +5 -0
- package/dist/chunks/index.d.mts +255 -194
- package/dist/chunks/index2.d.mts +8246 -3610
- package/dist/chunks/libs/@chenglou/pretext.mjs +9 -0
- package/dist/chunks/libs/@chevrotain/gast.mjs +27 -1
- package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +81 -9
- package/dist/chunks/libs/@logtape/logtape.mjs +5 -4
- package/dist/chunks/libs/@lume/kiwi.mjs +1 -1
- package/dist/chunks/libs/@ts-graphviz/common.d.mts +2 -4
- package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
- package/dist/chunks/libs/birpc.mjs +1 -1
- package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
- package/dist/chunks/libs/chevrotain.mjs +88 -36
- package/dist/chunks/libs/clone.mjs +1 -0
- package/dist/chunks/libs/eventemitter3.mjs +1 -1
- package/dist/chunks/libs/fast-equals.mjs +1 -0
- package/dist/chunks/libs/fontkit.mjs +1 -0
- package/dist/chunks/libs/json5.mjs +4 -4
- package/dist/chunks/libs/langium.d.mts +6707 -6715
- package/dist/chunks/libs/langium.mjs +16 -24
- package/dist/chunks/libs/merge-error-cause.mjs +1 -1
- package/dist/chunks/libs/p-limit.mjs +1 -0
- package/dist/chunks/libs/p-queue.mjs +1 -1
- package/dist/chunks/libs/package-manager-detector.mjs +1 -1
- package/dist/chunks/libs/pako.mjs +1 -1
- package/dist/chunks/libs/pathe.mjs +1 -1
- package/dist/chunks/libs/pretty-ms.mjs +1 -1
- package/dist/chunks/libs/remeda.mjs +1 -1
- package/dist/chunks/libs/ufo.mjs +1 -1
- package/dist/chunks/libs/unstorage.mjs +1 -1
- package/dist/chunks/libs/which.mjs +1 -1
- package/dist/chunks/node.mjs +111 -77
- package/dist/chunks/rolldown-runtime.mjs +1 -1
- package/dist/chunks/sequence-view.mjs +1 -1
- package/dist/chunks/vite-plugin.mjs +185 -166
- package/dist/cli/index.mjs +254 -1306
- package/dist/config/index.d.mts +66 -5
- package/dist/config/index.mjs +1 -1
- package/dist/generators/likec4.d.mts +6530 -0
- package/dist/generators/likec4.mjs +1 -0
- package/dist/index.d.mts +2 -4
- package/dist/model/index.d.mts +0 -7
- package/dist/vite-plugin/index.d.mts +83 -58
- package/dist/vite-plugin/index.mjs +1 -1
- package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +8 -0
- package/dist/vite-plugin/internal/index.d.mts +92 -17
- package/dist/vite-plugin/internal/index.mjs +225 -126
- package/generators/likec4/package.json +4 -0
- package/package.json +134 -122
- package/react/index.d.mts +7496 -26659
- package/react/index.mjs +533 -63936
- package/react/rolldown-runtime-CfRud99p.js +1 -0
- package/skills/likec4-dsl/SKILL.md +474 -0
- package/skills/likec4-dsl/evals/evals-public.json +207 -0
- package/skills/likec4-dsl/evals/grading-spec.json +603 -0
- package/skills/likec4-dsl/references/bridge-leanix-drawio.md +42 -0
- package/skills/likec4-dsl/references/cli.md +168 -0
- package/skills/likec4-dsl/references/configuration.md +266 -0
- package/skills/likec4-dsl/references/deployment.md +160 -0
- package/skills/likec4-dsl/references/diffs.md +52 -0
- package/skills/likec4-dsl/references/dynamic-views.md +455 -0
- package/skills/likec4-dsl/references/examples.md +370 -0
- package/skills/likec4-dsl/references/identifier-validity.md +90 -0
- package/skills/likec4-dsl/references/include-predicates-wildcards.md +180 -0
- package/skills/likec4-dsl/references/model.md +182 -0
- package/skills/likec4-dsl/references/predicates.md +123 -0
- package/skills/likec4-dsl/references/relationships-bidirectional.md +176 -0
- package/skills/likec4-dsl/references/specification.md +79 -0
- package/skills/likec4-dsl/references/style-tokens-colors.md +150 -0
- package/skills/likec4-dsl/references/troubleshooting.md +101 -0
- package/skills/likec4-dsl/references/views.md +329 -0
- package/vite-plugin-modules.d.ts +126 -51
- package/__app__/src/chunks/LikeC4Styles.mjs +0 -2306
- package/__app__/src/chunks/ProjectsOverview.mjs +0 -537
- package/__app__/src/chunks/es.mjs +0 -439
- package/__app__/src/chunks/libs/@floating-ui.mjs +0 -2532
- package/__app__/src/chunks/libs/@mantine.mjs +0 -13868
- package/__app__/src/chunks/libs/@xstate/react.mjs +0 -2015
- package/__app__/src/chunks/libs/@xyflow/react.mjs +0 -5367
- package/__app__/src/chunks/libs/bezier-js.mjs +0 -1007
- package/__app__/src/chunks/libs/d3.mjs +0 -2817
- package/__app__/src/chunks/libs/framer.mjs +0 -5926
- package/__app__/src/chunks/libs/zod.mjs +0 -3176
- package/dist/chunks/libs/@chevrotain/types.d.mts +0 -108
- package/dist/chunks/libs/picomatch.mjs +0 -1
- package/dist/chunks/libs/zod.d.mts +0 -3840
- package/dist/chunks/libs/zod.mjs +0 -65
|
@@ -1,402 +1,806 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { r as __name } from "./rolldown-runtime.mjs";
|
|
2
|
+
import { f as css, i as HStack, o as VStack, r as Txt } from "./styled-system.mjs";
|
|
3
|
+
import { t as useSyncedRef } from "./useSyncedRef.mjs";
|
|
4
|
+
import { v as createReactComponent } from "./libs/@tabler/icons-react.mjs";
|
|
5
|
+
import { a as toolDefinition, i as fetchServerSentEvents, n as useChat$1, r as clientTools, t as ChatMessage$1 } from "./libs/@tanstack-ai.mjs";
|
|
6
|
+
import { t as useStore } from "./react.mjs";
|
|
7
|
+
import { i as nanostoresGlobal, n as onMount, r as atom } from "./libs/nanostores.mjs";
|
|
8
|
+
import { c as useNavigate } from "./libs/@tanstack.mjs";
|
|
9
|
+
import { a as a$2, c as r$1, i as t, l as t$1, n as e, o as e$1, r as n, s as n$1, t as a$3 } from "./find.mjs";
|
|
10
|
+
import { t as useCurrentProject } from "./hooks.mjs";
|
|
11
|
+
import { createContext, use, useCallback, useEffect, useRef, useState } from "react";
|
|
12
|
+
import { c } from "react/compiler-runtime";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { ActionIcon, Badge, Button, CloseButton, FloatingWindow, Modal, Notification, ScrollAreaAutosize, Textarea, Title, Tooltip } from "@mantine/core";
|
|
15
|
+
import { Markdown, useDiagram } from "likec4/react";
|
|
16
|
+
import { useLocalStorage } from "@mantine/hooks";
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
import { AnimatePresence, m } from "motion/react";
|
|
19
|
+
import { RichText, nonNullable, nonexhaustive } from "@likec4/core";
|
|
20
|
+
import { AIAdapter } from "likec4:rpc";
|
|
21
|
+
import { ElementShapes } from "@likec4/core/styles";
|
|
22
|
+
// ../../node_modules/.pnpm/remeda@2.52.0/node_modules/remeda/dist/map.js
|
|
23
|
+
function r(...t$2) {
|
|
24
|
+
return t(i, t$2, a$1);
|
|
25
|
+
}
|
|
26
|
+
var i = (e, t) => e.map(t);
|
|
27
|
+
var a$1 = /* @__PURE__ */ __name((e$2) => n(e$2) ? e((t, n, r) => e$2(t, n, r)) : e$2, "a");
|
|
28
|
+
// ../../node_modules/.pnpm/remeda@2.52.0/node_modules/remeda/dist/pipe-D-eT-Ko7.js
|
|
29
|
+
var a = "Remeda: unexpected access to a callback's `data` argument during lazy evaluation.";
|
|
30
|
+
var o = /^(?:0|[1-9]\d*)$/u;
|
|
31
|
+
var s = new Proxy([{ error: a }], {
|
|
32
|
+
get: c$1,
|
|
33
|
+
getOwnPropertyDescriptor: c$1,
|
|
34
|
+
has: c$1,
|
|
35
|
+
ownKeys: l,
|
|
36
|
+
defineProperty: l,
|
|
37
|
+
deleteProperty: l,
|
|
38
|
+
preventExtensions: l,
|
|
39
|
+
set: l,
|
|
40
|
+
setPrototypeOf: l
|
|
41
|
+
});
|
|
42
|
+
function c$1(e, t) {
|
|
43
|
+
(t in Array.prototype || o.test(String(t))) && l();
|
|
44
|
+
}
|
|
45
|
+
__name(c$1, "c");
|
|
46
|
+
function l() {
|
|
47
|
+
throw Error(a);
|
|
48
|
+
}
|
|
49
|
+
function u(t, n, r) {
|
|
50
|
+
let i = n(...r);
|
|
51
|
+
let a = i.requiresData ? [] : void 0;
|
|
52
|
+
let o = a ?? s;
|
|
53
|
+
let c = a$2();
|
|
54
|
+
let l = [];
|
|
55
|
+
let u = 0;
|
|
56
|
+
if (Array.isArray(t)) for (let e of t) {
|
|
57
|
+
a?.push(e);
|
|
58
|
+
let t = d(i(e, u, o, c), l, c);
|
|
59
|
+
if (u += 1, t) break;
|
|
60
|
+
}
|
|
61
|
+
else for (let e of t) {
|
|
62
|
+
a?.push(e);
|
|
63
|
+
let t = d(i(e, u, o, c), l, c);
|
|
64
|
+
if (u += 1, t) break;
|
|
65
|
+
}
|
|
66
|
+
return n.single ? l[0] : l;
|
|
67
|
+
}
|
|
68
|
+
function d(e, a, o) {
|
|
69
|
+
if (typeof e == `symbol`) {
|
|
70
|
+
if (e === e$1) return !1;
|
|
71
|
+
if (e === r$1) {
|
|
72
|
+
for (let e of o.values) a.push(e);
|
|
73
|
+
return !1;
|
|
74
|
+
}
|
|
75
|
+
if (e === n$1) return a.push(o.value), !0;
|
|
76
|
+
if (e === t$1) return !0;
|
|
77
|
+
}
|
|
78
|
+
return a.push(e), !1;
|
|
79
|
+
}
|
|
80
|
+
function f(e, ...t) {
|
|
81
|
+
if (t.length === 0) return e;
|
|
82
|
+
if (t.length === 1) {
|
|
83
|
+
let n = t[0];
|
|
84
|
+
return `lazy` in n ? u(e, n.lazy, n.lazyArgs) : n(e);
|
|
85
|
+
}
|
|
86
|
+
let n = e;
|
|
87
|
+
let r = 0;
|
|
88
|
+
for (; r < t.length;) {
|
|
89
|
+
let e = t[r];
|
|
90
|
+
if (!(`lazy` in e)) {
|
|
91
|
+
n = e(n), r += 1;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
let i = t[r + 1];
|
|
95
|
+
if (i === void 0 || !(`lazy` in i) || e.lazy.single) {
|
|
96
|
+
n = u(n, e.lazy, e.lazyArgs), r += 1;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
let a = p(t, r);
|
|
100
|
+
n = m$1(n, a), r += a.length, t[r - 1].lazy.single && (n = n[0]);
|
|
101
|
+
}
|
|
102
|
+
return n;
|
|
103
|
+
}
|
|
104
|
+
function p(e, t) {
|
|
105
|
+
let n = [];
|
|
106
|
+
for (let r = t; r < e.length; r++) {
|
|
107
|
+
let t = e[r];
|
|
108
|
+
if (!(`lazy` in t)) break;
|
|
109
|
+
let i = t.lazy(...t.lazyArgs);
|
|
110
|
+
if (n.push(i.requiresData ? {
|
|
111
|
+
lazyEvaluator: i,
|
|
112
|
+
index: 0,
|
|
113
|
+
requiresData: !0,
|
|
114
|
+
items: []
|
|
115
|
+
} : {
|
|
116
|
+
lazyEvaluator: i,
|
|
117
|
+
index: 0,
|
|
118
|
+
requiresData: !1,
|
|
119
|
+
items: s
|
|
120
|
+
}), t.lazy.single) break;
|
|
121
|
+
}
|
|
122
|
+
return n;
|
|
123
|
+
}
|
|
124
|
+
function m$1(t, n) {
|
|
125
|
+
let r = [];
|
|
126
|
+
let i = a$2();
|
|
127
|
+
if (Array.isArray(t)) {
|
|
128
|
+
for (let e of t) if (h(n, r, e, i, 0)) break;
|
|
129
|
+
} else for (let e of t) if (h(n, r, e, i, 0)) break;
|
|
130
|
+
return r;
|
|
131
|
+
}
|
|
132
|
+
__name(m$1, "m");
|
|
133
|
+
function h(e, a, o, s, c) {
|
|
134
|
+
let l = o;
|
|
135
|
+
let u = !1;
|
|
136
|
+
for (let o = c; o < e.length; o++) {
|
|
137
|
+
let c = e[o];
|
|
138
|
+
c.requiresData && c.items.push(l);
|
|
139
|
+
let { lazyEvaluator: d } = c, f = d(l, c.index, c.items, s);
|
|
140
|
+
if (c.index += 1, typeof f == `symbol`) {
|
|
141
|
+
if (f === e$1) return u;
|
|
142
|
+
if (f === r$1) {
|
|
143
|
+
for (let t of s.values) if (h(e, a, t, s, o + 1)) return !0;
|
|
144
|
+
return u;
|
|
145
|
+
}
|
|
146
|
+
if (f === n$1) {
|
|
147
|
+
l = s.value, u = !0;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (f === t$1) return !0;
|
|
28
151
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
152
|
+
l = f;
|
|
153
|
+
}
|
|
154
|
+
return a.push(l), u;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* @license @tabler/icons-react v3.49.0 - MIT
|
|
158
|
+
*
|
|
159
|
+
* This source code is licensed under the MIT license.
|
|
160
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
+
*/
|
|
162
|
+
var IconSparkles = createReactComponent("outline", "sparkles", "Sparkles", [["path", {
|
|
163
|
+
"d": "M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6",
|
|
164
|
+
"key": "svg-0"
|
|
165
|
+
}]]);
|
|
166
|
+
/**
|
|
167
|
+
* @license @tabler/icons-react v3.49.0 - MIT
|
|
168
|
+
*
|
|
169
|
+
* This source code is licensed under the MIT license.
|
|
170
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
+
*/
|
|
172
|
+
var IconPlayerStopFilled = createReactComponent("filled", "player-stop-filled", "PlayerStopFilled", [["path", {
|
|
173
|
+
"d": "M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",
|
|
174
|
+
"key": "svg-0"
|
|
175
|
+
}]]);
|
|
176
|
+
// ../../node_modules/.pnpm/@react-hookz+web@26.1.0_react-dom@19.3.1_react@19.3.1__react@19.3.1/node_modules/@react-hookz/web/dist/useTimeoutEffect/index.js
|
|
177
|
+
var cancelTimeout = (id) => {
|
|
178
|
+
if (id) clearTimeout(id);
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Like `setTimeout` but in the form of a react hook.
|
|
182
|
+
*
|
|
183
|
+
* @param callback Callback to be called after the timeout. Changing this
|
|
184
|
+
* will not reset the timeout.
|
|
185
|
+
* @param ms Timeout delay in milliseconds. `undefined` disables the timeout.
|
|
186
|
+
* Keep in mind, that changing this parameter will re-set timeout, meaning
|
|
187
|
+
* that it will be set as new after the change.
|
|
188
|
+
*/
|
|
189
|
+
function useTimeoutEffect(callback, ms) {
|
|
190
|
+
const cbRef = useSyncedRef(callback);
|
|
191
|
+
const msRef = useSyncedRef(ms);
|
|
192
|
+
const timeoutIdRef = useRef(null);
|
|
193
|
+
const cancel = useCallback(() => {
|
|
194
|
+
cancelTimeout(timeoutIdRef.current);
|
|
195
|
+
}, []);
|
|
196
|
+
const reset = useCallback(() => {
|
|
197
|
+
if (msRef.current === void 0) return;
|
|
198
|
+
cancel();
|
|
199
|
+
timeoutIdRef.current = setTimeout(() => {
|
|
200
|
+
cbRef.current();
|
|
201
|
+
}, msRef.current);
|
|
202
|
+
}, []);
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
reset();
|
|
205
|
+
return cancel;
|
|
206
|
+
}, [ms]);
|
|
207
|
+
return [cancel, reset];
|
|
208
|
+
}
|
|
209
|
+
// ../../node_modules/.pnpm/nanostores@1.5.5/node_modules/nanostores/computed/index.js
|
|
210
|
+
var computedStore = (stores, cb, batched) => {
|
|
211
|
+
if (!Array.isArray(stores)) stores = [stores];
|
|
212
|
+
let previousArgs;
|
|
213
|
+
let currentEpoch;
|
|
214
|
+
let set = () => {
|
|
215
|
+
if (currentEpoch === nanostoresGlobal.epoch) return;
|
|
216
|
+
currentEpoch = nanostoresGlobal.epoch;
|
|
217
|
+
let args = stores.map(($store) => $store.get());
|
|
218
|
+
if (!previousArgs?.every((arg, i) => stores[i].eq(arg, args[i]))) {
|
|
219
|
+
previousArgs = args;
|
|
220
|
+
let value = cb(...args);
|
|
221
|
+
if (value && value.then && value.t) value.then((asyncValue) => {
|
|
222
|
+
if (previousArgs === args) $computed.set(asyncValue);
|
|
223
|
+
});
|
|
224
|
+
else {
|
|
225
|
+
$computed.set(value);
|
|
226
|
+
currentEpoch = nanostoresGlobal.epoch;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
let $computed = /* @__PURE__ */ atom();
|
|
231
|
+
let get = $computed.get;
|
|
232
|
+
$computed.get = () => {
|
|
233
|
+
set();
|
|
234
|
+
return get();
|
|
235
|
+
};
|
|
236
|
+
let timer;
|
|
237
|
+
let run = batched ? () => {
|
|
238
|
+
clearTimeout(timer);
|
|
239
|
+
timer = setTimeout(set);
|
|
33
240
|
} : set;
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
|
|
241
|
+
onMount($computed, () => {
|
|
242
|
+
let unbinds = stores.map(($store) => $store.listen(run));
|
|
243
|
+
set();
|
|
244
|
+
return () => {
|
|
245
|
+
for (let unbind of unbinds) unbind();
|
|
38
246
|
};
|
|
39
|
-
})
|
|
40
|
-
|
|
247
|
+
});
|
|
248
|
+
return $computed;
|
|
249
|
+
};
|
|
250
|
+
var batched = /* @__NO_SIDE_EFFECTS__ */ (stores, fn) => computedStore(stores, fn, true);
|
|
251
|
+
// src/aichat/ChatContext.tsx
|
|
252
|
+
var ChatContext = createContext(null);
|
|
41
253
|
function useChatContext() {
|
|
42
|
-
return
|
|
254
|
+
return nonNullable(use(ChatContext), "useChatContext: ChatProvider is not provided");
|
|
43
255
|
}
|
|
44
|
-
|
|
45
|
-
//#region src/aichat/ChatInput.tsx
|
|
256
|
+
// src/aichat/ChatInput.tsx
|
|
46
257
|
function ChatInput() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
|
|
258
|
+
const $ = c(22);
|
|
259
|
+
const { sendMessage, isLoading, messages, clear, stop } = useChatContext();
|
|
260
|
+
const [value, setValue] = useState("");
|
|
261
|
+
const inputRef = useRef(null);
|
|
262
|
+
let t0;
|
|
263
|
+
if ($[0] !== isLoading || $[1] !== sendMessage || $[2] !== value) {
|
|
264
|
+
t0 = () => {
|
|
265
|
+
if (!value.trim() || isLoading) return;
|
|
266
|
+
sendMessage(value);
|
|
267
|
+
setValue("");
|
|
268
|
+
};
|
|
269
|
+
$[0] = isLoading;
|
|
270
|
+
$[1] = sendMessage;
|
|
271
|
+
$[2] = value;
|
|
272
|
+
$[3] = t0;
|
|
273
|
+
} else t0 = $[3];
|
|
274
|
+
const handleSubmit = t0;
|
|
275
|
+
let t1;
|
|
276
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
277
|
+
t1 = (e) => setValue(e.target.value);
|
|
278
|
+
$[4] = t1;
|
|
279
|
+
} else t1 = $[4];
|
|
53
280
|
let t2;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
281
|
+
if ($[5] !== handleSubmit) {
|
|
282
|
+
t2 = (e_0) => {
|
|
283
|
+
if (e_0.key === "Enter" && !e_0.shiftKey && !e_0.ctrlKey && !e_0.metaKey) {
|
|
284
|
+
e_0.preventDefault();
|
|
285
|
+
handleSubmit();
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
$[5] = handleSubmit;
|
|
289
|
+
$[6] = t2;
|
|
290
|
+
} else t2 = $[6];
|
|
291
|
+
let t3;
|
|
292
|
+
if ($[7] !== isLoading || $[8] !== t2 || $[9] !== value) {
|
|
293
|
+
t3 = /* @__PURE__ */ jsx(Textarea, {
|
|
294
|
+
flex: 1,
|
|
295
|
+
className: "chat-input",
|
|
296
|
+
placeholder: "Your question...",
|
|
297
|
+
value,
|
|
298
|
+
onChange: t1,
|
|
299
|
+
onKeyDown: t2,
|
|
300
|
+
disabled: isLoading,
|
|
301
|
+
ref: inputRef,
|
|
302
|
+
loading: isLoading,
|
|
303
|
+
autosize: true,
|
|
304
|
+
minRows: 1
|
|
305
|
+
});
|
|
306
|
+
$[7] = isLoading;
|
|
307
|
+
$[8] = t2;
|
|
308
|
+
$[9] = value;
|
|
309
|
+
$[10] = t3;
|
|
310
|
+
} else t3 = $[10];
|
|
311
|
+
let t4;
|
|
312
|
+
if ($[11] !== clear || $[12] !== isLoading || $[13] !== messages.length) {
|
|
313
|
+
t4 = messages.length > 0 && !isLoading && /* @__PURE__ */ jsx(Button, {
|
|
314
|
+
size: "sm",
|
|
315
|
+
color: "red",
|
|
316
|
+
variant: "light",
|
|
317
|
+
onClick: () => clear(),
|
|
318
|
+
children: "Clear"
|
|
319
|
+
});
|
|
320
|
+
$[11] = clear;
|
|
321
|
+
$[12] = isLoading;
|
|
322
|
+
$[13] = messages.length;
|
|
323
|
+
$[14] = t4;
|
|
324
|
+
} else t4 = $[14];
|
|
325
|
+
let t5;
|
|
326
|
+
if ($[15] !== isLoading || $[16] !== stop) {
|
|
327
|
+
t5 = isLoading && /* @__PURE__ */ jsx(ActionIcon, {
|
|
328
|
+
color: "red",
|
|
329
|
+
variant: "light",
|
|
330
|
+
onClick: () => stop(),
|
|
331
|
+
children: /* @__PURE__ */ jsx(IconPlayerStopFilled, {})
|
|
332
|
+
});
|
|
333
|
+
$[15] = isLoading;
|
|
334
|
+
$[16] = stop;
|
|
335
|
+
$[17] = t5;
|
|
336
|
+
} else t5 = $[17];
|
|
337
|
+
let t6;
|
|
338
|
+
if ($[18] !== t3 || $[19] !== t4 || $[20] !== t5) {
|
|
339
|
+
t6 = /* @__PURE__ */ jsxs(HStack, { children: [
|
|
340
|
+
t3,
|
|
341
|
+
t4,
|
|
342
|
+
t5
|
|
343
|
+
] });
|
|
344
|
+
$[18] = t3;
|
|
345
|
+
$[19] = t4;
|
|
346
|
+
$[20] = t5;
|
|
347
|
+
$[21] = t6;
|
|
348
|
+
} else t6 = $[21];
|
|
349
|
+
return t6;
|
|
350
|
+
}
|
|
351
|
+
// src/aichat/ChatMessage.tsx
|
|
95
352
|
function ChatMessages() {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
let
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
353
|
+
const $ = c(7);
|
|
354
|
+
const { messages, error } = useChatContext();
|
|
355
|
+
let t0;
|
|
356
|
+
if ($[0] !== messages) {
|
|
357
|
+
t0 = messages.map(_temp);
|
|
358
|
+
$[0] = messages;
|
|
359
|
+
$[1] = t0;
|
|
360
|
+
} else t0 = $[1];
|
|
361
|
+
let t1;
|
|
362
|
+
if ($[2] !== error) {
|
|
363
|
+
t1 = error && /* @__PURE__ */ jsx(Notification, {
|
|
364
|
+
styles: { icon: { alignSelf: "flex-start" } },
|
|
365
|
+
color: "red",
|
|
366
|
+
title: "Oops, something went wrong",
|
|
367
|
+
withCloseButton: false,
|
|
368
|
+
children: /* @__PURE__ */ jsxs(Txt, {
|
|
369
|
+
fontSize: "sm",
|
|
370
|
+
fontFamily: "mono",
|
|
371
|
+
whiteSpace: "pre",
|
|
372
|
+
my: "xs",
|
|
373
|
+
children: [error.message, error.stack && "\n" + error.stack]
|
|
374
|
+
})
|
|
375
|
+
});
|
|
376
|
+
$[2] = error;
|
|
377
|
+
$[3] = t1;
|
|
378
|
+
} else t1 = $[3];
|
|
379
|
+
let t2;
|
|
380
|
+
if ($[4] !== t0 || $[5] !== t1) {
|
|
381
|
+
t2 = /* @__PURE__ */ jsxs(Fragment, { children: [t0, t1] });
|
|
382
|
+
$[4] = t0;
|
|
383
|
+
$[5] = t1;
|
|
384
|
+
$[6] = t2;
|
|
385
|
+
} else t2 = $[6];
|
|
386
|
+
return t2;
|
|
387
|
+
}
|
|
388
|
+
function _temp(message) {
|
|
389
|
+
return /* @__PURE__ */ jsx(ChatMessage, { message }, message.id);
|
|
390
|
+
}
|
|
391
|
+
var ChatMessage = (t0) => {
|
|
392
|
+
const $ = c(4);
|
|
393
|
+
const { message } = t0;
|
|
394
|
+
const role = message.role;
|
|
395
|
+
let t1;
|
|
396
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
397
|
+
t1 = css({
|
|
398
|
+
color: "text.bright",
|
|
399
|
+
alignSelf: "flex-end",
|
|
400
|
+
paddingInline: "2",
|
|
401
|
+
paddingBlock: "1",
|
|
402
|
+
marginInlineEnd: "2",
|
|
403
|
+
rounded: "sm",
|
|
404
|
+
backgroundColor: "surface.hover",
|
|
405
|
+
whiteSpace: "pre-wrap"
|
|
406
|
+
});
|
|
407
|
+
$[0] = t1;
|
|
408
|
+
} else t1 = $[0];
|
|
409
|
+
const t2 = role === "user" ? UserMessageTextPart : MarkdownTextPart;
|
|
410
|
+
let t3;
|
|
411
|
+
if ($[1] !== message || $[2] !== t2) {
|
|
412
|
+
t3 = /* @__PURE__ */ jsx(ChatMessage$1, {
|
|
413
|
+
message,
|
|
414
|
+
userClassName: t1,
|
|
415
|
+
textPartRenderer: t2
|
|
416
|
+
});
|
|
417
|
+
$[1] = message;
|
|
418
|
+
$[2] = t2;
|
|
419
|
+
$[3] = t3;
|
|
420
|
+
} else t3 = $[3];
|
|
421
|
+
return t3;
|
|
422
|
+
};
|
|
423
|
+
var UserMessageTextPart = (t0) => {
|
|
424
|
+
const $ = c(2);
|
|
425
|
+
const { content } = t0;
|
|
426
|
+
let t1;
|
|
427
|
+
if ($[0] !== content) {
|
|
428
|
+
t1 = /* @__PURE__ */ jsx(Fragment, { children: content });
|
|
429
|
+
$[0] = content;
|
|
430
|
+
$[1] = t1;
|
|
431
|
+
} else t1 = $[1];
|
|
432
|
+
return t1;
|
|
433
|
+
};
|
|
434
|
+
var MarkdownTextPart = (t0) => {
|
|
435
|
+
const $ = c(4);
|
|
436
|
+
const { content } = t0;
|
|
437
|
+
let t1;
|
|
438
|
+
if ($[0] !== content) {
|
|
439
|
+
t1 = RichText.from({ md: content });
|
|
440
|
+
$[0] = content;
|
|
441
|
+
$[1] = t1;
|
|
442
|
+
} else t1 = $[1];
|
|
443
|
+
let t2;
|
|
444
|
+
if ($[2] !== t1) {
|
|
445
|
+
t2 = /* @__PURE__ */ jsx(Markdown, {
|
|
446
|
+
textScale: .95,
|
|
447
|
+
value: t1
|
|
448
|
+
});
|
|
449
|
+
$[2] = t1;
|
|
450
|
+
$[3] = t2;
|
|
451
|
+
} else t2 = $[3];
|
|
452
|
+
return t2;
|
|
453
|
+
};
|
|
454
|
+
// src/aichat/semantic-layout-log-state.ts
|
|
455
|
+
var $log = /* @__PURE__ */ atom("");
|
|
456
|
+
var $status = /* @__PURE__ */ atom("closed");
|
|
457
|
+
var $state = /* @__PURE__ */ batched([$log, $status], (log, status) => ({
|
|
458
|
+
log,
|
|
459
|
+
status
|
|
150
460
|
}));
|
|
151
461
|
function useSemanticLayoutLog() {
|
|
152
|
-
return
|
|
462
|
+
return useStore($state);
|
|
153
463
|
}
|
|
154
464
|
function closeSemanticLayoutLog() {
|
|
155
|
-
|
|
465
|
+
$status.set("closed");
|
|
466
|
+
$log.set("");
|
|
156
467
|
}
|
|
157
|
-
|
|
158
|
-
|
|
468
|
+
// src/aichat/SemanticLayoutLog.tsx
|
|
469
|
+
/**
|
|
470
|
+
* Modal that shows the log of the semantic layout application
|
|
471
|
+
* (For internal debugging purposes)
|
|
472
|
+
*/
|
|
159
473
|
function SemanticLayoutLog() {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
474
|
+
const $ = c(6);
|
|
475
|
+
const { log, status } = useSemanticLayoutLog();
|
|
476
|
+
if (status === "closed") return null;
|
|
477
|
+
const closable = status === "completed";
|
|
478
|
+
let t0;
|
|
479
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
480
|
+
t0 = /* @__PURE__ */ jsx(Title, {
|
|
481
|
+
order: 4,
|
|
482
|
+
children: "Semantic Layout"
|
|
483
|
+
});
|
|
484
|
+
$[0] = t0;
|
|
485
|
+
} else t0 = $[0];
|
|
486
|
+
const t1 = log || "Waiting for response...";
|
|
487
|
+
let t2;
|
|
488
|
+
if ($[1] !== t1) {
|
|
489
|
+
t2 = /* @__PURE__ */ jsx(Txt, {
|
|
490
|
+
whiteSpace: "pre-wrap",
|
|
491
|
+
children: t1
|
|
492
|
+
});
|
|
493
|
+
$[1] = t1;
|
|
494
|
+
$[2] = t2;
|
|
495
|
+
} else t2 = $[2];
|
|
496
|
+
let t3;
|
|
497
|
+
if ($[3] !== closable || $[4] !== t2) {
|
|
498
|
+
t3 = /* @__PURE__ */ jsx(Modal, {
|
|
499
|
+
size: "xl",
|
|
500
|
+
opened: true,
|
|
501
|
+
onClose: closeSemanticLayoutLog,
|
|
502
|
+
closeOnEscape: closable,
|
|
503
|
+
withCloseButton: closable,
|
|
504
|
+
closeOnClickOutside: closable,
|
|
505
|
+
title: t0,
|
|
506
|
+
children: t2
|
|
507
|
+
});
|
|
508
|
+
$[3] = closable;
|
|
509
|
+
$[4] = t2;
|
|
510
|
+
$[5] = t3;
|
|
511
|
+
} else t3 = $[5];
|
|
512
|
+
return t3;
|
|
513
|
+
}
|
|
514
|
+
// ../vite-plugin/src/ai/tools.ts
|
|
515
|
+
var nodeSchema = z.object({
|
|
516
|
+
id: z.string().meta({ description: "Node ID" }),
|
|
517
|
+
title: z.string(),
|
|
518
|
+
shape: z.enum(ElementShapes),
|
|
519
|
+
color: z.string().meta({ description: "Node color, from theme or custom" }),
|
|
520
|
+
icon: z.string().nullish(),
|
|
521
|
+
parentId: z.string().nullish().meta({ description: "Parent node ID (if node is nested)" }),
|
|
522
|
+
children: z.array(z.string()).nullish().meta({ description: "Nested node IDs (if node is compound)" }),
|
|
523
|
+
x: z.number(),
|
|
524
|
+
y: z.number(),
|
|
525
|
+
width: z.number(),
|
|
526
|
+
height: z.number(),
|
|
527
|
+
modelFqn: z.string().nullish().meta({ description: "Model element FQN (if node has reference)" })
|
|
528
|
+
});
|
|
529
|
+
var readUiStateDef = toolDefinition({
|
|
200
530
|
name: "read_ui",
|
|
201
531
|
description: "Read current UI state. Use arguments to include additional data.",
|
|
202
|
-
needsApproval:
|
|
203
|
-
inputSchema:
|
|
204
|
-
selectedNode:
|
|
205
|
-
nodes:
|
|
532
|
+
needsApproval: false,
|
|
533
|
+
inputSchema: z.object({
|
|
534
|
+
selectedNode: z.boolean().default(false).meta({ description: "Include selected node (if any)" }),
|
|
535
|
+
nodes: z.boolean().default(false).meta({ description: "Include all nodes from the view" })
|
|
206
536
|
}),
|
|
207
|
-
outputSchema:
|
|
208
|
-
projectId:
|
|
209
|
-
editMode:
|
|
210
|
-
view:
|
|
211
|
-
id:
|
|
212
|
-
title:
|
|
213
|
-
type:
|
|
537
|
+
outputSchema: z.object({
|
|
538
|
+
projectId: z.string(),
|
|
539
|
+
editMode: z.boolean().meta({ description: "Whether the UI is in edit mode" }),
|
|
540
|
+
view: z.object({
|
|
541
|
+
id: z.string(),
|
|
542
|
+
title: z.string(),
|
|
543
|
+
type: z.enum([
|
|
214
544
|
"element",
|
|
215
545
|
"deployment",
|
|
216
546
|
"dynamic"
|
|
217
547
|
]).meta({ description: "Type of the current view" })
|
|
218
548
|
}).meta({ description: "Current view" }),
|
|
219
|
-
nodes:
|
|
220
|
-
selectedNode:
|
|
549
|
+
nodes: z.array(nodeSchema).nullish(),
|
|
550
|
+
selectedNode: nodeSchema.nullish()
|
|
221
551
|
})
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
552
|
+
});
|
|
553
|
+
var focusCommand = z.object({
|
|
554
|
+
type: z.literal("focus"),
|
|
555
|
+
elementId: z.string().meta({ description: "Element ID (FQN)" })
|
|
556
|
+
}).meta({ description: "Focus UI on an element by its FQN" });
|
|
557
|
+
var fitViewCommand = z.object({ type: z.literal("fitview") }).meta({ description: "Zoom out to fit all elements in the viewport, and clear any selection/focus" });
|
|
558
|
+
var updateUiStateDef = toolDefinition({
|
|
226
559
|
name: "update_ui",
|
|
227
560
|
description: "Update UI state by executing a command.",
|
|
228
|
-
needsApproval:
|
|
229
|
-
inputSchema:
|
|
230
|
-
outputSchema:
|
|
231
|
-
})
|
|
561
|
+
needsApproval: false,
|
|
562
|
+
inputSchema: z.object({ command: z.discriminatedUnion("type", [focusCommand, fitViewCommand]) }),
|
|
563
|
+
outputSchema: z.object({})
|
|
564
|
+
});
|
|
565
|
+
var navigateToDef = toolDefinition({
|
|
232
566
|
name: "navigate_to",
|
|
233
567
|
description: "Navigates UI to another view",
|
|
234
|
-
needsApproval:
|
|
235
|
-
inputSchema:
|
|
236
|
-
outputSchema:
|
|
237
|
-
})
|
|
568
|
+
needsApproval: false,
|
|
569
|
+
inputSchema: z.object({ viewId: z.string().meta({ description: "View ID" }) }),
|
|
570
|
+
outputSchema: z.object({})
|
|
571
|
+
});
|
|
572
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/double-indexed-kv.js
|
|
573
|
+
var DoubleIndexedKV = class {
|
|
238
574
|
constructor() {
|
|
239
|
-
this.keyToValue = /* @__PURE__ */ new Map()
|
|
575
|
+
this.keyToValue = /* @__PURE__ */ new Map();
|
|
576
|
+
this.valueToKey = /* @__PURE__ */ new Map();
|
|
240
577
|
}
|
|
241
|
-
set(
|
|
242
|
-
this.keyToValue.set(
|
|
578
|
+
set(key, value) {
|
|
579
|
+
this.keyToValue.set(key, value);
|
|
580
|
+
this.valueToKey.set(value, key);
|
|
243
581
|
}
|
|
244
|
-
getByKey(
|
|
245
|
-
return this.keyToValue.get(
|
|
582
|
+
getByKey(key) {
|
|
583
|
+
return this.keyToValue.get(key);
|
|
246
584
|
}
|
|
247
|
-
getByValue(
|
|
248
|
-
return this.valueToKey.get(
|
|
585
|
+
getByValue(value) {
|
|
586
|
+
return this.valueToKey.get(value);
|
|
249
587
|
}
|
|
250
588
|
clear() {
|
|
251
|
-
this.keyToValue.clear()
|
|
589
|
+
this.keyToValue.clear();
|
|
590
|
+
this.valueToKey.clear();
|
|
252
591
|
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
592
|
+
};
|
|
593
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/registry.js
|
|
594
|
+
var Registry = class {
|
|
595
|
+
constructor(generateIdentifier) {
|
|
596
|
+
this.generateIdentifier = generateIdentifier;
|
|
597
|
+
this.kv = new DoubleIndexedKV();
|
|
256
598
|
}
|
|
257
|
-
register(
|
|
258
|
-
this.kv.getByValue(
|
|
599
|
+
register(value, identifier) {
|
|
600
|
+
if (this.kv.getByValue(value)) return;
|
|
601
|
+
if (!identifier) identifier = this.generateIdentifier(value);
|
|
602
|
+
this.kv.set(identifier, value);
|
|
259
603
|
}
|
|
260
604
|
clear() {
|
|
261
605
|
this.kv.clear();
|
|
262
606
|
}
|
|
263
|
-
getIdentifier(
|
|
264
|
-
return this.kv.getByValue(
|
|
607
|
+
getIdentifier(value) {
|
|
608
|
+
return this.kv.getByValue(value);
|
|
265
609
|
}
|
|
266
|
-
getValue(
|
|
267
|
-
return this.kv.getByKey(
|
|
610
|
+
getValue(identifier) {
|
|
611
|
+
return this.kv.getByKey(identifier);
|
|
268
612
|
}
|
|
269
|
-
}
|
|
613
|
+
};
|
|
614
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/class-registry.js
|
|
615
|
+
var ClassRegistry = class extends Registry {
|
|
270
616
|
constructor() {
|
|
271
|
-
super((
|
|
617
|
+
super((c) => c.name);
|
|
618
|
+
this.classToAllowedProps = /* @__PURE__ */ new Map();
|
|
272
619
|
}
|
|
273
|
-
register(
|
|
274
|
-
typeof
|
|
620
|
+
register(value, options) {
|
|
621
|
+
if (typeof options === "object") {
|
|
622
|
+
if (options.allowProps) this.classToAllowedProps.set(value, options.allowProps);
|
|
623
|
+
super.register(value, options.identifier);
|
|
624
|
+
} else super.register(value, options);
|
|
275
625
|
}
|
|
276
|
-
getAllowedProps(
|
|
277
|
-
return this.classToAllowedProps.get(
|
|
626
|
+
getAllowedProps(value) {
|
|
627
|
+
return this.classToAllowedProps.get(value);
|
|
278
628
|
}
|
|
279
629
|
};
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return t;
|
|
630
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/util.js
|
|
631
|
+
function valuesOfObj(record) {
|
|
632
|
+
if ("values" in Object) return Object.values(record);
|
|
633
|
+
const values = [];
|
|
634
|
+
for (const key in record) if (record.hasOwnProperty(key)) values.push(record[key]);
|
|
635
|
+
return values;
|
|
287
636
|
}
|
|
288
|
-
function find(
|
|
289
|
-
|
|
290
|
-
if ("find" in
|
|
291
|
-
|
|
292
|
-
for (let
|
|
293
|
-
|
|
294
|
-
if (
|
|
637
|
+
function find(record, predicate) {
|
|
638
|
+
const values = valuesOfObj(record);
|
|
639
|
+
if ("find" in values) return values.find(predicate);
|
|
640
|
+
const valuesNotNever = values;
|
|
641
|
+
for (let i = 0; i < valuesNotNever.length; i++) {
|
|
642
|
+
const value = valuesNotNever[i];
|
|
643
|
+
if (predicate(value)) return value;
|
|
295
644
|
}
|
|
296
645
|
}
|
|
297
|
-
function forEach(
|
|
298
|
-
Object.entries(
|
|
646
|
+
function forEach(record, run) {
|
|
647
|
+
Object.entries(record).forEach(([key, value]) => run(value, key));
|
|
299
648
|
}
|
|
300
|
-
function includes(
|
|
301
|
-
return
|
|
649
|
+
function includes(arr, value) {
|
|
650
|
+
return arr.indexOf(value) !== -1;
|
|
302
651
|
}
|
|
303
|
-
function findArr(
|
|
304
|
-
for (let
|
|
305
|
-
|
|
306
|
-
if (
|
|
652
|
+
function findArr(record, predicate) {
|
|
653
|
+
for (let i = 0; i < record.length; i++) {
|
|
654
|
+
const value = record[i];
|
|
655
|
+
if (predicate(value)) return value;
|
|
307
656
|
}
|
|
308
657
|
}
|
|
309
|
-
|
|
310
|
-
//#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/custom-transformer-registry.js
|
|
658
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/custom-transformer-registry.js
|
|
311
659
|
var CustomTransformerRegistry = class {
|
|
312
660
|
constructor() {
|
|
313
661
|
this.transfomers = {};
|
|
314
662
|
}
|
|
315
|
-
register(
|
|
316
|
-
this.transfomers[
|
|
663
|
+
register(transformer) {
|
|
664
|
+
this.transfomers[transformer.name] = transformer;
|
|
317
665
|
}
|
|
318
|
-
findApplicable(
|
|
319
|
-
return find(this.transfomers, (
|
|
666
|
+
findApplicable(v) {
|
|
667
|
+
return find(this.transfomers, (transformer) => transformer.isApplicable(v));
|
|
320
668
|
}
|
|
321
|
-
findByName(
|
|
322
|
-
return this.transfomers[
|
|
669
|
+
findByName(name) {
|
|
670
|
+
return this.transfomers[name];
|
|
323
671
|
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
672
|
+
};
|
|
673
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/is.js
|
|
674
|
+
var getType$1 = /* @__PURE__ */ __name((payload) => Object.prototype.toString.call(payload).slice(8, -1), "getType");
|
|
675
|
+
var isUndefined = (payload) => typeof payload === "undefined";
|
|
676
|
+
var isNull = (payload) => payload === null;
|
|
677
|
+
var isPlainObject$1 = /* @__PURE__ */ __name((payload) => {
|
|
678
|
+
if (typeof payload !== "object" || payload === null) return false;
|
|
679
|
+
if (payload === Object.prototype) return false;
|
|
680
|
+
if (Object.getPrototypeOf(payload) === null) return true;
|
|
681
|
+
return Object.getPrototypeOf(payload) === Object.prototype;
|
|
682
|
+
}, "isPlainObject");
|
|
683
|
+
var isEmptyObject = (payload) => isPlainObject$1(payload) && Object.keys(payload).length === 0;
|
|
684
|
+
var isArray$1 = /* @__PURE__ */ __name((payload) => Array.isArray(payload), "isArray");
|
|
685
|
+
var isString = (payload) => typeof payload === "string";
|
|
686
|
+
var isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
|
|
687
|
+
var isBoolean = (payload) => typeof payload === "boolean";
|
|
688
|
+
var isRegExp = (payload) => payload instanceof RegExp;
|
|
689
|
+
var isMap = (payload) => payload instanceof Map;
|
|
690
|
+
var isSet = (payload) => payload instanceof Set;
|
|
691
|
+
var isSymbol = (payload) => getType$1(payload) === "Symbol";
|
|
692
|
+
var isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
|
|
693
|
+
var isError = (payload) => payload instanceof Error;
|
|
694
|
+
var isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
|
|
695
|
+
var isPrimitive = (payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
|
|
696
|
+
var isBigint = (payload) => typeof payload === "bigint";
|
|
697
|
+
var isInfinite = (payload) => payload === Infinity || payload === -Infinity;
|
|
698
|
+
var isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
|
|
699
|
+
var isURL = (payload) => payload instanceof URL;
|
|
700
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/pathstringifier.js
|
|
701
|
+
var escapeKey = (key) => key.replace(/\\/g, "\\\\").replace(/\./g, "\\.");
|
|
702
|
+
var stringifyPath = (path) => path.map(String).map(escapeKey).join(".");
|
|
703
|
+
var parsePath = (string, legacyPaths) => {
|
|
704
|
+
const result = [];
|
|
705
|
+
let segment = "";
|
|
706
|
+
for (let i = 0; i < string.length; i++) {
|
|
707
|
+
let char = string.charAt(i);
|
|
708
|
+
if (!legacyPaths && char === "\\") {
|
|
709
|
+
const escaped = string.charAt(i + 1);
|
|
710
|
+
if (escaped === "\\") {
|
|
711
|
+
segment += "\\";
|
|
712
|
+
i++;
|
|
332
713
|
continue;
|
|
333
|
-
}
|
|
334
|
-
if (t !== ".") throw Error("invalid path");
|
|
714
|
+
} else if (escaped !== ".") throw Error("invalid path");
|
|
335
715
|
}
|
|
336
|
-
if (
|
|
337
|
-
|
|
716
|
+
if (char === "\\" && string.charAt(i + 1) === ".") {
|
|
717
|
+
segment += ".";
|
|
718
|
+
i++;
|
|
338
719
|
continue;
|
|
339
720
|
}
|
|
340
|
-
if (
|
|
341
|
-
|
|
721
|
+
if (char === ".") {
|
|
722
|
+
result.push(segment);
|
|
723
|
+
segment = "";
|
|
342
724
|
continue;
|
|
343
725
|
}
|
|
344
|
-
|
|
726
|
+
segment += char;
|
|
345
727
|
}
|
|
346
|
-
|
|
347
|
-
|
|
728
|
+
const lastSegment = segment;
|
|
729
|
+
result.push(lastSegment);
|
|
730
|
+
return result;
|
|
348
731
|
};
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
function simpleTransformation(e, t, n, r) {
|
|
732
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/transformer.js
|
|
733
|
+
function simpleTransformation(isApplicable, annotation, transform, untransform) {
|
|
352
734
|
return {
|
|
353
|
-
isApplicable
|
|
354
|
-
annotation
|
|
355
|
-
transform
|
|
356
|
-
untransform
|
|
735
|
+
isApplicable,
|
|
736
|
+
annotation,
|
|
737
|
+
transform,
|
|
738
|
+
untransform
|
|
357
739
|
};
|
|
358
740
|
}
|
|
359
|
-
var
|
|
741
|
+
var simpleRules = [
|
|
360
742
|
simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
|
|
361
|
-
simpleTransformation(isBigint, "bigint", (
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
743
|
+
simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
|
|
744
|
+
if (typeof BigInt !== "undefined") return BigInt(v);
|
|
745
|
+
console.error("Please add a BigInt polyfill.");
|
|
746
|
+
return v;
|
|
747
|
+
}),
|
|
748
|
+
simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
|
|
749
|
+
simpleTransformation(isError, "Error", (v, superJson) => {
|
|
750
|
+
const baseError = {
|
|
751
|
+
name: v.name,
|
|
752
|
+
message: v.message
|
|
367
753
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
754
|
+
if ("cause" in v) baseError.cause = v.cause;
|
|
755
|
+
superJson.allowedErrorProps.forEach((prop) => {
|
|
756
|
+
baseError[prop] = v[prop];
|
|
757
|
+
});
|
|
758
|
+
return baseError;
|
|
759
|
+
}, (v, superJson) => {
|
|
760
|
+
const e = new Error(v.message, { cause: v.cause });
|
|
761
|
+
e.name = v.name;
|
|
762
|
+
e.stack = v.stack;
|
|
763
|
+
superJson.allowedErrorProps.forEach((prop) => {
|
|
764
|
+
e[prop] = v[prop];
|
|
765
|
+
});
|
|
766
|
+
return e;
|
|
376
767
|
}),
|
|
377
|
-
simpleTransformation(isRegExp, "regexp", (
|
|
378
|
-
|
|
379
|
-
|
|
768
|
+
simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
|
|
769
|
+
const body = regex.slice(1, regex.lastIndexOf("/"));
|
|
770
|
+
const flags = regex.slice(regex.lastIndexOf("/") + 1);
|
|
771
|
+
return new RegExp(body, flags);
|
|
380
772
|
}),
|
|
381
|
-
simpleTransformation(isSet, "set", (
|
|
382
|
-
simpleTransformation(isMap, "map", (
|
|
383
|
-
simpleTransformation((
|
|
384
|
-
|
|
385
|
-
|
|
773
|
+
simpleTransformation(isSet, "set", (v) => [...v.values()], (v) => new Set(v)),
|
|
774
|
+
simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
|
|
775
|
+
simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
|
|
776
|
+
if (isNaNValue(v)) return "NaN";
|
|
777
|
+
if (v > 0) return "Infinity";
|
|
778
|
+
else return "-Infinity";
|
|
779
|
+
}, Number),
|
|
780
|
+
simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
|
|
781
|
+
return "-0";
|
|
782
|
+
}, Number),
|
|
783
|
+
simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
|
|
386
784
|
];
|
|
387
|
-
function compositeTransformation(
|
|
785
|
+
function compositeTransformation(isApplicable, annotation, transform, untransform) {
|
|
388
786
|
return {
|
|
389
|
-
isApplicable
|
|
390
|
-
annotation
|
|
391
|
-
transform
|
|
392
|
-
untransform
|
|
787
|
+
isApplicable,
|
|
788
|
+
annotation,
|
|
789
|
+
transform,
|
|
790
|
+
untransform
|
|
393
791
|
};
|
|
394
792
|
}
|
|
395
|
-
var
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
793
|
+
var symbolRule = compositeTransformation((s, superJson) => {
|
|
794
|
+
if (isSymbol(s)) return !!superJson.symbolRegistry.getIdentifier(s);
|
|
795
|
+
return false;
|
|
796
|
+
}, (s, superJson) => {
|
|
797
|
+
return ["symbol", superJson.symbolRegistry.getIdentifier(s)];
|
|
798
|
+
}, (v) => v.description, (_, a, superJson) => {
|
|
799
|
+
const value = superJson.symbolRegistry.getValue(a[1]);
|
|
800
|
+
if (!value) throw new Error("Trying to deserialize unknown symbol");
|
|
801
|
+
return value;
|
|
802
|
+
});
|
|
803
|
+
var constructorToName = [
|
|
400
804
|
Int8Array,
|
|
401
805
|
Uint8Array,
|
|
402
806
|
Int16Array,
|
|
@@ -406,451 +810,616 @@ var K = compositeTransformation((e, t) => isSymbol(e) ? !!t.symbolRegistry.getId
|
|
|
406
810
|
Float32Array,
|
|
407
811
|
Float64Array,
|
|
408
812
|
Uint8ClampedArray
|
|
409
|
-
].reduce((
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
813
|
+
].reduce((obj, ctor) => {
|
|
814
|
+
obj[ctor.name] = ctor;
|
|
815
|
+
return obj;
|
|
816
|
+
}, {});
|
|
817
|
+
var typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
|
|
818
|
+
const ctor = constructorToName[a[1]];
|
|
819
|
+
if (!ctor) throw new Error("Trying to deserialize unknown typed array");
|
|
820
|
+
return new ctor(v);
|
|
821
|
+
});
|
|
822
|
+
function isInstanceOfRegisteredClass(potentialClass, superJson) {
|
|
823
|
+
if (potentialClass?.constructor) return !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
|
|
824
|
+
return false;
|
|
825
|
+
}
|
|
826
|
+
var classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
|
|
827
|
+
return ["class", superJson.classRegistry.getIdentifier(clazz.constructor)];
|
|
828
|
+
}, (clazz, superJson) => {
|
|
829
|
+
const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
|
|
830
|
+
if (!allowedProps) return { ...clazz };
|
|
831
|
+
const result = {};
|
|
832
|
+
allowedProps.forEach((prop) => {
|
|
833
|
+
result[prop] = clazz[prop];
|
|
834
|
+
});
|
|
835
|
+
return result;
|
|
836
|
+
}, (v, a, superJson) => {
|
|
837
|
+
const clazz = superJson.classRegistry.getValue(a[1]);
|
|
838
|
+
if (!clazz) throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
|
|
839
|
+
return Object.assign(Object.create(clazz.prototype), v);
|
|
840
|
+
});
|
|
841
|
+
var customRule = compositeTransformation((value, superJson) => {
|
|
842
|
+
return !!superJson.customTransformerRegistry.findApplicable(value);
|
|
843
|
+
}, (value, superJson) => {
|
|
844
|
+
return ["custom", superJson.customTransformerRegistry.findApplicable(value).name];
|
|
845
|
+
}, (value, superJson) => {
|
|
846
|
+
return superJson.customTransformerRegistry.findApplicable(value).serialize(value);
|
|
847
|
+
}, (v, a, superJson) => {
|
|
848
|
+
const transformer = superJson.customTransformerRegistry.findByName(a[1]);
|
|
849
|
+
if (!transformer) throw new Error("Trying to deserialize unknown custom value");
|
|
850
|
+
return transformer.deserialize(v);
|
|
413
851
|
});
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
let r = n.classRegistry.getValue(t[1]);
|
|
426
|
-
if (!r) throw Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
|
|
427
|
-
return Object.assign(Object.create(r.prototype), e);
|
|
428
|
-
}), X = compositeTransformation((e, t) => !!t.customTransformerRegistry.findApplicable(e), (e, t) => ["custom", t.customTransformerRegistry.findApplicable(e).name], (e, t) => t.customTransformerRegistry.findApplicable(e).serialize(e), (e, t, n) => {
|
|
429
|
-
let r = n.customTransformerRegistry.findByName(t[1]);
|
|
430
|
-
if (!r) throw Error("Trying to deserialize unknown custom value");
|
|
431
|
-
return r.deserialize(e);
|
|
432
|
-
}), Oe = [
|
|
433
|
-
Y,
|
|
434
|
-
K,
|
|
435
|
-
X,
|
|
436
|
-
J
|
|
437
|
-
], transformValue = (e, t) => {
|
|
438
|
-
let n = findArr(Oe, (n) => n.isApplicable(e, t));
|
|
439
|
-
if (n) return {
|
|
440
|
-
value: n.transform(e, t),
|
|
441
|
-
type: n.annotation(e, t)
|
|
852
|
+
var compositeRules = [
|
|
853
|
+
classRule,
|
|
854
|
+
symbolRule,
|
|
855
|
+
customRule,
|
|
856
|
+
typedArrayRule
|
|
857
|
+
];
|
|
858
|
+
var transformValue = (value, superJson) => {
|
|
859
|
+
const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
|
|
860
|
+
if (applicableCompositeRule) return {
|
|
861
|
+
value: applicableCompositeRule.transform(value, superJson),
|
|
862
|
+
type: applicableCompositeRule.annotation(value, superJson)
|
|
442
863
|
};
|
|
443
|
-
|
|
444
|
-
if (
|
|
445
|
-
value:
|
|
446
|
-
type:
|
|
864
|
+
const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
|
|
865
|
+
if (applicableSimpleRule) return {
|
|
866
|
+
value: applicableSimpleRule.transform(value, superJson),
|
|
867
|
+
type: applicableSimpleRule.annotation
|
|
447
868
|
};
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
869
|
+
};
|
|
870
|
+
var simpleRulesByAnnotation = {};
|
|
871
|
+
simpleRules.forEach((rule) => {
|
|
872
|
+
simpleRulesByAnnotation[rule.annotation] = rule;
|
|
451
873
|
});
|
|
452
|
-
var untransformValue = (
|
|
453
|
-
if (
|
|
454
|
-
case "symbol": return
|
|
455
|
-
case "class": return
|
|
456
|
-
case "custom": return
|
|
457
|
-
case "typed-array": return
|
|
458
|
-
default: throw Error("Unknown transformation: " +
|
|
874
|
+
var untransformValue = (json, type, superJson) => {
|
|
875
|
+
if (isArray$1(type)) switch (type[0]) {
|
|
876
|
+
case "symbol": return symbolRule.untransform(json, type, superJson);
|
|
877
|
+
case "class": return classRule.untransform(json, type, superJson);
|
|
878
|
+
case "custom": return customRule.untransform(json, type, superJson);
|
|
879
|
+
case "typed-array": return typedArrayRule.untransform(json, type, superJson);
|
|
880
|
+
default: throw new Error("Unknown transformation: " + type);
|
|
459
881
|
}
|
|
460
882
|
else {
|
|
461
|
-
|
|
462
|
-
if (!
|
|
463
|
-
return
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
883
|
+
const transformation = simpleRulesByAnnotation[type];
|
|
884
|
+
if (!transformation) throw new Error("Unknown transformation: " + type);
|
|
885
|
+
return transformation.untransform(json, superJson);
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/accessDeep.js
|
|
889
|
+
var getNthKey = (value, n) => {
|
|
890
|
+
if (n > value.size) throw new Error("index out of bounds");
|
|
891
|
+
const keys = value.keys();
|
|
892
|
+
while (n > 0) {
|
|
893
|
+
keys.next();
|
|
894
|
+
n--;
|
|
895
|
+
}
|
|
896
|
+
return keys.next().value;
|
|
470
897
|
};
|
|
471
|
-
function validatePath(
|
|
472
|
-
if (includes(
|
|
473
|
-
if (includes(
|
|
474
|
-
if (includes(
|
|
475
|
-
}
|
|
476
|
-
var getDeep = (
|
|
477
|
-
validatePath(
|
|
478
|
-
for (let
|
|
479
|
-
|
|
480
|
-
if (isSet(
|
|
481
|
-
else if (isMap(
|
|
482
|
-
|
|
483
|
-
|
|
898
|
+
function validatePath(path) {
|
|
899
|
+
if (includes(path, "__proto__")) throw new Error("__proto__ is not allowed as a property");
|
|
900
|
+
if (includes(path, "prototype")) throw new Error("prototype is not allowed as a property");
|
|
901
|
+
if (includes(path, "constructor")) throw new Error("constructor is not allowed as a property");
|
|
902
|
+
}
|
|
903
|
+
var getDeep = (object, path) => {
|
|
904
|
+
validatePath(path);
|
|
905
|
+
for (let i = 0; i < path.length; i++) {
|
|
906
|
+
const key = path[i];
|
|
907
|
+
if (isSet(object)) object = getNthKey(object, +key);
|
|
908
|
+
else if (isMap(object)) {
|
|
909
|
+
const row = +key;
|
|
910
|
+
const type = +path[++i] === 0 ? "key" : "value";
|
|
911
|
+
const keyOfRow = getNthKey(object, row);
|
|
912
|
+
switch (type) {
|
|
484
913
|
case "key":
|
|
485
|
-
|
|
914
|
+
object = keyOfRow;
|
|
486
915
|
break;
|
|
487
|
-
case "value":
|
|
916
|
+
case "value": object = object.get(keyOfRow);
|
|
488
917
|
}
|
|
489
|
-
} else
|
|
490
|
-
}
|
|
491
|
-
return
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
918
|
+
} else object = object[key];
|
|
919
|
+
}
|
|
920
|
+
return object;
|
|
921
|
+
};
|
|
922
|
+
var setDeep = (object, path, mapper) => {
|
|
923
|
+
validatePath(path);
|
|
924
|
+
if (path.length === 0) return mapper(object);
|
|
925
|
+
let parent = object;
|
|
926
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
927
|
+
const key = path[i];
|
|
928
|
+
if (isArray$1(parent)) {
|
|
929
|
+
const index = +key;
|
|
930
|
+
parent = parent[index];
|
|
931
|
+
} else if (isPlainObject$1(parent)) parent = parent[key];
|
|
932
|
+
else if (isSet(parent)) {
|
|
933
|
+
const row = +key;
|
|
934
|
+
parent = getNthKey(parent, row);
|
|
935
|
+
} else if (isMap(parent)) {
|
|
936
|
+
if (i === path.length - 2) break;
|
|
937
|
+
const row = +key;
|
|
938
|
+
const type = +path[++i] === 0 ? "key" : "value";
|
|
939
|
+
const keyOfRow = getNthKey(parent, row);
|
|
940
|
+
switch (type) {
|
|
508
941
|
case "key":
|
|
509
|
-
|
|
942
|
+
parent = keyOfRow;
|
|
510
943
|
break;
|
|
511
|
-
case "value":
|
|
944
|
+
case "value": parent = parent.get(keyOfRow);
|
|
512
945
|
}
|
|
513
946
|
}
|
|
514
947
|
}
|
|
515
|
-
|
|
516
|
-
if (
|
|
517
|
-
|
|
518
|
-
|
|
948
|
+
const lastKey = path[path.length - 1];
|
|
949
|
+
if (isArray$1(parent)) parent[+lastKey] = mapper(parent[+lastKey]);
|
|
950
|
+
else if (isPlainObject$1(parent)) parent[lastKey] = mapper(parent[lastKey]);
|
|
951
|
+
if (isSet(parent)) {
|
|
952
|
+
const oldValue = getNthKey(parent, +lastKey);
|
|
953
|
+
const newValue = mapper(oldValue);
|
|
954
|
+
if (oldValue !== newValue) {
|
|
955
|
+
parent.delete(oldValue);
|
|
956
|
+
parent.add(newValue);
|
|
957
|
+
}
|
|
519
958
|
}
|
|
520
|
-
if (isMap(
|
|
521
|
-
|
|
522
|
-
|
|
959
|
+
if (isMap(parent)) {
|
|
960
|
+
const row = +path[path.length - 2];
|
|
961
|
+
const keyToRow = getNthKey(parent, row);
|
|
962
|
+
switch (+lastKey === 0 ? "key" : "value") {
|
|
523
963
|
case "key": {
|
|
524
|
-
|
|
525
|
-
|
|
964
|
+
const newKey = mapper(keyToRow);
|
|
965
|
+
parent.set(newKey, parent.get(keyToRow));
|
|
966
|
+
if (newKey !== keyToRow) parent.delete(keyToRow);
|
|
526
967
|
break;
|
|
527
968
|
}
|
|
528
|
-
case "value":
|
|
969
|
+
case "value": parent.set(keyToRow, mapper(parent.get(keyToRow)));
|
|
529
970
|
}
|
|
530
971
|
}
|
|
531
|
-
return
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
if (!
|
|
537
|
-
|
|
972
|
+
return object;
|
|
973
|
+
};
|
|
974
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/plainer.js
|
|
975
|
+
var enableLegacyPaths = (version) => version < 1;
|
|
976
|
+
function traverse(tree, walker, version, origin = []) {
|
|
977
|
+
if (!tree) return;
|
|
978
|
+
const legacyPaths = enableLegacyPaths(version);
|
|
979
|
+
if (!isArray$1(tree)) {
|
|
980
|
+
forEach(tree, (subtree, key) => traverse(subtree, walker, version, [...origin, ...parsePath(key, legacyPaths)]));
|
|
538
981
|
return;
|
|
539
982
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
traverse(
|
|
543
|
-
})
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
983
|
+
const [nodeValue, children] = tree;
|
|
984
|
+
if (children) forEach(children, (child, key) => {
|
|
985
|
+
traverse(child, walker, version, [...origin, ...parsePath(key, legacyPaths)]);
|
|
986
|
+
});
|
|
987
|
+
walker(nodeValue, origin);
|
|
988
|
+
}
|
|
989
|
+
function applyValueAnnotations(plain, annotations, version, superJson) {
|
|
990
|
+
traverse(annotations, (type, path) => {
|
|
991
|
+
plain = setDeep(plain, path, (v) => untransformValue(v, type, superJson));
|
|
992
|
+
}, version);
|
|
993
|
+
return plain;
|
|
994
|
+
}
|
|
995
|
+
function applyReferentialEqualityAnnotations(plain, annotations, version) {
|
|
996
|
+
const legacyPaths = enableLegacyPaths(version);
|
|
997
|
+
function apply(identicalPaths, path) {
|
|
998
|
+
const object = getDeep(plain, parsePath(path, legacyPaths));
|
|
999
|
+
identicalPaths.map((path) => parsePath(path, legacyPaths)).forEach((identicalObjectPath) => {
|
|
1000
|
+
plain = setDeep(plain, identicalObjectPath, () => object);
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
if (isArray$1(annotations)) {
|
|
1004
|
+
const [root, other] = annotations;
|
|
1005
|
+
root.forEach((identicalPath) => {
|
|
1006
|
+
plain = setDeep(plain, parsePath(identicalPath, legacyPaths), () => plain);
|
|
556
1007
|
});
|
|
1008
|
+
if (other) forEach(other, apply);
|
|
1009
|
+
} else forEach(annotations, apply);
|
|
1010
|
+
return plain;
|
|
1011
|
+
}
|
|
1012
|
+
var isDeep = (object, superJson) => isPlainObject$1(object) || isArray$1(object) || isMap(object) || isSet(object) || isError(object) || isInstanceOfRegisteredClass(object, superJson);
|
|
1013
|
+
function addIdentity(object, path, identities) {
|
|
1014
|
+
const existingSet = identities.get(object);
|
|
1015
|
+
if (existingSet) existingSet.push(path);
|
|
1016
|
+
else identities.set(object, [path]);
|
|
1017
|
+
}
|
|
1018
|
+
function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
|
1019
|
+
const result = {};
|
|
1020
|
+
let rootEqualityPaths = void 0;
|
|
1021
|
+
identitites.forEach((paths) => {
|
|
1022
|
+
if (paths.length <= 1) return;
|
|
1023
|
+
if (!dedupe) paths = paths.map((path) => path.map(String)).sort((a, b) => a.length - b.length);
|
|
1024
|
+
const [representativePath, ...identicalPaths] = paths;
|
|
1025
|
+
if (representativePath.length === 0) rootEqualityPaths = identicalPaths.map(stringifyPath);
|
|
1026
|
+
else result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
|
|
1027
|
+
});
|
|
1028
|
+
if (rootEqualityPaths) {
|
|
1029
|
+
if (isEmptyObject(result)) return [rootEqualityPaths];
|
|
1030
|
+
else return [rootEqualityPaths, result];
|
|
1031
|
+
} else return isEmptyObject(result) ? void 0 : result;
|
|
1032
|
+
}
|
|
1033
|
+
var walker = (object, identities, superJson, dedupe, path = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
|
|
1034
|
+
const primitive = isPrimitive(object);
|
|
1035
|
+
if (!primitive) {
|
|
1036
|
+
addIdentity(object, path, identities);
|
|
1037
|
+
const seen = seenObjects.get(object);
|
|
1038
|
+
if (seen) return dedupe ? { transformedValue: null } : seen;
|
|
1039
|
+
}
|
|
1040
|
+
if (!isDeep(object, superJson)) {
|
|
1041
|
+
const transformed = transformValue(object, superJson);
|
|
1042
|
+
const result = transformed ? {
|
|
1043
|
+
transformedValue: transformed.value,
|
|
1044
|
+
annotations: [transformed.type]
|
|
1045
|
+
} : { transformedValue: object };
|
|
1046
|
+
if (!primitive) seenObjects.set(object, result);
|
|
1047
|
+
return result;
|
|
557
1048
|
}
|
|
558
|
-
if (
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
function generateReferentialEqualityAnnotations(e, t) {
|
|
572
|
-
let n = {}, r;
|
|
573
|
-
return e.forEach((e) => {
|
|
574
|
-
if (e.length <= 1) return;
|
|
575
|
-
t || (e = e.map((e) => e.map(String)).sort((e, t) => e.length - t.length));
|
|
576
|
-
let [i, ...a] = e;
|
|
577
|
-
i.length === 0 ? r = a.map(stringifyPath) : n[stringifyPath(i)] = a.map(stringifyPath);
|
|
578
|
-
}), r ? isEmptyObject(n) ? [r] : [r, n] : isEmptyObject(n) ? void 0 : n;
|
|
579
|
-
}
|
|
580
|
-
var walker = (e, t, n, r, i = [], a = [], o = /* @__PURE__ */ new Map()) => {
|
|
581
|
-
let s = isPrimitive(e);
|
|
582
|
-
if (!s) {
|
|
583
|
-
addIdentity(e, i, t);
|
|
584
|
-
let n = o.get(e);
|
|
585
|
-
if (n) return r ? { transformedValue: null } : n;
|
|
586
|
-
}
|
|
587
|
-
if (!isDeep(e, n)) {
|
|
588
|
-
let t = transformValue(e, n), r = t ? {
|
|
589
|
-
transformedValue: t.value,
|
|
590
|
-
annotations: [t.type]
|
|
591
|
-
} : { transformedValue: e };
|
|
592
|
-
return s || o.set(e, r), r;
|
|
593
|
-
}
|
|
594
|
-
if (includes(a, e)) return { transformedValue: null };
|
|
595
|
-
let c = transformValue(e, n), l = c?.value ?? e, u = W(l) ? [] : {}, d = {};
|
|
596
|
-
forEach(l, (s, c) => {
|
|
597
|
-
if (c === "__proto__" || c === "constructor" || c === "prototype") throw Error(`Detected property ${c}. This is a prototype pollution risk, please remove it from your object.`);
|
|
598
|
-
let l = walker(s, t, n, r, [...i, c], [...a, e], o);
|
|
599
|
-
u[c] = l.transformedValue, W(l.annotations) ? d[escapeKey(c)] = l.annotations : U(l.annotations) && forEach(l.annotations, (e, t) => {
|
|
600
|
-
d[escapeKey(c) + "." + t] = e;
|
|
1049
|
+
if (includes(objectsInThisPath, object)) return { transformedValue: null };
|
|
1050
|
+
const transformationResult = transformValue(object, superJson);
|
|
1051
|
+
const transformed = transformationResult?.value ?? object;
|
|
1052
|
+
const transformedValue = isArray$1(transformed) ? [] : {};
|
|
1053
|
+
const innerAnnotations = {};
|
|
1054
|
+
forEach(transformed, (value, index) => {
|
|
1055
|
+
if (index === "__proto__" || index === "constructor" || index === "prototype") throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
|
|
1056
|
+
const recursiveResult = walker(value, identities, superJson, dedupe, [...path, index], [...objectsInThisPath, object], seenObjects);
|
|
1057
|
+
transformedValue[index] = recursiveResult.transformedValue;
|
|
1058
|
+
if (isArray$1(recursiveResult.annotations)) innerAnnotations[escapeKey(index)] = recursiveResult.annotations;
|
|
1059
|
+
else if (isPlainObject$1(recursiveResult.annotations)) forEach(recursiveResult.annotations, (tree, key) => {
|
|
1060
|
+
innerAnnotations[escapeKey(index) + "." + key] = tree;
|
|
601
1061
|
});
|
|
602
1062
|
});
|
|
603
|
-
|
|
604
|
-
transformedValue
|
|
605
|
-
annotations:
|
|
1063
|
+
const result = isEmptyObject(innerAnnotations) ? {
|
|
1064
|
+
transformedValue,
|
|
1065
|
+
annotations: !!transformationResult ? [transformationResult.type] : void 0
|
|
606
1066
|
} : {
|
|
607
|
-
transformedValue
|
|
608
|
-
annotations:
|
|
1067
|
+
transformedValue,
|
|
1068
|
+
annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
|
|
609
1069
|
};
|
|
610
|
-
|
|
1070
|
+
if (!primitive) seenObjects.set(object, result);
|
|
1071
|
+
return result;
|
|
611
1072
|
};
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
function getType(
|
|
615
|
-
return Object.prototype.toString.call(
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
function isArray(
|
|
620
|
-
return getType(
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
1073
|
+
// ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/getType.js
|
|
1074
|
+
/** Returns the object type of the given payload */
|
|
1075
|
+
function getType(payload) {
|
|
1076
|
+
return Object.prototype.toString.call(payload).slice(8, -1);
|
|
1077
|
+
}
|
|
1078
|
+
// ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isArray.js
|
|
1079
|
+
/** Returns whether the payload is an array */
|
|
1080
|
+
function isArray(payload) {
|
|
1081
|
+
return getType(payload) === "Array";
|
|
1082
|
+
}
|
|
1083
|
+
// ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isPlainObject.js
|
|
1084
|
+
/**
|
|
1085
|
+
* Returns whether the payload is a plain JavaScript object (excluding special classes or objects
|
|
1086
|
+
* with other prototypes)
|
|
1087
|
+
*/
|
|
1088
|
+
function isPlainObject(payload) {
|
|
1089
|
+
if (getType(payload) !== "Object") return false;
|
|
1090
|
+
const prototype = Object.getPrototypeOf(payload);
|
|
1091
|
+
return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
|
|
1092
|
+
}
|
|
1093
|
+
// ../../node_modules/.pnpm/copy-anything@4.0.5/node_modules/copy-anything/dist/index.js
|
|
1094
|
+
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
|
|
1095
|
+
const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
|
|
1096
|
+
if (propType === "enumerable") carry[key] = newVal;
|
|
1097
|
+
if (includeNonenumerable && propType === "nonenumerable") Object.defineProperty(carry, key, {
|
|
1098
|
+
value: newVal,
|
|
1099
|
+
enumerable: false,
|
|
1100
|
+
writable: true,
|
|
1101
|
+
configurable: true
|
|
638
1102
|
});
|
|
639
1103
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
1104
|
+
/**
|
|
1105
|
+
* Copy (clone) an object and all its props recursively to get rid of any prop referenced of the
|
|
1106
|
+
* original object. Arrays are also cloned, however objects inside arrays are still linked.
|
|
1107
|
+
*
|
|
1108
|
+
* @param target Target can be anything
|
|
1109
|
+
* @param [options={}] See type {@link Options} for more details.
|
|
1110
|
+
*
|
|
1111
|
+
* - `{ props: ['key1'] }` will only copy the `key1` property. When using this you will need to cast
|
|
1112
|
+
* the return type manually (in order to keep the TS implementation in here simple I didn't
|
|
1113
|
+
* built a complex auto resolved type for those few cases people want to use this option)
|
|
1114
|
+
* - `{ nonenumerable: true }` will copy all non-enumerable properties. Default is `{}`
|
|
1115
|
+
*
|
|
1116
|
+
* @returns The target with replaced values
|
|
1117
|
+
*/
|
|
1118
|
+
function copy(target, options = {}) {
|
|
1119
|
+
if (isArray(target)) return target.map((item) => copy(item, options));
|
|
1120
|
+
if (!isPlainObject(target)) return target;
|
|
1121
|
+
const props = Object.getOwnPropertyNames(target);
|
|
1122
|
+
const symbols = Object.getOwnPropertySymbols(target);
|
|
1123
|
+
return [...props, ...symbols].reduce((carry, key) => {
|
|
1124
|
+
if (key === "__proto__") return carry;
|
|
1125
|
+
if (isArray(options.props) && !options.props.includes(key)) return carry;
|
|
1126
|
+
const val = target[key];
|
|
1127
|
+
assignProp(carry, key, copy(val, options), target, options.nonenumerable);
|
|
1128
|
+
return carry;
|
|
648
1129
|
}, {});
|
|
649
1130
|
}
|
|
650
|
-
|
|
651
|
-
//#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/index.js
|
|
1131
|
+
// ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/index.js
|
|
652
1132
|
var SuperJSON = class {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
1133
|
+
/**
|
|
1134
|
+
* @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
|
|
1135
|
+
*/
|
|
1136
|
+
constructor({ dedupe = false } = {}) {
|
|
1137
|
+
this.classRegistry = new ClassRegistry();
|
|
1138
|
+
this.symbolRegistry = new Registry((s) => s.description ?? "");
|
|
1139
|
+
this.customTransformerRegistry = new CustomTransformerRegistry();
|
|
1140
|
+
this.allowedErrorProps = [];
|
|
1141
|
+
this.dedupe = dedupe;
|
|
1142
|
+
}
|
|
1143
|
+
serialize(object) {
|
|
1144
|
+
const identities = /* @__PURE__ */ new Map();
|
|
1145
|
+
const output = walker(object, identities, this, this.dedupe);
|
|
1146
|
+
const res = { json: output.transformedValue };
|
|
1147
|
+
if (output.annotations) res.meta = {
|
|
1148
|
+
...res.meta,
|
|
1149
|
+
values: output.annotations
|
|
1150
|
+
};
|
|
1151
|
+
const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
|
|
1152
|
+
if (equalityAnnotations) res.meta = {
|
|
1153
|
+
...res.meta,
|
|
1154
|
+
referentialEqualities: equalityAnnotations
|
|
1155
|
+
};
|
|
1156
|
+
if (res.meta) res.meta.v = 1;
|
|
1157
|
+
return res;
|
|
667
1158
|
}
|
|
668
|
-
deserialize(
|
|
669
|
-
|
|
670
|
-
|
|
1159
|
+
deserialize(payload, options) {
|
|
1160
|
+
const { json, meta } = payload;
|
|
1161
|
+
let result = options?.inPlace ? json : copy(json);
|
|
1162
|
+
if (meta?.values) result = applyValueAnnotations(result, meta.values, meta.v ?? 0, this);
|
|
1163
|
+
if (meta?.referentialEqualities) result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities, meta.v ?? 0);
|
|
1164
|
+
return result;
|
|
671
1165
|
}
|
|
672
|
-
stringify(
|
|
673
|
-
return JSON.stringify(this.serialize(
|
|
1166
|
+
stringify(object) {
|
|
1167
|
+
return JSON.stringify(this.serialize(object));
|
|
674
1168
|
}
|
|
675
|
-
parse(
|
|
676
|
-
return this.deserialize(JSON.parse(
|
|
1169
|
+
parse(string) {
|
|
1170
|
+
return this.deserialize(JSON.parse(string), { inPlace: true });
|
|
677
1171
|
}
|
|
678
|
-
registerClass(
|
|
679
|
-
this.classRegistry.register(
|
|
1172
|
+
registerClass(v, options) {
|
|
1173
|
+
this.classRegistry.register(v, options);
|
|
680
1174
|
}
|
|
681
|
-
registerSymbol(
|
|
682
|
-
this.symbolRegistry.register(
|
|
1175
|
+
registerSymbol(v, identifier) {
|
|
1176
|
+
this.symbolRegistry.register(v, identifier);
|
|
683
1177
|
}
|
|
684
|
-
registerCustom(
|
|
1178
|
+
registerCustom(transformer, name) {
|
|
685
1179
|
this.customTransformerRegistry.register({
|
|
686
|
-
name
|
|
687
|
-
...
|
|
1180
|
+
name,
|
|
1181
|
+
...transformer
|
|
688
1182
|
});
|
|
689
1183
|
}
|
|
690
|
-
allowErrorProps(...
|
|
691
|
-
this.allowedErrorProps.push(...
|
|
1184
|
+
allowErrorProps(...props) {
|
|
1185
|
+
this.allowedErrorProps.push(...props);
|
|
692
1186
|
}
|
|
693
1187
|
};
|
|
694
|
-
SuperJSON.defaultInstance = new SuperJSON()
|
|
695
|
-
|
|
696
|
-
SuperJSON.
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
1188
|
+
SuperJSON.defaultInstance = new SuperJSON();
|
|
1189
|
+
SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
|
|
1190
|
+
SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
|
|
1191
|
+
SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
|
|
1192
|
+
SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
|
|
1193
|
+
SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
|
|
1194
|
+
SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
|
|
1195
|
+
SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
|
|
1196
|
+
SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
|
|
1197
|
+
SuperJSON.serialize;
|
|
1198
|
+
SuperJSON.deserialize;
|
|
1199
|
+
var stringify = SuperJSON.stringify;
|
|
1200
|
+
var parse = SuperJSON.parse;
|
|
1201
|
+
SuperJSON.registerClass;
|
|
1202
|
+
SuperJSON.registerCustom;
|
|
1203
|
+
SuperJSON.registerSymbol;
|
|
1204
|
+
SuperJSON.allowErrorProps;
|
|
1205
|
+
// src/aichat/useChat.tsx
|
|
1206
|
+
function mapToNodeData(storeState) {
|
|
1207
|
+
return ({ id, data, ...node }) => {
|
|
1208
|
+
let icon = data.icon ?? void 0;
|
|
1209
|
+
if (icon === "none") icon = void 0;
|
|
1210
|
+
let children = storeState.parentLookup.get(id)?.values().map((child) => child.id).toArray();
|
|
704
1211
|
return {
|
|
705
|
-
id
|
|
706
|
-
title:
|
|
707
|
-
shape:
|
|
708
|
-
color:
|
|
709
|
-
icon
|
|
710
|
-
parentId:
|
|
711
|
-
children
|
|
712
|
-
x:
|
|
713
|
-
y:
|
|
714
|
-
width:
|
|
715
|
-
height:
|
|
716
|
-
..."modelFqn" in
|
|
1212
|
+
id,
|
|
1213
|
+
title: data.title,
|
|
1214
|
+
shape: data.shape,
|
|
1215
|
+
color: data.color,
|
|
1216
|
+
icon,
|
|
1217
|
+
parentId: node.parentId,
|
|
1218
|
+
children,
|
|
1219
|
+
x: data.x,
|
|
1220
|
+
y: data.y,
|
|
1221
|
+
width: node.measured?.width ?? node.width ?? node.initialWidth ?? 0,
|
|
1222
|
+
height: node.measured?.height ?? node.height ?? node.initialHeight ?? 0,
|
|
1223
|
+
..."modelFqn" in data && data.modelFqn && { modelFqn: data.modelFqn }
|
|
717
1224
|
};
|
|
718
1225
|
};
|
|
719
1226
|
}
|
|
720
1227
|
function useChatTools() {
|
|
721
|
-
|
|
722
|
-
|
|
1228
|
+
const $ = c(11);
|
|
1229
|
+
const { id: projectId } = useCurrentProject();
|
|
1230
|
+
const navigate = useNavigate();
|
|
1231
|
+
const diagram = useDiagram();
|
|
1232
|
+
let t0;
|
|
1233
|
+
if ($[0] !== diagram || $[1] !== navigate || $[2] !== projectId) {
|
|
723
1234
|
let t1;
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
1235
|
+
if ($[4] !== navigate) {
|
|
1236
|
+
t1 = (t2) => {
|
|
1237
|
+
const { viewId } = t2;
|
|
1238
|
+
navigate({
|
|
1239
|
+
to: "./",
|
|
1240
|
+
params: (current) => ({
|
|
1241
|
+
...current,
|
|
1242
|
+
viewId
|
|
1243
|
+
})
|
|
1244
|
+
});
|
|
1245
|
+
return {};
|
|
1246
|
+
};
|
|
1247
|
+
$[4] = navigate;
|
|
1248
|
+
$[5] = t1;
|
|
1249
|
+
} else t1 = $[5];
|
|
734
1250
|
let t2;
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
1251
|
+
if ($[6] !== diagram || $[7] !== projectId) {
|
|
1252
|
+
t2 = (params) => {
|
|
1253
|
+
const { view, focusedNode, xynodes, xystore, toggledFeatures, features } = diagram.getContext();
|
|
1254
|
+
const isReadOnly = toggledFeatures.enableReadOnly ?? features.enableReadOnly;
|
|
1255
|
+
const toNodeData = mapToNodeData(xystore.getState());
|
|
1256
|
+
const nodes = params.nodes === true && r(xynodes, toNodeData) || void 0;
|
|
1257
|
+
const selectedNode = params.selectedNode === true && f(xynodes, a$3((n) => !!n.selected || n.id === focusedNode), (n_0) => n_0 ? toNodeData(n_0) : void 0);
|
|
1258
|
+
return {
|
|
1259
|
+
projectId,
|
|
1260
|
+
editMode: !isReadOnly,
|
|
1261
|
+
view: {
|
|
1262
|
+
id: view.id,
|
|
1263
|
+
title: view.title ?? "",
|
|
1264
|
+
type: view._type
|
|
1265
|
+
},
|
|
1266
|
+
...nodes && { nodes },
|
|
1267
|
+
...selectedNode && { selectedNode }
|
|
1268
|
+
};
|
|
747
1269
|
};
|
|
748
|
-
|
|
1270
|
+
$[6] = diagram;
|
|
1271
|
+
$[7] = projectId;
|
|
1272
|
+
$[8] = t2;
|
|
1273
|
+
} else t2 = $[8];
|
|
749
1274
|
let t3;
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
1275
|
+
if ($[9] !== diagram) {
|
|
1276
|
+
t3 = (t4) => {
|
|
1277
|
+
const { command } = t4;
|
|
1278
|
+
bb50: switch (command.type) {
|
|
1279
|
+
case "focus":
|
|
1280
|
+
diagram.focusOnElement(command.elementId);
|
|
1281
|
+
break bb50;
|
|
1282
|
+
case "fitview":
|
|
1283
|
+
diagram.fitDiagram();
|
|
1284
|
+
break bb50;
|
|
1285
|
+
default: nonexhaustive(command);
|
|
1286
|
+
}
|
|
1287
|
+
return {};
|
|
1288
|
+
};
|
|
1289
|
+
$[9] = diagram;
|
|
1290
|
+
$[10] = t3;
|
|
1291
|
+
} else t3 = $[10];
|
|
1292
|
+
t0 = clientTools(navigateToDef.client(t1), readUiStateDef.client(t2), updateUiStateDef.client(t3));
|
|
1293
|
+
$[0] = diagram;
|
|
1294
|
+
$[1] = navigate;
|
|
1295
|
+
$[2] = projectId;
|
|
1296
|
+
$[3] = t0;
|
|
1297
|
+
} else t0 = $[3];
|
|
1298
|
+
return t0;
|
|
765
1299
|
}
|
|
766
|
-
var
|
|
1300
|
+
var storage$1 = {
|
|
767
1301
|
key: "likec4.ai.chat.messages",
|
|
768
1302
|
read() {
|
|
769
1303
|
try {
|
|
770
|
-
|
|
771
|
-
|
|
1304
|
+
const stored = sessionStorage.getItem(this.key);
|
|
1305
|
+
if (!stored) return [];
|
|
1306
|
+
return parse(stored);
|
|
772
1307
|
} catch {
|
|
773
1308
|
return [];
|
|
774
1309
|
}
|
|
775
1310
|
},
|
|
776
|
-
write(
|
|
1311
|
+
write(messages) {
|
|
777
1312
|
try {
|
|
778
|
-
if (
|
|
1313
|
+
if (messages.length === 0) {
|
|
779
1314
|
sessionStorage.removeItem(this.key);
|
|
780
1315
|
return;
|
|
781
1316
|
}
|
|
782
|
-
sessionStorage.setItem(this.key,
|
|
1317
|
+
sessionStorage.setItem(this.key, stringify(messages));
|
|
783
1318
|
} catch {}
|
|
784
1319
|
}
|
|
785
1320
|
};
|
|
786
|
-
function useChat(
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
1321
|
+
function useChat(options) {
|
|
1322
|
+
const $ = c(9);
|
|
1323
|
+
let t0;
|
|
1324
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1325
|
+
t0 = {
|
|
1326
|
+
connection: fetchServerSentEvents("/__likec4_ai"),
|
|
1327
|
+
initialMessages: storage$1.read()
|
|
1328
|
+
};
|
|
1329
|
+
$[0] = t0;
|
|
1330
|
+
} else t0 = $[0];
|
|
1331
|
+
const memoProps = t0;
|
|
1332
|
+
let t1;
|
|
1333
|
+
if ($[1] !== options) {
|
|
1334
|
+
t1 = options ?? {};
|
|
1335
|
+
$[1] = options;
|
|
1336
|
+
$[2] = t1;
|
|
1337
|
+
} else t1 = $[2];
|
|
1338
|
+
const t2 = useChatTools();
|
|
1339
|
+
let t3;
|
|
1340
|
+
if ($[3] !== t1 || $[4] !== t2) {
|
|
1341
|
+
t3 = {
|
|
1342
|
+
...memoProps,
|
|
1343
|
+
...t1,
|
|
1344
|
+
tools: t2
|
|
1345
|
+
};
|
|
1346
|
+
$[3] = t1;
|
|
1347
|
+
$[4] = t2;
|
|
1348
|
+
$[5] = t3;
|
|
1349
|
+
} else t3 = $[5];
|
|
1350
|
+
const chat = useChat$1(t3);
|
|
1351
|
+
let t4;
|
|
1352
|
+
let t5;
|
|
1353
|
+
if ($[6] !== chat.messages) {
|
|
1354
|
+
t4 = () => {
|
|
1355
|
+
storage$1.write(chat.messages);
|
|
1356
|
+
};
|
|
1357
|
+
t5 = [chat.messages];
|
|
1358
|
+
$[6] = chat.messages;
|
|
1359
|
+
$[7] = t4;
|
|
1360
|
+
$[8] = t5;
|
|
1361
|
+
} else {
|
|
1362
|
+
t4 = $[7];
|
|
1363
|
+
t5 = $[8];
|
|
1364
|
+
}
|
|
1365
|
+
useEffect(t4, t5);
|
|
1366
|
+
return chat;
|
|
1367
|
+
}
|
|
1368
|
+
// src/aichat/AIChat.tsx
|
|
1369
|
+
var storage = {
|
|
806
1370
|
key: "likec4.ai.chat.position",
|
|
807
1371
|
read() {
|
|
808
1372
|
try {
|
|
809
|
-
|
|
810
|
-
|
|
1373
|
+
const stored = localStorage.getItem(this.key);
|
|
1374
|
+
if (!stored) return null;
|
|
1375
|
+
return JSON.parse(stored);
|
|
811
1376
|
} catch {
|
|
812
1377
|
return null;
|
|
813
1378
|
}
|
|
814
1379
|
},
|
|
815
|
-
write(
|
|
1380
|
+
write(position) {
|
|
816
1381
|
try {
|
|
817
|
-
if (
|
|
818
|
-
|
|
1382
|
+
if (position === null) {
|
|
1383
|
+
localStorage.removeItem(this.key);
|
|
1384
|
+
return position;
|
|
1385
|
+
}
|
|
1386
|
+
localStorage.setItem(this.key, JSON.stringify(position));
|
|
819
1387
|
} catch {}
|
|
820
|
-
return
|
|
1388
|
+
return position;
|
|
821
1389
|
}
|
|
822
1390
|
};
|
|
823
1391
|
function AIChatComponent() {
|
|
824
|
-
|
|
825
|
-
|
|
1392
|
+
const initialPosition = useRef(null);
|
|
1393
|
+
if (!initialPosition.current) initialPosition.current = storage.read() ?? {
|
|
826
1394
|
right: 16,
|
|
827
1395
|
bottom: 100
|
|
828
1396
|
};
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
left:
|
|
832
|
-
top:
|
|
1397
|
+
const onPositionChange = (pos) => {
|
|
1398
|
+
initialPosition.current = storage.write({
|
|
1399
|
+
left: pos.x,
|
|
1400
|
+
top: pos.y
|
|
833
1401
|
});
|
|
834
|
-
}
|
|
1402
|
+
};
|
|
1403
|
+
const [isCollapsed, setCollapsed] = useLocalStorage({
|
|
835
1404
|
key: "likec4.ai.chat.collapsed",
|
|
836
|
-
defaultValue:
|
|
1405
|
+
defaultValue: true
|
|
837
1406
|
});
|
|
838
|
-
return /* @__PURE__ */
|
|
1407
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(AnimatePresence, { children: [!isCollapsed && /* @__PURE__ */ jsx(FloatingWindow, {
|
|
839
1408
|
w: 300,
|
|
840
1409
|
pos: "fixed",
|
|
841
|
-
className:
|
|
1410
|
+
className: css({
|
|
842
1411
|
rounded: "md",
|
|
843
1412
|
padding: "xs",
|
|
844
1413
|
shadow: "md",
|
|
845
1414
|
layerStyle: "likec4.panel"
|
|
846
1415
|
}),
|
|
847
|
-
constrainToViewport:
|
|
1416
|
+
constrainToViewport: true,
|
|
848
1417
|
constrainOffset: 8,
|
|
849
1418
|
excludeDragHandleSelector: ".chat-input",
|
|
850
|
-
initialPosition:
|
|
1419
|
+
initialPosition: initialPosition.current,
|
|
851
1420
|
onPositionChange,
|
|
852
|
-
children: /* @__PURE__ */
|
|
853
|
-
}),
|
|
1421
|
+
children: /* @__PURE__ */ jsx(AIChatWindowContent, { onClose: () => setCollapsed(true) })
|
|
1422
|
+
}), isCollapsed && /* @__PURE__ */ jsx(m.div, {
|
|
854
1423
|
initial: {
|
|
855
1424
|
opacity: .1,
|
|
856
1425
|
translateX: "10%"
|
|
@@ -869,83 +1438,130 @@ function AIChatComponent() {
|
|
|
869
1438
|
bottom: 60,
|
|
870
1439
|
zIndex: 1e3
|
|
871
1440
|
},
|
|
872
|
-
children: /* @__PURE__ */
|
|
1441
|
+
children: /* @__PURE__ */ jsx(Tooltip, {
|
|
873
1442
|
label: "Show AI Assistant",
|
|
874
1443
|
color: "dark",
|
|
875
1444
|
fz: "xs",
|
|
876
|
-
children: /* @__PURE__ */
|
|
1445
|
+
children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
877
1446
|
size: "lg",
|
|
878
1447
|
variant: "gradient",
|
|
879
|
-
onClick: () =>
|
|
880
|
-
children: /* @__PURE__ */
|
|
1448
|
+
onClick: () => setCollapsed(false),
|
|
1449
|
+
children: /* @__PURE__ */ jsx(IconSparkles, { stroke: 1.5 })
|
|
881
1450
|
})
|
|
882
1451
|
})
|
|
883
|
-
}, "collapsed")] }), /* @__PURE__ */
|
|
884
|
-
}
|
|
885
|
-
function AIChatWindowContent(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1452
|
+
}, "collapsed")] }), /* @__PURE__ */ jsx(SemanticLayoutLog, {})] });
|
|
1453
|
+
}
|
|
1454
|
+
function AIChatWindowContent(t0) {
|
|
1455
|
+
const $ = c(15);
|
|
1456
|
+
const { onClose } = t0;
|
|
1457
|
+
const scrollAnchorRef = useRef(null);
|
|
1458
|
+
let t1;
|
|
1459
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1460
|
+
t1 = () => {
|
|
1461
|
+
scrollAnchorRef.current?.scrollIntoView();
|
|
1462
|
+
};
|
|
1463
|
+
$[0] = t1;
|
|
1464
|
+
} else t1 = $[0];
|
|
1465
|
+
const scrollIntoView = t1;
|
|
1466
|
+
let t2;
|
|
1467
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1468
|
+
t2 = () => {
|
|
1469
|
+
scrollIntoView();
|
|
1470
|
+
};
|
|
1471
|
+
$[1] = t2;
|
|
1472
|
+
} else t2 = $[1];
|
|
1473
|
+
useTimeoutEffect(t2, 100);
|
|
1474
|
+
let t3;
|
|
1475
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1476
|
+
t3 = { onChunk: scrollIntoView };
|
|
1477
|
+
$[2] = t3;
|
|
1478
|
+
} else t3 = $[2];
|
|
1479
|
+
const chat = useChat(t3);
|
|
1480
|
+
let t4;
|
|
1481
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1482
|
+
t4 = /* @__PURE__ */ jsxs(HStack, { children: [/* @__PURE__ */ jsx(Txt, {
|
|
1483
|
+
textStyle: "likec4.panel",
|
|
1484
|
+
nouserselect: true,
|
|
1485
|
+
children: "AI Assistant"
|
|
1486
|
+
}), /* @__PURE__ */ jsx(Badge, {
|
|
1487
|
+
size: "xs",
|
|
1488
|
+
radius: "sm",
|
|
1489
|
+
variant: "light",
|
|
1490
|
+
children: AIAdapter
|
|
1491
|
+
})] });
|
|
1492
|
+
$[3] = t4;
|
|
1493
|
+
} else t4 = $[3];
|
|
1494
|
+
let t5;
|
|
1495
|
+
if ($[4] !== onClose) {
|
|
1496
|
+
t5 = /* @__PURE__ */ jsxs(HStack, {
|
|
1497
|
+
cursor: "move",
|
|
1498
|
+
justify: "space-between",
|
|
1499
|
+
children: [t4, /* @__PURE__ */ jsx(CloseButton, {
|
|
1500
|
+
size: "sm",
|
|
1501
|
+
onClick: (e) => {
|
|
1502
|
+
e.stopPropagation();
|
|
1503
|
+
onClose();
|
|
1504
|
+
}
|
|
1505
|
+
})]
|
|
1506
|
+
});
|
|
1507
|
+
$[4] = onClose;
|
|
1508
|
+
$[5] = t5;
|
|
1509
|
+
} else t5 = $[5];
|
|
1510
|
+
let t6;
|
|
1511
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1512
|
+
t6 = { content: css({ display: "contents" }) };
|
|
1513
|
+
$[6] = t6;
|
|
1514
|
+
} else t6 = $[6];
|
|
1515
|
+
let t7;
|
|
1516
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1517
|
+
t7 = /* @__PURE__ */ jsx(ChatMessages, {});
|
|
1518
|
+
$[7] = t7;
|
|
1519
|
+
} else t7 = $[7];
|
|
1520
|
+
let t8;
|
|
1521
|
+
let t9;
|
|
1522
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1523
|
+
t8 = /* @__PURE__ */ jsx(ScrollAreaAutosize, {
|
|
1524
|
+
scrollbars: "y",
|
|
1525
|
+
w: "100%",
|
|
1526
|
+
flex: 1,
|
|
1527
|
+
mih: 250,
|
|
1528
|
+
mah: 350,
|
|
1529
|
+
classNames: t6,
|
|
1530
|
+
children: /* @__PURE__ */ jsxs(VStack, { children: [t7, /* @__PURE__ */ jsx("div", {
|
|
1531
|
+
ref: scrollAnchorRef,
|
|
1532
|
+
style: { height: 2 }
|
|
1533
|
+
})] })
|
|
1534
|
+
});
|
|
1535
|
+
t9 = /* @__PURE__ */ jsx(ChatInput, {});
|
|
1536
|
+
$[8] = t8;
|
|
1537
|
+
$[9] = t9;
|
|
1538
|
+
} else {
|
|
1539
|
+
t8 = $[8];
|
|
1540
|
+
t9 = $[9];
|
|
1541
|
+
}
|
|
1542
|
+
let t10;
|
|
1543
|
+
if ($[10] !== t5) {
|
|
1544
|
+
t10 = /* @__PURE__ */ jsxs(VStack, {
|
|
1545
|
+
w: "100%",
|
|
1546
|
+
children: [
|
|
1547
|
+
t5,
|
|
1548
|
+
t8,
|
|
1549
|
+
t9
|
|
1550
|
+
]
|
|
1551
|
+
});
|
|
1552
|
+
$[10] = t5;
|
|
1553
|
+
$[11] = t10;
|
|
1554
|
+
} else t10 = $[11];
|
|
1555
|
+
let t11;
|
|
1556
|
+
if ($[12] !== chat || $[13] !== t10) {
|
|
1557
|
+
t11 = /* @__PURE__ */ jsx(ChatContext, {
|
|
1558
|
+
value: chat,
|
|
1559
|
+
children: t10
|
|
1560
|
+
});
|
|
1561
|
+
$[12] = chat;
|
|
1562
|
+
$[13] = t10;
|
|
1563
|
+
$[14] = t11;
|
|
1564
|
+
} else t11 = $[14];
|
|
1565
|
+
return t11;
|
|
1566
|
+
}
|
|
951
1567
|
export { AIChatComponent as default };
|