@mulmoclaude/shapescript-plugin 2.0.0 → 2.4.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 (54) hide show
  1. package/README.md +117 -26
  2. package/dist/core/definition.d.ts.map +1 -1
  3. package/dist/core/index.d.ts +2 -1
  4. package/dist/core/index.d.ts.map +1 -1
  5. package/dist/core/plugin.d.ts.map +1 -1
  6. package/dist/{core-BvTjfhU2.js → core-CvNYv5VF.js} +2 -2
  7. package/dist/{core-DZvhTmuk.cjs → core-DmD6zaRF.cjs} +1 -1
  8. package/dist/core.cjs +1 -1
  9. package/dist/core.js +4 -4
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.js +4 -4
  12. package/dist/lang/de.d.ts.map +1 -1
  13. package/dist/lang/en.d.ts.map +1 -1
  14. package/dist/lang/es.d.ts.map +1 -1
  15. package/dist/lang/fr.d.ts.map +1 -1
  16. package/dist/lang/ja.d.ts.map +1 -1
  17. package/dist/lang/ko.d.ts.map +1 -1
  18. package/dist/lang/messages.d.ts +4 -0
  19. package/dist/lang/messages.d.ts.map +1 -1
  20. package/dist/lang/ptBR.d.ts.map +1 -1
  21. package/dist/lang/zh.d.ts.map +1 -1
  22. package/dist/render/page.d.ts.map +1 -1
  23. package/dist/render.cjs +8 -4
  24. package/dist/render.js +14 -10
  25. package/dist/samples-BrJ4z8v-.cjs +324 -0
  26. package/dist/{samples-CXhuDdDd.js → samples-y59fsGq8.js} +281 -276
  27. package/dist/shapescript/builders.d.ts +17 -2
  28. package/dist/shapescript/builders.d.ts.map +1 -1
  29. package/dist/shapescript/evaluator.d.ts +76 -2
  30. package/dist/shapescript/evaluator.d.ts.map +1 -1
  31. package/dist/shapescript/meshValues.d.ts +54 -0
  32. package/dist/shapescript/meshValues.d.ts.map +1 -0
  33. package/dist/shapescript/minkowski.d.ts +37 -0
  34. package/dist/shapescript/minkowski.d.ts.map +1 -0
  35. package/dist/shapescript/parser.d.ts +81 -2
  36. package/dist/shapescript/parser.d.ts.map +1 -1
  37. package/dist/shapescript/text.d.ts +29 -0
  38. package/dist/shapescript/text.d.ts.map +1 -0
  39. package/dist/shapescript/toThreeJS.d.ts +159 -9
  40. package/dist/shapescript/toThreeJS.d.ts.map +1 -1
  41. package/dist/shapescript/types.d.ts +160 -17
  42. package/dist/shapescript/types.d.ts.map +1 -1
  43. package/dist/style.css +1 -1
  44. package/dist/toThreeJS-CaZGJjfO.cjs +24 -0
  45. package/dist/{toThreeJS-FsP-Na75.js → toThreeJS-OGEAi4zV.js} +6136 -3781
  46. package/dist/vue/Preview.vue.d.ts.map +1 -1
  47. package/dist/vue/View.vue.d.ts.map +1 -1
  48. package/dist/vue/index.d.ts +1 -1
  49. package/dist/vue/index.d.ts.map +1 -1
  50. package/dist/vue.cjs +37 -25
  51. package/dist/vue.js +1534 -1493
  52. package/package.json +1 -1
  53. package/dist/samples-DGD0Kjwg.cjs +0 -276
  54. package/dist/toThreeJS-MvllBF9e.cjs +0 -10
@@ -1,9 +1,9 @@
1
- import { In as e, Ln as t, Rn as n, i as r, it as i, m as a, n as o, r as s } from "./toThreeJS-FsP-Na75.js";
2
- import { ARTIFACTS_ROOT as c, buildArtifactRelPath as l, classifyFilePath as u, hasUnsafePathSegment as d, slugifyArtifact as f, toWorkspaceArtifactPath as p } from "@mulmoclaude/core/artifacts";
1
+ import { Rn as e, a as t, g as n, i as r, n as i, ot as a, r as o, s, zn as c } from "./toThreeJS-OGEAi4zV.js";
2
+ import { ARTIFACTS_ROOT as l, buildArtifactRelPath as u, classifyFilePath as d, hasUnsafePathSegment as f, slugifyArtifact as p, toWorkspaceArtifactPath as m } from "@mulmoclaude/core/artifacts";
3
3
  //#region src/core/definition.ts
