likec4 1.57.0 → 1.59.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.
Files changed (178) hide show
  1. package/__app__/codegen/react.mjs +7 -8
  2. package/__app__/codegen/webcomponent.mjs +78 -889
  3. package/__app__/src/aichat/index.mjs +8 -1
  4. package/__app__/src/chunks/AIChat.mjs +956 -0
  5. package/__app__/src/chunks/LikeC4Styles.mjs +2164 -0
  6. package/__app__/src/chunks/ProjectsOverview.mjs +537 -0
  7. package/__app__/src/chunks/es.mjs +439 -0
  8. package/__app__/src/chunks/hooks.mjs +458 -0
  9. package/__app__/src/chunks/libs/@floating-ui.mjs +2218 -0
  10. package/__app__/src/chunks/libs/@mantine.mjs +12974 -0
  11. package/__app__/src/chunks/libs/@tanstack-ai.mjs +1768 -0
  12. package/__app__/src/chunks/libs/@tanstack.mjs +2693 -0
  13. package/__app__/src/chunks/libs/@xstate/react.mjs +1996 -0
  14. package/__app__/src/chunks/libs/@xyflow/react.mjs +5280 -0
  15. package/__app__/src/chunks/libs/bezier-js.mjs +1006 -0
  16. package/__app__/src/chunks/libs/d3.mjs +2842 -0
  17. package/__app__/src/chunks/libs/fast-equals.mjs +268 -0
  18. package/__app__/src/chunks/libs/framer.mjs +5905 -0
  19. package/__app__/src/chunks/libs/zod.mjs +3173 -0
  20. package/__app__/src/chunks/rolldown-runtime.mjs +30 -0
  21. package/__app__/src/chunks/styled-system.mjs +1047 -0
  22. package/__app__/src/fonts.css +1 -1
  23. package/__app__/src/main.mjs +27659 -14
  24. package/__app__/src/style.css +1 -1
  25. package/dist/chunks/dist.mjs +10 -0
  26. package/dist/chunks/enableServer.mjs +1 -1
  27. package/dist/chunks/filenames.mjs +2 -2
  28. package/dist/chunks/index.d.mts +9 -9
  29. package/dist/chunks/index2.d.mts +2167 -867
  30. package/dist/chunks/libs/@chevrotain/gast.mjs +1 -1
  31. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +1 -1
  32. package/dist/chunks/libs/@logtape/logtape.mjs +4 -3
  33. package/dist/chunks/libs/@ts-graphviz/common.d.mts +1 -2
  34. package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
  35. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
  36. package/dist/chunks/libs/chevrotain.mjs +25 -25
  37. package/dist/chunks/libs/json5.mjs +1 -1
  38. package/dist/chunks/libs/langium.d.mts +2940 -2914
  39. package/dist/chunks/libs/langium.mjs +9 -9
  40. package/dist/chunks/libs/merge-error-cause.mjs +1 -1
  41. package/dist/chunks/libs/p-queue.mjs +1 -1
  42. package/dist/chunks/libs/package-manager-detector.mjs +1 -1
  43. package/dist/chunks/libs/pako.mjs +1 -1
  44. package/dist/chunks/libs/picomatch.mjs +1 -1
  45. package/dist/chunks/libs/pretty-ms.mjs +1 -1
  46. package/dist/chunks/libs/remeda.mjs +1 -1
  47. package/dist/chunks/libs/ufo.mjs +1 -1
  48. package/dist/chunks/libs/unstorage.d.mts +1 -0
  49. package/dist/chunks/libs/unstorage.mjs +1 -1
  50. package/dist/chunks/libs/which.mjs +1 -1
  51. package/dist/chunks/libs/zod.d.mts +48 -36
  52. package/dist/chunks/libs/zod.mjs +65 -0
  53. package/dist/chunks/logger.mjs +1 -0
  54. package/dist/chunks/node.mjs +65 -63
  55. package/dist/chunks/rolldown-runtime.mjs +1 -1
  56. package/dist/chunks/sequence-view.mjs +1 -1
  57. package/dist/chunks/{plugin.mjs → vite-plugin.mjs} +41 -41
  58. package/dist/cli/index.mjs +186 -144
  59. package/dist/index.d.mts +3 -4
  60. package/dist/index.mjs +1 -1
  61. package/dist/model/index.d.mts +6 -5
  62. package/dist/vite-plugin/index.d.mts +6 -9
  63. package/dist/vite-plugin/index.mjs +1 -1
  64. package/dist/vite-plugin/internal/index.d.mts +64 -64
  65. package/dist/vite-plugin/internal/index.mjs +946 -1
  66. package/package.json +51 -52
  67. package/react/index.d.mts +853 -134
  68. package/react/index.mjs +49718 -44030
  69. package/__app__/chunks/AIChat2.mjs +0 -2
  70. package/__app__/chunks/DiagramActorProvider.mjs +0 -10
  71. package/__app__/chunks/EmbedPage.mjs +0 -1
  72. package/__app__/chunks/ExportPage.mjs +0 -2
  73. package/__app__/chunks/LikeC4Diagram.mjs +0 -19
  74. package/__app__/chunks/LikeC4Styles.mjs +0 -48
  75. package/__app__/chunks/Markdown.mjs +0 -1
  76. package/__app__/chunks/NavigationPanel.mjs +0 -1
  77. package/__app__/chunks/ViewReact.mjs +0 -1
  78. package/__app__/chunks/adhoc-editor.mjs +0 -1
  79. package/__app__/chunks/aichat.mjs +0 -1
  80. package/__app__/chunks/box.mjs +0 -1
  81. package/__app__/chunks/create-style-context.mjs +0 -1
  82. package/__app__/chunks/css.mjs +0 -1
  83. package/__app__/chunks/factory.mjs +0 -1
  84. package/__app__/chunks/hooks.mjs +0 -1
  85. package/__app__/chunks/hstack.mjs +0 -1
  86. package/__app__/chunks/libs/@dagrejs/dagre.mjs +0 -1
  87. package/__app__/chunks/libs/@floating-ui/core.mjs +0 -1
  88. package/__app__/chunks/libs/@floating-ui/dom.mjs +0 -1
  89. package/__app__/chunks/libs/@floating-ui/react.mjs +0 -1
  90. package/__app__/chunks/libs/@mantine/core.mjs +0 -41
  91. package/__app__/chunks/libs/@mantine/hooks.mjs +0 -1
  92. package/__app__/chunks/libs/@nanostores/react.mjs +0 -1
  93. package/__app__/chunks/libs/@react-hookz/web.mjs +0 -1
  94. package/__app__/chunks/libs/@tabler/icons-react.mjs +0 -358
  95. package/__app__/chunks/libs/@tanstack/ai-client.mjs +0 -2
  96. package/__app__/chunks/libs/@tanstack/ai-react-ui.mjs +0 -1
  97. package/__app__/chunks/libs/@tanstack/ai-react.mjs +0 -1
  98. package/__app__/chunks/libs/@tanstack/ai.mjs +0 -2
  99. package/__app__/chunks/libs/@tanstack/history.mjs +0 -1
  100. package/__app__/chunks/libs/@tanstack/react-router.mjs +0 -3
  101. package/__app__/chunks/libs/@tanstack/router-core.mjs +0 -1
  102. package/__app__/chunks/libs/@xstate/react.mjs +0 -1
  103. package/__app__/chunks/libs/@xstate/store.mjs +0 -1
  104. package/__app__/chunks/libs/@xyflow/react.mjs +0 -7
  105. package/__app__/chunks/libs/@zag-js/anatomy.mjs +0 -1
  106. package/__app__/chunks/libs/@zag-js/collection.mjs +0 -1
  107. package/__app__/chunks/libs/@zag-js/core.mjs +0 -1
  108. package/__app__/chunks/libs/@zag-js/react.mjs +0 -1
  109. package/__app__/chunks/libs/@zag-js/tree-view.mjs +0 -1
  110. package/__app__/chunks/libs/bezier-js.mjs +0 -1
  111. package/__app__/chunks/libs/copy-anything.mjs +0 -1
  112. package/__app__/chunks/libs/d3-path.mjs +0 -1
  113. package/__app__/chunks/libs/d3-shape.mjs +0 -1
  114. package/__app__/chunks/libs/fast-equals.mjs +0 -1
  115. package/__app__/chunks/libs/framer-motion.mjs +0 -9
  116. package/__app__/chunks/libs/html-to-image.mjs +0 -2
  117. package/__app__/chunks/libs/motion-dom.mjs +0 -1
  118. package/__app__/chunks/libs/nanostores.mjs +0 -1
  119. package/__app__/chunks/libs/react-error-boundary.mjs +0 -1
  120. package/__app__/chunks/libs/react-resizable-panels.mjs +0 -1
  121. package/__app__/chunks/libs/remeda.mjs +0 -1
  122. package/__app__/chunks/libs/superjson.mjs +0 -1
  123. package/__app__/chunks/libs/zod.mjs +0 -64
  124. package/__app__/chunks/rolldown-runtime.mjs +0 -1
  125. package/__app__/chunks/styles.css.mjs +0 -1
  126. package/__app__/chunks/txt.mjs +0 -1
  127. package/__app__/chunks/useLikeC4Project.mjs +0 -1
  128. package/__app__/src/pages/AdHocViewEditor.mjs +0 -1
  129. package/__app__/src/pages/EmbedPage.mjs +0 -1
  130. package/__app__/src/pages/ExportPage.mjs +0 -1
  131. package/__app__/src/pages/ProjectsOverview.mjs +0 -1
  132. package/__app__/src/pages/ViewAsD2.mjs +0 -1
  133. package/__app__/src/pages/ViewAsDot.mjs +0 -1
  134. package/__app__/src/pages/ViewAsMmd.mjs +0 -1
  135. package/__app__/src/pages/ViewAsPuml.mjs +0 -1
  136. package/__app__/src/pages/ViewEditor.mjs +0 -1
  137. package/__app__/src/pages/ViewReact.mjs +0 -1
  138. package/dist/chunks/libs/@chevrotain/utils.mjs +0 -1
  139. package/dist/chunks/libs/@hono/mcp.mjs +0 -70
  140. package/dist/chunks/libs/@hono/node-server.mjs +0 -1
  141. package/dist/chunks/libs/@logtape/logtape.d.mts +0 -1023
  142. package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +0 -12
  143. package/dist/chunks/libs/ajv.mjs +0 -1
  144. package/dist/chunks/libs/ansi-align.mjs +0 -2
  145. package/dist/chunks/libs/ansi-regex.mjs +0 -1
  146. package/dist/chunks/libs/ansi-styles.mjs +0 -1
  147. package/dist/chunks/libs/atomically.mjs +0 -1
  148. package/dist/chunks/libs/boxen.mjs +0 -22
  149. package/dist/chunks/libs/conf.mjs +0 -1
  150. package/dist/chunks/libs/defu.mjs +0 -1
  151. package/dist/chunks/libs/destr.mjs +0 -1
  152. package/dist/chunks/libs/find-up-simple.mjs +0 -1
  153. package/dist/chunks/libs/get-port.mjs +0 -1
  154. package/dist/chunks/libs/hono.mjs +0 -1
  155. package/dist/chunks/libs/is-docker.mjs +0 -1
  156. package/dist/chunks/libs/is-error-instance.mjs +0 -1
  157. package/dist/chunks/libs/is-inside-container.mjs +0 -1
  158. package/dist/chunks/libs/is-plain-obj.mjs +0 -1
  159. package/dist/chunks/libs/isexe.mjs +0 -1
  160. package/dist/chunks/libs/ky.mjs +0 -3
  161. package/dist/chunks/libs/p-debounce.mjs +0 -1
  162. package/dist/chunks/libs/p-limit.mjs +0 -1
  163. package/dist/chunks/libs/p-timeout.mjs +0 -1
  164. package/dist/chunks/libs/package-up.mjs +0 -1
  165. package/dist/chunks/libs/parse-ms.mjs +0 -1
  166. package/dist/chunks/libs/safe-stringify.mjs +0 -1
  167. package/dist/chunks/libs/strip-indent.mjs +0 -1
  168. package/dist/chunks/libs/tinyrainbow.mjs +0 -1
  169. package/dist/chunks/libs/ts-graphviz.mjs +0 -1
  170. package/dist/chunks/libs/unctx.mjs +0 -1
  171. package/dist/chunks/libs/vscode-languageserver.mjs +0 -1
  172. package/dist/chunks/libs/word-wrap.mjs +0 -12
  173. package/dist/vite-plugin/internal/chunks/libs/@nanostores/react.mjs +0 -1
  174. package/dist/vite-plugin/internal/chunks/libs/birpc.mjs +0 -1
  175. package/dist/vite-plugin/internal/chunks/libs/fast-equals.mjs +0 -1
  176. package/dist/vite-plugin/internal/chunks/libs/nanostores.mjs +0 -1
  177. package/dist/vite-plugin/internal/chunks/libs/remeda.mjs +0 -1
  178. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +0 -1
