@pi-outpost/embed 0.52.0 → 0.54.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.
@@ -21698,7 +21698,8 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
21698
21698
  return root.getElementsByTagName("diagram").length;
21699
21699
  }
21700
21700
 
21701
- 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) {
21702
21703
  last = { xml: xml, dark: dark };
21703
21704
  stopTouchUp();
21704
21705
  document.body.className = dark ? "dark" : "";
@@ -21719,7 +21720,7 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
21719
21720
  tell({ type: M.FAILED, message: "This is not a draw.io diagram: its root is <" + doc.documentElement.nodeName + ">, not <mxfile> or <mxGraphModel>." });
21720
21721
  return;
21721
21722
  }
21722
- 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);
21723
21724
  var container = document.createElement("div");
21724
21725
  container.id = "diagram";
21725
21726
  document.body.appendChild(container);
@@ -22014,7 +22015,7 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
22014
22015
  if (event.source !== parent) return;
22015
22016
  var data = event.data;
22016
22017
  if (!data) return;
22017
- 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);
22018
22019
  else if (data.type === M.EDIT) {
22019
22020
  editing = data.on === true;
22020
22021
  if (editing) startTouchUp();
@@ -22042,60 +22043,60 @@ div.mxRubberband { position: absolute; overflow: hidden; border: 1px solid #29b6
22042
22043
  }
22043
22044
  //#endregion
22044
22045
  //#region ../ui/src/components/DrawioFrame.tsx
22045
- 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) {
22046
- 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({
22047
22048
  onTouchUpChange: a,
22048
22049
  onPageLocked: o,
22049
22050
  onEscape: s,
22050
22051
  onRendered: c
22051
22052
  });
22052
- y.current = {
22053
+ b.current = {
22053
22054
  onTouchUpChange: a,
22054
22055
  onPageLocked: o,
22055
22056
  onEscape: s,
22056
22057
  onRendered: c
22057
22058
  };
22058
- let b = T(null), ee = T(i);
22059
- function x(e) {
22060
- d.current?.contentWindow?.postMessage(e, "*");
22059
+ let ee = T(null), x = T(i);
22060
+ function S(e) {
22061
+ f.current?.contentWindow?.postMessage(e, "*");
22061
22062
  }
22062
- function S(e, t) {
22063
+ function C(e, t) {
22063
22064
  return new Promise((n, r) => {
22064
- v.current.get(t)?.reject(/* @__PURE__ */ Error("superseded"));
22065
+ y.current.get(t)?.reject(/* @__PURE__ */ Error("superseded"));
22065
22066
  let i = setTimeout(() => {
22066
- 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"));
22067
22068
  }, GT);
22068
- v.current.set(t, {
22069
+ y.current.set(t, {
22069
22070
  resolve: ((e) => {
22070
22071
  clearTimeout(i), n(e);
22071
22072
  }),
22072
22073
  reject: (e) => {
22073
22074
  clearTimeout(i), r(e);
22074
22075
  }
22075
- }), x({ type: e });
22076
+ }), S({ type: e });
22076
22077
  });
22077
22078
  }
22078
- return ae(u, () => ({
22079
- save: () => S(zT.SAVE, zT.SAVED),
22080
- markClean: () => x({ type: zT.CLEAN }),
22081
- undo: () => x({ type: zT.UNDO }),
22082
- redo: () => x({ type: zT.REDO }),
22083
- setWireStyle: (e) => x({
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({
22084
22085
  type: zT.WIRE_STYLE,
22085
22086
  style: e
22086
22087
  }),
22087
- exportSvg: () => S(zT.EXPORT_SVG, zT.SVG)
22088
+ exportSvg: () => C(zT.EXPORT_SVG, zT.SVG)
22088
22089
  })), w(() => {
22089
- let e = v.current;
22090
+ let e = y.current;
22090
22091
  function t(t) {
22091
- if (d.current === null || t.source !== d.current.contentWindow) return;
22092
+ if (f.current === null || t.source !== f.current.contentWindow) return;
22092
22093
  let n = t.data;
22093
22094
  if (typeof n == "object" && n) {
22094
- if (n.type === zT.READY) b.current = null, ee.current = !1, h((e) => e + 1);
22095
- 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);
22096
22097
  else if (n.type === zT.FAILED) {
22097
22098
  let e = typeof n.message == "string" ? n.message : "The diagram could not be drawn.";
22098
- _(e), y.current.onRendered?.(e);
22099
+ v(e), b.current.onRendered?.(e);
22099
22100
  } else if (n.type === zT.CHANGED) {
22100
22101
  let e = [
22101
22102
  "straight",
@@ -22103,13 +22104,13 @@ var WT = "allow-scripts", GT = 1e4, KT = te(function({ xml: e, serverUrl: t, tit
22103
22104
  "curved",
22104
22105
  "mixed"
22105
22106
  ].includes(n.wireStyle) ? n.wireStyle : void 0;
22106
- y.current.onTouchUpChange?.({
22107
+ b.current.onTouchUpChange?.({
22107
22108
  dirty: n.dirty === !0,
22108
22109
  canUndo: n.canUndo === !0,
22109
22110
  canRedo: n.canRedo === !0,
22110
22111
  ...e ? { wireStyle: e } : {}
22111
22112
  });
22112
- } else 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({
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({
22113
22114
  page: n.page,
22114
22115
  xml: n.xml
22115
22116
  }), e.delete(zT.SAVED)) : n.type === zT.SVG && typeof n.svg == "string" && typeof n.page == "number" && (e.get(zT.SVG)?.resolve({
@@ -22125,56 +22126,58 @@ var WT = "allow-scripts", GT = 1e4, KT = te(function({ xml: e, serverUrl: t, tit
22125
22126
  e.clear();
22126
22127
  };
22127
22128
  }, []), w(() => {
22128
- 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 = {
22129
22130
  xml: e,
22130
- dark: f
22131
- }, x({
22131
+ dark: p
22132
+ }, S({
22132
22133
  type: zT.RENDER,
22133
22134
  xml: e,
22134
- dark: f
22135
- })), ee.current || x({
22135
+ dark: p,
22136
+ ...u === void 0 ? {} : { page: u }
22137
+ })), x.current || S({
22136
22138
  type: zT.EDIT,
22137
22139
  on: !0
22138
- }), ee.current = !0) : ee.current ? (ee.current = !1, b.current = {
22140
+ }), x.current = !0) : x.current ? (x.current = !1, ee.current = {
22139
22141
  xml: e,
22140
- dark: f
22141
- }, x({
22142
+ dark: p
22143
+ }, S({
22142
22144
  type: zT.EDIT,
22143
22145
  on: !1,
22144
22146
  xml: e,
22145
- dark: f
22146
- })) : (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 = {
22147
22149
  xml: e,
22148
- dark: f
22149
- }, x({
22150
+ dark: p
22151
+ }, S({
22150
22152
  type: zT.RENDER,
22151
22153
  xml: e,
22152
- dark: f
22154
+ dark: p,
22155
+ ...u === void 0 ? {} : { page: u }
22153
22156
  })));
22154
22157
  }, [
22155
- m,
22158
+ h,
22156
22159
  e,
22157
- f,
22160
+ p,
22158
22161
  i
22159
22162
  ]), /* @__PURE__ */ k("div", {
22160
22163
  className: l,
22161
22164
  "data-testid": "drawio-view",
22162
22165
  children: [
22163
- g !== null && /* @__PURE__ */ O("div", {
22166
+ _ !== null && /* @__PURE__ */ O("div", {
22164
22167
  role: "alert",
22165
22168
  "data-testid": "drawio-failure",
22166
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",
22167
- children: g
22170
+ children: _
22168
22171
  }),
22169
22172
  /* @__PURE__ */ O("iframe", {
22170
- ref: d,
22173
+ ref: f,
22171
22174
  title: n,
22172
22175
  "data-testid": "drawio-frame",
22173
22176
  sandbox: WT,
22174
- srcDoc: p,
22175
- 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"
22176
22179
  }),
22177
- g !== null && /* @__PURE__ */ O("div", {
22180
+ _ !== null && /* @__PURE__ */ O("div", {
22178
22181
  className: "min-h-0 flex-1 overflow-auto",
22179
22182
  children: r
22180
22183
  })
@@ -22238,16 +22241,51 @@ function eE(e, t, n) {
22238
22241
  return e.slice(0, a.start) + c + r + s + r + o + "</diagram>" + e.slice(a.end);
22239
22242
  }
22240
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
22241
22279
  //#region ../ui/src/components/DrawioBlock.tsx
22242
- var tE = {
22280
+ var sE = {
22243
22281
  dirty: !1,
22244
22282
  canUndo: !1,
22245
22283
  canRedo: !1
22246
- }, nE = "Discard the unsaved touch-ups to this diagram?";
22247
- function rE(e) {
22284
+ }, cE = "Discard the unsaved touch-ups to this diagram?";
22285
+ function lE(e) {
22248
22286
  return e.slice(e.lastIndexOf("/") + 1).replace(/\.(drawio|dio)$/i, "") || "diagram";
22249
22287
  }
22250
- function iE(e, t, n) {
22288
+ function uE(e, t, n) {
22251
22289
  let r = URL.createObjectURL(new Blob([t], { type: n }));
22252
22290
  try {
22253
22291
  let t = document.createElement("a");
@@ -22256,11 +22294,11 @@ function iE(e, t, n) {
22256
22294
  URL.revokeObjectURL(r);
22257
22295
  }
22258
22296
  }
22259
- function aE(e, t) {
22297
+ function dE(e, t) {
22260
22298
  let n = t?.trim().replace(/[^\p{L}\p{N}._-]+/gu, "-").replace(/^-+|-+$/g, "");
22261
- return `${rE(e)}${n ? `-${n}` : ""}.svg`;
22299
+ return `${lE(e)}${n ? `-${n}` : ""}.svg`;
22262
22300
  }
22263
- function oE(e, t, n) {
22301
+ function fE(e, t, n) {
22264
22302
  let { fileIo: r } = JT(), [i, a] = E({ status: "loading" }), o = T(0), s = ne(() => {
22265
22303
  if (!t) return;
22266
22304
  if (r === void 0) {
@@ -22299,7 +22337,7 @@ function oE(e, t, n) {
22299
22337
  s
22300
22338
  ]), i;
22301
22339
  }
22302
- function sE(e, t) {
22340
+ function pE(e, t) {
22303
22341
  let [n, r] = E(!t || typeof IntersectionObserver > "u");
22304
22342
  return w(() => {
22305
22343
  if (n || e.current === null) return;
@@ -22309,117 +22347,149 @@ function sE(e, t) {
22309
22347
  return t.observe(e.current), () => t.disconnect();
22310
22348
  }, [n, e]), n;
22311
22349
  }
22312
- function cE({ path: e, xml: t, variant: n, fallback: r, onTouchUpDirtyChange: i }) {
22313
- 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);
22314
22368
  w(() => {
22315
- i?.(fe);
22316
- }, [fe, i]), w(() => () => i?.(!1), [i]);
22317
- async function me(t) {
22318
- if (o !== void 0 && b === null) {
22319
- 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);
22320
22388
  try {
22321
- x.current = await o.read(e), C(tE), ee(t);
22389
+ te.current = await l.read(e), ie(sE), C(t);
22322
22390
  } catch (e) {
22323
- oe({
22391
+ ue({
22324
22392
  message: e instanceof Error ? e.message : String(e),
22325
22393
  conflict: !1
22326
22394
  });
22327
22395
  }
22328
22396
  }
22329
22397
  }
22330
- function he() {
22331
- 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);
22332
22400
  }
22333
- async function ge() {
22334
- let t = b, n = x.current;
22335
- if (!(t === null || n === null || o === void 0 || ie.current)) {
22336
- 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);
22337
22405
  try {
22338
- let r = await le(t).current.save(), i = eE(n.content, r.page, r.xml), { mtimeMs: a } = await o.write(e, i, n.mtimeMs);
22339
- 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 = {
22340
22408
  content: i,
22341
22409
  mtimeMs: a
22342
- }, le(t).current?.markClean();
22410
+ }, me(t).current?.markClean();
22343
22411
  } catch (e) {
22344
22412
  let t = e instanceof YT && e.reason === "conflict";
22345
- oe({
22413
+ ue({
22346
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)}`,
22347
22415
  conflict: t
22348
22416
  });
22349
22417
  } finally {
22350
- ie.current = !1, re(!1);
22418
+ ce.current = !1, oe(!1);
22351
22419
  }
22352
22420
  }
22353
22421
  }
22354
- async function A(t) {
22355
- y(null);
22422
+ async function Te(t) {
22423
+ x(null);
22356
22424
  try {
22357
- let n = await le(t).current.exportSvg();
22358
- 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");
22359
22427
  } catch (e) {
22360
- y(e instanceof Error ? e.message : String(e));
22361
- }
22362
- }
22363
- function _e() {
22364
- (b !== "enlarged" || he()) && h(!1);
22365
- }
22366
- let ve = ne(() => ce("Save or undo the touch-ups on this page before turning to another."), []), ye = T(he);
22367
- ye.current = he;
22368
- let be = T(_e);
22369
- be.current = _e;
22370
- let xe = T(b);
22371
- xe.current = b;
22372
- let Se = T(m);
22373
- Se.current = m;
22374
- let Te = ne(() => {
22375
- 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();
22376
22446
  }, []);
22377
22447
  w(() => {
22378
- if (b === null) return;
22448
+ if (S === null) return;
22379
22449
  function e(e) {
22380
- e.key === "Escape" && (e.preventDefault(), e.stopImmediatePropagation(), ye.current());
22450
+ e.key === "Escape" && (e.preventDefault(), e.stopImmediatePropagation(), Me.current ? Me.current() : Oe.current());
22381
22451
  }
22382
22452
  return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
22383
- }, [b]);
22384
- function Ee(t) {
22453
+ }, [S]);
22454
+ function Pe(t) {
22385
22455
  return /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O("button", {
22386
22456
  type: "button",
22387
22457
  className: Ce,
22388
- disabled: d === null || g !== null,
22389
- onClick: () => void A(t),
22458
+ disabled: m === null || y !== null,
22459
+ onClick: () => void Te(t),
22390
22460
  title: "Save the page shown as .svg — insert it as a picture in a document",
22391
22461
  children: "⤓ download SVG"
22392
22462
  }), /* @__PURE__ */ O("button", {
22393
22463
  type: "button",
22394
22464
  className: Ce,
22395
- disabled: d === null,
22396
- 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"),
22397
22467
  title: "Save the .drawio file, to open or share it",
22398
22468
  children: "⤓ download .drawio"
22399
22469
  })] });
22400
22470
  }
22401
- function De(e) {
22402
- return b === e ? /* @__PURE__ */ k(D, { children: [
22471
+ function Fe(e) {
22472
+ return S === e ? /* @__PURE__ */ k(D, { children: [
22403
22473
  /* @__PURE__ */ O("button", {
22404
22474
  type: "button",
22405
22475
  className: Ce,
22406
- disabled: !S.dirty || te,
22407
- onClick: () => void ge(),
22408
- children: te ? "saving…" : "✓ save"
22476
+ disabled: !re.dirty || ae,
22477
+ onClick: () => void Se(),
22478
+ children: ae ? "saving…" : "✓ save"
22409
22479
  }),
22410
22480
  /* @__PURE__ */ O("button", {
22411
22481
  type: "button",
22412
22482
  className: Ce,
22413
- disabled: !S.canUndo,
22414
- onClick: () => le(e).current?.undo(),
22483
+ disabled: !re.canUndo,
22484
+ onClick: () => me(e).current?.undo(),
22415
22485
  title: "Undo (⌘Z / Ctrl+Z)",
22416
22486
  children: "↶ undo"
22417
22487
  }),
22418
22488
  /* @__PURE__ */ O("button", {
22419
22489
  type: "button",
22420
22490
  className: Ce,
22421
- disabled: !S.canRedo,
22422
- onClick: () => le(e).current?.redo(),
22491
+ disabled: !re.canRedo,
22492
+ onClick: () => me(e).current?.redo(),
22423
22493
  title: "Redo (⇧⌘Z / Ctrl+Y)",
22424
22494
  children: "↷ redo"
22425
22495
  }),
@@ -22429,10 +22499,10 @@ function cE({ path: e, xml: t, variant: n, fallback: r, onTouchUpDirtyChange: i
22429
22499
  children: ["wires", /* @__PURE__ */ k("select", {
22430
22500
  className: Ce,
22431
22501
  "aria-label": "Wire style",
22432
- value: S.wireStyle ?? "orthogonal",
22502
+ value: re.wireStyle ?? "orthogonal",
22433
22503
  onChange: (t) => {
22434
22504
  let n = t.target.value;
22435
- n !== "mixed" && le(e).current?.setWireStyle(n);
22505
+ n !== "mixed" && me(e).current?.setWireStyle(n);
22436
22506
  },
22437
22507
  children: [
22438
22508
  /* @__PURE__ */ O("option", {
@@ -22447,7 +22517,7 @@ function cE({ path: e, xml: t, variant: n, fallback: r, onTouchUpDirtyChange: i
22447
22517
  value: "curved",
22448
22518
  children: "curved"
22449
22519
  }),
22450
- S.wireStyle === "mixed" && /* @__PURE__ */ O("option", {
22520
+ re.wireStyle === "mixed" && /* @__PURE__ */ O("option", {
22451
22521
  value: "mixed",
22452
22522
  disabled: !0,
22453
22523
  children: "mixed"
@@ -22458,51 +22528,51 @@ function cE({ path: e, xml: t, variant: n, fallback: r, onTouchUpDirtyChange: i
22458
22528
  /* @__PURE__ */ O("button", {
22459
22529
  type: "button",
22460
22530
  className: Ce,
22461
- onClick: () => he(),
22531
+ onClick: () => xe(),
22462
22532
  title: "Leave touch-up (Escape); unsaved touch-ups are asked about first",
22463
22533
  children: "done"
22464
22534
  }),
22465
22535
  /* @__PURE__ */ O("span", {
22466
22536
  className: "text-xs text-zinc-400",
22467
22537
  "data-testid": "drawio-touchup-status",
22468
- 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"
22469
22539
  })
22470
- ] }) : de && b === null && g === null ? /* @__PURE__ */ O("button", {
22540
+ ] }) : ge && S === null && y === null ? /* @__PURE__ */ O("button", {
22471
22541
  type: "button",
22472
22542
  className: Ce,
22473
- disabled: d === null,
22474
- onClick: () => void me(e),
22543
+ disabled: m === null,
22544
+ onClick: () => void be(e),
22475
22545
  title: "Move boxes, re-attach wires and fix labels here; anything more in draw.io",
22476
22546
  children: "✎ touch up"
22477
22547
  }) : null;
22478
22548
  }
22479
- function Oe(e) {
22549
+ function Ie(e) {
22480
22550
  return /* @__PURE__ */ k(D, { children: [
22481
- b === e && ae && /* @__PURE__ */ O("span", {
22551
+ S === e && le && /* @__PURE__ */ O("span", {
22482
22552
  role: "alert",
22483
22553
  "data-testid": "drawio-touchup-problem",
22484
22554
  className: "text-red-600 dark:text-red-400",
22485
- children: ae.message
22555
+ children: le.message
22486
22556
  }),
22487
- b === e && se && /* @__PURE__ */ O("span", {
22557
+ S === e && de && /* @__PURE__ */ O("span", {
22488
22558
  role: "status",
22489
22559
  className: "text-amber-700 dark:text-amber-300",
22490
- children: se
22560
+ children: de
22491
22561
  }),
22492
- b === null && ae && /* @__PURE__ */ k("span", {
22562
+ S === null && le && /* @__PURE__ */ k("span", {
22493
22563
  role: "alert",
22494
22564
  className: "text-red-600 dark:text-red-400",
22495
- children: ["Could not start touch-up: ", ae.message]
22565
+ children: ["Could not start touch-up: ", le.message]
22496
22566
  }),
22497
- v && /* @__PURE__ */ k("span", {
22567
+ ee && /* @__PURE__ */ k("span", {
22498
22568
  role: "alert",
22499
22569
  className: "text-red-600 dark:text-red-400",
22500
- children: ["Could not download SVG: ", v]
22570
+ children: ["Could not download SVG: ", ee]
22501
22571
  })
22502
22572
  ] });
22503
22573
  }
22504
- if (n === "reply" && u.status === "failed") return /* @__PURE__ */ k("div", {
22505
- ref: c,
22574
+ if (n === "reply" && p.status === "failed") return /* @__PURE__ */ k("div", {
22575
+ ref: d,
22506
22576
  role: "alert",
22507
22577
  "data-testid": "drawio-block-missing",
22508
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",
@@ -22510,89 +22580,102 @@ function cE({ path: e, xml: t, variant: n, fallback: r, onTouchUpDirtyChange: i
22510
22580
  "The diagram ",
22511
22581
  /* @__PURE__ */ O("code", { children: e }),
22512
22582
  " could not be shown: ",
22513
- u.message
22583
+ p.message
22514
22584
  ]
22515
22585
  });
22516
- let ke = r ?? /* @__PURE__ */ k("p", {
22586
+ let Le = r ?? /* @__PURE__ */ k("p", {
22517
22587
  className: "px-3 py-2 text-xs text-zinc-500",
22518
22588
  children: [
22519
22589
  "The diagram ",
22520
22590
  /* @__PURE__ */ O("code", { children: e }),
22521
22591
  " could not be drawn."
22522
22592
  ]
22523
- }), Ae = /* @__PURE__ */ k("div", {
22593
+ }), Re = /* @__PURE__ */ k("div", {
22524
22594
  className: `${we} ${n === "reply" ? "order-3" : "shrink-0 px-3 py-1.5"}`,
22525
22595
  children: [
22526
- b !== "inline" && /* @__PURE__ */ O("button", {
22596
+ S !== "inline" && /* @__PURE__ */ O("button", {
22527
22597
  type: "button",
22528
22598
  className: "text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50",
22529
- disabled: d === null || b !== null,
22530
- onClick: () => h(!0),
22599
+ disabled: m === null || S !== null,
22600
+ onClick: () => v(!0),
22531
22601
  "aria-label": "Show diagram at full size",
22532
22602
  children: "⤢ enlarge"
22533
22603
  }),
22534
- b !== "inline" && Ee("inline"),
22535
- n === "reply" && s && /* @__PURE__ */ O("button", {
22604
+ S !== "inline" && Pe("inline"),
22605
+ n === "reply" && u && /* @__PURE__ */ O("button", {
22536
22606
  type: "button",
22537
22607
  className: "text-xs text-zinc-500 underline hover:text-zinc-800 dark:hover:text-zinc-200 disabled:opacity-50",
22538
- onClick: () => s(e),
22608
+ onClick: () => u(e),
22539
22609
  title: "Open the file in the file viewer",
22540
22610
  children: "↗ open"
22541
22611
  }),
22542
- n === "viewer" && De("inline"),
22543
- Oe("inline")
22612
+ n === "viewer" && Fe("inline"),
22613
+ Ie("inline")
22544
22614
  ]
22545
22615
  });
22546
22616
  return /* @__PURE__ */ k("div", {
22547
- ref: c,
22617
+ ref: d,
22548
22618
  "data-testid": n === "reply" ? "drawio-block-reply" : "drawio-block-viewer",
22549
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",
22550
22620
  children: [
22551
- n === "viewer" && Ae,
22552
- 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", {
22553
22635
  className: "h-80 animate-pulse rounded bg-zinc-100 dark:bg-zinc-800/60",
22554
22636
  "data-testid": "drawio-block-loading",
22555
22637
  "aria-label": `Loading ${e}`
22556
22638
  }) : /* @__PURE__ */ O(KT, {
22557
- ref: f,
22558
- xml: ue("inline"),
22559
- serverUrl: a,
22639
+ ref: h,
22640
+ xml: he("inline"),
22641
+ serverUrl: c,
22560
22642
  title: e,
22561
- fallback: ke,
22562
- editing: b === "inline",
22563
- onTouchUpChange: C,
22564
- onPageLocked: ve,
22565
- onEscape: Te,
22566
- onRendered: _,
22567
- 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
22568
22651
  }),
22569
- n === "reply" && Ae,
22652
+ n === "reply" && Re,
22570
22653
  /* @__PURE__ */ O(pe, {
22571
22654
  label: e,
22572
22655
  testId: "drawio-enlarged",
22573
- open: m,
22574
- onClose: _e,
22575
- anchorRef: c,
22656
+ open: _,
22657
+ onClose: Ee,
22658
+ anchorRef: d,
22576
22659
  actions: /* @__PURE__ */ k(D, { children: [
22577
- Ee("enlarged"),
22578
- De("enlarged"),
22579
- Oe("enlarged")
22660
+ Pe("enlarged"),
22661
+ Fe("enlarged"),
22662
+ Ie("enlarged")
22580
22663
  ] }),
22581
- children: d !== null && /* @__PURE__ */ O("div", {
22664
+ children: m !== null && /* @__PURE__ */ O("div", {
22582
22665
  style: {
22583
22666
  width: "90vw",
22584
22667
  height: "75vh"
22585
22668
  },
22586
22669
  children: /* @__PURE__ */ O(KT, {
22587
- ref: p,
22588
- xml: ue("enlarged"),
22589
- serverUrl: a,
22670
+ ref: g,
22671
+ xml: he("enlarged"),
22672
+ serverUrl: c,
22590
22673
  title: `${e}, full size`,
22591
- fallback: ke,
22592
- editing: b === "enlarged",
22593
- onTouchUpChange: C,
22594
- onPageLocked: ve,
22595
- onEscape: Te,
22674
+ fallback: Le,
22675
+ editing: S === "enlarged",
22676
+ onTouchUpChange: ie,
22677
+ onPageLocked: De,
22678
+ onEscape: Ne,
22596
22679
  className: "flex h-full flex-col"
22597
22680
  })
22598
22681
  })
@@ -22602,28 +22685,28 @@ function cE({ path: e, xml: t, variant: n, fallback: r, onTouchUpDirtyChange: i
22602
22685
  }
22603
22686
  //#endregion
22604
22687
  //#region ../ui/src/components/AssistantMessage.tsx
22605
- function lE(e) {
22688
+ function hE(e) {
22606
22689
  return e === "className" || Array.isArray(e) && e[0] === "className";
22607
22690
  }
22608
- function uE(e) {
22691
+ function gE(e) {
22609
22692
  let t = {};
22610
- 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));
22611
22694
  return t["*"] = [...t["*"] ?? [], "className"], t;
22612
22695
  }
22613
- var dE = {
22696
+ var _E = {
22614
22697
  ...xT,
22615
22698
  tagNames: [.../* @__PURE__ */ new Set([
22616
22699
  ...xT.tagNames ?? [],
22617
22700
  "details",
22618
22701
  "summary"
22619
22702
  ])],
22620
- attributes: uE(xT.attributes ?? {})
22621
- }, fE = [
22703
+ attributes: gE(xT.attributes ?? {})
22704
+ }, vE = [
22622
22705
  yT,
22623
- [RT, dE],
22706
+ [RT, _E],
22624
22707
  Mb
22625
- ], pE = [d, m];
22626
- function mE(e) {
22708
+ ], yE = [d, m];
22709
+ function bE(e) {
22627
22710
  let t = g("", e);
22628
22711
  try {
22629
22712
  return decodeURIComponent(t);
@@ -22631,10 +22714,10 @@ function mE(e) {
22631
22714
  return t;
22632
22715
  }
22633
22716
  }
22634
- function hE(e) {
22717
+ function xE(e) {
22635
22718
  return typeof e == "string" && e !== "" && !y(e) && _(e.split(/[?#]/)[0]);
22636
22719
  }
22637
- function gE({ text: e }) {
22720
+ function SE({ text: e }) {
22638
22721
  let [t, n] = E(!1);
22639
22722
  return /* @__PURE__ */ k("div", {
22640
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",
@@ -22655,13 +22738,13 @@ function gE({ text: e }) {
22655
22738
  })]
22656
22739
  });
22657
22740
  }
22658
- 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 }) {
22659
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);
22660
22743
  l.current = i;
22661
22744
  let u = se(() => {
22662
22745
  function e({ src: e, alt: i, ...a }) {
22663
- if (hE(e)) return /* @__PURE__ */ O(cE, {
22664
- path: mE(e),
22746
+ if (xE(e)) return /* @__PURE__ */ O(mE, {
22747
+ path: bE(e),
22665
22748
  variant: "reply"
22666
22749
  });
22667
22750
  let o = typeof e == "string" && e !== "" && !y(e) ? v(t, g("", e), n, void 0, r) : e;
@@ -22695,7 +22778,7 @@ function _E({ item: e, serverUrl: t = "", token: n = null, workspace: r, onOpenF
22695
22778
  }
22696
22779
  function a({ node: e, children: t, ...n }) {
22697
22780
  let r = (e?.children ?? []).filter((e) => e.type !== "text" || (e.value ?? "").trim() !== "");
22698
- 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", {
22699
22782
  className: "my-2",
22700
22783
  children: t
22701
22784
  }) : /* @__PURE__ */ O("p", {
@@ -22721,11 +22804,11 @@ function _E({ item: e, serverUrl: t = "", token: n = null, workspace: r, onOpenF
22721
22804
  className: "flex justify-end opacity-0 transition-opacity group-hover:opacity-100",
22722
22805
  children: /* @__PURE__ */ O(de, { text: c })
22723
22806
  }),
22724
- 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", {
22725
22808
  className: "prose-chat",
22726
22809
  children: /* @__PURE__ */ O(lh, {
22727
- remarkPlugins: pE,
22728
- rehypePlugins: fE,
22810
+ remarkPlugins: yE,
22811
+ rehypePlugins: vE,
22729
22812
  components: u,
22730
22813
  children: s(e.text)
22731
22814
  })
@@ -22739,20 +22822,20 @@ function _E({ item: e, serverUrl: t = "", token: n = null, workspace: r, onOpenF
22739
22822
  }
22740
22823
  //#endregion
22741
22824
  //#region ../shared/src/protocol.ts
22742
- var vE = [
22825
+ var wE = [
22743
22826
  "off",
22744
22827
  "minimal",
22745
22828
  "low",
22746
22829
  "medium",
22747
22830
  "high",
22748
22831
  "xhigh"
22749
- ], yE = "worktree", bE = class extends Error {
22832
+ ], TE = "worktree", EE = class extends Error {
22750
22833
  kind;
22751
22834
  constructor(e, t) {
22752
22835
  super(e), this.name = "HistoryError", this.kind = t;
22753
22836
  }
22754
22837
  };
22755
- async function xE(e, t) {
22838
+ async function DE(e, t) {
22756
22839
  let n = [];
22757
22840
  for (;;) {
22758
22841
  let r = await e(n.length, 50);
@@ -22760,4 +22843,4 @@ async function xE(e, t) {
22760
22843
  }
22761
22844
  }
22762
22845
  //#endregion
22763
- 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 };