@weasel-js/core 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +9 -5
  3. package/dist/animation/useAnimator.js +20 -13
  4. package/dist/animation/useAnimator.js.map +1 -1
  5. package/dist/{builtins-BW32dOXy.d.ts → builtins-CQcvcLXh.d.ts} +105 -31
  6. package/dist/canvas/DrawCanvas.js +33 -33
  7. package/dist/canvas/DrawCanvas.js.map +1 -1
  8. package/dist/canvas/MinimapCanvas.js +29 -29
  9. package/dist/canvas/MinimapCanvas.js.map +1 -1
  10. package/dist/canvas/NodeShape.js +63 -54
  11. package/dist/canvas/NodeShape.js.map +1 -1
  12. package/dist/canvas/SceneCanvas/features.js +26 -5
  13. package/dist/canvas/SceneCanvas/features.js.map +1 -1
  14. package/dist/canvas/SceneCanvas/useSceneSelectTool.js +3 -2
  15. package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
  16. package/dist/canvas/SceneCanvas.js +526 -529
  17. package/dist/canvas/SceneCanvas.js.map +1 -1
  18. package/dist/canvas/SceneViewCanvas.js +35 -35
  19. package/dist/canvas/SceneViewCanvas.js.map +1 -1
  20. package/dist/canvas/defaultDrawOne.js +6 -1
  21. package/dist/canvas/defaultDrawOne.js.map +1 -1
  22. package/dist/canvas/pickWalk.js.map +1 -1
  23. package/dist/canvas/sceneAdapter.js.map +1 -1
  24. package/dist/canvas/useHitObserver.js +23 -0
  25. package/dist/canvas/useHitObserver.js.map +1 -0
  26. package/dist/canvas/useHostAnchor.js.map +1 -1
  27. package/dist/core/device/useDeviceProfile.js.map +1 -1
  28. package/dist/core/scene/derivedPath.js.map +1 -1
  29. package/dist/core/scene/effectivePose.js.map +1 -1
  30. package/dist/core/scene/kitRegistry.js.map +1 -1
  31. package/dist/core/scene/scene.js +9 -0
  32. package/dist/core/scene/scene.js.map +1 -1
  33. package/dist/core/scene/types.js.map +1 -1
  34. package/dist/core/scene/useScene.js.map +1 -1
  35. package/dist/core/selection/useSelection.js +27 -33
  36. package/dist/core/selection/useSelection.js.map +1 -1
  37. package/dist/core/stableStringify.js +8 -0
  38. package/dist/core/stableStringify.js.map +1 -0
  39. package/dist/core/viewport/fitViewToBounds.js +3 -3
  40. package/dist/core/viewport/fitViewToBounds.js.map +1 -1
  41. package/dist/core/viewport/screenSlop.js +8 -2
  42. package/dist/core/viewport/screenSlop.js.map +1 -1
  43. package/dist/features/minimap/actions.js.map +1 -1
  44. package/dist/features/paths/markerCommands.js +95 -63
  45. package/dist/features/paths/markerCommands.js.map +1 -1
  46. package/dist/features/paths/tessellate/dash.js +52 -0
  47. package/dist/features/paths/tessellate/dash.js.map +1 -0
  48. package/dist/features/paths/tessellate/insets.js +32 -0
  49. package/dist/features/paths/tessellate/insets.js.map +1 -0
  50. package/dist/features/paths/tessellate/metric.js +72 -0
  51. package/dist/features/paths/tessellate/metric.js.map +1 -0
  52. package/dist/features/paths/tessellate/stroke.js +74 -134
  53. package/dist/features/paths/tessellate/stroke.js.map +1 -1
  54. package/dist/features/paths/tessellate/vertexWidths.js +32 -0
  55. package/dist/features/paths/tessellate/vertexWidths.js.map +1 -0
  56. package/dist/features/pointer/PointerContext.js +2 -2
  57. package/dist/features/pointer/PointerContext.js.map +1 -1
  58. package/dist/features/poseRun/usePoseRun.js.map +1 -1
  59. package/dist/features/text/useTextEdit.js +86 -84
  60. package/dist/features/text/useTextEdit.js.map +1 -1
  61. package/dist/index.d.ts +84 -45
  62. package/dist/index.js +269 -268
  63. package/dist/interactions/actions/defaults/align.js.map +1 -1
  64. package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
  65. package/dist/interactions/actions/defaults/areaSelect.js.map +1 -1
  66. package/dist/interactions/actions/defaults/booleans.js.map +1 -1
  67. package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -1
  68. package/dist/interactions/actions/defaults/clearSelection.js.map +1 -1
  69. package/dist/interactions/actions/defaults/clipboard.js.map +1 -1
  70. package/dist/interactions/actions/defaults/clone.js.map +1 -1
  71. package/dist/interactions/actions/defaults/createOutlines.js +1 -1
  72. package/dist/interactions/actions/defaults/createOutlines.js.map +1 -1
  73. package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -1
  74. package/dist/interactions/actions/defaults/delete.js.map +1 -1
  75. package/dist/interactions/actions/defaults/distribute.js.map +1 -1
  76. package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
  77. package/dist/interactions/actions/defaults/editAnchors.js.map +1 -1
  78. package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -1
  79. package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
  80. package/dist/interactions/actions/defaults/escape.js +1 -1
  81. package/dist/interactions/actions/defaults/escape.js.map +1 -1
  82. package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -1
  83. package/dist/interactions/actions/defaults/flip.js.map +1 -1
  84. package/dist/interactions/actions/defaults/group.js.map +1 -1
  85. package/dist/interactions/actions/defaults/ingest.js.map +1 -1
  86. package/dist/interactions/actions/defaults/insert.js.map +1 -1
  87. package/dist/interactions/actions/defaults/insertPathAnchor.js +1 -1
  88. package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -1
  89. package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -1
  90. package/dist/interactions/actions/defaults/move.js.map +1 -1
  91. package/dist/interactions/actions/defaults/nudge.js.map +1 -1
  92. package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -1
  93. package/dist/interactions/actions/defaults/reorder.js.map +1 -1
  94. package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -1
  95. package/dist/interactions/actions/defaults/resize.js.map +1 -1
  96. package/dist/interactions/actions/defaults/rotate.js.map +1 -1
  97. package/dist/interactions/actions/defaults/selectAll.js.map +1 -1
  98. package/dist/interactions/actions/defaults/slice.js.map +1 -1
  99. package/dist/interactions/actions/defaults/toolActivate.js.map +1 -1
  100. package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -1
  101. package/dist/interactions/actions/defaults/undoRedo.js +1 -1
  102. package/dist/interactions/actions/defaults/undoRedo.js.map +1 -1
  103. package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
  104. package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -1
  105. package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -1
  106. package/dist/interactions/actions/planeInput.js.map +1 -1
  107. package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -1
  108. package/dist/{registerProgram-ateHDGjw.d.ts → registerProgram-BMZRDgrh.d.ts} +4 -0
  109. package/dist/renderer/cache/markerCommandCache.js +46 -42
  110. package/dist/renderer/cache/markerCommandCache.js.map +1 -1
  111. package/dist/renderer/cache/outlineStrokeMeshCache.js +30 -25
  112. package/dist/renderer/cache/outlineStrokeMeshCache.js.map +1 -1
  113. package/dist/renderer/cache/strokeMeshCache.js +42 -31
  114. package/dist/renderer/cache/strokeMeshCache.js.map +1 -1
  115. package/dist/renderer/cullDrawCommands.js +32 -31
  116. package/dist/renderer/cullDrawCommands.js.map +1 -1
  117. package/dist/renderer/draw.js +315 -362
  118. package/dist/renderer/draw.js.map +1 -1
  119. package/dist/renderer/drawBatch.js.map +1 -1
  120. package/dist/renderer/glyphOutlineMesh.js +67 -0
  121. package/dist/renderer/glyphOutlineMesh.js.map +1 -0
  122. package/dist/renderer/math/mat3.js +8 -3
  123. package/dist/renderer/math/mat3.js.map +1 -1
  124. package/dist/renderer/shaders/batchFill.js +3 -2
  125. package/dist/renderer/shaders/batchFill.js.map +1 -1
  126. package/dist/renderer/strokeLengths.js +50 -0
  127. package/dist/renderer/strokeLengths.js.map +1 -0
  128. package/dist/renderer.d.ts +2 -2
  129. package/dist/{test-seams-fYf6m5pu.d.ts → test-seams-CuIxe0xY.d.ts} +1 -1
  130. package/dist/test-seams.d.ts +2 -2
  131. package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -1
  132. package/dist/tools/builtin/pen/usePenTool.js +1 -1
  133. package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
  134. package/dist/tools/builtin/select/selectionContributions.js +43 -23
  135. package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
  136. package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
  137. package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
  138. package/dist/version.js +1 -1
  139. package/package.json +17 -16
@@ -8,30 +8,30 @@ import { getPaintKind as l } from "../core/paintKinds.js";
8
8
  import { SPRITE_STRIDE as u } from "./DrawCommand.js";
9
9
  import { patternTileSpace as d } from "./math/patternSpace.js";
10
10
  import { getMesh as f } from "./cache/cache.js";
11
- import { resolveStrokeWidth as p } from "../features/paths/tessellate/stroke.js";
12
- import { outlineMesh as m } from "./cache/outlineMeshCache.js";
13
- import { outlineStrokeMesh as h, quantizeEmWidth as g } from "./cache/outlineStrokeMeshCache.js";
14
- import { resolveMarkerSize as _ } from "../core/markerInset.js";
15
- import { quantizeStrokeScale as v, strokeMesh as y } from "./cache/strokeMeshCache.js";
11
+ import { metricKeepsRects as p } from "../features/paths/tessellate/metric.js";
12
+ import { resolveStrokeWidth as m } from "../features/paths/tessellate/stroke.js";
13
+ import { strokeMesh as h } from "./cache/strokeMeshCache.js";
14
+ import { SYNTHETIC_ITALIC_RADIANS as g } from "./syntheticItalic.js";
15
+ import { outlineGroupMesh as _, outlineGroupStrokeMesh as v } from "./glyphOutlineMesh.js";
16
+ import { resolveStrokeLengths as y } from "./strokeLengths.js";
16
17
  import { cachedMarkerCommands as b } from "./cache/markerCommandCache.js";
17
18
  import { axisAlignedClipRect as ee, intersectClipRects as x } from "./batchClip.js";
18
19
  import { COMPOSITE_PROGRAM_ID as S } from "./effects/composite.js";
19
- import { SYNTHETIC_ITALIC_RADIANS as te } from "./syntheticItalic.js";
20
- import { GLYPH_MODE_MSDF as C, GLYPH_MODE_R8 as ne, dynamicPageTextureId as re, ensureFontTexture as ie, glyphFieldScale as ae, syncDynamicPageTexture as oe, textureCacheKey as se } from "@weasel-js/font";
20
+ import { GLYPH_MODE_MSDF as te, GLYPH_MODE_R8 as ne, dynamicPageTextureId as re, ensureFontTexture as ie, glyphFieldScale as ae, syncDynamicPageTexture as oe, textureCacheKey as se } from "@weasel-js/font";
21
21
  import { cachedLayoutRuns as ce, resolveTextStyle as le, verticalAlignOffset as ue } from "@weasel-js/text";
22
22
  import { tessellate as de } from "@weasel-js/geom/tessellate";
23
23
  //#region src/renderer/draw.ts
