@pi-outpost/embed 0.51.0 → 0.53.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.
@@ -21614,6 +21614,7 @@ var zT = {
21614
21614
  UNDO: "pi-outpost:drawio-undo",
21615
21615
  REDO: "pi-outpost:drawio-redo",
21616
21616
  EXPORT_SVG: "pi-outpost:drawio-export-svg",
21617
+ WIRE_STYLE: "pi-outpost:drawio-wire-style",
21617
21618
  CHANGED: "pi-outpost:drawio-changed",
21618
21619
  SAVED: "pi-outpost:drawio-saved",
21619
21620
  SVG: "pi-outpost:drawio-svg",
@@ -21697,7 +21698,8 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
21697
21698
  return root.getElementsByTagName("diagram").length;
21698
21699
  }
21699
21700
 
21700
- function render(xml, dark) {
21701
+ // \`start\`: the page to show first, when nothing is drawn yet; later texts keep the page shown
21702
+ function render(xml, dark, start) {
21701
21703
  last = { xml: xml, dark: dark };
21702
21704
  stopTouchUp();
21703
21705
  document.body.className = dark ? "dark" : "";
@@ -21718,7 +21720,7 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
21718
21720
  tell({ type: M.FAILED, message: "This is not a draw.io diagram: its root is <" + doc.documentElement.nodeName + ">, not <mxfile> or <mxGraphModel>." });
21719
21721
  return;
21720
21722
  }
21721
- var page = viewer !== null ? Math.min(viewer.currentPage || 0, pages - 1) : 0;
21723
+ var page = Math.min(viewer !== null ? viewer.currentPage || 0 : typeof start === "number" && start > 0 ? start : 0, pages - 1);
21722
21724
  var container = document.createElement("div");
21723
21725
  container.id = "diagram";
21724
21726
  document.body.appendChild(container);
@@ -21766,7 +21768,79 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
21766
21768
  var undo = touch.undo;
21767
21769
  // A label being typed is an edit too: leaving now would drop it
21768
21770
  var typing = viewer !== null && viewer.graph.isEditing();
21769
- tell({ type: M.CHANGED, dirty: typing || undo.indexOfNextAdd !== touch.clean, canUndo: undo.canUndo(), canRedo: undo.canRedo() });
21771
+ tell({ type: M.CHANGED, dirty: typing || undo.indexOfNextAdd !== touch.clean, canUndo: undo.canUndo(), canRedo: undo.canRedo(), wireStyle: viewer === null ? null : targetWireStyle(viewer.graph) });
21772
+ }
21773
+
21774
+ // Wire styles as draw.io's Waypoints menu sets them (Menus.js, edgeStyleChange): the keys
21775
+ // each one writes, null removing a key
21776
+ var WIRE_STYLES = {
21777
+ straight: { edgeStyle: null, curved: null, noEdgeStyle: null, elbow: null },
21778
+ orthogonal: { edgeStyle: "orthogonalEdgeStyle", curved: null, noEdgeStyle: null, elbow: null },
21779
+ curved: { edgeStyle: "orthogonalEdgeStyle", curved: "1", noEdgeStyle: null, elbow: null }
21780
+ };
21781
+
21782
+ function wireStyleOf(graph, cell) {
21783
+ var style = graph.getCurrentCellStyle(cell);
21784
+ if (style.noEdgeStyle == 1 || style.edgeStyle == null || style.edgeStyle === "none") return "straight";
21785
+ return style.curved == 1 ? "curved" : "orthogonal";
21786
+ }
21787
+
21788
+ function pageWires(graph) {
21789
+ var model = graph.getModel();
21790
+ return Object.keys(model.cells).map(function (id) { return model.cells[id]; }).filter(function (cell) { return model.isEdge(cell); });
21791
+ }
21792
+
21793
+ // The wires a choice changes: the selected ones, else all of the page's
21794
+ function targetWires(graph) {
21795
+ var selected = graph.getSelectionCells().filter(function (cell) { return graph.getModel().isEdge(cell); });
21796
+ return selected.length > 0 ? selected : pageWires(graph);
21797
+ }
21798
+
21799
+ function targetWireStyle(graph) {
21800
+ var wires = targetWires(graph);
21801
+ if (wires.length === 0) return newWireStyle(graph);
21802
+ var first = wireStyleOf(graph, wires[0]);
21803
+ for (var i = 1; i < wires.length; i++) if (wireStyleOf(graph, wires[i]) !== first) return "mixed";
21804
+ return first;
21805
+ }
21806
+
21807
+ function newWireStyle(graph) {
21808
+ var current = graph.currentEdgeStyle || {};
21809
+ if (current.edgeStyle == null || current.edgeStyle === "none") return "straight";
21810
+ return current.curved == "1" ? "curved" : "orthogonal";
21811
+ }
21812
+
21813
+ // New wires take this style (Graph.createCurrentEdgeStyle reads currentEdgeStyle)
21814
+ function setNewWireStyle(graph, name) {
21815
+ var current = mxUtils.clone(graph.currentEdgeStyle || {});
21816
+ var keys = WIRE_STYLES[name];
21817
+ for (var key in keys) {
21818
+ if (keys[key] === null) delete current[key];
21819
+ else current[key] = keys[key];
21820
+ }
21821
+ graph.currentEdgeStyle = current;
21822
+ }
21823
+
21824
+ // One model update: one undo takes it back. Waypoints go, as draw.io resets them: laid out
21825
+ // for one style, they make no sense in another
21826
+ function applyWireStyle(name) {
21827
+ if (touch === null || viewer === null || !WIRE_STYLES[name]) return;
21828
+ var graph = viewer.graph;
21829
+ if (graph.isEditing()) graph.stopEditing(false);
21830
+ var wires = targetWires(graph);
21831
+ var model = graph.getModel();
21832
+ model.beginUpdate();
21833
+ try {
21834
+ for (var i = 0; i < wires.length; i++) {
21835
+ graph.resetEdge(wires[i]);
21836
+ var keys = WIRE_STYLES[name];
21837
+ for (var key in keys) graph.setCellStyles(key, keys[key], [wires[i]]);
21838
+ }
21839
+ } finally {
21840
+ model.endUpdate();
21841
+ }
21842
+ setNewWireStyle(graph, name);
21843
+ changed();
21770
21844
  }
21771
21845
 
21772
21846
  // The viewer holds back the editing core it bundles; this lets it go, for the page shown
@@ -21805,6 +21879,13 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
21805
21879
  if (height > container.offsetHeight) shown.updateContainerHeight(container, height);
21806
21880
  };
21807
21881
  graph.getModel().addListener(mxEvent.CHANGE, grow);