4
- var m = "presentShapeScript", h = {
4
+ var h = "presentShapeScript", g = {
5
5
  type: "function",
6
- name: m,
6
+ name: h,
7
7
  description: "Display interactive 3D visualizations using ShapeScript with expressions, variables, control flow, and functions. A new `script` is saved to `artifacts/shapes/` and the returned `filePath` names it; pass `path` instead to present a source that already exists.",
8
8
  parameters: {
9
9
  type: "object",
@@ -14,7 +14,7 @@ var m = "presentShapeScript", h = {
14
14
  },
15
15
  script: {
16
16
  type: "string",
17
- description: "ShapeScript code defining the 3D scene. Supported features and syntax are listed below. Syntax, evaluation, geometry and resource-limit errors are returned as diagnostics; correct the script and retry.\n\n## SYNTAX OVERVIEW:\n\n### Expressions & Operators:\n- Arithmetic: +, -, *, /, % with proper precedence\n- Comparison: =, <>, <, <=, >, >=\n- Boolean: and, or, not\n- Parentheses for grouping: (2 + 3) * 4\n\n### Variables:\ndefine radius 2\ndefine red (1 0 0)\nsphere {\n size radius\n color red\n}\n\n### Control Flow:\n\nFor loops with variables:\nfor i in 1 to 5 {\n cube {\n position (i * 2) 0 0\n size 1\n }\n}\n\nFor loops with step:\nfor i in 0 to 10 step 2 {\n sphere { position 0 i 0 }\n}\n\nIf/else conditionals:\ndefine showSphere 1\nif showSphere {\n sphere { size 2 }\n} else {\n cube { size 2 }\n}\n\nSwitch statements:\ndefine shape 2\nswitch shape {\ncase 1\n cube\ncase 2\n sphere\nelse\n cone\n}\n\n### Built-in Functions:\n\nMath: round, floor, ceil, abs, sign, sqrt, pow, min, max\nTrig: sin, cos, tan, asin, acos, atan, atan2 (uses radians)\nVector: dot, cross, length, normalize, sum\n\nIMPORTANT: Function calls require NO space between name and parenthesis:\n- sin(x) ✓ function call\n- sin (x) ✗ NOT a function call (identifier + parenthesized expression)\nSeparate arguments with spaces, as upstream does: max(0 (j - 1)), pow(2.718 (0 - x)). Commas also work\nhere (max(0, j - 1)) but NOT in the upstream ShapeScript app, so prefer spaces. Bare max 0 1 without\nparentheses is not supported.\nWrite ONE statement per line. This parser accepts \"define a 1 define b 2\" on one line; the upstream app\nrejects it, and a script that keeps to one statement per line opens in both.\n\nExamples:\nfor i in 1 to 8 {\n define angle (i * 0.785) // 45 degrees in radians\n cube { position (cos(angle) * 3) 0 (sin(angle) * 3) }\n}\n\n### Primitives & Properties:\n\nShapes: cube, sphere, cylinder, cone, torus, circle, square, polygon (sides 3–256)\nProperties: position X Y Z, orientation ROLL YAW PITCH (alias: rotation), size X Y Z\nMaterials: color R G B (0-1), opacity (0-1)\n\nUNITS (same as upstream ShapeScript — https://shapescript.info/mac/):\n- size is the DIAMETER of sphere/cylinder/cone/circle/polygon/torus (a bare sphere fits the unit cube); for cube/square it is the edge length.\n- orientation / rotate use HALF-TURNS in roll (Z), yaw (Y), pitch (X) order: 0.5 = 90°, 1 = 180°. Positive is clockwise. A lone value is a roll: orientation 0.25 = 45° about Z. Angle-axis also works: orientation 0.5 0 1 0.\n- rotate / translate / scale as commands are relative and accumulate; orientation as a command is absolute.\n- Trig FUNCTIONS (sin, cos, …) still take radians. Convert with pi: a half-turn value h is h * pi radians.\n\n### CSG Operations:\nunion, difference, intersection, xor, stencil\n\nExample:\ndifference {\n sphere {\n size 2\n color (1 0.5 0)\n }\n cube { size 1.5 }\n}\n\n### Paths:\npath { point X Y … } — coordinates are ABSOLUTE in the path's frame. Close a path by repeating the first point.\n- curve X Y is a quadratic Bézier CONTROL point: the outline passes through the point commands on either side, not through it. Two curves in a row get an implicit on-curve midpoint, so eight curves in an octagon draw a circle.\n- A path may carry position / orientation / size of its own (path { position 0 0 2 orientation 0 0.5 0 point … }); that is how a loft section is placed in 3D. Give loft and extrude PATH children, not fill{} meshes — the upstream app rejects a mesh there.\n- rotate (half-turns) / translate / scale inside a path move the frame for later points:\n path {\n for 0 to 8 {\n curve 0 1\n rotate 1 / 8\n }\n } // semicircle\n\n### Builders:\n- extrude: extrude { polygon { sides 3 } } or an inline path (size Z = depth, default 1):\n extrude path {\n point 0 0\n point 1 0\n point 0 1\n point 0 0\n }\n- fill: fill { square } or fill path { ... }\n- lathe (revolves the XY profile about Y):\n lathe path {\n point 0 0\n point 1 0\n curve 1.5 1\n point 1 2\n point 0 2\n }\n- loft (closed planar sections joined with caps):\n loft {\n square\n translate 0 0 2\n circle\n }\n- hull (convex envelope):\n hull {\n cube { position -1 0 0 }\n cube { position 1 0 0 }\n }\n- stencil preserves the first shape and paints its surface with later shapes' materials.\nLoft sections must each have one perimeter and enclose an area; extrude/fill primitive profiles must lie in XY.\n\n### Additional Expressions:\n- Constants: pi, true, false (tau exists here but NOT in the upstream app; write 2 * pi)\n- Scientific notation and unary plus: 1e-3, +2\n- Tuple/vector members: vector.x, vector.y, vector.z; color.red/green/blue/alpha\n- Tuple/string length: value.count; zero-based indexing: values[0]; ordinals: v.first v.second … v.last, v.allButFirst, v.allButLast\n- String literals, join(...), trim(...); min/max also accept tuples\n- Custom shapes with options:\ndefine post {\n option height 2\n cylinder { size 0.2 height }\n}\npost { height 3 }\n- Random numbers: rnd (0–1) and seed N (scoped to the enclosing block, same generator as upstream)\n\n### Compatibility:\nThis plugin implements the documented modeling subset, not all upstream ShapeScript syntax; units and\npath semantics follow upstream, so a script written against the upstream docs renders the same here.\nFunction calls use name(...). Imports, textures, text/fonts, lights/cameras, arbitrary objects,\nhex/named colours, and general user-defined functions are not supported.\n\n### Comments:\n// Single-line comment\n/* Multi-line\n comment */\n\n## COMPLETE EXAMPLES:\n\nLinear arrangement with expressions:\ndefine spacing 1.5\nfor i in 1 to 4 {\n cylinder {\n position ((i - 2.5) * spacing) 0 0\n size 0.4 1\n }\n}\n\nCircular pattern:\ndefine count 12\nfor i in 1 to count {\n define angle ((i / count) * 6.283) // 2 * PI\n cube {\n position (cos(angle) * 3) 0 (sin(angle) * 3)\n color (i / count) 0.5 (1 - i / count)\n size 0.5\n }\n}\n\nConditional geometry:\ndefine makeHollow 1\nif makeHollow {\n difference {\n sphere {\n size 2\n color (1 0 0)\n }\n sphere { size 1.7 }\n }\n} else {\n sphere {\n size 2\n color (1 0 0)\n }\n}\n\nMathematical visualization:\nfor x in -5 to 5 {\n for z in -5 to 5 {\n define height (sin(x * 0.5) * cos(z * 0.5) * 2)\n cube {\n position (x * 0.3) height (z * 0.3)\n size 0.25 (abs(height) + 0.1) 0.25\n color (0.5 + height * 0.25) 0.3 (0.5 - height * 0.25)\n }\n }\n}"
17
+ description: "ShapeScript code defining the 3D scene. Supported features and syntax are listed below. Syntax, evaluation, geometry and resource-limit errors are returned as diagnostics; correct the script and retry.\n\n## SYNTAX OVERVIEW:\n\n### Expressions & Operators:\n- Arithmetic: +, -, *, /, % with proper precedence\n- Comparison: =, <>, <, <=, >, >=\n- Boolean: and, or, not\n- Parentheses for grouping: (2 + 3) * 4\n\n### Variables:\ndefine radius 2\ndefine red (1 0 0)\nsphere {\n size radius\n color red\n}\n\n### Control Flow:\n\nFor loops with variables:\nfor i in 1 to 5 {\n cube {\n position (i * 2) 0 0\n size 1\n }\n}\n\nFor loops with step:\nfor i in 0 to 10 step 2 {\n sphere { position 0 i 0 }\n}\n\nIf/else conditionals:\ndefine showSphere 1\nif showSphere {\n sphere { size 2 }\n} else {\n cube { size 2 }\n}\n\nSwitch statements:\ndefine shape 2\nswitch shape {\ncase 1\n cube\ncase 2\n sphere\nelse\n cone\n}\n\n### Built-in Functions:\n\nMath: round, floor, ceil, abs, sign, sqrt, pow, min, max\nTrig: sin, cos, tan, asin, acos, atan, atan2 (uses radians)\nVector: dot, cross, length, normalize, sum\nColour: rgb(r g b [a]), hsb(h s b [a]); strings: join, split, trim\n\nTwo call spellings, both as upstream: C-like max(0 (j - 1)) with NO space before the parenthesis, or the\nbare form max 0 (j - 1) / sqrt 9 / sin pi / 2, where the function takes every value after it. Separate\narguments with spaces; commas also work here (max(0, j - 1)) but NOT in the upstream ShapeScript app.\nInside a larger expression parenthesise a bare call: (sqrt 9) + (sqrt 16).\nCustom functions: define hyp(a b) { sqrt(a * a + b * b) } — parameters, optional defines, then the result\nexpression. A function may also build shapes: define face(data) { polygon { … } } returns what it built.\nWrite ONE statement per line. This parser accepts \"define a 1 define b 2\" on one line; the upstream app\nrejects it, and \"size 2 1 radius 0.5\" on one line reads radius as a fourth size component in both.\n\nExamples:\nfor i in 1 to 8 {\n define angle (i * 0.785) // 45 degrees in radians\n cube { position (cos(angle) * 3) 0 (sin(angle) * 3) }\n}\n\n### Primitives & Properties:\n\nShapes: cube, sphere, icosphere, cylinder, cone, torus, circle, square, roundrect (radius 0–0.5 of the smaller side), polygon (sides 3–256)\nProperties: position X Y Z, orientation ROLL YAW PITCH (alias: rotation), size X Y Z, detail N, smoothing N, name \"label\"\nMaterials (as properties or as scoped commands): color, opacity, metallicity, roughness, glow, material NAME\n- color takes 1–4 values: luminance, luminance+alpha, RGB, RGBA. Also hex #F00 / #FF0000 / #FF000080, the names\n black blue green cyan red magenta purple yellow white orange gray/grey, hsb(...), and \"color red 0.5\" to set alpha.\n- opacity multiplies through nested scopes (opacity 0.5 twice = 0.25); glow is an emissive colour; smoothing 0 = flat shading.\n- define shiny material { color blue metallicity 1 roughness 0.1 } bundles properties; apply with material shiny.\n- texture \"file.png\" and background \"file.png\" are accepted with a warning (not drawn); background R G B sets the scene colour.\n- camera { … } and light { … } blocks are accepted and skipped with a warning.\n\nUNITS (same as upstream ShapeScript — https://shapescript.info/mac/):\n- size is the DIAMETER of sphere/icosphere/cylinder/cone/circle/polygon/torus (a bare sphere fits the unit cube); for cube/square it is the edge length. size 1 2 means 1 2 1 (the third value repeats the first).\n- orientation / rotate use HALF-TURNS in roll (Z), yaw (Y), pitch (X) order: 0.5 = 90°, 1 = 180°. Positive is clockwise. A lone value is a roll: orientation 0.25 = 45° about Z. Angle-axis also works: orientation 0.5 0 1 0.\n- rotate / translate / scale as commands are relative and accumulate; orientation as a command is absolute.\n- SCOPE: a shape block, group, builder or custom block resets transforms and materials at its closing brace.\n for / if / switch bodies do NOT: a translate inside a loop carries on after it (upstream's rule). Symbols\n (define) are scoped by every block.\n- Trig FUNCTIONS (sin, cos, …) still take radians. Convert with pi: a half-turn value h is h * pi radians.\n\n### CSG Operations:\nunion, difference, intersection, xor, stencil\n\nExample:\ndifference {\n sphere {\n size 2\n color (1 0.5 0)\n }\n cube { size 1.5 }\n}\n\n### Paths:\npath { point X Y … } — coordinates are ABSOLUTE in the path's frame. Close a path by repeating the first point.\nA bare path draws as a LINE (stroke), as upstream; use fill / extrude / lathe / loft to make a surface or solid.\n- arc { angle A } inside a path: A half-turns clockwise from +Y, radius size/2 (default 0.5), with optional\n position / orientation / size — e.g. two quarter arcs and two points make a rounded slab.\n- curve X Y is a quadratic Bézier CONTROL point: the outline passes through the point commands on either side, not through it. Two curves in a row get an implicit on-curve midpoint, so eight curves in an octagon draw a circle.\n- A path may carry position / orientation / size of its own (path { position 0 0 2 orientation 0 0.5 0 point … }); that is how a loft section is placed in 3D. Give loft and extrude PATH children, not fill{} meshes — the upstream app rejects a mesh there.\n- rotate (half-turns) / translate / scale inside a path move the frame for later points:\n path {\n for 0 to 8 {\n curve 0 1\n rotate 1 / 8\n }\n } // semicircle\n\n### Builders:\n- extrude: extrude polygon { sides 3 } / extrude { … } or an inline path (size X Y scale the profile, size Z = depth, default 1):\n extrude path {\n point 0 0\n point 1 0\n point 0 1\n point 0 0\n }\n- fill: fill { square } or fill path { ... }\n- lathe (revolves the XY profile about Y):\n lathe path {\n point 0 0\n point 1 0\n curve 1.5 1\n point 1 2\n point 0 2\n }\n- loft (closed planar sections joined with caps):\n loft {\n square\n translate 0 0 2\n circle\n }\n- hull (convex envelope):\n hull {\n cube { position -1 0 0 }\n cube { position 1 0 0 }\n }\n- stencil preserves the first shape and paints its surface with later shapes' materials.\n- minkowski (the Minkowski sum; with inset it rounds edges, as upstream's Fillet example does):\n define fillet(source radius) {\n minkowski {\n inset(source radius)\n sphere { size radius * 2 }\n }\n }\n fillet(cone { color red } 0.1)\n- extrude … along (a section swept along a path, capped at the ends of an open path):\n extrude {\n circle { size 0.1 }\n along path { for i in 0 to 20 { curve 0 1 - i / 20 rotate 0.2 } }\n }\nLoft sections must each have one perimeter and enclose an area; extrude/fill primitive profiles must lie in XY.\nAn extrude path is a solid only when it is closed (its last point repeats its first); an open path extrudes\nto a wall, as upstream. inset(mesh distance) moves a mesh value's faces inward (outward when negative).\nA material command inside a builder block (extrude { color red … }) colours the result; size on a builder or\ngroup scales it. Not supported: extrude twist, svgpath.\n- text \"Hello\" / text { size 0.5 wrapwidth 3 linespacing 0.2 \"Line one\" \"Line two\" }: glyph outlines in the built-in\n Helvetica-like font, left margin at x 0 and first baseline at y 0, one unit per line (size scales it). Bare text draws\n outlines; fill text \"Hi\" makes faces and extrude { size 1 1 0.3 text \"Hi\" } solids. Values interpolate:\n text \"Bob has \" apples \" apples\", text i. Centre it with its bounds: define t text \"Hi\" then\n translate -t.bounds.width/2 -t.bounds.height/2 before fill t. font is accepted and ignored (one face only).\n- mesh { polygon { point x y z … } … }: a mesh from explicit faces; polygon { color red point a point b point c }\n takes 3D points (a tuple works: point v) and a colour per face. Faces may come from a function: mesh { for f in faces { face f } }.\n\n### Additional Expressions:\n- Constants: pi, true, false (tau exists here but NOT in the upstream app; write 2 * pi)\n- A lone position / translate value is X alone (position 1 = 1 0 0); a lone size is uniform; a lone orientation is a roll.\n- Scientific notation and unary plus: 1e-3, +2\n- Ranges as values: define loops 1 to 5 step 2, then for i in loops { … }, for i in loops step 1, and\n \"if 3 in loops\"; the in operator also tests tuples (2 in (1 2 3)) and strings.\n- Tuple/vector members: .x .y .z, .width .height .depth, .roll .yaw .pitch, .red .green .blue .alpha, .hue .saturation .brightness\n- Tuple/string length: value.count; zero-based indexing values[0], negative from the end values[-1], by name values[\"y\"];\n ordinals: v.first v.second … v.last, v.allButFirst, v.allButLast\n- String literals, join(...), split(...), trim(...); min/max also accept tuples\n- print a b … records output that is returned with the tool result; assert condition stops the script when false\n- Custom shapes with options:\ndefine post {\n option height 2\n cylinder { size 0.2 height }\n}\npost { height 3 }\n- Random numbers: rnd (0–1) and seed N (scoped to the enclosing block, same generator as upstream)\n- Shapes as values: define ico icosphere { detail 0 } then ico (places it), ico.polygons (faces, each with\n .center .points .bounds), ico.triangles, ico.bounds (.min .max .center .size .width .height .depth), ico.volume.\n- for / if as expressions: define scales for i in 1 to 3 { i / 3 }; define c if big { red } else { white }\n- Functions may build shapes: define face(data) { polygon { … } } and are called bare as statements: face data\n\n### Compatibility:\nThis plugin implements the documented modeling subset, not all upstream ShapeScript syntax; units, scoping,\nmaterials and path semantics follow upstream, so a script written against the upstream docs renders the\nsame here. Not supported (each is refused by name): import, svgpath, extrude twist,\nobject values and paths as values. Textures, fonts, cameras and lights are accepted but not drawn.\n\n### Comments:\n// Single-line comment\n/* Multi-line\n comment */\n\n## COMPLETE EXAMPLES:\n\nLinear arrangement with expressions:\ndefine spacing 1.5\nfor i in 1 to 4 {\n cylinder {\n position ((i - 2.5) * spacing) 0 0\n size 0.4 1\n }\n}\n\nCircular pattern:\ndefine count 12\nfor i in 1 to count {\n define angle ((i / count) * 6.283) // 2 * PI\n cube {\n position (cos(angle) * 3) 0 (sin(angle) * 3)\n color (i / count) 0.5 (1 - i / count)\n size 0.5\n }\n}\n\nConditional geometry:\ndefine makeHollow 1\nif makeHollow {\n difference {\n sphere {\n size 2\n color (1 0 0)\n }\n sphere { size 1.7 }\n }\n} else {\n sphere {\n size 2\n color (1 0 0)\n }\n}\n\nMathematical visualization:\nfor x in -5 to 5 {\n for z in -5 to 5 {\n define height (sin(x * 0.5) * cos(z * 0.5) * 2)\n cube {\n position (x * 0.3) height (z * 0.3)\n size 0.25 (abs(height) + 0.1) 0.25\n color (0.5 + height * 0.25) 0.3 (0.5 - height * 0.25)\n }\n }\n}"
18
18
  },
19
19
  path: {
20
20
  type: "string",
@@ -23,11 +23,11 @@ var m = "presentShapeScript", h = {
23
23
  },
24
24
  required: ["title"]
25
25
  }
26
- }, g = "shapes", _ = "shape", v = [".shape"];
27
- function y(e, t = _) {
28
- return f(e, t);
26
+ }, _ = "shapes", v = "shape", y = [".shape"];
27
+ function b(e, t = v) {
28
+ return p(e, t);
29
29
  }
30
- function b() {
30
+ function x() {
31
31
  let e = globalThis.crypto;
32
32
  if (e?.getRandomValues) {
33
33
  let t = e.getRandomValues(/* @__PURE__ */ new Uint8Array(4));
@@ -35,61 +35,61 @@ function b() {
35
35
  }
36
36
  return Math.random().toString(16).slice(2, 10).padEnd(8, "0");
37
37
  }
38
- function x(e, t = /* @__PURE__ */ new Date(), n = b()) {
39
- let r = l({
40
- dir: g,
38
+ function S(e, t = /* @__PURE__ */ new Date(), n = x()) {
39
+ let r = u({
40
+ dir: _,
41
41
  title: e,
42
42
  ext: ".shape",
43
- fallback: _,
43
+ fallback: v,
44
44
  now: t,
45
45
  partitioned: !1,
46
46
  suffix: n
47
47
  });
48
48
  return {
49
49
  relPath: r,
50
- filePath: p(r)
50
+ filePath: m(r)
51
51
  };
52
52
  }
53
- function S(e, t = /* @__PURE__ */ new Date(), n = b()) {
54
- let r = l({
55
- dir: g,
53
+ function C(e, t = /* @__PURE__ */ new Date(), n = x()) {
54
+ let r = u({
55
+ dir: _,
56
56
  title: e,
57
57
  ext: ".usdz",
58
- fallback: _,
58
+ fallback: v,
59
59
  now: t,
60
60
  partitioned: !1,
61
61
  suffix: n
62
62
  });
63
63
  return {
64
64
  relPath: r,
65
- filePath: p(r)
65
+ filePath: m(r)
66
66
  };
67
67
  }
68
- function C(e) {
69
- return !e.startsWith(`${c}/${g}/`) || !e.endsWith(".shape") ? !1 : !d(e);
70
- }
71
68
  function w(e) {
72
- return e.startsWith(`${c}/`) ? e.slice(c.length + 1) : e;
69
+ return !e.startsWith(`${l}/${_}/`) || !e.endsWith(".shape") ? !1 : !f(e);
73
70
  }
74
71
  function T(e) {
75
- return u(e, v) !== null;
72
+ return e.startsWith(`${l}/`) ? e.slice(l.length + 1) : e;
73
+ }
74
+ function E(e) {
75
+ return d(e, y) !== null;
76
76
  }
77
77
  //#endregion
78
78
  //#region src/core/dispatch.ts
79
- function E(e, t) {
80
- if (C(t)) return {
79
+ function D(e, t) {
80
+ if (w(t)) return {
81
81
  files: e.files.artifacts,
82
- rel: w(t)
82
+ rel: T(t)
83
83
  };
84
84
  let n = e.files.byPath;
85
- return n && T(t) ? {
85
+ return n && E(t) ? {
86
86
  files: n,
87
87
  rel: t
88
88
  } : null;
89
89
  }
90
- async function D(e, t) {
90
+ async function O(e, t) {
91
91
  if (typeof t?.path != "string") throw Error("path must be an existing .shape file");
92
- let n = E(e, t.path);
92
+ let n = D(e, t.path);
93
93
  if (!n) throw Error("path must be an existing .shape file");
94
94
  switch (t.kind) {
95
95
  case "loadShape": return { script: await n.files.read(n.rel) };
@@ -102,61 +102,66 @@ async function D(e, t) {
102
102
  }
103
103
  //#endregion
104
104
  //#region src/core/plugin.ts
105
- var O = "Acknowledge that the 3D visualization has been created and is displayed to the user. They can rotate, zoom, and pan the camera.", k = (e) => typeof e == "string" && e.trim() !== "";
106
- function A(t) {
107
- r(s(e(t)));
105
+ var k = "Acknowledge that the 3D visualization has been created and is displayed to the user. They can rotate, zoom, and pan the camera.", A = (e) => typeof e == "string" && e.trim() !== "";
106
+ function j(e) {
107
+ let n = o(s(e)), i = r(n);
108
+ return t(n), i;
108
109
  }
109
- async function j(e, t) {
110
+ function M(e) {
111
+ let t = [];
112
+ return e.warnings.length && t.push(`Not rendered: ${e.warnings.join("; ")}`), e.logs.length && t.push(`Output:\n${e.logs.join("\n")}`), t.length ? `\n${t.join("\n")}` : "";
113
+ }
114
+ async function N(e, t) {
110
115
  let n = e.files;
111
116
  if (!n) throw Error("This host cannot open a ShapeScript by path — pass the source as `script` instead");
112
- let r = E({ files: n }, t);
117
+ let r = D({ files: n }, t);
113
118
  if (!r) throw Error("`path` must be a .shape file, without `.` / `..` segments");
114
119
  if (!await r.files.exists(r.rel)) throw Error(`No ShapeScript exists at ${t}`);
115
120
  return r.files.read(r.rel);
116
121
  }
117
- var M = 5;
118
- async function N(e, t, n) {
122
+ var P = 5;
123
+ async function F(e, t, n) {
119
124
  let r = e.files?.artifacts;
120
125
  if (r) {
121
- for (let e = 0; e < M; e++) {
122
- let { relPath: e, filePath: i } = x(n);
126
+ for (let e = 0; e < P; e++) {
127
+ let { relPath: e, filePath: i } = S(n);
123
128
  if (!await r.exists(e)) return await r.write(e, t), i;
124
129
  }
125
130
  throw Error("Could not allocate a free path under artifacts/shapes — try again with a different title");
126
131
  }
127
132
  }
128
- async function P(e, t) {
129
- if (k(t.path) && k(t.script)) throw Error("Provide either `script` or `path`, not both");
130
- if (k(t.path)) return {
131
- script: await j(e, t.path),
133
+ async function ee(e, t) {
134
+ if (A(t.path) && A(t.script)) throw Error("Provide either `script` or `path`, not both");
135
+ if (A(t.path)) return {
136
+ script: await N(e, t.path),
132
137
  filePath: t.path
133
138
  };
134
- if (!k(t.script)) throw Error("ShapeScript code is required but was not provided");
139
+ if (!A(t.script)) throw Error("ShapeScript code is required but was not provided");
135
140
  return { script: t.script };
136
141
  }
137
- var F = async (e, r) => {
138
- let i = "INVALID_ARGUMENT";
142
+ var I = async (t, n) => {
143
+ let r = "INVALID_ARGUMENT";
139
144
  try {
140
- if (!n(r)) throw Error("presentShapeScript args must be an object with `script` or `path`");
141
- if (!k(r.title)) throw Error("A nonempty visualization title is required");
142
- let t = await P(e ?? {}, r);
143
- i = "EVALUATION_ERROR", A(t.script);
144
- let a = t.filePath ?? await N(e ?? {}, t.script, r.title);
145
+ if (!c(n)) throw Error("presentShapeScript args must be an object with `script` or `path`");
146
+ if (!A(n.title)) throw Error("A nonempty visualization title is required");
147
+ let e = await ee(t ?? {}, n);
148
+ r = "EVALUATION_ERROR";
149
+ let i = j(e.script), a = e.filePath ?? await F(t ?? {}, e.script, n.title);
145
150
  return {
146
- message: a ? `Saved ShapeScript to ${a}` : `Created 3D visualization: ${r.title}`,
147
- title: r.title,
151
+ message: (a ? `Saved ShapeScript to ${a}` : `Created 3D visualization: ${n.title}`) + M(i),
152
+ title: n.title,
148
153
  data: a ? {
149
- script: t.script,
154
+ script: e.script,
150
155
  filePath: a
151
- } : { script: t.script },
152
- instructions: O
156
+ } : { script: e.script },
157
+ instructions: k
153
158
  };
154
- } catch (e) {
159
+ } catch (t) {
155
160
  let n = {
156
- code: e instanceof t ? "PARSE_ERROR" : e instanceof o ? "LIMIT_EXCEEDED" : i,
157
- message: e instanceof Error ? e.message : String(e),
158
- ...e instanceof t && e.line !== void 0 ? { line: e.line } : {},
159
- ...e instanceof t && e.column !== void 0 ? { column: e.column } : {}
161
+ code: t instanceof e ? "PARSE_ERROR" : t instanceof i ? "LIMIT_EXCEEDED" : r,
162
+ message: t instanceof Error ? t.message : String(t),
163
+ ...t instanceof e && t.line !== void 0 ? { line: t.line } : {},
164
+ ...t instanceof e && t.column !== void 0 ? { column: t.column } : {}
160
165
  };
161
166
  return {
162
167
  message: `ShapeScript error: ${n.message}`,
@@ -165,13 +170,13 @@ var F = async (e, r) => {
165
170
  instructions: "The visualization was not created. Correct the ShapeScript using the returned diagnostic and call presentShapeScript again."
166
171
  };
167
172
  }
168
- }, ee = {
169
- toolDefinition: h,
170
- execute: F,
173
+ }, L = {
174
+ toolDefinition: g,
175
+ execute: I,
171
176
  generatingMessage: "Creating 3D visualization...",
172
177
  waitingMessage: "Tell the user that the 3D visualization was created and will be presented shortly.",
173
178
  isEnabled: () => !0
174
- }, I = F, L = Uint8Array, R = Uint16Array, z = Int32Array, te = new L([
179
+ }, R = I, z = Uint8Array, B = Uint16Array, V = Int32Array, te = new z([
175
180
  0,
176
181
  0,
177
182
  0,
@@ -204,7 +209,7 @@ var F = async (e, r) => {
204
209
  0,
205
210
  0,
206
211
  0
207
- ]), ne = new L([
212
+ ]), ne = new z([
208
213
  0,
209
214
  0,
210
215
  0,
@@ -237,7 +242,7 @@ var F = async (e, r) => {
237
242
  13,
238
243
  0,
239
244
  0
240
- ]), re = new L([
245
+ ]), re = new z([
241
246
  16,
242
247
  17,
243
248
  18,
@@ -257,42 +262,42 @@ var F = async (e, r) => {
257
262
  14,
258
263
  1,
259
264
  15
260
- ]), B = function(e, t) {
261
- for (var n = new R(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
262
- for (var i = new z(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
265
+ ]), H = function(e, t) {
266
+ for (var n = new B(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
267
+ for (var i = new V(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
263
268
  return {
264
269
  b: n,
265
270
  r: i
266
271
  };
267
- }, V = B(te, 2), H = V.b, ie = V.r;
268
- H[28] = 258, ie[258] = 28;
269
- var ae = B(ne, 0);
270
- ae.b;
271
- for (var oe = ae.r, U = new R(32768), W = 0; W < 32768; ++W) {
272
+ }, ie = H(te, 2), ae = ie.b, oe = ie.r;
273
+ ae[28] = 258, oe[258] = 28;
274
+ var U = H(ne, 0);
275
+ U.b;
276
+ for (var se = U.r, ce = new B(32768), W = 0; W < 32768; ++W) {
272
277
  var G = (W & 43690) >> 1 | (W & 21845) << 1;
273
- G = (G & 52428) >> 2 | (G & 13107) << 2, G = (G & 61680) >> 4 | (G & 3855) << 4, U[W] = ((G & 65280) >> 8 | (G & 255) << 8) >> 1;
278
+ G = (G & 52428) >> 2 | (G & 13107) << 2, G = (G & 61680) >> 4 | (G & 3855) << 4, ce[W] = ((G & 65280) >> 8 | (G & 255) << 8) >> 1;
274
279
  }
275
280
  for (var K = (function(e, t, n) {
276
- for (var r = e.length, i = 0, a = new R(t); i < r; ++i) e[i] && ++a[e[i] - 1];
277
- var o = new R(t);
281
+ for (var r = e.length, i = 0, a = new B(t); i < r; ++i) e[i] && ++a[e[i] - 1];
282
+ var o = new B(t);
278
283
  for (i = 1; i < t; ++i) o[i] = o[i - 1] + a[i - 1] << 1;
279
284
  var s;
280
285
  if (n) {
281
- s = new R(1 << t);
286
+ s = new B(1 << t);
282
287
  var c = 15 - t;
283
- for (i = 0; i < r; ++i) if (e[i]) for (var l = i << 4 | e[i], u = t - e[i], d = o[e[i] - 1]++ << u, f = d | (1 << u) - 1; d <= f; ++d) s[U[d] >> c] = l;
284
- } else for (s = new R(r), i = 0; i < r; ++i) e[i] && (s[i] = U[o[e[i] - 1]++] >> 15 - e[i]);
288
+ for (i = 0; i < r; ++i) if (e[i]) for (var l = i << 4 | e[i], u = t - e[i], d = o[e[i] - 1]++ << u, f = d | (1 << u) - 1; d <= f; ++d) s[ce[d] >> c] = l;
289
+ } else for (s = new B(r), i = 0; i < r; ++i) e[i] && (s[i] = ce[o[e[i] - 1]++] >> 15 - e[i]);
285
290
  return s;
286
- }), q = new L(288), W = 0; W < 144; ++W) q[W] = 8;
291
+ }), q = new z(288), W = 0; W < 144; ++W) q[W] = 8;
287
292
  for (var W = 144; W < 256; ++W) q[W] = 9;
288
293
  for (var W = 256; W < 280; ++W) q[W] = 7;
289
294
  for (var W = 280; W < 288; ++W) q[W] = 8;
290
- for (var J = new L(32), W = 0; W < 32; ++W) J[W] = 5;
291
- var se = /*#__PURE__*/ K(q, 9, 0), ce = /*#__PURE__*/ K(J, 5, 0), le = function(e) {
295
+ for (var le = new z(32), W = 0; W < 32; ++W) le[W] = 5;
296
+ var ue = /*#__PURE__*/ K(q, 9, 0), de = /*#__PURE__*/ K(le, 5, 0), fe = function(e) {
292
297
  return (e + 7) / 8 | 0;
293
- }, ue = function(e, t, n) {
294
- return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new L(e.subarray(t, n));
295
- }, de = [
298
+ }, pe = function(e, t, n) {
299
+ return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new z(e.subarray(t, n));
300
+ }, me = [
296
301
  "unexpected EOF",
297
302
  "invalid block type",
298
303
  "invalid length/literal",
@@ -307,30 +312,30 @@ var se = /*#__PURE__*/ K(q, 9, 0), ce = /*#__PURE__*/ K(J, 5, 0), le = function(
307
312
  "filename too long",
308
313
  "stream finishing",
309
314
  "invalid zip data"
310
- ], fe = function(e, t, n) {
311
- var r = Error(t || de[e]);
312
- if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, fe), !n) throw r;
315
+ ], he = function(e, t, n) {
316
+ var r = Error(t || me[e]);
317
+ if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, he), !n) throw r;
313
318
  return r;
314
- }, Y = function(e, t, n) {
319
+ }, J = function(e, t, n) {
315
320
  n <<= t & 7;
316
321
  var r = t / 8 | 0;
317
322
  e[r] |= n, e[r + 1] |= n >> 8;
318
- }, X = function(e, t, n) {
323
+ }, Y = function(e, t, n) {
319
324
  n <<= t & 7;
320
325
  var r = t / 8 | 0;
321
326
  e[r] |= n, e[r + 1] |= n >> 8, e[r + 2] |= n >> 16;
322
- }, pe = function(e, t) {
327
+ }, ge = function(e, t) {
323
328
  for (var n = [], r = 0; r < e.length; ++r) e[r] && n.push({
324
329
  s: r,
325
330
  f: e[r]
326
331
  });
327
332
  var i = n.length, a = n.slice();
328
333
  if (!i) return {
329
- t: be,
334
+ t: Se,
330
335
  l: 0
331
336
  };
332
337
  if (i == 1) {
333
- var o = new L(n[0].s + 1);
338
+ var o = new z(n[0].s + 1);
334
339
  return o[n[0].s] = 1, {
335
340
  t: o,
336
341
  l: 1
@@ -355,7 +360,7 @@ var se = /*#__PURE__*/ K(q, 9, 0), ce = /*#__PURE__*/ K(J, 5, 0), le = function(
355
360
  r: c
356
361
  };
357
362
  for (var f = a[0].s, r = 1; r < i; ++r) a[r].s > f && (f = a[r].s);
358
- var p = new R(f + 1), m = me(n[u - 1], p, 0);
363
+ var p = new B(f + 1), m = _e(n[u - 1], p, 0);
359
364
  if (m > t) {
360
365
  var r = 0, h = 0, g = m - t, _ = 1 << g;
361
366
  for (a.sort(function(e, t) {
@@ -376,14 +381,14 @@ var se = /*#__PURE__*/ K(q, 9, 0), ce = /*#__PURE__*/ K(J, 5, 0), le = function(
376
381
  m = t;
377
382
  }
378
383
  return {
379
- t: new L(p),
384
+ t: new z(p),
380
385
  l: m
381
386
  };
382
- }, me = function(e, t, n) {
383
- return e.s == -1 ? Math.max(me(e.l, t, n + 1), me(e.r, t, n + 1)) : t[e.s] = n;
384
- }, he = function(e) {
387
+ }, _e = function(e, t, n) {
388
+ return e.s == -1 ? Math.max(_e(e.l, t, n + 1), _e(e.r, t, n + 1)) : t[e.s] = n;
389
+ }, ve = function(e) {
385
390
  for (var t = e.length; t && !e[--t];);
386
- for (var n = new R(++t), r = 0, i = e[0], a = 1, o = function(e) {
391
+ for (var n = new B(++t), r = 0, i = e[0], a = 1, o = function(e) {
387
392
  n[r++] = e;
388
393
  }, s = 1; s <= t; ++s) if (e[s] == i && s != t) ++a;
389
394
  else {
@@ -401,44 +406,44 @@ var se = /*#__PURE__*/ K(q, 9, 0), ce = /*#__PURE__*/ K(J, 5, 0), le = function(
401
406
  c: n.subarray(0, r),
402
407
  n: t
403
408
  };
404
- }, ge = function(e, t) {
409
+ }, X = function(e, t) {
405
410
  for (var n = 0, r = 0; r < t.length; ++r) n += e[r] * t[r];
406
411
  return n;
407
- }, _e = function(e, t, n) {
408
- var r = n.length, i = le(t + 2);
412
+ }, ye = function(e, t, n) {
413
+ var r = n.length, i = fe(t + 2);
409
414
  e[i] = r & 255, e[i + 1] = r >> 8, e[i + 2] = e[i] ^ 255, e[i + 3] = e[i + 1] ^ 255;
410
415
  for (var a = 0; a < r; ++a) e[i + a + 4] = n[a];
411
416
  return (i + 4 + r) * 8;
412
- }, ve = function(e, t, n, r, i, a, o, s, c, l, u) {
413
- Y(t, u++, n), ++i[256];
414
- for (var d = pe(i, 15), f = d.t, p = d.l, m = pe(a, 15), h = m.t, g = m.l, _ = he(f), v = _.c, y = _.n, b = he(h), x = b.c, S = b.n, C = new R(19), w = 0; w < v.length; ++w) ++C[v[w] & 31];
417
+ }, be = function(e, t, n, r, i, a, o, s, c, l, u) {
418
+ J(t, u++, n), ++i[256];
419
+ for (var d = ge(i, 15), f = d.t, p = d.l, m = ge(a, 15), h = m.t, g = m.l, _ = ve(f), v = _.c, y = _.n, b = ve(h), x = b.c, S = b.n, C = new B(19), w = 0; w < v.length; ++w) ++C[v[w] & 31];
415
420
  for (var w = 0; w < x.length; ++w) ++C[x[w] & 31];
416
- for (var T = pe(C, 7), E = T.t, D = T.l, O = 19; O > 4 && !E[re[O - 1]]; --O);
417
- var k = l + 5 << 3, A = ge(i, q) + ge(a, J) + o, j = ge(i, f) + ge(a, h) + o + 14 + 3 * O + ge(C, E) + 2 * C[16] + 3 * C[17] + 7 * C[18];
418
- if (c >= 0 && k <= A && k <= j) return _e(t, u, e.subarray(c, c + l));
421
+ for (var T = ge(C, 7), E = T.t, D = T.l, O = 19; O > 4 && !E[re[O - 1]]; --O);
422
+ var k = l + 5 << 3, A = X(i, q) + X(a, le) + o, j = X(i, f) + X(a, h) + o + 14 + 3 * O + X(C, E) + 2 * C[16] + 3 * C[17] + 7 * C[18];
423
+ if (c >= 0 && k <= A && k <= j) return ye(t, u, e.subarray(c, c + l));
419
424
  var M, N, P, F;
420
- if (Y(t, u, 1 + (j < A)), u += 2, j < A) {
425
+ if (J(t, u, 1 + (j < A)), u += 2, j < A) {
421
426
  M = K(f, p, 0), N = f, P = K(h, g, 0), F = h;
422
427
  var ee = K(E, D, 0);
423
- Y(t, u, y - 257), Y(t, u + 5, S - 1), Y(t, u + 10, O - 4), u += 14;
424
- for (var w = 0; w < O; ++w) Y(t, u + 3 * w, E[re[w]]);
428
+ J(t, u, y - 257), J(t, u + 5, S - 1), J(t, u + 10, O - 4), u += 14;
429
+ for (var w = 0; w < O; ++w) J(t, u + 3 * w, E[re[w]]);
425
430
  u += 3 * O;
426
- for (var I = [v, x], L = 0; L < 2; ++L) for (var z = I[L], w = 0; w < z.length; ++w) {
427
- var B = z[w] & 31;
428
- Y(t, u, ee[B]), u += E[B], B > 15 && (Y(t, u, z[w] >> 5 & 127), u += z[w] >> 12);
431
+ for (var I = [v, x], L = 0; L < 2; ++L) for (var R = I[L], w = 0; w < R.length; ++w) {
432
+ var z = R[w] & 31;
433
+ J(t, u, ee[z]), u += E[z], z > 15 && (J(t, u, R[w] >> 5 & 127), u += R[w] >> 12);
429
434
  }
430
- } else M = se, N = q, P = ce, F = J;
435
+ } else M = ue, N = q, P = de, F = le;
431
436
  for (var w = 0; w < s; ++w) {
432
437
  var V = r[w];
433
438
  if (V > 255) {
434
- var B = V >> 18 & 31;
435
- X(t, u, M[B + 257]), u += N[B + 257], B > 7 && (Y(t, u, V >> 23 & 31), u += te[B]);
439
+ var z = V >> 18 & 31;
440
+ Y(t, u, M[z + 257]), u += N[z + 257], z > 7 && (J(t, u, V >> 23 & 31), u += te[z]);
436
441
  var H = V & 31;
437
- X(t, u, P[H]), u += F[H], H > 3 && (X(t, u, V >> 5 & 8191), u += ne[H]);
438
- } else X(t, u, M[V]), u += N[V];
442
+ Y(t, u, P[H]), u += F[H], H > 3 && (Y(t, u, V >> 5 & 8191), u += ne[H]);
443
+ } else Y(t, u, M[V]), u += N[V];
439
444
  }
440
- return X(t, u, M[256]), u + N[256];
441
- }, ye = /*#__PURE__*/ new z([
445
+ return Y(t, u, M[256]), u + N[256];
446
+ }, xe = /*#__PURE__*/ new V([
442
447
  65540,
443
448
  131080,
444
449
  131088,
@@ -448,76 +453,76 @@ var se = /*#__PURE__*/ K(q, 9, 0), ce = /*#__PURE__*/ K(J, 5, 0), le = function(
448
453
  1048832,
449
454
  2114560,
450
455
  2117632
451
- ]), be = /*#__PURE__*/ new L(0), xe = function(e, t, n, r, i, a) {
452
- var o = a.z || e.length, s = new L(r + o + 5 * (1 + Math.ceil(o / 7e3)) + i), c = s.subarray(r, s.length - i), l = a.l, u = (a.r || 0) & 7;
456
+ ]), Se = /*#__PURE__*/ new z(0), Ce = function(e, t, n, r, i, a) {
457
+ var o = a.z || e.length, s = new z(r + o + 5 * (1 + Math.ceil(o / 7e3)) + i), c = s.subarray(r, s.length - i), l = a.l, u = (a.r || 0) & 7;
453
458
  if (t) {
454
459
  u && (c[0] = a.r >> 3);
455
- for (var d = ye[t - 1], f = d >> 13, p = d & 8191, m = (1 << n) - 1, h = a.p || new R(32768), g = a.h || new R(m + 1), _ = Math.ceil(n / 3), v = 2 * _, y = function(t) {
460
+ for (var d = xe[t - 1], f = d >> 13, p = d & 8191, m = (1 << n) - 1, h = a.p || new B(32768), g = a.h || new B(m + 1), _ = Math.ceil(n / 3), v = 2 * _, y = function(t) {
456
461
  return (e[t] ^ e[t + 1] << _ ^ e[t + 2] << v) & m;
457
- }, b = new z(25e3), x = new R(288), S = new R(32), C = 0, w = 0, T = a.i || 0, E = 0, D = a.w || 0, O = 0; T + 2 < o; ++T) {
462
+ }, b = new V(25e3), x = new B(288), S = new B(32), C = 0, w = 0, T = a.i || 0, E = 0, D = a.w || 0, O = 0; T + 2 < o; ++T) {
458
463
  var k = y(T), A = T & 32767, j = g[k];
459
464
  if (h[A] = j, g[k] = A, D <= T) {
460
465
  var M = o - T;
461
466
  if ((C > 7e3 || E > 24576) && (M > 423 || !l)) {
462
- u = ve(e, c, 0, b, x, S, w, E, O, T - O, u), E = C = w = 0, O = T;
467
+ u = be(e, c, 0, b, x, S, w, E, O, T - O, u), E = C = w = 0, O = T;
463
468
  for (var N = 0; N < 286; ++N) x[N] = 0;
464
469
  for (var N = 0; N < 30; ++N) S[N] = 0;
465
470
  }
466
471
  var P = 2, F = 0, ee = p, I = A - j & 32767;
467
- if (M > 2 && k == y(T - I)) for (var re = Math.min(f, M) - 1, B = Math.min(32767, T), V = Math.min(258, M); I <= B && --ee && A != j;) {
472
+ if (M > 2 && k == y(T - I)) for (var L = Math.min(f, M) - 1, R = Math.min(32767, T), re = Math.min(258, M); I <= R && --ee && A != j;) {
468
473
  if (e[T + P] == e[T + P - I]) {
469
- for (var H = 0; H < V && e[T + H] == e[T + H - I]; ++H);
474
+ for (var H = 0; H < re && e[T + H] == e[T + H - I]; ++H);
470
475
  if (H > P) {
471
- if (P = H, F = I, H > re) break;
472
- for (var ae = Math.min(I, H - 2), U = 0, N = 0; N < ae; ++N) {
473
- var W = T - I + N & 32767, G = W - h[W] & 32767;
474
- G > U && (U = G, j = W);
476
+ if (P = H, F = I, H > L) break;
477
+ for (var ie = Math.min(I, H - 2), ae = 0, N = 0; N < ie; ++N) {
478
+ var U = T - I + N & 32767, ce = U - h[U] & 32767;
479
+ ce > ae && (ae = ce, j = U);
475
480
  }
476
481
  }
477
482
  }
478
483
  A = j, j = h[A], I += A - j & 32767;
479
484
  }
480
485
  if (F) {
481
- b[E++] = 268435456 | ie[P] << 18 | oe[F];
482
- var K = ie[P] & 31, q = oe[F] & 31;
483
- w += te[K] + ne[q], ++x[257 + K], ++S[q], D = T + P, ++C;
486
+ b[E++] = 268435456 | oe[P] << 18 | se[F];
487
+ var W = oe[P] & 31, G = se[F] & 31;
488
+ w += te[W] + ne[G], ++x[257 + W], ++S[G], D = T + P, ++C;
484
489
  } else b[E++] = e[T], ++x[e[T]];
485
490
  }
486
491
  }
487
492
  for (T = Math.max(T, D); T < o; ++T) b[E++] = e[T], ++x[e[T]];
488
- u = ve(e, c, l, b, x, S, w, E, O, T - O, u), l || (a.r = u & 7 | c[u / 8 | 0] << 3, u -= 7, a.h = g, a.p = h, a.i = T, a.w = D);
493
+ u = be(e, c, l, b, x, S, w, E, O, T - O, u), l || (a.r = u & 7 | c[u / 8 | 0] << 3, u -= 7, a.h = g, a.p = h, a.i = T, a.w = D);
489
494
  } else {
490
495
  for (var T = a.w || 0; T < o + l; T += 65535) {
491
- var J = T + 65535;
492
- J >= o && (c[u / 8 | 0] = l, J = o), u = _e(c, u + 1, e.subarray(T, J));
496
+ var K = T + 65535;
497
+ K >= o && (c[u / 8 | 0] = l, K = o), u = ye(c, u + 1, e.subarray(T, K));
493
498
  }
494
499
  a.i = o;
495
500
  }
496
- return ue(s, 0, r + le(u) + i);
497
- }, Se = /*#__PURE__*/ (function() {
501
+ return pe(s, 0, r + fe(u) + i);
502
+ }, we = /*#__PURE__*/ (function() {
498
503
  for (var e = /* @__PURE__ */ new Int32Array(256), t = 0; t < 256; ++t) {
499
504
  for (var n = t, r = 9; --r;) n = (n & 1 && -306674912) ^ n >>> 1;
500
505
  e[t] = n;
501
506
  }
502
507
  return e;
503
- })(), Ce = function() {
508
+ })(), Te = function() {
504
509
  var e = -1;
505
510
  return {
506
511
  p: function(t) {
507
- for (var n = e, r = 0; r < t.length; ++r) n = Se[n & 255 ^ t[r]] ^ n >>> 8;
512
+ for (var n = e, r = 0; r < t.length; ++r) n = we[n & 255 ^ t[r]] ^ n >>> 8;
508
513
  e = n;
509
514
  },
510
515
  d: function() {
511
516
  return ~e;
512
517
  }
513
518
  };
514
- }, we = function(e, t, n, r, i) {
519
+ }, Ee = function(e, t, n, r, i) {
515
520
  if (!i && (i = { l: 1 }, t.dictionary)) {
516
- var a = t.dictionary.subarray(-32768), o = new L(a.length + e.length);
521
+ var a = t.dictionary.subarray(-32768), o = new z(a.length + e.length);
517
522
  o.set(a), o.set(e, a.length), e = o, i.w = a.length;
518
523
  }
519
- return xe(e, t.level == null ? 6 : t.level, t.mem == null ? i.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(e.length))) * 1.5) : 20 : 12 + t.mem, n, r, i);
520
- }, Te = function(e, t) {
524
+ return Ce(e, t.level == null ? 6 : t.level, t.mem == null ? i.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(e.length))) * 1.5) : 20 : 12 + t.mem, n, r, i);
525
+ }, De = function(e, t) {
521
526
  var n = {};
522
527
  for (var r in e) n[r] = e[r];
523
528
  for (var r in t) n[r] = t[r];
@@ -525,65 +530,65 @@ var se = /*#__PURE__*/ K(q, 9, 0), ce = /*#__PURE__*/ K(J, 5, 0), le = function(
525
530
  }, Z = function(e, t, n) {
526
531
  for (; n; ++t) e[t] = n, n >>>= 8;
527
532
  };
528
- function Ee(e, t) {
529
- return we(e, t || {}, 0, 0);
533
+ function Oe(e, t) {
534
+ return Ee(e, t || {}, 0, 0);
530
535
  }
531
- var De = function(e, t, n, r) {
536
+ var ke = function(e, t, n, r) {
532
537
  for (var i in e) {
533
538
  var a = e[i], o = t + i, s = r;
534
- Array.isArray(a) && (s = Te(r, a[1]), a = a[0]), a instanceof L ? n[o] = [a, s] : (n[o += "/"] = [new L(0), s], De(a, o, n, r));
539
+ Array.isArray(a) && (s = De(r, a[1]), a = a[0]), a instanceof z ? n[o] = [a, s] : (n[o += "/"] = [new z(0), s], ke(a, o, n, r));
535
540
  }
536
- }, Oe = typeof TextEncoder < "u" && /*#__PURE__*/ new TextEncoder(), ke = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
541
+ }, Ae = typeof TextEncoder < "u" && /*#__PURE__*/ new TextEncoder(), je = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
537
542
  try {
538
- ke.decode(be, { stream: !0 });
543
+ je.decode(Se, { stream: !0 });
539
544
  } catch {}
540
- function Ae(e, t) {
545
+ function Me(e, t) {
541
546
  if (t) {
542
- for (var n = new L(e.length), r = 0; r < e.length; ++r) n[r] = e.charCodeAt(r);
547
+ for (var n = new z(e.length), r = 0; r < e.length; ++r) n[r] = e.charCodeAt(r);
543
548
  return n;
544
549
  }
545
- if (Oe) return Oe.encode(e);
546
- for (var i = e.length, a = new L(e.length + (e.length >> 1)), o = 0, s = function(e) {
550
+ if (Ae) return Ae.encode(e);
551
+ for (var i = e.length, a = new z(e.length + (e.length >> 1)), o = 0, s = function(e) {
547
552
  a[o++] = e;
548
553
  }, r = 0; r < i; ++r) {
549
554
  if (o + 5 > a.length) {
550
- var c = new L(o + 8 + (i - r << 1));
555
+ var c = new z(o + 8 + (i - r << 1));
551
556
  c.set(a), a = c;
552
557
  }
553
558
  var l = e.charCodeAt(r);
554
559
  l < 128 || t ? s(l) : l < 2048 ? (s(192 | l >> 6), s(128 | l & 63)) : l > 55295 && l < 57344 ? (l = 65536 + (l & 1047552) | e.charCodeAt(++r) & 1023, s(240 | l >> 18), s(128 | l >> 12 & 63), s(128 | l >> 6 & 63), s(128 | l & 63)) : (s(224 | l >> 12), s(128 | l >> 6 & 63), s(128 | l & 63));
555
560
  }
556
- return ue(a, 0, o);
561
+ return pe(a, 0, o);
557
562
  }
558
- var je = function(e) {
563
+ var Ne = function(e) {
559
564
  var t = 0;
560
565
  if (e) for (var n in e) {
561
566
  var r = e[n].length;
562
- r > 65535 && fe(9), t += r + 4;
567
+ r > 65535 && he(9), t += r + 4;
563
568
  }
564
569
  return t;
565
- }, Me = function(e, t, n, r, i, a, o, s) {
566
- var c = r.length, l = n.extra, u = s && s.length, d = je(l);
570
+ }, Pe = function(e, t, n, r, i, a, o, s) {
571
+ var c = r.length, l = n.extra, u = s && s.length, d = Ne(l);
567
572
  Z(e, t, o == null ? 67324752 : 33639248), t += 4, o != null && (e[t++] = 20, e[t++] = n.os), e[t] = 20, t += 2, e[t++] = n.flag << 1 | (a < 0 && 8), e[t++] = i && 8, e[t++] = n.compression & 255, e[t++] = n.compression >> 8;
568
573
  var f = new Date(n.mtime == null ? Date.now() : n.mtime), p = f.getFullYear() - 1980;
569
- if ((p < 0 || p > 119) && fe(10), Z(e, t, p << 25 | f.getMonth() + 1 << 21 | f.getDate() << 16 | f.getHours() << 11 | f.getMinutes() << 5 | f.getSeconds() >> 1), t += 4, a != -1 && (Z(e, t, n.crc), Z(e, t + 4, a < 0 ? -a - 2 : a), Z(e, t + 8, n.size)), Z(e, t + 12, c), Z(e, t + 14, d), t += 16, o != null && (Z(e, t, u), Z(e, t + 6, n.attrs), Z(e, t + 10, o), t += 14), e.set(r, t), t += c, d) for (var m in l) {
574
+ if ((p < 0 || p > 119) && he(10), Z(e, t, p << 25 | f.getMonth() + 1 << 21 | f.getDate() << 16 | f.getHours() << 11 | f.getMinutes() << 5 | f.getSeconds() >> 1), t += 4, a != -1 && (Z(e, t, n.crc), Z(e, t + 4, a < 0 ? -a - 2 : a), Z(e, t + 8, n.size)), Z(e, t + 12, c), Z(e, t + 14, d), t += 16, o != null && (Z(e, t, u), Z(e, t + 6, n.attrs), Z(e, t + 10, o), t += 14), e.set(r, t), t += c, d) for (var m in l) {
570
575
  var h = l[m], g = h.length;
571
576
  Z(e, t, +m), Z(e, t + 2, g), e.set(h, t + 4), t += 4 + g;
572
577
  }
573
578
  return u && (e.set(s, t), t += u), t;
574
- }, Ne = function(e, t, n, r, i) {
579
+ }, Fe = function(e, t, n, r, i) {
575
580
  Z(e, t, 101010256), Z(e, t + 8, n), Z(e, t + 10, n), Z(e, t + 12, r), Z(e, t + 16, i);
576
581
  };
577
- function Pe(e, t) {
582
+ function Ie(e, t) {
578
583
  t ||= {};
579
584
  var n = {}, r = [];
580
- De(e, "", n, t);
585
+ ke(e, "", n, t);
581
586
  var i = 0, a = 0;
582
587
  for (var o in n) {
583
- var s = n[o], c = s[0], l = s[1], u = l.level == 0 ? 0 : 8, d = Ae(o), f = d.length, p = l.comment, m = p && Ae(p), h = m && m.length, g = je(l.extra);
584
- f > 65535 && fe(11);
585
- var _ = u ? Ee(c, l) : c, v = _.length, y = Ce();
586
- y.p(c), r.push(Te(l, {
588
+ var s = n[o], c = s[0], l = s[1], u = l.level == 0 ? 0 : 8, d = Me(o), f = d.length, p = l.comment, m = p && Me(p), h = m && m.length, g = Ne(l.extra);
589
+ f > 65535 && he(11);
590
+ var _ = u ? Oe(c, l) : c, v = _.length, y = Te();
591
+ y.p(c), r.push(De(l, {
587
592
  size: c.length,
588
593
  crc: y.d(),
589
594
  c: _,
@@ -594,13 +599,13 @@ function Pe(e, t) {
594
599
  compression: u
595
600
  })), i += 30 + f + g + v, a += 76 + 2 * (f + g) + (h || 0) + v;
596
601
  }
597
- for (var b = new L(a + 22), x = i, S = a - i, C = 0; C < r.length; ++C) {
602
+ for (var b = new z(a + 22), x = i, S = a - i, C = 0; C < r.length; ++C) {
598
603
  var d = r[C];
599
- Me(b, d.o, d, d.f, d.u, d.c.length);
600
- var w = 30 + d.f.length + je(d.extra);
601
- b.set(d.c, d.o + w), Me(b, i, d, d.f, d.u, d.c.length, d.o, d.m), i += 16 + w + (d.m ? d.m.length : 0);
604
+ Pe(b, d.o, d, d.f, d.u, d.c.length);
605
+ var w = 30 + d.f.length + Ne(d.extra);
606
+ b.set(d.c, d.o + w), Pe(b, i, d, d.f, d.u, d.c.length, d.o, d.m), i += 16 + w + (d.m ? d.m.length : 0);
602
607
  }
603
- return Ne(b, i, r.length, S, x), b;
608
+ return Fe(b, i, r.length, S, x), b;
604
609
  }
605
610
  //#endregion
606
611
  //#region ../../../node_modules/three/examples/jsm/exporters/USDZExporter.js
@@ -644,7 +649,7 @@ var Q = class {
644
649
  let s = o.join("\n");
645
650
  return `${t}def ${this.type ? this.type + " " : ""}"${this.name}"${r}\n${t}{\n${s}\n${t}}`;
646
651
  }
647
- }, Fe = class {
652
+ }, Le = class {
648
653
  constructor() {
649
654
  this.textureUtils = null;
650
655
  }
@@ -669,27 +674,27 @@ var Q = class {
669
674
  }, t);
670
675
  let n = /* @__PURE__ */ new Set(), r = {}, i = "model.usda";
671
676
  r[i] = null;
672
- let a = Be(e, t.animations);
677
+ let a = He(e, t.animations);
673
678
  t.animationTracks = a;
674
679
  let o = new Q("Root", "Xform"), s = new Q("Scenes", "Scope");
675
680
  s.addMetadata("kind", "\"sceneLibrary\""), o.addChild(s);
676
681
  let c = "Scene", l = new Q(c, "Xform");
677
682
  l.addMetadata("customData", ["bool preliminary_collidesWithEnvironment = 0", `string sceneName = "${c}"`]), l.addMetadata("sceneName", `"${c}"`), t.includeAnchoringProperties && (l.addProperty(`token preliminary:anchoring:type = "${t.ar.anchoring.type}"`), l.addProperty(`token preliminary:planeAnchoring:alignment = "${t.ar.planeAnchoring.alignment}"`)), s.addChild(l);
678
683
  let u, d = {}, f = {};
679
- e.isScene ? We(e, l, d, n, r, t) : Ge(e, l, d, n, r, t);
680
- let p = rt(d, f, t.quickLookCompatible);
681
- u = ze(a.size > 0 ? {
684
+ e.isScene ? Ke(e, l, d, n, r, t) : qe(e, l, d, n, r, t);
685
+ let p = at(d, f, t.quickLookCompatible);
686
+ u = Ve(a.size > 0 ? {
682
687
  fps: t.animationFrameRate,
683
- endTimeCode: Ve(t.animations) * t.animationFrameRate
684
- } : null) + "\n" + o.toString() + "\n\n" + p.toString(), r[i] = Ae(u), u = null;
688
+ endTimeCode: Ue(t.animations) * t.animationFrameRate
689
+ } : null) + "\n" + o.toString() + "\n\n" + p.toString(), r[i] = Me(u), u = null;
685
690
  for (let e in f) {
686
691
  let n = f[e];
687
692
  if (n.isCompressedTexture === !0) {
688
693
  if (this.textureUtils === null) throw Error("THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.");
689
694
  n = await this.textureUtils.decompress(n);
690
695
  }
691
- let i = Re(n.image, n.flipY, t.maxTextureSize), a = n.userData.mimeType === "image/jpeg" ? "image/jpeg" : "image/png", o = await new Promise((e) => i.toBlob(e, a));
692
- r[`textures/Texture_${e}.${Le(n)}`] = new Uint8Array(await o.arrayBuffer());
696
+ let i = Be(n.image, n.flipY, t.maxTextureSize), a = n.userData.mimeType === "image/jpeg" ? "image/jpeg" : "image/png", o = await new Promise((e) => i.toBlob(e, a));
697
+ r[`textures/Texture_${e}.${ze(n)}`] = new Uint8Array(await o.arrayBuffer());
693
698
  }
694
699
  let m = 0;
695
700
  for (let e in r) {
@@ -702,17 +707,17 @@ var Q = class {
702
707
  }
703
708
  m = t.length;
704
709
  }
705
- return Pe(r, { level: 0 });
710
+ return Ie(r, { level: 0 });
706
711
  }
707
712
  };
708
- function Ie(e, t) {
713
+ function Re(e, t) {
709
714
  let n = e.name;
710
715
  return n = n.replace(/[^A-Za-z0-9_]/g, ""), /^[0-9]/.test(n) && (n = "_" + n), n === "" && (n = e.isCamera ? "Camera" : "Object"), t.has(n) && (n = n + "_" + e.id), t.add(n), n;
711
716
  }
712
- function Le(e) {
717
+ function ze(e) {
713
718
  return e.userData.mimeType === "image/jpeg" ? "jpg" : "png";
714
719
  }
715
- function Re(e, t, n) {
720
+ function Be(e, t, n) {
716
721
  if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas || typeof ImageBitmap < "u" && e instanceof ImageBitmap) {
717
722
  let r = n / Math.max(e.width, e.height), i = document.createElement("canvas");
718
723
  i.width = e.width * Math.min(1, r), i.height = e.height * Math.min(1, r);
@@ -722,7 +727,7 @@ function Re(e, t, n) {
722
727
  throw Error("THREE.USDZExporter: No valid image data found. Unable to process texture.");
723
728
  }
724
729
  var $ = 7;
725
- function ze(e = null) {
730
+ function Ve(e = null) {
726
731
  return `#usda 1.0
727
732
  (
728
733
  customLayerData = {
@@ -738,12 +743,12 @@ function ze(e = null) {
738
743
  )
739
744
  `;
740
745
  }
741
- function Be(e, t) {
746
+ function He(e, t) {
742
747
  let n = /* @__PURE__ */ new Map();
743
748
  for (let r = 0; r < t.length; r++) {
744
- let a = t[r];
745
- for (let t = 0; t < a.tracks.length; t++) {
746
- let r = a.tracks[t], o = i.parseTrackName(r.name), s = i.findNode(e, o.nodeName);
749
+ let i = t[r];
750
+ for (let t = 0; t < i.tracks.length; t++) {
751
+ let r = i.tracks[t], o = a.parseTrackName(r.name), s = a.findNode(e, o.nodeName);
747
752
  if (s == null) continue;
748
753
  let c = o.propertyName;
749
754
  if (c !== "position" && c !== "quaternion" && c !== "scale") continue;
@@ -753,12 +758,12 @@ function Be(e, t) {
753
758
  }
754
759
  return n;
755
760
  }
756
- function Ve(e) {
761
+ function Ue(e) {
757
762
  let t = 0;
758
763
  for (let n = 0; n < e.length; n++) e[n].duration > t && (t = e[n].duration);
759
764
  return t;
760
765
  }
761
- function He(e, t, n, r) {
766
+ function We(e, t, n, r) {
762
767
  let i = n.times, a = n.values, o = [];
763
768
  for (let e = 0; e < i.length; e++) {
764
769
  let t = e * 3;
@@ -766,7 +771,7 @@ function He(e, t, n, r) {
766
771
  }
767
772
  return `${t} ${e}.timeSamples = {\n\t${o.join(",\n ")},\n}`;
768
773
  }
769
- function Ue(e, t) {
774
+ function Ge(e, t) {
770
775
  let n = e.times, r = e.values, i = [];
771
776
  for (let e = 0; e < n.length; e++) {
772
777
  let a = e * 4;
@@ -774,10 +779,10 @@ function Ue(e, t) {
774
779
  }
775
780
  return `quatf xformOp:orient.timeSamples = {\n\t${i.join(",\n ")},\n}`;
776
781
  }
777
- function We(e, t, n, r, i, a) {
778
- for (let o = 0, s = e.children.length; o < s; o++) Ge(e.children[o], t, n, r, i, a);
782
+ function Ke(e, t, n, r, i, a) {
783
+ for (let o = 0, s = e.children.length; o < s; o++) qe(e.children[o], t, n, r, i, a);
779
784
  }
780
- function Ge(e, t, n, r, i, a) {
785
+ function qe(e, t, n, r, i, a) {
781
786
  if (e.visible === !1 && a.onlyVisible === !0) return;
782
787
  let o;
783
788
  if (e.isMesh) {
@@ -790,58 +795,58 @@ function Ge(e, t, n, r, i, a) {
790
795
  if (s === !1) {
791
796
  let e = `geometries/Geometry_${t.id}.usda`;
792
797
  if (!(e in i)) {
793
- let n = Ze(t);
794
- i[e] = Ae(ze() + "\n" + n.toString());
798
+ let n = $e(t);
799
+ i[e] = Me(Ve() + "\n" + n.toString());
795
800
  }
796
801
  }
797
- o = Je(e, t, l, r, a);
798
- } else o = e.isCamera ? ct(e, r, a) : qe(e, r, a);
799
- t.addChild(o), We(e, o, n, r, i, a);
802
+ o = Xe(e, t, l, r, a);
803
+ } else o = e.isCamera ? ut(e, r, a) : Ye(e, r, a);
804
+ t.addChild(o), Ke(e, o, n, r, i, a);
800
805
  }
801
- function Ke(e, t, n) {
806
+ function Je(e, t, n) {
802
807
  let r = n.animationTracks.get(t), i = t.pivot !== null;
803
808
  if (!i && r === void 0) {
804
- let n = Ye(t.matrix);
809
+ let n = Ze(t.matrix);
805
810
  e.addProperty(`matrix4d xformOp:transform = ${n}`), e.addProperty("uniform token[] xformOpOrder = [\"xformOp:transform\"]");
806
811
  return;
807
812
  }
808
813
  let a = n.animationFrameRate, o = t.position, s = t.quaternion, c = t.scale;
809
- if (r !== void 0 && r.position !== void 0 ? e.addProperty(He("xformOp:translate", "float3", r.position, a)) : e.addProperty(`float3 xformOp:translate = (${o.x.toPrecision($)}, ${o.y.toPrecision($)}, ${o.z.toPrecision($)})`), i) {
814
+ if (r !== void 0 && r.position !== void 0 ? e.addProperty(We("xformOp:translate", "float3", r.position, a)) : e.addProperty(`float3 xformOp:translate = (${o.x.toPrecision($)}, ${o.y.toPrecision($)}, ${o.z.toPrecision($)})`), i) {
810
815
  let n = t.pivot;
811
816
  e.addProperty(`float3 xformOp:translate:pivot = (${n.x.toPrecision($)}, ${n.y.toPrecision($)}, ${n.z.toPrecision($)})`);
812
817
  }
813
- r !== void 0 && r.quaternion !== void 0 ? e.addProperty(Ue(r.quaternion, a)) : e.addProperty(`quatf xformOp:orient = (${s.w.toPrecision($)}, ${s.x.toPrecision($)}, ${s.y.toPrecision($)}, ${s.z.toPrecision($)})`), r !== void 0 && r.scale !== void 0 ? e.addProperty(He("xformOp:scale", "float3", r.scale, a)) : e.addProperty(`float3 xformOp:scale = (${c.x.toPrecision($)}, ${c.y.toPrecision($)}, ${c.z.toPrecision($)})`), i ? e.addProperty("uniform token[] xformOpOrder = [\"xformOp:translate\", \"xformOp:translate:pivot\", \"xformOp:orient\", \"xformOp:scale\", \"!invert!xformOp:translate:pivot\"]") : e.addProperty("uniform token[] xformOpOrder = [\"xformOp:translate\", \"xformOp:orient\", \"xformOp:scale\"]");
818
+ r !== void 0 && r.quaternion !== void 0 ? e.addProperty(Ge(r.quaternion, a)) : e.addProperty(`quatf xformOp:orient = (${s.w.toPrecision($)}, ${s.x.toPrecision($)}, ${s.y.toPrecision($)}, ${s.z.toPrecision($)})`), r !== void 0 && r.scale !== void 0 ? e.addProperty(We("xformOp:scale", "float3", r.scale, a)) : e.addProperty(`float3 xformOp:scale = (${c.x.toPrecision($)}, ${c.y.toPrecision($)}, ${c.z.toPrecision($)})`), i ? e.addProperty("uniform token[] xformOpOrder = [\"xformOp:translate\", \"xformOp:translate:pivot\", \"xformOp:orient\", \"xformOp:scale\", \"!invert!xformOp:translate:pivot\"]") : e.addProperty("uniform token[] xformOpOrder = [\"xformOp:translate\", \"xformOp:orient\", \"xformOp:scale\"]");
814
819
  }
815
- function qe(e, t, n) {
816
- let r = Ie(e, t);
820
+ function Ye(e, t, n) {
821
+ let r = Re(e, t);
817
822
  e.matrix.determinant() < 0 && console.warn("THREE.USDZExporter: USDZ does not support negative scales", e);
818
823
  let i = new Q(r, "Xform");
819
- return Ke(i, e, n), i;
824
+ return Je(i, e, n), i;
820
825
  }
821
- function Je(e, t, n, r, i) {
822
- let a = qe(e, r, i);
823
- return n.length === 1 ? (a.addMetadata("prepend references", `@./geometries/Geometry_${t.id}.usda@</Geometry>`), a.addMetadata("prepend apiSchemas", "[\"MaterialBindingAPI\"]"), a.addProperty(`rel material:binding = </Materials/Material_${n[0].id}>`)) : a.addChild(Qe(t, n)), a;
826
+ function Xe(e, t, n, r, i) {
827
+ let a = Ye(e, r, i);
828
+ return n.length === 1 ? (a.addMetadata("prepend references", `@./geometries/Geometry_${t.id}.usda@</Geometry>`), a.addMetadata("prepend apiSchemas", "[\"MaterialBindingAPI\"]"), a.addProperty(`rel material:binding = </Materials/Material_${n[0].id}>`)) : a.addChild(et(t, n)), a;
824
829
  }
825
- function Ye(e) {
830
+ function Ze(e) {
826
831
  let t = e.elements;
827
- return `( ${Xe(t, 0)}, ${Xe(t, 4)}, ${Xe(t, 8)}, ${Xe(t, 12)} )`;
832
+ return `( ${Qe(t, 0)}, ${Qe(t, 4)}, ${Qe(t, 8)}, ${Qe(t, 12)} )`;
828
833
  }
829
- function Xe(e, t) {
834
+ function Qe(e, t) {
830
835
  return `(${e[t + 0]}, ${e[t + 1]}, ${e[t + 2]}, ${e[t + 3]})`;
831
836
  }
832
- function Ze(e) {
833
- let t = new Q("Geometry"), n = Qe(e);
837
+ function $e(e) {
838
+ let t = new Q("Geometry"), n = et(e);
834
839
  return t.addChild(n), t;
835
840
  }
836
- function Qe(e, t = null) {
841
+ function et(e, t = null) {
837
842
  let n = e.attributes, r = n.position.count, i = new Q("Geometry", "Mesh");
838
- i.addProperty(`int[] faceVertexCounts = [${$e(e)}]`), i.addProperty(`int[] faceVertexIndices = [${et(e)}]`), i.addProperty(`normal3f[] normals = [${tt(n.normal, r)}]`, ["interpolation = \"vertex\""]), i.addProperty(`point3f[] points = [${tt(n.position, r)}]`);
843
+ i.addProperty(`int[] faceVertexCounts = [${tt(e)}]`), i.addProperty(`int[] faceVertexIndices = [${nt(e)}]`), i.addProperty(`normal3f[] normals = [${rt(n.normal, r)}]`, ["interpolation = \"vertex\""]), i.addProperty(`point3f[] points = [${rt(n.position, r)}]`);
839
844
  for (let e = 0; e < 4; e++) {
840
845
  let t = e > 0 ? e : "", r = n["uv" + t];
841
- r !== void 0 && i.addProperty(`texCoord2f[] primvars:st${t} = [${nt(r)}]`, ["interpolation = \"vertex\""]);
846
+ r !== void 0 && i.addProperty(`texCoord2f[] primvars:st${t} = [${it(r)}]`, ["interpolation = \"vertex\""]);
842
847
  }
843
848
  let a = n.color;
844
- if (a !== void 0 && i.addProperty(`color3f[] primvars:displayColor = [${tt(a, r)}]`, ["interpolation = \"vertex\""]), i.addProperty("uniform token subdivisionScheme = \"none\""), t !== null) {
849
+ if (a !== void 0 && i.addProperty(`color3f[] primvars:displayColor = [${rt(a, r)}]`, ["interpolation = \"vertex\""]), i.addProperty("uniform token subdivisionScheme = \"none\""), t !== null) {
845
850
  let r = e.groups, a = (e.index === null ? n.position.count : e.index.count) / 3;
846
851
  for (let e = 0; e < r.length; e++) {
847
852
  let n = r[e], o = t[n.materialIndex];
@@ -854,11 +859,11 @@ function Qe(e, t = null) {
854
859
  }
855
860
  return i;
856
861
  }
857
- function $e(e) {
862
+ function tt(e) {
858
863
  let t = e.index === null ? e.attributes.position.count : e.index.count;
859
864
  return Array(t / 3).fill(3).join(", ");
860
865
  }
861
- function et(e) {
866
+ function nt(e) {
862
867
  let t = e.index, n = [];
863
868
  if (t !== null) for (let e = 0; e < t.count; e++) n.push(t.getX(e));
864
869
  else {
@@ -867,7 +872,7 @@ function et(e) {
867
872
  }
868
873
  return n.join(", ");
869
874
  }
870
- function tt(e, t) {
875
+ function rt(e, t) {
871
876
  if (e === void 0) return console.warn("USDZExporter: Normals missing."), Array(t).fill("(0, 0, 0)").join(", ");
872
877
  let n = [];
873
878
  for (let t = 0; t < e.count; t++) {
@@ -876,7 +881,7 @@ function tt(e, t) {
876
881
  }
877
882
  return n.join(", ");
878
883
  }
879
- function nt(e) {
884
+ function it(e) {
880
885
  let t = [];
881
886
  for (let n = 0; n < e.count; n++) {
882
887
  let r = e.getX(n), i = e.getY(n);
@@ -884,39 +889,39 @@ function nt(e) {
884
889
  }
885
890
  return t.join(", ");
886
891
  }
887
- function rt(e, t, n = !1) {
892
+ function at(e, t, n = !1) {
888
893
  let r = new Q("Materials");
889
894
  for (let i in e) {
890
895
  let a = e[i];
891
- r.addChild(it(a, t, n));
896
+ r.addChild(ot(a, t, n));
892
897
  }
893
898
  return r;
894
899
  }
895
- function it(e, t, n = !1) {
896
- let r = new Q(`Material_${e.id}`, "Material");
897
- function i(r, i, a) {
898
- let o = r.source.id + "_" + r.flipY;
899
- t[o] = r;
900
- let s = r.channel > 0 ? "st" + r.channel : "st", c = {
900
+ function ot(e, t, r = !1) {
901
+ let i = new Q(`Material_${e.id}`, "Material");
902
+ function a(n, i, a) {
903
+ let o = n.source.id + "_" + n.flipY;
904
+ t[o] = n;
905
+ let s = n.channel > 0 ? "st" + n.channel : "st", c = {
901
906
  1e3: "repeat",
902
907
  1001: "clamp",
903
908
  1002: "mirror"
904
- }, l = r.repeat.clone(), u = r.offset.clone(), d = r.rotation, f = Math.sin(d), p = Math.cos(d);
905
- u.y = 1 - u.y - l.y, n ? (u.x /= l.x, u.y /= l.y, u.x += f / l.x, u.y += p - 1) : (u.x += f * l.x, u.y += (1 - p) * l.y);
909
+ }, l = n.repeat.clone(), u = n.offset.clone(), d = n.rotation, f = Math.sin(d), p = Math.cos(d);
910
+ u.y = 1 - u.y - l.y, r ? (u.x /= l.x, u.y /= l.y, u.x += f / l.x, u.y += p - 1) : (u.x += f * l.x, u.y += (1 - p) * l.y);
906
911
  let m = new Q(`PrimvarReader_${i}`, "Shader");
907
912
  m.addProperty("uniform token info:id = \"UsdPrimvarReader_float2\""), m.addProperty("float2 inputs:fallback = (0.0, 0.0)"), m.addProperty(`string inputs:varname = "${s}"`), m.addProperty("float2 outputs:result");
908
913
  let h = new Q(`Transform2d_${i}`, "Shader");
909
- h.addProperty("uniform token info:id = \"UsdTransform2d\""), h.addProperty(`float2 inputs:in.connect = </Materials/Material_${e.id}/PrimvarReader_${i}.outputs:result>`), h.addProperty(`float inputs:rotation = ${(180 / Math.PI * d).toFixed($)}`), h.addProperty(`float2 inputs:scale = ${st(l)}`), h.addProperty(`float2 inputs:translation = ${st(u)}`), h.addProperty("float2 outputs:result");
910
- let g = new Q(`Texture_${r.id}_${i}`, "Shader");
911
- if (g.addProperty("uniform token info:id = \"UsdUVTexture\""), g.addProperty(`asset inputs:file = @textures/Texture_${o}.${Le(r)}@`), g.addProperty(`float2 inputs:st.connect = </Materials/Material_${e.id}/Transform2d_${i}.outputs:result>`), a !== void 0) {
914
+ h.addProperty("uniform token info:id = \"UsdTransform2d\""), h.addProperty(`float2 inputs:in.connect = </Materials/Material_${e.id}/PrimvarReader_${i}.outputs:result>`), h.addProperty(`float inputs:rotation = ${(180 / Math.PI * d).toFixed($)}`), h.addProperty(`float2 inputs:scale = ${lt(l)}`), h.addProperty(`float2 inputs:translation = ${lt(u)}`), h.addProperty("float2 outputs:result");
915
+ let g = new Q(`Texture_${n.id}_${i}`, "Shader");
916
+ if (g.addProperty("uniform token info:id = \"UsdUVTexture\""), g.addProperty(`asset inputs:file = @textures/Texture_${o}.${ze(n)}@`), g.addProperty(`float2 inputs:st.connect = </Materials/Material_${e.id}/Transform2d_${i}.outputs:result>`), a !== void 0) {
912
917
  let t = i === "diffuse" ? e.opacity : 1;
913
- g.addProperty(`float4 inputs:scale = ${ot(a, t)}`);
918
+ g.addProperty(`float4 inputs:scale = ${ct(a, t)}`);
914
919
  }
915
920
  if (i === "normal") {
916
921
  let t = e.normalScale.x;
917
922
  g.addProperty(`float4 inputs:scale = (${2 * t}, ${2 * t}, 2, 1)`), g.addProperty(`float4 inputs:bias = (${-t}, ${-t}, -1, 0)`);
918
923
  }
919
- return g.addProperty(`token inputs:sourceColorSpace = "${r.colorSpace === "" ? "raw" : "sRGB"}"`), g.addProperty(`token inputs:wrapS = "${c[r.wrapS]}"`), g.addProperty(`token inputs:wrapT = "${c[r.wrapT]}"`), g.addProperty("float outputs:r"), g.addProperty("float outputs:g"), g.addProperty("float outputs:b"), g.addProperty("float3 outputs:rgb"), (e.transparent || e.alphaTest > 0) && g.addProperty("float outputs:a"), [
924
+ return g.addProperty(`token inputs:sourceColorSpace = "${n.colorSpace === "" ? "raw" : "sRGB"}"`), g.addProperty(`token inputs:wrapS = "${c[n.wrapS]}"`), g.addProperty(`token inputs:wrapT = "${c[n.wrapT]}"`), g.addProperty("float outputs:r"), g.addProperty("float outputs:g"), g.addProperty("float outputs:b"), g.addProperty("float3 outputs:rgb"), (e.transparent || e.alphaTest > 0) && g.addProperty("float outputs:a"), [
920
925
  m,
921
926
  h,
922
927
  g
@@ -924,58 +929,58 @@ function it(e, t, n = !1) {
924
929
  }
925
930
  e.side === 2 && console.warn("THREE.USDZExporter: USDZ does not support double sided materials", e);
926
931
  let o = new Q("PreviewSurface", "Shader");
927
- if (o.addProperty("uniform token info:id = \"UsdPreviewSurface\""), e.map === null ? o.addProperty(`color3f inputs:diffuseColor = ${at(e.color)}`) : (o.addProperty(`color3f inputs:diffuseColor.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:rgb>`), e.transparent ? o.addProperty(`float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`) : e.alphaTest > 0 && (o.addProperty(`float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`), o.addProperty(`float inputs:opacityThreshold = ${e.alphaTest}`)), i(e.map, "diffuse", e.color).forEach((e) => r.addChild(e))), e.emissive) {
932
+ if (o.addProperty("uniform token info:id = \"UsdPreviewSurface\""), e.map === null ? o.addProperty(`color3f inputs:diffuseColor = ${st(e.color)}`) : (o.addProperty(`color3f inputs:diffuseColor.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:rgb>`), e.transparent ? o.addProperty(`float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`) : e.alphaTest > 0 && (o.addProperty(`float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`), o.addProperty(`float inputs:opacityThreshold = ${e.alphaTest}`)), a(e.map, "diffuse", e.color).forEach((e) => i.addChild(e))), e.emissive) {
928
933
  let t = e.emissiveIntensity ?? 1;
929
934
  if (e.emissiveMap) {
930
935
  o.addProperty(`color3f inputs:emissiveColor.connect = </Materials/Material_${e.id}/Texture_${e.emissiveMap.id}_emissive.outputs:rgb>`);
931
- let n = new a(e.emissive.r * t, e.emissive.g * t, e.emissive.b * t);
932
- i(e.emissiveMap, "emissive", n).forEach((e) => r.addChild(e));
933
- } else e.emissive.getHex() > 0 && o.addProperty(`color3f inputs:emissiveColor = ${at(e.emissive)}`);
936
+ let r = new n(e.emissive.r * t, e.emissive.g * t, e.emissive.b * t);
937
+ a(e.emissiveMap, "emissive", r).forEach((e) => i.addChild(e));
938
+ } else e.emissive.getHex() > 0 && o.addProperty(`color3f inputs:emissiveColor = ${st(e.emissive)}`);
934
939
  }
935
- if (e.normalMap && (o.addProperty(`normal3f inputs:normal.connect = </Materials/Material_${e.id}/Texture_${e.normalMap.id}_normal.outputs:rgb>`), i(e.normalMap, "normal").forEach((e) => r.addChild(e))), e.aoMap) {
940
+ if (e.normalMap && (o.addProperty(`normal3f inputs:normal.connect = </Materials/Material_${e.id}/Texture_${e.normalMap.id}_normal.outputs:rgb>`), a(e.normalMap, "normal").forEach((e) => i.addChild(e))), e.aoMap) {
936
941
  o.addProperty(`float inputs:occlusion.connect = </Materials/Material_${e.id}/Texture_${e.aoMap.id}_occlusion.outputs:r>`);
937
- let t = e.aoMapIntensity ?? 1, n = new a(t, t, t);
938
- i(e.aoMap, "occlusion", n).forEach((e) => r.addChild(e));
942
+ let t = e.aoMapIntensity ?? 1, r = new n(t, t, t);
943
+ a(e.aoMap, "occlusion", r).forEach((e) => i.addChild(e));
939
944
  }
940
945
  if (e.roughnessMap) {
941
946
  o.addProperty(`float inputs:roughness.connect = </Materials/Material_${e.id}/Texture_${e.roughnessMap.id}_roughness.outputs:g>`);
942
- let t = new a(e.roughness, e.roughness, e.roughness);
943
- i(e.roughnessMap, "roughness", t).forEach((e) => r.addChild(e));
947
+ let t = new n(e.roughness, e.roughness, e.roughness);
948
+ a(e.roughnessMap, "roughness", t).forEach((e) => i.addChild(e));
944
949
  } else o.addProperty(`float inputs:roughness = ${e.roughness ?? 1}`);
945
950
  if (e.metalnessMap) {
946
951
  o.addProperty(`float inputs:metallic.connect = </Materials/Material_${e.id}/Texture_${e.metalnessMap.id}_metallic.outputs:b>`);
947
- let t = new a(e.metalness, e.metalness, e.metalness);
948
- i(e.metalnessMap, "metallic", t).forEach((e) => r.addChild(e));
952
+ let t = new n(e.metalness, e.metalness, e.metalness);
953
+ a(e.metalnessMap, "metallic", t).forEach((e) => i.addChild(e));
949
954
  } else o.addProperty(`float inputs:metallic = ${e.metalness ?? 0}`);
950
- if (e.alphaMap ? (o.addProperty(`float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.alphaMap.id}_opacity.outputs:r>`), o.addProperty("float inputs:opacityThreshold = 0.0001"), i(e.alphaMap, "opacity").forEach((e) => r.addChild(e))) : o.addProperty(`float inputs:opacity = ${e.opacity}`), e.isMeshPhysicalMaterial) {
955
+ if (e.alphaMap ? (o.addProperty(`float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.alphaMap.id}_opacity.outputs:r>`), o.addProperty("float inputs:opacityThreshold = 0.0001"), a(e.alphaMap, "opacity").forEach((e) => i.addChild(e))) : o.addProperty(`float inputs:opacity = ${e.opacity}`), e.isMeshPhysicalMaterial) {
951
956
  if (e.clearcoatMap !== null) {
952
957
  o.addProperty(`float inputs:clearcoat.connect = </Materials/Material_${e.id}/Texture_${e.clearcoatMap.id}_clearcoat.outputs:r>`);
953
- let t = new a(e.clearcoat, e.clearcoat, e.clearcoat);
954
- i(e.clearcoatMap, "clearcoat", t).forEach((e) => r.addChild(e));
958
+ let t = new n(e.clearcoat, e.clearcoat, e.clearcoat);
959
+ a(e.clearcoatMap, "clearcoat", t).forEach((e) => i.addChild(e));
955
960
  } else o.addProperty(`float inputs:clearcoat = ${e.clearcoat}`);
956
961
  if (e.clearcoatRoughnessMap !== null) {
957
962
  o.addProperty(`float inputs:clearcoatRoughness.connect = </Materials/Material_${e.id}/Texture_${e.clearcoatRoughnessMap.id}_clearcoatRoughness.outputs:g>`);
958
- let t = new a(e.clearcoatRoughness, e.clearcoatRoughness, e.clearcoatRoughness);
959
- i(e.clearcoatRoughnessMap, "clearcoatRoughness", t).forEach((e) => r.addChild(e));
963
+ let t = new n(e.clearcoatRoughness, e.clearcoatRoughness, e.clearcoatRoughness);
964
+ a(e.clearcoatRoughnessMap, "clearcoatRoughness", t).forEach((e) => i.addChild(e));
960
965
  } else o.addProperty(`float inputs:clearcoatRoughness = ${e.clearcoatRoughness}`);
961
966
  o.addProperty(`float inputs:ior = ${e.ior}`);
962
967
  }
963
- return o.addProperty("int inputs:useSpecularWorkflow = 0"), o.addProperty("token outputs:surface"), r.addChild(o), r.addProperty(`token outputs:surface.connect = </Materials/Material_${e.id}/PreviewSurface.outputs:surface>`), r;
968
+ return o.addProperty("int inputs:useSpecularWorkflow = 0"), o.addProperty("token outputs:surface"), i.addChild(o), i.addProperty(`token outputs:surface.connect = </Materials/Material_${e.id}/PreviewSurface.outputs:surface>`), i;
964
969
  }
965
- function at(e) {
970
+ function st(e) {
966
971
  return `(${e.r}, ${e.g}, ${e.b})`;
967
972
  }
968
- function ot(e, t = 1) {
973
+ function ct(e, t = 1) {
969
974
  return `(${e.r}, ${e.g}, ${e.b}, ${t})`;
970
975
  }
971
- function st(e) {
976
+ function lt(e) {
972
977
  return `(${e.x}, ${e.y})`;
973
978
  }
974
- function ct(e, t, n) {
975
- let r = Ie(e, t);
979
+ function ut(e, t, n) {
980
+ let r = Re(e, t);
976
981
  e.matrix.determinant() < 0 && console.warn("THREE.USDZExporter: USDZ does not support negative scales", e);
977
982
  let i = new Q(r, "Camera");
978
- Ke(i, e, n);
983
+ Je(i, e, n);
979
984
  let a = e.isOrthographicCamera ? "orthographic" : "perspective";
980
985
  i.addProperty(`token projection = "${a}"`);
981
986
  let o = `(${e.near.toPrecision($)}, ${e.far.toPrecision($)})`;
@@ -993,25 +998,25 @@ function ct(e, t, n) {
993
998
  }
994
999
  //#endregion
995
1000
  //#region src/export/usdz.ts
996
- var lt = "model/vnd.usdz+zip", ut = ".usdz";
997
- async function dt(e) {
998
- let t = await new Fe().parseAsync(e, { quickLookCompatible: !0 });
1001
+ var dt = "model/vnd.usdz+zip", ft = ".usdz";
1002
+ async function pt(e) {
1003
+ let t = await new Le().parseAsync(e, { quickLookCompatible: !0 });
999
1004
  return new Uint8Array(t);
1000
1005
  }
1001
- async function ft(t, n = {}) {
1002
- let i = s(e(t), {
1006
+ async function mt(e, n = {}) {
1007
+ let r = o(s(e), {
1003
1008
  ...n,
1004
1009
  wireframe: !1
1005
1010
  });
1006
1011
  try {
1007
- return await dt(i);
1012
+ return await pt(r);
1008
1013
  } finally {
1009
- r(i);
1014
+ t(r);
1010
1015
  }
1011
1016
  }
1012
1017
  //#endregion
1013
1018
  //#region src/core/samples.ts
1014
- var pt = [
1019
+ var ht = [
1015
1020
  {
1016
1021
  name: "Basic Shapes",
1017
1022
  args: {
@@ -1035,4 +1040,4 @@ var pt = [
1035
1040
  }
1036
1041
  ];
1037
1042
  //#endregion
1038
- export { S as _, ft as a, F as c, v as d, T as f, w as g, y as h, dt as i, D as l, x as m, ut as n, I as o, C as p, lt as r, ee as s, pt as t, E as u, h as v, m as y };
1043
+ export { C as _, mt as a, I as c, y as d, E as f, T as g, b as h, pt as i, O as l, S as m, ft as n, R as o, w as p, dt as r, L as s, ht as t, D as u, g as v, h as y };