@selvajs/compute 3.1.0-beta.10 → 3.1.0-beta.12

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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chunk-3SEQKFGD.js +2 -0
  3. package/dist/chunk-3SEQKFGD.js.map +1 -0
  4. package/dist/chunk-44HGB4C4.cjs +2 -0
  5. package/dist/chunk-44HGB4C4.cjs.map +1 -0
  6. package/dist/chunk-H3FZW6OX.cjs +4 -0
  7. package/dist/chunk-H3FZW6OX.cjs.map +1 -0
  8. package/dist/chunk-INP5HVA2.js +62 -0
  9. package/dist/chunk-INP5HVA2.js.map +1 -0
  10. package/dist/chunk-KTKY5M5S.cjs +62 -0
  11. package/dist/chunk-KTKY5M5S.cjs.map +1 -0
  12. package/dist/chunk-Y3M7P3BW.js +4 -0
  13. package/dist/chunk-Y3M7P3BW.js.map +1 -0
  14. package/dist/core.cjs +1 -1
  15. package/dist/core.cjs.map +1 -1
  16. package/dist/core.d.cts +22 -1
  17. package/dist/core.d.ts +22 -1
  18. package/dist/core.js +1 -1
  19. package/dist/grasshopper.cjs +1 -1
  20. package/dist/grasshopper.cjs.map +1 -1
  21. package/dist/grasshopper.d.cts +20 -0
  22. package/dist/grasshopper.d.ts +20 -0
  23. package/dist/grasshopper.js +1 -1
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/{visualization-MOYO6MDN.js → visualization-5RH6RSLV.js} +2 -2
  30. package/dist/visualization-KRP5OPYW.cjs +2 -0
  31. package/dist/visualization-KRP5OPYW.cjs.map +1 -0
  32. package/dist/visualization.cjs +1 -1
  33. package/dist/visualization.cjs.map +1 -1
  34. package/dist/visualization.d.cts +35 -4
  35. package/dist/visualization.d.ts +35 -4
  36. package/dist/visualization.js +1 -1
  37. package/package.json +51 -30
  38. package/dist/chunk-2KQHHQZW.js +0 -2
  39. package/dist/chunk-2KQHHQZW.js.map +0 -1
  40. package/dist/chunk-7XMD5YXP.cjs +0 -62
  41. package/dist/chunk-7XMD5YXP.cjs.map +0 -1
  42. package/dist/chunk-CUQQ3ZBV.cjs +0 -4
  43. package/dist/chunk-CUQQ3ZBV.cjs.map +0 -1
  44. package/dist/chunk-HOWV4A5D.cjs +0 -2
  45. package/dist/chunk-HOWV4A5D.cjs.map +0 -1
  46. package/dist/chunk-PX2YTSHJ.js +0 -62
  47. package/dist/chunk-PX2YTSHJ.js.map +0 -1
  48. package/dist/chunk-WPB2LKCD.js +0 -4
  49. package/dist/chunk-WPB2LKCD.js.map +0 -1
  50. package/dist/visualization-4RSUYQG2.cjs +0 -2
  51. package/dist/visualization-4RSUYQG2.cjs.map +0 -1
  52. /package/dist/{visualization-MOYO6MDN.js.map → visualization-5RH6RSLV.js.map} +0 -0