21882
+ // New wires start in the style most of the page's wires have: an agent's diagonal wires
21883
+ // get diagonal neighbours, not draw.io's orthogonal default
21884
+ var counts = { straight: 0, orthogonal: 0, curved: 0 };
21885
+ pageWires(graph).forEach(function (cell) { counts[wireStyleOf(graph, cell)] += 1; });
21886
+ var most = counts.orthogonal >= counts.straight && counts.orthogonal >= counts.curved ? "orthogonal" : counts.straight >= counts.curved ? "straight" : "curved";
21887
+ setNewWireStyle(graph, most);
21888
+ graph.getSelectionModel().addListener(mxEvent.CHANGE, changed);
21808
21889
  graph.addListener(mxEvent.EDITING_STARTED, changed);
21809
21890
  graph.addListener(mxEvent.EDITING_STOPPED, changed);
21810
21891
  // The keys are the graph's own, not the document's: mxKeyHandler only takes an event
@@ -21869,6 +21950,7 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
21869
21950
  viewer.graph.getModel().removeListener(current.record);
21870
21951
  viewer.graph.getModel().removeListener(current.grow);
21871
21952
  viewer.graph.removeListener(changed);
21953
+ viewer.graph.getSelectionModel().removeListener(changed);
21872
21954
  viewer.graph.getView().removeListener(current.record);
21873
21955
  }
21874
21956
  }
@@ -21933,7 +22015,7 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
21933
22015
  if (event.source !== parent) return;
21934
22016
  var data = event.data;
21935
22017
  if (!data) return;
21936
- if (data.type === M.RENDER && typeof data.xml === "string") render(data.xml, data.dark === true);
22018
+ if (data.type === M.RENDER && typeof data.xml === "string") render(data.xml, data.dark === true, data.page);
21937
22019
  else if (data.type === M.EDIT) {
21938
22020
  editing = data.on === true;
21939
22021
  if (editing) startTouchUp();
@@ -21947,6 +22029,7 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
21947
22029
  else if (data.type === M.UNDO) undoOrRedo(false);
21948
22030
  else if (data.type === M.REDO) undoOrRedo(true);
21949
22031
  else if (data.type === M.EXPORT_SVG) exportSvg();
22032
+ else if (data.type === M.WIRE_STYLE && typeof data.style === "string") applyWireStyle(data.style);
21950
22033
  });
21951
22034
 
21952
22035
  if (typeof GraphViewer === "undefined") {
@@ -21960,61 +22043,74 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
21960
22043
  }
21961
22044
  //#endregion
21962
22045
  //#region ../ui/src/components/DrawioFrame.tsx
