@popcraft/kit 0.53.1 → 0.53.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/chunks/{agent-B4XH7FCC.js → agent-DVKYZ5MR.js} +1 -1
  2. package/dist/chunks/{builtin-3TWJNRDI.js → builtin-VDSMLZXH.js} +5 -3
  3. package/dist/chunks/{buy-credits-VZ2J2SR7.js → buy-credits-424PQFK4.js} +2 -2
  4. package/dist/chunks/{check-template-GMNQVCCI.js → check-template-E5WVEJ54.js} +4 -2
  5. package/dist/chunks/{chunk-SMF4YIFH.js → chunk-3OXHJA4W.js} +1 -1
  6. package/dist/chunks/{chunk-U3PY5BWW.js → chunk-4SD7TX7R.js} +11 -11
  7. package/dist/chunks/{chunk-MYCQCAXZ.js → chunk-4SPJEVG6.js} +4 -4
  8. package/dist/chunks/{chunk-YHQGAEC5.js → chunk-524RSKF3.js} +1 -1
  9. package/dist/chunks/{chunk-5JMMBP5Q.js → chunk-5SVFCWRP.js} +60 -101
  10. package/dist/chunks/{chunk-P5HF37GX.js → chunk-6HQI4NQA.js} +2 -2
  11. package/dist/chunks/{chunk-GNNRFMXK.js → chunk-777OZHEF.js} +9 -9
  12. package/dist/chunks/{chunk-DBGETMUH.js → chunk-7IH7U6KU.js} +4 -4
  13. package/dist/chunks/{chunk-UDUHQLOJ.js → chunk-AEVF4O3X.js} +2 -2
  14. package/dist/chunks/{chunk-MJMCMLHB.js → chunk-BKRXB4FD.js} +1 -1
  15. package/dist/chunks/{chunk-UNJ2Y726.js → chunk-FJSJT5ZM.js} +4 -4
  16. package/dist/chunks/{chunk-Z557VFSN.js → chunk-FMWUXVVS.js} +1 -1
  17. package/dist/chunks/{chunk-XMO6D5A2.js → chunk-GUGOVTVN.js} +55 -7
  18. package/dist/chunks/{chunk-IROVLB4V.js → chunk-HS4CR6HU.js} +19 -5
  19. package/dist/chunks/{chunk-XJFTD3EZ.js → chunk-JOUHQ5HK.js} +1 -1
  20. package/dist/chunks/{chunk-7CNZ5HLR.js → chunk-MQ73SYLV.js} +4 -4
  21. package/dist/chunks/{chunk-NPTJQ2AF.js → chunk-NBFZY6QK.js} +1 -1
  22. package/dist/chunks/{chunk-AJPYEZRT.js → chunk-NQPNGZ3C.js} +2 -2
  23. package/dist/chunks/{chunk-D7XGMFYM.js → chunk-ODM6DFGO.js} +4 -4
  24. package/dist/chunks/{chunk-U54RHZSX.js → chunk-OE2LGHLL.js} +3 -3
  25. package/dist/chunks/chunk-OLQTCVWP.js +92 -0
  26. package/dist/chunks/{chunk-T4FFRJAH.js → chunk-OWWBFGCR.js} +3 -3
  27. package/dist/chunks/{chunk-TCPSVZN3.js → chunk-Q23DL77U.js} +5 -5
  28. package/dist/chunks/{chunk-UT6GKZJF.js → chunk-UPLMAXNQ.js} +1 -1
  29. package/dist/chunks/{chunk-5ICU2TQ2.js → chunk-VYWXAGEE.js} +8 -8
  30. package/dist/chunks/{chunk-KPKVF2TA.js → chunk-W5KNQERV.js} +2 -2
  31. package/dist/chunks/{chunk-DFY5UNVM.js → chunk-ZLHMVVTT.js} +45 -5
  32. package/dist/chunks/{chunk-7XP5CWQO.js → chunk-ZPETEA54.js} +183 -71
  33. package/dist/chunks/{client-DNVGPZXT.js → client-2L4XUPQN.js} +1 -1
  34. package/dist/chunks/{client-SE7SVRWK.js → client-6XOD422W.js} +2 -2
  35. package/dist/chunks/{client-77HZDECD.js → client-NOHRL7S3.js} +3 -3
  36. package/dist/chunks/{client-actions-UNYIWTLI.js → client-actions-K54NVVVW.js} +13 -12
  37. package/dist/chunks/{dangerous-WMMPM5TV.js → dangerous-4QU6QUOD.js} +5 -3
  38. package/dist/chunks/{delete-current-file-WB6ZWMBO.js → delete-current-file-RMINS2BA.js} +7 -6
  39. package/dist/chunks/{editor-seams-AZ2NUX6J.js → editor-seams-SW67BCBW.js} +18 -17
  40. package/dist/chunks/{editor-store-TPVGGNLW.js → editor-store-WPRQJL2A.js} +5 -5
  41. package/dist/chunks/{export-PGMO7YEU.js → export-ILWWIDBI.js} +1 -1
  42. package/dist/chunks/{export-watermark-UGGZ5TX6.js → export-watermark-2QVKO7OR.js} +7 -6
  43. package/dist/chunks/{eyedropper-HPK6A4PE.js → eyedropper-WCIR6LL5.js} +3 -2
  44. package/dist/chunks/{generate-media-Y6MB3ENV.js → generate-media-WCNTS5OY.js} +4 -4
  45. package/dist/chunks/{host-FNER4M32.js → host-GLRRFC2S.js} +12 -11
  46. package/dist/chunks/{integrations-LPVAVUUV.js → integrations-5I6DGN6S.js} +1 -1
  47. package/dist/chunks/{libraries-I6J7YJQE.js → libraries-INCBCGOZ.js} +7 -6
  48. package/dist/chunks/{live-ZRJ2GT3E.js → live-SGBLJFAC.js} +3 -2
  49. package/dist/chunks/{lottie-CBQTJRYU.js → lottie-ZWAKIFY2.js} +4 -4
  50. package/dist/chunks/{media-tool-LTK46STY.js → media-tool-KSXO2AAJ.js} +4 -3
  51. package/dist/chunks/{new-file-XH7E3IEZ.js → new-file-56ACDQ35.js} +5 -4
  52. package/dist/chunks/{pdf-NHOWFQ66.js → pdf-HK3GJ6QP.js} +3 -3
  53. package/dist/chunks/{player-check-4LAIMR3H.js → player-check-3HTULNTP.js} +4 -4
  54. package/dist/chunks/{plugin-LAZVW4F4.js → plugin-GJXXN4UQ.js} +4 -2
  55. package/dist/chunks/{plugin-import-P4PD76X3.js → plugin-import-N2J7NVET.js} +23 -22
  56. package/dist/chunks/{pptx-LHJRZA42.js → pptx-O7RRDHAR.js} +2 -2
  57. package/dist/chunks/{presence-WSPF6N32.js → presence-S6FAMSP4.js} +4 -3
  58. package/dist/chunks/{project-M3KF66GG.js → project-IH23X2UG.js} +3 -3
  59. package/dist/chunks/{publish-site-PUHKHZF4.js → publish-site-7YFHE7PV.js} +8 -7
  60. package/dist/chunks/{publish-store-PZMIV6LJ.js → publish-store-I3NKMHZK.js} +5 -5
  61. package/dist/chunks/{raster-actions-NS2NSYLC.js → raster-actions-PRMIAQQ7.js} +3 -2
  62. package/dist/chunks/{reference-images-CYSRQG7A.js → reference-images-TAWHPRYN.js} +2 -2
  63. package/dist/chunks/{resolvers-BQ5WXLUC.js → resolvers-UTQHZ6ET.js} +5 -5
  64. package/dist/chunks/{runner-PGFSW23U.js → runner-OVYUXA4W.js} +30 -24
  65. package/dist/chunks/{store-BXDDRMK7.js → store-BYSDY5PO.js} +14 -13
  66. package/dist/chunks/{storefront-prepare-EXR7OIWW.js → storefront-prepare-6IUMZTCQ.js} +1 -1
  67. package/dist/chunks/{svg-export-J2YVV3WM.js → svg-export-LMGINUQK.js} +5 -5
  68. package/dist/chunks/{svg-place-ZAG7VYF6.js → svg-place-LWB4XU2O.js} +2 -1
  69. package/dist/chunks/{sync-4AHF7NWR.js → sync-TFB3VWFP.js} +7 -6
  70. package/dist/chunks/{tabs-KFQNMNUM.js → tabs-CNE4XGIM.js} +10 -9
  71. package/dist/chunks/{team-QUBELR4W.js → team-DFOKEFOE.js} +1 -1
  72. package/dist/chunks/{team-client-NCOTLKC5.js → team-client-QHRXYUPI.js} +1 -1
  73. package/dist/chunks/{tools-T5XCKKCW.js → tools-YDR7QIHQ.js} +4 -2
  74. package/dist/chunks/{ui-commands-77JZN35K.js → ui-commands-HB4FFFXA.js} +20 -19
  75. package/dist/chunks/{versions-5HYBXUPA.js → versions-G4PGAFLF.js} +7 -6
  76. package/dist/index.js +1 -1
  77. package/package.json +1 -1