@@ -1,62 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkCUQQ3ZBVcjs = require('./chunk-CUQQ3ZBV.cjs');var At={};_chunkCUQQ3ZBVcjs.a.call(void 0, At,{CONCRETE_MATERIAL:()=>Pe,EMISSIVE_MATERIAL:()=>Oe,GLASS_MATERIAL:()=>Ve,METAL_MATERIAL:()=>De,PLASTIC_MATERIAL:()=>Fe,RUBBER_MATERIAL:()=>Be,SHARED_MATERIALS:()=>ye,WOOD_MATERIAL:()=>ke});var _three = require('three'); var D = _interopRequireWildcard(_three); var B = _interopRequireWildcard(_three); var U = _interopRequireWildcard(_three); var k = _interopRequireWildcard(_three); var G = _interopRequireWildcard(_three); var W = _interopRequireWildcard(_three); var qe = _interopRequireWildcard(_three); var O = _interopRequireWildcard(_three); var Ee = _interopRequireWildcard(_three); var E = _interopRequireWildcard(_three); var se = _interopRequireWildcard(_three); var $ = _interopRequireWildcard(_three); var P = _interopRequireWildcard(_three);var Oe=new D.MeshPhysicalMaterial({color:0,emissive:new D.Color(16777215),emissiveIntensity:5,metalness:0,roughness:.2,clearcoat:.3,clearcoatRoughness:.2,depthWrite:!0,depthTest:!0,transparent:!1,alphaTest:0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:D.FrontSide,dithering:!0}),De=new D.MeshPhysicalMaterial({color:new D.Color(0),metalness:.9,roughness:.3,envMapIntensity:1.2,clearcoat:.3,clearcoatRoughness:.2,reflectivity:1,ior:2.5,thickness:1,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:D.FrontSide,dithering:!0}),Pe=new D.MeshPhysicalMaterial({color:new D.Color(13421772),metalness:0,roughness:.92,envMapIntensity:.15,clearcoat:.05,clearcoatRoughness:.9,reflectivity:.15,transmission:0,ior:1.45,thickness:0,depthWrite:!0,transparent:!1,alphaTest:0,depthTest:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1,side:D.FrontSide,dithering:!0}),Fe=new D.MeshPhysicalMaterial({color:new D.Color(16777215),metalness:0,roughness:.3,envMapIntensity:.5,clearcoat:.5,clearcoatRoughness:.1,reflectivity:.5,ior:1.4,transmission:0,transparent:!1,depthWrite:!0,side:D.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Ve=new D.MeshPhysicalMaterial({color:new D.Color(16777215),metalness:0,roughness:0,transmission:.95,transparent:!0,depthWrite:!1,envMapIntensity:1,clearcoat:1,clearcoatRoughness:0,ior:1.52,reflectivity:.9,thickness:1,side:D.DoubleSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),Be=new D.MeshPhysicalMaterial({color:new D.Color(1710618),metalness:0,roughness:.9,envMapIntensity:.2,clearcoat:.1,clearcoatRoughness:.8,reflectivity:.2,ior:1.3,transmission:0,depthWrite:!0,side:D.FrontSide,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ke=new D.MeshPhysicalMaterial({color:new D.Color(8934707),metalness:0,roughness:.7,envMapIntensity:.3,clearcoat:.3,clearcoatRoughness:.4,reflectivity:.3,ior:1.3,transmission:0,depthWrite:!0,side:D.FrontSide,dithering:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),ye=new Set([Oe,De,Pe,Fe,Ve,Be,ke]);var K={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function qr(e,r,t,n,i){if(Ot(e),r.length===0)return;r.forEach(u=>{e.add(u)});let o=be(r),a=o.getCenter(new B.Vector3),s=o.getSize(new B.Vector3),l=Math.max(s.x,s.y,s.z);if(l/Math.min(s.x||1,s.y||1,s.z||1)>K.SCALE_RATIO_THRESHOLD||l>K.HUGE_THRESHOLD?(t.near=l*K.NEAR_PLANE_FACTOR.TINY,t.far=l*K.FAR_PLANE_FACTOR.HUGE):l>K.LARGE_THRESHOLD?(t.near=l*K.NEAR_PLANE_FACTOR.SMALL,t.far=l*K.FAR_PLANE_FACTOR.LARGE):(t.near=Math.max(.01,l*K.NEAR_PLANE_FACTOR.NORMAL),t.far=Math.max(2e3,l*K.FAR_PLANE_FACTOR.NORMAL)),t.updateProjectionMatrix(),!i){let u=l*K.INITIAL_DISTANCE_MULTIPLIER;t.position.set(a.x+u*.8,a.y+u,a.z+u*1.2),n.target.copy(a),n.update()}}function Ue(e){if(!e||typeof e!="string")return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Invalid color input: ${e}, using white`),new B.Color(16777215);let r=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(r))try{let n=r.startsWith("#")?r:`#${r}`;return new B.Color(n)}catch (e2){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Invalid hex color: ${e}, using white`),new B.Color(16777215)}if(r.includes(",")){let n=r.split(",").map(i=>parseInt(i.trim(),10));if(n.length===3&&n.every(i=>!isNaN(i)&&i>=0&&i<=255))return new B.Color(n[0]/255,n[1]/255,n[2]/255)}let t=r.toLowerCase();return t in B.Color.NAMES?new B.Color(B.Color.NAMES[t]):(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Invalid color string: ${e}, using white`),new B.Color(16777215))}function ze(e,r,t="z"){e.forEach(n=>{n.position[t]-=r})}function be(e){let r=new B.Box3;return e.length===0||e.forEach(t=>{t.updateMatrixWorld(!0);let n=new B.Box3().setFromObject(t);r.union(n)}),r}var St=new Set(["grid","floor","label-layer","measure"]);function Lt(e){let r=e;for(;r;){if(typeof r.userData.id=="string"&&St.has(r.userData.id))return!0;r=r.parent}return!1}function Q(e){e.updateMatrixWorld(!0);let r=new B.Box3;return e.traverse(t=>{let n=t;t.visible&&!Lt(t)&&n.geometry&&r.expandByObject(t)}),r}var It=new Set(["floor","grid","label-layer"]);function Ot(e){[...e.children].forEach(t=>{It.has(t.userData.id)||t.userData.source!=="user"&&(t.traverse(n=>{let i=n;if(!i.geometry&&!i.material)return;_optionalChain([i, 'access', _2 => _2.geometry, 'optionalAccess', _3 => _3.dispose, 'call', _4 => _4()]);let o=i.material;if(!o)return;(Array.isArray(o)?o:[o]).forEach(s=>{if(!ye.has(s)){for(let l of Object.values(s))l instanceof B.Texture&&l.dispose();s.dispose()}})}),t.removeFromParent())})}function Dt(e){let r=e.clone().normalize(),t=new U.Vector3(0,0,1),n=new U.Vector3(0,1,0),i=Math.abs(r.dot(t))>.9?n:t,o=new U.Vector3().crossVectors(r,i).normalize(),a=new U.Vector3().crossVectors(o,r).normalize();return{top:r.clone(),bottom:r.clone().negate(),front:a.clone(),back:a.clone().negate(),right:o.clone(),left:o.clone().negate(),iso:a.clone().multiplyScalar(1.2).add(o.clone()).add(r.clone()).normalize()}}function _e(e){let{scene:r,perspective:t,controls:n,onActiveCameraChange:i}=e,o=(_nullishCoalesce(e.up, () => (t.up))).clone().normalize(),a=Dt(o),s=new U.OrthographicCamera(-1,1,1,-1,t.near,t.far);s.up.copy(o);let l="perspective",c=t.aspect,u=()=>l==="perspective"?t:s,m=null,d=()=>{_optionalChain([m, 'optionalAccess', _5 => _5.cancel, 'call', _6 => _6()]),m=null},f=()=>{let R=(l==="orthographic"?s:t).position.distanceTo(n.target)*Math.tan(t.fov*Math.PI/360),w=R*c;s.left=-w,s.right=w,s.top=R,s.bottom=-R,s.near=t.near,s.far=t.far,s.updateProjectionMatrix()},b=p=>{if(p!==l){if(d(),p==="orthographic")s.position.copy(t.position),s.up.copy(t.up),s.lookAt(n.target),s.zoom=1,f();else{let R=(s.top-s.bottom)/(2*s.zoom)/Math.tan(t.fov*Math.PI/360),w=s.position.clone().sub(n.target);w.lengthSq()<1e-12&&w.copy(o),w.normalize(),t.position.copy(n.target).add(w.multiplyScalar(R))}l=p,n.object=u(),n.update(),i(u())}},T=(p,g,R,w)=>{let S=t.fov*(Math.PI/180),F=g/(2*Math.tan(S/2))*1.5,Y=Pt(R,o),V=p.clone().add(Y.clone().multiplyScalar(F)),X=u();l==="orthographic"&&(s.zoom=1),d(),w?m=Vt(X,n,V,p,()=>{l==="orthographic"&&f()}):(X.position.copy(V),n.target.copy(p),l==="orthographic"&&f(),n.update())},H=(p,g=!0)=>{let R=Q(r),w=R.isEmpty()?n.target.clone():R.getCenter(new U.Vector3),S=R.isEmpty()?new U.Vector3(1,1,1):R.getSize(new U.Vector3),F=Math.max(S.x,S.y,S.z)||1;T(w,F,p,g)};return{getActiveCamera:u,getProjection:()=>l,setProjection:b,toggleProjection:()=>(b(l==="perspective"?"orthographic":"perspective"),l),setView:(p,g=!0)=>{H(a[p],g)},setViewDirection:H,frameBounds:(p,g=!0)=>{if(p.isEmpty())return;let R=p.getCenter(new U.Vector3),w=p.getSize(new U.Vector3),S=Math.max(w.x,w.y,w.z)||1,F=u().position.clone().sub(n.target);F.lengthSq()<1e-12&&F.copy(a.iso),T(R,S,F.normalize(),g)},setRotateEnabled:p=>{n.enableRotate=p},isRotateEnabled:()=>n.enableRotate,updateAspect:(p,g)=>{c=g===0?c:p/g,l==="orthographic"&&f()},dispose:d}}function Pt(e,r){let t=r.clone().normalize(),n=e.clone().normalize();if(Math.abs(n.dot(t))<.9999)return e;let i=Math.abs(t.dot(new U.Vector3(0,0,1)))>.9?new U.Vector3(0,1,0):new U.Vector3(0,0,1),o=new U.Vector3().crossVectors(t,i).normalize(),a=.5*Math.PI/180;return n.multiplyScalar(Math.cos(a)).add(o.multiplyScalar(Math.sin(a))).normalize()}var Ft=e=>1-Math.pow(1-e,3);function Vt(e,r,t,n,i,o=250){let a=e.position.clone(),s=r.target.clone(),l=performance.now(),c=null,u=()=>{c=null;let m=Ft(Math.min((performance.now()-l)/o,1));e.position.lerpVectors(a,t,m),r.target.lerpVectors(s,n,m),i(),r.update(),m<1&&(c=requestAnimationFrame(u))};return c=requestAnimationFrame(u),{cancel:()=>{c!==null&&(cancelAnimationFrame(c),c=null)}}}var Bt=`
2
- varying vec3 vWorldPos;
3
- void main() {
4
- vec4 world = modelMatrix * vec4(position, 1.0);
5
- vWorldPos = world.xyz;
6
- gl_Position = projectionMatrix * viewMatrix * world;
7
- }
8
- `,kt=`
9
- precision highp float;
10
- varying vec3 vWorldPos;
11
-
12
- uniform vec2 uAxes; // indices (0=x,1=y,2=z) of the two in-plane world axes
13
- uniform float uCell;
14
- uniform float uMajor;
15
- uniform vec3 uCellColor;
16
- uniform vec3 uMajorColor;
17
- uniform vec3 uCenter; // fade center (camera position), projected onto plane
18
- uniform float uFade;
19
-
20
- // Antialiased grid line intensity for a given spacing, using screen-space derivatives so lines
21
- // stay ~1px regardless of zoom (the standard "pristine grid" technique).
22
- float gridLine(vec2 coord, float spacing) {
23
- vec2 c = coord / spacing;
24
- vec2 d = fwidth(c);
25
- vec2 g = abs(fract(c - 0.5) - 0.5) / max(d, 1e-6);
26
- float line = min(g.x, g.y);
27
- return 1.0 - clamp(line, 0.0, 1.0);
28
- }
29
-
30
- // Index a vec3 by a float axis id (0/1/2) without dynamic indexing (WebGL1-safe).
31
- float axis(vec3 v, float i) {
32
- return i < 0.5 ? v.x : (i < 1.5 ? v.y : v.z);
33
- }
34
-
35
- void main() {
36
- // Pick the two in-plane world coordinates.
37
- vec2 coord = vec2(axis(vWorldPos, uAxes.x), axis(vWorldPos, uAxes.y));
38
-
39
- float minor = gridLine(coord, uCell);
40
- float major = gridLine(coord, uCell * uMajor);
41
-
42
- vec3 color = mix(uCellColor, uMajorColor, major);
43
- float alpha = max(minor, major);
44
-
45
- // Radial fade from the camera-projected center.
46
- float dist = distance(vWorldPos, uCenter);
47
- float fade = 1.0 - clamp(dist / uFade, 0.0, 1.0);
48
- alpha *= fade * fade;
49
-
50
- if (alpha < 0.001) discard;
51
- gl_FragColor = vec4(color, alpha);
52
- }
53
- `;function je(e={}){let{cellSize:r=1,majorEvery:t=10,cellColor:n=8947848,majorColor:i=4473924,fadeDistance:o=100,plane:a="y"}=e,s=a==="y"?new k.Vector2(0,2):a==="z"?new k.Vector2(0,1):new k.Vector2(1,2),l=o*2.5,c=new k.PlaneGeometry(l,l);a==="y"?c.rotateX(-Math.PI/2):a==="x"&&c.rotateY(Math.PI/2);let u=new k.ShaderMaterial({vertexShader:Bt,fragmentShader:kt,transparent:!0,depthWrite:!1,side:k.DoubleSide,uniforms:{uAxes:{value:s},uCell:{value:r},uMajor:{value:t},uCellColor:{value:new k.Color(n)},uMajorColor:{value:new k.Color(i)},uCenter:{value:new k.Vector3},uFade:{value:o}}}),m=new k.Mesh(c,u);m.name="grid",m.userData.id="grid",m.renderOrder=-1;let d=new k.Vector3;return{object:m,update:f=>{a==="y"?(m.position.set(f.x,0,f.z),d.set(f.x,0,f.z)):a==="z"?(m.position.set(f.x,f.y,0),d.set(f.x,f.y,0)):(m.position.set(0,f.y,f.z),d.set(0,f.y,f.z)),u.uniforms.uCenter.value.copy(d)},setVisible:f=>{m.visible=f},dispose:()=>{m.removeFromParent(),c.dispose(),u.dispose()}}}var _ViewHelperjs = require('three/addons/helpers/ViewHelper.js');function Ne(e){let{camera:r,domElement:t,controller:n}=e,i=new (0, _ViewHelperjs.ViewHelper)(r,t);i.setLabels("X","Y","Z");let o=!0,a=128,s=new G.Raycaster,l=new G.OrthographicCamera(-2,2,2,-2,0,4);l.position.set(0,0,2),l.updateMatrixWorld();let c={posX:new G.Vector3(1,0,0),negX:new G.Vector3(-1,0,0),posY:new G.Vector3(0,1,0),negY:new G.Vector3(0,-1,0),posZ:new G.Vector3(0,0,1),negZ:new G.Vector3(0,0,-1)},u=d=>{let f=t.getBoundingClientRect(),b=f.left+t.offsetWidth-a-i.location.right,T=f.top+t.offsetHeight-a-i.location.bottom,H=new G.Vector2((d.clientX-b)/a*2-1,-((d.clientY-T)/a)*2+1);if(Math.abs(H.x)>1||Math.abs(H.y)>1)return null;i.quaternion.copy(r.quaternion).invert(),i.updateMatrixWorld(),s.setFromCamera(H,l);let x=s.intersectObjects(i.children,!1);for(let y of x){let C=_optionalChain([y, 'access', _7 => _7.object, 'access', _8 => _8.userData, 'optionalAccess', _9 => _9.type]);if(typeof C=="string"&&C in c)return C}return null};return{render:d=>{if(!o)return;let f=d.autoClear;d.autoClear=!1,i.render(d),d.autoClear=f},update:()=>{},handleClick:d=>{if(!o)return!1;let f=u(d);return f?(n.getProjection()==="orthographic"&&n.setProjection("perspective"),n.setViewDirection(c[f],!1),!0):!1},isAnimating:!1,setVisible:d=>{o=d},isVisible:()=>o,dispose:()=>i.dispose()}}var _LineSegmentsGeometryjs = require('three/addons/lines/LineSegmentsGeometry.js');var _LineSegments2js = require('three/addons/lines/LineSegments2.js');var _LineMaterialjs = require('three/addons/lines/LineMaterial.js');var de="edge-overlay",jt=2236962,Nt=1.5,Gt=30,Wt=80,Ge=20,$t=1,Yt=2;function $e(e,r){let t=Array.isArray(e.material)?e.material:[e.material];for(let n of t)n&&(n.polygonOffset=r,n.polygonOffsetFactor=r?$t:0,n.polygonOffsetUnits=r?Yt:0)}var Te=new WeakMap;function Ye(e,r={}){let t=new W.Color(_nullishCoalesce(r.color, () => (jt))),n=_nullishCoalesce(r.width, () => (Nt)),i=_nullishCoalesce(r.thresholdAngle, () => (Gt)),o=_nullishCoalesce(r.distanceFade, () => (!0)),a=Zt(t,n,o),s=[];return e.traverse(l=>{if(!(l instanceof W.Mesh)||l.userData.id==="floor"||l.userData.id==="grid"||l.userData.kind===de||l.children.some(u=>_optionalChain([u, 'access', _10 => _10.userData, 'optionalAccess', _11 => _11.kind])===de)||!l.geometry)return;let c=Kt(l.geometry,a,i,o);l.add(c),$e(l,!0),s.push(c)}),s.length===0&&a.dispose(),s}function Xt(e,r){let t=Te.get(e);t||(t=new Map,Te.set(e,t));let n=t.get(r);if(!n){let i=new W.EdgesGeometry(e,r),o=new _LineSegmentsGeometryjs.LineSegmentsGeometry;o.setPositions(i.attributes.position.array),i.dispose(),n={geometry:o,refCount:0},t.set(r,n)}return n.refCount+=1,n.geometry}function qt(e){let r=e.userData,t=r.edgeSource&&Te.get(r.edgeSource),n=r.edgeThresholdAngle!=null?_optionalChain([t, 'optionalAccess', _12 => _12.get, 'call', _13 => _13(r.edgeThresholdAngle)]):void 0;if(!n||n.geometry!==e.geometry){e.geometry.dispose();return}n.refCount-=1,n.refCount<=0&&(n.geometry.dispose(),t.delete(r.edgeThresholdAngle))}function Zt(e,r,t){let n=new (0, _LineMaterialjs.LineMaterial)({color:e});return n.linewidth=r,t&&(n.transparent=!0),n}function Kt(e,r,t,n){let i=Xt(e,t),o=new (0, _LineSegments2js.LineSegments2)(i,r);return o.userData.kind=de,o.userData.edgeSource=e,o.userData.edgeThresholdAngle=t,o.raycast=()=>{},n&&en(o),o}var We=new W.Vector3,Jt=new W.Vector3;function Qt(e,r,t){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let n=e.geometry.boundingSphere;if(!n||n.radius<=0)return 1/0;let i=n.radius*e.matrixWorld.getMaxScaleOnAxis();if(We.copy(n.center).applyMatrix4(e.matrixWorld),r.isPerspectiveCamera){let o=r,a=Jt.setFromMatrixPosition(r.matrixWorld).distanceTo(We);if(a<=i)return 1/0;let s=Math.tan(W.MathUtils.degToRad(o.fov)*.5);return i/(a*s)*t}if(r.isOrthographicCamera){let o=r,a=(o.top-o.bottom)/o.zoom;return a>0?2*i/a*t:1/0}return 1/0}function en(e){e.onBeforeRender=(r,t,n)=>{_LineSegments2js.LineSegments2.prototype.onBeforeRender.call(e,r);let i=e.material,o=Qt(e,n,i.resolution.y);i.opacity=W.MathUtils.clamp((o-Ge)/(Wt-Ge),0,1)}}function tn(e){return _optionalChain([e, 'access', _14 => _14.userData, 'optionalAccess', _15 => _15.kind])===de}function io(e){let r=[];e.traverse(n=>{n instanceof _LineSegments2js.LineSegments2&&tn(n)&&r.push(n)});let t=new Set;for(let n of r)qt(n),t.add(n.material),n.parent instanceof W.Mesh&&$e(n.parent,!1),n.removeFromParent();return t.forEach(n=>n.dispose()),r.length}var _EffectComposerjs = require('three/addons/postprocessing/EffectComposer.js');var _RenderPassjs = require('three/addons/postprocessing/RenderPass.js');var _GTAOPassjs = require('three/addons/postprocessing/GTAOPass.js');var _SMAAPassjs = require('three/addons/postprocessing/SMAAPass.js');var _OutputPassjs = require('three/addons/postprocessing/OutputPass.js');function Xe(e,r,t,n,i,o){let a=new (0, _EffectComposerjs.EffectComposer)(e),s=new (0, _RenderPassjs.RenderPass)(r,t);a.addPass(s);let l=new (0, _GTAOPassjs.GTAOPass)(r,t,n,i);l.blendIntensity=_nullishCoalesce(o.aoIntensity, () => (1)),l.updateGtaoMaterial({screenSpaceRadius:!0}),a.addPass(l);let c=new _SMAAPassjs.SMAAPass;a.addPass(c);let u=new _OutputPassjs.OutputPass;a.addPass(u),e.toneMapping=o.toneMapping,e.toneMappingExposure=o.toneMappingExposure;let m=_nullishCoalesce(o.aoPixelRatio, () => (1));return a.setSize(n,i),{render:d=>a.render(d),setSize:(d,f,b)=>{a.setPixelRatio(Math.min(b,m)),a.setSize(d,f)},setCamera:d=>{s.camera=d,l.camera=d;let f=d.isPerspectiveCamera?1:0;l.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==f&&(l.gtaoMaterial.defines.PERSPECTIVE_CAMERA=f,l.gtaoMaterial.needsUpdate=!0)},dispose:()=>{a.dispose(),l.dispose(),c.dispose(),u.dispose()}}}var _CSS2DRendererjs = require('three/addons/renderers/CSS2DRenderer.js');function Ze(e,r){let t=new _CSS2DRendererjs.CSS2DRenderer,n=t.domElement;n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.overflow="hidden",n.style.pointerEvents="none",n.style.zIndex="30",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(n);let i={width:e.clientWidth||1,height:e.clientHeight||1};t.setSize(i.width,i.height);let o=new qe.Group;o.name="label-layer",o.userData.id="label-layer",r.add(o);let a=new Set;return{addLabel:(l,c,u)=>{let m=document.createElement("div");m.textContent=l,u?m.className=u:Object.assign(m.style,{padding:"2px 6px",borderRadius:"4px",background:"rgba(20, 20, 20, 0.78)",color:"#fff",font:"12px/1.3 system-ui, sans-serif",whiteSpace:"pre",textAlign:"center",userSelect:"none"}),m.style.pointerEvents="none";let d=new (0, _CSS2DRendererjs.CSS2DObject)(m);return d.position.copy(c),o.add(d),a.add(d),{object:d,setPosition:f=>d.position.copy(f),setText:f=>{m.textContent=f},remove:()=>{d.removeFromParent(),m.remove(),a.delete(d)}}},render:(l,c)=>t.render(l,c),setSize:(l,c)=>t.setSize(l,c),dispose:()=>{a.forEach(l=>{l.removeFromParent(),l.element.remove()}),a.clear(),o.removeFromParent(),n.remove()}}}var _Line2js = require('three/addons/lines/Line2.js');var _LineGeometryjs = require('three/addons/lines/LineGeometry.js');var pn=12,fn=16763904,Ke=.015,Je={Millimeters:{metersPerUnit:1/1e3,suffix:"mm"},Centimeters:{metersPerUnit:1/100,suffix:"cm"},Meters:{metersPerUnit:1,suffix:"m"},Inches:{metersPerUnit:1/39.37,suffix:"in"},Feet:{metersPerUnit:1/3.28084,suffix:"ft"}};function En(e){let r=e&&Je[e]||Je.Meters;return t=>`${(t/r.metersPerUnit).toPrecision(3)} ${r.suffix}`}function hn(e,r){if(e.isOrthographicCamera){let n=e;return Math.abs(n.top-n.bottom)/(n.zoom||1)*Ke}return((r?e.position.distanceTo(r):e.position.length())||1)*Ke}function gn(e){let r=e.object;if(r instanceof O.Mesh)return e.face?[e.face.a,e.face.b,e.face.c]:null;if(r instanceof O.Points)return e.index!=null?[e.index]:null;if(r instanceof O.Line){if(e.index==null)return null;let t=r.geometry.index;return t?e.index+1>=t.count?null:[t.getX(e.index),t.getX(e.index+1)]:[e.index,e.index+1]}return null}function yn(e,r,t,n){let i=e.point.clone(),o=e.object,a=gn(e);if(!a||!o.geometry)return i;let s=o.geometry.attributes.position;if(!s)return i;let l=d=>{let f=d.clone().project(r);return new O.Vector2((f.x+1)/2*t.width,(1-f.y)/2*t.height)},c=l(i),u=i,m=n;for(let d of a){if(d>=s.count)continue;let b=new O.Vector3().fromBufferAttribute(s,d).applyMatrix4(o.matrixWorld),T=l(b).distanceTo(c);T<m&&(m=T,u=b)}return u}function Qe(e){let{canvas:r,scene:t,getActiveCamera:n,getViewTarget:i,labelLayer:o,options:a={}}=e,s=_nullishCoalesce(a.snapPixels, () => (pn)),l=new O.Color(_nullishCoalesce(a.color, () => (fn))),c=En(a.displayUnit),u=(L,v)=>`${c(L)}
54
- \u0394x ${c(v.x)} \u0394y ${c(v.y)} \u0394z ${c(v.z)}`,m=_nullishCoalesce(a.format, () => (u)),d=new O.Raycaster,f=new O.Vector2,b=!1,T=[],H=[],x=null,y=null,C=new O.PointsMaterial({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),M=new O.PointsMaterial({color:l,size:11,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.5}),p=null,g=L=>{if(!L){p&&(p.visible=!1);return}if(!p){let v=new O.BufferGeometry;v.setAttribute("position",new O.Float32BufferAttribute([0,0,0],3)),p=new O.Points(v,M),p.renderOrder=1e3,p.userData.id="measure",p.raycast=()=>{},t.add(p)}p.position.copy(L),p.visible=!0},R=L=>{let v=new O.BufferGeometry;v.setAttribute("position",new O.Float32BufferAttribute([L.x,L.y,L.z],3));let _=new O.Points(v,C);return _.renderOrder=999,_.userData.id="measure",_.raycast=()=>{},t.add(_),_},w=()=>{T.length=0,H.forEach(L=>{L.geometry.dispose(),L.removeFromParent()}),H.length=0,x&&(x.geometry.dispose(),x.material.dispose(),x.removeFromParent(),x=null),_optionalChain([y, 'optionalAccess', _16 => _16.remove, 'call', _17 => _17()]),y=null},S=()=>{if(T.length!==2)return;let[L,v]=T,_=new _LineGeometryjs.LineGeometry;_.setPositions([L.x,L.y,L.z,v.x,v.y,v.z]);let j=new (0, _LineMaterialjs.LineMaterial)({color:l});j.linewidth=2,j.depthTest=!1,x=new (0, _Line2js.Line2)(_,j),x.renderOrder=998,x.userData.id="measure",x.raycast=()=>{},t.add(x);let ee=L.clone().add(v).multiplyScalar(.5),te=new O.Vector3(Math.abs(v.x-L.x),Math.abs(v.y-L.y),Math.abs(v.z-L.z));y=o.addLabel(m(L.distanceTo(v),te),ee,a.labelClassName)},F=L=>{let v=r.getBoundingClientRect();f.x=(L.clientX-v.left)/v.width*2-1,f.y=-((L.clientY-v.top)/v.height)*2+1;let _=n();d.setFromCamera(f,_);let j=hn(_,_optionalChain([i, 'optionalCall', _18 => _18()]));d.params.Line.threshold=j,d.params.Points.threshold=j;let ee=d.intersectObjects(t.children,!0).filter(te=>te.object.userData.id!=="measure"&&te.object.userData.id!=="grid");return ee.length===0?null:yn(ee[0],_,{width:v.width,height:v.height},s)},Y=null,V=0,X=()=>{V&&(cancelAnimationFrame(V),V=0),Y=null};return{setEnabled:L=>{b=L,L||(X(),w(),g(null))},isEnabled:()=>b,handleClick:L=>{if(!b)return!1;T.length===2&&w();let v=F(L);return v===null||(T.push(v),H.push(R(v)),T.length===2&&S()),!0},handleMove:L=>{b&&(Y=L,!V&&(V=requestAnimationFrame(()=>{V=0;let v=Y;Y=null,!(!b||!v)&&g(F(v))})))},clear:w,dispose:()=>{X(),w(),p&&(p.geometry.dispose(),p.removeFromParent(),p=null),C.dispose(),M.dispose()}}}var bn=64,Tn=256,Z=new Map,ae=new Map,me=0,fe=class extends Error{constructor(r){super(`Texture load for ${r} resolved after clearTextureCache(); texture disposed.`),this.name="StaleTextureLoadError"}},pe=1;function et(e){pe=Math.max(1,e);for(let r of Z.values())r.anisotropy!==pe&&(r.anisotropy=pe,r.needsUpdate=!0)}function tt(e,r){let t=Rn(r),n=Z.get(t);if(n){Z.delete(t),Z.set(t,n),e.map=n,e.needsUpdate=!0;return}typeof document>"u"||xn(r,t).then(i=>{e.map=i,e.needsUpdate=!0}).catch(i=>{i instanceof fe||_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to load material texture ${r}:`,i)})}function Ro(){me++;for(let e of Z.values())e.dispose();Z.clear(),ae.clear()}function Rn(e){return e.length<=Tn?e:`data-uri:${Hn(e).toString(16)}:${e.length}`}function Hn(e){let r=2166136261;for(let t=0;t<e.length;t++)r^=e.charCodeAt(t),r=Math.imul(r,16777619);return r>>>0}function vn(e,r){for(Z.set(e,r);Z.size>bn;){let t=Z.keys().next().value,n=Z.get(t);Z.delete(t),n.dispose()}}function xn(e,r){let t=ae.get(r);if(!t){let n=me;t=new Promise((i,o)=>{new Ee.TextureLoader().load(e,a=>{if(n!==me){a.dispose(),o(new fe(e));return}a.colorSpace=Ee.SRGBColorSpace,a.anisotropy=pe,vn(r,a),ae.delete(r),i(a)},void 0,a=>{n===me&&ae.delete(r),o(a)})}),ae.set(r,t)}return t}var _OrbitControlsjs = require('three/addons/controls/OrbitControls.js');var _HDRLoaderjs = require('three/addons/loaders/HDRLoader.js');var wn=.5,Cn=.01,Mn=.05;function nt({camera:e,scene:r,groundNormals:t=[]}){let n=e.near,i=e.near,o=new se.Vector3,a=new se.Vector3;return{update:()=>{e.near!==i&&(n=e.near);let l=Q(r),c=n;if(!l.isEmpty()){let u=l.getSize(a).length()*.5,m=e.position.distanceTo(l.getCenter(o))-u;for(let d of t)m=Math.min(m,Math.abs(e.position.dot(d)));c=se.MathUtils.clamp(m*wn,n,e.far*Cn)}Math.abs(c-i)>i*Mn&&(e.near=c,e.updateProjectionMatrix(),i=c)}}}var oe=new E.Vector3(0,0,1),Ln="technical",He={studio:{toneMapping:E.ACESFilmicToneMapping,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.75,ambientIntensity:.4,cullBackfaces:!1,ambientOcclusion:!1},technical:{toneMapping:E.NeutralToneMapping,toneMappingExposure:1,envMapIntensity:.5,environmentIntensity:1,hemisphereIntensity:0,ambientIntensity:1,cullBackfaces:!1,ambientOcclusion:!1},showcase:{toneMapping:E.ACESFilmicToneMapping,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1.25,hemisphereIntensity:.35,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!1}};function In(e){let r=He[e];return{envMapIntensity:r.envMapIntensity,cullBackfaces:r.cullBackfaces}}function On(e){let r=Math.abs(e.x),t=Math.abs(e.y),n=Math.abs(e.z);return n>=r&&n>=t?"z":t>=r&&t>=n?"y":"x"}var ko=function(e,r){let t=Dn(r||{}),n=_optionalChain([t, 'access', _19 => _19.environment, 'optionalAccess', _20 => _20.sceneUp])||oe,i=_nullishCoalesce(t.render.pixelRatio, () => (Math.min(window.devicePixelRatio,2))),o=Fn(t),a=zn(t,e);a.up.copy(n);let s=_n(e,t,i);et(s.capabilities.getMaxAnisotropy());let l=Nn(a,e,t),c=_e({scene:o,perspective:a,controls:l,onActiveCameraChange:()=>{},up:n}),u=()=>c.getActiveCamera(),m=!1;Bn(o,t,()=>m);let d=kn(o,t),f=d.sun,b=()=>{f&&Pn(f,Q(o))};_optionalChain([t, 'access', _21 => _21.floor, 'optionalAccess', _22 => _22.enabled])&&Un(o,t);let T=t.grid.enabled?je({cellSize:t.grid.cellSize,majorEvery:t.grid.majorEvery,cellColor:t.grid.cellColor,majorColor:t.grid.majorColor,fadeDistance:t.grid.fadeDistance,plane:t.grid.plane}):null;T&&o.add(T.object);let H=t.gizmo.enabled?Ne({camera:a,domElement:e,controller:c}):null,x=[];if(T){let h=_nullishCoalesce(t.grid.plane, () => ("z"));x.push(new E.Vector3(h==="x"?1:0,h==="y"?1:0,h==="z"?1:0))}t.floor.enabled&&x.push(n.clone().normalize());let y=t.camera.dynamicNear?nt({camera:a,scene:o,groundNormals:x}):null,C=_nullishCoalesce(e.parentElement, () => (e)),M=t.measure.enabled?Ze(C,o):null,p=t.measure.enabled&&M?Qe({canvas:e,scene:o,getActiveCamera:u,labelLayer:M,options:{snapPixels:t.measure.snapPixels,color:t.measure.color,labelClassName:t.measure.labelClassName,displayUnit:t.measure.displayUnit,format:t.measure.format}}):null,g=t.events.enableEventHandlers!==!1?jn(e,o,c,t):{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{}},R=5,w=0,S=0,F=h=>{w=h.clientX,S=h.clientY},Y=h=>Math.hypot(h.clientX-w,h.clientY-S)>R,V=h=>{if(!Y(h)){if(_optionalChain([p, 'optionalAccess', _23 => _23.handleClick, 'call', _24 => _24(h)])){h.stopImmediatePropagation();return}_optionalChain([H, 'optionalAccess', _25 => _25.handleClick, 'call', _26 => _26(h)])&&h.stopImmediatePropagation()}};(H||p)&&(e.addEventListener("mousedown",F,{capture:!0}),e.addEventListener("click",V,{capture:!0}));let X=h=>_optionalChain([p, 'optionalAccess', _27 => _27.handleMove, 'call', _28 => _28(h)]);p&&e.addEventListener("mousemove",X,{passive:!0});let ie=h=>{Ye(h,{color:t.edges.color,width:t.edges.width,thresholdAngle:t.edges.thresholdAngle,distanceFade:t.edges.distanceFade})},q=e.parentElement,L=()=>q?{width:q.clientWidth,height:q.clientHeight}:{width:window.innerWidth,height:window.innerHeight},v=null,_=()=>{let{width:h,height:I}=L(),N=Xe(s,o,u(),Math.max(1,h),Math.max(1,I),{toneMapping:_nullishCoalesce(t.render.toneMapping, () => (E.NeutralToneMapping)),toneMappingExposure:_nullishCoalesce(t.render.toneMappingExposure, () => (1)),aoIntensity:t.render.aoIntensity,aoPixelRatio:t.render.aoPixelRatio});return N.setSize(Math.max(1,h),Math.max(1,I),i),N},j=h=>{h&&!v?v=_():!h&&v&&(v.dispose(),v=null)};t.render.ambientOcclusion&&(v=_());let ee=h=>{h.ambientIntensity!==void 0&&(d.ambient.intensity=h.ambientIntensity),h.hemisphereIntensity!==void 0&&!d.hemisphere&&h.hemisphereIntensity>0&&(d.hemisphere=new E.HemisphereLight(_nullishCoalesce(h.hemisphereSkyColor, () => (t.lighting.hemisphereSkyColor)),_nullishCoalesce(h.hemisphereGroundColor, () => (t.lighting.hemisphereGroundColor)),h.hemisphereIntensity),d.hemisphere.position.copy(_nullishCoalesce(t.environment.sceneUp, () => (oe))),o.add(d.hemisphere)),d.hemisphere&&(h.hemisphereIntensity!==void 0&&(d.hemisphere.intensity=h.hemisphereIntensity),h.hemisphereSkyColor!==void 0&&d.hemisphere.color.set(h.hemisphereSkyColor),h.hemisphereGroundColor!==void 0&&d.hemisphere.groundColor.set(h.hemisphereGroundColor))},te=h=>{t.environment.environmentIntensity=h,o.environmentIntensity=h},gt=h=>{t.render.toneMappingExposure=h,s.toneMappingExposure=h,v&&(j(!1),j(!0))},yt=h=>{t.render.aoIntensity=h,v&&(j(!1),j(!0))},bt=h=>{let I=He[h];Ae=h,s.toneMapping=I.toneMapping,s.toneMappingExposure=I.toneMappingExposure,t.render.toneMapping=I.toneMapping,t.render.toneMappingExposure=I.toneMappingExposure,ee({hemisphereIntensity:I.hemisphereIntensity,ambientIntensity:I.ambientIntensity}),te(I.environmentIntensity),v&&j(!1),j(I.ambientOcclusion),o.traverse(N=>{if(N.userData.source!=="compute")return;let ue=N,Ct=Array.isArray(ue.material)?ue.material:ue.material?[ue.material]:[];for(let Le of Ct)"envMapIntensity"in Le&&(Le.envMapIntensity=I.envMapIntensity)})},Ae=t.look,Tt=()=>In(Ae),{animate:Rt,dispose:Ht}=Vn(s,o,a,u,c,l,L,i,t.events.onFrame,T,H,()=>v,M,y);Rt(),o.up.set(n.x,n.y,n.z),b();let Se=h=>{h.traverse(I=>{let N=I;!N.geometry&&!N.material||(_optionalChain([N, 'access', _29 => _29.geometry, 'optionalAccess', _30 => _30.dispose, 'call', _31 => _31()]),Array.isArray(N.material)?N.material.forEach(he):N.material&&he(N.material))})},vt=h=>{h.userData.source="user",o.add(h)},xt=h=>{h.removeFromParent(),Se(h)},wt=()=>{o.children.filter(I=>I.userData.source==="user").forEach(I=>{I.removeFromParent(),Se(I)})};return{scene:o,camera:a,controls:l,renderer:s,cameraController:c,grid:T,gizmo:H,measureTool:p,applyEdges:ie,setAmbientOcclusion:j,setLook:bt,setFillLights:ee,setEnvironmentIntensity:te,setToneMappingExposure:gt,setAoIntensity:yt,getMaterialAppearance:Tt,updateShadowBounds:b,dispose:()=>{m||(m=!0,Ht(),g.dispose(),(H||p)&&(e.removeEventListener("mousedown",F,{capture:!0}),e.removeEventListener("click",V,{capture:!0})),p&&e.removeEventListener("mousemove",X),_optionalChain([p, 'optionalAccess', _32 => _32.dispose, 'call', _33 => _33()]),_optionalChain([M, 'optionalAccess', _34 => _34.dispose, 'call', _35 => _35()]),_optionalChain([H, 'optionalAccess', _36 => _36.dispose, 'call', _37 => _37()]),_optionalChain([T, 'optionalAccess', _38 => _38.dispose, 'call', _39 => _39()]),_optionalChain([v, 'optionalAccess', _40 => _40.dispose, 'call', _41 => _41()]),c.dispose(),l.dispose(),s.dispose(),s.forceContextLoss(),o.traverse(h=>{let I=h;!I.geometry&&!I.material||(_optionalChain([I, 'access', _42 => _42.geometry, 'optionalAccess', _43 => _43.dispose, 'call', _44 => _44()]),Array.isArray(I.material)?I.material.forEach(he):I.material&&he(I.material))}),_optionalChain([o, 'access', _45 => _45.environment, 'optionalAccess', _46 => _46.dispose, 'call', _47 => _47()]),o.background instanceof E.Texture&&o.background.dispose())},fitToView:g.fitToView,clearSelection:g.clearSelection,addUserGeometry:vt,removeUserGeometry:xt,clearUserGeometry:wt}};function Dn(e){let r=e.sceneScale||"m",n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[r],i=_nullishCoalesce(e.look, () => (Ln)),o=He[i];return{sceneScale:r,look:i,camera:{position:_optionalChain([e, 'access', _48 => _48.camera, 'optionalAccess', _49 => _49.position])||new E.Vector3(-n.cameraDistance,-n.cameraDistance,n.cameraDistance),fov:_optionalChain([e, 'access', _50 => _50.camera, 'optionalAccess', _51 => _51.fov])||20,near:_optionalChain([e, 'access', _52 => _52.camera, 'optionalAccess', _53 => _53.near])||n.near,far:_optionalChain([e, 'access', _54 => _54.camera, 'optionalAccess', _55 => _55.far])||n.far,target:_optionalChain([e, 'access', _56 => _56.camera, 'optionalAccess', _57 => _57.target])||new E.Vector3(0,0,0),dynamicNear:_nullishCoalesce(_optionalChain([e, 'access', _58 => _58.camera, 'optionalAccess', _59 => _59.dynamicNear]), () => (!0))},lighting:{enableSunlight:_nullishCoalesce(_optionalChain([e, 'access', _60 => _60.lighting, 'optionalAccess', _61 => _61.enableSunlight]), () => (!0)),sunlightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _62 => _62.lighting, 'optionalAccess', _63 => _63.sunlightIntensity]), () => (1)),sunlightPosition:_optionalChain([e, 'access', _64 => _64.lighting, 'optionalAccess', _65 => _65.sunlightPosition])||new E.Vector3(n.lightDistance,n.lightDistance,n.lightHeight),ambientLightColor:_optionalChain([e, 'access', _66 => _66.lighting, 'optionalAccess', _67 => _67.ambientLightColor])||new E.Color(4210752),ambientLightIntensity:_nullishCoalesce(_optionalChain([e, 'access', _68 => _68.lighting, 'optionalAccess', _69 => _69.ambientLightIntensity]), () => (o.ambientIntensity)),sunlightColor:_optionalChain([e, 'access', _70 => _70.lighting, 'optionalAccess', _71 => _71.sunlightColor])||16777215,enableHemisphereLight:_nullishCoalesce(_optionalChain([e, 'access', _72 => _72.lighting, 'optionalAccess', _73 => _73.enableHemisphereLight]), () => (o.hemisphereIntensity>0)),hemisphereSkyColor:_nullishCoalesce(_optionalChain([e, 'access', _74 => _74.lighting, 'optionalAccess', _75 => _75.hemisphereSkyColor]), () => (14673663)),hemisphereGroundColor:_nullishCoalesce(_optionalChain([e, 'access', _76 => _76.lighting, 'optionalAccess', _77 => _77.hemisphereGroundColor]), () => (7036754)),hemisphereIntensity:_nullishCoalesce(_optionalChain([e, 'access', _78 => _78.lighting, 'optionalAccess', _79 => _79.hemisphereIntensity]), () => (o.hemisphereIntensity))},environment:{hdrPath:_optionalChain([e, 'access', _80 => _80.environment, 'optionalAccess', _81 => _81.hdrPath])||"/baseHDR.hdr",backgroundColor:_optionalChain([e, 'access', _82 => _82.environment, 'optionalAccess', _83 => _83.backgroundColor])||new E.Color(15790320),enableEnvironmentLighting:_nullishCoalesce(_optionalChain([e, 'access', _84 => _84.environment, 'optionalAccess', _85 => _85.enableEnvironmentLighting]), () => (!0)),sceneUp:_optionalChain([e, 'access', _86 => _86.environment, 'optionalAccess', _87 => _87.sceneUp])||oe,showEnvironment:_nullishCoalesce(_optionalChain([e, 'access', _88 => _88.environment, 'optionalAccess', _89 => _89.showEnvironment]), () => (!1)),environmentIntensity:_nullishCoalesce(_optionalChain([e, 'access', _90 => _90.environment, 'optionalAccess', _91 => _91.environmentIntensity]), () => (o.environmentIntensity))},floor:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _92 => _92.floor, 'optionalAccess', _93 => _93.enabled]), () => (!1)),size:_optionalChain([e, 'access', _94 => _94.floor, 'optionalAccess', _95 => _95.size])||n.floorSize,color:_optionalChain([e, 'access', _96 => _96.floor, 'optionalAccess', _97 => _97.color])||new E.Color(8421504),roughness:_nullishCoalesce(_optionalChain([e, 'access', _98 => _98.floor, 'optionalAccess', _99 => _99.roughness]), () => (.7)),metalness:_nullishCoalesce(_optionalChain([e, 'access', _100 => _100.floor, 'optionalAccess', _101 => _101.metalness]), () => (0)),receiveShadow:_nullishCoalesce(_optionalChain([e, 'access', _102 => _102.floor, 'optionalAccess', _103 => _103.receiveShadow]), () => (!0))},render:{enableShadows:_nullishCoalesce(_optionalChain([e, 'access', _104 => _104.render, 'optionalAccess', _105 => _105.enableShadows]), () => (!0)),shadowMapSize:_optionalChain([e, 'access', _106 => _106.render, 'optionalAccess', _107 => _107.shadowMapSize])||2048,antialias:_nullishCoalesce(_optionalChain([e, 'access', _108 => _108.render, 'optionalAccess', _109 => _109.antialias]), () => (!0)),pixelRatio:_optionalChain([e, 'access', _110 => _110.render, 'optionalAccess', _111 => _111.pixelRatio])||Math.min(window.devicePixelRatio,2),toneMapping:_nullishCoalesce(_optionalChain([e, 'access', _112 => _112.render, 'optionalAccess', _113 => _113.toneMapping]), () => (o.toneMapping)),toneMappingExposure:_nullishCoalesce(_optionalChain([e, 'access', _114 => _114.render, 'optionalAccess', _115 => _115.toneMappingExposure]), () => (o.toneMappingExposure)),preserveDrawingBuffer:_nullishCoalesce(_optionalChain([e, 'access', _116 => _116.render, 'optionalAccess', _117 => _117.preserveDrawingBuffer]), () => (!1)),ambientOcclusion:_nullishCoalesce(_optionalChain([e, 'access', _118 => _118.render, 'optionalAccess', _119 => _119.ambientOcclusion]), () => (o.ambientOcclusion)),aoIntensity:_nullishCoalesce(_optionalChain([e, 'access', _120 => _120.render, 'optionalAccess', _121 => _121.aoIntensity]), () => (1)),aoPixelRatio:_nullishCoalesce(_optionalChain([e, 'access', _122 => _122.render, 'optionalAccess', _123 => _123.aoPixelRatio]), () => (1))},controls:{enableDamping:_nullishCoalesce(_optionalChain([e, 'access', _124 => _124.controls, 'optionalAccess', _125 => _125.enableDamping]), () => (!1)),dampingFactor:_optionalChain([e, 'access', _126 => _126.controls, 'optionalAccess', _127 => _127.dampingFactor])||.05,autoRotate:_nullishCoalesce(_optionalChain([e, 'access', _128 => _128.controls, 'optionalAccess', _129 => _129.autoRotate]), () => (!1)),autoRotateSpeed:_optionalChain([e, 'access', _130 => _130.controls, 'optionalAccess', _131 => _131.autoRotateSpeed])||.5,enableZoom:_nullishCoalesce(_optionalChain([e, 'access', _132 => _132.controls, 'optionalAccess', _133 => _133.enableZoom]), () => (!0)),enablePan:_nullishCoalesce(_optionalChain([e, 'access', _134 => _134.controls, 'optionalAccess', _135 => _135.enablePan]), () => (!0)),minDistance:_optionalChain([e, 'access', _136 => _136.controls, 'optionalAccess', _137 => _137.minDistance])||n.minDistance,maxDistance:_optionalChain([e, 'access', _138 => _138.controls, 'optionalAccess', _139 => _139.maxDistance])||1/0},grid:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _140 => _140.grid, 'optionalAccess', _141 => _141.enabled]), () => (!1)),cellSize:_nullishCoalesce(_optionalChain([e, 'access', _142 => _142.grid, 'optionalAccess', _143 => _143.cellSize]), () => (1)),majorEvery:_nullishCoalesce(_optionalChain([e, 'access', _144 => _144.grid, 'optionalAccess', _145 => _145.majorEvery]), () => (10)),cellColor:_nullishCoalesce(_optionalChain([e, 'access', _146 => _146.grid, 'optionalAccess', _147 => _147.cellColor]), () => (8947848)),majorColor:_nullishCoalesce(_optionalChain([e, 'access', _148 => _148.grid, 'optionalAccess', _149 => _149.majorColor]), () => (4473924)),fadeDistance:_nullishCoalesce(_optionalChain([e, 'access', _150 => _150.grid, 'optionalAccess', _151 => _151.fadeDistance]), () => (100)),plane:_nullishCoalesce(_optionalChain([e, 'access', _152 => _152.grid, 'optionalAccess', _153 => _153.plane]), () => (On(_nullishCoalesce(_optionalChain([e, 'access', _154 => _154.environment, 'optionalAccess', _155 => _155.sceneUp]), () => (oe)))))},gizmo:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _156 => _156.gizmo, 'optionalAccess', _157 => _157.enabled]), () => (!1))},edges:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _158 => _158.edges, 'optionalAccess', _159 => _159.enabled]), () => (!1)),color:_nullishCoalesce(_optionalChain([e, 'access', _160 => _160.edges, 'optionalAccess', _161 => _161.color]), () => (2236962)),width:_nullishCoalesce(_optionalChain([e, 'access', _162 => _162.edges, 'optionalAccess', _163 => _163.width]), () => (1.5)),thresholdAngle:_nullishCoalesce(_optionalChain([e, 'access', _164 => _164.edges, 'optionalAccess', _165 => _165.thresholdAngle]), () => (30)),distanceFade:_nullishCoalesce(_optionalChain([e, 'access', _166 => _166.edges, 'optionalAccess', _167 => _167.distanceFade]), () => (!0))},measure:{enabled:_nullishCoalesce(_optionalChain([e, 'access', _168 => _168.measure, 'optionalAccess', _169 => _169.enabled]), () => (!1)),snapPixels:_optionalChain([e, 'access', _170 => _170.measure, 'optionalAccess', _171 => _171.snapPixels]),color:_optionalChain([e, 'access', _172 => _172.measure, 'optionalAccess', _173 => _173.color]),labelClassName:_optionalChain([e, 'access', _174 => _174.measure, 'optionalAccess', _175 => _175.labelClassName]),displayUnit:_optionalChain([e, 'access', _176 => _176.measure, 'optionalAccess', _177 => _177.displayUnit]),format:_optionalChain([e, 'access', _178 => _178.measure, 'optionalAccess', _179 => _179.format])},events:{onBackgroundClicked:_optionalChain([e, 'access', _180 => _180.events, 'optionalAccess', _181 => _181.onBackgroundClicked]),onObjectSelected:_optionalChain([e, 'access', _182 => _182.events, 'optionalAccess', _183 => _183.onObjectSelected]),onMeshMetadataClicked:_optionalChain([e, 'access', _184 => _184.events, 'optionalAccess', _185 => _185.onMeshMetadataClicked]),onMeshDoubleClicked:_optionalChain([e, 'access', _186 => _186.events, 'optionalAccess', _187 => _187.onMeshDoubleClicked]),selectionColor:_optionalChain([e, 'access', _188 => _188.events, 'optionalAccess', _189 => _189.selectionColor])||"#ff0000",enableEventHandlers:_nullishCoalesce(_optionalChain([e, 'access', _190 => _190.events, 'optionalAccess', _191 => _191.enableEventHandlers]), () => (!0)),enableKeyboardControls:_nullishCoalesce(_optionalChain([e, 'access', _192 => _192.events, 'optionalAccess', _193 => _193.enableKeyboardControls]), () => (!0)),enableClickToFocus:_nullishCoalesce(_optionalChain([e, 'access', _194 => _194.events, 'optionalAccess', _195 => _195.enableClickToFocus]), () => (!0)),enableDoubleClickZoom:_nullishCoalesce(_optionalChain([e, 'access', _196 => _196.events, 'optionalAccess', _197 => _197.enableDoubleClickZoom]), () => (!0)),onReady:_optionalChain([e, 'access', _198 => _198.events, 'optionalAccess', _199 => _199.onReady]),onFrame:_optionalChain([e, 'access', _200 => _200.events, 'optionalAccess', _201 => _201.onFrame])}}}function he(e){for(let r of Object.values(e))r instanceof E.Texture&&r.dispose();e.dispose()}function Pn(e,r){if(r.isEmpty())return;let t=r.getCenter(new E.Vector3),n=r.getSize(new E.Vector3).length()*.5*1.2,i=e.shadow.camera;i.left=-n,i.right=n,i.top=n,i.bottom=-n,e.target.position.copy(t),e.target.updateMatrixWorld();let o=e.position.distanceTo(t);i.near=Math.max(n*.01,o-n),i.far=o+n,i.updateProjectionMatrix()}function Fn(e){let r=new E.Scene,t=typeof e.environment.backgroundColor=="string"?new E.Color(e.environment.backgroundColor):e.environment.backgroundColor;return r.background=t||null,r}function Vn(e,r,t,n,i,o,a,s,l,c,u,m,d,f){let b=null,T=performance.now(),H=()=>{let{width:C,height:M}=a();if(C===0||M===0)return;let p=Math.floor(C*s),g=Math.floor(M*s);(e.domElement.width!==p||e.domElement.height!==g)&&(e.setPixelRatio(s),e.setSize(C,M,!1),t.aspect=C/M,t.updateProjectionMatrix(),i.updateAspect(C,M),_optionalChain([m, 'optionalCall', _202 => _202(), 'optionalAccess', _203 => _203.setSize, 'call', _204 => _204(C,M,s)]),_optionalChain([d, 'optionalAccess', _205 => _205.setSize, 'call', _206 => _206(C,M)]))},x=function(){b=requestAnimationFrame(x);let C=performance.now(),M=(C-T)/1e3;T=C,H(),(o.enableDamping||o.autoRotate)&&o.update(),c&&c.update(n().position),u&&u.update(M),f&&f.update(),_optionalChain([l, 'optionalCall', _207 => _207(M)]);let p=n(),g=_optionalChain([m, 'optionalCall', _208 => _208()]);g?(g.setCamera(p),g.render(M)):e.render(r,p),d&&d.render(r,p),u&&u.render(e)};return{animate:x,dispose:()=>{b!==null&&(cancelAnimationFrame(b),b=null)}}}function Bn(e,r,t){r.environment.enableEnvironmentLighting?new (0, _HDRLoaderjs.HDRLoader)().load(r.environment.hdrPath||"/baseHDR.hdr",function(n){if(t()){n.dispose();return}if(!_optionalChain([n, 'optionalAccess', _209 => _209.image])){_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("HDR loaded without image data; skipping environment map."),_optionalChain([n, 'optionalAccess', _210 => _210.dispose, 'call', _211 => _211()]),_optionalChain([r, 'access', _212 => _212.events, 'access', _213 => _213.onReady, 'optionalCall', _214 => _214()]);return}n.mapping=E.EquirectangularReflectionMapping,e.environment=n,e.environmentIntensity=_nullishCoalesce(r.environment.environmentIntensity, () => (1)),r.environment.showEnvironment&&(e.background=n),_optionalChain([r, 'access', _215 => _215.events, 'access', _216 => _216.onReady, 'optionalCall', _217 => _217()])},void 0,function(n){t()||(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("HDR texture could not be loaded, falling back to basic lighting:",n),_optionalChain([r, 'access', _218 => _218.events, 'access', _219 => _219.onReady, 'optionalCall', _220 => _220()]))}):_optionalChain([r, 'access', _221 => _221.events, 'access', _222 => _222.onReady, 'optionalCall', _223 => _223()])}function kn(e,r){let t=new E.AmbientLight(r.lighting.ambientLightColor,r.lighting.ambientLightIntensity);e.add(t);let n=null;if(r.lighting.enableHemisphereLight){n=new E.HemisphereLight(r.lighting.hemisphereSkyColor,r.lighting.hemisphereGroundColor,r.lighting.hemisphereIntensity);let a=_nullishCoalesce(r.environment.sceneUp, () => (oe));n.position.copy(a),e.add(n)}if(!r.lighting.enableSunlight)return{ambient:t,hemisphere:n,sun:null};let i=new E.DirectionalLight(_nullishCoalesce(r.lighting.sunlightColor, () => (16777215)),r.lighting.sunlightIntensity),o=r.lighting.sunlightPosition;return o&&i.position.set(o.x,o.y,o.z),r.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=r.render.shadowMapSize||2048,i.shadow.mapSize.height=r.render.shadowMapSize||2048,i.shadow.bias=-1e-4,i.shadow.normalBias=.02,i.shadow.radius=4,e.add(i),e.add(i.target),{ambient:t,hemisphere:n,sun:i}):(e.add(i),{ambient:t,hemisphere:n,sun:null})}function Un(e,r){let t=r.floor.size,n=new E.PlaneGeometry(t,t),i=typeof r.floor.color=="string"?new E.Color(r.floor.color):r.floor.color,o=new E.MeshStandardMaterial({color:i,roughness:r.floor.roughness,metalness:r.floor.metalness,side:E.DoubleSide}),a=new E.Mesh(n,o);a.userData.id="floor",a.name="floor";let s=(_optionalChain([r, 'access', _224 => _224.environment, 'optionalAccess', _225 => _225.sceneUp])||oe).clone().normalize();a.quaternion.setFromUnitVectors(new E.Vector3(0,0,1),s),a.position.set(0,0,0),r.floor.receiveShadow&&r.render.enableShadows&&(a.receiveShadow=!0),e.add(a)}function zn(e,r){let t=r.parentElement,n=t?t.clientWidth:window.innerWidth,i=t?t.clientHeight:window.innerHeight,o=new E.PerspectiveCamera(e.camera.fov,n/i,e.camera.near,e.camera.far),a=e.camera.position;return a&&o.position.set(a.x,a.y,a.z),o}function _n(e,r,t){let n=new E.WebGLRenderer({antialias:r.render.antialias,canvas:e,alpha:!0,powerPreference:"high-performance",preserveDrawingBuffer:r.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,o=i?i.clientWidth:window.innerWidth,a=i?i.clientHeight:window.innerHeight;return i&&(e.style.width="100%",e.style.height="100%",e.style.display="block"),n.setSize(o,a,!1),n.setPixelRatio(t),r.render.enableShadows&&(n.shadowMap.enabled=!0,n.shadowMap.type=E.VSMShadowMap),n.toneMapping=r.render.toneMapping,n.toneMappingExposure=_nullishCoalesce(r.render.toneMappingExposure, () => (1)),n.outputColorSpace=E.SRGBColorSpace,n.sortObjects=!0,n}function jn(e,r,t,n){let i=new Set,o=new Map,a=new E.Raycaster,s=new E.Vector2,l=new E.Vector2,c=()=>t.getActiveCamera(),u=p=>{let g=p;for(;g;){if(!g.visible)return!1;g=g.parent}return!0},m=()=>{let p=Q(r);if(p.isEmpty()){_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("No objects to fit to view");return}t.frameBounds(p,!1)},d=typeof n.events.selectionColor=="string"?new E.Color(n.events.selectionColor):n.events.selectionColor instanceof E.Color?n.events.selectionColor:new E.Color("#ff0000"),f=()=>{i.forEach(p=>{let g=p;if(o.has(p)){let R=o.get(p),w=g.material;w instanceof E.Material?w.dispose():Array.isArray(w)&&w.forEach(F=>F.dispose()),g.material=R,o.delete(p);let S=p;for(;S.parent;)S=S.parent;S!==r&&(R instanceof E.Material?R.dispose():R.forEach(F=>F.dispose()))}}),i.clear()},b=p=>{let g=p;if(!(g.material instanceof E.Material))return!1;o.set(p,g.material);let R=g.material.clone();return p instanceof E.Mesh&&"emissive"in R?R.emissive=d.clone():"color"in R&&(R.color=d.clone()),g.material=R,!0},T=()=>{let p=Q(r),g=p.isEmpty()?1:p.getSize(new E.Vector3).length();a.params.Points.threshold=g*.01},H=p=>{l.set(p.clientX,p.clientY)},x=p=>{let g=new E.Vector2(p.clientX,p.clientY);if(l.distanceTo(g)>5)return;let R=e.getBoundingClientRect();s.x=(p.clientX-R.left)/R.width*2-1,s.y=-((p.clientY-R.top)/R.height)*2+1,T(),a.setFromCamera(s,c());let w=a.intersectObjects(r.children,!0).filter(S=>u(S.object));if(w.length>0){let S=w[0].object;i.has(S)||(f(),i.add(S),b(S),_optionalChain([n, 'access', _226 => _226.events, 'optionalAccess', _227 => _227.onObjectSelected, 'optionalCall', _228 => _228(S)]),S instanceof E.Mesh&&Object.keys(S.userData).length>0&&_optionalChain([n, 'access', _229 => _229.events, 'optionalAccess', _230 => _230.onMeshMetadataClicked, 'optionalCall', _231 => _231(S.userData)]))}else f(),_optionalChain([n, 'access', _232 => _232.events, 'optionalAccess', _233 => _233.onBackgroundClicked, 'optionalCall', _234 => _234({x:s.x,y:s.y})])},y=p=>{let g=e.getBoundingClientRect();s.x=(p.clientX-g.left)/g.width*2-1,s.y=-((p.clientY-g.top)/g.height)*2+1,T(),a.setFromCamera(s,c());let R=a.intersectObjects(r.children,!0).filter(F=>u(F.object));if(R.length===0)return;let w=R[0].object;if(_optionalChain([n, 'access', _235 => _235.events, 'optionalAccess', _236 => _236.onMeshDoubleClicked, 'optionalCall', _237 => _237(w)]),!_optionalChain([n, 'access', _238 => _238.events, 'optionalAccess', _239 => _239.enableDoubleClickZoom]))return;let S=new E.Box3().setFromObject(w);S.isEmpty()||t.frameBounds(S,!0)},C=p=>{if(_optionalChain([n, 'access', _240 => _240.events, 'optionalAccess', _241 => _241.enableKeyboardControls]))switch(p.key.toLowerCase()){case"f":p.preventDefault(),m();break;case"escape":p.preventDefault(),f();break;case" ":p.preventDefault(),m();break}};return _optionalChain([n, 'access', _242 => _242.events, 'optionalAccess', _243 => _243.enableClickToFocus])&&(e.addEventListener("mousedown",H),e.addEventListener("click",x),e.addEventListener("dblclick",y)),_optionalChain([n, 'access', _244 => _244.events, 'optionalAccess', _245 => _245.enableKeyboardControls])&&(e.setAttribute("tabindex","0"),e.addEventListener("keydown",C)),{dispose:()=>{e.removeEventListener("mousedown",H),e.removeEventListener("click",x),e.removeEventListener("dblclick",y),e.removeEventListener("keydown",C),f()},fitToView:m,clearSelection:f}}function Nn(e,r,t){let n=new (0, _OrbitControlsjs.OrbitControls)(e,r),i=t.camera.target;return i&&n.target.set(i.x,i.y,i.z),n.enableDamping=t.controls.enableDamping||!1,n.dampingFactor=t.controls.dampingFactor||.05,n.autoRotate=t.controls.autoRotate||!1,n.autoRotateSpeed=t.controls.autoRotateSpeed||.5,n.enableZoom=_nullishCoalesce(t.controls.enableZoom, () => (!0)),n.enablePan=_nullishCoalesce(t.controls.enablePan, () => (!0)),n.minDistance=t.controls.minDistance||.001,n.maxDistance=t.controls.maxDistance||1/0,n.screenSpacePanning=!1,n.maxPolarAngle=Math.PI,n.update(),n}var zo=["technical","studio","showcase"];function ge(e,r,t,n=!0){return{x:e,y:r,z:t}}var Yn="#ffffff",rt=12,Xn=4e-4,qn=12,Zn=.05;function ot(e,r={}){if(!e||e.length===0)return[];let{rhino:t,applyTransforms:n=!0}=r,i=[];for(let o of e)switch(o.kind){case"curve":{let a=Jn(o,t,n);a&&i.push(a);break}case"point":{let a=Qn(o,n);a&&i.push(a);break}default:{let s=o;_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Skipping unknown display item kind: ${String(s.kind)}`);break}}return i}var Kn=2;function Jn(e,r,t){if(!r)return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("No rhino3dm instance provided; skipping curve display item."),null;let n=er(e.json,r);if(!n)return null;let i;try{i=tr(n,t)}catch(m){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Failed to tessellate curve display item; skipping.",m),null}finally{le(n)}if(i.length<2)return null;let o=[];for(let m of i)o.push(m.x,m.y,m.z);let a=new _LineGeometryjs.LineGeometry;a.setPositions(o);let s=it(e.color,e.opacity),l=new (0, _LineMaterialjs.LineMaterial)({color:s.color}),c=l;c.linewidth=_nullishCoalesce(e.width, () => (Kn)),c.transparent=s.transparent,c.opacity=s.opacity;let u=new (0, _Line2js.Line2)(a,l);return u.computeLineDistances(),u.name=e.name,u.userData={source:"compute",id:e.id,layer:e.layer,kind:"curve",metadata:e.metadata},u}function Qn(e,r){let{position:t}=e;if(!t||typeof t.X!="number"||!Number.isFinite(t.X)||typeof t.Y!="number"||!Number.isFinite(t.Y)||typeof t.Z!="number"||!Number.isFinite(t.Z))return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Skipping point display item with missing or non-finite position (id: ${String(e.id)}).`),null;let{x:n,y:i,z:o}=ge(t.X,t.Y,t.Z,r),a=new $.BufferGeometry;a.setAttribute("position",new $.Float32BufferAttribute([n,i,o],3));let s=new $.PointsMaterial({...it(e.color,e.opacity),size:6,sizeAttenuation:!1}),l=new $.Points(a,s);return l.name=e.name,l.userData={source:"compute",id:e.id,layer:e.layer,kind:"point",metadata:e.metadata},l}function le(e){_optionalChain([e, 'optionalAccess', _246 => _246.delete, 'optionalCall', _247 => _247()])}function er(e,r){try{let t=JSON.parse(e),n=r.CommonObject.decode(t);return n&&typeof n.pointAt=="function"?n:(le(n),_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Decoded display-item JSON is not a curve; skipping."),null)}catch(t){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Failed to decode curve display item JSON:",t),null}}function tr(e,r){let t=nr(e,r);return t||rr(e,r)}function nr(e,r){if(!e.isPolyline())return null;let t=e.tryGetPolyline(),n=Array.isArray(t)?t[1]:t;if(!n||typeof n.count!="number"||n.count<2)return le(n),null;let i=[];for(let o=0;o<n.count;o++){let a=n.get(o),{x:s,y:l,z:c}=ge(a[0],a[1],a[2],r);i.push(new $.Vector3(s,l,c))}return le(n),i}function rr(e,r){let t=e.domain,n=t[0],o=t[1]-n,a=m=>{let d=e.pointAt(m),{x:f,y:b,z:T}=ge(d[0],d[1],d[2],r);return new $.Vector3(f,b,T)},s=or(e),l=n,c=a(n),u=[c];for(let m=0;m<rt;m++){let d=n+o*(m+1)/rt,f=a(d);ve(l,c,d,f,a,s,qn,u),u.push(f),l=d,c=f}return u}function ve(e,r,t,n,i,o,a,s){if(a<=0)return;let l=(e+t)/2,c=i(l),u=ar(c,r,n),m=ir(r,c,n);u<=o&&m<=Zn||(ve(e,r,l,c,i,o,a-1,s),s.push(c),ve(l,c,t,n,i,o,a-1,s))}function or(e){let r=e.getBoundingBox(),t=r.min,n=r.max;le(r);let i=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]);return Math.max(i*Xn,1e-6)}function ir(e,r,t){let n=r.x-e.x,i=r.y-e.y,o=r.z-e.z,a=t.x-r.x,s=t.y-r.y,l=t.z-r.z,c=Math.sqrt(n*n+i*i+o*o),u=Math.sqrt(a*a+s*s+l*l);if(c===0||u===0)return 0;let m=n*a+i*s+o*l,d=Math.max(-1,Math.min(1,m/(c*u)));return Math.acos(d)}function ar(e,r,t){let n=t.x-r.x,i=t.y-r.y,o=t.z-r.z,a=n*n+i*i+o*o;if(a===0)return e.distanceTo(r);let s=e.x-r.x,l=e.y-r.y,c=e.z-r.z,u=Math.max(0,Math.min(1,(s*n+l*i+c*o)/a)),m=s-n*u,d=l-i*u,f=c-o*u;return Math.sqrt(m*m+d*d+f*f)}function it(e,r){let t=_nullishCoalesce(r, () => (1));return{color:new $.Color(_nullishCoalesce(e, () => (Yn))),transparent:t<1,opacity:t}}var _fflate = require('fflate');var at=1096174675,lr= exports.y =1515605075,st= exports.z =3,lt= exports.A =1,we= exports.B =1,cr= exports.C =2,ur= exports.D =4,dr= exports.E =8,mr= exports.F =16,Jo= exports.G =0,pr= exports.H =1,ct=12,ut=56,fr=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;function Ce(e){if(!fr)throw new (0, _chunkCUQQ3ZBVcjs.d)("SLVA parsing requires a little-endian host: the zero-copy geometry readers view the wire bytes in host byte order.",_chunkCUQQ3ZBVcjs.c.ENVIRONMENT_ERROR);let r=yr(gr(e)),t=new DataView(r.buffer,r.byteOffset,r.byteLength);if(r.byteLength<ct)throw z("Blob too small to contain SLVA header.",{expectedBytes:ct,availableBytes:r.byteLength});let n=0,i=t.getUint32(n,!0);if(n+=4,i!==at)throw z(`Invalid SLVA magic: 0x${i.toString(16)}`,{expectedMagic:`0x${at.toString(16)}`,actualMagic:`0x${i.toString(16)}`});let o=t.getUint32(n,!0);if(n+=4,o<lt||o>st)throw z(`Unsupported SLVA version: ${o}`,{minSupportedVersion:lt,maxSupportedVersion:st,actualVersion:o});let a=t.getUint32(n,!0);if(n+=4,n+a>r.byteLength)throw z("Insufficient data to read metadata JSON.",{expectedBytes:a,availableBytes:r.byteLength-n,offset:n});let s=r.subarray(n,n+a);n+=a;let l;try{l=JSON.parse(br(s))}catch(q){throw z(`Failed to parse metadata JSON: ${q instanceof Error?q.message:String(q)}`,{metadataLen:a})}if(n+ut>r.byteLength)throw z("Insufficient data to read geometry header.",{expectedBytes:ut,availableBytes:r.byteLength-n,offset:n});let c=t.getUint32(n,!0);n+=4;let u=t.getFloat64(n,!0);n+=8;let m=t.getFloat64(n,!0);n+=8;let d=t.getFloat64(n,!0);n+=8;let f=t.getFloat64(n,!0);n+=8;let b=t.getFloat64(n,!0);n+=8;let T=t.getFloat64(n,!0);n+=8;let H=t.getUint32(n,!0);n+=4;let x=(c&we)!==0,y=(c&ur)!==0,C=H*3,p=C*(x?4:2);if(n+p>r.byteLength)throw z("Insufficient data to read vertices.",{expectedBytes:p,availableBytes:r.byteLength-n,offset:n,useFloat32:x,vertexCount:H});let g=r.byteOffset+n,R;if(x?R=mt(r.buffer,g,C):y?R=vr(xe(r.buffer,g,C)):R=Tr(r.buffer,g,C),n+=p,n+4>r.byteLength)throw z("Insufficient data to read index count.",{expectedBytes:4,availableBytes:r.byteLength-n,offset:n});let w=t.getUint32(n,!0);n+=4;let S=(c&cr)!==0,Y=w*(S?2:4);if(n+Y>r.byteLength)throw z("Insufficient data to read indices.",{expectedBytes:Y,availableBytes:r.byteLength-n,offset:n,indexCount:w,useUint16Indices:S});let V=S?xe(r.buffer,r.byteOffset+n,w):Rr(r.buffer,r.byteOffset+n,w);y&&(V=V instanceof Uint16Array?xr(V):wr(V)),Hr(V,H),n+=Y;let X=null;if((c&dr)!==0){let q=Er(r,t,n,H,y);X=q.uvs,n=q.offset}let ie=null;return(c&mr)!==0&&(ie=hr(r,n,H,y)),{metadata:l,flags:c,vertices:R,indices:V,origin:[u,m,d],scale:[f,b,T],uvs:X,colors:ie}}var dt=36;function Er(e,r,t,n,i){if(t+dt>e.byteLength)throw z("Insufficient data to read UV chunk header.",{expectedBytes:dt,availableBytes:e.byteLength-t,offset:t});let o=r.getUint32(t,!0);t+=4;let a=r.getFloat64(t,!0);t+=8;let s=r.getFloat64(t,!0);t+=8;let l=r.getFloat64(t,!0);t+=8;let c=r.getFloat64(t,!0);t+=8;let u=n*2,m=o===pr,d=u*(m?4:2);if(t+d>e.byteLength)throw z("Insufficient data to read UV chunk.",{expectedBytes:d,availableBytes:e.byteLength-t,offset:t,uvFormat:o,vertexCount:n});let f=e.byteOffset+t,b;if(m)b=mt(e.buffer,f,u).slice();else{let T=xe(e.buffer,f,u);b=new Float32Array(u);let H=0,x=0;for(let y=0;y<u;y+=2)i?(H=H+J(T[y])&65535,x=x+J(T[y+1])&65535):(H=T[y],x=T[y+1]),b[y]=a+H*l,b[y+1]=s+x*c}return{uvs:b,offset:t+d}}function hr(e,r,t,n){let i=t*3;if(r+i>e.byteLength)throw z("Insufficient data to read vertex-color chunk.",{expectedBytes:i,availableBytes:e.byteLength-r,offset:r,vertexCount:t});let o=e.subarray(r,r+i);if(!n)return o.slice();let a=new Uint8Array(i),s=0,l=0,c=0;for(let u=0;u<i;u+=3)s=s+J(o[u])&255,l=l+J(o[u+1])&255,c=c+J(o[u+2])&255,a[u]=s,a[u+1]=l,a[u+2]=c;return a}function gr(e){return typeof e=="string"?_chunkCUQQ3ZBVcjs.j.call(void 0, e):e instanceof Uint8Array?e:new Uint8Array(e)}function yr(e){if(e.byteLength<8)return e;let r=new DataView(e.buffer,e.byteOffset,e.byteLength);if(r.getUint32(0,!0)!==lr)return e;let t=r.getUint32(4,!0),n=e.subarray(8),i=Math.max(n.byteLength*1032+1024,1<<20);if(t>i)throw z("SLVZ header declares an implausible uncompressed length",{uncompressedLen:t,deflatedBytes:n.byteLength,maxPlausibleLen:i});let o;try{o=_fflate.inflateSync.call(void 0, n,{out:new Uint8Array(t+1)})}catch(a){throw z(`Failed to inflate SLVZ blob: ${a instanceof Error?a.message:String(a)}`,{uncompressedLen:t,deflatedBytes:n.byteLength})}if(o.byteLength!==t)throw z("SLVZ payload inflated to a different size than the header declares.",{declaredLen:t,actualLen:o.byteLength,deflatedBytes:n.byteLength});return o}function br(e){if(typeof TextDecoder<"u")return new TextDecoder("utf-8").decode(e);if(typeof globalThis.Buffer<"u")return globalThis.Buffer.from(e).toString("utf-8");throw new (0, _chunkCUQQ3ZBVcjs.d)("No UTF-8 decoder available in this environment.",_chunkCUQQ3ZBVcjs.c.INVALID_STATE)}function Tr(e,r,t){if(t===0)return new Int16Array(0);if(r%2===0)return new Int16Array(e,r,t);let n=new Uint8Array(t*2);return n.set(new Uint8Array(e,r,t*2)),new Int16Array(n.buffer)}function mt(e,r,t){if(t===0)return new Float32Array(0);if(r%4===0)return new Float32Array(e,r,t);let n=new Uint8Array(t*4);return n.set(new Uint8Array(e,r,t*4)),new Float32Array(n.buffer)}function xe(e,r,t){if(t===0)return new Uint16Array(0);if(r%2===0)return new Uint16Array(e,r,t);let n=new Uint8Array(t*2);return n.set(new Uint8Array(e,r,t*2)),new Uint16Array(n.buffer)}function Rr(e,r,t){if(t===0)return new Uint32Array(0);if(r%4===0)return new Uint32Array(e,r,t);let n=new Uint8Array(t*4);return n.set(new Uint8Array(e,r,t*4)),new Uint32Array(n.buffer)}function Hr(e,r){if(e.length!==0&&!(e instanceof Uint16Array&&r>65535)){for(let t=0;t<e.length;t++)if(e[t]>=r)throw z("Index out of range of vertexCount.",{indexPosition:t,indexValue:e[t],vertexCount:r})}}function J(e){return e>>>1^-(e&1)}function vr(e){let r=new Int16Array(e.length),t=0,n=0,i=0;for(let o=0;o<e.length;o+=3)t=t+J(e[o])<<16>>16,n=n+J(e[o+1])<<16>>16,i=i+J(e[o+2])<<16>>16,r[o]=t,r[o+1]=n,r[o+2]=i;return r}function xr(e){let r=new Uint16Array(e.length),t=0;for(let n=0;n<e.length;n++)t=t+J(e[n])&65535,r[n]=t;return r}function wr(e){let r=new Uint32Array(e.length),t=0;for(let n=0;n<e.length;n++)t=t+J(e[n])>>>0,r[n]=t;return r}function z(e,r){return new (0, _chunkCUQQ3ZBVcjs.d)(e,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:r})}async function ii(e,r){let{debug:t=!1}=_nullishCoalesce(r, () => ({})),n=t?performance.now():0,i,o=performance.now();try{i=JSON.parse(e)}catch(s){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).error("Error parsing mesh batch envelope JSON:",s),[]}let a=performance.now()-o;return await Me(i,r,{parseTime:a,perfStart:n})}async function Me(e,r,t){let{mergeByMaterial:n=!0,applyTransforms:i=!0,debug:o=!1,material:a}=_nullishCoalesce(r, () => ({})),{parseTime:s=0,perfStart:l=o?performance.now():0}=_nullishCoalesce(t, () => ({}));if(!e.compressedData)return[];let c=performance.now(),u=Ce(e.compressedData),m=performance.now()-c,d=o?Dr(e.compressedData):0;return pt(u,{mergeByMaterial:n,applyTransforms:i,debug:o,material:a,parseTime:s,decodeTime:m,perfStart:l,blobBytes:d,fallback:{materials:e.materials,groups:e.groups,sourceComponentId:e.sourceComponentId}})}async function ai(e,r){let{mergeByMaterial:t=!0,applyTransforms:n=!0,debug:i=!1,material:o}=_nullishCoalesce(r, () => ({})),a=i?performance.now():0,s=performance.now(),l=Ce(e),c=performance.now()-s,u=e.byteLength;return pt(l,{mergeByMaterial:t,applyTransforms:n,debug:i,material:o,parseTime:0,decodeTime:c,perfStart:a,blobBytes:u})}function pt(e,r){let{mergeByMaterial:t,applyTransforms:n,debug:i,material:o,parseTime:a,decodeTime:s,perfStart:l,blobBytes:c,fallback:u}=r,m=_nullishCoalesce(_nullishCoalesce(e.metadata.materials, () => (_optionalChain([u, 'optionalAccess', _248 => _248.materials]))), () => ([])),d=_nullishCoalesce(_nullishCoalesce(e.metadata.groups, () => (_optionalChain([u, 'optionalAccess', _249 => _249.groups]))), () => ([])),f=_nullishCoalesce(_optionalChain([u, 'optionalAccess', _250 => _250.sourceComponentId]), () => (e.metadata.sourceComponentId)),b=(e.flags&we)!==0;Cr(d,m.length,e.vertices.length/3,e.indices.length);let T=b?Ar(e.vertices,n):Mr(e.vertices,e.origin,e.scale,n);if(i){let M=e.vertices.byteLength+e.indices.byteLength;_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug("Mesh Batch Stats:"),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Materials: ${m.length} | Groups: ${d.length}`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Format: ${b?"float32":"int16 quantized"}`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(M/1024/1024).toFixed(2)} MB`)}let H=performance.now(),x=m.map(M=>Sr(M,{vertexColors:e.colors!=null,appearance:o})),y=[];for(let M of d)if(t&&M.meshes.length>1){let p=Ir(M,T,e.indices,x,e.uvs,e.colors);p.userData.sourceComponentId=_nullishCoalesce(f, () => (null)),y.push(p)}else{let p=Or(M,T,e.indices,x,e.uvs,e.colors);for(let g of p)g.userData.sourceComponentId=_nullishCoalesce(f, () => (null));y.push(...p)}let C=performance.now()-H;if(i){let M=performance.now()-l;_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug("Performance:"),a>0&&_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Parse JSON: ${a.toFixed(2)}ms`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Decode binary: ${s.toFixed(2)}ms`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Create Meshes: ${C.toFixed(2)}ms`),_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(` Total: ${M.toFixed(2)}ms`)}return Promise.resolve(y)}function ce(e,r){return new (0, _chunkCUQQ3ZBVcjs.d)(e,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:r})}function Cr(e,r,t,n){for(let i of e){if(!Number.isInteger(i.materialId)||i.materialId<0||i.materialId>=r)throw ce("Group materialId out of range of the materials array.",{materialId:i.materialId,materialCount:r});for(let o of i.meshes){let a={vertexStart:o.vertexStart,vertexCount:o.vertexCount,indexStart:o.indexStart,indexCount:o.indexCount};for(let[s,l]of Object.entries(a))if(!Number.isInteger(l)||l<0)throw ce(`Mesh metadata field "${s}" must be a non-negative integer.`,{meshName:o.name,field:s,value:l});if(o.vertexStart+o.vertexCount>t)throw ce("Mesh vertex window exceeds the batch vertex buffer.",{meshName:o.name,vertexStart:o.vertexStart,vertexCount:o.vertexCount,totalVertexCount:t});if(o.indexStart+o.indexCount>n)throw ce("Mesh index window exceeds the batch index buffer.",{meshName:o.name,indexStart:o.indexStart,indexCount:o.indexCount,totalIndexCount:n})}}}function ft(e,r){if(e<r.vertexStart||e>=r.vertexStart+r.vertexCount)throw ce("Index references a vertex outside its mesh's vertex window.",{meshName:r.name,indexValue:e,vertexStart:r.vertexStart,vertexCount:r.vertexCount})}function Mr(e,r,t,n){let i=new Float32Array(e.length),o=r[0],a=r[1],s=r[2],l=t[0],c=t[1],u=t[2];for(let m=0;m<e.length;m+=3)i[m]=o+(e[m]+32767)*l,i[m+1]=a+(e[m+1]+32767)*c,i[m+2]=s+(e[m+2]+32767)*u;return i}function Ar(e,r){return e}function Sr(e,r){let t=Ue(e.color),n=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _251 => _251.vertexColors]), () => (!1)),i=_optionalChain([r, 'optionalAccess', _252 => _252.appearance]),o=new P.MeshPhysicalMaterial({color:t,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,vertexColors:n,side:_optionalChain([i, 'optionalAccess', _253 => _253.cullBackfaces])?P.FrontSide:P.DoubleSide,polygonOffset:!0,polygonOffsetFactor:.5,polygonOffsetUnits:.5,depthWrite:!0,depthTest:!0});return _optionalChain([i, 'optionalAccess', _254 => _254.envMapIntensity])!=null&&(o.envMapIntensity=i.envMapIntensity),n&&Lr(o),e.map&&tt(o,e.map),o}function Lr(e){e.onBeforeCompile=r=>{r.vertexShader=r.vertexShader.replace("#include <color_vertex>",`#include <color_vertex>
55
- #if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
56
- vColor.rgb = mix(
57
- vColor.rgb / 12.92,
58
- pow( ( vColor.rgb + 0.055 ) / 1.055, vec3( 2.4 ) ),
59
- step( vec3( 0.04045 ), vColor.rgb )
60
- );
61
- #endif`)}}function Ir(e,r,t,n,i=null,o=null){let a=0,s=0;for(let y of e.meshes)a+=y.vertexCount,s+=y.indexCount;let l=new Float32Array(a*3),c=new Uint32Array(s),u=i?new Float32Array(a*2):null,m=o?new Uint8Array(a*3):null,d=0,f=0;for(let y of e.meshes){let C=y.vertexStart*3,M=y.vertexCount*3;if(l.set(r.subarray(C,C+M),d*3),u&&i){let R=y.vertexStart*2;u.set(i.subarray(R,R+y.vertexCount*2),d*2)}m&&o&&m.set(o.subarray(C,C+M),d*3);let p=t.subarray(y.indexStart,y.indexStart+y.indexCount),g=d-y.vertexStart;for(let R=0;R<p.length;R++){let w=p[R];ft(w,y),c[f+R]=w+g}d+=y.vertexCount,f+=y.indexCount}let b=new P.BufferGeometry;b.setAttribute("position",new P.BufferAttribute(l,3)),b.setIndex(new P.BufferAttribute(c,1)),u&&b.setAttribute("uv",new P.BufferAttribute(u,2)),m&&b.setAttribute("color",new P.BufferAttribute(m,3,!0)),b.computeVertexNormals();let T=new P.Mesh(b,n[e.materialId]),H=e.meshes[0],x=e.meshes.map(y=>y.name).filter(y=>y&&y.length>0);return T.name=x.length>0?x[0]:`merged_material_${e.materialId}`,T.castShadow=!0,T.receiveShadow=!0,T.userData={source:"compute",name:T.name,layer:_nullishCoalesce(_optionalChain([H, 'optionalAccess', _255 => _255.layer]), () => ("")),originalIndex:_nullishCoalesce(_optionalChain([H, 'optionalAccess', _256 => _256.originalIndex]), () => (0)),metadata:_nullishCoalesce(_optionalChain([H, 'optionalAccess', _257 => _257.metadata]), () => ({})),mergedFrom:e.meshes.slice(1).map(y=>({name:y.name,layer:y.layer,originalIndex:y.originalIndex}))},T}function Or(e,r,t,n,i=null,o=null){let a=[];for(let s of e.meshes){let l=s.vertexStart*3,c=s.vertexCount*3,u=r.slice(l,l+c),m=t.subarray(s.indexStart,s.indexStart+s.indexCount),d=new Uint32Array(m.length),f=s.vertexStart;for(let H=0;H<m.length;H++){let x=m[H];ft(x,s),d[H]=x-f}let b=new P.BufferGeometry;if(b.setAttribute("position",new P.BufferAttribute(u,3)),b.setIndex(new P.BufferAttribute(d,1)),i){let H=s.vertexStart*2,x=i.slice(H,H+s.vertexCount*2);b.setAttribute("uv",new P.BufferAttribute(x,2))}if(o){let H=o.slice(l,l+c);b.setAttribute("color",new P.BufferAttribute(H,3,!0))}b.computeVertexNormals();let T=new P.Mesh(b,n[e.materialId]);T.name=s.name,T.userData={source:"compute",name:s.name,layer:_nullishCoalesce(s.layer, () => ("")),originalIndex:s.originalIndex,metadata:_nullishCoalesce(s.metadata, () => ({}))},T.castShadow=!0,T.receiveShadow=!0,a.push(T)}return a}function Dr(e){return Math.floor(e.length*3/4)}var Et={Angstroms:1e-10,Nanometers:1e-9,Microns:1e-6,Millimeters:.001,Centimeters:.01,Decimeters:.1,Meters:1,Dekameters:10,Hectometers:100,Kilometers:1e3,Megameters:1e6,Gigameters:1e9,Microinches:254e-10,Mils:254e-7,Inches:.0254,Feet:.3048,Yards:.9144,Miles:1609.344,NauticalMiles:1852},Pr="Display",Fr="DisplayBatch";function Vr(e){let r=e.split(".");return r.includes(Pr)||r.includes(Fr)}var ht=new Set;async function mi(e,r){let t=performance.now(),n=[],{allowScaling:i=!0,allowAutoPosition:o=!0,rhino:a,debug:s=!1,parsing:l={}}=_nullishCoalesce(r, () => ({}));try{let c=i?Br(e.modelunits):1;return await kr(e,n,c,l,a,s),o&&jr(n),n}catch(c){throw Nr(c,n),c}finally{s&&Wr(t)}}function Br(e){let r=Et[e];return r!==void 0?r:(ht.has(e)||(ht.add(e),_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Unknown Rhino model unit "${e}" \u2014 geometry will not be scaled (factor 1). Known units: ${Object.keys(Et).join(", ")}.`)),1)}async function kr(e,r,t,n,i,o){for(let a of e.values){let s=a.InnerTree;for(let l in s){let c=s[l];c&&await Ur(c,r,t,n,i,o)}}}async function Ur(e,r,t,n,i,o){for(let a of e){if(!Vr(a.type))continue;let s={mergeByMaterial:!0,applyTransforms:!0,debug:!1,...n},l=zr(a.data);if(!l){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("Error parsing display batch envelope: invalid JSON");continue}let c=await Me(l,s),u=ot(l.items,{rhino:i,applyTransforms:s.applyTransforms}),m=[...c,...u];if(t!==1)for(let d of m)d.scale.set(t,t,t);r.push(...m),o&&_chunkCUQQ3ZBVcjs.e.call(void 0, ).debug(`Extracted ${c.length} meshes and ${u.length} items from batch`)}}function zr(e){return typeof e=="string"?_r(e):e}function _r(e){try{return JSON.parse(e)}catch (e3){return}}function jr(e){if(e.length===0)return;let r=be(e);ze(e,r.min.z,"z")}function Nr(e,r){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("An unexpected error occurred:",e),Gr(r)}function Gr(e){for(let r of e){let t=r;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>n.dispose()):t.material.dispose())}}function Wr(e){let r=performance.now()-e;_chunkCUQQ3ZBVcjs.e.call(void 0, ).info("Time to process meshes:",`${r.toFixed(2)}ms`)}exports.a = At; exports.b = qr; exports.c = Ue; exports.d = ze; exports.e = be; exports.f = _e; exports.g = je; exports.h = Ne; exports.i = de; exports.j = Ye; exports.k = tn; exports.l = io; exports.m = Xe; exports.n = Ze; exports.o = yn; exports.p = Qe; exports.q = bn; exports.r = et; exports.s = Ro; exports.t = In; exports.u = ko; exports.v = zo; exports.w = ot; exports.x = at; exports.y = lr; exports.z = st; exports.A = lt; exports.B = we; exports.C = cr; exports.D = ur; exports.E = dr; exports.F = mr; exports.G = Jo; exports.H = pr; exports.I = Ce; exports.J = ii; exports.K = Me; exports.L = ai; exports.M = Et; exports.N = mi;
62
- //# sourceMappingURL=chunk-7XMD5YXP.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\chunk-7XMD5YXP.cjs"],"names":[],"mappings":"AAAA,2/BAAwE,IAAK,EAAE,CAAC,CAAC,CAAC,CAAC,iCAAE,EAAG,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,sjBAAuB,IAAK,EAAE,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAA4B,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,qBAAqB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,iCAAC,CAAE,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAA","file":"D:\\Coding\\selva-compute\\dist\\chunk-7XMD5YXP.cjs","sourcesContent":[null]}
@@ -1,4 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var M=Object.defineProperty;var Z=(t,e,r)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Ne=(t,e)=>{for(var r in e)M(t,r,{get:e[r],enumerable:!0})};var h=(t,e,r)=>Z(t,typeof e!="symbol"?e+"":e,r);var u={NETWORK_ERROR:"NETWORK_ERROR",AUTH_ERROR:"AUTH_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",COMPUTATION_ERROR:"COMPUTATION_ERROR",TIMEOUT_ERROR:"TIMEOUT_ERROR",CORS_ERROR:"CORS_ERROR",NOT_FOUND:"NOT_FOUND",RATE_LIMIT:"RATE_LIMIT",INVALID_RESPONSE:"INVALID_RESPONSE",UNKNOWN_ERROR:"UNKNOWN_ERROR",INVALID_STATE:"INVALID_STATE",INVALID_INPUT:"INVALID_INPUT",INVALID_CONFIG:"INVALID_CONFIG",BROWSER_ONLY:"BROWSER_ONLY",ENVIRONMENT_ERROR:"ENVIRONMENT_ERROR",ENCODING_ERROR:"ENCODING_ERROR",MALFORMED_DEFAULT:"MALFORMED_DEFAULT",SUPERSEDED:"SUPERSEDED",ABORTED:"ABORTED",QUEUE_FULL:"QUEUE_FULL",QUEUE_TIMEOUT:"QUEUE_TIMEOUT",DEFINITION_NOT_CACHED:"DEFINITION_NOT_CACHED"},p= exports.d =class t extends Error{constructor(r,n=u.UNKNOWN_ERROR,o){super(r);h(this,"code");h(this,"statusCode");h(this,"context");h(this,"originalError");this.name="RhinoComputeError",this.code=n,this.statusCode=_optionalChain([o, 'optionalAccess', _2 => _2.statusCode]),this.context=_optionalChain([o, 'optionalAccess', _3 => _3.context]),this.originalError=_optionalChain([o, 'optionalAccess', _4 => _4.originalError]),_optionalChain([o, 'optionalAccess', _5 => _5.originalError])&&(this.cause=o.originalError)}static missingValues(r,n,o){return new t(`Input "${r}" has no values defined${n?` (expected ${n})`:""}`,u.INVALID_INPUT,{context:{inputName:r,expectedType:n,...o}})}static unknownParamType(r,n,o){return new t(`Unknown paramType: ${r}`,u.VALIDATION_ERROR,{context:{receivedParamType:r,paramName:n,...o}})}};var O=class{debug(){}info(){}warn(){}error(){}},$=class{debug(e,...r){console.debug(e,...r)}info(e,...r){console.info(e,...r)}warn(e,...r){console.warn(e,...r)}error(e,...r){console.error(e,...r)}},_=new O;function m(){return _}function F(t){if(t===null){_=new O;return}let e=["debug","info","warn","error"].filter(r=>typeof t[r]!="function");if(e.length>0)throw new p(`Logger is missing required method(s): ${e.join(", ")}. A logger must implement debug, info, warn and error.`,u.INVALID_CONFIG,{context:{missingMethods:e}});_=t}function Q(){F(new $)}function I(){let t=globalThis.Buffer;return typeof t=="function"?t:void 0}function Me(t){let e=I();return e?e.from(t,"utf-8").toString("base64"):te(new TextEncoder().encode(t))}var X=64,ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Fe(t){if(!t)return null;let e=t.replace(/[\t\n\f\r ]/g,"");e.length%4===0&&(e=e.replace(/={1,2}$/,""));let r=e.length%4;if(r===1||e.length<X||!/^[A-Za-z0-9+/]*$/.test(e))return null;let n=ee.indexOf(e.charAt(e.length-1));return r===2&&(n&15)!==0||r===3&&(n&3)!==0?null:r===0?e:e+"==".slice(0,4-r)}function k(t){let e=t.replace(/[\t\n\f\r ]/g,"");if(e.length%4===0&&(e=e.replace(/={1,2}$/,"")),e.length%4===1||!/^[A-Za-z0-9+/]*$/.test(e))throw new p("Invalid base64 input.",u.ENCODING_ERROR,{context:{inputLength:t.length}});let r=I();if(r)return new Uint8Array(r.from(e,"base64"));if(typeof globalThis.atob=="function"){let n=globalThis.atob(e),o=new Uint8Array(n.length);for(let s=0;s<n.length;s++)o[s]=n.charCodeAt(s)&255;return o}throw new p("Base64 decoding not supported in this environment.",u.INVALID_STATE,{context:{environmentInfo:"atob or Buffer not available"}})}function x(t){let e=I();if(e)return e.byteLength(t,"utf-8");let r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?r+=1:o<2048?r+=2:o>=55296&&o<=56319&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(r+=4,n++):r+=3}return r}function te(t){let e=I();if(e)return e.from(t).toString("base64");if(typeof globalThis.btoa=="function"){let n=[];for(let o=0;o<t.length;o+=32766)n.push(globalThis.btoa(String.fromCharCode.apply(null,t.subarray(o,o+32766))));return n.join("")}throw new p("Base64 encoding not supported in this environment.",u.INVALID_STATE,{context:{environmentInfo:"btoa or Buffer not available"}})}function re(t){if(!t)return null;let e={raw:t},r=!1;for(let n of t.split(",")){let[o,...s]=n.trim().split(";"),l=s.find(f=>f.trim().toLowerCase().startsWith("dur"));if(!l)continue;let i=Number(l.split("=")[1]);if(!Number.isFinite(i))continue;let a=o.trim().toLowerCase();(a==="decode"||a==="solve"||a==="encode")&&(e[a]=i,r=!0)}return r?e:null}var v={attempts:0,baseDelayMs:500,maxDelayMs:3e4,retryOn429:!0},P=new Set([502,503,504]),ne=6e4,U=4096;function oe(t){return t?{attempts:_nullishCoalesce(t.attempts, () => (v.attempts)),baseDelayMs:_nullishCoalesce(t.baseDelayMs, () => (v.baseDelayMs)),maxDelayMs:_nullishCoalesce(t.maxDelayMs, () => (v.maxDelayMs)),retryOn429:_nullishCoalesce(t.retryOn429, () => (v.retryOn429))}:v}function se(t){if(!t)return null;let e=Number(t);if(Number.isFinite(e)&&e>=0)return e*1e3;let r=Date.parse(t);if(Number.isFinite(r)){let n=r-Date.now();return n>0?n:0}return null}function C(t,e){let r=e.baseDelayMs*Math.pow(2,t),n=Math.random()*e.baseDelayMs;return Math.min(r+n,e.maxDelayMs)}function ie(t,e){return new Promise((r,n)=>{if(_optionalChain([e, 'optionalAccess', _6 => _6.aborted])){n(new DOMException("Aborted","AbortError"));return}let o=setTimeout(()=>{_optionalChain([e, 'optionalAccess', _7 => _7.removeEventListener, 'call', _8 => _8("abort",s)]),r()},t),s=()=>{clearTimeout(o),n(new DOMException("Aborted","AbortError"))};_optionalChain([e, 'optionalAccess', _9 => _9.addEventListener, 'call', _10 => _10("abort",s,{once:!0})])})}function ae(t){return t.length<=U?t:`${t.slice(0,U)}\u2026 [truncated ${t.length-U} chars]`}function ue(t,e,r,n,o,s,l,i){let{status:a,statusText:f}=t,c={};t.headers.forEach((G,Y)=>{c[Y]=G});let g=s.trim(),d=g?` \u2014 ${g.slice(0,200)}${g.length>200?"\u2026":""}`:"",E=_nullishCoalesce(i, () => (s)),T={url:e,requestId:r,method:"POST",requestSize:n,serverUrl:o,responseBody:E?ae(E):void 0,responseHeaders:c},b={401:{message:`HTTP ${a}: ${f}${d}`,code:u.AUTH_ERROR},403:{message:`HTTP ${a}: ${f}${d}`,code:u.AUTH_ERROR},404:{message:`Endpoint not found: ${e}`,code:u.NOT_FOUND},413:{message:`Request too large: ${(n/1024).toFixed(2)}KB`,code:u.VALIDATION_ERROR},429:{message:`Rate limit exceeded${d}`,code:u.RATE_LIMIT},500:{message:`Server error: ${f}${d}`,code:u.COMPUTATION_ERROR},502:{message:`Service unavailable: ${f}${d}`,code:u.NETWORK_ERROR},503:{message:`Service unavailable: ${f}${d}`,code:u.NETWORK_ERROR},504:{message:`Service unavailable: ${f}${d}`,code:u.NETWORK_ERROR}}[a]||{message:`HTTP ${a}: ${f}${d}`,code:u.UNKNOWN_ERROR},D=_nullishCoalesce(le(l), () => (b.code));throw new p(b.message,D,{statusCode:a,context:T})}function le(t){if(t==="definition_not_cached")return u.DEFINITION_NOT_CACHED}function ce(t,e){let r=e.replace(/\/+$/,""),n=t.replace(/^\/+/,"");return`${r}/${n}`}function de(t){try{let e=new URL(t).hostname.toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="[::1]"}catch (e2){return/(localhost|127\.0\.0\.1|\[::1\])/i.test(t)}}var B=new Set;function fe(t,e){let r={...e.headers,"X-Request-ID":t,"Content-Type":"application/json",...e.authToken&&{Authorization:e.authToken},...e.apiKey&&{RhinoComputeKey:e.apiKey}};return!e.apiKey&&!e.authToken&&!B.has(e.serverUrl)&&!de(e.serverUrl)&&(B.add(e.serverUrl),m().warn(`\u26A0\uFE0F [Rhino Compute] Request [${t}] targets remote server (${e.serverUrl}) but no API key or auth token is configured. Requests may fail or be rate-limited. (warned once per server)`)),r}function pe(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}function y(t,e){e&&m().debug(t)}function me(t,e){let r=()=>{},n=typeof e=="number"&&e>0;if(!t&&!n)return{signal:void 0,cleanup:r};if(t&&!n)return{signal:t,cleanup:r};let o=typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function";if(!t){if(o)return{signal:AbortSignal.timeout(e),cleanup:r};let c=new AbortController,g=setTimeout(()=>c.abort(),e);return{signal:c.signal,cleanup:()=>clearTimeout(g)}}let s=new AbortController,l,i;if(o)l=AbortSignal.timeout(e);else{let c=new AbortController;i=setTimeout(()=>c.abort(),e),l=c.signal}let a=[t,l],f=function(){s.abort(this.reason)};for(let c of a){if(c.aborted){s.abort(c.reason);break}c.addEventListener("abort",f,{once:!0})}return{signal:s.signal,cleanup:()=>{i!==void 0&&clearTimeout(i);for(let c of a)c.removeEventListener("abort",f)}}}function q(t,e,r,n){if(!r)return;let o=re(t.headers.get("Server-Timing"));if(o)try{r(o,e)}catch(s){n&&y(` onServerTiming callback threw: ${s}`,!0)}}async function ge(t,e,r,n,o,s,l,i){let a=Math.round(performance.now()-s);if(!t.ok){let f=await t.text(),c=f;l&&(y(`\u274C Request [${r}] failed with HTTP ${t.status} in ${a}ms`,!0),y(` URL: ${e}`,!0),y(` Status: ${t.status} ${t.statusText}`,!0),c&&y(` Response body: ${c.substring(0,500)}${c.length>500?"...":""}`,!0));let g;try{let d=JSON.parse(c);typeof _optionalChain([d, 'optionalAccess', _11 => _11.code])=="string"&&(g=d.code)}catch (e3){}if(t.status===500)try{let d=JSON.parse(c);if(_optionalChain([d, 'optionalAccess', _12 => _12.values])&&(d.errors||d.warnings))return l&&(y(`\u26A0\uFE0F Request [${r}] completed with Grasshopper errors in ${a}ms`,!0),_optionalChain([d, 'access', _13 => _13.errors, 'optionalAccess', _14 => _14.length])>0&&y(` Errors: ${JSON.stringify(d.errors,null,2)}`,!0),_optionalChain([d, 'access', _15 => _15.warnings, 'optionalAccess', _16 => _16.length])>0&&y(` Warnings: ${JSON.stringify(d.warnings,null,2)}`,!0)),q(t,r,i,l),d;let E=typeof _optionalChain([d, 'optionalAccess', _17 => _17.message])=="string"&&d.message||typeof _optionalChain([d, 'optionalAccess', _18 => _18.Message])=="string"&&d.Message||"",T=typeof _optionalChain([d, 'optionalAccess', _19 => _19.ExceptionType])=="string"&&d.ExceptionType||"",S=_nullishCoalesce(_optionalChain([d, 'optionalAccess', _20 => _20.stackTrace]), () => (_optionalChain([d, 'optionalAccess', _21 => _21.StackTrace]))),b=Array.isArray(S)?S.join(`
2
- `):S||"";E?c=`${T?`${T}: `:""}${E}${b?`
3
- ${b}`:""}`:_optionalChain([d, 'optionalAccess', _22 => _22.error])&&(c=typeof d.error=="string"?d.error:JSON.stringify(d.error,null,2))}catch(d){l&&y(` Failed to parse error body as JSON: ${d}`,!0)}ue(t,e,r,n,o,c,g,f)}y(`\u2705 Request [${r}] completed in ${a}ms`,l),q(t,r,i,l);try{return await t.json()}catch(f){let c=(_nullishCoalesce(t.headers.get("Content-Type"), () => (""))).toLowerCase();throw c!==""&&!c.includes("json")?new p(`Server returned a non-JSON response (Content-Type: ${c}) \u2014 check the server URL / proxy configuration`,u.INVALID_RESPONSE,{statusCode:t.status,context:{url:e,requestId:r,contentType:c},originalError:f instanceof Error?f:new Error(String(f))}):new p("Failed to parse JSON response",u.NETWORK_ERROR,{statusCode:t.status,context:{url:e,requestId:r},originalError:f instanceof Error?f:new Error(String(f))})}}async function he(t,e,r,n){let{signal:o,cleanup:s}=me(t.config.signal,t.config.timeoutMs),l=performance.now();try{let i=await fetch(t.fullUrl,{method:"POST",body:t.body,headers:t.headers,signal:o});if((P.has(i.status)||e.retryOn429&&i.status===429)&&r<n-1){let c=se(i.headers.get("Retry-After")),g=c!==null?Math.min(c,Math.max(e.maxDelayMs,ne)):C(r,e);return await i.text().catch(()=>{}),{ok:!1,retry:!0,delayMs:g,cause:new p(`HTTP ${i.status} ${i.statusText} (will retry)`,i.status===429?u.RATE_LIMIT:u.NETWORK_ERROR,{statusCode:i.status,context:{requestId:t.requestId}})}}return{ok:!0,value:await ge(i,t.fullUrl,t.requestId,t.requestSize,t.config.serverUrl,l,t.config.debug,t.config.onServerTiming)}}catch(i){if(i instanceof Error&&(i.name==="AbortError"||i.name==="TimeoutError")){if(_optionalChain([t, 'access', _23 => _23.config, 'access', _24 => _24.signal, 'optionalAccess', _25 => _25.aborted])===!0)return{ok:!1,retry:!1,cause:new p("Request aborted by caller",u.ABORTED,{context:{endpoint:t.endpoint,requestId:t.requestId,requestSize:t.requestSize},originalError:i})};let c=typeof t.config.timeoutMs=="number"&&t.config.timeoutMs>0?new p(`Request timed out after ${t.config.timeoutMs}ms`,u.TIMEOUT_ERROR,{context:{serverUrl:t.config.serverUrl,timeoutMs:t.config.timeoutMs,url:t.fullUrl,requestId:t.requestId,endpoint:t.endpoint,requestSize:t.requestSize},originalError:i}):new p(`Request aborted by the runtime (${i.name}): ${i.message}`,u.NETWORK_ERROR,{context:{serverUrl:t.config.serverUrl,url:t.fullUrl,requestId:t.requestId,endpoint:t.endpoint,requestSize:t.requestSize},originalError:i});return r<n-1?{ok:!1,retry:!0,delayMs:C(r,e),cause:c}:{ok:!1,retry:!1,cause:c}}if(i instanceof TypeError){let a=typeof window<"u"&&typeof window.document<"u",f={serverUrl:t.config.serverUrl,url:t.fullUrl,requestId:t.requestId,endpoint:t.endpoint,requestSize:t.requestSize},c=a?new p(`Request failed: ${i.message} \u2014 in a browser this usually means a CORS misconfiguration on the server (or a network failure; the browser does not distinguish them)`,u.CORS_ERROR,{context:f,originalError:i}):new p(`Network error: ${i.message}`,u.NETWORK_ERROR,{context:f,originalError:i});return r<n-1?{ok:!1,retry:!0,delayMs:C(r,e),cause:c}:{ok:!1,retry:!1,cause:c}}if(i instanceof p){let a=i.statusCode;return(i.code===u.NETWORK_ERROR&&a!==void 0&&a>=200&&a<300||a!==void 0&&(P.has(a)||e.retryOn429&&a===429))&&r<n-1?{ok:!1,retry:!0,delayMs:C(r,e),cause:i}:{ok:!1,retry:!1,cause:i}}return{ok:!1,retry:!1,cause:new p(i instanceof Error?i.message:String(i),u.UNKNOWN_ERROR,{context:{endpoint:t.endpoint,requestId:t.requestId},originalError:i instanceof Error?i:new Error(String(i))})}}finally{s()}}async function ye(t,e,r){let n=pe(),o=JSON.stringify(e),s=x(o),l=ce(t,r.serverUrl),i=fe(n,r),a=oe(r.retry),f=a.attempts+1;if(r.debug){let g=(s/1024).toFixed(2),d=s>1e5?"\u26A0\uFE0F":"\u{1F680}";y(`${d} Starting compute request [${n}]: ${t} (${g}KB)`,!0)}let c={endpoint:t,body:o,requestSize:s,fullUrl:l,requestId:n,headers:i,config:r};for(let g=0;;g++){let d=await he(c,a,g,f);if(d.ok)return d.value;if(!d.retry)throw d.cause;r.debug&&y(`\u{1F501} Request [${n}] retrying after ${d.delayMs}ms (attempt ${g+2}/${f}): ${d.cause.message}`,!0);try{await ie(d.delayMs,r.signal)}catch (e4){throw new p("Request aborted by caller",u.ABORTED,{context:{endpoint:t,requestId:n,requestSize:s},originalError:d.cause})}}}var Re="compute.rhino3d.com";function K(t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _26 => _26.trim, 'call', _27 => _27()]), () => (""));if(!e)throw new p("serverUrl is required",u.INVALID_CONFIG,{context:{receivedServerUrl:t}});if(!/^https?:\/\//i.test(e))throw new p(`Invalid serverUrl: "${e}". Must start with "http://" or "https://". For example: "http://localhost:5000" or "https://example.com"`,u.INVALID_CONFIG,{context:{receivedServerUrl:t}});let r;try{r=new URL(e)}catch(o){throw new p(`Invalid serverUrl: "${e}". Must be a valid URL. Received error: ${o instanceof Error?o.message:String(o)}`,u.INVALID_CONFIG,{context:{receivedServerUrl:t},originalError:o instanceof Error?o:void 0})}if(r.username!==""||r.password!=="")throw new p(`Invalid serverUrl: "${e}". Must not embed credentials (user:pass@host) \u2014 fetch rejects credentialed URLs at request time. Pass the API key separately.`,u.INVALID_CONFIG,{context:{receivedServerUrl:t}});if(e.includes("?")||e.includes("#"))throw new p(`Invalid serverUrl: "${e}". Must not contain a query string or fragment \u2014 endpoint paths are appended to this URL (e.g. "\${serverUrl}/version"), and a "?" or "#" suffix would corrupt every request path.`,u.INVALID_CONFIG,{context:{receivedServerUrl:t}});if(r.hostname.toLowerCase().replace(/\.+$/,"")===Re)throw new p("serverUrl must be set to your Compute server URL. The default public endpoint is not allowed.",u.INVALID_CONFIG,{context:{receivedServerUrl:t}});return e.replace(/\/+$/,"")}var R=class R{constructor(e,r){h(this,"serverUrl");h(this,"apiKey");h(this,"disposed",!1);h(this,"activeMonitors",new Set);h(this,"activeTimeouts",new Set);this.serverUrl=K(e),this.apiKey=r}buildHeaders(){let e={"Content-Type":"application/json"};return this.apiKey&&(e.RhinoComputeKey=this.apiKey),e}fetchWithTimeout(e,r={},n=R.DEFAULT_TIMEOUT_MS){let o=new Headers(this.buildHeaders());r.headers&&new Headers(r.headers).forEach((i,a)=>{o.set(a,i)});let s={};o.forEach((i,a)=>{s[a]=i});let l={...r,headers:s};return n>0&&!l.signal&&(l.signal=AbortSignal.timeout(n)),fetch(e,l)}async isServerOnline(e=5e3){this.ensureNotDisposed();let r=`${this.serverUrl}/`;try{return(await this.fetchWithTimeout(r,{method:"GET"},e)).ok}catch(n){return m().debug("[ComputeServerStats] Fetch error:",n),!1}}async getActiveChildren(e={}){this.ensureNotDisposed();let{initialize:r=!0}=e,n=r?`${this.serverUrl}/activechildren`:`${this.serverUrl}/activechildren?initialize=false`,o=r?R.LIFECYCLE_TIMEOUT_MS:R.DEFAULT_TIMEOUT_MS;try{let s=await this.fetchWithTimeout(n,{},o);if(!s.ok)return m().warn("[ComputeServerStats] Failed to fetch active children:",s.status),null;let l=(await s.text()).trim();return/^\d+$/.test(l)?parseInt(l,10):(m().warn("[ComputeServerStats] Invalid active children response:",l),null)}catch(s){return m().warn("[ComputeServerStats] Error fetching active children:",s),null}}async getVersion(){this.ensureNotDisposed();try{let e=await this.fetchWithTimeout(`${this.serverUrl}/version`);if(!e.ok)return m().warn("[ComputeServerStats] Failed to fetch version:",e.status),null;let r=await e.text();try{let n=JSON.parse(r);return{rhino:_nullishCoalesce(n.rhino, () => ("")),compute:_nullishCoalesce(n.compute, () => ("")),git_sha:_nullishCoalesce(n.git_sha, () => (null))}}catch (e5){return{rhino:r,compute:"",git_sha:null}}}catch(e){return m().warn("[ComputeServerStats] Error fetching version:",e),null}}async getInstalledPlugins(e="gh"){this.ensureNotDisposed();try{let r=await this.fetchWithTimeout(`${this.serverUrl}/plugins/${e}/installed`);if(!r.ok)return m().warn(`[ComputeServerStats] Failed to fetch ${e} plugins:`,r.status),null;let n=await r.text();try{let o=JSON.parse(n);return o&&typeof o=="object"?o:null}catch (e6){return null}}catch(r){return m().warn(`[ComputeServerStats] Error fetching ${e} plugins:`,r),null}}async getServerStats(){if(this.ensureNotDisposed(),!await this.isServerOnline())return{isOnline:!1};let[r,n]=await Promise.all([this.getVersion(),this.getActiveChildren({initialize:!1})]);return{isOnline:!0,...r&&{version:r},...n!==null&&{activeChildren:n}}}async purgeCache(){this.ensureNotDisposed();try{let e=await this.fetchWithTimeout(`${this.serverUrl}/cache/purge`,{method:"POST"});if(!e.ok)return m().warn("[ComputeServerStats] Failed to purge cache:",e.status),null;let r=await e.text();try{let n=JSON.parse(r);return typeof n.purged=="number"?n.purged:null}catch (e7){return null}}catch(e){return m().warn("[ComputeServerStats] Error purging cache:",e),null}}async purgeAllChildren(){this.ensureNotDisposed();let e=await this.getActiveChildren({initialize:!1});if(e===null)return m().warn("[ComputeServerStats] purgeAllChildren: could not read child count"),null;if(e===0)return{totalPurged:0,calls:0,children:0,confident:!0};let r=e*2,n=0;for(let o=0;o<r;o++){let s=await this.purgeCache();s!==null&&(n+=s)}return{totalPurged:n,calls:r,children:e,confident:e===1}}async getServerTime(){this.ensureNotDisposed();try{let e=await this.fetchWithTimeout(`${this.serverUrl}/servertime`);if(!e.ok)return m().warn("[ComputeServerStats] Failed to fetch server time:",e.status),null;let r=(await e.text()).trim().replace(/^"|"$/g,""),n=new Date(r);return isNaN(n.getTime())?null:n}catch(e){return m().warn("[ComputeServerStats] Error fetching server time:",e),null}}async getIdleSpan(){this.ensureNotDisposed();try{let e=await this.fetchWithTimeout(`${this.serverUrl}/idlespan`);if(!e.ok)return m().warn("[ComputeServerStats] Failed to fetch idle span:",e.status),null;let r=parseFloat((await e.text()).trim());return isNaN(r)?null:r}catch(e){return m().warn("[ComputeServerStats] Error fetching idle span:",e),null}}async launchChildren(){return this.postJson("/launch-children")}async launchChild(e){let r=e===void 0?"/launch-child":`/launch-child?port=${e}`;return this.postJson(r)}async shutdownChildren(e){let r=e===void 0?"/shutdown-children":`/shutdown-children?port=${e}`;return this.postJson(r)}async recycleChildren(e){let r=e===void 0?"/recycle-children":`/recycle-children?port=${e}`;return this.postJson(r)}async postJson(e){this.ensureNotDisposed();try{let r=await this.fetchWithTimeout(`${this.serverUrl}${e}`,{method:"POST"},R.LIFECYCLE_TIMEOUT_MS);if(!r.ok)return m().warn(`[ComputeServerStats] POST ${e} failed:`,r.status),null;let n=await r.text();try{return JSON.parse(n)}catch (e8){return null}}catch(r){return m().warn(`[ComputeServerStats] Error on POST ${e}:`,r),null}}monitor(e,r=5e3){if(this.ensureNotDisposed(),!Number.isFinite(r)||r<R.MIN_MONITOR_INTERVAL_MS)throw new RangeError(`monitor() intervalMs must be a finite number >= ${R.MIN_MONITOR_INTERVAL_MS}ms, got ${r}. Sub-${R.MIN_MONITOR_INTERVAL_MS}ms polling would hot-loop the server.`);let n=!0,o=null;m().info(`\u{1F504} Starting server stats monitoring every ${r}ms`);let s=async()=>{if(o!==null&&(this.activeTimeouts.delete(o),o=null),!(!n||this.disposed)){try{let i=await this.getServerStats();if(!n||this.disposed)return;try{e(i)}catch(a){m().error("[ComputeServerStats] Monitor callback threw:",a)}}catch(i){!n||this.disposed?m().debug("[ComputeServerStats] Monitor poll cancelled during shutdown:",i):m().error("[ComputeServerStats] Failed to fetch stats during monitor:",i)}n&&!this.disposed&&(o=setTimeout(()=>{s()},r),this.activeTimeouts.add(o))}},l=()=>{n=!1,o!==null&&(clearTimeout(o),this.activeTimeouts.delete(o),o=null),this.activeMonitors.delete(l)};return this.activeMonitors.add(l),s(),l}async dispose(){if(!this.disposed){this.disposed=!0;for(let e of this.activeMonitors)e();this.activeMonitors.clear();for(let e of this.activeTimeouts)clearTimeout(e);this.activeTimeouts.clear()}}ensureNotDisposed(){if(this.disposed)throw new p("ComputeServerStats has been disposed and cannot be used",u.INVALID_STATE,{context:{disposed:this.disposed}})}};h(R,"DEFAULT_TIMEOUT_MS",5e3),h(R,"LIFECYCLE_TIMEOUT_MS",6e4),h(R,"MIN_MONITOR_INTERVAL_MS",100);var N=R;function V(t,e={}){let{preserveSpaces:r=!1}=e,n=r?/[-_]+(.)?/g:/[\s\-_]+(.)?/g,o=t.trim().replace(n,(s,l)=>l?l.toUpperCase():"");return o=o.replace(/^[A-Z]+(?=[A-Z][a-z]|[^A-Za-z]|$)/,s=>s.toLowerCase()),o.charAt(0).toLowerCase()+o.slice(1)}function we(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function L(t,e={}){if(!t||typeof t!="object")return t;if(Array.isArray(t))return e.deep?t.map(n=>L(n,e)):t;if(!we(t))return t;let r={};for(let n of Object.keys(t)){let o=V(n,{preserveSpaces:e.preserveSpaces});Object.prototype.hasOwnProperty.call(r,o)&&m().warn(`camelcaseKeys: key '${n}' collides with an earlier key on '${o}' \u2014 the earlier value is overwritten (last key wins).`);let s=t[n];r[o]=e.deep?L(s,e):s}return r}function w(t,e){if(!t||typeof t!="object")return;let r=t;if(z(r,e))return r[e];let n=H(r).get(e.toLowerCase());return n===void 0?void 0:r[n]}var z=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);function Ze(t,e){if(!t||typeof t!="object")return!1;let r=t;return z(r,e)?!0:H(r).has(e.toLowerCase())}var W=new WeakMap;function H(t){let e=Object.keys(t),r=W.get(t);if(r&&r.keyCount===e.length)return r.map;let n=new Map;for(let o of e){let s=o.toLowerCase();n.has(s)||n.set(s,o)}return W.set(t,{keyCount:e.length,map:n}),n}var Ee=async(t,e=null)=>{try{return await J(t,e)}catch(r){throw new p("Failed to extract files from compute response",u.INVALID_STATE,{context:{originalError:r instanceof Error?r.message:String(r)},originalError:r instanceof Error?r:void 0})}},be= exports.t =async(t,e,r=null)=>{if(typeof document>"u"||typeof Blob>"u")throw new p("File download functionality is only available in browser environments. This function requires the DOM API (document, Blob).",u.BROWSER_ONLY,{context:{environment:typeof window<"u"?"browser (SSR)":"Node.js",documentAvailable:typeof document<"u",blobAvailable:typeof Blob<"u"}});try{let n=await J(t,r);await Ie(n,e)}catch(n){throw n instanceof p?n:new p("Failed to download files from compute response",u.INVALID_STATE,{context:{originalError:n instanceof Error?n.message:String(n)},originalError:n instanceof Error?n:void 0})}},A=t=>t.replace(/\\/g,"/").split("/").map(e=>e.trim()).filter(e=>e!==""&&e!=="."&&e!==".."&&!/^[a-zA-Z]:$/.test(e)).join("/"),ve=t=>t===!0||typeof t=="string"&&t.trim().toLowerCase()==="true",Te=t=>{let e=[];return t.forEach(r=>{let n=_nullishCoalesce(w(r,"fileName"), () => ("")),o=_nullishCoalesce(w(r,"fileType"), () => ("")),s=A(`${n}${o}`);if(s===""){m().warn(`Skipping file with unusable name "${n}${o}": no safe archive path remains after sanitization.`);return}let l=w(r,"subFolder"),i=l?A(l):"",a=i!==""?`${i}/${s}`:s,f=w(r,"data");if(typeof f!="string"||f===""){m().warn(`Skipping file "${a}": item carries no usable data.`);return}if(ve(w(r,"isBase64Encoded")))try{e.push({fileName:s,content:k(f),path:a})}catch(c){m().warn(`Skipping file "${a}": base64 decode failed.`,c)}else e.push({fileName:s,content:f,path:a})}),e},Se=3e4,Oe=async t=>(await Promise.all(t.map(async r=>{try{let n=typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"?AbortSignal.timeout(Se):void 0,o=await fetch(r.filePath,{signal:n});if(!o.ok)return m().warn(`Failed to fetch additional file from URL: ${r.filePath}`),null;let s=await o.arrayBuffer(),l=A(r.fileName);if(l==="")return m().warn(`Skipping fetched file with unusable name: ${r.fileName}`),null;let i=r.subFolder?A(r.subFolder):"";return{fileName:l,content:new Uint8Array(s),path:i!==""?`${i}/${l}`:l}}catch(n){return m().error(`Error fetching additional file from URL: ${r.filePath}`,n),null}}))).filter(r=>r!==null),J=async(t,e)=>{let r=Te(t);if(e){let o=Array.isArray(e)?e:[e];r.push(...await Oe(o))}let n=new Set;return r.map(o=>{let s=j(o.path,n);return n.add(s),s===o.path?o:(m().warn(`Duplicate archive path "${o.path}" \u2014 storing as "${s}".`),{...o,path:s,fileName:s.slice(s.lastIndexOf("/")+1)})})};async function Ie(t,e){let{zip:r,strToU8:n}=await Promise.resolve().then(() => _interopRequireWildcard(require("fflate"))),o={},s=new Set;t.forEach(a=>{let f=j(a.path,s);s.add(f),f!==a.path&&m().warn(`Duplicate archive path "${a.path}" \u2014 storing as "${f}".`),o[f]=typeof a.content=="string"?n(a.content):a.content});let l=await new Promise((a,f)=>{r(o,{level:6},(c,g)=>c?f(c):a(g))}),i=new Blob([l],{type:"application/zip"});Ce(i,`${e}.zip`)}function j(t,e){if(!e.has(t))return t;let r=t.lastIndexOf("/"),n=t.lastIndexOf("."),o=n>r?n:t.length,s=t.slice(0,o),l=t.slice(o);for(let i=2;;i++){let a=`${s}-${i}${l}`;if(!e.has(a))return a}}function Ce(t,e){if(typeof document>"u")throw new p("saveFile requires a browser environment with DOM API access.",u.BROWSER_ONLY,{context:{function:"saveFile",requiredAPI:"document"}});let r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download=e,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e4)}exports.a = Ne; exports.b = h; exports.c = u; exports.d = p; exports.e = m; exports.f = F; exports.g = Q; exports.h = Me; exports.i = Fe; exports.j = k; exports.k = te; exports.l = ye; exports.m = K; exports.n = N; exports.o = V; exports.p = L; exports.q = w; exports.r = Ze; exports.s = Ee; exports.t = be;
4
- //# sourceMappingURL=chunk-CUQQ3ZBV.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\chunk-CUQQ3ZBV.cjs"],"names":[],"mappings":"AAAA,u8BAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC,UAAU,CAAC,YAAY,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,aAAa,CAAC,eAAe,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,aAAa,CAAC,eAAe,CAAC,aAAa,CAAC,eAAe,CAAC,aAAa,CAAC,eAAe,CAAC,cAAc,CAAC,gBAAgB,CAAC,YAAY,CAAC,cAAc,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,cAAc,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,eAAe,CAAC,qBAAqB,CAAC,uBAAuB,CAAC,CAAC,CAAC,aAAC,MAAM,EAAE,QAAQ,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,iBAAC,CAAC,6BAAE,YAAU,CAAC,IAAI,CAAC,OAAO,iBAAC,CAAC,6BAAE,SAAO,CAAC,IAAI,CAAC,aAAa,iBAAC,CAAC,6BAAE,eAAa,iBAAC,CAAC,6BAAE,eAAa,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AACA;AACA","file":"D:\\Coding\\selva-compute\\dist\\chunk-CUQQ3ZBV.cjs","sourcesContent":[null]}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkCUQQ3ZBVcjs = require('./chunk-CUQQ3ZBV.cjs');var ne=new Set;function Me(){if(typeof window>"u"||_optionalChain([globalThis, 'access', _2 => _2.process, 'optionalAccess', _3 => _3.versions, 'optionalAccess', _4 => _4.node])!=null)return!1;let e=globalThis.navigator,r=typeof _optionalChain([e, 'optionalAccess', _5 => _5.userAgent])=="string"?e.userAgent:"";return!/jsdom/i.test(r)}function D(t,e){e||Me()&&!ne.has(t)&&(ne.add(t),_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Warning: ${t} is running on the client side. For better performance and security, consider running this on the server side.`))}function T(t){return typeof t=="object"&&!(t instanceof Uint8Array)&&typeof t.key=="string"&&typeof t.load=="function"}var Ge="Unable to load grasshopper definition";function Ve(t){return t instanceof _chunkCUQQ3ZBVcjs.d?t.code===_chunkCUQQ3ZBVcjs.c.DEFINITION_NOT_CACHED||t.message.includes(Ge):!1}function Le(t,e){if(!e)return;let r=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"values");if(!Array.isArray(r)||r.length===0)return;let n=[];for(let s of r){let i=_chunkCUQQ3ZBVcjs.q.call(void 0, s,"innerTree");(!i||Object.keys(i).length===0)&&n.push(_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, s,"paramName"), () => ("<unnamed>")))}if(n.length===0)return;let o=n.length===r.length?"all":`${n.length}/${r.length}`;_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Solve returned empty output(s) (${o}): ${n.join(", ")}. These parameters produced no data \u2014 check the definition's inputs and the branch feeding each.`)}async function E(t,e,r){D("solveGrasshopperDefinition",_nullishCoalesce(r.suppressBrowserWarning, () => (r.suppressClientSideWarning)));let n=await B(e),{response:o}=await N(v(n,t),r);return o}async function oe(t,e,r){D("solveGrasshopperDefinitionWithCacheKey",_nullishCoalesce(r.suppressBrowserWarning, () => (r.suppressClientSideWarning)));let n=await B(e);return N(v(n,t),r)}async function se(t,e,r,n){D("solveByCacheKey",_nullishCoalesce(n.suppressBrowserWarning, () => (n.suppressClientSideWarning)));let o={algo:null,pointer:e,values:t};try{return{...await N(o,n),missed:!1}}catch(s){if(!Ve(s))throw s;let i=await B(r);return{...await N(v(i,t),n),missed:!0}}}async function B(t){if(!T(t))return t;try{return await t.load()}catch(e){throw new (0, _chunkCUQQ3ZBVcjs.d)(`Failed to load definition bytes for ref '${t.key}'`,_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{definitionKey:t.key},originalError:e instanceof Error?e:new Error(String(e))})}}async function N(t,e){We(t,e);let r=await _chunkCUQQ3ZBVcjs.l.call(void 0, "grasshopper",t,e),{pointer:n,algo:o,...s}=r,i=s;return Le(i,e.debug),{response:i,cacheKey:typeof n=="string"?n:null}}function v(t,e){let r={algo:null,pointer:null,values:e};return t instanceof Uint8Array?r.algo=_chunkCUQQ3ZBVcjs.k.call(void 0, t):/^https?:\/\//i.test(t)?r.pointer=t:r.algo=_nullishCoalesce(_chunkCUQQ3ZBVcjs.i.call(void 0, t), () => (_chunkCUQQ3ZBVcjs.h.call(void 0, t))),r}function We(t,e){e.cachesolve!=null&&(t.cachesolve=e.cachesolve),e.cacheerroredsolves!=null&&(t.cacheerroredsolves=e.cacheerroredsolves),e.modelunits!=null&&(t.modelunits=e.modelunits),e.angletolerance!=null&&(t.angletolerance=e.angletolerance),e.absolutetolerance!=null&&(t.absolutetolerance=e.absolutetolerance),e.dataversion!=null&&(t.dataversion=e.dataversion)}function $(t){let e=new WeakSet,r=n=>{if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="number")return Number.isFinite(n)?String(n):"null";if(typeof n=="string"||typeof n=="boolean")return JSON.stringify(n);if(typeof n=="bigint")return`${n}n`;if(n instanceof Uint8Array)return`{"__u8":${n.length},"hash":"${ue(n)}"}`;if(Array.isArray(n)){if(e.has(n))return'"[Circular]"';e.add(n);let o=[];for(let s=0;s<n.length;s++)o.push(r(n[s]));return e.delete(n),`[${o.join(",")}]`}if(typeof n=="object"){if(e.has(n))return'"[Circular]"';e.add(n);let o;return typeof n.toJSON=="function"?o=r(n.toJSON()):n instanceof Map?o=`{"__map":[${[...n.entries()].map(([i,a])=>`[${r(i)},${r(a)}]`).sort().join(",")}]}`:n instanceof Set?o=`{"__set":[${[...n.values()].map(r).sort().join(",")}]}`:o=`{${Object.keys(n).sort().map(a=>`${JSON.stringify(a)}:${r(n[a])}`).join(",")}}`,e.delete(n),o}return"null"};return r(t)}function ie(t,e){let r=2166136261;for(let n=0;n<t;n++)r^=e(n),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return r.toString(16).padStart(8,"0")}function ae(t){return ie(t.length,e=>t.charCodeAt(e))}function ue(t){return ie(t.length,e=>t[e])}function pe(t,e){return q(R(t),e)}function q(t,e){let r=$(e);return`${t}|t:${r.length}:${ae(r)}`}function R(t){return T(t)?`r:${t.key}`:typeof t=="string"?`s:${t.length}:${ae(t)}`:`u8:${t.length}:${ue(t)}`}var je=100;function Be(t){return typeof t!="string"?!0:!/^https?:\/\//i.test(t)}var I=class{constructor(e,r,n={},o){_chunkCUQQ3ZBVcjs.b.call(void 0, this,"executor");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"baseConfig");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"mode");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"maxConcurrent");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"maxQueueDepth");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"queueWaitMs");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"timeoutMs");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"retry");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheEnabled");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheMax");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheTtl");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheErroredSolves");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cache",new Map);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"cacheKeyExecutor");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"reuseServerDefinitionCache");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"serverCacheKeys",new Map);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"onStart");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"onSettle");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"onSuperseded");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"subscribers",new Set);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"inFlight",new Set);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"pendingForLatestWins",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"fifoQueue",[]);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"_lastResult",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"_lastError",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"_lastDurationMs",null);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"solveSeq",0);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"lastStateSeq",0);_chunkCUQQ3ZBVcjs.b.call(void 0, this,"disposed",!1);this.executor=e,this.cacheKeyExecutor=o,this.baseConfig=r,this.mode=_nullishCoalesce(n.mode, () => ("latest-wins")),this.maxConcurrent=Math.max(1,_nullishCoalesce(n.maxConcurrent, () => ((this.mode==="parallel"?4:1)))),this.maxQueueDepth=n.maxQueueDepth!==void 0&&n.maxQueueDepth>0?Math.floor(n.maxQueueDepth):void 0,this.queueWaitMs=n.queueWaitMs!==void 0&&n.queueWaitMs>0?n.queueWaitMs:void 0,this.timeoutMs=n.timeoutMs,this.retry=n.retry;let s=n.cache;this.cacheEnabled=s!==void 0&&s!==!1;let i=typeof s=="object"?s:{};this.cacheMax=_nullishCoalesce(i.maxEntries, () => (50)),this.cacheTtl=_nullishCoalesce(i.ttlMs, () => (0)),this.cacheErroredSolves=_nullishCoalesce(i.cacheErroredSolves, () => (!0)),this.reuseServerDefinitionCache=!!o&&(_nullishCoalesce(n.reuseServerDefinitionCache, () => (!0))),this.onStart=n.onStart,this.onSettle=n.onSettle,this.onSuperseded=n.onSuperseded}get isSolving(){return this.inFlight.size>0}get hasPending(){return this.pendingForLatestWins!==null||this.fifoQueue.length>0}get inFlightCount(){return this.inFlight.size}get queueDepth(){return this.fifoQueue.length+(this.pendingForLatestWins?1:0)}get lastResult(){return this._lastResult}get lastError(){return this._lastError}get lastDurationMs(){return this._lastDurationMs}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}notify(){for(let e of this.subscribers)try{e()}catch(r){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("[SolveScheduler] subscriber threw:",r)}}solve(e,r,n){if(this.disposed)return Promise.reject(new (0, _chunkCUQQ3ZBVcjs.d)("SolveScheduler has been disposed and cannot be used",_chunkCUQQ3ZBVcjs.c.INVALID_STATE));let o=R(e),s=q(o,r),i=++this.solveSeq,a={key:s,enqueuedAt:Date.now(),startedAt:null};if(_optionalChain([n, 'optionalAccess', _6 => _6.signal, 'optionalAccess', _7 => _7.aborted]))return Promise.reject(this.makeAbortError(a));if(this.cacheEnabled){let u=this.readCache(s);if(u){this.mode==="latest-wins"&&this.supersedeCurrent();let d={status:"success",response:u,durationMs:0,fromCache:!0};return this.writeLastState(i,{result:u,durationMs:0}),this.runHook(this.onStart,a),this.runHook(this.onSettle,a,d),this.notify(),Promise.resolve(u)}}return new Promise((u,d)=>{let f={definition:e,dataTree:r,definitionHash:o,ctx:a,seq:i,resolve:u,reject:d,externalSignal:_optionalChain([n, 'optionalAccess', _8 => _8.signal])};f.externalSignal&&(f.queuedAbortHandler=()=>this.abortQueuedItem(f),f.externalSignal.addEventListener("abort",f.queuedAbortHandler,{once:!0})),this.enqueue(f)})}writeLastState(e,r){return e<this.lastStateSeq?!1:(this.lastStateSeq=e,"result"in r?(this._lastResult=r.result,this._lastError=null):this._lastError=r.error,this._lastDurationMs=r.durationMs,!0)}supersedeCurrent(){this.pendingForLatestWins&&(this.supersede(this.pendingForLatestWins),this.pendingForLatestWins=null);for(let e of this.inFlight)this.supersede(e),e.controller.abort()}abortQueuedItem(e){this.pendingForLatestWins===e&&(this.pendingForLatestWins=null);let r=this.fifoQueue.indexOf(e);r>=0&&this.fifoQueue.splice(r,1),this.rejectAsAborted(e),this.notify()}shedAsQueueFull(e){let r=new (0, _chunkCUQQ3ZBVcjs.d)("Solve queue is full; request shed (backpressure)",_chunkCUQQ3ZBVcjs.c.QUEUE_FULL,{statusCode:503,context:{key:e.ctx.key,queueDepth:this.fifoQueue.length,maxQueueDepth:this.maxQueueDepth}});this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:0}),this.notify()}armQueueWaitTimer(e){if(this.queueWaitMs===void 0)return;let r=this.queueWaitMs;e.queueWaitTimer=setTimeout(()=>{if(e.settled)return;let n=this.fifoQueue.indexOf(e);n>=0&&this.fifoQueue.splice(n,1);let o=new (0, _chunkCUQQ3ZBVcjs.d)(`Solve waited longer than ${r}ms in queue; shed (backpressure)`,_chunkCUQQ3ZBVcjs.c.QUEUE_TIMEOUT,{statusCode:503,context:{key:e.ctx.key,waitedMs:Date.now()-e.ctx.enqueuedAt,queueWaitMs:r}});this.settleError(e,o)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:o,durationMs:0}),this.notify()},r)}clearQueueWaitTimer(e){e.queueWaitTimer!==void 0&&(clearTimeout(e.queueWaitTimer),e.queueWaitTimer=void 0)}enqueue(e){switch(this.mode){case"latest-wins":{this.supersedeCurrent(),this.inFlight.size===0?this.execute(e):this.pendingForLatestWins=e;break}case"queue":case"parallel":{this.inFlight.size<this.maxConcurrent?this.execute(e):this.maxQueueDepth!==void 0&&this.fifoQueue.length>=this.maxQueueDepth?this.shedAsQueueFull(e):(this.armQueueWaitTimer(e),this.fifoQueue.push(e));break}}this.notify()}async execute(e){let r=new AbortController,n=e;n.controller=r,this.inFlight.add(n),e.ctx.startedAt=Date.now(),this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e);let o=()=>r.abort();_optionalChain([e, 'access', _9 => _9.externalSignal, 'optionalAccess', _10 => _10.addEventListener, 'call', _11 => _11("abort",o,{once:!0})]),this.runHook(this.onStart,e.ctx),this.notify();let s=performance.now();try{let i={...this.baseConfig,signal:r.signal,...this.timeoutMs!==void 0&&{timeoutMs:this.timeoutMs},...this.retry!==void 0&&{retry:this.retry}},{response:a,definitionReuploaded:u}=await this.runExecutor(e.definition,e.dataTree,e.definitionHash,i),d=performance.now()-s;if(this.cacheEnabled&&this.writeCache(e.ctx.key,a),!this.settleSuccess(e,a))return;this.writeLastState(e.seq,{result:a,durationMs:d}),this.runHook(this.onSettle,e.ctx,{status:"success",response:a,durationMs:d,fromCache:!1,definitionReuploaded:u})}catch(i){let a=performance.now()-s,u=this.normalizeExecutionError(i,n);this.writeLastState(e.seq,{error:u,durationMs:a}),this.settleError(e,u)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:u,durationMs:a})}finally{_optionalChain([e, 'access', _12 => _12.externalSignal, 'optionalAccess', _13 => _13.removeEventListener, 'call', _14 => _14("abort",o)]),this.inFlight.delete(n),this.drainNext(),this.notify()}}async runExecutor(e,r,n,o){if(!this.cacheKeyExecutor||!this.reuseServerDefinitionCache||!Be(e))return{response:await this.executor(e,r,o)};let s=n,i=_nullishCoalesce(this.serverCacheKeys.get(s), () => (null)),a=await this.cacheKeyExecutor(e,r,i,o);if(a.cacheKey)for(this.serverCacheKeys.delete(s),this.serverCacheKeys.set(s,a.cacheKey);this.serverCacheKeys.size>je;){let u=this.serverCacheKeys.keys().next().value;if(u===void 0)break;this.serverCacheKeys.delete(u)}else this.serverCacheKeys.delete(s);return{response:a.response,definitionReuploaded:a.missed}}drainNext(){if(!this.disposed){if(this.mode==="latest-wins"){if(this.pendingForLatestWins&&this.inFlight.size===0){let e=this.pendingForLatestWins;this.pendingForLatestWins=null,this.execute(e)}return}for(;this.fifoQueue.length>0&&this.inFlight.size<this.maxConcurrent;){let e=this.fifoQueue.shift();this.execute(e)}}}supersede(e){let r=new (0, _chunkCUQQ3ZBVcjs.d)("Superseded by newer solve",_chunkCUQQ3ZBVcjs.c.SUPERSEDED,{context:{key:e.ctx.key,enqueuedAt:e.ctx.enqueuedAt}});this.settleError(e,r)&&this.runHook(this.onSuperseded,e.ctx)}makeAbortError(e){return new (0, _chunkCUQQ3ZBVcjs.d)("Request aborted by caller",_chunkCUQQ3ZBVcjs.c.ABORTED,{context:{key:e.key,enqueuedAt:e.enqueuedAt}})}settleError(e,r){return e.settled?!1:(e.settled={error:r},this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e),e.reject(r),!0)}settleSuccess(e,r){return e.settled?!1:(e.settled={ok:!0},this.clearQueueWaitTimer(e),this.removeQueuedAbortHandler(e),e.resolve(r),!0)}removeQueuedAbortHandler(e){e.queuedAbortHandler&&e.externalSignal&&e.externalSignal.removeEventListener("abort",e.queuedAbortHandler),e.queuedAbortHandler=void 0}isAbortLikeError(e){if(e instanceof Error){if(e.name==="AbortError")return!0;if(typeof DOMException<"u"&&e instanceof DOMException)return e.name==="AbortError"}return!1}normalizeExecutionError(e,r){return r.settled&&"error"in r.settled?r.settled.error:e instanceof _chunkCUQQ3ZBVcjs.d?e:this.isAbortLikeError(e)?this.makeAbortError(r.ctx):new (0, _chunkCUQQ3ZBVcjs.d)(e instanceof Error?e.message:String(e),_chunkCUQQ3ZBVcjs.c.UNKNOWN_ERROR,{originalError:e instanceof Error?e:new Error(String(e))})}cancelAll(){for(this.pendingForLatestWins&&(this.rejectAsAborted(this.pendingForLatestWins),this.pendingForLatestWins=null);this.fifoQueue.length>0;){let e=this.fifoQueue.shift();this.rejectAsAborted(e)}for(let e of this.inFlight){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:e.ctx.startedAt?Date.now()-e.ctx.startedAt:0}),e.controller.abort()}this.notify()}rejectAsAborted(e){let r=this.makeAbortError(e.ctx);this.settleError(e,r)&&this.runHook(this.onSettle,e.ctx,{status:"error",error:r,durationMs:0})}readCache(e){if(!this.cacheEnabled)return null;let r=this.cache.get(e);return r?this.cacheTtl>0&&Date.now()-r.insertedAt>this.cacheTtl?(this.cache.delete(e),null):(this.cache.delete(e),this.cache.set(e,r),r.response):null}writeCache(e,r){if(this.cacheEnabled&&!(!this.cacheErroredSolves&&r.errors&&r.errors.length>0))for(this.cache.set(e,{response:r,insertedAt:Date.now()});this.cache.size>this.cacheMax;){let n=this.cache.keys().next().value;if(n===void 0)break;this.cache.delete(n)}}clearCache(){this.cache.clear()}dispose(){this.disposed||(this.disposed=!0,this.cancelAll(),this.subscribers.clear(),this.cache.clear())}runHook(e,...r){if(e)try{e(...r)}catch(n){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("[SolveScheduler] hook threw:",n)}}};function le(t){return T(t)?`ref:${t.key}`:typeof t=="string"&&t.length<200?t:"...content..."}function ce(t){return Array.isArray(t)?t.map(e=>{let r=0,n=0,o=_chunkCUQQ3ZBVcjs.q.call(void 0, e,"innerTree");if(o&&typeof o=="object"){for(let s of Object.values(o))if(Array.isArray(s)){r+=s.length;for(let i of s){let a=_optionalChain([i, 'optionalAccess', _15 => _15.data]);typeof a=="string"&&(n+=a.length)}}}return{param:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, e,"paramName"), () => ("<unnamed>")),items:r,bytes:n}}):[]}var A=class t{constructor(e){_chunkCUQQ3ZBVcjs.b.call(void 0, this,"config");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"serverStats");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"disposed",!1);this.config=this.normalizeComputeConfig(e),this.serverStats=new (0, _chunkCUQQ3ZBVcjs.n)(this.config.serverUrl,this.config.apiKey)}static async create(e){let r=new t(e),n=Math.max(1,(_nullishCoalesce(_optionalChain([e, 'access', _16 => _16.retry, 'optionalAccess', _17 => _17.attempts]), () => (2)))+1),o=_nullishCoalesce(_optionalChain([e, 'access', _18 => _18.retry, 'optionalAccess', _19 => _19.baseDelayMs]), () => (250)),s=_nullishCoalesce(_optionalChain([e, 'access', _20 => _20.retry, 'optionalAccess', _21 => _21.maxDelayMs]), () => (1e3));for(let i=0;i<n;i++){if(await r.serverStats.isServerOnline())return r;if(i<n-1){let a=Math.min(o*2**i,s);await new Promise(u=>setTimeout(u,a))}}throw await r.dispose(),new (0, _chunkCUQQ3ZBVcjs.d)("Rhino Compute server is not online",_chunkCUQQ3ZBVcjs.c.NETWORK_ERROR,{context:{serverUrl:r.config.serverUrl,attempts:n}})}getConfig(){return this.ensureNotDisposed(),{...this.config}}async getIO(e){return this.ensureNotDisposed(),M(e,this.config)}async getRawIO(e){return this.ensureNotDisposed(),P(e,this.config)}async solve(e,r,n){this.ensureNotDisposed();try{if(typeof e=="string"&&!_optionalChain([e, 'optionalAccess', _22 => _22.trim, 'call', _23 => _23()]))throw new (0, _chunkCUQQ3ZBVcjs.d)("Definition URL/content is required",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{receivedUrl:e}});if(e instanceof Uint8Array&&e.length===0)throw new (0, _chunkCUQQ3ZBVcjs.d)("Definition content is empty",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT);if(T(e)&&!e.key.trim())throw new (0, _chunkCUQQ3ZBVcjs.d)("DefinitionRef key is empty",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT);let o={...this.config,..._optionalChain([n, 'optionalAccess', _24 => _24.signal])!==void 0&&{signal:n.signal},..._optionalChain([n, 'optionalAccess', _25 => _25.timeoutMs])!==void 0&&{timeoutMs:n.timeoutMs},..._optionalChain([n, 'optionalAccess', _26 => _26.retry])!==void 0&&{retry:n.retry}},s=await E(r,e,o);if(_optionalChain([s, 'optionalAccess', _27 => _27.errors])&&s.errors.length>0)throw new (0, _chunkCUQQ3ZBVcjs.d)(s.errors.join("; ")||"Computation failed",_chunkCUQQ3ZBVcjs.c.COMPUTATION_ERROR,{context:{definition:le(e),inputSummary:ce(r),errors:s.errors,warnings:s.warnings,values:s.values}});return s}catch(o){throw this.config.debug&&_chunkCUQQ3ZBVcjs.e.call(void 0, ).error("Compute failed:",o),o instanceof _chunkCUQQ3ZBVcjs.d?o:new (0, _chunkCUQQ3ZBVcjs.d)(o instanceof Error?o.message:String(o),_chunkCUQQ3ZBVcjs.c.COMPUTATION_ERROR,{context:{definition:le(e),inputSummary:ce(r)},originalError:o instanceof Error?o:new Error(String(o))})}}createScheduler(e){this.ensureNotDisposed();let r=(o,s,i)=>E(s,o,i),n=(o,s,i,a)=>i===null?oe(s,o,a).then(u=>({...u,missed:!1})):se(s,i,o,a);return new I(r,this.config,e,n)}async dispose(){this.disposed||(this.disposed=!0,await this.serverStats.dispose())}ensureNotDisposed(){if(this.disposed)throw new (0, _chunkCUQQ3ZBVcjs.d)("GrasshopperClient has been disposed and cannot be used",_chunkCUQQ3ZBVcjs.c.INVALID_STATE)}normalizeComputeConfig(e){return{...e,serverUrl:_chunkCUQQ3ZBVcjs.m.call(void 0, e.serverUrl),apiKey:e.apiKey,authToken:e.authToken,debug:_nullishCoalesce(e.debug, () => (!1)),suppressBrowserWarning:_nullishCoalesce(e.suppressBrowserWarning, () => (e.suppressClientSideWarning))}}};var G=new Map;function de(t,e){G.set(t,e)}de("Rhino.Geometry.Point3d",(t,e)=>{let r=e;return!r||typeof r.X!="number"?null:new t.Point([r.X,r.Y,r.Z])});de("Rhino.Geometry.Line",(t,e)=>{let r=e;return!r||!r.From||!r.To?null:new t.Line([r.From.X,r.From.Y,r.From.Z],[r.To.X,r.To.Y,r.To.Z])});function $e(t){if(G.has(t))return G.get(t);for(let[e,r]of G)if(t.startsWith(e))return r}function qe(t){return!!(t&&typeof t=="object"&&typeof t.data=="string")}function fe(t,e){return{__decodeError:!0,type:t,raw:e}}function me(t,e,r){let n=$e(e),o=!1;if(n)try{let s=n(r,t);if(s!=null)return s}catch(s){_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to decode Rhino type ${e}:`,s),o=!0}try{if(qe(t))return r.CommonObject.decode(t)}catch(s){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to decode ${e} with CommonObject:`,s),fe(e,t)}return o?fe(e,t):t}function he(t){let e=new WeakSet,r=n=>{if(!n||typeof n!="object"||e.has(n))return;e.add(n);let o=n.delete;if(typeof o=="function"){let i=n.isDeleted;(typeof i!="function"||!i.call(n))&&o.call(n);return}if(Array.isArray(n)){for(let i of n)r(i);return}let s=Object.getPrototypeOf(n);if(s===Object.prototype||s===null)for(let i of Object.values(n))r(i)};r(t)}var x={STRING:"System.String",INT:"System.Int32",DOUBLE:"System.Double",BOOL:"System.Boolean"},Ue="Rhino.Geometry.",ze=["WebDisplay"],_e="FileData";function ye(t){return ze.some(e=>t.includes(e))}function Ke(t){if(typeof t!="string")return t;let e=t.trim();if(!(e.startsWith("{")||e.startsWith("[")||e.startsWith('"')))return t;try{let n=JSON.parse(e);if(typeof n=="string")try{return JSON.parse(n)}catch (e2){return n}return n}catch (e3){return t}}function Qe(t,e,r){switch(e){case x.STRING:return typeof t!="string"?t:t.replace(/^"(.*)"$/,"$1");case x.INT:return Number.parseInt(t,10);case x.DOUBLE:return Number.parseFloat(t);case x.BOOL:return String(t).toLowerCase()==="true";default:return r&&e.startsWith(Ue)?me(t,e,r):t}}var U=new WeakMap;function ge(t){if(U.has(t))return U.get(t);let e=Ke(t.data);return U.set(t,e),e}function be(t,e,r,n){if(typeof t.data!="string")return t.data;let o=r?ge(t):t.data;return Qe(o,e,n)}function He(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fileName=="string"&&typeof e.fileType=="string"&&"data"in e&&typeof e.isBase64Encoded=="boolean"&&typeof e.subFolder=="string"}function z(t){let e=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"values");return Array.isArray(e)?e:[]}function _(t){return typeof t.type=="string"?t.type:""}function K(t,e){if(!(!t||typeof t!="object")){for(let r of Object.values(t))if(Array.isArray(r))for(let n of r)n&&typeof n=="object"&&e(n)}}function Te(t,e=!1,r={}){let{parseValues:n=!0,rhino:o,stringOnly:s=!1}=r,i={},a=new Set;for(let u of z(t)){let d=_chunkCUQQ3ZBVcjs.q.call(void 0, u,"paramName");K(_chunkCUQQ3ZBVcjs.q.call(void 0, u,"innerTree"),f=>{let m=_(f);if(ye(m)||s&&m!==x.STRING)return;let g=e?f.id:d;if(!g)return;let b=be(f,m,n,o);g in i?a.has(g)?i[g].push(b):(i[g]=[i[g],b],a.add(g)):i[g]=b})}return{values:i,dispose:()=>he(i)}}function Se(t){let e=[];for(let r of z(t))K(_chunkCUQQ3ZBVcjs.q.call(void 0, r,"innerTree"),n=>{if(!_(n).includes(_e))return;let o=ge(n);He(o)&&e.push(o)});return e}function De(t,e,r={}){let{parseValues:n=!0,rhino:o,stringOnly:s=!1}=r;for(let i of z(t)){let a=_chunkCUQQ3ZBVcjs.q.call(void 0, i,"innerTree"),u=!1;if("byName"in e){if(_chunkCUQQ3ZBVcjs.q.call(void 0, i,"paramName")!==e.byName)continue;u=!0}let d=[];if(K(a,f=>{if("byId"in e){if(f.id!==e.byId)return;u=!0}let m=_(f);ye(m)||s&&m!==x.STRING||d.push(be(f,m,n,o))}),u)return d.length===0?void 0:d.length===1?d[0]:d}}var k=class{constructor(e,r=!1){this.response=e;this.debug=r}getValues(e=!1,r={}){return Te(this.response,e,r)}getValue(e,r){return De(this.response,e,r)}async extractMeshesFromResponse(e){let r={debug:this.debug,...e},n;try{({getThreeMeshesFromComputeResponse:n}=await Promise.resolve().then(() => _interopRequireWildcard(require("./visualization-4RSUYQG2.cjs"))))}catch(o){throw new (0, _chunkCUQQ3ZBVcjs.d)("Failed to load three.js visualization module. Ensure three.js is installed as a peer dependency.",_chunkCUQQ3ZBVcjs.c.INVALID_STATE,{context:{originalError:o instanceof Error?o.message:String(o)}})}return n(this.response,r)}getFileData(){return Se(this.response)}async getAndDownloadFiles(e,r){let n=this.getFileData();await _chunkCUQQ3ZBVcjs.t.call(void 0, n,e,r)}};var Q=/^\{(-?\d+(?:;-?\d+)*)?\}$/;function C(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.entries(t);return e.length>0&&e.every(([r,n])=>Q.test(r)&&Array.isArray(n))}function w(t,e,r){if(t==null)return t;if(Array.isArray(t)){let o=t.map(e).filter(s=>s!==null);return o.length>0?o:void 0}let n=e(t);return n!==null?n:r?void 0:t}var V=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"){let e=t.trim();if(e===""||/^[+-]?0[xbo]/i.test(e))return null;let r=Number(e);return Number.isFinite(r)?r:null}return null},H=t=>{if(typeof t=="boolean")return t;if(typeof t=="string"){let e=t.trim().toLowerCase();if(e==="true")return!0;if(e==="false")return!1}return null},Je=t=>typeof t=="string"?t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t.startsWith('"')?t.slice(1):t:null,Ye=t=>{if(typeof t=="string"){let e=t.trim();return e.startsWith('"')&&e.endsWith('"')&&(e=e.slice(1,-1).trim()),e}return null};function xe(t){return e=>{if(typeof e=="object"&&e!==null)return e;if(typeof e=="string"&&e.trim()!=="")try{let r=JSON.parse(e);return typeof r=="object"&&r!==null?r:(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Parsed value for input ${t} is not an object`),null)}catch(r){return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`Failed to parse object value "${e}" for input ${t}`,r),null}return null}}function Ie(t,e,r){let n=Number(t.toFixed(e));return Math.abs(t-n)<r?n:t}function Xe(t,e){if(!Number.isFinite(t)||t===0)return .1;let r=Math.abs(t);if(r>=1){let g=String(t).split(".")[1];if(g&&g.length>0){let b=Math.min(g.length,12),S=Math.pow(10,-b),Y=Number(S.toFixed(b));return Math.abs(Y-S)<e?Y:S}return 1}let n=String(t),o=n.toLowerCase().match(/e(-?\d+)/);if(o){let m=Number(o[1]);if(m<0||n.toLowerCase().includes("e-")){let g=Math.abs(m),b=Math.pow(10,-g),S=Number(b.toFixed(g));return Math.abs(S-b)<e?S:b}return .1}let s=12,a=r.toFixed(s).replace(/0+$/,""),u=Math.min((a.split(".")[1]||"").length,s);if(u===0)return .1;let d=Math.pow(10,-u),f=Number(d.toFixed(u));return Math.abs(f-d)<e?f:d}function Ce(t){return typeof t.stepSize=="number"&&Number.isFinite(t.stepSize)&&t.stepSize>0?t.stepSize:void 0}function Ze(t,e=1e-8){let r=t.paramType==="Integer",n=Ce(t);if(C(t.default))return{default:t.default,stepSize:_nullishCoalesce(n, () => ((r?1:.1)))};if(typeof t.default=="string"&&t.default.trim()!==""&&V(t.default)===null)throw new (0, _chunkCUQQ3ZBVcjs.d)(`Invalid numeric default "${t.default}" for input "${t.name||"unknown"}"`,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});let o=w(t.default,V,!0);if(r)return Array.isArray(o)?o=o.map(m=>typeof m=="number"?Math.round(m):m):typeof o=="number"&&(o=Math.round(o)),{default:o,stepSize:_nullishCoalesce(n, () => (1))};let s=Array.isArray(o)?o[0]:o,i;typeof s=="number"&&Number.isFinite(s)&&s!==0?i=s:typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum!==0?i=t.minimum:typeof t.maximum=="number"&&Number.isFinite(t.maximum)&&t.maximum!==0&&(i=t.maximum);let a=_nullishCoalesce(n, () => ((i!==void 0?Xe(i,e):.1))),u=0,d=String(a),f=d.toLowerCase().match(/e(-?\d+)/);if(f?u=Math.abs(Number(f[1])):u=_nullishCoalesce(_optionalChain([d, 'access', _28 => _28.split, 'call', _29 => _29("."), 'access', _30 => _30[1], 'optionalAccess', _31 => _31.length]), () => (0)),u===0&&typeof s=="number"&&s!==0&&Math.abs(s)<1){let m=Math.ceil(-Math.log10(Math.abs(s)));Number.isFinite(m)&&m>0&&(u=m)}return u=Math.min(Math.max(u,0),12),Array.isArray(o)?o=o.map(m=>typeof m=="number"?Ie(m,u,e):m):typeof o=="number"&&(o=Ie(o,u,e)),{default:o,stepSize:a}}var et={types:["Number","Integer"],parse(t,e){let{default:r,stepSize:n}=Ze(t);return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:n,default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1,n=typeof t.minimum=="number"&&Number.isFinite(t.minimum)&&t.minimum>0?t.minimum:0;return{...e,paramType:t.paramType,minimum:t.minimum,maximum:t.maximum,atLeast:t.atLeast,atMost:t.atMost,stepSize:_nullishCoalesce(Ce(t), () => ((t.paramType==="Integer"?1:.1))),default:r?[n]:n}}},tt={types:["Boolean"],parse(t,e){if(C(t.default))return{...e,paramType:"Boolean",default:t.default};let r=w(t.default,H,!1);if(r!=null&&typeof r!="boolean"&&!Array.isArray(r))throw new (0, _chunkCUQQ3ZBVcjs.d)(`Invalid boolean default "${String(r)}" for input "${t.name||"unknown"}"`,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});return{...e,paramType:"Boolean",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Boolean",default:r?[!1]:!1}}},rt={types:["Text"],parse(t,e){let r=w(t.default,Je,!1);return{...e,paramType:"Text",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Text",default:r?[""]:""}}},nt={types:["ValueList"],parse(t,e){if(!t.values||typeof t.values!="object"||Object.keys(t.values).length===0)throw _chunkCUQQ3ZBVcjs.d.missingValues(t.nickname||"unnamed","ValueList");let r=t.default;if(t.default!==void 0&&t.default!==null){if(typeof t.default=="object")throw new (0, _chunkCUQQ3ZBVcjs.d)(`ValueList input "${t.nickname||"unnamed"}" default is not a string-able value`,_chunkCUQQ3ZBVcjs.c.VALIDATION_ERROR,{context:{inputName:t.name,default:t.default}});let n=String(t.default).toLowerCase(),o=Object.keys(t.values).find(s=>s.toLowerCase()===n);o!==void 0?r=o:_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`ValueList input "${t.nickname||"unnamed"}" default value "${t.default}" is not in available values`)}return{...e,paramType:"ValueList",values:t.values,default:r}},fallback(t,e){return{...e,paramType:"ValueList",values:t.values&&typeof t.values=="object"?t.values:{},default:void 0}}},we={types:["Geometry"],parse(t,e){let r=w(t.default,xe(t.nickname||"unnamed"),!0);return{...e,paramType:"Geometry",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Geometry",default:r?[null]:null}}},ot={types:["File"],parse(t,e){let r=w(t.default,xe(t.nickname||"unnamed"),!0);return{...e,paramType:"File",acceptedFormats:t.acceptedFormats,default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"File",default:r?[null]:null}}},st={types:["Color"],parse(t,e){let r=w(t.default,Ye,!1);return{...e,paramType:"Color",default:r}},fallback(t,e){let r=(_nullishCoalesce(t.atMost, () => (1)))>1;return{...e,paramType:"Color",default:r?["0, 0, 0"]:"0, 0, 0"}}},it=[et,tt,rt,nt,we,ot,st],J=new Map(it.flatMap(t=>t.types.map(e=>[e,t]))),Ee=we;function ve(t){return _chunkCUQQ3ZBVcjs.q.call(void 0, t,"data")}function at(t){return _chunkCUQQ3ZBVcjs.q.call(void 0, t,"type")}var ut=new Set(["System.Double","System.Single","System.Decimal","System.Int32","System.Int64"]),pt=new Set(["System.Int32","System.Int64"]);function Re(t){if(typeof t.default!="object"||t.default===null)return{schema:t};if(Array.isArray(t.default))return{schema:t};if(!_chunkCUQQ3ZBVcjs.r.call(void 0, t.default,"innerTree")){let n=`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default had an unrecognized shape (no innerTree key); the default was dropped.`;return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Unexpected structure in input.default:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:n}}}let e=_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t.default,"innerTree"), () => ({}));if(Object.keys(e).length===0)return{schema:{...t,default:void 0}};if(t.treeAccess||t.atMost&&t.atMost>1){let n={},o=[];for(let[i,a]of Object.entries(e)){if(!Array.isArray(a)){let d=`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default had a non-array innerTree branch ("${i}"); the default was dropped.`;return _chunkCUQQ3ZBVcjs.e.call(void 0, ).warn("Unexpected structure in input.default innerTree:",t.default),{schema:{...t,default:null},warning:{code:"MALFORMED_DEFAULT",message:d}}}let u=[];for(let d of a){let f=ve(d),m=at(d);if(m&&ut.has(m)){if(typeof f=="string"&&f.trim()==="")continue;let g=V(f);if(g===null){o.push(`"${String(f)}" (${m})`);continue}u.push(pt.has(m)?Math.round(g):g);continue}if(m==="System.Boolean"){let g=H(f);if(g===null){o.push(`"${String(f)}" (${m})`);continue}u.push(g);continue}if(typeof f=="string"&&_optionalChain([m, 'optionalAccess', _32 => _32.startsWith, 'call', _33 => _33("Rhino.Geometry")])){try{u.push(JSON.parse(f))}catch (e4){u.push(f)}continue}u.push(f)}n[i]=u}let s;if(o.length>0){let i=`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default contained ${o.length} tree value(s) that could not be parsed and were dropped: ${o.join(", ")}.`;_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(i),s={code:"MALFORMED_DEFAULT",message:i}}return{schema:{...t,default:n},...s&&{warning:s}}}let r=[];for(let n of Object.values(e))Array.isArray(n)&&n.forEach(o=>{o&&typeof o=="object"&&_chunkCUQQ3ZBVcjs.r.call(void 0, o,"data")&&r.push(ve(o))});return r.length===0?{schema:{...t,default:void 0}}:r.length===1?{schema:{...t,default:r[0]}}:{schema:{...t,default:r}}}var lt=new Map([...J.keys()].map(t=>[t.toLowerCase(),t]));function ct(t){return _nullishCoalesce(lt.get(_optionalChain([t, 'optionalAccess', _34 => _34.toLowerCase, 'call', _35 => _35()])), () => (t))}function Ae(t){return Pe(t).input}function Pe(t){let e={description:t.description,name:t.name,nickname:t.nickname,treeAccess:t.treeAccess,groupName:_nullishCoalesce(t.groupName, () => (void 0)),id:t.id},r=ct(t.paramType),n={...t,paramType:r},o;try{let{schema:i,warning:a}=Re(n);n=i,o=a&&{inputName:t.name||"unknown",paramType:t.paramType,message:a.message,code:a.code}}catch(i){n={...n,default:null},o={inputName:t.name||"unknown",paramType:t.paramType,message:`Input "${_nullishCoalesce(t.name, () => ("unknown"))}" default could not be normalized and was dropped: ${i instanceof Error?i.message:String(i)}`,code:"MALFORMED_DEFAULT"}}let s=J.get(r);try{if(!s)throw _chunkCUQQ3ZBVcjs.d.unknownParamType(r,t.name);return{input:s.parse(n,e),error:o,...o&&{errors:[o]}}}catch(i){if(i instanceof _chunkCUQQ3ZBVcjs.d){_chunkCUQQ3ZBVcjs.e.call(void 0, ).error(`Validation error for input ${t.name||"unknown"}:`,i.message);let a={inputName:t.name||"unknown",paramType:t.paramType,message:i.message,code:i.code};return{input:(_nullishCoalesce(s, () => (Ee))).fallback(n,e),error:a,errors:o?[o,a]:[a]}}throw new (0, _chunkCUQQ3ZBVcjs.d)(i instanceof Error?i.message:String(i),"VALIDATION_ERROR",{context:{paramName:t.name,paramType:r},originalError:i instanceof Error?i:new Error(String(i))})}}function ke(t){return L(t).inputs}function L(t){let e=[],r=[];for(let n of t){let{input:o,errors:s}=Pe(n);e.push(o),s&&r.push(...s)}return{inputs:e,parseErrors:r}}function Oe(t){let e=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"stepSize");return{id:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"id"), () => ("")),name:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"name"), () => ("")),nickname:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"nickname"), () => (null)),description:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"description"), () => ("")),paramType:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"paramType"), () => ("")),treeAccess:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"treeAccess"), () => (!1)),minimum:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"minimum"), () => (null)),maximum:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"maximum"), () => (null)),atLeast:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"atLeast"), () => (1)),atMost:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"atMost"), () => (1)),stepSize:typeof e=="number"&&Number.isFinite(e)?e:void 0,default:_chunkCUQQ3ZBVcjs.q.call(void 0, t,"default"),values:_chunkCUQQ3ZBVcjs.q.call(void 0, t,"values"),acceptedFormats:_chunkCUQQ3ZBVcjs.q.call(void 0, t,"acceptedFormats"),groupName:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"groupName"), () => (null))}}function Fe(t){return{name:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"name"), () => ("")),nickname:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"nickname"), () => (null)),paramType:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"paramType"), () => ("")),id:_nullishCoalesce(_chunkCUQQ3ZBVcjs.q.call(void 0, t,"id"), () => (""))}}async function P(t,e){let r=v(t,[]),n={};if(r.algo&&(n.algo=r.algo),r.pointer&&(n.pointer=r.pointer),!n.algo&&!n.pointer)throw new (0, _chunkCUQQ3ZBVcjs.d)("Definition must resolve to either a URL pointer or base64 algo",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{definition:t}});let o=await _chunkCUQQ3ZBVcjs.l.call(void 0, "io",n,e);if(!o||typeof o!="object")throw new (0, _chunkCUQQ3ZBVcjs.d)("Invalid IO response structure",_chunkCUQQ3ZBVcjs.c.INVALID_INPUT,{context:{response:o,definition:t}});let s=Ne(_chunkCUQQ3ZBVcjs.q.call(void 0, o,"warnings")),i=Ne(_chunkCUQQ3ZBVcjs.q.call(void 0, o,"errors")),a=_chunkCUQQ3ZBVcjs.q.call(void 0, o,"inputs"),u=_chunkCUQQ3ZBVcjs.q.call(void 0, o,"outputs");return{inputs:Array.isArray(a)?a.map(Oe):[],outputs:Array.isArray(u)?u.map(Fe):[],...s&&{loadWarnings:s},...i&&{loadErrors:i}}}function Ne(t){if(!Array.isArray(t))return;let e=t.map(ft).filter(r=>r!==void 0);return e.length>0?e:void 0}function ft(t){if(t==null)return;let e;if(typeof t=="string")e=t;else if(typeof t=="object"){let r=_chunkCUQQ3ZBVcjs.q.call(void 0, t,"message");if(typeof r=="string"&&r.trim().length>0)e=r;else try{e=_nullishCoalesce(JSON.stringify(t), () => (String(t)))}catch (e5){e=String(t)}}else e=String(t);return e.trim().length>0?e:void 0}async function M(t,e){D("fetchParsedDefinitionIO",_nullishCoalesce(e.suppressBrowserWarning, () => (e.suppressClientSideWarning)));let{inputs:r,outputs:n,loadWarnings:o,loadErrors:s}=await P(t,e),{inputs:i,parseErrors:a}=L(r);return{inputs:i,outputs:n,...a.length>0&&{parseErrors:a},...o&&{loadWarnings:o},...s&&{loadErrors:s}}}var W=class t{constructor(e){_chunkCUQQ3ZBVcjs.b.call(void 0, this,"innerTree");_chunkCUQQ3ZBVcjs.b.call(void 0, this,"paramName");this.paramName=e,this.innerTree={}}append(e,r){let n=t.formatPathString(e);this.innerTree[n]||(this.innerTree[n]=[]);let o=r.map(s=>({data:t.serializeValue(s)}));return this.innerTree[n].push(...o),this}appendSingle(e,r){return this.append(e,[r])}fromDataTreeDefault(e){this.innerTree={};for(let[r,n]of Object.entries(e)){if(!Array.isArray(n))continue;let o=t.parsePathString(r);this.append(o,n)}return this}appendFlat(e){let r=Array.isArray(e)?e:[e];return this.append([0],r)}flatten(){let e=[];for(let r of Object.values(this.innerTree))if(Array.isArray(r))for(let n of r)e.push(t.deserializeValue(n.data));return e}getPaths(){return Object.keys(this.innerTree)}getPath(e){let r=t.formatPathString(e),n=this.innerTree[r];if(n)return n.map(o=>t.deserializeValue(o.data))}toComputeFormat(){return{ParamName:this.paramName,InnerTree:this.innerTree}}getInnerTree(){return this.innerTree}getParamName(){return this.paramName}static fromInputParams(e){return e.filter(r=>t.hasValidValue(r.default)).map(r=>{let n=new t(r.nickname||"unnamed"),o=r.default;if(r.treeAccess&&C(o))n.fromDataTreeDefault(o),t.isNumericInput(r)&&n.applyNumericConstraints(r.minimum,r.maximum,r.nickname||"unnamed");else{let s=Array.isArray(o)?o:[o],i=t.processValues(s,r);n.appendFlat(i)}return n.toComputeFormat()})}static fromInputParam(e){return t.hasValidValue(e.default)?t.fromInputParams([e])[0]:void 0}static replaceTreeValue(e,r,n){let o=e.length>0&&e[0]instanceof t,s=t.buildFromValue(r,n);if(o){let d=e.slice(),f=d.findIndex(m=>m.getParamName()===r);return f!==-1?d[f]=s:d.push(s),d}let i=e.slice(),a=s.toComputeFormat(),u=i.findIndex(d=>d.ParamName===r);return u!==-1?i[u]=a:i.push(a),i}static buildFromValue(e,r){let n=new t(e);return C(r)?n.fromDataTreeDefault(r):n.appendFlat(r),n}static getTreeValue(e,r){let o=e.length>0&&e[0]instanceof t?t.readFromBuilders(e,r):t.readFromDataTrees(e,r);return o===null||o.length===0?null:o.length===1?o[0]:o}static readFromBuilders(e,r){let n=e.find(o=>o.getParamName()===r);return n?n.flatten():null}static readFromDataTrees(e,r){let n=e.find(i=>i.ParamName===r);if(!_optionalChain([n, 'optionalAccess', _36 => _36.InnerTree]))return null;let o=Object.keys(n.InnerTree)[0];if(!o)return null;let s=n.InnerTree[o];return Array.isArray(s)?s.map(i=>_optionalChain([i, 'optionalAccess', _37 => _37.data])!==void 0?t.deserializeValue(i.data):null):_optionalChain([s, 'optionalAccess', _38 => _38.data])!==void 0?[t.deserializeValue(s.data)]:s!==void 0?[s]:null}static parsePathString(e){let r=e.match(Q);if(!r)throw new Error(`Invalid Grasshopper tree path: "${e}". Expected "{}", "{0}", or "{0;1;2}" (negative indices allowed, no empty segments).`);return r[1]?r[1].split(";").map(Number):[]}static formatPathString(e){return`{${e.join(";")}}`}applyNumericConstraints(e,r,n){for(let o of Object.values(this.innerTree))if(Array.isArray(o))for(let s of o){let i=t.deserializeValue(s.data);if(typeof i=="number"){let a=t.clampValue(i,e,r,n);s.data=t.serializeValue(a)}}}static serializeValue(e){return typeof e=="boolean"||typeof e=="number"||typeof e=="string"?e:typeof e=="object"&&e!==null?JSON.stringify(e):String(e)}static deserializeValue(e){if(typeof e=="boolean"||typeof e=="number"||typeof e!="string")return e;if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch (e6){return e}let r=Number(e);return Number.isFinite(r)&&String(r)===e?r:e==="true"?!0:e==="false"?!1:e}static hasValidValue(e){return e==null?!1:typeof e=="string"?!0:!(Array.isArray(e)&&e.length===0||typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0)}static isNumericInput(e){return e.paramType==="Number"||e.paramType==="Integer"}static processValues(e,r){return e.map(n=>t.isNumericInput(r)&&typeof n=="number"?t.clampValue(n,r.minimum,r.maximum,r.nickname||"unnamed"):n).filter(n=>n!=null)}static clampValue(e,r,n,o){let s=e;return r!=null&&s<r&&(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`${o}: ${e} below min ${r}, clamping`),s=r),n!=null&&s>n&&(_chunkCUQQ3ZBVcjs.e.call(void 0, ).warn(`${o}: ${e} above max ${n}, clamping`),s=n),s}};exports.a = T; exports.b = E; exports.c = $; exports.d = pe; exports.e = R; exports.f = I; exports.g = A; exports.h = k; exports.i = Ae; exports.j = ke; exports.k = P; exports.l = M; exports.m = W;
2
- //# sourceMappingURL=chunk-HOWV4A5D.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\chunk-HOWV4A5D.cjs"],"names":[],"mappings":"AAAA,2/BAA+H,IAAK,EAAE,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,MAAM,CAAC,GAAG,kBAAE,UAAU,qBAAC,OAAO,6BAAE,QAAQ,6BAAE,MAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAO,CAAC,6BAAE,WAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,iCAAC,CAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,8GAA8G,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,WAAW,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,uCAAuC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,WAAW,mBAAC,CAAC,CAAC,CAAC,IAAI,GAAG,mBAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,iCAAC,CAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,iCAAC,CAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,kBAAC,iCAAC,CAAE,CAAC,WAAW,CAAC,SAAE,aAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAA","file":"D:\\Coding\\selva-compute\\dist\\chunk-HOWV4A5D.cjs","sourcesContent":[null]}