21963
- var WT = "allow-scripts", GT = 1e4, KT = te(function({ xml: e, serverUrl: t, title: n, fallback: r, editing: i = !1, onTouchUpChange: a, onPageLocked: o, onEscape: s, onRendered: c, className: l = "flex h-full min-h-[24rem] flex-col" }, u) {
21964
- let d = T(null), f = ue() === "dark", p = se(() => UT(BT(t)), [t]), [m, h] = E(0), [g, _] = E(null), v = T(/* @__PURE__ */ new Map()), y = T({
22046
+ var WT = "allow-scripts", GT = 1e4, KT = te(function({ xml: e, serverUrl: t, title: n, fallback: r, editing: i = !1, onTouchUpChange: a, onPageLocked: o, onEscape: s, onRendered: c, className: l = "flex h-full min-h-[24rem] flex-col", page: u }, d) {
22047
+ let f = T(null), p = ue() === "dark", m = se(() => UT(BT(t)), [t]), [h, g] = E(0), [_, v] = E(null), y = T(/* @__PURE__ */ new Map()), b = T({
21965
22048
  onTouchUpChange: a,
21966
22049
  onPageLocked: o,
21967
22050
  onEscape: s,
21968
22051
  onRendered: c
21969
22052
  });
21970
- y.current = {
22053
+ b.current = {
21971
22054
  onTouchUpChange: a,
21972
22055
  onPageLocked: o,
21973
22056
  onEscape: s,
21974
22057
  onRendered: c
21975
22058
  };
21976
- let b = T(null), ee = T(i);
21977
- function x(e) {
21978
- d.current?.contentWindow?.postMessage(e, "*");
22059
+ let ee = T(null), x = T(i);
22060
+ function S(e) {
22061
+ f.current?.contentWindow?.postMessage(e, "*");
21979
22062
  }
21980
- function S(e, t) {
22063
+ function C(e, t) {
21981
22064
  return new Promise((n, r) => {
21982
- v.current.get(t)?.reject(/* @__PURE__ */ Error("superseded"));
22065
+ y.current.get(t)?.reject(/* @__PURE__ */ Error("superseded"));
21983
22066
  let i = setTimeout(() => {
21984
- v.current.delete(t), r(/* @__PURE__ */ Error("the diagram did not answer"));
22067
+ y.current.delete(t), r(/* @__PURE__ */ Error("the diagram did not answer"));
21985
22068
  }, GT);
21986
- v.current.set(t, {
22069
+ y.current.set(t, {
21987
22070
  resolve: ((e) => {
21988
22071
  clearTimeout(i), n(e);
21989
22072
  }),
21990
22073
  reject: (e) => {
21991
22074
  clearTimeout(i), r(e);
21992
22075
  }
21993
- }), x({ type: e });
22076
+ }), S({ type: e });
21994
22077
  });
21995
22078
  }
21996
- return ae(u, () => ({
21997
- save: () => S(zT.SAVE, zT.SAVED),
21998
- markClean: () => x({ type: zT.CLEAN }),
21999
- undo: () => x({ type: zT.UNDO }),
22000
- redo: () => x({ type: zT.REDO }),
22001
- exportSvg: () => S(zT.EXPORT_SVG, zT.SVG)
22079
+ return ae(d, () => ({
22080
+ save: () => C(zT.SAVE, zT.SAVED),
22081
+ markClean: () => S({ type: zT.CLEAN }),
22082
+ undo: () => S({ type: zT.UNDO }),
22083
+ redo: () => S({ type: zT.REDO }),
22084
+ setWireStyle: (e) => S({
22085
+ type: zT.WIRE_STYLE,
22086
+ style: e
22087
+ }),
22088
+ exportSvg: () => C(zT.EXPORT_SVG, zT.SVG)
22002
22089
  })), w(() => {
22003
- let e = v.current;
22090
+ let e = y.current;
22004
22091
  function t(t) {
22005
- if (d.current === null || t.source !== d.current.contentWindow) return;
22092
+ if (f.current === null || t.source !== f.current.contentWindow) return;
22006
22093
  let n = t.data;
22007
22094
  if (typeof n == "object" && n) {
22008
- if (n.type === zT.READY) b.current = null, ee.current = !1, h((e) => e + 1);
22009
- else if (n.type === zT.RENDERED) _(null), y.current.onRendered?.(null);
22095
+ if (n.type === zT.READY) ee.current = null, x.current = !1, g((e) => e + 1);
22096
+ else if (n.type === zT.RENDERED) v(null), b.current.onRendered?.(null);
22010
22097
  else if (n.type === zT.FAILED) {
22011
22098
  let e = typeof n.message == "string" ? n.message : "The diagram could not be drawn.";
22012
- _(e), y.current.onRendered?.(e);
22013
- } else n.type === zT.CHANGED ? y.current.onTouchUpChange?.({
22014
- dirty: n.dirty === !0,
22015
- canUndo: n.canUndo === !0,
22016
- canRedo: n.canRedo === !0
22017
- }) : n.type === zT.FOCUS ? d.current !== null && document.activeElement !== d.current && d.current.focus({ preventScroll: !0 }) : n.type === zT.ESCAPE ? y.current.onEscape?.() : n.type === zT.PAGE_LOCKED ? y.current.onPageLocked?.() : n.type === zT.SAVED && typeof n.xml == "string" && typeof n.page == "number" ? (e.get(zT.SAVED)?.resolve({
22099
+ v(e), b.current.onRendered?.(e);
22100
+ } else if (n.type === zT.CHANGED) {
22101
+ let e = [
22102
+ "straight",
22103
+ "orthogonal",
22104
+ "curved",
22105
+ "mixed"
22106
+ ].includes(n.wireStyle) ? n.wireStyle : void 0;
22107
+ b.current.onTouchUpChange?.({
22108
+ dirty: n.dirty === !0,
22109
+ canUndo: n.canUndo === !0,
22110
+ canRedo: n.canRedo === !0,
22111
+ ...e ? { wireStyle: e } : {}
22112
+ });
22113
+ } else n.type === zT.FOCUS ? f.current !== null && document.activeElement !== f.current && f.current.focus({ preventScroll: !0 }) : n.type === zT.ESCAPE ? b.current.onEscape?.() : n.type === zT.PAGE_LOCKED ? b.current.onPageLocked?.() : n.type === zT.SAVED && typeof n.xml == "string" && typeof n.page == "number" ? (e.get(zT.SAVED)?.resolve({
22018
22114
  page: n.page,
22019
22115
  xml: n.xml
22020
22116
  }), e.delete(zT.SAVED)) : n.type === zT.SVG && typeof n.svg == "string" && typeof n.page == "number" && (e.get(zT.SVG)?.resolve({
@@ -22030,56 +22126,58 @@ var WT = "allow-scripts", GT = 1e4, KT = te(function({ xml: e, serverUrl: t, tit
22030
22126
  e.clear();
22031
22127
  };
22032
22128
  }, []), w(() => {
22033
- m !== 0 && (i ? (!ee.current && (b.current === null || b.current.xml !== e || b.current.dark !== f) && (b.current = {
22129
+ h !== 0 && (i ? (!x.current && (ee.current === null || ee.current.xml !== e || ee.current.dark !== p) && (ee.current = {
22034
22130
  xml: e,
22035
- dark: f
22036
- }, x({
22131
+ dark: p
22132
+ }, S({
22037
22133
  type: zT.RENDER,
22038
22134
  xml: e,
22039
- dark: f
22040
- })), ee.current || x({
22135
+ dark: p,
22136
+ ...u === void 0 ? {} : { page: u }
22137
+ })), x.current || S({
22041
22138
  type: zT.EDIT,
22042
22139
  on: !0
22043
- }), ee.current = !0) : ee.current ? (ee.current = !1, b.current = {
22140
+ }), x.current = !0) : x.current ? (x.current = !1, ee.current = {
22044
22141
  xml: e,
22045
- dark: f
22046
- }, x({
22142
+ dark: p
22143
+ }, S({
22047
22144
  type: zT.EDIT,
22048
22145
  on: !1,
22049
22146
  xml: e,
22050
- dark: f
22051
- })) : (b.current === null || b.current.xml !== e || b.current.dark !== f) && (b.current = {
22147
+ dark: p
22148
+ })) : (ee.current === null || ee.current.xml !== e || ee.current.dark !== p) && (ee.current = {
22052
22149
  xml: e,
22053
- dark: f
22054
- }, x({
22150
+ dark: p
22151
+ }, S({
22055
22152
  type: zT.RENDER,
22056
22153
  xml: e,
22057
- dark: f
22154
+ dark: p,
22155
+ ...u === void 0 ? {} : { page: u }
22058
22156
  })));
22059
22157
  }, [
22060
- m,
22158
+ h,
22061
22159
  e,
22062
- f,
22160
+ p,
22063
22161
  i
22064
22162
  ]), /* @__PURE__ */ k("div", {
22065
22163
  className: l,
22066
22164
  "data-testid": "drawio-view",
22067
22165
  children: [
22068
- g !== null && /* @__PURE__ */ O("div", {
22166
+ _ !== null && /* @__PURE__ */ O("div", {
22069
22167
  role: "alert",
22070
22168
  "data-testid": "drawio-failure",
22071
22169
  className: "border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200",
22072
- children: g
22170
+ children: _
22073
22171
  }),
22074
22172
  /* @__PURE__ */ O("iframe", {
22075
- ref: d,
22173
+ ref: f,
22076
22174
  title: n,
22077
22175
  "data-testid": "drawio-frame",
22078
22176
  sandbox: WT,
22079
- srcDoc: p,
22080
- className: g === null ? "min-h-0 w-full flex-1 border-0" : "h-0 w-full border-0"
22177
+ srcDoc: m,
22178
+ className: _ === null ? "min-h-0 w-full flex-1 border-0" : "h-0 w-full border-0"
22081
22179
  }),
22082
- g !== null && /* @__PURE__ */ O("div", {
22180
+ _ !== null && /* @__PURE__ */ O("div", {
22083
22181
  className: "min-h-0 flex-1 overflow-auto",
22084
22182
  children: r
22085
22183
  })
@@ -22143,16 +22241,51 @@ function eE(e, t, n) {
22143
22241
  return e.slice(0, a.start) + c + r + s + r + o + "</diagram>" + e.slice(a.end);
22144
22242
  }
22145
22243
  //#endregion
22244
+ //#region ../ui/src/util/drawioPages.ts
22245
+ function tE(e) {
22246
+ let t = new DOMParser().parseFromString(e, "application/xml").documentElement;
22247
+ if (t.nodeName === "parsererror" || t.getElementsByTagName("parsererror").length > 0) throw Error("it is not a draw.io diagram (not XML)");
22248
+ if (t.nodeName !== "mxfile" && t.nodeName !== "mxGraphModel") throw Error(`it is not a draw.io diagram (its root is <${t.nodeName}>)`);
22249
+ return t;
22250
+ }
22251
+ function nE(e) {
22252
+ return [...e.children].filter((e) => e.nodeName === "diagram");
22253
+ }
22254
+ function rE(e) {
22255
+ let t = tE(e);
22256
+ if (t.nodeName === "mxGraphModel") return ["Page 1"];
22257
+ let n = nE(t);
22258
+ if (n.length === 0) throw Error("it holds no page");
22259
+ return n.map((e, t) => e.getAttribute("name")?.trim() || `Page ${t + 1}`);
22260
+ }
22261
+ function iE(e, t) {
22262
+ if (t === void 0 || t.trim() === "") return 0;
22263
+ let n = rE(e), r = t.trim(), i = n.indexOf(r), a = i >= 0 ? i : /^\d+$/.test(r) ? Number(r) - 1 : -1;
22264
+ if (a < 0 || a >= n.length) throw Error(`it has no page "${r}"; its pages are ${n.map((e) => `"${e}"`).join(", ")}`);
22265
+ return a;
22266
+ }
22267
+ function aE(e, t) {
22268
+ let n = tE(e), r = iE(e, t);
22269
+ if (n.nodeName === "mxGraphModel") return e;
22270
+ let i = n.cloneNode(!1);
22271
+ return i.appendChild(nE(n)[r].cloneNode(!0)), new XMLSerializer().serializeToString(i);
22272
+ }
22273
+ function oE(e, t) {
22274
+ let n = e.split("/").slice(0, -1), r = t.split("/"), i = 0;
22275
+ for (; i < n.length && i < r.length - 1 && n[i] === r[i];) i += 1;
22276
+ return [...n.slice(i).map(() => ".."), ...r.slice(i)].join("/");
22277
+ }
22278
+ //#endregion
22146
22279
  //#region ../ui/src/components/DrawioBlock.tsx
22147
- var tE = {
22280
+ var sE = {
22148
22281
  dirty: !1,
22149
22282
  canUndo: !1,
22150
22283
  canRedo: !1
22151
- }, nE = "Discard the unsaved touch-ups to this diagram?";
22152
- function rE(e) {
22284
+ }, cE = "Discard the unsaved touch-ups to this diagram?";
22285
+ function lE(e) {
22153
22286
  return e.slice(e.lastIndexOf("/") + 1).replace(/\.(drawio|dio)$/i, "") || "diagram";
22154
22287
  }
22155
- function iE(e, t, n) {
22288
+ function uE(e, t, n) {
22156
22289
  let r = URL.createObjectURL(new Blob([t], { type: n }));
22157
22290
  try {
22158
22291
  let t = document.createElement("a");
@@ -22161,11 +22294,11 @@ function iE(e, t, n) {
22161
22294
  URL.revokeObjectURL(r);
22162
22295
  }
22163
22296
  }
22164
- function aE(e, t) {
22297
+ function dE(e, t) {
22165
22298
  let n = t?.trim().replace(/[^\p{L}\p{N}._-]+/gu, "-").replace(/^-+|-+$/g, "");
22166
- return `${rE(e)}${n ? `-${n}` : ""}.svg`;
22299
+ return `${lE(e)}${n ? `-${n}` : ""}.svg`;
22167
22300
  }
22168
- function oE(e, t, n) {
22301
+ function fE(e, t, n) {
22169
22302
  let { fileIo: r } = JT(), [i, a] = E({ status: "loading" }), o = T(0), s = ne(() => {
22170
22303
  if (!t) return;
22171
22304
  if (r === void 0) {
@@ -22204,7 +22337,7 @@ function oE(e, t, n) {
22204
22337
  s
22205
22338
  ]), i;
22206
22339
  }
22207
- function sE(e, t) {
22340
+ function pE(e, t) {
22208
22341
  let [n, r] = E(!t || typeof IntersectionObserver > "u");
22209
22342
  return w(() => {
22210
22343
  if (n || e.current === null) return;
@@ -22214,168 +22347,232 @@ function sE(e, t) {
22214
22347
  return t.observe(e.current), () => t.disconnect();
22215
22348
  }, [n, e]), n;
22216
22349
  }
22217
- function cE({ path: e, xml: t, variant: n, fallback: r, onTouchUpDirtyChange: i }) {
22218
- let { serverUrl: a, fileIo: o, onOpenFile: s } = JT(), c = T(null), l = sE(c, n === "reply"), u = oE(e, t === void 0, l), d = t ?? (u.status === "loaded" ? u.content : null), f = T(null), p = T(null), [m, h] = E(!1), [g, _] = E(null), [v, y] = E(null), [b, ee] = E(null), x = T(null), [S, C] = E(tE), [te, re] = E(!1), ie = T(!1), [ae, oe] = E(null), [se, ce] = E(null), le = (e) => e === "inline" ? f : p, ue = (e) => b === e && x.current !== null ? x.current.content : d, de = o !== void 0, fe = b !== null && S.dirty;
22350
+ function mE({ path: e, xml: t, variant: n, fallback: r, onTouchUpDirtyChange: i, page: a, startTouchUp: o = !1, onEscape: s }) {
22351
+ let { serverUrl: c, fileIo: l, onOpenFile: u } = JT(), d = T(null), f = pE(d, n === "reply"), p = fE(e, t === void 0, f), m = t ?? (p.status === "loaded" ? p.content : null), h = T(null), g = T(null), [_, v] = E(!1), [y, b] = E(null), [ee, x] = E(null), [S, C] = E(null), te = T(null), [re, ie] = E(sE), [ae, oe] = E(!1), ce = T(!1), [le, ue] = E(null), [de, fe] = E(null), me = (e) => e === "inline" ? h : g, he = (e) => S === e && te.current !== null ? te.current.content : m, ge = l !== void 0, A = S !== null && re.dirty, _e = se(() => {
22352
+ if (a === void 0 || m === null) return {
22353
+ index: 0,
22354
+ problem: null
22355
+ };
22356
+ try {
22357
+ return {
22358
+ index: iE(m, a),
22359
+ problem: null
22360
+ };
22361
+ } catch (e) {
22362
+ return {
22363
+ index: 0,
22364
+ problem: e instanceof Error ? e.message : String(e)
22365
+ };
22366
+ }
22367
+ }, [a, m]), ve = T(!1);
22219
22368
  w(() => {
22220
- i?.(fe);
22221
- }, [fe, i]), w(() => () => i?.(!1), [i]);
22222
- async function me(t) {
22223
- if (o !== void 0 && b === null) {
22224
- oe(null), ce(null);
22369
+ o && !ve.current && m !== null && _e.problem === null && (ve.current = !0, be("inline"));
22370
+ });
22371
+ let ye = T(null);
22372
+ w(() => {
22373
+ S === null || re.dirty || te.current === null || m === null || m === te.current.content || (ye.current = S, te.current = null, ie(sE), C(null));
22374
+ }, [
22375
+ m,
22376
+ S,
22377
+ re.dirty
22378
+ ]), w(() => {
22379
+ if (S !== null || ye.current === null) return;
22380
+ let e = ye.current;
22381
+ ye.current = null, be(e);
22382
+ }), w(() => {
22383
+ i?.(A);
22384
+ }, [A, i]), w(() => () => i?.(!1), [i]);
22385
+ async function be(t) {
22386
+ if (l !== void 0 && S === null) {
22387
+ ue(null), fe(null);
22225
22388
  try {
22226
- x.current = await o.read(e), C(tE), ee(t);
22389
+ te.current = await l.read(e), ie(sE), C(t);
22227
22390
  } catch (e) {
22228
- oe({
22391
+ ue({
22229
22392
  message: e instanceof Error ? e.message : String(e),
22230
22393
  conflict: !1
22231
22394
  });
22232
22395
  }
22233
22396
  }
22234
22397
  }
22235
- function he() {
22236
- return fe && !window.confirm(nE) ? !1 : (ee(null), C(tE), oe(null), ce(null), x.current = null, !0);
22398
+ function xe() {
22399
+ return A && !window.confirm(cE) ? !1 : (C(null), ie(sE), ue(null), fe(null), te.current = null, !0);
22237
22400
  }
22238
- async function ge() {
22239
- let t = b, n = x.current;
22240
- if (!(t === null || n === null || o === void 0 || ie.current)) {
22241
- ie.current = !0, re(!0), oe(null);
22401
+ async function Se() {
22402
+ let t = S, n = te.current;
22403
+ if (!(t === null || n === null || l === void 0 || ce.current)) {
22404
+ ce.current = !0, oe(!0), ue(null);
22242
22405
  try {
22243
- let r = await le(t).current.save(), i = eE(n.content, r.page, r.xml), { mtimeMs: a } = await o.write(e, i, n.mtimeMs);
22244
- x.current = {
22406
+ let r = await me(t).current.save(), i = eE(n.content, r.page, r.xml), { mtimeMs: a } = await l.write(e, i, n.mtimeMs);
22407
+ te.current = {
22245
22408
  content: i,
22246
22409
  mtimeMs: a
22247
- }, le(t).current?.markClean();
22410
+ }, me(t).current?.markClean();
22248
22411
  } catch (e) {
22249
22412
  let t = e instanceof YT && e.reason === "conflict";
22250
- oe({
22413
+ ue({
22251
22414
  message: t ? "The file changed on disk, or was removed, since this touch-up began, so it was not saved. Leave without saving to see what is there now." : `Could not save: ${e instanceof Error ? e.message : String(e)}`,
22252
22415
  conflict: t
22253
22416
  });
22254
22417
  } finally {
22255
- ie.current = !1, re(!1);
22418
+ ce.current = !1, oe(!1);
22256
22419
  }
22257
22420
  }
22258
22421
  }
22259
- async function A(t) {
22260
- y(null);
22422
+ async function Te(t) {
22423
+ x(null);
22261
22424
  try {
22262
- let n = await le(t).current.exportSvg();
22263
- iE(aE(e, n.name), n.svg, "image/svg+xml;charset=utf-8");
22425
+ let n = await me(t).current.exportSvg();
22426
+ uE(dE(e, n.name), n.svg, "image/svg+xml;charset=utf-8");
22264
22427
  } catch (e) {
22265
- y(e instanceof Error ? e.message : String(e));
22266
- }
22267
- }
22268
- function _e() {
22269
- (b !== "enlarged" || he()) && h(!1);
22270
- }
22271
- let ve = ne(() => ce("Save or undo the touch-ups on this page before turning to another."), []), ye = T(he);
22272
- ye.current = he;
22273
- let be = T(_e);
22274
- be.current = _e;
22275
- let xe = T(b);
22276
- xe.current = b;
22277
- let Se = T(m);
22278
- Se.current = m;
22279
- let Te = ne(() => {
22280
- xe.current === null ? Se.current && be.current() : ye.current();
22428
+ x(e instanceof Error ? e.message : String(e));
22429
+ }
22430
+ }
22431
+ function Ee() {
22432
+ (S !== "enlarged" || xe()) && v(!1);
22433
+ }
22434
+ let De = ne(() => fe("Save or undo the touch-ups on this page before turning to another."), []), Oe = T(xe);
22435
+ Oe.current = xe;
22436
+ let ke = T(Ee);
22437
+ ke.current = Ee;
22438
+ let Ae = T(S);
22439
+ Ae.current = S;
22440
+ let je = T(_);
22441
+ je.current = _;
22442
+ let Me = T(s);
22443
+ Me.current = s;
22444
+ let Ne = ne(() => {
22445
+ Me.current ? Me.current() : Ae.current === null ? je.current && ke.current() : Oe.current();
22281
22446
  }, []);
22282
22447
  w(() => {
22283
- if (b === null) return;
22448
+ if (S === null) return;
22284
22449
  function e(e) {
22285
- e.key === "Escape" && (e.preventDefault(), e.stopImmediatePropagation(), ye.current());
22450
+ e.key === "Escape" && (e.preventDefault(), e.stopImmediatePropagation(), Me.current ? Me.current() : Oe.current());
22286
22451
  }
22287
22452
  return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
22288
- }, [b]);
22289
- function Ee(t) {
22453
+ }, [S]);
22454
+ function Pe(t) {
22290
22455
  return /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O("button", {
22291
22456
  type: "button",
22292
22457
  className: Ce,
22293
- disabled: d === null || g !== null,
22294
- onClick: () => void A(t),
22458
+ disabled: m === null || y !== null,
22459
+ onClick: () => void Te(t),
22295
22460
  title: "Save the page shown as .svg — insert it as a picture in a document",
22296
22461
  children: "⤓ download SVG"
22297
22462
  }), /* @__PURE__ */ O("button", {
22298
22463
  type: "button",
22299
22464
  className: Ce,
22300
- disabled: d === null,
22301
- onClick: () => d !== null && iE(e.slice(e.lastIndexOf("/") + 1), d, "application/xml;charset=utf-8"),
22465
+ disabled: m === null,
22466
+ onClick: () => m !== null && uE(e.slice(e.lastIndexOf("/") + 1), m, "application/xml;charset=utf-8"),
22302
22467
  title: "Save the .drawio file, to open or share it",
22303
22468
  children: "⤓ download .drawio"
22304
22469
  })] });
22305
22470
  }
22306
- function De(e) {
22307
- return b === e ? /* @__PURE__ */ k(D, { children: [
22471
+ function Fe(e) {
22472
+ return S === e ? /* @__PURE__ */ k(D, { children: [
22308
22473
  /* @__PURE__ */ O("button", {
22309
22474
  type: "button",
22310
22475
  className: Ce,
22311
- disabled: !S.dirty || te,
22312
- onClick: () => void ge(),
22313
- children: te ? "saving…" : "✓ save"
22476
+ disabled: !re.dirty || ae,
22477
+ onClick: () => void Se(),
22478
+ children: ae ? "saving…" : "✓ save"
22314
22479
  }),
22315
22480
  /* @__PURE__ */ O("button", {
22316
22481
  type: "button",
22317
22482
  className: Ce,
22318
- disabled: !S.canUndo,
22319
- onClick: () => le(e).current?.undo(),
22483
+ disabled: !re.canUndo,
22484
+ onClick: () => me(e).current?.undo(),
22320
22485
  title: "Undo (⌘Z / Ctrl+Z)",
22321
22486
  children: "↶ undo"
22322
22487
  }),
22323
22488
  /* @__PURE__ */ O("button", {
22324
22489
  type: "button",
22325
22490
  className: Ce,
22326
- disabled: !S.canRedo,
22327
- onClick: () => le(e).current?.redo(),
22491
+ disabled: !re.canRedo,
22492
+ onClick: () => me(e).current?.redo(),
22328
22493
  title: "Redo (⇧⌘Z / Ctrl+Y)",
22329
22494
  children: "↷ redo"
22330
22495
  }),
22496
+ /* @__PURE__ */ k("label", {
22497
+ className: "inline-flex items-center gap-1 text-xs text-zinc-500 dark:text-zinc-400",
22498
+ title: "How the selected wires are drawn — or every wire of the page when none is selected — and new wires too",
22499
+ children: ["wires", /* @__PURE__ */ k("select", {
22500
+ className: Ce,
22501
+ "aria-label": "Wire style",
22502
+ value: re.wireStyle ?? "orthogonal",
22503
+ onChange: (t) => {
22504
+ let n = t.target.value;
22505
+ n !== "mixed" && me(e).current?.setWireStyle(n);
22506
+ },
22507
+ children: [
22508
+ /* @__PURE__ */ O("option", {
22509
+ value: "straight",
22510
+ children: "straight"
22511
+ }),
22512
+ /* @__PURE__ */ O("option", {
22513
+ value: "orthogonal",
22514
+ children: "orthogonal"
22515
+ }),
22516
+ /* @__PURE__ */ O("option", {
22517
+ value: "curved",
22518
+ children: "curved"
22519
+ }),
22520
+ re.wireStyle === "mixed" && /* @__PURE__ */ O("option", {
22521
+ value: "mixed",
22522
+ disabled: !0,
22523
+ children: "mixed"
22524
+ })
22525
+ ]
22526
+ })]
22527
+ }),
22331
22528
  /* @__PURE__ */ O("button", {
22332
22529
  type: "button",
22333
22530
  className: Ce,
22334
- onClick: () => he(),
22531
+ onClick: () => xe(),
22335
22532
  title: "Leave touch-up (Escape); unsaved touch-ups are asked about first",
22336
22533
  children: "done"
22337
22534
  }),
22338
22535
  /* @__PURE__ */ O("span", {
22339
22536
  className: "text-xs text-zinc-400",
22340
22537
  "data-testid": "drawio-touchup-status",
22341
- children: S.dirty ? "● unsaved" : "touching up — drag boxes and wire ends, double-click a label"
22538
+ children: re.dirty ? "● unsaved" : "touching up — drag boxes and wire ends, double-click a label"
22342
22539
  })
22343
- ] }) : de && b === null && g === null ? /* @__PURE__ */ O("button", {
22540
+ ] }) : ge && S === null && y === null ? /* @__PURE__ */ O("button", {
22344
22541
  type: "button",
22345
22542
  className: Ce,
22346
- disabled: d === null,
22347
- onClick: () => void me(e),
22543
+ disabled: m === null,
22544
+ onClick: () => void be(e),
22348
22545
  title: "Move boxes, re-attach wires and fix labels here; anything more in draw.io",
22349
22546
  children: "✎ touch up"
22350
22547
  }) : null;
22351
22548
  }
22352
- function Oe(e) {
22549
+ function Ie(e) {
22353
22550
  return /* @__PURE__ */ k(D, { children: [
22354
- b === e && ae && /* @__PURE__ */ O("span", {
22551
+ S === e && le && /* @__PURE__ */ O("span", {
22355
22552
  role: "alert",
22356
22553
  "data-testid": "drawio-touchup-problem",
22357
22554
  className: "text-red-600 dark:text-red-400",
22358
- children: ae.message
22555
+ children: le.message
22359
22556
  }),
22360
- b === e && se && /* @__PURE__ */ O("span", {
22557
+ S === e && de && /* @__PURE__ */ O("span", {
22361
22558
  role: "status",
22362
22559
  className: "text-amber-700 dark:text-amber-300",
22363
- children: se
22560
+ children: de
22364
22561
  }),
22365
- b === null && ae && /* @__PURE__ */ k("span", {
22562
+ S === null && le && /* @__PURE__ */ k("span", {
22366
22563
  role: "alert",
22367
22564
  className: "text-red-600 dark:text-red-400",
22368
- children: ["Could not start touch-up: ", ae.message]
22565
+ children: ["Could not start touch-up: ", le.message]
22369
22566
  }),
22370
- v && /* @__PURE__ */ k("span", {
22567
+ ee && /* @__PURE__ */ k("span", {
22371
22568
  role: "alert",
22372
22569
  className: "text-red-600 dark:text-red-400",
22373
- children: ["Could not download SVG: ", v]
22570
+ children: ["Could not download SVG: ", ee]
22374
22571
  })
22375
22572
  ] });
22376
22573
  }
22377
- if (n === "reply" && u.status === "failed") return /* @__PURE__ */ k("div", {
22378
- ref: c,
22574
+ if (n === "reply" && p.status === "failed") return /* @__PURE__ */ k("div", {
22575
+ ref: d,
22379
22576
  role: "alert",
22380
22577
  "data-testid": "drawio-block-missing",
22381
22578
  className: "my-2 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200",
@@ -22383,89 +22580,102 @@ function cE({ path: e, xml: t, variant: n, fallback: r, onTouchUpDirtyChange: i
22383
22580
  "The diagram ",
22384
22581
  /* @__PURE__ */ O("code", { children: e }),
22385
22582
  " could not be shown: ",
22386
- u.message
22583
+ p.message
22387
22584
  ]
22388
22585
  });
22389
- let ke = r ?? /* @__PURE__ */ k("p", {
22586
+ let Le = r ?? /* @__PURE__ */ k("p", {
22390
22587
  className: "px-3 py-2 text-xs text-zinc-500",
22391
22588
  children: [
22392
22589
  "The diagram ",
22393
22590
  /* @__PURE__ */ O("code", { children: e }),
22394
22591
  " could not be drawn."
22395
22592
  ]
22396
- }), Ae = /* @__PURE__ */ k("div", {
22593
+ }), Re = /* @__PURE__ */ k("div", {
22397
22594
  className: `${we} ${n === "reply" ? "order-3" : "shrink-0 px-3 py-1.5"}`,
22398
22595
  children: [
22399
- b !== "inline" && /* @__PURE__ */ O("button", {
22596
+ S !== "inline" && /* @__PURE__ */ O("button", {
22400
22597
  type: "button",
22401
22598
  className: "text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50",
22402
- disabled: d === null || b !== null,
22403
- onClick: () => h(!0),
22599
+ disabled: m === null || S !== null,
22600
+ onClick: () => v(!0),
22404
22601
  "aria-label": "Show diagram at full size",
22405
22602
  children: "⤢ enlarge"
22406
22603
  }),
22407
- b !== "inline" && Ee("inline"),
22408
- n === "reply" && s && /* @__PURE__ */ O("button", {
22604
+ S !== "inline" && Pe("inline"),
22605
+ n === "reply" && u && /* @__PURE__ */ O("button", {
22409
22606
  type: "button",
22410
22607
  className: "text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50",
22411
- onClick: () => s(e),
22608
+ onClick: () => u(e),
22412
22609
  title: "Open the file in the file viewer",
22413
22610
  children: "↗ open"
22414
22611
  }),
22415
- n === "viewer" && De("inline"),
22416
- Oe("inline")
22612
+ n === "viewer" && Fe("inline"),
22613
+ Ie("inline")
22417
22614
  ]
22418
22615
  });
22419
22616
  return /* @__PURE__ */ k("div", {
22420
- ref: c,
22617
+ ref: d,
22421
22618
  "data-testid": n === "reply" ? "drawio-block-reply" : "drawio-block-viewer",
22422
22619
  className: n === "reply" ? "my-2 flex flex-col gap-2 rounded-lg border border-zinc-200 bg-zinc-50 p-3 dark:border-zinc-800 dark:bg-zinc-900" : "flex h-full flex-col",
22423
22620
  children: [
22424
- n === "viewer" && Ae,
22425
- d === null || !l ? /* @__PURE__ */ O("div", {
22621
+ n === "viewer" && Re,
22622
+ _e.problem !== null && /* @__PURE__ */ k("p", {
22623
+ role: "alert",
22624
+ "data-testid": "drawio-block-page-problem",
22625
+ className: "px-3 py-1.5 text-xs text-amber-800 dark:text-amber-200",
22626
+ children: [
22627
+ "The diagram ",
22628
+ /* @__PURE__ */ O("code", { children: e }),
22629
+ " ",
22630
+ _e.problem,
22631
+ "; its first page is shown."
22632
+ ]
22633
+ }),
22634
+ m === null || !f ? /* @__PURE__ */ O("div", {
22426
22635
  className: "h-80 animate-pulse rounded bg-zinc-100 dark:bg-zinc-800/60",
22427
22636
  "data-testid": "drawio-block-loading",
22428
22637
  "aria-label": `Loading ${e}`
22429
22638
  }) : /* @__PURE__ */ O(KT, {
22430
- ref: f,
22431
- xml: ue("inline"),
22432
- serverUrl: a,
22639
+ ref: h,
22640
+ xml: he("inline"),
22641
+ serverUrl: c,
22433
22642
  title: e,
22434
- fallback: ke,
22435
- editing: b === "inline",
22436
- onTouchUpChange: C,
22437
- onPageLocked: ve,
22438
- onEscape: Te,
22439
- onRendered: _,
22440
- className: n === "reply" ? "flex h-80 flex-col" : "flex min-h-[24rem] flex-1 flex-col"
22643
+ fallback: Le,
22644
+ editing: S === "inline",
22645
+ onTouchUpChange: ie,
22646
+ onPageLocked: De,
22647
+ onEscape: Ne,
22648
+ onRendered: b,
22649
+ className: n === "reply" ? "flex h-80 flex-col" : "flex min-h-[24rem] flex-1 flex-col",
22650
+ page: a === void 0 ? void 0 : _e.index
22441
22651
  }),
22442
- n === "reply" && Ae,
22652
+ n === "reply" && Re,
22443
22653
  /* @__PURE__ */ O(pe, {
22444
22654
  label: e,
22445
22655
  testId: "drawio-enlarged",
22446
- open: m,
22447
- onClose: _e,
22448
- anchorRef: c,
22656
+ open: _,
22657
+ onClose: Ee,
22658
+ anchorRef: d,
22449
22659
  actions: /* @__PURE__ */ k(D, { children: [
22450
- Ee("enlarged"),
22451
- De("enlarged"),
22452
- Oe("enlarged")
22660
+ Pe("enlarged"),
22661
+ Fe("enlarged"),
22662
+ Ie("enlarged")
22453
22663
  ] }),
22454
- children: d !== null && /* @__PURE__ */ O("div", {
22664
+ children: m !== null && /* @__PURE__ */ O("div", {
22455
22665
  style: {
22456
22666
  width: "90vw",
22457
22667
  height: "75vh"
22458
22668
  },
22459
22669
  children: /* @__PURE__ */ O(KT, {
22460
- ref: p,
22461
- xml: ue("enlarged"),
22462
- serverUrl: a,
22670
+ ref: g,
22671
+ xml: he("enlarged"),
22672
+ serverUrl: c,
22463
22673
  title: `${e}, full size`,
22464
- fallback: ke,
22465
- editing: b === "enlarged",
22466
- onTouchUpChange: C,
22467
- onPageLocked: ve,
22468
- onEscape: Te,
22674
+ fallback: Le,
22675
+ editing: S === "enlarged",
22676
+ onTouchUpChange: ie,
22677
+ onPageLocked: De,
22678
+ onEscape: Ne,
22469
22679
  className: "flex h-full flex-col"
22470
22680
  })
22471
22681
  })
@@ -22475,28 +22685,28 @@ function cE({ path: e, xml: t, variant: n, fallback: r, onTouchUpDirtyChange: i
22475
22685
  }
22476
22686
  //#endregion
22477
22687
  //#region ../ui/src/components/AssistantMessage.tsx
22478
- function lE(e) {
22688
+ function hE(e) {
22479
22689
  return e === "className" || Array.isArray(e) && e[0] === "className";
22480
22690
  }
22481
- function uE(e) {
22691
+ function gE(e) {
22482
22692
  let t = {};
22483
- for (let [n, r] of Object.entries(e)) t[n] = r.filter((e) => !lE(e));
22693
+ for (let [n, r] of Object.entries(e)) t[n] = r.filter((e) => !hE(e));
22484
22694
  return t["*"] = [...t["*"] ?? [], "className"], t;
22485
22695
  }
22486
- var dE = {
22696
+ var _E = {
22487
22697
  ...xT,
22488
22698
  tagNames: [.../* @__PURE__ */ new Set([
22489
22699
  ...xT.tagNames ?? [],
22490
22700
  "details",
22491
22701
  "summary"
22492
22702
  ])],
22493
- attributes: uE(xT.attributes ?? {})
22494
- }, fE = [
22703
+ attributes: gE(xT.attributes ?? {})
22704
+ }, vE = [
22495
22705
  yT,
22496
- [RT, dE],
22706
+ [RT, _E],
22497
22707
  Mb
22498
- ], pE = [d, m];
22499
- function mE(e) {
22708
+ ], yE = [d, m];
22709
+ function bE(e) {
22500
22710
  let t = g("", e);
22501
22711
  try {
22502
22712
  return decodeURIComponent(t);
@@ -22504,10 +22714,10 @@ function mE(e) {
22504
22714
  return t;
22505
22715
  }
22506
22716
  }
22507
- function hE(e) {
22717
+ function xE(e) {
22508
22718
  return typeof e == "string" && e !== "" && !y(e) && _(e.split(/[?#]/)[0]);
22509
22719
  }
22510
- function gE({ text: e }) {
22720
+ function SE({ text: e }) {
22511
22721
  let [t, n] = E(!1);
22512
22722
  return /* @__PURE__ */ k("div", {
22513
22723
  className: "my-1 rounded-lg border border-zinc-200 bg-zinc-50 text-sm dark:border-zinc-800/80 dark:bg-zinc-900/40",
@@ -22528,13 +22738,13 @@ function gE({ text: e }) {
22528
22738
  })]
22529
22739
  });
22530
22740
  }
22531
- function _E({ item: e, serverUrl: t = "", token: n = null, workspace: r, onOpenFile: i, hideReasoning: a = !1 }) {
22741
+ function CE({ item: e, serverUrl: t = "", token: n = null, workspace: r, onOpenFile: i, hideReasoning: a = !1 }) {
22532
22742
  let o = a ? e.blocks.filter((e) => e.type !== "thinking") : e.blocks, c = e.blocks.filter((e) => e.type === "text").map((e) => e.text).join("\n\n").trim(), l = T(i);
22533
22743
  l.current = i;
22534
22744
  let u = se(() => {
22535
22745
  function e({ src: e, alt: i, ...a }) {
22536
- if (hE(e)) return /* @__PURE__ */ O(cE, {
22537
- path: mE(e),
22746
+ if (xE(e)) return /* @__PURE__ */ O(mE, {
22747
+ path: bE(e),
22538
22748
  variant: "reply"
22539
22749
  });
22540
22750
  let o = typeof e == "string" && e !== "" && !y(e) ? v(t, g("", e), n, void 0, r) : e;
@@ -22568,7 +22778,7 @@ function _E({ item: e, serverUrl: t = "", token: n = null, workspace: r, onOpenF
22568
22778
  }
22569
22779
  function a({ node: e, children: t, ...n }) {
22570
22780
  let r = (e?.children ?? []).filter((e) => e.type !== "text" || (e.value ?? "").trim() !== "");
22571
- return r.length > 0 && r.every((e) => e.type === "element" && e.tagName === "img" && hE(e.properties?.src)) ? /* @__PURE__ */ O("div", {
22781
+ return r.length > 0 && r.every((e) => e.type === "element" && e.tagName === "img" && xE(e.properties?.src)) ? /* @__PURE__ */ O("div", {
22572
22782
  className: "my-2",
22573
22783
  children: t
22574
22784
  }) : /* @__PURE__ */ O("p", {
@@ -22594,11 +22804,11 @@ function _E({ item: e, serverUrl: t = "", token: n = null, workspace: r, onOpenF
22594
22804
  className: "flex justify-end opacity-0 transition-opacity group-hover:opacity-100",
22595
22805
  children: /* @__PURE__ */ O(de, { text: c })
22596
22806
  }),
22597
- o.map((e, t) => e.type === "thinking" ? /* @__PURE__ */ O(gE, { text: e.text }, e.contentIndex ?? t) : /* @__PURE__ */ O("div", {
22807
+ o.map((e, t) => e.type === "thinking" ? /* @__PURE__ */ O(SE, { text: e.text }, e.contentIndex ?? t) : /* @__PURE__ */ O("div", {
22598
22808
  className: "prose-chat",
22599
22809
  children: /* @__PURE__ */ O(lh, {
22600
- remarkPlugins: pE,
22601
- rehypePlugins: fE,
22810
+ remarkPlugins: yE,
22811
+ rehypePlugins: vE,
22602
22812
  components: u,
22603
22813
  children: s(e.text)
22604
22814
  })
@@ -22612,20 +22822,20 @@ function _E({ item: e, serverUrl: t = "", token: n = null, workspace: r, onOpenF
22612
22822
  }
22613
22823
  //#endregion
22614
22824
  //#region ../shared/src/protocol.ts
22615
- var vE = [
22825
+ var wE = [
22616
22826
  "off",
22617
22827
  "minimal",
22618
22828
  "low",
22619
22829
  "medium",
22620
22830
  "high",
22621
22831
  "xhigh"
22622
- ], yE = "worktree", bE = class extends Error {
22832
+ ], TE = "worktree", EE = class extends Error {
22623
22833
  kind;
22624
22834
  constructor(e, t) {
22625
22835
  super(e), this.name = "HistoryError", this.kind = t;
22626
22836
  }
22627
22837
  };
22628
- async function xE(e, t) {
22838
+ async function DE(e, t) {
22629
22839
  let n = [];
22630
22840
  for (;;) {
22631
22841
  let r = await e(n.length, 50);
@@ -22633,4 +22843,4 @@ async function xE(e, t) {
22633
22843
  }
22634
22844
  }
22635
22845
  //#endregion
22636
- export { Zl as A, Mf as C, _f as D, bf as E, de as M, le as N, yf as O, ue as P, cp as S, xf as T, lh as _, _E as a, dp as b, YT as c, KT as d, RT as f, Mb as g, Pb as h, yE as i, Ae as j, Jd as k, qT as l, Jb as m, xE as n, dE as o, yT as p, vE as r, cE as s, bE as t, JT as u, ih as v, Ef as w, fp as x, mp as y };
22846
+ export { _f as A, dp as C, Ef as D, Mf as E, Ce as F, fe as I, de as L, Jd as M, Zl as N, xf as O, Ae as P, le as R, mp as S, cp as T, Jb as _, CE as a, lh as b, aE as c, YT as d, qT as f, yT as g, RT as h, TE as i, yf as j, bf as k, rE as l, KT as m, DE as n, _E as o, JT as p, wE as r, mE as s, EE as t, oE as u, Pb as v, fp as w, ih as x, Mb as y, ue as z };