@@ -40,7 +40,7 @@ async function underReviewKit(doc, kit) {
40
40
  return settleMeasuredLayout({ ...kitted, nodes });
41
41
  }
42
42
  async function renderDocument(doc, nodeIds, options) {
43
- const { selectionReferenceImages } = await import("./reference-images-CYSRQG7A.js");
43
+ const { selectionReferenceImages } = await import("./reference-images-TAWHPRYN.js");
44
44
  if (options?.kit) {
45
45
  doc = await underReviewKit(doc, options.kit);
46
46
  }
@@ -57,19 +57,19 @@ async function renderDocument(doc, nodeIds, options) {
57
57
  function generateCapability(ctx) {
58
58
  return async (prompt, options = {}) => {
59
59
  if (options.format === "audio") {
60
- const { requestAudio } = await import("./client-77HZDECD.js");
60
+ const { requestAudio } = await import("./client-NOHRL7S3.js");
61
61
  const { signal: signal2, format: _f, ...rest2 } = options;
62
62
  void _f;
63
63
  return requestAudio({ prompt, ...rest2 }, signal2 ?? ctx.signal);
64
64
  }
65
65
  if (options.format === "video") {
66
- const { generateVideoFile } = await import("./generate-media-Y6MB3ENV.js");
66
+ const { generateVideoFile } = await import("./generate-media-WCNTS5OY.js");
67
67
  const { format: _f, signal: signal2, ...rest2 } = options;
68
68
  void _f;
69
69
  return generateVideoFile({ ...rest2, prompt, doc: ctx.doc() }, { signal: signal2 ?? ctx.signal });
70
70
  }
71
71
  const [{ requestImage }, { effectiveImageModel, useAiStore }] = await Promise.all([
72
- import("./client-77HZDECD.js"),
72
+ import("./client-NOHRL7S3.js"),
73
73
  import("./client-store-3YCO6KV5.js")
74
74
  ]);
75
75
  const modelId = effectiveImageModel(useAiStore.getState());
@@ -150,7 +150,7 @@ function startHyperyTeams() {
150
150
  maybePromptForTeam();
151
151
  void followFileTeam(linkedKey);
152
152
  });
153
- void import("./sync-4AHF7NWR.js").then(({ onSyncStatus, syncStatus }) => {
153
+ void import("./sync-TFB3VWFP.js").then(({ onSyncStatus, syncStatus }) => {
154
154
  linkedKey = syncStatus().link?.key ?? null;
155
155
  void followFileTeam(linkedKey);
156
156
  onSyncStatus((_s, link) => {
@@ -1744,12 +1744,59 @@ var require_polygon_clipping_cjs = __commonJS({
1744
1744
 
1745
1745
  // lib/engine/vector-geometry-cache.ts
1746
1746
  init_define_POPCRAFT_COMPONENT_IDS();
1747
- var import_polygon_clipping2 = __toESM(require_polygon_clipping_cjs());
1747
+ var import_polygon_clipping3 = __toESM(require_polygon_clipping_cjs());
1748
1748
  init_flatten();
1749
1749
 
1750
1750
  // lib/engine/geometry/triangulate.ts
1751
1751
  init_define_POPCRAFT_COMPONENT_IDS();
1752
+ var import_polygon_clipping2 = __toESM(require_polygon_clipping_cjs());
1753
+
1754
+ // lib/engine/geometry/winding.ts
1755
+ init_define_POPCRAFT_COMPONENT_IDS();
1752
1756
  var import_polygon_clipping = __toESM(require_polygon_clipping_cjs());
1757
+ var signedArea = (r) => {
1758
+ let a = 0;
1759
+ for (let i = 0, j = r.length - 1; i < r.length; j = i++) a += (r[j][0] - r[i][0]) * (r[j][1] + r[i][1]);
1760
+ return a / 2;
1761
+ };
1762
+ var inside = ([x, y], r) => {
1763
+ let c = false;
1764
+ for (let i = 0, j = r.length - 1; i < r.length; j = i++) {
1765
+ const [xi, yi] = r[i], [xj, yj] = r[j];
1766
+ if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) c = !c;
1767
+ }
1768
+ return c;
1769
+ };
1770
+ function interiorPoint(r) {
1771
+ let cx = 0, cy = 0;
1772
+ for (const [x, y] of r) {
1773
+ cx += x;
1774
+ cy += y;
1775
+ }
1776
+ const centroid = [cx / r.length, cy / r.length];
1777
+ if (inside(centroid, r)) return centroid;
1778
+ const [a, b, c] = [r[0], r[1], r[2] ?? r[0]];
1779
+ return [(a[0] + b[0] + c[0]) / 3, (a[1] + b[1] + c[1]) / 3];
1780
+ }
1781
+ function nonzeroMultiPoly(rings) {
1782
+ const usable = rings.filter((r) => r.length >= 3);
1783
+ if (!usable.length) return [];
1784
+ const polys = usable.map((r) => [r]);
1785
+ if (usable.length === 1) return import_polygon_clipping.default.union(polys[0]);
1786
+ const areas = usable.map(signedArea);
1787
+ const add = [], sub = [];
1788
+ usable.forEach((r, i) => {
1789
+ const p = interiorPoint(r);
1790
+ let w = Math.sign(areas[i]);
1791
+ usable.forEach((o, j) => {
1792
+ if (j !== i && Math.abs(areas[j]) > Math.abs(areas[i]) && inside(p, o)) w += Math.sign(areas[j]);
1793
+ });
1794
+ (w === 0 ? sub : add).push(polys[i]);
1795
+ });
1796
+ if (!add.length) return [];
1797
+ const filled = import_polygon_clipping.default.union(add[0], ...add.slice(1));
1798
+ return sub.length ? import_polygon_clipping.default.difference(filled, ...sub) : filled;
1799
+ }
1753
1800
 
1754
1801
  // lib/engine/vector-geometry-cache.ts
1755
1802
  init_shape_outline();
@@ -1771,7 +1818,7 @@ function computeBooleanMultiPoly(node, allNodes) {
1771
1818
  const asPolys = rings.map((r) => [r]);
1772
1819
  let mp;
1773
1820
  try {
1774
- mp = asPolys.length > 1 ? import_polygon_clipping2.default.union(asPolys[0], ...asPolys.slice(1)) : asPolys;
1821
+ mp = asPolys.length > 1 ? import_polygon_clipping3.default.union(asPolys[0], ...asPolys.slice(1)) : asPolys;
1775
1822
  } catch {
1776
1823
  mp = asPolys;
1777
1824
  }
@@ -1783,14 +1830,14 @@ function computeBooleanMultiPoly(node, allNodes) {
1783
1830
  try {
1784
1831
  const rest = operands.slice(1);
1785
1832
  if (rest.length > 0) {
1786
- if (op === "SUBTRACT") result = import_polygon_clipping2.default.difference(operands[0], ...rest);
1787
- else if (op === "INTERSECT") result = import_polygon_clipping2.default.intersection(operands[0], ...rest);
1788
- else if (op === "EXCLUDE") result = import_polygon_clipping2.default.xor(operands[0], ...rest);
1789
- else result = import_polygon_clipping2.default.union(operands[0], ...rest);
1833
+ if (op === "SUBTRACT") result = import_polygon_clipping3.default.difference(operands[0], ...rest);
1834
+ else if (op === "INTERSECT") result = import_polygon_clipping3.default.intersection(operands[0], ...rest);
1835
+ else if (op === "EXCLUDE") result = import_polygon_clipping3.default.xor(operands[0], ...rest);
1836
+ else result = import_polygon_clipping3.default.union(operands[0], ...rest);
1790
1837
  }
1791
1838
  } catch {
1792
1839
  try {
1793
- result = import_polygon_clipping2.default.union(operands[0], ...operands.slice(1));
1840
+ result = import_polygon_clipping3.default.union(operands[0], ...operands.slice(1));
1794
1841
  } catch {
1795
1842
  result = operands[0];
1796
1843
  }
@@ -1800,5 +1847,6 @@ function computeBooleanMultiPoly(node, allNodes) {
1800
1847
 
1801
1848
  export {
1802
1849
  require_polygon_clipping_cjs,
1850
+ nonzeroMultiPoly,
1803
1851
  computeBooleanMultiPoly
1804
1852
  };
@@ -4,6 +4,9 @@ import { dirname as __popcraftDirname } from 'node:path';
4
4
  const require = __popcraftRequire(import.meta.url);
5
5
  const __filename = __popcraftPath(import.meta.url);
6
6
  const __dirname = __popcraftDirname(__filename);
7
+ import {
8
+ scaleSubtreePatches
9
+ } from "./chunk-OLQTCVWP.js";
7
10
  import {
8
11
  importSVG
9
12
  } from "./chunk-7DATU5VX.js";
@@ -45,11 +48,22 @@ function placeSvgLayers(doc, parentId, svg, place) {
45
48
  if (n.type === "IMAGE" && !doc.nodes[n.id] && url?.startsWith("data:")) nodes[n.id] = { ...n, imageUrl: place.intern(url) };
46
49
  }
47
50
  }
48
- const minX = Math.min(...kids.map((k) => k.x)), minY = Math.min(...kids.map((k) => k.y));
49
- const maxX = Math.max(...kids.map((k) => k.x + k.width)), maxY = Math.max(...kids.map((k) => k.y + k.height));
50
- for (const k of kids) nodes[k.id] = { ...nodes[k.id], x: k.x - minX, y: k.y - minY };
51
- const w = Math.max(1, maxX - minX), h = Math.max(1, maxY - minY);
52
- nodes[frame.id] = { ...nodes[frame.id], x: Math.round(place.cx - w / 2), y: Math.round(place.cy - h / 2), width: w, height: h };
51
+ const minX = Math.min(...kids.map((k2) => k2.x)), minY = Math.min(...kids.map((k2) => k2.y));
52
+ const maxX = Math.max(...kids.map((k2) => k2.x + k2.width)), maxY = Math.max(...kids.map((k2) => k2.y + k2.height));
53
+ for (const k2 of kids) nodes[k2.id] = { ...nodes[k2.id], x: k2.x - minX, y: k2.y - minY };
54
+ let w = Math.max(1, maxX - minX), h = Math.max(1, maxY - minY);
55
+ const f = place.fit;
56
+ const k = f && (f.width || f.height) ? Math.min(f.width ? f.width / w : Infinity, f.height ? f.height / h : Infinity) : 1;
57
+ if (k !== 1 && Number.isFinite(k) && k > 0) {
58
+ const wrapper = { childIds: kids.map((c) => c.id) };
59
+ for (const [id, patch] of scaleSubtreePatches({ ...nodes, [frame.id]: { ...nodes[frame.id], ...wrapper } }, frame.id, k, k, false)) {
60
+ nodes[id] = { ...nodes[id], ...patch };
61
+ }
62
+ w *= k;
63
+ h *= k;
64
+ }
65
+ const topLeft = place.anchor === "top-left";
66
+ nodes[frame.id] = { ...nodes[frame.id], x: Math.round(topLeft ? place.cx : place.cx - w / 2), y: Math.round(topLeft ? place.cy : place.cy - h / 2), width: w, height: h };
53
67
  return { doc: { ...next, nodes }, id: frame.id };
54
68
  }
55
69
 
@@ -6,7 +6,7 @@ const __filename = __popcraftPath(import.meta.url);
6
6
  const __dirname = __popcraftDirname(__filename);
7
7
  import {
8
8
  useEditorStore
9
- } from "./chunk-5JMMBP5Q.js";
9
+ } from "./chunk-5SVFCWRP.js";
10
10
  import {
11
11
  announce
12
12
  } from "./chunk-DV7XWPVL.js";
@@ -9,7 +9,7 @@ import {
9
9
  hostEnv,
10
10
  plain,
11
11
  registerBuiltinCommands
12
- } from "./chunk-7XP5CWQO.js";
12
+ } from "./chunk-ZPETEA54.js";
13
13
  import {
14
14
  storeOpsSeam
15
15
  } from "./chunk-KOAEKWIA.js";
@@ -613,9 +613,9 @@ var commands = [
613
613
  // saves (the Ecommerce plugin's Shopify theme), so a target is written once, here, and never again in a plugin.
614
614
  run: async (p, ctx) => {
615
615
  const [{ storefrontInputs }, { STOREFRONT_TARGETS }, { bytesOf }, { zipFiles }, { EXPORT_NODE_CAP }] = await Promise.all([
616
- import("./storefront-prepare-EXR7OIWW.js"),
616
+ import("./storefront-prepare-6IUMZTCQ.js"),
617
617
  import("./storefront-BPMM6QWK.js"),
618
- import("./project-M3KF66GG.js"),
618
+ import("./project-IH23X2UG.js"),
619
619
  import("./zip-export-ZYXDK4SM.js"),
620
620
  import("./tree-YKYXBPRZ.js")
621
621
  ]);
@@ -812,7 +812,7 @@ var pluginRun = defineCommand({
812
812
  }
813
813
  },
814
814
  run: async (p, ctx) => {
815
- const { runPlugin } = await import("./host-FNER4M32.js");
815
+ const { runPlugin } = await import("./host-GLRRFC2S.js");
816
816
  await runPlugin(p.pluginId, p.commandId);
817
817
  ctx.notice(`Started ${p.pluginId}.`);
818
818
  return {
@@ -6,7 +6,7 @@ const __filename = __popcraftPath(import.meta.url);
6
6
  const __dirname = __popcraftDirname(__filename);
7
7
  import {
8
8
  computeBooleanMultiPoly
9
- } from "./chunk-XMO6D5A2.js";
9
+ } from "./chunk-GUGOVTVN.js";
10
10
  import {
11
11
  glyphOutline,
12
12
  init_text_rings
@@ -91,9 +91,9 @@ async function placeStockPhoto(photo, opts = {}) {
91
91
  }
92
92
  async function placePicture(imported, opts = {}) {
93
93
  const [{ useEditorStore }, { photoFrameOf }, { placeImage }] = await Promise.all([
94
- import("./editor-store-TPVGGNLW.js"),
94
+ import("./editor-store-WPRQJL2A.js"),
95
95
  import("../lib/document/photo-frames.js"),
96
- import("./media-tool-LTK46STY.js")
96
+ import("./media-tool-KSXO2AAJ.js")
97
97
  ]);
98
98
  const st = useEditorStore.getState();
99
99
  const frame = photoFrameOf(st.document.nodes, opts.targetId !== void 0 ? opts.targetId : st.selection[0] ?? null);
@@ -20,14 +20,14 @@ import {
20
20
  } from "./chunk-U7FLEMSS.js";
21
21
  import {
22
22
  notice
23
- } from "./chunk-TCPSVZN3.js";
23
+ } from "./chunk-Q23DL77U.js";
24
24
  import {
25
25
  agentContext
26
- } from "./chunk-UNJ2Y726.js";
26
+ } from "./chunk-FJSJT5ZM.js";
27
27
  import {
28
28
  collabSession,
29
29
  syncStatus
30
- } from "./chunk-DBGETMUH.js";
30
+ } from "./chunk-7IH7U6KU.js";
31
31
  import {
32
32
  loadEntitlements
33
33
  } from "./chunk-7SMURRFY.js";
@@ -36,7 +36,7 @@ import {
36
36
  } from "./chunk-KWUXHRXD.js";
37
37
  import {
38
38
  useEditorStore
39
- } from "./chunk-5JMMBP5Q.js";
39
+ } from "./chunk-5SVFCWRP.js";
40
40
  import {
41
41
  getActiveRenderer
42
42
  } from "./chunk-CEVTHE4E.js";
@@ -127,7 +127,7 @@ async function copyNodeAsPNG(renderer, node, doc, styles, scale = 2) {
127
127
  }
128
128
  async function copyNodeAsSVG(renderer, node, doc, styles) {
129
129
  try {
130
- const { exportNodeToSVG } = await import("./svg-export-J2YVV3WM.js");
130
+ const { exportNodeToSVG } = await import("./svg-export-LMGINUQK.js");
131
131
  const svg = await exportNodeToSVG(renderer, node, doc, styles);
132
132
  if (!svg) return false;
133
133
  await navigator.clipboard.writeText(svg);
@@ -149,12 +149,12 @@ async function exportSettingFile(renderer, node, setting, doc, styles) {
149
149
  return blob ? { name, blob } : null;
150
150
  }
151
151
  if (setting.format === "SVG") {
152
- const { exportNodeToSVG } = await import("./svg-export-J2YVV3WM.js");
152
+ const { exportNodeToSVG } = await import("./svg-export-LMGINUQK.js");
153
153
  const svg = await exportNodeToSVG(renderer, node, doc, styles);
154
154
  return svg ? { name, blob: new Blob([svg], { type: "image/svg+xml" }) } : null;
155
155
  }
156
156
  if (setting.format === "PDF") {
157
- const { exportNodeToPDF, pdfOptionsFor } = await import("./pdf-NHOWFQ66.js");
157
+ const { exportNodeToPDF, pdfOptionsFor } = await import("./pdf-HK3GJ6QP.js");
158
158
  const blob = await exportNodeToPDF(renderer, node, pdfOptionsFor(setting), doc, styles);
159
159
  return blob ? { name, blob } : null;
160
160
  }
@@ -0,0 +1,92 @@
1
+ import { createRequire as __popcraftRequire } from 'node:module';
2
+ import { fileURLToPath as __popcraftPath } from 'node:url';
3
+ import { dirname as __popcraftDirname } from 'node:path';
4
+ const require = __popcraftRequire(import.meta.url);
5
+ const __filename = __popcraftPath(import.meta.url);
6
+ const __dirname = __popcraftDirname(__filename);
7
+ import {
8
+ init_define_POPCRAFT_COMPONENT_IDS
9
+ } from "./chunk-WKDVCZ45.js";
10
+
11
+ // lib/document/scale-geometry.ts
12
+ init_define_POPCRAFT_COMPONENT_IDS();
13
+ var scalePoint = (p, sx, sy) => ({
14
+ ...p,
15
+ x: p.x * sx,
16
+ y: p.y * sy,
17
+ // Bezier handles live in the same space as the point and have to scale with it, or a stretched curve
18
+ // keeps its original curvature and bulges out of the shape.
19
+ handleIn: p.handleIn ? { x: p.handleIn.x * sx, y: p.handleIn.y * sy } : void 0,
20
+ handleOut: p.handleOut ? { x: p.handleOut.x * sx, y: p.handleOut.y * sy } : void 0
21
+ });
22
+ function scaleVectorPaths(paths, sx, sy, rebuild) {
23
+ if (!paths?.length || sx === 1 && sy === 1) return paths;
24
+ return paths.map((path) => {
25
+ const points = path.points.map((p) => scalePoint(p, sx, sy));
26
+ return { ...path, points, data: rebuild(points, path.closed) };
27
+ });
28
+ }
29
+ function scaledChildProps(orig, sx, sy, rebuild) {
30
+ return {
31
+ x: orig.x * sx,
32
+ y: orig.y * sy,
33
+ width: orig.width * sx,
34
+ height: orig.height * sy,
35
+ ...orig.type === "VECTOR" ? { paths: scaleVectorPaths(orig.paths, sx, sy, rebuild) } : {}
36
+ };
37
+ }
38
+ function rebuildVectorData(points, closed) {
39
+ if (points.length < 2) return [];
40
+ const data = [];
41
+ data.push("M", points[0].x, points[0].y);
42
+ for (let i = 1; i < points.length; i++) {
43
+ const prev = points[i - 1];
44
+ const curr = points[i];
45
+ if (prev.handleOut && curr.handleIn) {
46
+ data.push("C", prev.handleOut.x, prev.handleOut.y, curr.handleIn.x, curr.handleIn.y, curr.x, curr.y);
47
+ } else if (prev.handleOut) {
48
+ data.push("Q", prev.handleOut.x, prev.handleOut.y, curr.x, curr.y);
49
+ } else if (curr.handleIn) {
50
+ data.push("Q", curr.handleIn.x, curr.handleIn.y, curr.x, curr.y);
51
+ } else {
52
+ data.push("L", curr.x, curr.y);
53
+ }
54
+ }
55
+ if (closed) {
56
+ const prev = points[points.length - 1];
57
+ const curr = points[0];
58
+ if (prev.handleOut && curr.handleIn) {
59
+ data.push("C", prev.handleOut.x, prev.handleOut.y, curr.handleIn.x, curr.handleIn.y, curr.x, curr.y);
60
+ } else if (prev.handleOut) {
61
+ data.push("Q", prev.handleOut.x, prev.handleOut.y, curr.x, curr.y);
62
+ } else if (curr.handleIn) {
63
+ data.push("Q", curr.handleIn.x, curr.handleIn.y, curr.x, curr.y);
64
+ }
65
+ data.push("Z");
66
+ }
67
+ return data;
68
+ }
69
+ function scaleSubtreePatches(nodes, id, sx, sy, includeSelf = true) {
70
+ const out = /* @__PURE__ */ new Map();
71
+ const root = nodes[id];
72
+ if (!root || sx === 1 && sy === 1) return out;
73
+ if (includeSelf && root.type === "VECTOR") out.set(id, { paths: scaleVectorPaths(root.paths, sx, sy, rebuildVectorData) });
74
+ const walk = (parent) => {
75
+ for (const cid of parent.childIds ?? []) {
76
+ const c = nodes[cid];
77
+ if (!c) continue;
78
+ const patch = { ...scaledChildProps(c, sx, sy, rebuildVectorData) };
79
+ if (c.type === "TEXT") patch.fontSize = (c.fontSize ?? 16) * Math.min(sx, sy);
80
+ out.set(cid, patch);
81
+ walk(c);
82
+ }
83
+ };
84
+ if (root.type === "GROUP" || root.type === "BOOLEAN" || !includeSelf) walk(root);
85
+ return out;
86
+ }
87
+
88
+ export {
89
+ scaleVectorPaths,
90
+ rebuildVectorData,
91
+ scaleSubtreePatches
92
+ };
@@ -15,7 +15,7 @@ import {
15
15
  layoutText,
16
16
  resolveThreadNode,
17
17
  rootMatrix
18
- } from "./chunk-MJMCMLHB.js";
18
+ } from "./chunk-BKRXB4FD.js";
19
19
  import {
20
20
  attachTextPath,
21
21
  polylineOf,
@@ -30,14 +30,14 @@ import {
30
30
  toSvgD,
31
31
  trimCmds,
32
32
  vectorCmds
33
- } from "./chunk-NPTJQ2AF.js";
33
+ } from "./chunk-NBFZY6QK.js";
34
34
  import {
35
35
  strokeBehindFill
36
36
  } from "./chunk-YZKSEJHZ.js";
37
37
  import {
38
38
  encodeImageData,
39
39
  sliceRegion
40
- } from "./chunk-U54RHZSX.js";
40
+ } from "./chunk-OE2LGHLL.js";
41
41
  import {
42
42
  documentForExport
43
43
  } from "./chunk-T4R6MNN5.js";
@@ -16,22 +16,22 @@ import {
16
16
  requestImageAction,
17
17
  sizeForAspect,
18
18
  vectorSupport
19
- } from "./chunk-YHQGAEC5.js";
19
+ } from "./chunk-524RSKF3.js";
20
20
  import {
21
21
  external_exports
22
22
  } from "./chunk-VOOUF5TT.js";
23
23
  import {
24
24
  placeSvgLayers
25
- } from "./chunk-IROVLB4V.js";
25
+ } from "./chunk-HS4CR6HU.js";
26
26
  import {
27
27
  exportNodeToSVG
28
- } from "./chunk-T4FFRJAH.js";
28
+ } from "./chunk-OWWBFGCR.js";
29
29
  import {
30
30
  selectionReferenceImages
31
- } from "./chunk-SMF4YIFH.js";
31
+ } from "./chunk-3OXHJA4W.js";
32
32
  import {
33
33
  useEditorStore
34
- } from "./chunk-5JMMBP5Q.js";
34
+ } from "./chunk-5SVFCWRP.js";
35
35
  import {
36
36
  withHistoryGroup
37
37
  } from "./chunk-76I6DIEM.js";
@@ -11,7 +11,7 @@ import {
11
11
  activeHyperyTeamId,
12
12
  activeTeamWorkspaceId,
13
13
  useHyperyTeam
14
- } from "./chunk-Z557VFSN.js";
14
+ } from "./chunk-FMWUXVVS.js";
15
15
  import {
16
16
  inAppPurchases
17
17
  } from "./chunk-KWUXHRXD.js";
@@ -15,20 +15,20 @@ import {
15
15
  } from "./chunk-ZYK65XJJ.js";
16
16
  import {
17
17
  syncStatus
18
- } from "./chunk-DBGETMUH.js";
18
+ } from "./chunk-7IH7U6KU.js";
19
19
  import {
20
20
  exportNodeToSVG
21
- } from "./chunk-T4FFRJAH.js";
21
+ } from "./chunk-OWWBFGCR.js";
22
22
  import {
23
23
  exportNodeToBlob
24
- } from "./chunk-U54RHZSX.js";
24
+ } from "./chunk-OE2LGHLL.js";
25
25
  import {
26
26
  usePluginStore
27
27
  } from "./chunk-RJHJSADV.js";
28
28
  import {
29
29
  setPluginTabs,
30
30
  useEditorStore
31
- } from "./chunk-5JMMBP5Q.js";
31
+ } from "./chunk-5SVFCWRP.js";
32
32
  import {
33
33
  openBeside
34
34
  } from "./chunk-PMLSPVLR.js";
@@ -69,7 +69,7 @@ init_define_POPCRAFT_COMPONENT_IDS();
69
69
  // lib/plugins/api.ts
70
70
  init_define_POPCRAFT_COMPONENT_IDS();
71
71
  async function handlePluginCall(env, method, params = {}) {
72
- const { dispatchPluginCall } = await import("./plugin-LAZVW4F4.js");
72
+ const { dispatchPluginCall } = await import("./plugin-GJXXN4UQ.js");
73
73
  return dispatchPluginCall(env, method, params);
74
74
  }
75
75
 
@@ -579,7 +579,7 @@ async function runPlugin(pluginId, commandId, opts = {}) {
579
579
  if (!openBeside(url)) throw new Error("The browser blocked the new tab");
580
580
  },
581
581
  createDocument: async (opts2) => {
582
- const { createFreshFileOrExplain } = await import("./new-file-XH7E3IEZ.js");
582
+ const { createFreshFileOrExplain } = await import("./new-file-56ACDQ35.js");
583
583
  const created = await createFreshFileOrExplain({}, { name: opts2?.name });
584
584
  if (!created.ok) throw new Error(created.reason === "plan" ? "Plan limit reached" : created.reason === "guest-limit" ? "Sign in to create another file" : `Could not create file (${created.reason})`);
585
585
  await useEditorStore.getState().openDocument(created.docId);
@@ -600,7 +600,7 @@ async function runPlugin(pluginId, commandId, opts = {}) {
600
600
  const st = useEditorStore.getState();
601
601
  const node = nodes[0];
602
602
  if (format === "PDF") {
603
- const { exportNodesToPDF } = await import("./pdf-NHOWFQ66.js");
603
+ const { exportNodesToPDF } = await import("./pdf-HK3GJ6QP.js");
604
604
  const { jobPageSize } = await import("../lib/document/print-pages.js");
605
605
  const { loadFullBleed } = await import("./print-prefs-XQJ4IJYZ.js");
606
606
  const blob2 = await exportNodesToPDF(renderer, nodes, { dpi: 300, bleed: !loadFullBleed(), marks: false, splitSpreads: true, pageSize: jobPageSize(st.document) }, st.document, st.document.styles);
@@ -769,7 +769,7 @@ if (typeof window !== "undefined") {
769
769
  const name = d.name || "Imported";
770
770
  void (async () => {
771
771
  try {
772
- const { importViaPlugin, applyPluginLayoutIr } = await import("./plugin-import-P4PD76X3.js");
772
+ const { importViaPlugin, applyPluginLayoutIr } = await import("./plugin-import-N2J7NVET.js");
773
773
  if (d.ir && typeof d.ir === "object") {
774
774
  await applyPluginLayoutIr(d.ir, { mode, name });
775
775
  return;
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-7SMURRFY.js";
10
10
  import {
11
11
  activeTeamWorkspaceId
12
- } from "./chunk-Z557VFSN.js";
12
+ } from "./chunk-FMWUXVVS.js";
13
13
  import {
14
14
  ApiError,
15
15
  GUEST_FILE_LIMIT,
@@ -23,7 +23,7 @@ import {
23
23
  } from "./chunk-TZQJDYMB.js";
24
24
  import {
25
25
  markLibraryDocument
26
- } from "./chunk-5JMMBP5Q.js";
26
+ } from "./chunk-5SVFCWRP.js";
27
27
  import {
28
28
  create
29
29
  } from "./chunk-QLJLPV5R.js";
@@ -13,7 +13,7 @@ import {
13
13
  agentTool,
14
14
  agentToolList,
15
15
  registerCommands
16
- } from "./chunk-UNJ2Y726.js";
16
+ } from "./chunk-FJSJT5ZM.js";
17
17
  import {
18
18
  dispatch
19
19
  } from "./chunk-OQZFD4BD.js";
@@ -58,14 +58,53 @@ function toolSpecs(names) {
58
58
  function: { name: t.name, description: t.description, parameters: toolParameters(t.parameters) }
59
59
  }));
60
60
  }
61
+ function parseToolArgs(text) {
62
+ try {
63
+ return JSON.parse(text);
64
+ } catch {
65
+ }
66
+ let depth = 0, inStr = false, esc = false;
67
+ const stack = [];
68
+ for (let i = 0; i < text.length; i++) {
69
+ const c = text[i];
70
+ if (inStr) {
71
+ if (esc) esc = false;
72
+ else if (c === "\\") esc = true;
73
+ else if (c === '"') inStr = false;
74
+ continue;
75
+ }
76
+ if (c === '"') inStr = true;
77
+ else if (c === "{" || c === "[") {
78
+ stack.push(c === "{" ? "}" : "]");
79
+ depth++;
80
+ } else if (c === "}" || c === "]") {
81
+ stack.pop();
82
+ depth--;
83
+ if (depth === 0) {
84
+ try {
85
+ return JSON.parse(text.slice(0, i + 1));
86
+ } catch {
87
+ return void 0;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ if (!stack.length) return void 0;
93
+ try {
94
+ return JSON.parse(text + (inStr ? '"' : "") + stack.reverse().join(""));
95
+ } catch {
96
+ return void 0;
97
+ }
98
+ }
61
99
  async function runTool(name, argsText, ctx) {
62
100
  let raw = {};
63
101
  if (argsText.trim()) {
64
- try {
65
- raw = JSON.parse(argsText);
66
- } catch {
67
- throw new ToolError(`The arguments for ${name} were not valid JSON.`, "invalid_params");
102
+ const parsed = parseToolArgs(argsText);
103
+ if (parsed === void 0) {
104
+ console.warn(`[agent] unparseable arguments for ${name}:`, argsText.slice(0, 500));
105
+ throw new ToolError(`The arguments for ${name} were not valid JSON. Send one JSON object.`, "invalid_params");
68
106
  }
107
+ raw = parsed;
69
108
  }
70
109
  return dispatch(name, {
71
110
  surface: "agent",
@@ -86,5 +125,6 @@ export {
86
125
  getTool,
87
126
  allTools,
88
127
  toolSpecs,
128
+ parseToolArgs,
89
129
  runTool
90
130
  };