@@ -0,0 +1,956 @@
1
+ import { i as e } from "./rolldown-runtime.mjs";
2
+ import { l as t } from "./libs/@tanstack.mjs";
3
+ import { C as n, F as r, N as i, O as a, _ as o, b as s, c, j as l, k as u, m as d, t as f, v as p, y as m } from "./hooks.mjs";
4
+ import { B as h, Et as g, J as ee, N as te, Xt as ne, Z as _, g as re, ht as v, mt as ie, r as ae, v as y, x as b } from "./libs/@mantine.mjs";
5
+ import { C as x, N as S, _ as C, x as w } from "./styled-system.mjs";
6
+ import { i as oe, m as se } from "./libs/framer.mjs";
7
+ import { a as T, c as E, i as ce, n as D, o as O, r as k, s as A, t as j } from "./libs/zod.mjs";
8
+ import { a as M, i as le, n as ue, r as de, t as fe } from "./libs/@tanstack-ai.mjs";
9
+ import { createContext as pe, use as me, useEffect as he, useRef as N, useState as P } from "react";
10
+ import { c as F } from "react/compiler-runtime";
11
+ import { Fragment as I, jsx as L, jsxs as R } from "react/jsx-runtime";
12
+ import { RichText as ge, nonNullable as z, nonexhaustive as _e } from "@likec4/core";
13
+ import { ElementShapes as ve } from "@likec4/core/styles";
14
+ import { AIAdapter as ye } from "likec4:rpc";
15
+ //#region ../../node_modules/.pnpm/nanostores@1.3.0/node_modules/nanostores/computed/index.js
16
+ var computedStore = (e, t, n) => {
17
+ Array.isArray(e) || (e = [e]);
18
+ let r, i, set = () => {
19
+ if (i === s.epoch) return;
20
+ i = s.epoch;
21
+ let n = e.map((e) => e.get());
22
+ if (!r || n.some((e, t) => e !== r[t])) {
23
+ r = n;
24
+ let e = t(...n);
25
+ e && e.then && e.t ? e.then((e) => {
26
+ r === n && a.set(e);
27
+ }) : (a.set(e), i = s.epoch);
28
+ }
29
+ }, a = /* @__PURE__ */ m(void 0), o = a.get;
30
+ a.get = () => (set(), o());
31
+ let c, l = n ? () => {
32
+ clearTimeout(c), c = setTimeout(set);
33
+ } : set;
34
+ return p(a, () => {
35
+ let t = e.map((e) => e.listen(l));
36
+ return set(), () => {
37
+ for (let e of t) e();
38
+ };
39
+ }), a;
40
+ }, batched = /* @__NO_SIDE_EFFECTS__ */ (e, t) => computedStore(e, t, !0), B = pe(null);
41
+ function useChatContext() {
42
+ return z(me(B), "useChatContext: ChatProvider is not provided");
43
+ }
44
+ //#endregion
45
+ //#region src/aichat/ChatInput.tsx
46
+ function ChatInput() {
47
+ let e = F(22), { sendMessage: t, isLoading: n, messages: r, clear: i, stop: o } = useChatContext(), [s, c] = P(""), l = N(null), t0;
48
+ e[0] !== n || e[1] !== t || e[2] !== s ? (t0 = () => {
49
+ !s.trim() || n || (t(s), c(""));
50
+ }, e[0] = n, e[1] = t, e[2] = s, e[3] = t0) : t0 = e[3];
51
+ let u = t0, t1;
52
+ e[4] === Symbol.for("react.memo_cache_sentinel") ? (t1 = (e) => c(e.target.value), e[4] = t1) : t1 = e[4];
53
+ let t2;
54
+ e[5] === u ? t2 = e[6] : (t2 = (e) => {
55
+ e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.metaKey && (e.preventDefault(), u());
56
+ }, e[5] = u, e[6] = t2);
57
+ let d;
58
+ e[7] !== n || e[8] !== t2 || e[9] !== s ? (d = /* @__PURE__ */ L(te, {
59
+ flex: 1,
60
+ className: "chat-input",
61
+ placeholder: "Your question...",
62
+ value: s,
63
+ onChange: t1,
64
+ onKeyDown: t2,
65
+ disabled: n,
66
+ ref: l,
67
+ loading: n,
68
+ autosize: !0,
69
+ minRows: 1
70
+ }), e[7] = n, e[8] = t2, e[9] = s, e[10] = d) : d = e[10];
71
+ let f;
72
+ e[11] !== i || e[12] !== n || e[13] !== r.length ? (f = r.length > 0 && !n && /* @__PURE__ */ L(ee, {
73
+ size: "sm",
74
+ color: "red",
75
+ variant: "light",
76
+ onClick: () => i(),
77
+ children: "Clear"
78
+ }), e[11] = i, e[12] = n, e[13] = r.length, e[14] = f) : f = e[14];
79
+ let p;
80
+ e[15] !== n || e[16] !== o ? (p = n && /* @__PURE__ */ L(v, {
81
+ color: "red",
82
+ variant: "light",
83
+ onClick: () => o(),
84
+ children: /* @__PURE__ */ L(a, {})
85
+ }), e[15] = n, e[16] = o, e[17] = p) : p = e[17];
86
+ let m;
87
+ return e[18] !== d || e[19] !== f || e[20] !== p ? (m = /* @__PURE__ */ R(w, { children: [
88
+ d,
89
+ f,
90
+ p
91
+ ] }), e[18] = d, e[19] = f, e[20] = p, e[21] = m) : m = e[21], m;
92
+ }
93
+ //#endregion
94
+ //#region src/aichat/ChatMessage.tsx
95
+ function ChatMessages() {
96
+ let e = F(7), { messages: t, error: n } = useChatContext(), r;
97
+ e[0] === t ? r = e[1] : (r = t.map(_temp), e[0] = t, e[1] = r);
98
+ let i;
99
+ e[2] === n ? i = e[3] : (i = n && /* @__PURE__ */ L(y, {
100
+ styles: { icon: { alignSelf: "flex-start" } },
101
+ color: "red",
102
+ title: "Oops, something went wrong",
103
+ withCloseButton: !1,
104
+ children: /* @__PURE__ */ R(C, {
105
+ fontSize: "sm",
106
+ fontFamily: "mono",
107
+ whiteSpace: "pre",
108
+ my: "xs",
109
+ children: [n.message, n.stack && "\n" + n.stack]
110
+ })
111
+ }), e[2] = n, e[3] = i);
112
+ let a;
113
+ return e[4] !== r || e[5] !== i ? (a = /* @__PURE__ */ R(I, { children: [r, i] }), e[4] = r, e[5] = i, e[6] = a) : a = e[6], a;
114
+ }
115
+ function _temp(e) {
116
+ return /* @__PURE__ */ L(ChatMessage, { message: e }, e.id);
117
+ }
118
+ var ChatMessage = (e) => {
119
+ let t = F(4), { message: n } = e, r = n.role, i;
120
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (i = S({
121
+ color: "text.bright",
122
+ alignSelf: "flex-end",
123
+ paddingInline: "2",
124
+ paddingBlock: "1",
125
+ marginInlineEnd: "2",
126
+ rounded: "sm",
127
+ backgroundColor: "default.hover",
128
+ whiteSpace: "pre-wrap"
129
+ }), t[0] = i) : i = t[0];
130
+ let a = r === "user" ? UserMessageTextPart : MarkdownTextPart, o;
131
+ return t[1] !== n || t[2] !== a ? (o = /* @__PURE__ */ L(fe, {
132
+ message: n,
133
+ userClassName: i,
134
+ textPartRenderer: a
135
+ }), t[1] = n, t[2] = a, t[3] = o) : o = t[3], o;
136
+ }, UserMessageTextPart = (e) => {
137
+ let t = F(2), { content: n } = e, r;
138
+ return t[0] === n ? r = t[1] : (r = /* @__PURE__ */ L(I, { children: n }), t[0] = n, t[1] = r), r;
139
+ }, MarkdownTextPart = (e) => {
140
+ let t = F(4), { content: n } = e, r;
141
+ t[0] === n ? r = t[1] : (r = ge.from({ md: n }), t[0] = n, t[1] = r);
142
+ let i;
143
+ return t[2] === r ? i = t[3] : (i = /* @__PURE__ */ L(c, {
144
+ textScale: .95,
145
+ value: r
146
+ }), t[2] = r, t[3] = i), i;
147
+ }, V = /* @__PURE__ */ m(""), H = /* @__PURE__ */ m("closed"), be = /* @__PURE__ */ batched([V, H], (e, t) => ({
148
+ log: e,
149
+ status: t
150
+ }));
151
+ function useSemanticLayoutLog() {
152
+ return o(be);
153
+ }
154
+ function closeSemanticLayoutLog() {
155
+ H.set("closed"), V.set("");
156
+ }
157
+ //#endregion
158
+ //#region src/aichat/SemanticLayoutLog.tsx
159
+ function SemanticLayoutLog() {
160
+ let e = F(6), { log: t, status: n } = useSemanticLayoutLog();
161
+ if (n === "closed") return null;
162
+ let r = n === "completed", i;
163
+ e[0] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ L(ae, {
164
+ order: 4,
165
+ children: "Semantic Layout"
166
+ }), e[0] = i) : i = e[0];
167
+ let a = t || "Waiting for response...", o;
168
+ e[1] === a ? o = e[2] : (o = /* @__PURE__ */ L(C, {
169
+ whiteSpace: "pre-wrap",
170
+ children: a
171
+ }), e[1] = a, e[2] = o);
172
+ let s;
173
+ return e[3] !== r || e[4] !== o ? (s = /* @__PURE__ */ L(b, {
174
+ size: "xl",
175
+ opened: !0,
176
+ onClose: closeSemanticLayoutLog,
177
+ closeOnEscape: r,
178
+ withCloseButton: r,
179
+ closeOnClickOutside: r,
180
+ title: i,
181
+ children: o
182
+ }), e[3] = r, e[4] = o, e[5] = s) : s = e[5], s;
183
+ }
184
+ //#endregion
185
+ //#region ../vite-plugin/src/ai/tools.ts
186
+ var U = A({
187
+ id: E().meta({ description: "Node ID" }),
188
+ title: E(),
189
+ shape: j(ve),
190
+ color: E().meta({ description: "Node color, from theme or custom" }),
191
+ icon: E().nullish(),
192
+ parentId: E().nullish().meta({ description: "Parent node ID (if node is nested)" }),
193
+ children: D(E()).nullish().meta({ description: "Nested node IDs (if node is compound)" }),
194
+ x: O(),
195
+ y: O(),
196
+ width: O(),
197
+ height: O(),
198
+ modelFqn: E().nullish().meta({ description: "Model element FQN (if node has reference)" })
199
+ }), xe = M({
200
+ name: "read_ui",
201
+ description: "Read current UI state. Use arguments to include additional data.",
202
+ needsApproval: !1,
203
+ inputSchema: A({
204
+ selectedNode: k().default(!1).meta({ description: "Include selected node (if any)" }),
205
+ nodes: k().default(!1).meta({ description: "Include all nodes from the view" })
206
+ }),
207
+ outputSchema: A({
208
+ projectId: E(),
209
+ editMode: k().meta({ description: "Whether the UI is in edit mode" }),
210
+ view: A({
211
+ id: E(),
212
+ title: E(),
213
+ type: j([
214
+ "element",
215
+ "deployment",
216
+ "dynamic"
217
+ ]).meta({ description: "Type of the current view" })
218
+ }).meta({ description: "Current view" }),
219
+ nodes: D(U).nullish(),
220
+ selectedNode: U.nullish()
221
+ })
222
+ }), Se = M({
223
+ name: "update_ui",
224
+ description: "Update UI state by executing a command.",
225
+ needsApproval: !1,
226
+ inputSchema: A({ command: ce("type", [A({
227
+ type: T("focus"),
228
+ elementId: E().meta({ description: "Element ID (FQN)" })
229
+ }).meta({ description: "Focus UI on an element by its FQN" }), A({ type: T("fitview") }).meta({ description: "Zoom out to fit all elements in the viewport, and clear any selection/focus" })]) }),
230
+ outputSchema: A({})
231
+ }), Ce = M({
232
+ name: "navigate_to",
233
+ description: "Navigates UI to another view",
234
+ needsApproval: !1,
235
+ inputSchema: A({ viewId: E().meta({ description: "View ID" }) }),
236
+ outputSchema: A({})
237
+ }), DoubleIndexedKV = class {
238
+ constructor() {
239
+ this.keyToValue = /* @__PURE__ */ new Map(), this.valueToKey = /* @__PURE__ */ new Map();
240
+ }
241
+ set(e, t) {
242
+ this.keyToValue.set(e, t), this.valueToKey.set(t, e);
243
+ }
244
+ getByKey(e) {
245
+ return this.keyToValue.get(e);
246
+ }
247
+ getByValue(e) {
248
+ return this.valueToKey.get(e);
249
+ }
250
+ clear() {
251
+ this.keyToValue.clear(), this.valueToKey.clear();
252
+ }
253
+ }, Registry = class {
254
+ constructor(e) {
255
+ this.generateIdentifier = e, this.kv = new DoubleIndexedKV();
256
+ }
257
+ register(e, t) {
258
+ this.kv.getByValue(e) || (t ||= this.generateIdentifier(e), this.kv.set(t, e));
259
+ }
260
+ clear() {
261
+ this.kv.clear();
262
+ }
263
+ getIdentifier(e) {
264
+ return this.kv.getByValue(e);
265
+ }
266
+ getValue(e) {
267
+ return this.kv.getByKey(e);
268
+ }
269
+ }, ClassRegistry = class extends Registry {
270
+ constructor() {
271
+ super((e) => e.name), this.classToAllowedProps = /* @__PURE__ */ new Map();
272
+ }
273
+ register(e, t) {
274
+ typeof t == "object" ? (t.allowProps && this.classToAllowedProps.set(e, t.allowProps), super.register(e, t.identifier)) : super.register(e, t);
275
+ }
276
+ getAllowedProps(e) {
277
+ return this.classToAllowedProps.get(e);
278
+ }
279
+ };
280
+ //#endregion
281
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/util.js
282
+ function valuesOfObj(e) {
283
+ if ("values" in Object) return Object.values(e);
284
+ let t = [];
285
+ for (let n in e) e.hasOwnProperty(n) && t.push(e[n]);
286
+ return t;
287
+ }
288
+ function find(e, t) {
289
+ let n = valuesOfObj(e);
290
+ if ("find" in n) return n.find(t);
291
+ let r = n;
292
+ for (let e = 0; e < r.length; e++) {
293
+ let n = r[e];
294
+ if (t(n)) return n;
295
+ }
296
+ }
297
+ function forEach(e, t) {
298
+ Object.entries(e).forEach(([e, n]) => t(n, e));
299
+ }
300
+ function includes(e, t) {
301
+ return e.indexOf(t) !== -1;
302
+ }
303
+ function findArr(e, t) {
304
+ for (let n = 0; n < e.length; n++) {
305
+ let r = e[n];
306
+ if (t(r)) return r;
307
+ }
308
+ }
309
+ //#endregion
310
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/custom-transformer-registry.js
311
+ var CustomTransformerRegistry = class {
312
+ constructor() {
313
+ this.transfomers = {};
314
+ }
315
+ register(e) {
316
+ this.transfomers[e.name] = e;
317
+ }
318
+ findApplicable(e) {
319
+ return find(this.transfomers, (t) => t.isApplicable(e));
320
+ }
321
+ findByName(e) {
322
+ return this.transfomers[e];
323
+ }
324
+ }, we = /* @__PURE__ */ e((e) => Object.prototype.toString.call(e).slice(8, -1), "getType"), isUndefined = (e) => e === void 0, isNull = (e) => e === null, W = /* @__PURE__ */ e((e) => typeof e != "object" || !e || e === Object.prototype ? !1 : Object.getPrototypeOf(e) === null ? !0 : Object.getPrototypeOf(e) === Object.prototype, "isPlainObject"), isEmptyObject = (e) => W(e) && Object.keys(e).length === 0, G = /* @__PURE__ */ e((e) => Array.isArray(e), "isArray"), isString = (e) => typeof e == "string", isNumber = (e) => typeof e == "number" && !isNaN(e), isBoolean = (e) => typeof e == "boolean", isRegExp = (e) => e instanceof RegExp, isMap = (e) => e instanceof Map, isSet = (e) => e instanceof Set, isSymbol = (e) => we(e) === "Symbol", isDate = (e) => e instanceof Date && !isNaN(e.valueOf()), isError = (e) => e instanceof Error, isNaNValue = (e) => typeof e == "number" && isNaN(e), isPrimitive = (e) => isBoolean(e) || isNull(e) || isUndefined(e) || isNumber(e) || isString(e) || isSymbol(e), isBigint = (e) => typeof e == "bigint", isInfinite = (e) => e === Infinity || e === -Infinity, isTypedArray = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView), isURL = (e) => e instanceof URL, escapeKey = (e) => e.replace(/\\/g, "\\\\").replace(/\./g, "\\."), stringifyPath = (e) => e.map(String).map(escapeKey).join("."), parsePath = (e, t) => {
325
+ let n = [], r = "";
326
+ for (let i = 0; i < e.length; i++) {
327
+ let a = e.charAt(i);
328
+ if (!t && a === "\\") {
329
+ let t = e.charAt(i + 1);
330
+ if (t === "\\") {
331
+ r += "\\", i++;
332
+ continue;
333
+ } else if (t !== ".") throw Error("invalid path");
334
+ }
335
+ if (a === "\\" && e.charAt(i + 1) === ".") {
336
+ r += ".", i++;
337
+ continue;
338
+ }
339
+ if (a === ".") {
340
+ n.push(r), r = "";
341
+ continue;
342
+ }
343
+ r += a;
344
+ }
345
+ let i = r;
346
+ return n.push(i), n;
347
+ };
348
+ //#endregion
349
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/transformer.js
350
+ function simpleTransformation(e, t, n, r) {
351
+ return {
352
+ isApplicable: e,
353
+ annotation: t,
354
+ transform: n,
355
+ untransform: r
356
+ };
357
+ }
358
+ var K = [
359
+ simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
360
+ simpleTransformation(isBigint, "bigint", (e) => e.toString(), (e) => typeof BigInt < "u" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
361
+ simpleTransformation(isDate, "Date", (e) => e.toISOString(), (e) => new Date(e)),
362
+ simpleTransformation(isError, "Error", (e, t) => {
363
+ let n = {
364
+ name: e.name,
365
+ message: e.message
366
+ };
367
+ return "cause" in e && (n.cause = e.cause), t.allowedErrorProps.forEach((t) => {
368
+ n[t] = e[t];
369
+ }), n;
370
+ }, (e, t) => {
371
+ let n = Error(e.message, { cause: e.cause });
372
+ return n.name = e.name, n.stack = e.stack, t.allowedErrorProps.forEach((t) => {
373
+ n[t] = e[t];
374
+ }), n;
375
+ }),
376
+ simpleTransformation(isRegExp, "regexp", (e) => "" + e, (e) => {
377
+ let t = e.slice(1, e.lastIndexOf("/")), n = e.slice(e.lastIndexOf("/") + 1);
378
+ return new RegExp(t, n);
379
+ }),
380
+ simpleTransformation(isSet, "set", (e) => [...e.values()], (e) => new Set(e)),
381
+ simpleTransformation(isMap, "map", (e) => [...e.entries()], (e) => new Map(e)),
382
+ simpleTransformation((e) => isNaNValue(e) || isInfinite(e), "number", (e) => isNaNValue(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
383
+ simpleTransformation((e) => e === 0 && 1 / e == -Infinity, "number", () => "-0", Number),
384
+ simpleTransformation(isURL, "URL", (e) => e.toString(), (e) => new URL(e))
385
+ ];
386
+ function compositeTransformation(e, t, n, r) {
387
+ return {
388
+ isApplicable: e,
389
+ annotation: t,
390
+ transform: n,
391
+ untransform: r
392
+ };
393
+ }
394
+ var q = compositeTransformation((e, t) => isSymbol(e) ? !!t.symbolRegistry.getIdentifier(e) : !1, (e, t) => ["symbol", t.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, t, n) => {
395
+ let r = n.symbolRegistry.getValue(t[1]);
396
+ if (!r) throw Error("Trying to deserialize unknown symbol");
397
+ return r;
398
+ }), Te = [
399
+ Int8Array,
400
+ Uint8Array,
401
+ Int16Array,
402
+ Uint16Array,
403
+ Int32Array,
404
+ Uint32Array,
405
+ Float32Array,
406
+ Float64Array,
407
+ Uint8ClampedArray
408
+ ].reduce((e, t) => (e[t.name] = t, e), {}), J = compositeTransformation(isTypedArray, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, t) => {
409
+ let n = Te[t[1]];
410
+ if (!n) throw Error("Trying to deserialize unknown typed array");
411
+ return new n(e);
412
+ });
413
+ function isInstanceOfRegisteredClass(e, t) {
414
+ return e?.constructor ? !!t.classRegistry.getIdentifier(e.constructor) : !1;
415
+ }
416
+ var Y = compositeTransformation(isInstanceOfRegisteredClass, (e, t) => ["class", t.classRegistry.getIdentifier(e.constructor)], (e, t) => {
417
+ let n = t.classRegistry.getAllowedProps(e.constructor);
418
+ if (!n) return { ...e };
419
+ let r = {};
420
+ return n.forEach((t) => {
421
+ r[t] = e[t];
422
+ }), r;
423
+ }, (e, t, n) => {
424
+ let r = n.classRegistry.getValue(t[1]);
425
+ if (!r) throw Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
426
+ return Object.assign(Object.create(r.prototype), e);
427
+ }), 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) => {
428
+ let r = n.customTransformerRegistry.findByName(t[1]);
429
+ if (!r) throw Error("Trying to deserialize unknown custom value");
430
+ return r.deserialize(e);
431
+ }), Ee = [
432
+ Y,
433
+ q,
434
+ X,
435
+ J
436
+ ], transformValue = (e, t) => {
437
+ let n = findArr(Ee, (n) => n.isApplicable(e, t));
438
+ if (n) return {
439
+ value: n.transform(e, t),
440
+ type: n.annotation(e, t)
441
+ };
442
+ let r = findArr(K, (n) => n.isApplicable(e, t));
443
+ if (r) return {
444
+ value: r.transform(e, t),
445
+ type: r.annotation
446
+ };
447
+ }, Z = {};
448
+ K.forEach((e) => {
449
+ Z[e.annotation] = e;
450
+ });
451
+ var untransformValue = (e, t, n) => {
452
+ if (G(t)) switch (t[0]) {
453
+ case "symbol": return q.untransform(e, t, n);
454
+ case "class": return Y.untransform(e, t, n);
455
+ case "custom": return X.untransform(e, t, n);
456
+ case "typed-array": return J.untransform(e, t, n);
457
+ default: throw Error("Unknown transformation: " + t);
458
+ }
459
+ else {
460
+ let r = Z[t];
461
+ if (!r) throw Error("Unknown transformation: " + t);
462
+ return r.untransform(e, n);
463
+ }
464
+ }, getNthKey = (e, t) => {
465
+ if (t > e.size) throw Error("index out of bounds");
466
+ let n = e.keys();
467
+ for (; t > 0;) n.next(), t--;
468
+ return n.next().value;
469
+ };
470
+ function validatePath(e) {
471
+ if (includes(e, "__proto__")) throw Error("__proto__ is not allowed as a property");
472
+ if (includes(e, "prototype")) throw Error("prototype is not allowed as a property");
473
+ if (includes(e, "constructor")) throw Error("constructor is not allowed as a property");
474
+ }
475
+ var getDeep = (e, t) => {
476
+ validatePath(t);
477
+ for (let n = 0; n < t.length; n++) {
478
+ let r = t[n];
479
+ if (isSet(e)) e = getNthKey(e, +r);
480
+ else if (isMap(e)) {
481
+ let i = +r, a = +t[++n] == 0 ? "key" : "value", o = getNthKey(e, i);
482
+ switch (a) {
483
+ case "key":
484
+ e = o;
485
+ break;
486
+ case "value":
487
+ e = e.get(o);
488
+ break;
489
+ }
490
+ } else e = e[r];
491
+ }
492
+ return e;
493
+ }, setDeep = (e, t, n) => {
494
+ if (validatePath(t), t.length === 0) return n(e);
495
+ let r = e;
496
+ for (let e = 0; e < t.length - 1; e++) {
497
+ let n = t[e];
498
+ if (G(r)) {
499
+ let e = +n;
500
+ r = r[e];
501
+ } else if (W(r)) r = r[n];
502
+ else if (isSet(r)) {
503
+ let e = +n;
504
+ r = getNthKey(r, e);
505
+ } else if (isMap(r)) {
506
+ if (e === t.length - 2) break;
507
+ let i = +n, a = +t[++e] == 0 ? "key" : "value", o = getNthKey(r, i);
508
+ switch (a) {
509
+ case "key":
510
+ r = o;
511
+ break;
512
+ case "value":
513
+ r = r.get(o);
514
+ break;
515
+ }
516
+ }
517
+ }
518
+ let i = t[t.length - 1];
519
+ if (G(r) ? r[+i] = n(r[+i]) : W(r) && (r[i] = n(r[i])), isSet(r)) {
520
+ let e = getNthKey(r, +i), t = n(e);
521
+ e !== t && (r.delete(e), r.add(t));
522
+ }
523
+ if (isMap(r)) {
524
+ let e = +t[t.length - 2], a = getNthKey(r, e);
525
+ switch (+i == 0 ? "key" : "value") {
526
+ case "key": {
527
+ let e = n(a);
528
+ r.set(e, r.get(a)), e !== a && r.delete(a);
529
+ break;
530
+ }
531
+ case "value":
532
+ r.set(a, n(r.get(a)));
533
+ break;
534
+ }
535
+ }
536
+ return e;
537
+ }, enableLegacyPaths = (e) => e < 1;
538
+ function traverse(e, t, n, r = []) {
539
+ if (!e) return;
540
+ let i = enableLegacyPaths(n);
541
+ if (!G(e)) {
542
+ forEach(e, (e, a) => traverse(e, t, n, [...r, ...parsePath(a, i)]));
543
+ return;
544
+ }
545
+ let [a, o] = e;
546
+ o && forEach(o, (e, a) => {
547
+ traverse(e, t, n, [...r, ...parsePath(a, i)]);
548
+ }), t(a, r);
549
+ }
550
+ function applyValueAnnotations(e, t, n, r) {
551
+ return traverse(t, (t, n) => {
552
+ e = setDeep(e, n, (e) => untransformValue(e, t, r));
553
+ }, n), e;
554
+ }
555
+ function applyReferentialEqualityAnnotations(e, t, n) {
556
+ let r = enableLegacyPaths(n);
557
+ function apply(t, n) {
558
+ let i = getDeep(e, parsePath(n, r));
559
+ t.map((e) => parsePath(e, r)).forEach((t) => {
560
+ e = setDeep(e, t, () => i);
561
+ });
562
+ }
563
+ if (G(t)) {
564
+ let [n, i] = t;
565
+ n.forEach((t) => {
566
+ e = setDeep(e, parsePath(t, r), () => e);
567
+ }), i && forEach(i, apply);
568
+ } else forEach(t, apply);
569
+ return e;
570
+ }
571
+ var isDeep = (e, t) => W(e) || G(e) || isMap(e) || isSet(e) || isError(e) || isInstanceOfRegisteredClass(e, t);
572
+ function addIdentity(e, t, n) {
573
+ let r = n.get(e);
574
+ r ? r.push(t) : n.set(e, [t]);
575
+ }
576
+ function generateReferentialEqualityAnnotations(e, t) {
577
+ let n = {}, r;
578
+ return e.forEach((e) => {
579
+ if (e.length <= 1) return;
580
+ t || (e = e.map((e) => e.map(String)).sort((e, t) => e.length - t.length));
581
+ let [i, ...a] = e;
582
+ i.length === 0 ? r = a.map(stringifyPath) : n[stringifyPath(i)] = a.map(stringifyPath);
583
+ }), r ? isEmptyObject(n) ? [r] : [r, n] : isEmptyObject(n) ? void 0 : n;
584
+ }
585
+ var walker = (e, t, n, r, i = [], a = [], o = /* @__PURE__ */ new Map()) => {
586
+ let s = isPrimitive(e);
587
+ if (!s) {
588
+ addIdentity(e, i, t);
589
+ let n = o.get(e);
590
+ if (n) return r ? { transformedValue: null } : n;
591
+ }
592
+ if (!isDeep(e, n)) {
593
+ let t = transformValue(e, n), r = t ? {
594
+ transformedValue: t.value,
595
+ annotations: [t.type]
596
+ } : { transformedValue: e };
597
+ return s || o.set(e, r), r;
598
+ }
599
+ if (includes(a, e)) return { transformedValue: null };
600
+ let c = transformValue(e, n), l = c?.value ?? e, u = G(l) ? [] : {}, d = {};
601
+ forEach(l, (s, c) => {
602
+ if (c === "__proto__" || c === "constructor" || c === "prototype") throw Error(`Detected property ${c}. This is a prototype pollution risk, please remove it from your object.`);
603
+ let l = walker(s, t, n, r, [...i, c], [...a, e], o);
604
+ u[c] = l.transformedValue, G(l.annotations) ? d[escapeKey(c)] = l.annotations : W(l.annotations) && forEach(l.annotations, (e, t) => {
605
+ d[escapeKey(c) + "." + t] = e;
606
+ });
607
+ });
608
+ let f = isEmptyObject(d) ? {
609
+ transformedValue: u,
610
+ annotations: c ? [c.type] : void 0
611
+ } : {
612
+ transformedValue: u,
613
+ annotations: c ? [c.type, d] : d
614
+ };
615
+ return s || o.set(e, f), f;
616
+ };
617
+ //#endregion
618
+ //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/getType.js
619
+ function getType(e) {
620
+ return Object.prototype.toString.call(e).slice(8, -1);
621
+ }
622
+ //#endregion
623
+ //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isArray.js
624
+ function isArray(e) {
625
+ return getType(e) === "Array";
626
+ }
627
+ //#endregion
628
+ //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isPlainObject.js
629
+ function isPlainObject(e) {
630
+ if (getType(e) !== "Object") return !1;
631
+ let t = Object.getPrototypeOf(e);
632
+ return !!t && t.constructor === Object && t === Object.prototype;
633
+ }
634
+ //#endregion
635
+ //#region ../../node_modules/.pnpm/copy-anything@4.0.5/node_modules/copy-anything/dist/index.js
636
+ function assignProp(e, t, n, r, i) {
637
+ let a = {}.propertyIsEnumerable.call(r, t) ? "enumerable" : "nonenumerable";
638
+ a === "enumerable" && (e[t] = n), i && a === "nonenumerable" && Object.defineProperty(e, t, {
639
+ value: n,
640
+ enumerable: !1,
641
+ writable: !0,
642
+ configurable: !0
643
+ });
644
+ }
645
+ function copy(e, t = {}) {
646
+ if (isArray(e)) return e.map((e) => copy(e, t));
647
+ if (!isPlainObject(e)) return e;
648
+ let n = Object.getOwnPropertyNames(e), r = Object.getOwnPropertySymbols(e);
649
+ return [...n, ...r].reduce((n, r) => {
650
+ if (r === "__proto__" || isArray(t.props) && !t.props.includes(r)) return n;
651
+ let i = e[r];
652
+ return assignProp(n, r, copy(i, t), e, t.nonenumerable), n;
653
+ }, {});
654
+ }
655
+ //#endregion
656
+ //#region ../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/index.js
657
+ var SuperJSON = class {
658
+ constructor({ dedupe: e = !1 } = {}) {
659
+ this.classRegistry = new ClassRegistry(), this.symbolRegistry = new Registry((e) => e.description ?? ""), this.customTransformerRegistry = new CustomTransformerRegistry(), this.allowedErrorProps = [], this.dedupe = e;
660
+ }
661
+ serialize(e) {
662
+ let t = /* @__PURE__ */ new Map(), n = walker(e, t, this, this.dedupe), r = { json: n.transformedValue };
663
+ n.annotations && (r.meta = {
664
+ ...r.meta,
665
+ values: n.annotations
666
+ });
667
+ let i = generateReferentialEqualityAnnotations(t, this.dedupe);
668
+ return i && (r.meta = {
669
+ ...r.meta,
670
+ referentialEqualities: i
671
+ }), r.meta && (r.meta.v = 1), r;
672
+ }
673
+ deserialize(e, t) {
674
+ let { json: n, meta: r } = e, i = t?.inPlace ? n : copy(n);
675
+ return r?.values && (i = applyValueAnnotations(i, r.values, r.v ?? 0, this)), r?.referentialEqualities && (i = applyReferentialEqualityAnnotations(i, r.referentialEqualities, r.v ?? 0)), i;
676
+ }
677
+ stringify(e) {
678
+ return JSON.stringify(this.serialize(e));
679
+ }
680
+ parse(e) {
681
+ return this.deserialize(JSON.parse(e), { inPlace: !0 });
682
+ }
683
+ registerClass(e, t) {
684
+ this.classRegistry.register(e, t);
685
+ }
686
+ registerSymbol(e, t) {
687
+ this.symbolRegistry.register(e, t);
688
+ }
689
+ registerCustom(e, t) {
690
+ this.customTransformerRegistry.register({
691
+ name: t,
692
+ ...e
693
+ });
694
+ }
695
+ allowErrorProps(...e) {
696
+ this.allowedErrorProps.push(...e);
697
+ }
698
+ };
699
+ SuperJSON.defaultInstance = new SuperJSON(), SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance), SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance), SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance), SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance), SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance), SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance), SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance), SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance), SuperJSON.serialize, SuperJSON.deserialize;
700
+ var De = SuperJSON.stringify, Oe = SuperJSON.parse;
701
+ SuperJSON.registerClass, SuperJSON.registerCustom, SuperJSON.registerSymbol, SuperJSON.allowErrorProps;
702
+ //#endregion
703
+ //#region src/aichat/useChat.tsx
704
+ function mapToNodeData(e) {
705
+ return ({ id: t, data: n, ...r }) => {
706
+ let i = n.icon ?? void 0;
707
+ i === "none" && (i = void 0);
708
+ let a = e.parentLookup.get(t)?.values().map((e) => e.id).toArray();
709
+ return {
710
+ id: t,
711
+ title: n.title,
712
+ shape: n.shape,
713
+ color: n.color,
714
+ icon: i,
715
+ parentId: r.parentId,
716
+ children: a,
717
+ x: n.x,
718
+ y: n.y,
719
+ width: r.measured?.width ?? r.width ?? r.initialWidth ?? 0,
720
+ height: r.measured?.height ?? r.height ?? r.initialHeight ?? 0,
721
+ ..."modelFqn" in n && n.modelFqn && { modelFqn: n.modelFqn }
722
+ };
723
+ };
724
+ }
725
+ function useChatTools() {
726
+ let e = F(11), { id: n } = f(), a = t(), o = d(), s;
727
+ if (e[0] !== o || e[1] !== a || e[2] !== n) {
728
+ let t1;
729
+ e[4] === a ? t1 = e[5] : (t1 = (e) => {
730
+ let { viewId: t } = e;
731
+ return a({
732
+ to: "./",
733
+ params: (e) => ({
734
+ ...e,
735
+ viewId: t
736
+ })
737
+ }), {};
738
+ }, e[4] = a, e[5] = t1);
739
+ let t2;
740
+ e[6] !== o || e[7] !== n ? (t2 = (e) => {
741
+ let { view: t, focusedNode: a, xynodes: s, xystore: c, toggledFeatures: u, features: d } = o.getContext(), f = u.enableReadOnly ?? d.enableReadOnly, p = mapToNodeData(c.getState()), m = e.nodes === !0 && l(s, p) || void 0, h = e.selectedNode === !0 && r(s, i((e) => !!e.selected || e.id === a), (e) => e ? p(e) : void 0);
742
+ return {
743
+ projectId: n,
744
+ editMode: !f,
745
+ view: {
746
+ id: t.id,
747
+ title: t.title ?? "",
748
+ type: t._type
749
+ },
750
+ ...m && { nodes: m },
751
+ ...h && { selectedNode: h }
752
+ };
753
+ }, e[6] = o, e[7] = n, e[8] = t2) : t2 = e[8];
754
+ let t3;
755
+ e[9] === o ? t3 = e[10] : (t3 = (e) => {
756
+ let { command: t } = e;
757
+ bb50: switch (t.type) {
758
+ case "focus":
759
+ o.focusOnElement(t.elementId);
760
+ break bb50;
761
+ case "fitview":
762
+ o.fitDiagram();
763
+ break bb50;
764
+ default: _e(t);
765
+ }
766
+ return {};
767
+ }, e[9] = o, e[10] = t3), s = de(Ce.client(t1), xe.client(t2), Se.client(t3)), e[0] = o, e[1] = a, e[2] = n, e[3] = s;
768
+ } else s = e[3];
769
+ return s;
770
+ }
771
+ var Q = {
772
+ key: "likec4.ai.chat.messages",
773
+ read() {
774
+ try {
775
+ let e = sessionStorage.getItem(this.key);
776
+ return e ? Oe(e) : [];
777
+ } catch {
778
+ return [];
779
+ }
780
+ },
781
+ write(e) {
782
+ try {
783
+ if (e.length === 0) {
784
+ sessionStorage.removeItem(this.key);
785
+ return;
786
+ }
787
+ sessionStorage.setItem(this.key, De(e));
788
+ } catch {}
789
+ }
790
+ };
791
+ function useChat(e) {
792
+ let t = F(7), n;
793
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (n = {
794
+ connection: le("/__likec4_ai"),
795
+ initialMessages: Q.read()
796
+ }, t[0] = n) : n = t[0];
797
+ let r = n, i = useChatTools(), a;
798
+ t[1] !== e || t[2] !== i ? (a = {
799
+ ...r,
800
+ ...e,
801
+ tools: i
802
+ }, t[1] = e, t[2] = i, t[3] = a) : a = t[3];
803
+ let o = ue(a), t3, s;
804
+ return t[4] === o.messages ? (t3 = t[5], s = t[6]) : (t3 = () => {
805
+ Q.write(o.messages);
806
+ }, s = [o.messages], t[4] = o.messages, t[5] = t3, t[6] = s), he(t3, s), o;
807
+ }
808
+ //#endregion
809
+ //#region src/aichat/AIChat.tsx
810
+ var $ = {
811
+ key: "likec4.ai.chat.position",
812
+ read() {
813
+ try {
814
+ let e = localStorage.getItem(this.key);
815
+ return e ? JSON.parse(e) : null;
816
+ } catch {
817
+ return null;
818
+ }
819
+ },
820
+ write(e) {
821
+ try {
822
+ if (e === null) return localStorage.removeItem(this.key), e;
823
+ localStorage.setItem(this.key, JSON.stringify(e));
824
+ } catch {}
825
+ return e;
826
+ }
827
+ };
828
+ function AIChatComponent() {
829
+ let e = N(null);
830
+ e.current ||= $.read() ?? {
831
+ right: 16,
832
+ bottom: 100
833
+ };
834
+ let onPositionChange = (t) => {
835
+ e.current = $.write({
836
+ left: t.x,
837
+ top: t.y
838
+ });
839
+ }, [t, n] = ne({
840
+ key: "likec4.ai.chat.collapsed",
841
+ defaultValue: !0
842
+ });
843
+ return /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ R(se, { children: [!t && /* @__PURE__ */ L(h, {
844
+ w: 300,
845
+ pos: "fixed",
846
+ className: S({
847
+ rounded: "md",
848
+ padding: "xs",
849
+ shadow: "md",
850
+ layerStyle: "likec4.panel"
851
+ }),
852
+ constrainToViewport: !0,
853
+ constrainOffset: 8,
854
+ excludeDragHandleSelector: ".chat-input",
855
+ initialPosition: e.current,
856
+ onPositionChange,
857
+ children: /* @__PURE__ */ L(AIChatWindowContent, { onClose: () => n(!0) })
858
+ }), t && /* @__PURE__ */ L(oe.div, {
859
+ initial: {
860
+ opacity: .1,
861
+ translateX: "10%"
862
+ },
863
+ animate: {
864
+ opacity: 1,
865
+ translateX: 0
866
+ },
867
+ exit: {
868
+ translateX: "50%",
869
+ opacity: .1
870
+ },
871
+ style: {
872
+ position: "fixed",
873
+ right: 8,
874
+ bottom: 60,
875
+ zIndex: 1e3
876
+ },
877
+ children: /* @__PURE__ */ L(re, {
878
+ label: "Show AI Assistant",
879
+ color: "dark",
880
+ fz: "xs",
881
+ children: /* @__PURE__ */ L(v, {
882
+ size: "lg",
883
+ variant: "gradient",
884
+ onClick: () => n(!1),
885
+ children: /* @__PURE__ */ L(u, { stroke: 1.5 })
886
+ })
887
+ })
888
+ }, "collapsed")] }), /* @__PURE__ */ L(SemanticLayoutLog, {})] });
889
+ }
890
+ function AIChatWindowContent(e) {
891
+ let t = F(15), { onClose: r } = e, i = N(null), t1;
892
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => {
893
+ i.current?.scrollIntoView();
894
+ }, t[0] = t1) : t1 = t[0];
895
+ let a = t1, t2;
896
+ t[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => {
897
+ a();
898
+ }, t[1] = t2) : t2 = t[1], n(t2, 100);
899
+ let o;
900
+ t[2] === Symbol.for("react.memo_cache_sentinel") ? (o = { onChunk: a }, t[2] = o) : o = t[2];
901
+ let s = useChat(o), c;
902
+ t[3] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ R(w, { children: [/* @__PURE__ */ L(C, {
903
+ textStyle: "likec4.panel",
904
+ noUserSelect: !0,
905
+ children: "AI Assistant"
906
+ }), /* @__PURE__ */ L(_, {
907
+ size: "xs",
908
+ radius: "sm",
909
+ variant: "light",
910
+ children: ye
911
+ })] }), t[3] = c) : c = t[3];
912
+ let l;
913
+ t[4] === r ? l = t[5] : (l = /* @__PURE__ */ R(w, {
914
+ cursor: "move",
915
+ justify: "space-between",
916
+ children: [c, /* @__PURE__ */ L(ie, {
917
+ size: "sm",
918
+ onClick: (e) => {
919
+ e.stopPropagation(), r();
920
+ }
921
+ })]
922
+ }), t[4] = r, t[5] = l);
923
+ let u;
924
+ t[6] === Symbol.for("react.memo_cache_sentinel") ? (u = { content: S({ display: "contents" }) }, t[6] = u) : u = t[6];
925
+ let d;
926
+ t[7] === Symbol.for("react.memo_cache_sentinel") ? (d = /* @__PURE__ */ L(ChatMessages, {}), t[7] = d) : d = t[7];
927
+ let f, p;
928
+ t[8] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ L(g, {
929
+ scrollbars: "y",
930
+ w: "100%",
931
+ flex: 1,
932
+ mih: 250,
933
+ mah: 350,
934
+ classNames: u,
935
+ children: /* @__PURE__ */ R(x, { children: [d, /* @__PURE__ */ L("div", {
936
+ ref: i,
937
+ style: { height: 2 }
938
+ })] })
939
+ }), p = /* @__PURE__ */ L(ChatInput, {}), t[8] = f, t[9] = p) : (f = t[8], p = t[9]);
940
+ let m;
941
+ t[10] === l ? m = t[11] : (m = /* @__PURE__ */ R(x, {
942
+ w: "100%",
943
+ children: [
944
+ l,
945
+ f,
946
+ p
947
+ ]
948
+ }), t[10] = l, t[11] = m);
949
+ let h;
950
+ return t[12] !== s || t[13] !== m ? (h = /* @__PURE__ */ L(B, {
951
+ value: s,
952
+ children: m
953
+ }), t[12] = s, t[13] = m, t[14] = h) : h = t[14], h;
954
+ }
955
+ //#endregion
956
+ export { AIChatComponent as default };