24
- function w(e, t, n) {
24
+ function C(e, t, n) {
25
25
  e.gl.drawElements(e.gl.TRIANGLES, t, n, 0), e.stats && e.stats.drawCalls++;
26
26
  }
27
27
  var fe = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap();
28
- function T(e, t) {
28
+ function w(e, t) {
29
29
  let n = fe.get(e);
30
30
  n || (n = /* @__PURE__ */ new WeakMap(), fe.set(e, n));
31
31
  let r = n.get(t);
32
32
  return r || (r = {}, n.set(t, r)), r;
33
33
  }
34
- function E(e, t) {
34
+ function T(e, t) {
35
35
  if (e === void 0 || e.length !== t.length) return !1;
36
36
  for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
37
37
  return !0;
@@ -39,7 +39,7 @@ function E(e, t) {
39
39
  function me(e, t, n, r, i, a) {
40
40
  let o = t.uniform("u_color");
41
41
  if (o === void 0) return;
42
- let s = T(e, t), c = s.color;
42
+ let s = w(e, t), c = s.color;
43
43
  (c === void 0 || c[0] !== n || c[1] !== r || c[2] !== i || c[3] !== a) && (e.gl.uniform4f(o, n, r, i, a), s.color = [
44
44
  n,
45
45
  r,
@@ -47,23 +47,23 @@ function me(e, t, n, r, i, a) {
47
47
  a
48
48
  ]);
49
49
  }
50
- function D(e, t, n) {
50
+ function E(e, t, n) {
51
51
  let r = t.uniform("u_alpha");
52
52
  if (r === void 0) return;
53
- let i = T(e, t);
53
+ let i = w(e, t);
54
54
  i.alpha !== n && (e.gl.uniform1f(r, n), i.alpha = n);
55
55
  }
56
- var O = o.identity();
56
+ var D = o.identity();
57
57
  function he(e) {
58
58
  let t = pe.get(e);
59
59
  return t || (t = o.screenToClip(e.widthCss, e.heightCss), pe.set(e, t)), t;
60
60
  }
61
- var k = /* @__PURE__ */ new Float32Array(16);
62
- function A(e, t, n = e.state.colorMatrix) {
63
- let r = e.gl, i = T(e, t), a = t.uniform("u_colorMatrix");
61
+ var O = /* @__PURE__ */ new Float32Array(16);
62
+ function k(e, t, n = e.state.colorMatrix) {
63
+ let r = e.gl, i = w(e, t), a = t.uniform("u_colorMatrix");
64
64
  if (a !== void 0) {
65
- for (let e = 0; e < 4; e++) for (let t = 0; t < 4; t++) k[t * 4 + e] = n[e * 5 + t];
66
- E(i.colorMatrix, k) || (r.uniformMatrix4fv(a, !1, k), i.colorMatrix = Float32Array.from(k));
65
+ for (let e = 0; e < 4; e++) for (let t = 0; t < 4; t++) O[t * 4 + e] = n[e * 5 + t];
66
+ T(i.colorMatrix, O) || (r.uniformMatrix4fv(a, !1, O), i.colorMatrix = Float32Array.from(O));
67
67
  }
68
68
  let o = t.uniform("u_colorBias");
69
69
  if (o !== void 0) {
@@ -73,7 +73,7 @@ function A(e, t, n = e.state.colorMatrix) {
73
73
  n[14],
74
74
  n[19]
75
75
  ];
76
- E(i.colorBias, e) || (r.uniform4f(o, e[0], e[1], e[2], e[3]), i.colorBias = Float32Array.from(e));
76
+ T(i.colorBias, e) || (r.uniform4f(o, e[0], e[1], e[2], e[3]), i.colorBias = Float32Array.from(e));
77
77
  }
78
78
  }
79
79
  function ge(e, t) {
@@ -85,22 +85,22 @@ function _e(e, t) {
85
85
  function ve(e, t) {
86
86
  return _e(e, ge(e, t));
87
87
  }
88
- function ye(e, t) {
88
+ function A(e, t) {
89
89
  switch (t.kind) {
90
- case "group": return je(e, t);
91
- case "path": return Le(e, t);
92
- case "text": return At(e, t);
93
- case "image": return Jt(e, t);
94
- case "sprites": return Yt(e, t);
95
- case "shader": return P(e), De(e, t);
90
+ case "group": return Ae(e, t);
91
+ case "path": return Fe(e, t);
92
+ case "text": return Dt(e, t);
93
+ case "image": return Vt(e, t);
94
+ case "sprites": return Ht(e, t);
95
+ case "shader": return F(e), Ee(e, t);
96
96
  }
97
97
  }
98
- var be = /* @__PURE__ */ new Set();
99
- function xe(e, t) {
98
+ var ye = /* @__PURE__ */ new Set();
99
+ function be(e, t) {
100
100
  let n = `${e}:${t}`;
101
- be.has(n) || (be.add(n), (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel drawShader: uniform "${t}" not found in program "${e}". Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`));
101
+ ye.has(n) || (ye.add(n), (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel drawShader: uniform "${t}" not found in program "${e}". Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`));
102
102
  }
103
- function Se(e, t, n, r, i) {
103
+ function xe(e, t, n, r, i) {
104
104
  if (typeof n == "object" && n && !Array.isArray(n) && !(n instanceof Float32Array) && "id" in n && typeof n.id == "string") {
105
105
  let a = n, o = c(a.id);
106
106
  if (!o) {
@@ -138,7 +138,7 @@ function Se(e, t, n, r, i) {
138
138
  return;
139
139
  }
140
140
  }
141
- var Ce = {
141
+ var Se = {
142
142
  float: {
143
143
  fn: "uniform1fv",
144
144
  n: 1
@@ -264,11 +264,11 @@ var Ce = {
264
264
  matrix: !0
265
265
  }
266
266
  };
267
- function we(e) {
267
+ function Ce(e) {
268
268
  return Array.isArray(e) || e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint32Array;
269
269
  }
270
- function Te(e, t, n, r) {
271
- let i = typeof process < "u" ? process.env.NODE_ENV !== "production" : !0, a = Ce[n.type];
270
+ function we(e, t, n, r) {
271
+ let i = typeof process < "u" ? process.env.NODE_ENV !== "production" : !0, a = Se[n.type];
272
272
  if (!a) {
273
273
  i && console.warn(`weasel setUniform: array uniform "${t}" has type ${n.type}, which cannot be written as a whole`);
274
274
  return;
@@ -281,22 +281,22 @@ function Te(e, t, n, r) {
281
281
  let o = e[a.fn];
282
282
  a.matrix ? o.call(e, n.location, !1, r) : o.call(e, n.location, r);
283
283
  }
284
- function Ee(e, t, n, r, i, a) {
284
+ function Te(e, t, n, r, i, a) {
285
285
  for (let [o, s] of Object.entries(r)) {
286
286
  let r = t.uniformArray(o);
287
- if (r && we(s)) {
288
- Te(e, o, r, s);
287
+ if (r && Ce(s)) {
288
+ we(e, o, r, s);
289
289
  continue;
290
290
  }
291
291
  let c = t.uniform(o);
292
292
  if (c === void 0) {
293
- xe(n, o);
293
+ be(n, o);
294
294
  continue;
295
295
  }
296
- Se(e, c, s, i, a);
296
+ xe(e, c, s, i, a);
297
297
  }
298
298
  }
299
- function De(e, t) {
299
+ function Ee(e, t) {
300
300
  let { gl: n, programRegistry: r, quadVbo: i, quadIbo: a, textureCache: s } = e, c = r.get(t.program.id);
301
301
  if (!c) {
302
302
  console.warn(`weasel drawShader: program "${t.program.id}" not compiled on this renderer. Call renderer.registerProgram(handle) after the module-level registerProgram().`);
@@ -314,36 +314,36 @@ function De(e, t) {
314
314
  let p = c.uniform("u_bounds");
315
315
  p !== void 0 && n.uniform4f(p, t.bounds.x, t.bounds.y, t.bounds.w, t.bounds.h);
316
316
  let m = c.uniform("u_view");
317
- m !== void 0 && n.uniformMatrix3fv(m, !1, e.state.transform), Ee(n, c, t.program.id, t.uniforms, s, { value: 1 }), Z(e), w(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && n.disableVertexAttribArray(l), u !== void 0 && n.disableVertexAttribArray(u), n.bindBuffer(n.ARRAY_BUFFER, null), n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, null);
317
+ m !== void 0 && n.uniformMatrix3fv(m, !1, e.state.transform), Te(n, c, t.program.id, t.uniforms, s, { value: 1 }), Z(e), C(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && n.disableVertexAttribArray(l), u !== void 0 && n.disableVertexAttribArray(u), n.bindBuffer(n.ARRAY_BUFFER, null), n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, null);
318
318
  }
319
- function Oe(e, t, n, r, i) {
319
+ function De(e, t, n, r, i) {
320
320
  let a = e.gl;
321
- P(e);
321
+ F(e);
322
322
  let o = e.renderTarget ?? null, s = e.clipDepth, c = e.clipStack, l = e.drawBatch.clip, u = a.isEnabled(a.SCISSOR_TEST), d = n.acquire(r, i), f = e.state.pushIsolated({ transform: t.transform });
323
323
  e.clipDepth = 0, e.clipStack = [], e.drawBatch.clip = null, a.bindFramebuffer(a.FRAMEBUFFER, d.fbo), e.renderTarget = d, a.viewport(0, 0, r, i), a.disable(a.SCISSOR_TEST), a.stencilMask(255), a.clear(a.COLOR_BUFFER_BIT | a.STENCIL_BUFFER_BIT);
324
- for (let n of t.children) ye(e, n);
325
- G(e), a.disable(a.BLEND);
324
+ for (let n of t.children) A(e, n);
325
+ q(e), a.disable(a.BLEND);
326
326
  for (let o of t.effects) {
327
327
  let t = e.ensureProgram?.(o.program.id) ?? null;
328
328
  if (!t) {
329
- xe(o.program.id, "(program)");
329
+ be(o.program.id, "(program)");
330
330
  continue;
331
331
  }
332
332
  let s = n.acquire(r, i);
333
- a.bindFramebuffer(a.FRAMEBUFFER, s.fbo), a.viewport(0, 0, r, i), a.clear(a.COLOR_BUFFER_BIT), Ae(e, t, d.texture, r, i, o.uniforms, void 0, o.program.id), n.release(d), d = s;
333
+ a.bindFramebuffer(a.FRAMEBUFFER, s.fbo), a.viewport(0, 0, r, i), a.clear(a.COLOR_BUFFER_BIT), ke(e, t, d.texture, r, i, o.uniforms, void 0, o.program.id), n.release(d), d = s;
334
334
  }
335
- a.enable(a.BLEND), e.state.pop(), e.clipDepth = s, e.clipStack = c, e.drawBatch.clip = l, e.renderTarget = o, ke(e, r, i, u);
335
+ a.enable(a.BLEND), e.state.pop(), e.clipDepth = s, e.clipStack = c, e.drawBatch.clip = l, e.renderTarget = o, Oe(e, r, i, u);
336
336
  let p = e.ensureProgram?.(S) ?? null;
337
- p && (Z(e), Ae(e, p, d.texture, r, i, void 0, {
337
+ p && (Z(e), ke(e, p, d.texture, r, i, void 0, {
338
338
  alpha: f.alpha,
339
339
  colorMatrix: f.colorMatrix
340
340
  })), n.release(d);
341
341
  }
342
- function ke(e, t, n, r) {
342
+ function Oe(e, t, n, r) {
343
343
  let i = e.gl, a = e.renderTarget ?? null;
344
344
  i.bindFramebuffer(i.FRAMEBUFFER, a ? a.fbo : null), a ? i.viewport(0, 0, t, n) : (e.restoreTargetRect?.(), r && i.enable(i.SCISSOR_TEST));
345
345
  }
346
- function Ae(e, t, n, r, i, a, o, s) {
346
+ function ke(e, t, n, r, i, a, o, s) {
347
347
  let c = e.gl;
348
348
  c.useProgram(t.handle);
349
349
  let l = t.attribute("a_position"), u = t.attribute("a_uv");
@@ -355,13 +355,13 @@ function Ae(e, t, n, r, i, a, o, s) {
355
355
  let p = t.uniform("u_texel");
356
356
  if (p !== void 0 && c.uniform2f(p, 1 / r, 1 / i), o) {
357
357
  let n = t.uniform("u_alpha");
358
- n !== void 0 && c.uniform1f(n, o.alpha), A(e, t, o.colorMatrix);
358
+ n !== void 0 && c.uniform1f(n, o.alpha), k(e, t, o.colorMatrix);
359
359
  }
360
- a && Ee(c, t, s ?? "effect", a, e.textureCache, { value: 1 }), w(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && l >= 0 && c.disableVertexAttribArray(l), u !== void 0 && u >= 0 && c.disableVertexAttribArray(u), c.bindBuffer(c.ARRAY_BUFFER, null), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, null);
360
+ a && Te(c, t, s ?? "effect", a, e.textureCache, { value: 1 }), C(e, 6, e.gl.UNSIGNED_SHORT), l !== void 0 && l >= 0 && c.disableVertexAttribArray(l), u !== void 0 && u >= 0 && c.disableVertexAttribArray(u), c.bindBuffer(c.ARRAY_BUFFER, null), c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, null);
361
361
  }
362
- function je(e, t) {
362
+ function Ae(e, t) {
363
363
  if (t.effects && t.effects.length > 0 && e.effectTargets && e.deviceWidth && e.deviceHeight) {
364
- Oe(e, t, e.effectTargets, e.deviceWidth, e.deviceHeight);
364
+ De(e, t, e.effectTargets, e.deviceWidth, e.deviceHeight);
365
365
  return;
366
366
  }
367
367
  if (e.state.push({
@@ -371,17 +371,17 @@ function je(e, t) {
371
371
  }), t.clip) {
372
372
  let n = e.clipStack.reduce((e, t) => e + +(t.depth === 0), 0);
373
373
  if (e.clipDepth + n + 1 > 7) throw e.state.pop(), Error("weasel: clip nesting depth exceeded (max 7). You can't nest more than 7 levels of clipped containers in a single draw tree. Flatten the hierarchy or compose poses outside the scene graph.");
374
- Me(e, t.clip);
374
+ je(e, t.clip);
375
375
  }
376
- for (let n of t.children) ye(e, n);
377
- t.clip && Ne(e), e.state.pop();
376
+ for (let n of t.children) A(e, n);
377
+ t.clip && Me(e), e.state.pop();
378
378
  }
379
- function Me(e, t) {
379
+ function je(e, t) {
380
380
  let n = e.state.transform, r = ee(t, n);
381
381
  if (r === null) {
382
- Pe(e);
382
+ j(e);
383
383
  let r = e.clipDepth + 1;
384
- vt(e, t, r), e.clipDepth = r, e.clipStack.push({
384
+ _t(e, t, r), e.clipDepth = r, e.clipStack.push({
385
385
  path: t,
386
386
  transform: n,
387
387
  rect: null,
@@ -393,105 +393,110 @@ function Me(e, t) {
393
393
  rect: r,
394
394
  depth: 0
395
395
  });
396
- Fe(e);
396
+ Ne(e);
397
397
  }
398
- function Ne(e) {
398
+ function Me(e) {
399
399
  let t = e.clipStack.pop();
400
- t.depth > 0 && (yt(e, t.path, t.depth - 1, t.transform), e.clipDepth = t.depth - 1), Fe(e);
400
+ t.depth > 0 && (vt(e, t.path, t.depth - 1, t.transform), e.clipDepth = t.depth - 1), Ne(e);
401
401
  }
402
- function Pe(e) {
402
+ function j(e) {
403
403
  for (let t of e.clipStack) {
404
404
  if (t.depth !== 0) continue;
405
405
  let n = e.clipDepth + 1;
406
- vt(e, t.path, n, t.transform), t.depth = n, e.clipDepth = n;
406
+ _t(e, t.path, n, t.transform), t.depth = n, e.clipDepth = n;
407
407
  }
408
408
  }
409
- function Fe(e) {
409
+ function Ne(e) {
410
410
  let t = null;
411
411
  for (let n of e.clipStack) n.rect && (t = t ? x(t, n.rect) : n.rect);
412
412
  e.drawBatch.clip = t;
413
413
  }
414
- function Ie(e) {
414
+ function Pe(e) {
415
415
  let t = e.clipStack;
416
416
  if (t.length === 0 || e.uncut) return e.clipDepth;
417
417
  for (let e = t.length - 1; e >= 0; e--) if (t[e].rect === null) return t[e].depth;
418
418
  for (let e of t) if (e.depth > 0) return e.depth - 1;
419
419
  return e.clipDepth;
420
420
  }
421
- function j(e) {
422
- Pe(e);
421
+ function M(e) {
422
+ j(e);
423
423
  let t = e.drawBatch.clip;
424
424
  return e.drawBatch.clip = null, e.uncut = !0, t;
425
425
  }
426
- function M(e, t) {
426
+ function N(e, t) {
427
427
  e.drawBatch.clip = t, e.uncut = !1;
428
428
  }
429
- function N(e, t, n, r) {
430
- let i = j(e);
431
- r(e, t, n), M(e, i);
429
+ function P(e, t, n, r) {
430
+ let i = M(e);
431
+ r(e, t, n), N(e, i);
432
432
  }
433
- function P(e) {
434
- G(e), e.clipStack.length > 0 && Pe(e);
433
+ function F(e) {
434
+ q(e), e.clipStack.length > 0 && j(e);
435
435
  }
436
- function Le(e, t) {
437
- t.fill && Re(e, t), t.stroke?.paint && Ct(e, t);
436
+ function Fe(e, t) {
437
+ t.fill && Ie(e, t), t.stroke?.paint && bt(e, t);
438
438
  }
439
- function Re(e, t) {
440
- let n = t.fill, r = n.fill === void 0 || n.fill === "solid", i = !!(t.vertexColors && t.vertexColors.length > 0), a = n, o = H(e, n, i);
439
+ function Ie(e, t) {
440
+ let n = t.fill, r = n.fill === void 0 || n.fill === "solid", i = !!(t.vertexColors && t.vertexColors.length > 0), a = n, o = G(e, n, i);
441
441
  if (o === null) return;
442
442
  if (o !== void 0 && t.path.kind === "rect") {
443
- o.kind === "ramp" ? nt(e, t.path, o) : Ye(e, t.path, o);
443
+ o.kind === "ramp" ? $e(e, t.path, o) : Ge(e, t.path, o);
444
444
  return;
445
445
  }
446
446
  let s = ge(e, t.path);
447
- if (W(e, s, o)) return;
447
+ if (K(e, s, o)) return;
448
448
  let c = _e(e, s);
449
- r && i ? it(e, t, a, c) : c.requiresStencil ? bt(e, n, c) : lt(e, n, c);
449
+ r && i ? nt(e, t, a, c) : c.requiresStencil ? yt(e, n, c) : ct(e, n, c);
450
450
  }
451
- var ze = new Int32Array(Array.from({ length: t }, (e, t) => t)), F = new Float32Array(2 * t);
452
- function Be(e) {
453
- return e === s || E(s, e);
451
+ var Le = new Int32Array(Array.from({ length: t }, (e, t) => t)), I = new Float32Array(2 * t);
452
+ function Re(e) {
453
+ return e === s || T(s, e);
454
454
  }
455
- function I(e, t, n, r, i = 0) {
456
- if (t.clipDepth !== (e.clipStack.length === 0 ? e.clipDepth : Ie(e)) || t.synthBold !== i || !t.foldsAlpha && t.alpha !== e.state.alpha || n !== void 0 && Ve(t, n, r) < 0) return !1;
455
+ function L(e, t, n, r, i = 0) {
456
+ if (t.clipDepth !== (e.clipStack.length === 0 ? e.clipDepth : Pe(e)) || t.synthBold !== i || !t.foldsAlpha && t.alpha !== e.state.alpha || n !== void 0 && ze(t, n, r) < 0) return !1;
457
457
  let a = e.state.colorMatrix;
458
- return t.colorMatrix === a || E(t.colorMatrix, a);
458
+ return t.colorMatrix === a || T(t.colorMatrix, a);
459
459
  }
460
- function Ve(e, t, n) {
460
+ function ze(e, t, n) {
461
461
  for (let r = 0; r < e.textures.length; r++) {
462
462
  let i = e.textures[r];
463
463
  if (i.kind === "bitmap" && i.image === t) return i.sampling === n ? r + 1 : -1;
464
464
  }
465
- return L(e);
465
+ return R(e);
466
466
  }
467
- function He(e) {
467
+ function Be(e) {
468
468
  for (let t = 0; t < e.textures.length; t++) if (e.textures[t].kind === "ramps") return t + 1;
469
- return L(e);
469
+ return R(e);
470
470
  }
471
- function Ue(e, t) {
471
+ function Ve(e, t) {
472
472
  for (let n = 0; n < e.textures.length; n++) {
473
473
  let r = e.textures[n];
474
474
  if (r.kind === "atlas" && r.id === t) return n + 1;
475
475
  }
476
- return L(e);
476
+ return R(e);
477
477
  }
478
- function L(e) {
478
+ function R(e) {
479
479
  return e.textures.length + 1 < t ? e.textures.length + 1 : -1;
480
480
  }
481
- var We = 256;
482
- function Ge(e) {
483
- return !e.requiresStencil && e.vertices.length >> 1 <= We;
481
+ var z = {
482
+ maxVertices: 96,
483
+ maxVerticesInRun: 1024
484
+ };
485
+ function He(e, t) {
486
+ if (t.requiresStencil) return !1;
487
+ let n = e.drawBatch.length > 0 ? z.maxVerticesInRun : z.maxVertices;
488
+ return t.vertices.length >> 1 <= n;
484
489
  }
485
- function R(e, t) {
486
- return e.batchState !== void 0 && !I(e, e.batchState) && G(e), e.drawBatch.wouldOverflow(t) && G(e), z(e);
490
+ function B(e, t) {
491
+ return e.batchState !== void 0 && !L(e, e.batchState) && q(e), e.drawBatch.wouldOverflow(t) && q(e), V(e);
487
492
  }
488
- function z(e) {
493
+ function V(e) {
489
494
  if (e.batchState === void 0) {
490
- let t = e.state.colorMatrix, n = Be(t);
495
+ let t = e.state.colorMatrix, n = Re(t);
491
496
  e.batchState = {
492
497
  alpha: n ? 1 : e.state.alpha,
493
498
  colorMatrix: t,
494
- clipDepth: Ie(e),
499
+ clipDepth: Pe(e),
495
500
  synthBold: 0,
496
501
  foldsAlpha: n,
497
502
  textures: []
@@ -499,9 +504,9 @@ function z(e) {
499
504
  }
500
505
  return e.batchState;
501
506
  }
502
- function B(e, t, n) {
503
- e.batchState !== void 0 && !I(e, e.batchState, t, n) && G(e), e.drawBatch.wouldOverflow(4) && G(e);
504
- let r = z(e), i = Ve(r, t, n);
507
+ function H(e, t, n) {
508
+ e.batchState !== void 0 && !L(e, e.batchState, t, n) && q(e), e.drawBatch.wouldOverflow(4) && q(e);
509
+ let r = V(e), i = ze(r, t, n);
505
510
  return i > r.textures.length && (r.textures.push({
506
511
  kind: "bitmap",
507
512
  image: t,
@@ -511,11 +516,11 @@ function B(e, t, n) {
511
516
  slot: i
512
517
  };
513
518
  }
514
- function V(e, t, n, r) {
515
- e.batchState !== void 0 && (!I(e, e.batchState, void 0, void 0, r) || Ue(e.batchState, t) < 0) && G(e), e.drawBatch.wouldOverflow(4) && G(e);
516
- let i = z(e);
519
+ function U(e, t, n, r) {
520
+ e.batchState !== void 0 && (!L(e, e.batchState, void 0, void 0, r) || Ve(e.batchState, t) < 0) && q(e), e.drawBatch.wouldOverflow(4) && q(e);
521
+ let i = V(e);
517
522
  i.synthBold = r;
518
- let a = Ue(i, t);
523
+ let a = Ve(i, t);
519
524
  return a > i.textures.length && (i.textures.push({
520
525
  kind: "atlas",
521
526
  id: t,
@@ -525,36 +530,36 @@ function V(e, t, n, r) {
525
530
  slot: a
526
531
  };
527
532
  }
528
- function Ke(e, t, n, r) {
529
- e.gradRamps.wouldReshape(t, n) && G(e), e.batchState !== void 0 && (!I(e, e.batchState) || He(e.batchState) < 0) && G(e), e.drawBatch.wouldOverflow(r) && G(e);
530
- let i = z(e), a = He(i);
533
+ function Ue(e, t, n, r) {
534
+ e.gradRamps.wouldReshape(t, n) && q(e), e.batchState !== void 0 && (!L(e, e.batchState) || Be(e.batchState) < 0) && q(e), e.drawBatch.wouldOverflow(r) && q(e);
535
+ let i = V(e), a = Be(i);
531
536
  return a > i.textures.length && (i.textures.push({ kind: "ramps" }), a = i.textures.length), {
532
537
  staged: i,
533
538
  slot: a,
534
539
  rowV: e.gradRamps.rowV(e.gradRamps.upload(t, n))
535
540
  };
536
541
  }
537
- function qe(e, t, n) {
542
+ function W(e, t, n) {
538
543
  return (n ?? 1) * (t.foldsAlpha ? e.state.alpha : 1);
539
544
  }
540
- function Je(e, t, n) {
545
+ function We(e, t, n) {
541
546
  let [r, i, o, s] = a(n.color);
542
547
  return [
543
548
  r,
544
549
  i,
545
550
  o,
546
- s * qe(e, t, n.opacity)
551
+ s * W(e, t, n.opacity)
547
552
  ];
548
553
  }
549
- function Ye(e, t, n) {
550
- let [r, i, a, o] = Je(e, R(e, 4), n);
551
- e.drawBatch.pushRect(t.x, t.y, t.width, t.height, e.state.transform, r, i, a, o) || N(e, t, n, Ye);
554
+ function Ge(e, t, n) {
555
+ let [r, i, a, o] = We(e, B(e, 4), n);
556
+ e.drawBatch.pushRect(t.x, t.y, t.width, t.height, e.state.transform, r, i, a, o) || P(e, t, n, Ge);
552
557
  }
553
- function Xe(e, t, n) {
554
- let [r, i, a, o] = Je(e, R(e, t.vertices.length >> 1), n);
555
- e.drawBatch.pushMesh(t, e.state.transform, r, i, a, o) || N(e, t, n, Xe);
558
+ function Ke(e, t, n) {
559
+ let [r, i, a, o] = We(e, B(e, t.vertices.length >> 1), n);
560
+ e.drawBatch.pushMesh(t, e.state.transform, r, i, a, o) || P(e, t, n, Ke);
556
561
  }
557
- function H(e, t, a) {
562
+ function G(e, t, a) {
558
563
  if (a) return;
559
564
  let o = t.fill ?? "solid";
560
565
  if (o === "solid") {
@@ -566,10 +571,10 @@ function H(e, t, a) {
566
571
  };
567
572
  }
568
573
  if (o !== "linear-gradient" && o !== "radial-gradient" && o !== "conic-gradient") return;
569
- let s = t, c = Ze(e, s.units);
570
- return c ? s.fill === "linear-gradient" ? U(s, r, Qe(c, s)) : s.fill === "radial-gradient" ? U(s, i, $e(c, s)) : U(s, n, et(c, s)) : null;
574
+ let s = t, c = Je(e, s.units);
575
+ return c ? s.fill === "linear-gradient" ? qe(s, r, Ye(c, s)) : s.fill === "radial-gradient" ? qe(s, i, Xe(c, s)) : qe(s, n, Ze(c, s)) : null;
571
576
  }
572
- function U(e, t, n) {
577
+ function qe(e, t, n) {
573
578
  return {
574
579
  kind: "ramp",
575
580
  stops: e.stops,
@@ -579,11 +584,11 @@ function U(e, t, n) {
579
584
  uv: n
580
585
  };
581
586
  }
582
- function Ze(e, t) {
587
+ function Je(e, t) {
583
588
  let n = X(e, t);
584
589
  return n && o.multiply(n, e.state.transform);
585
590
  }
586
- function Qe(e, t) {
591
+ function Ye(e, t) {
587
592
  let n = t.to.x - t.from.x, r = t.to.y - t.from.y, i = Math.hypot(n, r) || 1, a = 1 / (i * i);
588
593
  return {
589
594
  ux: (e[0] * n + e[1] * r) * a,
@@ -594,7 +599,7 @@ function Qe(e, t) {
594
599
  v0: 0
595
600
  };
596
601
  }
597
- function $e(e, t) {
602
+ function Xe(e, t) {
598
603
  let n = 1 / Math.max(t.radius, 1e-4);
599
604
  return {
600
605
  ux: e[0] * n,
@@ -605,7 +610,7 @@ function $e(e, t) {
605
610
  v0: (e[7] - t.center.y) * n
606
611
  };
607
612
  }
608
- function et(e, t) {
613
+ function Ze(e, t) {
609
614
  let n = Math.cos(t.angle), r = Math.sin(t.angle), i = e[6] - t.center.x, a = e[7] - t.center.y;
610
615
  return {
611
616
  ux: n * e[0] + r * e[1],
@@ -616,7 +621,7 @@ function et(e, t) {
616
621
  v0: n * a - r * i
617
622
  };
618
623
  }
619
- function tt(e, t) {
624
+ function Qe(e, t) {
620
625
  return e.mode === r ? {
621
626
  uv: {
622
627
  ...e.uv,
@@ -628,18 +633,18 @@ function tt(e, t) {
628
633
  post: t
629
634
  };
630
635
  }
631
- function nt(e, t, n) {
632
- let { staged: r, slot: i, rowV: a } = Ke(e, n.stops, n.space, 4), { uv: o, post: s } = tt(n, a);
633
- e.drawBatch.pushGradientRect(t.x, t.y, t.width, t.height, e.state.transform, o, s, i, n.mode, 1, 1, 1, qe(e, r, n.opacity)) || N(e, t, n, nt);
636
+ function $e(e, t, n) {
637
+ let { staged: r, slot: i, rowV: a } = Ue(e, n.stops, n.space, 4), { uv: o, post: s } = Qe(n, a);
638
+ e.drawBatch.pushGradientRect(t.x, t.y, t.width, t.height, e.state.transform, o, s, i, n.mode, 1, 1, 1, W(e, r, n.opacity)) || P(e, t, n, $e);
634
639
  }
635
- function rt(e, t, n) {
636
- let { staged: r, slot: i, rowV: a } = Ke(e, n.stops, n.space, t.vertices.length >> 1), { uv: o, post: s } = tt(n, a);
637
- e.drawBatch.pushGradientMesh(t, e.state.transform, o, s, i, n.mode, 1, 1, 1, qe(e, r, n.opacity)) || N(e, t, n, rt);
640
+ function et(e, t, n) {
641
+ let { staged: r, slot: i, rowV: a } = Ue(e, n.stops, n.space, t.vertices.length >> 1), { uv: o, post: s } = Qe(n, a);
642
+ e.drawBatch.pushGradientMesh(t, e.state.transform, o, s, i, n.mode, 1, 1, 1, W(e, r, n.opacity)) || P(e, t, n, et);
638
643
  }
639
- function W(e, t, n) {
640
- return n !== void 0 && Ge(t) ? (n.kind === "ramp" ? rt(e, t, n) : Xe(e, t, n), !0) : (P(e), !1);
644
+ function K(e, t, n) {
645
+ return n !== void 0 && He(e, t) ? (n.kind === "ramp" ? et(e, t, n) : Ke(e, t, n), !0) : (F(e), !1);
641
646
  }
642
- function G(e) {
647
+ function q(e) {
643
648
  let t = e.drawBatch, n = e.batchState;
644
649
  if (t.length === 0 || n === void 0) {
645
650
  e.batchState = void 0;
@@ -648,11 +653,11 @@ function G(e) {
648
653
  let r = e.gl, i = e.batchFill;
649
654
  r.useProgram(i.handle);
650
655
  let a = t.uploadAndBind();
651
- q(e, i, O), me(e, i, 1, 1, 1, 1), D(e, i, n.alpha), r.uniform1f(i.uniform("u_synthBold"), n.synthBold), A(e, i, n.colorMatrix), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, e.whiteTexture);
656
+ J(e, i, D), me(e, i, 1, 1, 1, 1), E(e, i, n.alpha), r.uniform1f(i.uniform("u_synthBold"), n.synthBold), k(e, i, n.colorMatrix), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, e.whiteTexture);
652
657
  for (let t = 0; t < n.textures.length; t++) {
653
658
  let i = n.textures[t];
654
659
  if (i.kind === "atlas") {
655
- e.textureCache.bind(i.id, t + 1), F[2 * (t + 1)] = i.fieldScale[0], F[2 * (t + 1) + 1] = i.fieldScale[1];
660
+ e.textureCache.bind(i.id, t + 1), I[2 * (t + 1)] = i.fieldScale[0], I[2 * (t + 1) + 1] = i.fieldScale[1];
656
661
  continue;
657
662
  }
658
663
  if (i.kind === "ramps") {
@@ -661,9 +666,9 @@ function G(e) {
661
666
  }
662
667
  e.imageCache.bind(i.image, t + 1), e.imageCache.setMagFilter(i.image, i.sampling === "nearest" ? r.NEAREST : r.LINEAR);
663
668
  }
664
- r.uniform1iv(i.uniform("u_samplers"), ze), r.uniform2fv(i.uniform("u_fieldScale"), F), Z(e, n.clipDepth), w(e, a, e.gl.UNSIGNED_INT), r.activeTexture(r.TEXTURE0), r.bindVertexArray(null), t.reset(), e.batchState = void 0;
669
+ r.uniform1iv(i.uniform("u_samplers"), Le), r.uniform2fv(i.uniform("u_fieldScale"), I), Z(e, n.clipDepth), C(e, a, e.gl.UNSIGNED_INT), r.activeTexture(r.TEXTURE0), r.bindVertexArray(null), t.reset(), e.batchState = void 0;
665
670
  }
666
- function K(e, t) {
671
+ function tt(e, t) {
667
672
  let n = t.anchorA, r = t.anchorB, i = t.anchorT;
668
673
  if (!n || !r || !i) return new Float32Array(e);
669
674
  let a = n.length, o = new Float32Array(a * 4);
@@ -673,33 +678,33 @@ function K(e, t) {
673
678
  }
674
679
  return o;
675
680
  }
676
- function it(e, t, n, r) {
681
+ function nt(e, t, n, r) {
677
682
  let i = e.gl, a = e.pathFillVColor;
678
- i.useProgram(a.handle), i.bindVertexArray(r.vao), q(e, a), J(e, a, n.color, n.opacity), A(e, a);
679
- let o = K(t.vertexColors, r), s = i.createBuffer();
683
+ i.useProgram(a.handle), i.bindVertexArray(r.vao), J(e, a), Y(e, a, n.color, n.opacity), k(e, a);
684
+ let o = tt(t.vertexColors, r), s = i.createBuffer();
680
685
  if (!s) throw Error("drawPathFillVColor: createBuffer (color VBO) returned null");
681
686
  i.bindBuffer(i.ARRAY_BUFFER, s), i.bufferData(i.ARRAY_BUFFER, o, i.DYNAMIC_DRAW);
682
687
  let c = a.attribute("a_vertexColor");
683
- c !== void 0 && (i.enableVertexAttribArray(c), i.vertexAttribPointer(c, 4, i.FLOAT, !1, 0, 0)), Z(e), w(e, r.indexCount, e.gl.UNSIGNED_INT), i.bindVertexArray(null), i.deleteBuffer(s);
688
+ c !== void 0 && (i.enableVertexAttribArray(c), i.vertexAttribPointer(c, 4, i.FLOAT, !1, 0, 0)), Z(e), C(e, r.indexCount, e.gl.UNSIGNED_INT), i.bindVertexArray(null), i.deleteBuffer(s);
684
689
  }
685
- function q(e, t, n = e.state.transform, r = he(e)) {
686
- let i = e.gl, a = T(e, t);
687
- E(a.proj, r) || (i.uniformMatrix3fv(t.uniform("u_proj"), !1, r), a.proj = Float32Array.from(r)), E(a.model, n) || (i.uniformMatrix3fv(t.uniform("u_model"), !1, n), a.model = Float32Array.from(n));
690
+ function J(e, t, n = e.state.transform, r = he(e)) {
691
+ let i = e.gl, a = w(e, t);
692
+ T(a.proj, r) || (i.uniformMatrix3fv(t.uniform("u_proj"), !1, r), a.proj = Float32Array.from(r)), T(a.model, n) || (i.uniformMatrix3fv(t.uniform("u_model"), !1, n), a.model = Float32Array.from(n));
688
693
  }
689
- function J(e, t, n, r) {
694
+ function Y(e, t, n, r) {
690
695
  let [i, o, s, c] = a(n);
691
- me(e, t, i, o, s, c * (r ?? 1)), D(e, t, e.state.alpha);
696
+ me(e, t, i, o, s, c * (r ?? 1)), E(e, t, e.state.alpha);
692
697
  }
693
- function Y(e, t) {
698
+ function rt(e, t) {
694
699
  let n = t.fill ?? "solid";
695
- if (n === "solid") return ut(e, t);
696
- if (n === "pattern") return dt(e, t);
697
- if (n === "linear-gradient" || n === "radial-gradient" || n === "conic-gradient") return ht(e, t);
700
+ if (n === "solid") return lt(e, t);
701
+ if (n === "pattern") return ut(e, t);
702
+ if (n === "linear-gradient" || n === "radial-gradient" || n === "conic-gradient") return mt(e, t);
698
703
  let r = l(n)?.bind;
699
- return r ? r(at(e), t) : null;
704
+ return r ? r(it(e), t) : null;
700
705
  }
701
- function at(e) {
702
- let t = ot.get(e);
706
+ function it(e) {
707
+ let t = at.get(e);
703
708
  if (t) return t;
704
709
  let n = {
705
710
  gl: e.gl,
@@ -707,38 +712,38 @@ function at(e) {
707
712
  return e.state.alpha;
708
713
  },
709
714
  program: (t) => e.ensureProgram?.(t) ?? e.programRegistry.get(t) ?? null,
710
- setProjAndModel: (t) => q(e, t),
715
+ setProjAndModel: (t) => J(e, t),
711
716
  spaceInverse: (t) => X(e, t),
712
- spaceToDevice: (t) => mt(e, t),
717
+ spaceToDevice: (t) => pt(e, t),
713
718
  get maxTextureSize() {
714
719
  return e.imageCache.maxTextureSide;
715
720
  },
716
- resources: e.paintResources ?? ct(e.gl),
721
+ resources: e.paintResources ?? st(e.gl),
717
722
  bindRamp: (t, n, r) => {
718
723
  let i = e.gradRamps.upload(t, r);
719
724
  return e.gradRamps.bind(n), e.gradRamps.rowV(i);
720
725
  }
721
726
  };
722
- return ot.set(e, n), n;
727
+ return at.set(e, n), n;
723
728
  }
724
- var ot = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap();
725
- function ct(t) {
726
- let n = st.get(t);
727
- return n || (n = e(), st.set(t, n)), n;
729
+ var at = /* @__PURE__ */ new WeakMap(), ot = /* @__PURE__ */ new WeakMap();
730
+ function st(t) {
731
+ let n = ot.get(t);
732
+ return n || (n = e(), ot.set(t, n)), n;
728
733
  }
729
- function lt(e, t, n) {
730
- if (!Y(e, t)) return;
734
+ function ct(e, t, n) {
735
+ if (!rt(e, t)) return;
731
736
  let r = e.gl;
732
- r.bindVertexArray(n.vao), Z(e), w(e, n.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
737
+ r.bindVertexArray(n.vao), Z(e), C(e, n.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
733
738
  }
734
- function ut(e, t) {
739
+ function lt(e, t) {
735
740
  let n = e.pathFill;
736
- return e.gl.useProgram(n.handle), q(e, n), J(e, n, t.color, t.opacity), A(e, n), n;
741
+ return e.gl.useProgram(n.handle), J(e, n), Y(e, n, t.color, t.opacity), k(e, n), n;
737
742
  }
738
- function dt(e, t) {
739
- return ft(e, e.patternFill, t, e.state.transform);
743
+ function ut(e, t) {
744
+ return dt(e, e.patternFill, t, e.state.transform);
740
745
  }
741
- function ft(e, t, n, r) {
746
+ function dt(e, t, n, r) {
742
747
  let i = n.pattern, a = c(i.id);
743
748
  if (!a) return (typeof process > "u" || process.env.NODE_ENV !== "production") && console.warn(`weasel: pattern TextureHandle "${i.id}" not registered`), null;
744
749
  let o = X(e, n.units);
@@ -750,31 +755,31 @@ function ft(e, t, n, r) {
750
755
  if (!s) return null;
751
756
  e.textureCache.upload(i.id, a.source, "repeat");
752
757
  let l = e.gl;
753
- l.useProgram(t.handle), q(e, t, r), A(e, t), l.uniformMatrix3fv(t.uniform("u_worldInv"), !1, s);
754
- let [u, f] = pt(a.source);
755
- return l.uniform2f(t.uniform("u_tileSize"), u, f), e.textureCache.bind(i.id, 0), l.uniform1i(t.uniform("u_sampler"), 0), l.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), D(e, t, e.state.alpha), t;
758
+ l.useProgram(t.handle), J(e, t, r), k(e, t), l.uniformMatrix3fv(t.uniform("u_worldInv"), !1, s);
759
+ let [u, f] = ft(a.source);
760
+ return l.uniform2f(t.uniform("u_tileSize"), u, f), e.textureCache.bind(i.id, 0), l.uniform1i(t.uniform("u_sampler"), 0), l.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), E(e, t, e.state.alpha), t;
756
761
  }
757
- function pt(e) {
762
+ function ft(e) {
758
763
  let t = "naturalWidth" in e ? e.naturalWidth : e.width, n = "naturalHeight" in e ? e.naturalHeight : e.height;
759
764
  return [t || 1, n || 1];
760
765
  }
761
766
  function X(e, t) {
762
767
  return t === "local" ? o.invert(e.state.transform) : t === "world" && e.viewMatrix ? o.invert(e.viewMatrix) : o.identity();
763
768
  }
764
- function mt(e, t) {
769
+ function pt(e, t) {
765
770
  let n = X(e, t), r = n && o.invert(n);
766
771
  if (!r) return null;
767
772
  let i = e.deviceWidth && e.widthCss > 0 ? e.deviceWidth / e.widthCss : 1;
768
773
  return o.multiply(o.scaled(o.identity(), i, i), r);
769
774
  }
770
- function ht(e, t) {
771
- return gt(e, e.gradFill, t, e.state.transform);
775
+ function mt(e, t) {
776
+ return ht(e, e.gradFill, t, e.state.transform);
772
777
  }
773
- function gt(e, t, n, r) {
778
+ function ht(e, t, n, r) {
774
779
  let i = X(e, n.units);
775
780
  if (!i) return null;
776
781
  let a = e.gl, o = e.gradRamps.upload(n.stops, n.interpolate ?? "rgb");
777
- if (a.useProgram(t.handle), q(e, t, r), a.uniformMatrix3fv(t.uniform("u_worldInv"), !1, i), A(e, t), e.gradRamps.bind(0), a.uniform1i(t.uniform("u_ramp"), 0), a.uniform1f(t.uniform("u_rampV"), e.gradRamps.rowV(o)), D(e, t, e.state.alpha), a.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), n.fill === "linear-gradient") {
782
+ if (a.useProgram(t.handle), J(e, t, r), a.uniformMatrix3fv(t.uniform("u_worldInv"), !1, i), k(e, t), e.gradRamps.bind(0), a.uniform1i(t.uniform("u_ramp"), 0), a.uniform1f(t.uniform("u_rampV"), e.gradRamps.rowV(o)), E(e, t, e.state.alpha), a.uniform1f(t.uniform("u_opacity"), n.opacity ?? 1), n.fill === "linear-gradient") {
778
783
  a.uniform1i(t.uniform("u_gradKind"), 0);
779
784
  let e = n.to.x - n.from.x, r = n.to.y - n.from.y, i = Math.hypot(e, r) || 1;
780
785
  a.uniform2f(t.uniform("u_gradP0"), n.from.x, n.from.y), a.uniform2f(t.uniform("u_gradDir"), e / i, r / i), a.uniform1f(t.uniform("u_gradLen"), i), a.uniform1f(t.uniform("u_gradRadius"), 0), a.uniform1f(t.uniform("u_gradAngle"), 0);
@@ -793,115 +798,97 @@ function Z(e, t = e.clipDepth) {
793
798
  function Q(e) {
794
799
  return e === 0 ? 0 : (1 << e + 1) - 1 & 254;
795
800
  }
796
- function _t(e, t, n) {
801
+ function gt(e, t, n) {
797
802
  let r = e.gl, i = ve(e, t);
798
- r.useProgram(e.pathFill.handle), r.bindVertexArray(i.vao), q(e, e.pathFill, n), w(e, i.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
803
+ r.useProgram(e.pathFill.handle), r.bindVertexArray(i.vao), J(e, e.pathFill, n), C(e, i.indexCount, e.gl.UNSIGNED_INT), r.bindVertexArray(null);
799
804
  }
800
- function vt(e, t, n, r = e.state.transform) {
801
- G(e);
805
+ function _t(e, t, n, r = e.state.transform) {
806
+ q(e);
802
807
  let i = e.gl, a = Q(n - 1), o = 1 << n, s = a | o;
803
- i.enable(i.STENCIL_TEST), i.colorMask(!1, !1, !1, !1), i.stencilMask(o), i.stencilFunc(i.EQUAL, s, a), i.stencilOp(i.KEEP, i.KEEP, i.REPLACE), _t(e, t, r), i.colorMask(!0, !0, !0, !0), i.stencilMask(255);
808
+ i.enable(i.STENCIL_TEST), i.colorMask(!1, !1, !1, !1), i.stencilMask(o), i.stencilFunc(i.EQUAL, s, a), i.stencilOp(i.KEEP, i.KEEP, i.REPLACE), gt(e, t, r), i.colorMask(!0, !0, !0, !0), i.stencilMask(255);
804
809
  }
805
- function yt(e, t, n, r = e.state.transform) {
806
- e.batchState !== void 0 && e.batchState.clipDepth > n && G(e);
810
+ function vt(e, t, n, r = e.state.transform) {
811
+ e.batchState !== void 0 && e.batchState.clipDepth > n && q(e);
807
812
  let i = e.gl;
808
813
  i.enable(i.STENCIL_TEST);
809
814
  let a = 1 << n + 1, o = Q(n) | a;
810
- i.colorMask(!1, !1, !1, !1), i.stencilMask(a), i.stencilFunc(i.EQUAL, o, o), i.stencilOp(i.KEEP, i.KEEP, i.ZERO), _t(e, t, r), i.colorMask(!0, !0, !0, !0), i.stencilMask(255);
815
+ i.colorMask(!1, !1, !1, !1), i.stencilMask(a), i.stencilFunc(i.EQUAL, o, o), i.stencilOp(i.KEEP, i.KEEP, i.ZERO), gt(e, t, r), i.colorMask(!0, !0, !0, !0), i.stencilMask(255);
811
816
  }
812
- function bt(e, t, n) {
817
+ function yt(e, t, n) {
813
818
  let r = e.gl;
814
- r.useProgram(e.pathFill.handle), r.bindVertexArray(n.vao), q(e, e.pathFill), r.enable(r.STENCIL_TEST), r.colorMask(!1, !1, !1, !1), r.stencilMask(1), r.stencilFunc(r.ALWAYS, 0, 1), r.stencilOp(r.KEEP, r.KEEP, r.INVERT), w(e, n.indexCount, e.gl.UNSIGNED_INT);
819
+ r.useProgram(e.pathFill.handle), r.bindVertexArray(n.vao), J(e, e.pathFill), r.enable(r.STENCIL_TEST), r.colorMask(!1, !1, !1, !1), r.stencilMask(1), r.stencilFunc(r.ALWAYS, 0, 1), r.stencilOp(r.KEEP, r.KEEP, r.INVERT), C(e, n.indexCount, e.gl.UNSIGNED_INT);
815
820
  let i = Q(e.clipDepth);
816
- r.colorMask(!0, !0, !0, !0), r.stencilFunc(r.EQUAL, i | 1, i | 1), r.stencilOp(r.KEEP, r.KEEP, r.KEEP), Y(e, t) && w(e, n.indexCount, e.gl.UNSIGNED_INT), r.stencilMask(1), r.clear(r.STENCIL_BUFFER_BIT), r.disable(r.STENCIL_TEST), r.bindVertexArray(null);
817
- }
818
- function xt(e, t) {
819
- let n = t.stroke, { markerStart: r, markerMid: i, markerEnd: a } = n;
820
- if (typeof n.width != "object" && !$(r) && !$(i) && !$(a)) return t;
821
- let s = o.meanScaleOf(e.state.transform), c = { ...n };
822
- return typeof n.width == "object" && (c.width = p(n.width, v(n.width.px, s))), $(r) && (c.markerStart = St(r, s)), $(i) && (c.markerMid = St(i, s)), $(a) && (c.markerEnd = St(a, s)), {
823
- ...t,
824
- stroke: c
825
- };
826
- }
827
- function $(e) {
828
- return typeof e == "object" && typeof e.size == "object";
829
- }
830
- function St(e, t) {
831
- return {
832
- ...e,
833
- size: _(e, 0, v(e.size.px, t))
834
- };
835
- }
836
- function Ct(e, t) {
837
- let n = xt(e, t), r = n.stroke, i = r.align ?? "center";
838
- n.path.kind === "polygon" && i !== "center" ? (P(e), Dt(e, n, i)) : wt(e, n);
839
- let a = p(r.width ?? 1, 1);
840
- for (let i of b(n.path, t.stroke, r, a, e.flattenTolerance)) Le(e, i);
841
- }
842
- function wt(e, t) {
843
- let n = t.stroke, r = n.paint, i = r.fill === void 0 || r.fill === "solid", a = r, o = y(t.path, n, e.flattenTolerance);
844
- if (o.indices.length === 0) return;
845
- let s = !!(n.vertexColors && n.vertexColors.length > 0), c = H(e, r, s);
846
- if (c === null || W(e, o, c)) return;
847
- let l = s ? e.meshCache.uploadTransient(o) : e.meshCache.uploadRecurring(o);
848
- if (!i && !s) {
849
- lt(e, r, l);
821
+ r.colorMask(!0, !0, !0, !0), r.stencilFunc(r.EQUAL, i | 1, i | 1), r.stencilOp(r.KEEP, r.KEEP, r.KEEP), rt(e, t) && C(e, n.indexCount, e.gl.UNSIGNED_INT), r.stencilMask(1), r.clear(r.STENCIL_BUFFER_BIT), r.disable(r.STENCIL_TEST), r.bindVertexArray(null);
822
+ }
823
+ function bt(e, t) {
824
+ let { cmd: n, spaces: r } = y(e.state.transform, t), i = n.stroke, a = i.align ?? "center", o = r.ribbon?.metric;
825
+ (n.path.kind === "polygon" || o !== void 0 && !p(o)) && a !== "center" ? (F(e), wt(e, n, a, r)) : xt(e, n, r);
826
+ let s = m(i.width ?? 1, 1), c = b(n.path, t.stroke, i, s, e.flattenTolerance, r);
827
+ for (let t of c) Fe(e, t);
828
+ }
829
+ function xt(e, t, n) {
830
+ let r = t.stroke, i = r.paint, a = i.fill === void 0 || i.fill === "solid", o = i, s = h(t.path, r, e.flattenTolerance, n);
831
+ if (s.indices.length === 0) return;
832
+ let c = !!(r.vertexColors && r.vertexColors.length > 0), l = G(e, i, c);
833
+ if (l === null || K(e, s, l)) return;
834
+ let u = c ? e.meshCache.uploadTransient(s) : e.meshCache.uploadRecurring(s);
835
+ if (!a && !c) {
836
+ ct(e, i, u);
850
837
  return;
851
838
  }
852
- let u = e.gl;
853
- if (s) {
839
+ let d = e.gl;
840
+ if (c) {
854
841
  let t = e.pathFillVColor;
855
- u.useProgram(t.handle), u.bindVertexArray(l.vao), q(e, t), J(e, t, i ? a.color : "#ffffff", r.opacity), A(e, t);
856
- let o = K(n.vertexColors, l), s = u.createBuffer();
842
+ d.useProgram(t.handle), d.bindVertexArray(u.vao), J(e, t), Y(e, t, a ? o.color : "#ffffff", i.opacity), k(e, t);
843
+ let n = tt(r.vertexColors, u), s = d.createBuffer();
857
844
  if (!s) throw Error("drawPathStrokeUnclipped: createBuffer (color VBO) returned null");
858
- u.bindBuffer(u.ARRAY_BUFFER, s), u.bufferData(u.ARRAY_BUFFER, o, u.DYNAMIC_DRAW);
845
+ d.bindBuffer(d.ARRAY_BUFFER, s), d.bufferData(d.ARRAY_BUFFER, n, d.DYNAMIC_DRAW);
859
846
  let c = t.attribute("a_vertexColor");
860
- c !== void 0 && (u.enableVertexAttribArray(c), u.vertexAttribPointer(c, 4, u.FLOAT, !1, 0, 0)), Z(e), w(e, l.indexCount, e.gl.UNSIGNED_INT), u.bindVertexArray(null), u.deleteBuffer(s);
847
+ c !== void 0 && (d.enableVertexAttribArray(c), d.vertexAttribPointer(c, 4, d.FLOAT, !1, 0, 0)), Z(e), C(e, u.indexCount, e.gl.UNSIGNED_INT), d.bindVertexArray(null), d.deleteBuffer(s);
861
848
  return;
862
849
  }
863
- u.useProgram(e.pathFill.handle), u.bindVertexArray(l.vao), q(e, e.pathFill), J(e, e.pathFill, a.color, a.opacity), A(e, e.pathFill), Z(e), w(e, l.indexCount, e.gl.UNSIGNED_INT), u.bindVertexArray(null);
864
- }
865
- var Tt = /* @__PURE__ */ new WeakMap();
866
- function Et(e) {
867
- let t = Tt.get(e);
868
- return t === void 0 && (t = e.map((e) => e * 2), Tt.set(e, t)), t;
869
- }
870
- function Dt(e, t, n) {
871
- let r = t.stroke, i = r.paint, a = i.fill === void 0 || i.fill === "solid", o = i, s = {
872
- ...r,
873
- width: p(r.width ?? 1, 1) * 2,
874
- ...r.vertexWidths ? { vertexWidths: Et(r.vertexWidths) } : {},
850
+ d.useProgram(e.pathFill.handle), d.bindVertexArray(u.vao), J(e, e.pathFill), Y(e, e.pathFill, o.color, o.opacity), k(e, e.pathFill), Z(e), C(e, u.indexCount, e.gl.UNSIGNED_INT), d.bindVertexArray(null);
851
+ }
852
+ var St = /* @__PURE__ */ new WeakMap();
853
+ function Ct(e) {
854
+ let t = St.get(e);
855
+ return t === void 0 && (t = e.map((e) => e * 2), St.set(e, t)), t;
856
+ }
857
+ function wt(e, t, n, r) {
858
+ let i = t.stroke, a = i.paint, o = a.fill === void 0 || a.fill === "solid", s = a, c = {
859
+ ...i,
860
+ width: m(i.width ?? 1, 1) * 2,
861
+ ...i.vertexWidths ? { vertexWidths: Ct(i.vertexWidths) } : {},
875
862
  align: "center"
876
- }, c = !!(r.vertexColors && r.vertexColors.length > 0), l = ve(e, t.path), u = y(t.path, s, e.flattenTolerance);
877
- if (u.indices.length === 0) return;
878
- let d = c ? e.meshCache.uploadTransient(u) : e.meshCache.uploadRecurring(u), f = e.gl, m = c ? e.pathFillVColor : e.pathFill;
879
- f.useProgram(m.handle), q(e, m), f.enable(f.STENCIL_TEST), f.colorMask(!1, !1, !1, !1), f.stencilMask(1), f.stencilFunc(f.ALWAYS, 1, 1), f.stencilOp(f.KEEP, f.KEEP, f.REPLACE), f.bindVertexArray(l.vao), w(e, l.indexCount, e.gl.UNSIGNED_INT);
880
- let h = Q(e.clipDepth);
881
- f.colorMask(!0, !0, !0, !0), n === "inner" ? f.stencilFunc(f.EQUAL, h | 1, h | 1) : f.stencilFunc(f.EQUAL, h, h | 1), f.stencilOp(f.KEEP, f.KEEP, f.KEEP);
882
- let g = m;
883
- if (c ? (J(e, m, a ? o.color : "#ffffff", i.opacity), A(e, m)) : g = Y(e, i), !g) {
884
- f.stencilMask(1), f.clear(f.STENCIL_BUFFER_BIT), f.disable(f.STENCIL_TEST), f.bindVertexArray(null);
863
+ }, l = !!(i.vertexColors && i.vertexColors.length > 0), u = ve(e, t.path), d = h(t.path, c, e.flattenTolerance, r);
864
+ if (d.indices.length === 0) return;
865
+ let f = l ? e.meshCache.uploadTransient(d) : e.meshCache.uploadRecurring(d), p = e.gl, g = l ? e.pathFillVColor : e.pathFill;
866
+ p.useProgram(g.handle), J(e, g), p.enable(p.STENCIL_TEST), p.colorMask(!1, !1, !1, !1), p.stencilMask(1), p.stencilFunc(p.ALWAYS, 1, 1), p.stencilOp(p.KEEP, p.KEEP, p.REPLACE), p.bindVertexArray(u.vao), C(e, u.indexCount, e.gl.UNSIGNED_INT);
867
+ let _ = Q(e.clipDepth);
868
+ p.colorMask(!0, !0, !0, !0), n === "inner" ? p.stencilFunc(p.EQUAL, _ | 1, _ | 1) : p.stencilFunc(p.EQUAL, _, _ | 1), p.stencilOp(p.KEEP, p.KEEP, p.KEEP);
869
+ let v = g;
870
+ if (l ? (Y(e, g, o ? s.color : "#ffffff", a.opacity), k(e, g)) : v = rt(e, a), !v) {
871
+ p.stencilMask(1), p.clear(p.STENCIL_BUFFER_BIT), p.disable(p.STENCIL_TEST), p.bindVertexArray(null);
885
872
  return;
886
873
  }
887
- f.bindVertexArray(d.vao);
888
- let _ = null;
889
- if (c) {
890
- let e = K(r.vertexColors, d);
891
- if (_ = f.createBuffer(), !_) throw Error("drawPathStrokeStenciled: createBuffer (color VBO) returned null");
892
- f.bindBuffer(f.ARRAY_BUFFER, _), f.bufferData(f.ARRAY_BUFFER, e, f.DYNAMIC_DRAW);
893
- let t = g.attribute("a_vertexColor");
894
- t !== void 0 && (f.enableVertexAttribArray(t), f.vertexAttribPointer(t, 4, f.FLOAT, !1, 0, 0));
874
+ p.bindVertexArray(f.vao);
875
+ let y = null;
876
+ if (l) {
877
+ let e = tt(i.vertexColors, f);
878
+ if (y = p.createBuffer(), !y) throw Error("drawPathStrokeStenciled: createBuffer (color VBO) returned null");
879
+ p.bindBuffer(p.ARRAY_BUFFER, y), p.bufferData(p.ARRAY_BUFFER, e, p.DYNAMIC_DRAW);
880
+ let t = v.attribute("a_vertexColor");
881
+ t !== void 0 && (p.enableVertexAttribArray(t), p.vertexAttribPointer(t, 4, p.FLOAT, !1, 0, 0));
895
882
  }
896
- w(e, d.indexCount, e.gl.UNSIGNED_INT), f.stencilMask(1), f.clear(f.STENCIL_BUFFER_BIT), f.disable(f.STENCIL_TEST), f.bindVertexArray(null), _ && f.deleteBuffer(_);
883
+ C(e, f.indexCount, e.gl.UNSIGNED_INT), p.stencilMask(1), p.clear(p.STENCIL_BUFFER_BIT), p.disable(p.STENCIL_TEST), p.bindVertexArray(null), y && p.deleteBuffer(y);
897
884
  }
898
- var Ot = 48;
899
- function kt(e) {
885
+ var Tt = 48;
886
+ function Et(e) {
900
887
  let t = Math.hypot(e[0], e[1]), n = Math.hypot(e[3], e[4]);
901
888
  return Math.sqrt(t * n) || 1;
902
889
  }
903
- function At(e, t) {
904
- let n = le(t.style), r = n.lineHeight, i = t.align ?? n.align, a = t.maxWidth ?? Infinity, o = e.textOutlineMinScreenSize ?? Ot, s = Number.isFinite(o) ? o / kt(e.state.transform) : void 0, c = ce(t.runs, {
890
+ function Dt(e, t) {
891
+ let n = le(t.style), r = n.lineHeight, i = t.align ?? n.align, a = t.maxWidth ?? Infinity, o = e.textOutlineMinScreenSize ?? Tt, s = Number.isFinite(o) ? o / Et(e.state.transform) : void 0, c = ce(t.runs, {
905
892
  maxWidth: a,
906
893
  alignWidth: t.width,
907
894
  lineHeight: r,
@@ -911,62 +898,28 @@ function At(e, t) {
911
898
  });
912
899
  if (c.groups.length === 0 && c.decorations.length === 0) return;
913
900
  let l = t.x, u = t.y + ue(t.verticalAlign, t.height, c.bounds.height);
914
- for (let t of c.groups) t.source === "outline" ? jt(e, t, l, u) : zt(e, t, l, u);
915
- It(e, c.decorations, l, u);
901
+ for (let t of c.groups) t.source === "outline" ? Ot(e, t, l, u) : Nt(e, t, l, u);
902
+ At(e, c.decorations, l, u);
916
903
  }
917
- function jt(e, t, n, r) {
904
+ function Ot(e, t, n, r) {
918
905
  let i = t.fill;
919
906
  if (i !== null) {
920
- let a = Nt(t, n, r);
921
- a && Mt(e, i, a);
907
+ let a = _(t, n, r);
908
+ a && kt(e, i, a);
922
909
  }
923
910
  let a = t.stroke?.paint;
924
911
  if (!a) return;
925
- let s = Pt(t, n, r, o.meanScaleOf(e.state.transform));
926
- s && Mt(e, a, s);
912
+ let o = v(t, n, r, e.state.transform);
913
+ o && kt(e, a, o);
927
914
  }
928
- function Mt(e, t, n) {
929
- let r = H(e, t, !1);
930
- r !== null && (W(e, n, r) || lt(e, t, e.meshCache.uploadTransient(n)));
931
- }
932
- function Nt(e, t, n) {
933
- return Ft(e, t, n, (e) => m(e.key, e.d));
934
- }
935
- function Pt(e, t, n, r) {
936
- let i = e.stroke;
937
- if (!i) return null;
938
- let a = p(i.width ?? 1, r);
939
- return a > 0 ? Ft(e, t, n, (e) => e.scale > 0 ? h(e.key, e.d, g(a / e.scale), i) : null) : null;
940
- }
941
- function Ft(e, t, n, r) {
942
- let i = [], a = 0, o = 0;
943
- for (let t of e.glyphs) {
944
- let e = r(t);
945
- e && e.indices.length !== 0 && (i.push({
946
- mesh: e,
947
- glyph: t
948
- }), a += e.vertices.length, o += e.indices.length);
949
- }
950
- if (i.length === 0) return null;
951
- let s = e.synthetic.italic ? Math.tan(te) : 0, c = new Float32Array(a), l = new Uint32Array(o), u = 0, d = 0, f = 0;
952
- for (let { mesh: e, glyph: r } of i) {
953
- let { x: i, baselineY: a, scale: o } = r;
954
- for (let r = 0; r < e.vertices.length; r += 2) {
955
- let l = e.vertices[r], d = e.vertices[r + 1];
956
- c[u++] = i + t + (l - d * s) * o, c[u++] = a + n + d * o;
957
- }
958
- for (let t = 0; t < e.indices.length; t++) l[d++] = f + e.indices[t];
959
- f += e.vertices.length / 2;
960
- }
961
- return {
962
- vertices: c,
963
- indices: l
964
- };
915
+ function kt(e, t, n) {
916
+ let r = G(e, t, !1);
917
+ r !== null && (K(e, n, r) || ct(e, t, e.meshCache.uploadTransient(n)));
965
918
  }
966
- function It(e, t, n, r) {
919
+ function At(e, t, n, r) {
967
920
  for (let i of t) {
968
- if (Bt(i.fill) !== null) {
969
- Mt(e, i.fill, Lt(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r));
921
+ if (Pt(i.fill) !== null) {
922
+ kt(e, i.fill, jt(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r));
970
923
  continue;
971
924
  }
972
925
  let [t, o, s, c] = "color" in i.fill ? a(i.fill.color) : [
@@ -976,14 +929,14 @@ function It(e, t, n, r) {
976
929
  1
977
930
  ], l;
978
931
  for (;;) {
979
- let a = R(e, 4);
932
+ let a = B(e, 4);
980
933
  if (e.drawBatch.pushRect(i.x0 + n, i.y0 + r, i.x1 - i.x0, i.y1 - i.y0, e.state.transform, t, o, s, c * (a.foldsAlpha ? e.state.alpha : 1))) break;
981
- l = j(e);
934
+ l = M(e);
982
935
  }
983
- l !== void 0 && M(e, l);
936
+ l !== void 0 && N(e, l);
984
937
  }
985
938
  }
986
- function Lt(e, t, n, r) {
939
+ function jt(e, t, n, r) {
987
940
  return {
988
941
  vertices: new Float32Array([
989
942
  e,
@@ -1005,17 +958,17 @@ function Lt(e, t, n, r) {
1005
958
  ])
1006
959
  };
1007
960
  }
1008
- var Rt = .08;
1009
- function zt(e, t, n, r) {
961
+ var Mt = .08;
962
+ function Nt(e, t, n, r) {
1010
963
  if (t.source === "canvas") {
1011
964
  if (!oe(e.textureCache, t.page)) return;
1012
965
  } else if (!ie(t.family, t.weight, t.style, e.textureCache)) return;
1013
966
  if (t.quads.length === 0) return;
1014
- let i = t.source === "canvas" ? re(t.page) : se(t.family, t.weight, t.style), o = t.source === "canvas" ? ne : C, s = ae(t.source === "canvas" ? "canvas" : "atlas", t.family, t.weight, t.style);
967
+ let i = t.source === "canvas" ? re(t.page) : se(t.family, t.weight, t.style), o = t.source === "canvas" ? ne : te, s = ae(t.source === "canvas" ? "canvas" : "atlas", t.family, t.weight, t.style);
1015
968
  if (!s) return;
1016
- let c = t.synthetic.bold ? Rt : 0, l = t.synthetic.italic ? Math.tan(te) : 0, u = Bt(t.fill);
969
+ let c = t.synthetic.bold ? Mt : 0, l = t.synthetic.italic ? Math.tan(g) : 0, u = Pt(t.fill);
1017
970
  if (u !== null) {
1018
- Ht(e, t, n, r, u, i, o, c, l, s);
971
+ Ft(e, t, n, r, u, i, o, c, l, s);
1019
972
  return;
1020
973
  }
1021
974
  let d = t.fill !== null && "color" in t.fill ? a(t.fill.color) : [
@@ -1023,43 +976,43 @@ function zt(e, t, n, r) {
1023
976
  0,
1024
977
  0,
1025
978
  1
1026
- ], f = e.drawBatch, p = e.state.transform, { staged: m, slot: h } = V(e, i, s, c), g = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
979
+ ], f = e.drawBatch, p = e.state.transform, { staged: m, slot: h } = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
1027
980
  for (let a of t.quads) {
1028
- f.wouldOverflow(4) && (G(e), {staged: m, slot: h} = V(e, i, s, c), g = d[3] * (m.foldsAlpha ? e.state.alpha : 1));
981
+ f.wouldOverflow(4) && (q(e), {staged: m, slot: h} = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1));
1029
982
  let t;
1030
- for (; !f.pushGlyph(a.x0 + n, a.y0 + r, a.x1 + n, a.y1 + r, a.baselineY + r, l, p, a.u0, a.v0, a.u1, a.v1, d[0], d[1], d[2], g, h, o);) t = j(e), {staged: m, slot: h} = V(e, i, s, c), g = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
1031
- t !== void 0 && (M(e, t), {staged: m, slot: h} = V(e, i, s, c), g = d[3] * (m.foldsAlpha ? e.state.alpha : 1));
983
+ for (; !f.pushGlyph(a.x0 + n, a.y0 + r, a.x1 + n, a.y1 + r, a.baselineY + r, l, p, a.u0, a.v0, a.u1, a.v1, d[0], d[1], d[2], _, h, o);) t = M(e), {staged: m, slot: h} = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1);
984
+ t !== void 0 && (N(e, t), {staged: m, slot: h} = U(e, i, s, c), _ = d[3] * (m.foldsAlpha ? e.state.alpha : 1));
1032
985
  }
1033
986
  }
1034
- function Bt(e) {
987
+ function Pt(e) {
1035
988
  let t = e?.fill ?? "solid";
1036
989
  return t === "pattern" ? "pattern" : t === "linear-gradient" || t === "radial-gradient" || t === "conic-gradient" ? "gradient" : t === "solid" ? null : "texture";
1037
990
  }
1038
- var Vt = 1;
1039
- function Ht(e, t, n, r, i, a, o, s, c, l) {
991
+ var $ = 1;
992
+ function Ft(e, t, n, r, i, a, o, s, c, l) {
1040
993
  let u = e.glyphPaintProgram?.(i);
1041
994
  if (!u) return;
1042
- P(e);
995
+ F(e);
1043
996
  let d = t.fill, f = e.state.transform, p;
1044
- if (i === "pattern") p = ft(e, u, d, O);
1045
- else if (i === "gradient") p = gt(e, u, d, O);
997
+ if (i === "pattern") p = dt(e, u, d, D);
998
+ else if (i === "gradient") p = ht(e, u, d, D);
1046
999
  else {
1047
- let i = Kt(e, d, Wt(t, n, r, c, f));
1048
- p = i && qt(e, u, i);
1000
+ let i = zt(e, d, Lt(t, n, r, c, f));
1001
+ p = i && Bt(e, u, i);
1049
1002
  }
1050
1003
  if (!p) return;
1051
1004
  let m = e.gl;
1052
- e.textureCache.bind(a, Vt), m.uniform1i(u.uniform("u_atlas"), Vt), m.uniform1f(u.uniform("u_synthBold"), s), m.uniform2f(u.uniform("u_fieldScale"), l[0], l[1]), Z(e);
1005
+ e.textureCache.bind(a, $), m.uniform1i(u.uniform("u_atlas"), $), m.uniform1f(u.uniform("u_synthBold"), s), m.uniform2f(u.uniform("u_fieldScale"), l[0], l[1]), Z(e);
1053
1006
  let h = e.drawBatch, g = h.clip;
1054
1007
  h.clip = null;
1055
- for (let i of t.quads) h.wouldOverflow(4) && Ut(e), h.pushGlyph(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r, i.baselineY + r, c, f, i.u0, i.v0, i.u1, i.v1, 1, 1, 1, 1, Vt, o);
1056
- Ut(e), h.clip = g, m.activeTexture(m.TEXTURE0), m.bindVertexArray(null);
1008
+ for (let i of t.quads) h.wouldOverflow(4) && It(e), h.pushGlyph(i.x0 + n, i.y0 + r, i.x1 + n, i.y1 + r, i.baselineY + r, c, f, i.u0, i.v0, i.u1, i.v1, 1, 1, 1, 1, $, o);
1009
+ It(e), h.clip = g, m.activeTexture(m.TEXTURE0), m.bindVertexArray(null);
1057
1010
  }
1058
- function Ut(e) {
1011
+ function It(e) {
1059
1012
  let t = e.drawBatch;
1060
- t.length !== 0 && (w(e, t.uploadAndBind(), e.gl.UNSIGNED_INT), t.reset());
1013
+ t.length !== 0 && (C(e, t.uploadAndBind(), e.gl.UNSIGNED_INT), t.reset());
1061
1014
  }
1062
- function Wt(e, t, n, r, i) {
1015
+ function Lt(e, t, n, r, i) {
1063
1016
  let a = {
1064
1017
  x0: Infinity,
1065
1018
  y0: Infinity,
@@ -1075,7 +1028,7 @@ function Wt(e, t, n, r, i) {
1075
1028
  }
1076
1029
  return a;
1077
1030
  }
1078
- var Gt = {
1031
+ var Rt = {
1079
1032
  vertices: new Float32Array([
1080
1033
  0,
1081
1034
  0,
@@ -1095,7 +1048,7 @@ var Gt = {
1095
1048
  3
1096
1049
  ])
1097
1050
  };
1098
- function Kt(e, t, n) {
1051
+ function zt(e, t, n) {
1099
1052
  let r = e.paintScratch, i = l(t.fill)?.bind;
1100
1053
  if (!r || !i) return null;
1101
1054
  let a = e.deviceWidth && e.widthCss > 0 ? e.deviceWidth / e.widthCss : 1, o = e.deviceWidth ?? Math.round(e.widthCss), s = e.deviceHeight ?? Math.round(e.heightCss), c = Math.max(0, Math.floor(n.x0 * a)), u = Math.max(0, Math.floor(n.y0 * a)), d = e.imageCache.maxTextureSide, f = Math.min(d, Math.min(o, Math.ceil(n.x1 * a)) - c), p = Math.min(d, Math.min(s, Math.ceil(n.y1 * a)) - u);
@@ -1120,15 +1073,15 @@ function Kt(e, t, n) {
1120
1073
  -1 - 2 * m / g,
1121
1074
  -1 - 2 * h / _,
1122
1075
  1
1123
- ]), b = at(e), ee = {
1076
+ ]), b = it(e), ee = {
1124
1077
  ...b,
1125
1078
  alpha: e.state.alpha,
1126
1079
  maxTextureSize: b.maxTextureSize,
1127
- setProjAndModel: (t) => q(e, t, v, y)
1080
+ setProjAndModel: (t) => J(e, t, v, y)
1128
1081
  }, x = e.gl, S = r.acquire(f, p), te = x.isEnabled(x.SCISSOR_TEST);
1129
1082
  x.activeTexture(x.TEXTURE0), x.bindTexture(x.TEXTURE_2D, null), x.bindFramebuffer(x.FRAMEBUFFER, S.fbo), x.viewport(0, 0, f, p), x.disable(x.SCISSOR_TEST), x.disable(x.STENCIL_TEST), x.clear(x.COLOR_BUFFER_BIT), x.disable(x.BLEND);
1130
- let C = i(ee, t);
1131
- return C && (x.bindVertexArray(e.meshCache.uploadRecurring(Gt).vao), w(e, Gt.indices.length, x.UNSIGNED_INT), x.bindVertexArray(null)), x.enable(x.BLEND), ke(e, o, s, te), C ? {
1083
+ let ne = i(ee, t);
1084
+ return ne && (x.bindVertexArray(e.meshCache.uploadRecurring(Rt).vao), C(e, Rt.indices.length, x.UNSIGNED_INT), x.bindVertexArray(null)), x.enable(x.BLEND), Oe(e, o, s, te), ne ? {
1132
1085
  texture: S.texture,
1133
1086
  uvFromScreen: new Float32Array([
1134
1087
  a / S.width,
@@ -1143,13 +1096,13 @@ function Kt(e, t, n) {
1143
1096
  ])
1144
1097
  } : null;
1145
1098
  }
1146
- function qt(e, t, n) {
1099
+ function Bt(e, t, n) {
1147
1100
  let r = e.gl;
1148
- return r.useProgram(t.handle), q(e, t, O), r.uniformMatrix3fv(t.uniform("u_worldInv"), !1, n.uvFromScreen), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, n.texture), r.uniform1i(t.uniform("u_sampler"), 0), t;
1101
+ return r.useProgram(t.handle), J(e, t, D), r.uniformMatrix3fv(t.uniform("u_worldInv"), !1, n.uvFromScreen), r.activeTexture(r.TEXTURE0), r.bindTexture(r.TEXTURE_2D, n.texture), r.uniform1i(t.uniform("u_sampler"), 0), t;
1149
1102
  }
1150
- function Jt(e, t) {
1103
+ function Vt(e, t) {
1151
1104
  e.imageCache.upload(t.image, t.image);
1152
- let { staged: n, slot: r } = B(e, t.image, t.sampling ?? "linear"), i = t.source, a = 0, o = 0, s = 1, c = 1;
1105
+ let { staged: n, slot: r } = H(e, t.image, t.sampling ?? "linear"), i = t.source, a = 0, o = 0, s = 1, c = 1;
1153
1106
  if (i) {
1154
1107
  let e = t.image.width, n = t.image.height;
1155
1108
  a = i.x / e, s = (i.x + i.w) / e, o = i.y / n, c = (i.y + i.h) / n;
@@ -1162,21 +1115,21 @@ function Jt(e, t) {
1162
1115
  let e = o;
1163
1116
  o = c, c = e;
1164
1117
  }
1165
- e.drawBatch.pushQuad(t.x, t.y, t.w, t.h, e.state.transform, a, o, s, c, (t.opacity ?? 1) * (n.foldsAlpha ? e.state.alpha : 1), r) || N(e, t, void 0, Jt);
1118
+ e.drawBatch.pushQuad(t.x, t.y, t.w, t.h, e.state.transform, a, o, s, c, (t.opacity ?? 1) * (n.foldsAlpha ? e.state.alpha : 1), r) || P(e, t, void 0, Vt);
1166
1119
  }
1167
- function Yt(e, t) {
1120
+ function Ht(e, t) {
1168
1121
  let n = t.sprites, r = Math.floor(n.length / u);
1169
1122
  if (r === 0) return;
1170
1123
  e.imageCache.upload(t.image, t.image);
1171
- let i = t.sampling ?? "linear", { staged: a, slot: o } = B(e, t.image, i), s = e.drawBatch, c = e.state.transform, l = a.foldsAlpha ? e.state.alpha : 1, d = t.image.width, f = t.image.height;
1124
+ let i = t.sampling ?? "linear", { staged: a, slot: o } = H(e, t.image, i), s = e.drawBatch, c = e.state.transform, l = a.foldsAlpha ? e.state.alpha : 1, d = t.image.width, f = t.image.height;
1172
1125
  for (let p = 0, m = 0; p < r; p++, m += u) {
1173
- s.wouldOverflow(4) && (G(e), {staged: a, slot: o} = B(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
1126
+ s.wouldOverflow(4) && (q(e), {staged: a, slot: o} = H(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
1174
1127
  let r = n[m + 4], u = n[m + 5], p = n[m + 6], h = n[m + 7], g;
1175
- for (; !s.pushQuad(n[m], n[m + 1], n[m + 2], n[m + 3], c, r / d, u / f, (r + p) / d, (u + h) / f, n[m + 8] * l, o);) g = j(e), {staged: a, slot: o} = B(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1;
1176
- g !== void 0 && (M(e, g), {staged: a, slot: o} = B(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
1128
+ for (; !s.pushQuad(n[m], n[m + 1], n[m + 2], n[m + 3], c, r / d, u / f, (r + p) / d, (u + h) / f, n[m + 8] * l, o);) g = M(e), {staged: a, slot: o} = H(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1;
1129
+ g !== void 0 && (N(e, g), {staged: a, slot: o} = H(e, t.image, i), l = a.foldsAlpha ? e.state.alpha : 1);
1177
1130
  }
1178
1131
  }
1179
1132
  //#endregion
1180
- export { Ot as OUTLINE_MIN_SCREEN_PX, ye as dispatch, je as drawGroup, G as flushBatch, f as getMesh, o as mat3, yt as popClip, vt as pushClip, Se as setUniform, W as tryStageFill };
1133
+ export { Tt as OUTLINE_MIN_SCREEN_PX, A as dispatch, Ae as drawGroup, q as flushBatch, f as getMesh, o as mat3, z as meshBatching, vt as popClip, _t as pushClip, xe as setUniform, K as tryStageFill };
1181
1134
 
1182
1135
  //# sourceMappingURL=draw.js.map