mesurer-solid 0.2.0-beta.0 → 0.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -14630,21 +14630,28 @@ function t_(e) {
14630
14630
  if (!Ru(e.fingerprint)) return null;
14631
14631
  let t = [];
14632
14632
  try {
14633
- t = D(e.selector).filter((t) => zu(t, e.fingerprint));
14633
+ t = D(e.selector);
14634
14634
  } catch {
14635
14635
  return null;
14636
14636
  }
14637
- if (t.length !== 1) return null;
14638
- if (!e.fingerprint.id && !e.fingerprint.testId) {
14639
- let n = [];
14640
- try {
14641
- n = D(e.fingerprint.tag).filter((t) => zu(t, e.fingerprint));
14642
- } catch {
14643
- return null;
14637
+ let n = t.filter((t) => zu(t, e.fingerprint));
14638
+ if (n.length === 1) {
14639
+ if (!e.fingerprint.id && !e.fingerprint.testId) {
14640
+ let t = [];
14641
+ try {
14642
+ t = D(e.fingerprint.tag).filter((t) => zu(t, e.fingerprint));
14643
+ } catch {
14644
+ return null;
14645
+ }
14646
+ if (t.length !== 1 || t[0] !== n[0]) return null;
14644
14647
  }
14645
- if (n.length !== 1 || n[0] !== t[0]) return null;
14648
+ return n[0] ?? null;
14646
14649
  }
14647
- return t[0] ?? null;
14650
+ if (t.length !== 1 || e.fingerprint.id || e.fingerprint.testId) return null;
14651
+ let r = t[0];
14652
+ if (!r || r.localName !== e.fingerprint.tag) return null;
14653
+ let i = Tu(r), a = e.lastRect, o = Math.max(4, Math.max(a.width, a.height) * .05), s = Math.max(2, Math.max(a.width, a.height) * .03);
14654
+ return Math.abs(i.left - a.left) <= o && Math.abs(i.top - a.top) <= o && Math.abs(i.width - a.width) <= s && Math.abs(i.height - a.height) <= s ? r : null;
14648
14655
  }, j = (e, t) => {
14649
14656
  let n = T(e, t.id), r = y.get(n);
14650
14657
  if (r?.isConnected && E(r)) return r;
@@ -17836,7 +17843,7 @@ function Ty(e) {
17836
17843
  }
17837
17844
  //#endregion
17838
17845
  //#region src/version.ts
17839
- var Ey = "0.2.0-beta.0", Dy = Xf, Oy = Zf, ky = () => ({
17846
+ var Ey = "0.2.0-beta.1", Dy = Xf, Oy = Zf, ky = () => ({
17840
17847
  ...Ip(),
17841
17848
  version: Ey
17842
17849
  }), Ay = (e, t) => e.left <= t.left + t.width && e.left + e.width >= t.left && e.top <= t.top + t.height && e.top + e.height >= t.top, jy = (e) => {
@@ -18340,8 +18347,8 @@ var Xy = (e, t, n, r, i) => {
18340
18347
  evidence: t,
18341
18348
  id: n,
18342
18349
  label: r
18343
- });
18344
- function Qy(e) {
18350
+ }), Qy = (e, t) => Math.abs(e.left - t.left) < .01 && Math.abs(e.top - t.top) < .01 && Math.abs(e.width - t.width) < .01 && Math.abs(e.height - t.height) < .01;
18351
+ function $y(e) {
18345
18352
  let t = e.runtime.annotation(e.annotationId);
18346
18353
  if (!t) throw Error(`Mesurer annotation not found: ${e.annotationId}`);
18347
18354
  let n = Gy({
@@ -18375,12 +18382,13 @@ function Qy(e) {
18375
18382
  Xy(a, "guide", `${e.orientation} guide ${e.id}`, e.position, t.position);
18376
18383
  }
18377
18384
  for (let e of t.baseline.measurements) {
18378
- let t = n.visualContext.measurements.find((t) => t.id === e.id) ?? i.find((t) => t.id === e.id);
18379
- if (!t) {
18380
- Zy(a, "measurement", e.id, e.id);
18385
+ let r = n.visualContext.measurements.find((t) => t.id === e.id) ?? i.find((t) => t.id === e.id);
18386
+ if (!r) {
18387
+ let r = t.baseline.targets.find((t) => Qy(t.rect, e.rect));
18388
+ r && n.targets.some((e) => e.ref === r.id) || Zy(a, "measurement", e.id, e.id);
18381
18389
  continue;
18382
18390
  }
18383
- Xy(a, "measurement", `${e.id} width`, e.rect.width, t.rect.width), Xy(a, "measurement", `${e.id} height`, e.rect.height, t.rect.height);
18391
+ Xy(a, "measurement", `${e.id} width`, e.rect.width, r.rect.width), Xy(a, "measurement", `${e.id} height`, e.rect.height, r.rect.height);
18384
18392
  }
18385
18393
  for (let e of t.baseline.distances) {
18386
18394
  let t = n.visualContext.distances.find((t) => t.id === e.id) ?? r.heldDistances.find((t) => t.id === e.id);
@@ -18400,7 +18408,7 @@ function Qy(e) {
18400
18408
  changes: a
18401
18409
  };
18402
18410
  }
18403
- async function $y(e, t, n) {
18411
+ async function eb(e, t, n) {
18404
18412
  try {
18405
18413
  if (t.navigator.clipboard?.writeText) {
18406
18414
  await t.navigator.clipboard.writeText(n);
@@ -18414,22 +18422,22 @@ async function $y(e, t, n) {
18414
18422
  }
18415
18423
  //#endregion
18416
18424
  //#region src/layout-guides.ts
18417
- var eb = $_, tb = ev, nb = () => ({
18425
+ var tb = $_, nb = ev, rb = () => ({
18418
18426
  ...Ev(),
18419
18427
  version: Ey
18420
- }), rb = "mesurer.context", ib = "context:v1", ab = "mesurer.context.settings", ob = "context.ui", sb = "data-mesurer-direct-text-edit-active", cb = {
18428
+ }), ib = "mesurer.context", ab = "context:v1", ob = "mesurer.context.settings", sb = "context.ui", cb = "data-mesurer-direct-text-edit-active", lb = {
18421
18429
  viewBox: "0 0 256 256",
18422
18430
  paths: ["M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"]
18423
- }, lb = {
18431
+ }, ub = {
18424
18432
  viewBox: "0 0 256 256",
18425
18433
  paths: ["M152,40a8,8,0,0,1-8,8H112a8,8,0,0,1,0-16h32A8,8,0,0,1,152,40Zm-8,168H112a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16ZM208,32H184a8,8,0,0,0,0,16h24V72a8,8,0,0,0,16,0V48A16,16,0,0,0,208,32Zm8,72a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V112A8,8,0,0,0,216,104Zm0,72a8,8,0,0,0-8,8v24H184a8,8,0,0,0,0,16h24a16,16,0,0,0,16-16V184A8,8,0,0,0,216,176ZM40,152a8,8,0,0,0,8-8V112a8,8,0,0,0-16,0v32A8,8,0,0,0,40,152Zm32,56H48V184a8,8,0,0,0-16,0v24a16,16,0,0,0,16,16H72a8,8,0,0,0,0-16ZM72,32H48A16,16,0,0,0,32,48V72a8,8,0,0,0,16,0V48H72a8,8,0,0,0,0-16Z"]
18426
- }, ub = {
18434
+ }, db = {
18427
18435
  viewBox: "0 0 256 256",
18428
18436
  paths: ["M229.66,58.34l-32-32a8,8,0,0,0-11.32,0l-96,96A8,8,0,0,0,88,128v32a8,8,0,0,0,8,8h32a8,8,0,0,0,5.66-2.34l96-96A8,8,0,0,0,229.66,58.34ZM124.69,152H104V131.31l64-64L188.69,88ZM200,76.69,179.31,56,192,43.31,212.69,64ZM224,128v80a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32h80a8,8,0,0,1,0,16H48V208H208V128a8,8,0,0,1,16,0Z"]
18429
- }, db = async (e, t, n = 1) => {
18437
+ }, fb = async (e, t, n = 1) => {
18430
18438
  await e.fonts?.ready;
18431
18439
  for (let e = 0; e < Math.max(1, n); e += 1) await new Promise((e) => t.requestAnimationFrame(() => e()));
18432
- }, fb = (e, t, n, r) => {
18440
+ }, pb = (e, t, n, r) => {
18433
18441
  let i = async (i) => Gy({
18434
18442
  runtime: e,
18435
18443
  ownerDocument: t,
@@ -18440,17 +18448,17 @@ var eb = $_, tb = ev, nb = () => ({
18440
18448
  return {
18441
18449
  context: i,
18442
18450
  contextText: a,
18443
- copyContext: async (e) => $y(t, n, await a(e)),
18451
+ copyContext: async (e) => eb(t, n, await a(e)),
18444
18452
  select: async (r) => {
18445
18453
  let a = Array.isArray(r) ? [...r] : [String(r)];
18446
- return e.select(a), await db(t, n), i({ scope: "selection" });
18454
+ return e.select(a), await fb(t, n), i({ scope: "selection" });
18447
18455
  },
18448
18456
  annotations: async () => e.annotations(),
18449
18457
  removeAnnotation: async (r) => {
18450
- e.removeAnnotation(r), await db(t, n);
18458
+ e.removeAnnotation(r), await fb(t, n);
18451
18459
  },
18452
18460
  review: async (i) => {
18453
- if (await db(t, n), i) return Qy({
18461
+ if (await fb(t, n), i) return $y({
18454
18462
  runtime: e,
18455
18463
  ownerDocument: t,
18456
18464
  ownerWindow: n,
@@ -18458,7 +18466,7 @@ var eb = $_, tb = ev, nb = () => ({
18458
18466
  layoutGuides: r()
18459
18467
  });
18460
18468
  let a = r();
18461
- return e.annotations().map((r) => Qy({
18469
+ return e.annotations().map((r) => $y({
18462
18470
  runtime: e,
18463
18471
  ownerDocument: t,
18464
18472
  ownerWindow: n,
@@ -18468,36 +18476,36 @@ var eb = $_, tb = ev, nb = () => ({
18468
18476
  },
18469
18477
  capturePlan: async (e) => Yy(await i(e)),
18470
18478
  prepareCapture: async () => {
18471
- e.prepareCapture(), await db(t, n);
18479
+ e.prepareCapture(), await fb(t, n);
18472
18480
  },
18473
18481
  finishCapture: async () => {
18474
- e.finishCapture(), await db(t, n);
18482
+ e.finishCapture(), await fb(t, n);
18475
18483
  }
18476
18484
  };
18477
- }, pb = (e) => {
18485
+ }, mb = (e) => {
18478
18486
  let t = e.currentSelection();
18479
18487
  return t.elements.length > 0 || t.region !== null;
18480
18488
  };
18481
- function mb(e = {}) {
18489
+ function hb(e = {}) {
18482
18490
  return {
18483
- id: rb,
18491
+ id: ib,
18484
18492
  version: Ey,
18485
18493
  requires: ["runtime:solid"],
18486
- provides: [ib],
18494
+ provides: [ab],
18487
18495
  setup(t) {
18488
18496
  let n = t.service.get("runtime:solid");
18489
18497
  if (!n) throw Error("Mesurer context plugin requires the renderer runtime service.");
18490
- let r = n.createWorkspaceRuntime(rb), i = fb(r, n.ownerDocument, n.ownerWindow, () => t.service.get(tb)?.list() ?? []);
18491
- t.service.provide(ib, i), t.state.register({
18492
- id: ab,
18498
+ let r = n.createWorkspaceRuntime(ib), i = pb(r, n.ownerDocument, n.ownerWindow, () => t.service.get(nb)?.list() ?? []);
18499
+ t.service.provide(ab, i), t.state.register({
18500
+ id: ob,
18493
18501
  initial: { ui: e.ui ?? !0 },
18494
18502
  persist: !0
18495
18503
  }), t.state.register({
18496
- id: ob,
18497
- initial: { hasSelection: pb(r) }
18504
+ id: sb,
18505
+ initial: { hasSelection: mb(r) }
18498
18506
  });
18499
- let a = () => t.state.get("mesurer.context.settings")?.ui ?? !0, o = () => t.state.get(ob)?.hasSelection === !0, s = (e) => {
18500
- t.state.update(ab, (t) => ({
18507
+ let a = () => t.state.get("mesurer.context.settings")?.ui ?? !0, o = () => t.state.get(sb)?.hasSelection === !0, s = (e) => {
18508
+ t.state.update(ob, (t) => ({
18501
18509
  ...t,
18502
18510
  ui: e
18503
18511
  }));
@@ -18511,12 +18519,12 @@ function mb(e = {}) {
18511
18519
  region: e.region ? { ...e.region } : null
18512
18520
  }, r.selectGestureActive() ? c?.abandonNoteComposer() : n && c?.closeNoteComposer();
18513
18521
  let i = e.elements.length > 0 || e.region !== null;
18514
- i !== (t.state.get(ob)?.hasSelection ?? !1) && t.state.update(ob, () => ({ hasSelection: i }));
18522
+ i !== (t.state.get(sb)?.hasSelection ?? !1) && t.state.update(sb, () => ({ hasSelection: i }));
18515
18523
  });
18516
18524
  t.command.register("context.copy", () => i.copyContext()), t.command.register("context.copy-selection", () => i.copyContext({ scope: "selection" }));
18517
18525
  let g = () => {
18518
18526
  let e = u?.element;
18519
- e && (n.rendererRoot?.hasAttribute(sb) ? e.setAttribute(sb, "true") : e.removeAttribute(sb));
18527
+ e && (n.rendererRoot?.hasAttribute(cb) ? e.setAttribute(cb, "true") : e.removeAttribute(cb));
18520
18528
  }, _ = () => {
18521
18529
  d?.disconnect(), d = null, c = null, l?.(), l = null, u?.dispose(), u = null;
18522
18530
  }, v = () => {
@@ -18525,7 +18533,7 @@ function mb(e = {}) {
18525
18533
  let e = new n.ownerWindow.MutationObserver(g);
18526
18534
  d = e, e.observe(n.rendererRoot, {
18527
18535
  attributes: !0,
18528
- attributeFilter: [sb]
18536
+ attributeFilter: [cb]
18529
18537
  }), g();
18530
18538
  }
18531
18539
  let e = {
@@ -18548,7 +18556,7 @@ function mb(e = {}) {
18548
18556
  shortcut: "C",
18549
18557
  command: "context.copy",
18550
18558
  order: 70,
18551
- icon: cb,
18559
+ icon: lb,
18552
18560
  hidden: () => !a()
18553
18561
  }), t.tool.register({
18554
18562
  id: "context.copy-selection",
@@ -18556,7 +18564,7 @@ function mb(e = {}) {
18556
18564
  shortcut: "Shift+C",
18557
18565
  command: "context.copy-selection",
18558
18566
  order: 71,
18559
- icon: lb,
18567
+ icon: ub,
18560
18568
  hidden: () => !a(),
18561
18569
  disabled: () => !o()
18562
18570
  }), t.tool.register({
@@ -18565,7 +18573,7 @@ function mb(e = {}) {
18565
18573
  shortcut: "N",
18566
18574
  command: "context.add-note",
18567
18575
  order: 72,
18568
- icon: ub,
18576
+ icon: db,
18569
18577
  hidden: () => !a(),
18570
18578
  disabled: () => !o()
18571
18579
  }), t.settings.register({
@@ -18588,7 +18596,7 @@ function mb(e = {}) {
18588
18596
  }
18589
18597
  //#endregion
18590
18598
  //#region src/host-layer.ts
18591
- var hb = {
18599
+ var gb = {
18592
18600
  display: "block",
18593
18601
  position: "fixed",
18594
18602
  inset: "0",
@@ -18630,48 +18638,48 @@ var hb = {
18630
18638
  "letter-spacing": "normal",
18631
18639
  direction: "ltr"
18632
18640
  };
18633
- function gb(e) {
18634
- for (let [t, n] of Object.entries(hb)) e.style.setProperty(t, n, "important");
18635
- }
18636
18641
  function _b(e) {
18642
+ for (let [t, n] of Object.entries(gb)) e.style.setProperty(t, n, "important");
18643
+ }
18644
+ function vb(e) {
18637
18645
  return "popover" in e && "showPopover" in e && typeof e.showPopover == "function" && "hidePopover" in e && typeof e.hidePopover == "function";
18638
18646
  }
18639
- var vb = (e) => "newState" in e, yb = (e) => e.localName === "dialog";
18640
- function bb(e) {
18641
- if (!yb(e) || !e.open) return !1;
18647
+ var yb = (e) => "newState" in e, bb = (e) => e.localName === "dialog";
18648
+ function xb(e) {
18649
+ if (!bb(e) || !e.open) return !1;
18642
18650
  try {
18643
18651
  return e.matches(":modal");
18644
18652
  } catch {
18645
18653
  return !1;
18646
18654
  }
18647
18655
  }
18648
- function xb(e, t, n = !0) {
18649
- gb(e);
18656
+ function Sb(e, t, n = !0) {
18657
+ _b(e);
18650
18658
  let r = e.ownerDocument, i = r.defaultView ?? window, a = t, o = !1, s = "fixed", c = !1, l = 0, u = [];
18651
- if (n && _b(e) && (e.popover = "manual"), t.append(e), n && _b(e)) try {
18659
+ if (n && vb(e) && (e.popover = "manual"), t.append(e), n && vb(e)) try {
18652
18660
  e.showPopover(), c = e.matches(":popover-open"), c && (s = "top-layer");
18653
18661
  } catch {
18654
18662
  e.removeAttribute("popover");
18655
18663
  }
18656
18664
  let d = () => {
18657
- if (!(!c || !_b(e))) try {
18665
+ if (!(!c || !vb(e))) try {
18658
18666
  e.matches(":popover-open") || e.showPopover();
18659
18667
  } catch {}
18660
18668
  }, f = (t) => {
18661
18669
  if (e.parentNode === t) return;
18662
- let n = c && _b(e) && e.matches(":popover-open");
18663
- if (n && _b(e)) try {
18670
+ let n = c && vb(e) && e.matches(":popover-open");
18671
+ if (n && vb(e)) try {
18664
18672
  e.hidePopover();
18665
18673
  } catch {}
18666
- t.append(e), gb(e), n && d();
18674
+ t.append(e), _b(e), n && d();
18667
18675
  }, p = () => {
18668
- u = u.filter((e) => e.isConnected && bb(e)), f(u.at(-1) ?? a);
18676
+ u = u.filter((e) => e.isConnected && xb(e)), f(u.at(-1) ?? a);
18669
18677
  }, m = (e) => {
18670
18678
  u = u.filter((t) => t !== e), u.push(e), p();
18671
18679
  }, h = (e) => {
18672
18680
  u = u.filter((t) => t !== e), p();
18673
18681
  }, g = () => {
18674
- if (!(o || !c || !_b(e))) try {
18682
+ if (!(o || !c || !vb(e))) try {
18675
18683
  e.matches(":popover-open") && e.hidePopover(), e.showPopover();
18676
18684
  } catch {}
18677
18685
  }, _ = () => {
@@ -18680,27 +18688,27 @@ function xb(e, t, n = !0) {
18680
18688
  }));
18681
18689
  }, v = (t) => {
18682
18690
  if (!c || t.target === e) return;
18683
- let n = vb(t) ? t.newState : void 0, r = t.target;
18691
+ let n = yb(t) ? t.newState : void 0, r = t.target;
18684
18692
  if (r instanceof i.Element) {
18685
- if (yb(r)) {
18686
- n === "open" && bb(r) ? (m(r), _()) : n === "closed" ? h(r) : n === "open" && _();
18693
+ if (bb(r)) {
18694
+ n === "open" && xb(r) ? (m(r), _()) : n === "closed" ? h(r) : n === "open" && _();
18687
18695
  return;
18688
18696
  }
18689
18697
  n === "open" && r.hasAttribute("popover") && _();
18690
18698
  }
18691
18699
  }, y = (e) => {
18692
18700
  let t = e.target;
18693
- t instanceof i.Element && yb(t) && h(t);
18701
+ t instanceof i.Element && bb(t) && h(t);
18694
18702
  }, b = () => {
18695
18703
  r.fullscreenElement && _();
18696
18704
  }, x = (e) => {
18697
- bb(e) && m(e);
18698
- for (let t of e.querySelectorAll("dialog")) bb(t) && m(t);
18705
+ xb(e) && m(e);
18706
+ for (let t of e.querySelectorAll("dialog")) xb(t) && m(t);
18699
18707
  }, S = new i.MutationObserver((e) => {
18700
18708
  if (c) for (let t of e) {
18701
18709
  if (t.type === "attributes") {
18702
18710
  let e = t.target;
18703
- e instanceof i.Element && yb(e) && (bb(e) ? m(e) : h(e));
18711
+ e instanceof i.Element && bb(e) && (xb(e) ? m(e) : h(e));
18704
18712
  }
18705
18713
  for (let e of t.addedNodes) e instanceof i.Element && x(e);
18706
18714
  u.some((e) => !e.isConnected) && p();
@@ -18716,7 +18724,7 @@ function xb(e, t, n = !0) {
18716
18724
  bringToFront: g,
18717
18725
  dispose() {
18718
18726
  if (!o) {
18719
- if (o = !0, l && i.cancelAnimationFrame(l), r.removeEventListener("toggle", v, !0), r.removeEventListener("close", y, !0), r.removeEventListener("fullscreenchange", b, !0), S.disconnect(), c && _b(e) && e.matches(":popover-open")) try {
18727
+ if (o = !0, l && i.cancelAnimationFrame(l), r.removeEventListener("toggle", v, !0), r.removeEventListener("close", y, !0), r.removeEventListener("fullscreenchange", b, !0), S.disconnect(), c && vb(e) && e.matches(":popover-open")) try {
18720
18728
  e.hidePopover();
18721
18729
  } catch {}
18722
18730
  u = [];
@@ -18726,28 +18734,28 @@ function xb(e, t, n = !0) {
18726
18734
  }
18727
18735
  //#endregion
18728
18736
  //#region src/codex-plugin.ts
18729
- var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2e3, Eb = 750, Db = 1800, Ob = 2e3, kb = 12e4, Ab = 10, jb = 5, Mb = [
18737
+ var Cb = "mesurer.codex", wb = "codex:v1", Tb = "http://127.0.0.1:47365", Eb = 2e3, Db = 750, Ob = 1800, kb = 2e3, Ab = 12e4, jb = 10, Mb = 5, Nb = [
18730
18738
  "Implement the current human feedback from Mesurer in this project.",
18731
18739
  "Treat the rendered page as the source of truth, preserve unrelated Mesurer review state,",
18732
18740
  "and verify the affected UI in the live page with Mesurer before claiming completion."
18733
- ].join(" "), Nb = {
18741
+ ].join(" "), Pb = {
18734
18742
  viewBox: "0 0 256 256",
18735
18743
  paths: ["M224,48,32,120l88,32,32,88Z M120,152l104-104"]
18736
- }, Pb = {
18744
+ }, Fb = {
18737
18745
  viewBox: "0 0 256 256",
18738
18746
  paths: ["M72,32H184a8,8,0,0,1,0,16h-8v20.69a40,40,0,0,1-11.72,28.28L137.25,124l27.03,27.03A40,40,0,0,1,176,179.31V208h8a8,8,0,0,1,0,16H72a8,8,0,0,1,0-16h8V179.31a40,40,0,0,1,11.72-28.28L118.75,124,91.72,96.97A40,40,0,0,1,80,68.69V48H72a8,8,0,0,1,0-16Zm24,16V68.69a24,24,0,0,0,7.03,16.97L128,110.63l24.97-24.97A24,24,0,0,0,160,68.69V48Zm32,90.63-24.97,24.97A24,24,0,0,0,96,180.57V208h64V180.57a24,24,0,0,0-7.03-16.97Z"]
18739
- }, Fb = {
18747
+ }, Ib = {
18740
18748
  viewBox: "0 0 256 256",
18741
18749
  paths: ["M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z"]
18742
- }, Ib = (e) => {
18750
+ }, Lb = (e) => {
18743
18751
  try {
18744
18752
  let t = globalThis.location;
18745
18753
  return t?.origin ? `mesurer-codex-ui:v1:${e}:${t.origin}${t.pathname}` : null;
18746
18754
  } catch {
18747
18755
  return null;
18748
18756
  }
18749
- }, Lb = (e) => {
18750
- let t = Ib(e);
18757
+ }, Rb = (e) => {
18758
+ let t = Lb(e);
18751
18759
  if (!t) return null;
18752
18760
  try {
18753
18761
  let e = globalThis.sessionStorage?.getItem(t);
@@ -18772,18 +18780,18 @@ var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2
18772
18780
  } catch {
18773
18781
  return null;
18774
18782
  }
18775
- }, Rb = (e, t) => {
18776
- let n = Ib(e);
18783
+ }, zb = (e, t) => {
18784
+ let n = Lb(e);
18777
18785
  if (n) try {
18778
18786
  globalThis.sessionStorage?.setItem(n, JSON.stringify(t));
18779
18787
  } catch {}
18780
- }, zb = (e, t) => {
18788
+ }, Bb = (e, t) => {
18781
18789
  let n = e.endsWith("/") ? e : `${e}/`;
18782
18790
  return new URL(t, n).toString();
18783
- }, Bb = async (e, t, n) => {
18791
+ }, Vb = async (e, t, n) => {
18784
18792
  let r = new AbortController(), i = setTimeout(() => r.abort(), 15e3);
18785
18793
  try {
18786
- let i = await fetch(zb(e, t), {
18794
+ let i = await fetch(Bb(e, t), {
18787
18795
  ...n,
18788
18796
  signal: r.signal
18789
18797
  }), a = await i.text(), o = {};
@@ -18799,10 +18807,10 @@ var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2
18799
18807
  } finally {
18800
18808
  clearTimeout(i);
18801
18809
  }
18802
- }, Vb = (e) => ({
18810
+ }, Hb = (e) => ({
18803
18811
  thread: e.thread?.trim() || null,
18804
18812
  threads: Array.isArray(e.threads) ? e.threads.filter((e) => e.trim().length > 0) : []
18805
- }), Hb = (e) => {
18813
+ }), Ub = (e) => {
18806
18814
  let t = e.deliveryId?.trim(), n = e.thread?.trim(), r = e.status;
18807
18815
  if (!t || !n || !r) throw Error("Mesurer Codex bridge returned an invalid delivery state.");
18808
18816
  let i = {
@@ -18814,7 +18822,7 @@ var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2
18814
18822
  updatedAt: Number.isFinite(e.updatedAt) ? Number(e.updatedAt) : 0
18815
18823
  };
18816
18824
  return e.queuedSubmissionId !== void 0 && (i.queuedSubmissionId = e.queuedSubmissionId?.trim() || null), e.dispatch !== void 0 && (i.dispatch = e.dispatch), e.dispatchError !== void 0 && (i.dispatchError = e.dispatchError?.trim() || null), i;
18817
- }, Ub = (e) => ({
18825
+ }, Wb = (e) => ({
18818
18826
  thread: e.thread?.trim() || null,
18819
18827
  threads: Array.isArray(e.threadDetails) ? e.threadDetails.flatMap((e) => {
18820
18828
  let t = e.id?.trim() ?? "";
@@ -18826,7 +18834,7 @@ var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2
18826
18834
  }] : [];
18827
18835
  }) : [],
18828
18836
  hasMore: e.hasMore === !0
18829
- }), Wb = async (e, t, n) => {
18837
+ }), Gb = async (e, t, n) => {
18830
18838
  let r = t?.instruction?.trim() || n, i = await e.annotations(), a = t?.annotationIds, o = a ? a.flatMap((e) => {
18831
18839
  let t = i.find((t) => t.id === e);
18832
18840
  return t ? [t] : [];
@@ -18849,18 +18857,18 @@ var Sb = "mesurer.codex", Cb = "codex:v1", wb = "http://127.0.0.1:47365", Tb = 2
18849
18857
  ])
18850
18858
  ].join("\n").trimEnd()
18851
18859
  };
18852
- }, Gb = (e) => e.length > 16 ? `${e.slice(0, 8)}…${e.slice(-4)}` : e, Kb = (e, t = 42) => e.length > t ? `${e.slice(0, t - 1)}…` : e, qb = (e, t) => e instanceof Error && e.message === `Mesurer Codex bridge is unavailable at ${t}. Start the local bridge before queueing feedback.`;
18853
- function Jb(e = {}) {
18854
- let t = e.endpoint ?? wb, n = e.instruction?.trim() || Mb, r = e.ui ?? !0, i = e.clearCompletedAnnotations ?? !0;
18860
+ }, Kb = (e) => e.length > 16 ? `${e.slice(0, 8)}…${e.slice(-4)}` : e, qb = (e, t = 42) => e.length > t ? `${e.slice(0, t - 1)}…` : e, Jb = (e, t) => e instanceof Error && e.message === `Mesurer Codex bridge is unavailable at ${t}. Start the local bridge before queueing feedback.`;
18861
+ function Yb(e = {}) {
18862
+ let t = e.endpoint ?? Tb, n = e.instruction?.trim() || Nb, r = e.ui ?? !0, i = e.clearCompletedAnnotations ?? !0;
18855
18863
  return {
18856
- id: Sb,
18864
+ id: Cb,
18857
18865
  version: Ey,
18858
- requires: [ib],
18859
- provides: [Cb],
18866
+ requires: [ab],
18867
+ provides: [wb],
18860
18868
  setup(e) {
18861
- let a = e.service.get(ib);
18869
+ let a = e.service.get(ab);
18862
18870
  if (!a) throw Error("Mesurer Codex plugin requires context() from mesurer-solid/plugins.");
18863
- let o = r ? Lb(t) : null, s = "unknown", c = !1, l = o?.originThread ?? null, u = o?.selectedThread ?? o?.originThread ?? null, d = !1, f = null, p = [], m = [], h = !1, g = jb, _, v = "", y = null, b = o?.delivery ? {
18871
+ let o = r ? Rb(t) : null, s = "unknown", c = !1, l = o?.originThread ?? null, u = o?.selectedThread ?? o?.originThread ?? null, d = !1, f = null, p = [], m = [], h = !1, g = Mb, _, v = "", y = null, b = o?.delivery ? {
18864
18872
  id: o.delivery.id,
18865
18873
  thread: o.delivery.thread,
18866
18874
  status: o.delivery.status,
@@ -18868,22 +18876,22 @@ function Jb(e = {}) {
18868
18876
  queuedSubmissionId: o.delivery.queuedSubmissionId ?? null,
18869
18877
  dispatch: o.delivery.dispatch ?? null,
18870
18878
  dispatchError: o.delivery.dispatchError ?? null
18871
- } : null, x = 0, S = 0, C = null, w = !1, T = async () => Vb(await Bb(t, "health")), E = async (e) => Hb(await Bb(t, `deliveries/${encodeURIComponent(e)}`)), D = async (e) => {
18879
+ } : null, x = 0, S = 0, C = null, w = !1, T = async () => Hb(await Vb(t, "health")), E = async (e) => Ub(await Vb(t, `deliveries/${encodeURIComponent(e)}`)), D = async (e) => {
18872
18880
  if (!e.id || !e.thread) throw Error("Cannot restore a Codex delivery without its id and thread.");
18873
18881
  let n = {
18874
18882
  deliveryId: e.id,
18875
18883
  thread: e.thread
18876
18884
  };
18877
- return e.queuedSubmissionId && (n.queuedSubmissionId = e.queuedSubmissionId), Hb(await Bb(t, "deliveries/restore", {
18885
+ return e.queuedSubmissionId && (n.queuedSubmissionId = e.queuedSubmissionId), Ub(await Vb(t, "deliveries/restore", {
18878
18886
  method: "POST",
18879
18887
  headers: { "Content-Type": "application/json" },
18880
18888
  body: JSON.stringify(n)
18881
18889
  }));
18882
18890
  }, O = async (e = {}) => {
18883
18891
  let n = new URLSearchParams();
18884
- n.set("limit", String(e.limit ?? Ab));
18892
+ n.set("limit", String(e.limit ?? jb));
18885
18893
  let r = e.thread?.trim();
18886
- return r && n.set("thread", r), Ub(await Bb(t, `threads?${n.toString()}`));
18894
+ return r && n.set("thread", r), Wb(await Vb(t, `threads?${n.toString()}`));
18887
18895
  }, k = () => u ?? l ?? (d ? null : f), A = () => {
18888
18896
  if (!r) return;
18889
18897
  let e = b?.id && (b.status === "queued" || b.status === "working" || b.status === "interrupted") ? {
@@ -18895,7 +18903,7 @@ function Jb(e = {}) {
18895
18903
  dispatch: b.dispatch,
18896
18904
  dispatchError: b.dispatchError
18897
18905
  } : null;
18898
- Rb(t, {
18906
+ zb(t, {
18899
18907
  version: 1,
18900
18908
  originThread: l,
18901
18909
  selectedThread: u,
@@ -18913,12 +18921,12 @@ function Jb(e = {}) {
18913
18921
  "queueing",
18914
18922
  "queued",
18915
18923
  "working"
18916
- ].includes(b.status) ? Pb : b.status === "completed" ? Fb : Nb : Nb, L = () => {
18924
+ ].includes(b.status) ? Fb : b.status === "completed" ? Ib : Pb : Pb, L = () => {
18917
18925
  let e = [], t = /* @__PURE__ */ new Set(), n = (n) => {
18918
18926
  t.has(n.id) || (t.add(n.id), e.push(n));
18919
18927
  }, r = (e) => ({
18920
18928
  id: e,
18921
- title: `Codex ${Gb(e)}`,
18929
+ title: `Codex ${Kb(e)}`,
18922
18930
  updatedAt: null,
18923
18931
  connected: !0
18924
18932
  });
@@ -18938,7 +18946,7 @@ function Jb(e = {}) {
18938
18946
  let t = e.id === l ? "Current · " : e.connected ? "Connected · " : "", r = b?.thread === e.id ? ` · ${N() ? "Blocked" : P(b.status)}` : "";
18939
18947
  return {
18940
18948
  id: `codex.thread.${e.id}`,
18941
- label: `${t}${Kb(e.title)}${r}`,
18949
+ label: `${t}${qb(e.title)}${r}`,
18942
18950
  checked: () => n === e.id,
18943
18951
  disabled: () => M(),
18944
18952
  run() {
@@ -18946,11 +18954,11 @@ function Jb(e = {}) {
18946
18954
  }
18947
18955
  };
18948
18956
  });
18949
- return g < Ab && (e.length > g || h) && r.push({
18957
+ return g < jb && (e.length > g || h) && r.push({
18950
18958
  id: "codex.thread.show-more",
18951
18959
  label: "Show 5 more…",
18952
18960
  run() {
18953
- g = Ab, B();
18961
+ g = jb, B();
18954
18962
  }
18955
18963
  }), r;
18956
18964
  }, B = () => {
@@ -18986,14 +18994,14 @@ function Jb(e = {}) {
18986
18994
  let e = l && p.includes(l) ? l : f;
18987
18995
  try {
18988
18996
  let t = await O({
18989
- limit: Ab,
18997
+ limit: jb,
18990
18998
  thread: e ?? void 0
18991
18999
  });
18992
19000
  m = t.threads, h = t.hasMore;
18993
19001
  } catch {
18994
19002
  m = p.map((e) => ({
18995
19003
  id: e,
18996
- title: `Codex ${Gb(e)}`,
19004
+ title: `Codex ${Kb(e)}`,
18997
19005
  updatedAt: null,
18998
19006
  connected: !0
18999
19007
  })), h = !1;
@@ -19016,7 +19024,7 @@ function Jb(e = {}) {
19016
19024
  }, te = () => {
19017
19025
  S && globalThis.clearTimeout(S), S = globalThis.setTimeout(() => {
19018
19026
  S = 0, b?.status === "completed" && (b = null, A(), B());
19019
- }, Db);
19027
+ }, Ob);
19020
19028
  }, H = async (e) => {
19021
19029
  if (!(!b || b.id !== e.id)) {
19022
19030
  if (b = {
@@ -19034,14 +19042,14 @@ function Jb(e = {}) {
19034
19042
  if (e.status === "interrupted") {
19035
19043
  A(), B();
19036
19044
  let t = e.updatedAt > 0 ? e.updatedAt : Date.now();
19037
- Date.now() - t < kb && (x = globalThis.setTimeout(() => {
19045
+ Date.now() - t < Ab && (x = globalThis.setTimeout(() => {
19038
19046
  x = 0, ne(e.id);
19039
- }, Ob));
19047
+ }, kb));
19040
19048
  return;
19041
19049
  }
19042
19050
  B(), x = globalThis.setTimeout(() => {
19043
19051
  x = 0, ne(e.id);
19044
- }, Eb);
19052
+ }, Db);
19045
19053
  }
19046
19054
  }, ne = async (e) => {
19047
19055
  if (!(w || b?.id !== e)) try {
@@ -19065,7 +19073,7 @@ function Jb(e = {}) {
19065
19073
  b = {
19066
19074
  ...b,
19067
19075
  status: "failed"
19068
- }, A(), qb(r, t) && (s = "unavailable"), B();
19076
+ }, A(), Jb(r, t) && (s = "unavailable"), B();
19069
19077
  }
19070
19078
  }, U = {
19071
19079
  health: T,
@@ -19074,7 +19082,7 @@ function Jb(e = {}) {
19074
19082
  async useThread(e) {
19075
19083
  let n = e.trim();
19076
19084
  if (!n) throw Error("Codex thread must be a non-empty string.");
19077
- let r = Vb(await Bb(t, "target", {
19085
+ let r = Hb(await Vb(t, "target", {
19078
19086
  method: "POST",
19079
19087
  headers: { "Content-Type": "application/json" },
19080
19088
  body: JSON.stringify({ thread: n })
@@ -19082,12 +19090,12 @@ function Jb(e = {}) {
19082
19090
  return j(n, !l), f = r.thread, p = r.threads, s = "available", c = !0, B(), r;
19083
19091
  },
19084
19092
  async queue(e) {
19085
- let i = await Wb(a, e, n), o = e?.thread?.trim(), c = o || (r ? k() : null);
19093
+ let i = await Gb(a, e, n), o = e?.thread?.trim(), c = o || (r ? k() : null);
19086
19094
  if (r && !o && (d || !c)) throw Error("Choose a Codex thread before queueing feedback.");
19087
19095
  let l = { message: i.message };
19088
19096
  c && (l.thread = c);
19089
19097
  try {
19090
- let e = await Bb(t, "send", {
19098
+ let e = await Vb(t, "send", {
19091
19099
  method: "POST",
19092
19100
  headers: { "Content-Type": "application/json" },
19093
19101
  body: JSON.stringify(l)
@@ -19103,14 +19111,14 @@ function Jb(e = {}) {
19103
19111
  };
19104
19112
  return e.queuedSubmissionId !== void 0 && (r.queuedSubmissionId = e.queuedSubmissionId?.trim() || null), e.dispatch !== void 0 && (r.dispatch = e.dispatch), e.dispatchError !== void 0 && (r.dispatchError = e.dispatchError?.trim() || null), r;
19105
19113
  } catch (e) {
19106
- throw r && qb(e, t) && (s = "unavailable", B()), e;
19114
+ throw r && Jb(e, t) && (s = "unavailable", B()), e;
19107
19115
  }
19108
19116
  },
19109
19117
  send(e) {
19110
19118
  return U.queue(e);
19111
19119
  }
19112
19120
  };
19113
- e.service.provide(Cb, U);
19121
+ e.service.provide(wb, U);
19114
19122
  let re = async () => {
19115
19123
  if (!(C || M())) return V(), b = {
19116
19124
  id: null,
@@ -19141,9 +19149,9 @@ function Jb(e = {}) {
19141
19149
  updatedAt: 0
19142
19150
  }) : x = globalThis.setTimeout(() => {
19143
19151
  x = 0, ne(e.deliveryId);
19144
- }, Eb) : S = globalThis.setTimeout(() => {
19152
+ }, Db) : S = globalThis.setTimeout(() => {
19145
19153
  S = 0, b?.id === null && b?.status === "queued" && (b = null, A(), B());
19146
- }, Db);
19154
+ }, Ob);
19147
19155
  } catch (e) {
19148
19156
  b = null, A(), B();
19149
19157
  let t = e instanceof Error ? e.message : String(e);
@@ -19159,7 +19167,7 @@ function Jb(e = {}) {
19159
19167
  }, 0));
19160
19168
  let t = globalThis.setInterval(() => {
19161
19169
  c && R().catch(() => void 0);
19162
- }, Tb);
19170
+ }, Eb);
19163
19171
  e.lifecycle.onDispose(() => {
19164
19172
  w = !0, V(), globalThis.clearInterval(t), _?.dispose(), _ = void 0;
19165
19173
  });
@@ -19169,12 +19177,12 @@ function Jb(e = {}) {
19169
19177
  }
19170
19178
  //#endregion
19171
19179
  //#region src/plugin-catalog.ts
19172
- var Yb = [
19180
+ var Xb = [
19173
19181
  {
19174
- id: rb,
19182
+ id: ib,
19175
19183
  label: "Context",
19176
19184
  order: 30,
19177
- create: mb,
19185
+ create: hb,
19178
19186
  settingsIds: ["context"],
19179
19187
  hiddenSettingsControlIds: ["ui"]
19180
19188
  },
@@ -19186,10 +19194,10 @@ var Yb = [
19186
19194
  settingsIds: ["arrange"]
19187
19195
  },
19188
19196
  {
19189
- id: eb,
19197
+ id: tb,
19190
19198
  label: "Layout Guides",
19191
19199
  order: 38,
19192
- create: nb
19200
+ create: rb
19193
19201
  },
19194
19202
  {
19195
19203
  id: Rv,
@@ -19203,13 +19211,13 @@ var Yb = [
19203
19211
  hiddenSettingsControlIds: ["tool"]
19204
19212
  },
19205
19213
  {
19206
- id: Sb,
19214
+ id: Cb,
19207
19215
  label: "Codex",
19208
19216
  order: 45,
19209
- create: Jb
19217
+ create: Yb
19210
19218
  }
19211
- ], Xb = (e) => {
19212
- let t = e !== void 0, n = new Map((e ?? []).map((e) => [e.id, e])), r = new Set(Yb.map((e) => e.id)), i = Yb.map((e) => {
19219
+ ], Zb = (e) => {
19220
+ let t = e !== void 0, n = new Map((e ?? []).map((e) => [e.id, e])), r = new Set(Xb.map((e) => e.id)), i = Xb.map((e) => {
19213
19221
  let r = n.get(e.id);
19214
19222
  return {
19215
19223
  ...e,
@@ -19226,16 +19234,16 @@ var Yb = [
19226
19234
  create: () => n
19227
19235
  });
19228
19236
  return i;
19229
- }, Zb = (e) => e;
19230
- function Qb() {
19237
+ }, Qb = (e) => e;
19238
+ function $b() {
19231
19239
  return zy();
19232
19240
  }
19233
- async function $b(e = {}) {
19241
+ async function ex(e = {}) {
19234
19242
  return By(e);
19235
19243
  }
19236
19244
  //#endregion
19237
19245
  //#region src/index.tsx
19238
- var ex = {
19246
+ var tx = {
19239
19247
  select: "select",
19240
19248
  xray: "xray",
19241
19249
  colorPicker: "color-picker",
@@ -19245,14 +19253,14 @@ var ex = {
19245
19253
  distance: "distance",
19246
19254
  settings: "settings"
19247
19255
  };
19248
- function tx(e = {}) {
19256
+ function nx(e = {}) {
19249
19257
  if (!("document" in globalThis)) throw Error("mountMesurer() requires a browser or Electron renderer document.");
19250
19258
  let { target: t = document.body, isolate: n = !0, shadowMode: r = "open", topLayer: i = !0, agent: a = !1, signal: o, onPluginHost: s, onPluginsReady: c, plugins: l, excludeBuiltins: u, excludePlugins: d, ...f } = e;
19251
19259
  if (o?.aborted) throw o.reason ?? new DOMException("Mesurer mount aborted.", "AbortError");
19252
19260
  if (!t) throw Error("mountMesurer() requires document.body to exist or an explicit target.");
19253
19261
  let p = t.ownerDocument ?? document, m = p.defaultView ?? window, h = p.createElement("div");
19254
19262
  h.dataset.mesurerIsland = "true";
19255
- let g = xb(h, t, i), _ = h, v = h, y = h;
19263
+ let g = Sb(h, t, i), _ = h, v = h, y = h;
19256
19264
  if (n) {
19257
19265
  let e = h.attachShadow({ mode: r });
19258
19266
  v = p.createElement("div"), v.dataset.mesurerIslandMount = "true", e.append(v), _ = e, y = e;
@@ -19275,7 +19283,7 @@ function tx(e = {}) {
19275
19283
  return t;
19276
19284
  }, N = async () => {
19277
19285
  await j.ready();
19278
- let e = b?.service.get(ib);
19286
+ let e = b?.service.get(ab);
19279
19287
  if (!e) throw Error("Mesurer Context is disabled. Enable it in Settings or include context() in plugins.");
19280
19288
  return e;
19281
19289
  }, P = async () => {
@@ -19291,7 +19299,7 @@ function tx(e = {}) {
19291
19299
  (await P()).show(e, t);
19292
19300
  }, re = async (e, t) => (await P()).capturePlan(e, t), ie = async (e, t) => (await P()).review(e, t), ae = () => j.textEdits(), oe = (e) => j.textEdit(e), se = Object.assign(j, {
19293
19301
  capabilities: () => {
19294
- let e = !!b?.service.get(ib);
19302
+ let e = !!b?.service.get(ab);
19295
19303
  return {
19296
19304
  protocol: "mesurer.agent/v1",
19297
19305
  contextSchema: "mesurer.context/v1",
@@ -19322,8 +19330,8 @@ function tx(e = {}) {
19322
19330
  }), ce = {
19323
19331
  ...f,
19324
19332
  version: Ey,
19325
- plugins: Xb(l),
19326
- excludePlugins: u ? u.map((e) => ex[e]) : [...d ?? []]
19333
+ plugins: Zb(l),
19334
+ excludePlugins: u ? u.map((e) => tx[e]) : [...d ?? []]
19327
19335
  }, le = _i(() => Rr(u_, gi(ce, {
19328
19336
  portalTarget: y,
19329
19337
  pageTarget: t,
@@ -19392,6 +19400,6 @@ function tx(e = {}) {
19392
19400
  }
19393
19401
  return _e;
19394
19402
  }
19395
- var nx = tx;
19403
+ var rx = nx;
19396
19404
  //#endregion
19397
- export { Cy as MESURER_TEXT_EDIT_SERVICE_ID, Ey as MESURER_VERSION, Gy as captureMesurerContext, $y as copyTextToClipboard, Ty as createMesurerAgentHarness, Yy as createMesurerCapturePlan, Qb as createMesurerPluginHost, $b as createMesurerRuntime, Zb as defineMesurerPlugin, Jy as formatMesurerContext, nx as mountMeasurer, tx as mountMesurer, Qy as reviewMesurerAnnotation };
19405
+ export { Cy as MESURER_TEXT_EDIT_SERVICE_ID, Ey as MESURER_VERSION, Gy as captureMesurerContext, eb as copyTextToClipboard, Ty as createMesurerAgentHarness, Yy as createMesurerCapturePlan, $b as createMesurerPluginHost, ex as createMesurerRuntime, Qb as defineMesurerPlugin, Jy as formatMesurerContext, rx as mountMeasurer, nx as mountMesurer, $y as reviewMesurerAnnotation };