@tscircuit/runframe 0.0.169 → 0.0.171

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.
@@ -12842,7 +12842,7 @@ ${l.join(`
12842
12842
  `)!==-1&&(r=r.replace(/\r\n/g,`
12843
12843
  `)),r.indexOf(`\\
12844
12844
  `)!==-1&&(r=r.replace(/\\\n/g,""));const t=r.split(`
12845
- `);let n="",i="",a=0,o=[];const s=typeof"".trimLeft=="function";for(let u=0,d=t.length;u<d;u++)if(n=t[u],n=s?n.trimLeft():n.trim(),a=n.length,a!==0&&(i=n.charAt(0),i!=="#"))if(i==="v"){const g=n.split(/\s+/);switch(g[0]){case"v":e.vertices.push(parseFloat(g[1]),parseFloat(g[2]),parseFloat(g[3])),g.length>=7?e.colors.push(parseFloat(g[4]),parseFloat(g[5]),parseFloat(g[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(g[1]),parseFloat(g[2]),parseFloat(g[3]));break;case"vt":e.uvs.push(parseFloat(g[1]),parseFloat(g[2]));break}}else if(i==="f"){const _=n.substr(1).trim().split(/\s+/),x=[];for(let M=0,R=_.length;M<R;M++){const L=_[M];if(L.length>0){const z=L.split("/");x.push(z)}}const T=x[0];for(let M=1,R=x.length-1;M<R;M++){const L=x[M],z=x[M+1];e.addFace(T[0],L[0],z[0],T[1],L[1],z[1],T[2],L[2],z[2])}}else if(i==="l"){const g=n.substring(1).trim().split(" ");let _=[];const x=[];if(n.indexOf("/")===-1)_=g;else for(let T=0,M=g.length;T<M;T++){const R=g[T].split("/");R[0]!==""&&_.push(R[0]),R[1]!==""&&x.push(R[1])}e.addLineGeometry(_,x)}else if(i==="p"){const _=n.substr(1).trim().split(" ");e.addPointGeometry(_)}else if((o=$5t.exec(n))!==null){const g=(" "+o[0].substr(1).trim()).substr(1);e.startObject(g)}else if(Q5t.test(n))e.object.startMaterial(n.substring(7).trim(),e.materialLibraries);else if(Z5t.test(n))e.materialLibraries.push(n.substring(7).trim());else if(K5t.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(i==="s"){if(o=n.split(" "),o.length>1){const _=o[1].trim().toLowerCase();e.object.smooth=_!=="0"&&_!=="off"}else e.object.smooth=!0;const g=e.object.currentMaterial();g&&(g.smooth=e.object.smooth)}else{if(n==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"')}e.finalize();const l=new kE;if(l.materialLibraries=[].concat(e.materialLibraries),!(e.objects.length===1&&e.objects[0].geometry.vertices.length===0)===!0)for(let u=0,d=e.objects.length;u<d;u++){const g=e.objects[u],_=g.geometry,x=g.materials,T=_.type==="Line",M=_.type==="Points";let R=!1;if(_.vertices.length===0)continue;const L=new k0;L.setAttribute("position",new bc(_.vertices,3)),_.normals.length>0&&L.setAttribute("normal",new bc(_.normals,3)),_.colors.length>0&&(R=!0,L.setAttribute("color",new bc(_.colors,3))),_.hasUVIndices===!0&&L.setAttribute("uv",new bc(_.uvs,2));const z=[];for(let Z=0,ee=x.length;Z<ee;Z++){const W=x[Z],se=W.name+"_"+W.smooth+"_"+R;let ae=e.materials[se];if(this.materials!==null){if(ae=this.materials.create(W.name),T&&ae&&!(ae instanceof Hx)){const ue=new Hx;s5.prototype.copy.call(ue,ae),ue.color.copy(ae.color),ae=ue}else if(M&&ae&&!(ae instanceof jE)){const ue=new jE({size:10,sizeAttenuation:!1});s5.prototype.copy.call(ue,ae),ue.color.copy(ae.color),ue.map=ae.map,ae=ue}}ae===void 0&&(T?ae=new Hx:M?ae=new jE({size:1,sizeAttenuation:!1}):ae=new cN,ae.name=W.name,ae.flatShading=!W.smooth,ae.vertexColors=R,e.materials[se]=ae),z.push(ae)}let j;if(z.length>1){for(let Z=0,ee=x.length;Z<ee;Z++){const W=x[Z];L.addGroup(W.groupStart,W.groupCount,Z)}T?j=new H3(L,z):M?j=new RM(L,z):j=new Kg(L,z)}else T?j=new H3(L,z[0]):M?j=new RM(L,z[0]):j=new Kg(L,z[0]);j.name=g.name,l.add(j)}else if(e.vertices.length>0){const u=new jE({size:1,sizeAttenuation:!1}),d=new k0;d.setAttribute("position",new bc(e.vertices,3)),e.colors.length>0&&e.colors[0]!==void 0&&(d.setAttribute("color",new bc(e.colors,3)),u.vertexColors=!0);const g=new RM(d,u);l.add(g)}return l}};function t2t({stlUrl:r,mtlUrl:e,color:t,opacity:n=1}){const i=b$(Y5t,r),a=Ct.useRef();return _t.jsxs("mesh",{ref:a,children:[_t.jsx("primitive",{object:i,attach:"geometry"}),_t.jsx("meshStandardMaterial",{color:t,transparent:n!==1,opacity:n})]})}var n2t={name:"@tscircuit/3d-viewer",version:"0.0.134",main:"./dist/index.js",module:"./dist/index.js",type:"module",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"}},files:["dist"],scripts:{start:"bun run storybook","dev:old":"bunx --bun vite",build:"tsup ./src/index.tsx --platform neutral --format esm --dts",prepublish:"npm run build",preview:"vite preview",storybook:"storybook dev -p 6006","build-storybook":"storybook build","vercel-build":"bun run build-storybook",format:"biome format . --write","format:check":"biome format .","test:node-bundle":"node ./scripts/load-bundle-in-node.js"},dependencies:{"@jscad/regl-renderer":"^2.6.12","@jscad/stl-serializer":"^2.1.20","@react-three/drei":"^9.121.4","@react-three/fiber":"^8.17.14","@tscircuit/core":"^0.0.313","@tscircuit/props":"^0.0.147","@tscircuit/react-fiber":"^1.2.0","@tscircuit/soup-util":"^0.0.41","jscad-electronics":"^0.0.23","jscad-fiber":"^0.0.77","jscad-planner":"^0.0.12",react:"^18.3.1","react-dom":"^18.3.1","react-use-gesture":"^9.1.3"},peerDependencies:{three:"*"},devDependencies:{"@biomejs/biome":"^1.9.4","@chromatic-com/storybook":"^1.9.0","@jscad/modeling":"^2.12.5","@storybook/addon-essentials":"^8.5.2","@storybook/addon-interactions":"^8.5.2","@storybook/addon-links":"^8.5.2","@storybook/addon-onboarding":"^8.5.2","@storybook/blocks":"^8.5.2","@storybook/builder-vite":"^8.5.2","@storybook/react":"^8.5.2","@storybook/react-vite":"^8.5.2","@storybook/test":"^8.5.2","@types/jsdom":"^21.1.7","@types/react":"^18.3.18","@types/react-dom":"^18.3.5","@types/three":"^0.165.0","@vitejs/plugin-react":"^4.3.4","bun-match-svg":"^0.0.9","bun-types":"^1.2.1","circuit-json":"^0.0.116","circuit-to-svg":"^0.0.91",debug:"^4.4.0",jsdom:"^26.0.0",semver:"^7.7.0",storybook:"^8.5.2","strip-ansi":"^7.1.0",tsup:"^8.3.6",typescript:"^5.7.3",vite:"^5.4.14","vite-tsconfig-paths":"^4.3.2"}};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new e3(0,0,0));function r2t(r,e){const t=new E5().setFromEuler(new e3(r.x,r.y,r.z)),n=new Fn(0,0,1);return n.applyQuaternion(t),n.multiplyScalar(e)}var i2t=({})=>{const r=Ct.useRef();return Ct.useRef({lastRotation:new e3}),WM((e,t)=>{if(!r.current)return;const n=window.TSCI_MAIN_CAMERA_ROTATION,i=r2t(n,2);e.camera.position.copy(i),e.camera.lookAt(0,0,0)}),_t.jsxs("mesh",{ref:r,rotation:[Math.PI/2,0,0],children:[_t.jsx("boxGeometry",{args:[1,1,1]}),_t.jsx("meshStandardMaterial",{color:"white"}),_t.jsx(i8,{position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),_t.jsx(i8,{position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),_t.jsx(i8,{position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),_t.jsx(i8,{position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),_t.jsx(i8,{position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),_t.jsx(i8,{position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"}),_t.jsx("lineSegments",{args:[new kW(new AS(1,1,1))],material:new Hx({color:0,linewidth:2})})]})},a2t=()=>(WM(({camera:r})=>{window.TSCI_MAIN_CAMERA_ROTATION=r.rotation}),_t.jsx(_t.Fragment,{})),o2t=Ct.forwardRef(({children:r,hoveredComponent:e,initialCameraPosition:t=[5,5,5],autoRotateDisabled:n},i)=>_t.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[_t.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:_t.jsxs(Qxe,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:[_t.jsx("ambientLight",{intensity:Math.PI/2}),_t.jsx(i2t,{})]})}),_t.jsxs(Qxe,{scene:{up:[0,0,1]},camera:{up:[0,0,1],position:t},children:[_t.jsx(a2t,{}),_t.jsx(xct,{autoRotate:!n,autoRotateSpeed:1}),_t.jsx("ambientLight",{intensity:Math.PI/2}),_t.jsx("pointLight",{position:[-10,-10,10],decay:0,intensity:Math.PI/4}),_t.jsx(Sct,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:1,sectionSize:10}),_t.jsx("object3D",{ref:i,children:r}),e&&_t.jsx(vlt,{position:e.mousePosition,style:{fontFamily:"sans-serif",transform:"translate3d(50%, 50%, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:e.name})]}),_t.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",n2t.version]})]})),s2t=r=>_t.jsx("group",{...r}),l2t=({children:r,isHovered:e,onHover:t,position:n})=>{const i=Ct.useRef(null),a=Ct.useCallback(s=>{s.stopPropagation();try{const l=s.point||(s.intersections&&s.intersections.length>0?s.intersections[0].point:null)||(n?new Fn(...n):null);l?(i.current=l,t({mousePosition:[l.x,l.y,l.z]})):t({})}catch(l){console.warn("Hover event error:",l),t({})}},[n]),o=Ct.useCallback(s=>{s.stopPropagation(),i.current=null,t(null)},[t]);return _t.jsx(s2t,{onPointerEnter:a,onPointerMove:a,onPointerLeave:o,children:r})},YL=l2t;typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function c2t(r){const[e,t]=Ct.useState(null);return Ct.useEffect(()=>{if(!r)return;const n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let i=!1;async function a(){var s;try{const c=await(await fetch(r)).text(),u=(s=c.match(/newmtl[\s\S]*?endmtl/g))==null?void 0:s.join(`
12845
+ `);let n="",i="",a=0,o=[];const s=typeof"".trimLeft=="function";for(let u=0,d=t.length;u<d;u++)if(n=t[u],n=s?n.trimLeft():n.trim(),a=n.length,a!==0&&(i=n.charAt(0),i!=="#"))if(i==="v"){const g=n.split(/\s+/);switch(g[0]){case"v":e.vertices.push(parseFloat(g[1]),parseFloat(g[2]),parseFloat(g[3])),g.length>=7?e.colors.push(parseFloat(g[4]),parseFloat(g[5]),parseFloat(g[6])):e.colors.push(void 0,void 0,void 0);break;case"vn":e.normals.push(parseFloat(g[1]),parseFloat(g[2]),parseFloat(g[3]));break;case"vt":e.uvs.push(parseFloat(g[1]),parseFloat(g[2]));break}}else if(i==="f"){const _=n.substr(1).trim().split(/\s+/),x=[];for(let M=0,R=_.length;M<R;M++){const L=_[M];if(L.length>0){const z=L.split("/");x.push(z)}}const T=x[0];for(let M=1,R=x.length-1;M<R;M++){const L=x[M],z=x[M+1];e.addFace(T[0],L[0],z[0],T[1],L[1],z[1],T[2],L[2],z[2])}}else if(i==="l"){const g=n.substring(1).trim().split(" ");let _=[];const x=[];if(n.indexOf("/")===-1)_=g;else for(let T=0,M=g.length;T<M;T++){const R=g[T].split("/");R[0]!==""&&_.push(R[0]),R[1]!==""&&x.push(R[1])}e.addLineGeometry(_,x)}else if(i==="p"){const _=n.substr(1).trim().split(" ");e.addPointGeometry(_)}else if((o=$5t.exec(n))!==null){const g=(" "+o[0].substr(1).trim()).substr(1);e.startObject(g)}else if(Q5t.test(n))e.object.startMaterial(n.substring(7).trim(),e.materialLibraries);else if(Z5t.test(n))e.materialLibraries.push(n.substring(7).trim());else if(K5t.test(n))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(i==="s"){if(o=n.split(" "),o.length>1){const _=o[1].trim().toLowerCase();e.object.smooth=_!=="0"&&_!=="off"}else e.object.smooth=!0;const g=e.object.currentMaterial();g&&(g.smooth=e.object.smooth)}else{if(n==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+n+'"')}e.finalize();const l=new kE;if(l.materialLibraries=[].concat(e.materialLibraries),!(e.objects.length===1&&e.objects[0].geometry.vertices.length===0)===!0)for(let u=0,d=e.objects.length;u<d;u++){const g=e.objects[u],_=g.geometry,x=g.materials,T=_.type==="Line",M=_.type==="Points";let R=!1;if(_.vertices.length===0)continue;const L=new k0;L.setAttribute("position",new bc(_.vertices,3)),_.normals.length>0&&L.setAttribute("normal",new bc(_.normals,3)),_.colors.length>0&&(R=!0,L.setAttribute("color",new bc(_.colors,3))),_.hasUVIndices===!0&&L.setAttribute("uv",new bc(_.uvs,2));const z=[];for(let Z=0,ee=x.length;Z<ee;Z++){const W=x[Z],se=W.name+"_"+W.smooth+"_"+R;let ae=e.materials[se];if(this.materials!==null){if(ae=this.materials.create(W.name),T&&ae&&!(ae instanceof Hx)){const ue=new Hx;s5.prototype.copy.call(ue,ae),ue.color.copy(ae.color),ae=ue}else if(M&&ae&&!(ae instanceof jE)){const ue=new jE({size:10,sizeAttenuation:!1});s5.prototype.copy.call(ue,ae),ue.color.copy(ae.color),ue.map=ae.map,ae=ue}}ae===void 0&&(T?ae=new Hx:M?ae=new jE({size:1,sizeAttenuation:!1}):ae=new cN,ae.name=W.name,ae.flatShading=!W.smooth,ae.vertexColors=R,e.materials[se]=ae),z.push(ae)}let j;if(z.length>1){for(let Z=0,ee=x.length;Z<ee;Z++){const W=x[Z];L.addGroup(W.groupStart,W.groupCount,Z)}T?j=new H3(L,z):M?j=new RM(L,z):j=new Kg(L,z)}else T?j=new H3(L,z[0]):M?j=new RM(L,z[0]):j=new Kg(L,z[0]);j.name=g.name,l.add(j)}else if(e.vertices.length>0){const u=new jE({size:1,sizeAttenuation:!1}),d=new k0;d.setAttribute("position",new bc(e.vertices,3)),e.colors.length>0&&e.colors[0]!==void 0&&(d.setAttribute("color",new bc(e.colors,3)),u.vertexColors=!0);const g=new RM(d,u);l.add(g)}return l}};function t2t({stlUrl:r,mtlUrl:e,color:t,opacity:n=1}){const i=b$(Y5t,r),a=Ct.useRef();return _t.jsxs("mesh",{ref:a,children:[_t.jsx("primitive",{object:i,attach:"geometry"}),_t.jsx("meshStandardMaterial",{color:t,transparent:n!==1,opacity:n})]})}var n2t={name:"@tscircuit/3d-viewer",version:"0.0.135",main:"./dist/index.js",module:"./dist/index.js",type:"module",exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"}},files:["dist"],scripts:{start:"bun run storybook","dev:old":"bunx --bun vite",build:"tsup ./src/index.tsx --platform neutral --format esm --dts",prepublish:"npm run build",preview:"vite preview",storybook:"storybook dev -p 6006","build-storybook":"storybook build","vercel-build":"bun run build-storybook",format:"biome format . --write","format:check":"biome format .","test:node-bundle":"node ./scripts/load-bundle-in-node.js"},dependencies:{"@jscad/regl-renderer":"^2.6.12","@jscad/stl-serializer":"^2.1.20","@react-three/drei":"^9.121.4","@react-three/fiber":"^8.17.14","@tscircuit/core":"^0.0.314","@tscircuit/props":"^0.0.147","@tscircuit/react-fiber":"^1.2.0","@tscircuit/soup-util":"^0.0.41","jscad-electronics":"^0.0.23","jscad-fiber":"^0.0.77","jscad-planner":"^0.0.12",react:"^18.3.1","react-dom":"^18.3.1","react-use-gesture":"^9.1.3"},peerDependencies:{three:"*"},devDependencies:{"@biomejs/biome":"^1.9.4","@chromatic-com/storybook":"^1.9.0","@jscad/modeling":"^2.12.5","@storybook/addon-essentials":"^8.5.2","@storybook/addon-interactions":"^8.5.2","@storybook/addon-links":"^8.5.2","@storybook/addon-onboarding":"^8.5.2","@storybook/blocks":"^8.5.2","@storybook/builder-vite":"^8.5.2","@storybook/react":"^8.5.2","@storybook/react-vite":"^8.5.2","@storybook/test":"^8.5.2","@types/jsdom":"^21.1.7","@types/react":"^18.3.18","@types/react-dom":"^18.3.5","@types/three":"^0.165.0","@vitejs/plugin-react":"^4.3.4","bun-match-svg":"^0.0.9","bun-types":"^1.2.1","circuit-json":"^0.0.116","circuit-to-svg":"^0.0.91",debug:"^4.4.0",jsdom:"^26.0.0",semver:"^7.7.0",storybook:"^8.5.2","strip-ansi":"^7.1.0",tsup:"^8.3.6",typescript:"^5.7.3",vite:"^5.4.14","vite-tsconfig-paths":"^4.3.2"}};typeof window<"u"&&(window.TSCI_MAIN_CAMERA_ROTATION=new e3(0,0,0));function r2t(r,e){const t=new E5().setFromEuler(new e3(r.x,r.y,r.z)),n=new Fn(0,0,1);return n.applyQuaternion(t),n.multiplyScalar(e)}var i2t=({})=>{const r=Ct.useRef();return Ct.useRef({lastRotation:new e3}),WM((e,t)=>{if(!r.current)return;const n=window.TSCI_MAIN_CAMERA_ROTATION,i=r2t(n,2);e.camera.position.copy(i),e.camera.lookAt(0,0,0)}),_t.jsxs("mesh",{ref:r,rotation:[Math.PI/2,0,0],children:[_t.jsx("boxGeometry",{args:[1,1,1]}),_t.jsx("meshStandardMaterial",{color:"white"}),_t.jsx(i8,{position:[0,0,.51],fontSize:.25,color:"black",children:"Front"}),_t.jsx(i8,{position:[0,0,-.51],fontSize:.25,color:"black",rotation:[0,Math.PI,0],children:"Back"}),_t.jsx(i8,{position:[.51,0,0],fontSize:.25,color:"black",rotation:[0,Math.PI/2,0],children:"Right"}),_t.jsx(i8,{position:[-.51,0,0],fontSize:.25,color:"black",rotation:[0,-Math.PI/2,0],children:"Left"}),_t.jsx(i8,{position:[0,.51,0],fontSize:.25,color:"black",rotation:[-Math.PI/2,0,0],children:"Top"}),_t.jsx(i8,{position:[0,-.51,0],fontSize:.25,color:"black",rotation:[Math.PI/2,0,0],children:"Bottom"}),_t.jsx("lineSegments",{args:[new kW(new AS(1,1,1))],material:new Hx({color:0,linewidth:2})})]})},a2t=()=>(WM(({camera:r})=>{window.TSCI_MAIN_CAMERA_ROTATION=r.rotation}),_t.jsx(_t.Fragment,{})),o2t=Ct.forwardRef(({children:r,hoveredComponent:e,initialCameraPosition:t=[5,5,5],autoRotateDisabled:n},i)=>_t.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[_t.jsx("div",{style:{position:"absolute",top:0,left:0,width:120,height:120},children:_t.jsxs(Qxe,{camera:{up:[0,0,1],position:[1,1,1]},style:{zIndex:10},children:[_t.jsx("ambientLight",{intensity:Math.PI/2}),_t.jsx(i2t,{})]})}),_t.jsxs(Qxe,{scene:{up:[0,0,1]},camera:{up:[0,0,1],position:t},children:[_t.jsx(a2t,{}),_t.jsx(xct,{autoRotate:!n,autoRotateSpeed:1}),_t.jsx("ambientLight",{intensity:Math.PI/2}),_t.jsx("pointLight",{position:[-10,-10,10],decay:0,intensity:Math.PI/4}),_t.jsx(Sct,{rotation:[Math.PI/2,0,0],infiniteGrid:!0,cellSize:1,sectionSize:10}),_t.jsx("object3D",{ref:i,children:r}),e&&_t.jsx(vlt,{position:e.mousePosition,style:{fontFamily:"sans-serif",transform:"translate3d(50%, 50%, 0)",backgroundColor:"white",padding:"5px",borderRadius:"3px",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},children:e.name})]}),_t.jsxs("div",{style:{position:"absolute",right:24,bottom:24,fontFamily:"sans-serif",color:"white",WebkitTextStroke:"0.5px rgba(0, 0, 0, 0.5)",fontSize:11},children:["@",n2t.version]})]})),s2t=r=>_t.jsx("group",{...r}),l2t=({children:r,isHovered:e,onHover:t,position:n})=>{const i=Ct.useRef(null),a=Ct.useCallback(s=>{s.stopPropagation();try{const l=s.point||(s.intersections&&s.intersections.length>0?s.intersections[0].point:null)||(n?new Fn(...n):null);l?(i.current=l,t({mousePosition:[l.x,l.y,l.z]})):t({})}catch(l){console.warn("Hover event error:",l),t({})}},[n]),o=Ct.useCallback(s=>{s.stopPropagation(),i.current=null,t(null)},[t]);return _t.jsx(s2t,{onPointerEnter:a,onPointerMove:a,onPointerLeave:o,children:r})},YL=l2t;typeof window<"u"&&!window.TSCIRCUIT_OBJ_LOADER_CACHE&&(window.TSCIRCUIT_OBJ_LOADER_CACHE=new Map);function c2t(r){const[e,t]=Ct.useState(null);return Ct.useEffect(()=>{if(!r)return;const n=window.TSCIRCUIT_OBJ_LOADER_CACHE;let i=!1;async function a(){var s;try{const c=await(await fetch(r)).text(),u=(s=c.match(/newmtl[\s\S]*?endmtl/g))==null?void 0:s.join(`
12846
12846
  `).replace(/d 0\./g,"d 1."),d=c.replace(/newmtl[\s\S]*?endmtl/g,""),g=new X5t;g.setMaterialOptions({invertTrProperty:!0});const _=g.parse(u.replace(/Kd\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/g,"Kd $2 $2 $2"),"test.mtl"),x=new e2t;return x.setMaterials(_),x.parse(d)}catch(l){return l}}function o(){if(n.has(r)){const l=n.get(r);return l.result?Promise.resolve(l.result.clone()):l.promise.then(c=>c.clone())}const s=a().then(l=>(l instanceof Error||n.set(r,{...n.get(r),result:l}),l));return n.set(r,{promise:s,result:null}),s}return o().then(s=>{i||t(s)}).catch(s=>{console.error(s)}),()=>{i=!0}},[r]),e}function u2t({url:r,position:e,rotation:t,onHover:n,isHovered:i}){const a=c2t(r);return a?a instanceof Error?_t.jsx(YL,{isHovered:i,onHover:n,children:_t.jsxs("mesh",{position:e,children:[_t.jsx("boxGeometry",{args:[.5,.5,.5]}),_t.jsx("meshStandardMaterial",{transparent:!0,color:"red",opacity:.5}),_t.jsx("meshBasicMaterial",{color:"red"})]})}):_t.jsx(YL,{isHovered:i,onHover:n,children:_t.jsx("primitive",{rotation:t,position:e,object:a})}):_t.jsx(YL,{isHovered:i,onHover:n,children:_t.jsxs("mesh",{position:e,children:[_t.jsx("boxGeometry",{args:[.5,.5,.5]}),_t.jsx("meshStandardMaterial",{transparent:!0,color:"red",opacity:.25})]})})}var f2t=l2(h6e()),S6e=({jscadPlan:r,positionOffset:e,rotationOffset:t,onHover:n,isHovered:i})=>{const{threeGeom:a,material:o}=Ct.useMemo(()=>{const s=F5e.executeJscadOperations(f2t.default,r),l=xut(s),c=new lN({vertexColors:!0,side:_3});return{threeGeom:l,material:c}},[r]);return Ct.useMemo(()=>{if(i){const s=new yl(o.color.getHex());o.emissive.copy(s),o.emissive.setRGB(0,0,1),o.emissiveIntensity=.2}else o.emissiveIntensity=0},[i,o]),a?_t.jsx(YL,{isHovered:i,onHover:n,position:e,children:_t.jsx("mesh",{geometry:a,material:o,position:e,rotation:t})}):null},{createJSCADRoot:d2t}=gut(F5e.jscadPlanner),h2t=({positionOffset:r,footprint:e,rotationOffset:t,onHover:n,isHovered:i})=>{const a=Ct.useMemo(()=>{if(!e)return null;const o=[];return d2t(o).render(_t.jsx(jyt,{footprint:e})),o},[e]);return a?_t.jsx(_t.Fragment,{children:a.map((o,s)=>_t.jsx(S6e,{positionOffset:r,rotationOffset:t,jscadPlan:o,onHover:n,isHovered:i},s))}):null},p2t=(...r)=>r,m2t=({cad_component:r,onHover:e=()=>{},isHovered:t=!1})=>{const n=r.model_obj_url??r.model_stl_url,i=r.rotation?p2t(r.rotation.x*Math.PI/180,r.rotation.y*Math.PI/180,r.rotation.z*Math.PI/180):void 0;if(n)return _t.jsx(u2t,{url:n,position:r.position?[r.position.x,r.position.y,r.position.z]:void 0,rotation:i,onHover:e,isHovered:t},r.cad_component_id);if(r.model_jscad)return _t.jsx(S6e,{jscadPlan:r.model_jscad,rotationOffset:i,onHover:e,isHovered:t},r.cad_component_id);if(r.footprinter_string)return _t.jsx(h2t,{positionOffset:r.position?[r.position.x,r.position.y,r.position.z]:void 0,rotationOffset:i,footprint:r.footprinter_string,onHover:e,isHovered:t})},v2t=class extends L0.Component{constructor(r){super(r),this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}render(){return this.state.hasError&&this.state.error?this.props.fallback({error:this.state.error}):this.props.children}},y2t=({error:r,cad_component:e})=>{let t=[0,0,0];return e!=null&&e.position&&(t=[e.position.x,e.position.y,e.position.z],t=t.map(n=>Number.isNaN(n)?0:n)),_t.jsxs("group",{position:t,children:[_t.jsxs("mesh",{renderOrder:-99999,rotation:[Math.PI/4,Math.PI/4,0],ref:n=>{n&&(n.renderOrder=999999)},children:[_t.jsx("boxGeometry",{args:[.5,.5,.5]}),_t.jsx("meshStandardMaterial",{depthTest:!1,transparent:!0,color:"red",opacity:.5})]}),_t.jsxs(i8,{scale:[.1,.1,.1],color:"red",anchorX:"center",anchorY:"middle",depthOffset:-99999,children:[r.toString().slice(0,50),"..."]})]})},g2t=Ct.forwardRef(({soup:r,circuitJson:e,children:t,autoRotateDisabled:n},i)=>{e??(e=r);const[a,o]=Ct.useState(null);e??(e=O5t(t));const s=Ct.useMemo(()=>{if(!e)return[5,5,5];try{const g=$y(e).pcb_board.list()[0];if(!g)return[5,5,5];const{width:_,height:x}=g,T=Math.max(_,x);return[T/2,T/2,T]}catch(g){return console.error(g),[5,5,5]}},[e]),l=Ct.useMemo(()=>!e||!e.some(g=>g.type==="pcb_board")?null:V5t(e),[e]),{stls:c,loading:u}=G5t(l);if(!e)return null;const d=$y(e).cad_component.list();return _t.jsxs(o2t,{ref:i,hoveredComponent:a,autoRotateDisabled:n,initialCameraPosition:s,children:[c.map(({stlUrl:g,color:_},x)=>_t.jsx(t2t,{stlUrl:g,color:_,opacity:x===0?.95:1},g)),d.map(g=>_t.jsx(v2t,{fallback:({error:_})=>_t.jsx(y2t,{cad_component:g,error:_}),children:_t.jsx(m2t,{onHover:_=>{var T;if(_||o(null),!_.mousePosition)return;const x=(T=$y(e).source_component.getUsing({source_component_id:g.source_component_id}))==null?void 0:T.name;o({cad_component_id:g.cad_component_id,name:x??"<unknown>",mousePosition:_.mousePosition})},cad_component:g,isHovered:(a==null?void 0:a.cad_component_id)===g.cad_component_id},g.cad_component_id)},g.cad_component_id))]})}),_2t=l2(L5t());l2(h6e()),(0,_2t.default)("tscircuit:3d-viewer:convert-circuit-json-to-3d-svg");const V7=r=>typeof r=="number"&&!isNaN(r),x8=r=>typeof r=="string",C3=r=>typeof r=="function",XL=r=>x8(r)||C3(r)?r:null,WK=r=>Ct.isValidElement(r)||x8(r)||C3(r)||V7(r);function x2t(r,e,t){t===void 0&&(t=300);const{scrollHeight:n,style:i}=r;requestAnimationFrame(()=>{i.minHeight="initial",i.height=n+"px",i.transition=`all ${t}ms`,requestAnimationFrame(()=>{i.height="0",i.padding="0",i.margin="0",setTimeout(e,t)})})}function WL(r){let{enter:e,exit:t,appendPosition:n=!1,collapse:i=!0,collapseDuration:a=300}=r;return function(o){let{children:s,position:l,preventExitTransition:c,done:u,nodeRef:d,isIn:g,playToast:_}=o;const x=n?`${e}--${l}`:e,T=n?`${t}--${l}`:t,M=Ct.useRef(0);return Ct.useLayoutEffect(()=>{const R=d.current,L=x.split(" "),z=j=>{j.target===d.current&&(_(),R.removeEventListener("animationend",z),R.removeEventListener("animationcancel",z),M.current===0&&j.type!=="animationcancel"&&R.classList.remove(...L))};R.classList.add(...L),R.addEventListener("animationend",z),R.addEventListener("animationcancel",z)},[]),Ct.useEffect(()=>{const R=d.current,L=()=>{R.removeEventListener("animationend",L),i?x2t(R,u,a):u()};g||(c?L():(M.current=1,R.className+=` ${T}`,R.addEventListener("animationend",L)))},[g]),L0.createElement(L0.Fragment,null,s)}}function E6e(r,e){return r!=null?{content:r.content,containerId:r.props.containerId,id:r.props.toastId,theme:r.props.theme,type:r.props.type,data:r.props.data||{},isLoading:r.props.isLoading,icon:r.props.icon,status:e}:{}}const L2=new Map;let j7=[];const $K=new Set,b2t=r=>$K.forEach(e=>e(r)),w6e=()=>L2.size>0;function T6e(r,e){var t;if(e)return!((t=L2.get(e))==null||!t.isToastActive(r));let n=!1;return L2.forEach(i=>{i.isToastActive(r)&&(n=!0)}),n}function M6e(r,e){WK(r)&&(w6e()||j7.push({content:r,options:e}),L2.forEach(t=>{t.buildToast(r,e)}))}function C6e(r,e){L2.forEach(t=>{e!=null&&e!=null&&e.containerId?(e==null?void 0:e.containerId)===t.id&&t.toggle(r,e==null?void 0:e.id):t.toggle(r,e==null?void 0:e.id)})}function S2t(r){const{subscribe:e,getSnapshot:t,setProps:n}=Ct.useRef(function(a){const o=a.containerId||1;return{subscribe(s){const l=function(u,d,g){let _=1,x=0,T=[],M=[],R=[],L=d;const z=new Map,j=new Set,Z=()=>{R=Array.from(z.values()),j.forEach(se=>se())},ee=se=>{M=se==null?[]:M.filter(ae=>ae!==se),Z()},W=se=>{const{toastId:ae,onOpen:ue,updateId:me,children:_e}=se.props,Se=me==null;se.staleId&&z.delete(se.staleId),z.set(ae,se),M=[...M,se.props.toastId].filter(Ae=>Ae!==se.staleId),Z(),g(E6e(se,Se?"added":"updated")),Se&&C3(ue)&&ue(Ct.isValidElement(_e)&&_e.props)};return{id:u,props:L,observe:se=>(j.add(se),()=>j.delete(se)),toggle:(se,ae)=>{z.forEach(ue=>{ae!=null&&ae!==ue.props.toastId||C3(ue.toggle)&&ue.toggle(se)})},removeToast:ee,toasts:z,clearQueue:()=>{x-=T.length,T=[]},buildToast:(se,ae)=>{if((Ie=>{let{containerId:at,toastId:ct,updateId:dt}=Ie;const zt=at?at!==u:u!==1,Pt=z.has(ct)&&dt==null;return zt||Pt})(ae))return;const{toastId:ue,updateId:me,data:_e,staleId:Se,delay:Ae}=ae,ke=()=>{ee(ue)},De=me==null;De&&x++;const Oe={...L,style:L.toastStyle,key:_++,...Object.fromEntries(Object.entries(ae).filter(Ie=>{let[at,ct]=Ie;return ct!=null})),toastId:ue,updateId:me,data:_e,closeToast:ke,isIn:!1,className:XL(ae.className||L.toastClassName),bodyClassName:XL(ae.bodyClassName||L.bodyClassName),progressClassName:XL(ae.progressClassName||L.progressClassName),autoClose:!ae.isLoading&&(Ne=ae.autoClose,Ue=L.autoClose,Ne===!1||V7(Ne)&&Ne>0?Ne:Ue),deleteToast(){const Ie=z.get(ue),{onClose:at,children:ct}=Ie.props;C3(at)&&at(Ct.isValidElement(ct)&&ct.props),g(E6e(Ie,"removed")),z.delete(ue),x--,x<0&&(x=0),T.length>0?W(T.shift()):Z()}};var Ne,Ue;Oe.closeButton=L.closeButton,ae.closeButton===!1||WK(ae.closeButton)?Oe.closeButton=ae.closeButton:ae.closeButton===!0&&(Oe.closeButton=!WK(L.closeButton)||L.closeButton);let je=se;Ct.isValidElement(se)&&!x8(se.type)?je=Ct.cloneElement(se,{closeToast:ke,toastProps:Oe,data:_e}):C3(se)&&(je=se({closeToast:ke,toastProps:Oe,data:_e}));const ze={content:je,props:Oe,staleId:Se};L.limit&&L.limit>0&&x>L.limit&&De?T.push(ze):V7(Ae)?setTimeout(()=>{W(ze)},Ae):W(ze)},setProps(se){L=se},setToggle:(se,ae)=>{z.get(se).toggle=ae},isToastActive:se=>M.some(ae=>ae===se),getSnapshot:()=>R}}(o,a,b2t);L2.set(o,l);const c=l.observe(s);return j7.forEach(u=>M6e(u.content,u.options)),j7=[],()=>{c(),L2.delete(o)}},setProps(s){var l;(l=L2.get(o))==null||l.setProps(s)},getSnapshot(){var s;return(s=L2.get(o))==null?void 0:s.getSnapshot()}}}(r)).current;n(r);const i=Ct.useSyncExternalStore(e,t,t);return{getToastToRender:function(a){if(!i)return[];const o=new Map;return r.newestOnTop&&i.reverse(),i.forEach(s=>{const{position:l}=s.props;o.has(l)||o.set(l,[]),o.get(l).push(s)}),Array.from(o,s=>a(s[0],s[1]))},isToastActive:T6e,count:i==null?void 0:i.length}}function E2t(r){const[e,t]=Ct.useState(!1),[n,i]=Ct.useState(!1),a=Ct.useRef(null),o=Ct.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:s,pauseOnHover:l,closeToast:c,onClick:u,closeOnClick:d}=r;var g,_;function x(){t(!0)}function T(){t(!1)}function M(z){const j=a.current;o.canDrag&&j&&(o.didMove=!0,e&&T(),o.delta=r.draggableDirection==="x"?z.clientX-o.start:z.clientY-o.start,o.start!==z.clientX&&(o.canCloseOnClick=!1),j.style.transform=`translate3d(${r.draggableDirection==="x"?`${o.delta}px, var(--y)`:`0, calc(${o.delta}px + var(--y))`},0)`,j.style.opacity=""+(1-Math.abs(o.delta/o.removalDistance)))}function R(){document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",R);const z=a.current;if(o.canDrag&&o.didMove&&z){if(o.canDrag=!1,Math.abs(o.delta)>o.removalDistance)return i(!0),r.closeToast(),void r.collapseAll();z.style.transition="transform 0.2s, opacity 0.2s",z.style.removeProperty("transform"),z.style.removeProperty("opacity")}}(_=L2.get((g={id:r.toastId,containerId:r.containerId,fn:t}).containerId||1))==null||_.setToggle(g.id,g.fn),Ct.useEffect(()=>{if(r.pauseOnFocusLoss)return document.hasFocus()||T(),window.addEventListener("focus",x),window.addEventListener("blur",T),()=>{window.removeEventListener("focus",x),window.removeEventListener("blur",T)}},[r.pauseOnFocusLoss]);const L={onPointerDown:function(z){if(r.draggable===!0||r.draggable===z.pointerType){o.didMove=!1,document.addEventListener("pointermove",M),document.addEventListener("pointerup",R);const j=a.current;o.canCloseOnClick=!0,o.canDrag=!0,j.style.transition="none",r.draggableDirection==="x"?(o.start=z.clientX,o.removalDistance=j.offsetWidth*(r.draggablePercent/100)):(o.start=z.clientY,o.removalDistance=j.offsetHeight*(r.draggablePercent===80?1.5*r.draggablePercent:r.draggablePercent)/100)}},onPointerUp:function(z){const{top:j,bottom:Z,left:ee,right:W}=a.current.getBoundingClientRect();z.nativeEvent.type!=="touchend"&&r.pauseOnHover&&z.clientX>=ee&&z.clientX<=W&&z.clientY>=j&&z.clientY<=Z?T():x()}};return s&&l&&(L.onMouseEnter=T,r.stacked||(L.onMouseLeave=x)),d&&(L.onClick=z=>{u&&u(z),o.canCloseOnClick&&c()}),{playToast:x,pauseToast:T,isRunning:e,preventExitTransition:n,toastRef:a,eventHandlers:L}}function w2t(r){let{delay:e,isRunning:t,closeToast:n,type:i="default",hide:a,className:o,style:s,controlledProgress:l,progress:c,rtl:u,isIn:d,theme:g}=r;const _=a||l&&c===0,x={...s,animationDuration:`${e}ms`,animationPlayState:t?"running":"paused"};l&&(x.transform=`scaleX(${c})`);const T=Ob("Toastify__progress-bar",l?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${g}`,`Toastify__progress-bar--${i}`,{"Toastify__progress-bar--rtl":u}),M=C3(o)?o({rtl:u,type:i,defaultClassName:T}):Ob(T,o),R={[l&&c>=1?"onTransitionEnd":"onAnimationEnd"]:l&&c<1?null:()=>{d&&n()}};return L0.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":_},L0.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${g} Toastify__progress-bar--${i}`}),L0.createElement("div",{role:"progressbar","aria-hidden":_?"true":"false","aria-label":"notification timer",className:M,style:x,...R}))}let T2t=1;const R6e=()=>""+T2t++;function M2t(r){return r&&(x8(r.toastId)||V7(r.toastId))?r.toastId:R6e()}function G7(r,e){return M6e(r,e),e.toastId}function $L(r,e){return{...e,type:e&&e.type||r,toastId:M2t(e)}}function ZL(r){return(e,t)=>G7(e,$L(r,t))}function Py(r,e){return G7(r,$L("default",e))}Py.loading=(r,e)=>G7(r,$L("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...e})),Py.promise=function(r,e,t){let n,{pending:i,error:a,success:o}=e;i&&(n=x8(i)?Py.loading(i,t):Py.loading(i.render,{...t,...i}));const s={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},l=(u,d,g)=>{if(d==null)return void Py.dismiss(n);const _={type:u,...s,...t,data:g},x=x8(d)?{render:d}:d;return n?Py.update(n,{..._,...x}):Py(x.render,{..._,...x}),g},c=C3(r)?r():r;return c.then(u=>l("success",o,u)).catch(u=>l("error",a,u)),c},Py.success=ZL("success"),Py.info=ZL("info"),Py.error=ZL("error"),Py.warning=ZL("warning"),Py.warn=Py.warning,Py.dark=(r,e)=>G7(r,$L("default",{theme:"dark",...e})),Py.dismiss=function(r){(function(e){var t;if(w6e()){if(e==null||x8(t=e)||V7(t))L2.forEach(n=>{n.removeToast(e)});else if(e&&("containerId"in e||"id"in e)){const n=L2.get(e.containerId);n?n.removeToast(e.id):L2.forEach(i=>{i.removeToast(e.id)})}}else j7=j7.filter(n=>e!=null&&n.options.toastId!==e)})(r)},Py.clearWaitingQueue=function(r){r===void 0&&(r={}),L2.forEach(e=>{!e.props.limit||r.containerId&&e.id!==r.containerId||e.clearQueue()})},Py.isActive=T6e,Py.update=function(r,e){e===void 0&&(e={});const t=((n,i)=>{var a;let{containerId:o}=i;return(a=L2.get(o||1))==null?void 0:a.toasts.get(n)})(r,e);if(t){const{props:n,content:i}=t,a={delay:100,...n,...e,toastId:e.toastId||r,updateId:R6e()};a.toastId!==r&&(a.staleId=r);const o=a.render||i;delete a.render,G7(o,a)}},Py.done=r=>{Py.update(r,{progress:1})},Py.onChange=function(r){return $K.add(r),()=>{$K.delete(r)}},Py.play=r=>C6e(!0,r),Py.pause=r=>C6e(!1,r);const C2t=typeof window<"u"?Ct.useLayoutEffect:Ct.useEffect,QL=r=>{let{theme:e,type:t,isLoading:n,...i}=r;return L0.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:e==="colored"?"currentColor":`var(--toastify-icon-color-${t})`,...i})},ZK={info:function(r){return L0.createElement(QL,{...r},L0.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(r){return L0.createElement(QL,{...r},L0.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(r){return L0.createElement(QL,{...r},L0.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(r){return L0.createElement(QL,{...r},L0.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))},spinner:function(){return L0.createElement("div",{className:"Toastify__spinner"})}},R2t=r=>{const{isRunning:e,preventExitTransition:t,toastRef:n,eventHandlers:i,playToast:a}=E2t(r),{closeButton:o,children:s,autoClose:l,onClick:c,type:u,hideProgressBar:d,closeToast:g,transition:_,position:x,className:T,style:M,bodyClassName:R,bodyStyle:L,progressClassName:z,progressStyle:j,updateId:Z,role:ee,progress:W,rtl:se,toastId:ae,deleteToast:ue,isIn:me,isLoading:_e,closeOnClick:Se,theme:Ae}=r,ke=Ob("Toastify__toast",`Toastify__toast-theme--${Ae}`,`Toastify__toast--${u}`,{"Toastify__toast--rtl":se},{"Toastify__toast--close-on-click":Se}),De=C3(T)?T({rtl:se,position:x,type:u,defaultClassName:ke}):Ob(ke,T),Oe=function(ze){let{theme:Ie,type:at,isLoading:ct,icon:dt}=ze,zt=null;const Pt={theme:Ie,type:at};return dt===!1||(C3(dt)?zt=dt({...Pt,isLoading:ct}):Ct.isValidElement(dt)?zt=Ct.cloneElement(dt,Pt):ct?zt=ZK.spinner():(Qt=>Qt in ZK)(at)&&(zt=ZK[at](Pt))),zt}(r),Ne=!!W||!l,Ue={closeToast:g,type:u,theme:Ae};let je=null;return o===!1||(je=C3(o)?o(Ue):Ct.isValidElement(o)?Ct.cloneElement(o,Ue):function(ze){let{closeToast:Ie,theme:at,ariaLabel:ct="close"}=ze;return L0.createElement("button",{className:`Toastify__close-button Toastify__close-button--${at}`,type:"button",onClick:dt=>{dt.stopPropagation(),Ie(dt)},"aria-label":ct},L0.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},L0.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}(Ue)),L0.createElement(_,{isIn:me,done:ue,position:x,preventExitTransition:t,nodeRef:n,playToast:a},L0.createElement("div",{id:ae,onClick:c,"data-in":me,className:De,...i,style:M,ref:n},L0.createElement("div",{...me&&{role:ee},className:C3(R)?R({type:u}):Ob("Toastify__toast-body",R),style:L},Oe!=null&&L0.createElement("div",{className:Ob("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!_e})},Oe),L0.createElement("div",null,s)),je,L0.createElement(w2t,{...Z&&!Ne?{key:`pb-${Z}`}:{},rtl:se,theme:Ae,delay:l,isRunning:e,isIn:me,closeToast:g,hide:d,type:u,style:j,className:z,controlledProgress:Ne,progress:W||0})))},KL=function(r,e){return e===void 0&&(e=!1),{enter:`Toastify--animate Toastify__${r}-enter`,exit:`Toastify--animate Toastify__${r}-exit`,appendPosition:e}},A2t=WL(KL("bounce",!0));WL(KL("slide",!0)),WL(KL("zoom")),WL(KL("flip"));const P2t={position:"top-right",transition:A2t,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function D2t(r){let e={...P2t,...r};const t=r.stacked,[n,i]=Ct.useState(!0),a=Ct.useRef(null),{getToastToRender:o,isToastActive:s,count:l}=S2t(e),{className:c,style:u,rtl:d,containerId:g}=e;function _(T){const M=Ob("Toastify__toast-container",`Toastify__toast-container--${T}`,{"Toastify__toast-container--rtl":d});return C3(c)?c({position:T,rtl:d,defaultClassName:M}):Ob(M,XL(c))}function x(){t&&(i(!0),Py.play())}return C2t(()=>{if(t){var T;const M=a.current.querySelectorAll('[data-in="true"]'),R=12,L=(T=e.position)==null?void 0:T.includes("top");let z=0,j=0;Array.from(M).reverse().forEach((Z,ee)=>{const W=Z;W.classList.add("Toastify__toast--stacked"),ee>0&&(W.dataset.collapsed=`${n}`),W.dataset.pos||(W.dataset.pos=L?"top":"bot");const se=z*(n?.2:1)+(n?0:R*ee);W.style.setProperty("--y",`${L?se:-1*se}px`),W.style.setProperty("--g",`${R}`),W.style.setProperty("--s",""+(1-(n?j:0))),z+=W.offsetHeight,j+=.025})}},[n,l,t]),L0.createElement("div",{ref:a,className:"Toastify",id:g,onMouseEnter:()=>{t&&(i(!1),Py.pause())},onMouseLeave:x},o((T,M)=>{const R=M.length?{...u}:{...u,pointerEvents:"none"};return L0.createElement("div",{className:_(T),style:R,key:`container-${T}`},M.map(L=>{let{content:z,props:j}=L;return L0.createElement(R2t,{...j,stacked:t,collapseAll:x,isIn:s(j.toastId,j.containerId),style:j.style,key:`toast-${j.key}`},z)}))}))}function N2t(){var r=':root{--toastify-color-light:#fff;--toastify-color-dark:#121212;--toastify-color-info:#3498db;--toastify-color-success:#07bc0c;--toastify-color-warning:#f1c40f;--toastify-color-error:#e74c3c;--toastify-color-transparent:hsla(0,0%,100%,.7);--toastify-icon-color-info:var(--toastify-color-info);--toastify-icon-color-success:var(--toastify-color-success);--toastify-icon-color-warning:var(--toastify-color-warning);--toastify-icon-color-error:var(--toastify-color-error);--toastify-toast-width:320px;--toastify-toast-offset:16px;--toastify-toast-top:max(var(--toastify-toast-offset),env(safe-area-inset-top));--toastify-toast-right:max(var(--toastify-toast-offset),env(safe-area-inset-right));--toastify-toast-left:max(var(--toastify-toast-offset),env(safe-area-inset-left));--toastify-toast-bottom:max(var(--toastify-toast-offset),env(safe-area-inset-bottom));--toastify-toast-background:#fff;--toastify-toast-min-height:64px;--toastify-toast-max-height:800px;--toastify-toast-bd-radius:6px;--toastify-font-family:sans-serif;--toastify-z-index:9999;--toastify-text-color-light:#757575;--toastify-text-color-dark:#fff;--toastify-text-color-info:#fff;--toastify-text-color-success:#fff;--toastify-text-color-warning:#fff;--toastify-text-color-error:#fff;--toastify-spinner-color:#616161;--toastify-spinner-color-empty-area:#e0e0e0;--toastify-color-progress-light:linear-gradient(90deg,#4cd964,#5ac8fa,#007aff,#34aadc,#5856d6,#ff2d55);--toastify-color-progress-dark:#bb86fc;--toastify-color-progress-info:var(--toastify-color-info);--toastify-color-progress-success:var(--toastify-color-success);--toastify-color-progress-warning:var(--toastify-color-warning);--toastify-color-progress-error:var(--toastify-color-error);--toastify-color-progress-bgo:0.2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translateZ(var(--toastify-z-index));position:fixed;padding:4px;width:var(--toastify-toast-width);box-sizing:border-box;color:#fff}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translateX(-50%)}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right)}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translateX(-50%)}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right)}@media only screen and (max-width:480px){.Toastify__toast-container{width:100vw;padding:0;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-center,.Toastify__toast-container--top-left,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translateX(0)}.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translateX(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:auto}}.Toastify__toast{--y:0;position:relative;-ms-touch-action:none;touch-action:none;min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:8px;border-radius:var(--toastify-toast-bd-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);cursor:default;direction:ltr;z-index:0;overflow:hidden}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__close-button,.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-body{margin:auto 0;-ms-flex:1 1 auto;flex:1 1 auto;padding:6px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.Toastify__toast-body>div:last-child{word-break:break-word;-ms-flex:1;flex:1}.Toastify__toast-icon{-webkit-margin-end:10px;margin-inline-end:10px;width:20px;-ms-flex-negative:0;flex-shrink:0;display:-ms-flexbox;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}@media only screen and (max-width:480px){.Toastify__toast{margin-bottom:0;border-radius:0}}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--colored.Toastify__toast--default,.Toastify__toast-theme--light{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;-ms-flex-item-align:start;align-self:flex-start;z-index:1}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:focus,.Toastify__close-button:hover{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:var(--toastify-z-index);opacity:.7;transform-origin:left;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:auto;transform-origin:right;border-bottom-left-radius:0;border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp{position:absolute;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--bottom-left,.Toastify__bounce-enter--top-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--bottom-right,.Toastify__bounce-enter--top-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--bottom-left,.Toastify__bounce-exit--top-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--bottom-right,.Toastify__bounce-exit--top-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--bottom-left,.Toastify__slide-enter--top-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--bottom-right,.Toastify__slide-enter--top-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--bottom-left,.Toastify__slide-exit--top-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-right,.Toastify__slide-exit--top-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}',e=document.createElement("style");e.innerText=r,document.head.appendChild(e)}const A6e=U8(HFe);var QK,P6e;function L2t(){if(P6e)return QK;P6e=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i=(M,R)=>{for(var L in R)r(M,L,{get:R[L],enumerable:!0})},a=(M,R,L,z)=>{if(R&&typeof R=="object"||typeof R=="function")for(let j of t(R))!n.call(M,j)&&j!==L&&r(M,j,{get:()=>R[j],enumerable:!(z=e(R,j))||z.enumerable});return M},o=M=>a(r({},"__esModule",{value:!0}),M),s={};i(s,{SuperGrid:()=>T,toMMSI:()=>x,toMeterSI:()=>_}),QK=o(s);var l=Lx(),c=A6e,u=tre(),d=(M,R,L)=>{const z=[];if(R<M)for(let j=M;j>=R;j-=Math.abs(L))z.push(j);else for(let j=M;j<=R;j+=Math.abs(L))z.push(j);return z};function g(M,R){return{x:Math.round(R.x/M)*M,y:Math.round(R.y/M)*M}}function _(M,R=1){return M<0?"-"+_(-M):M<1e-6?"0m":M>1e3?Math.floor(M/1e3)+"km":M>1&&R>1?Math.round(M)+"m":M>1&&R<=1?M.toFixed(Math.ceil(-Math.log10(R)))+"m":M<1&&R>=1/1e3?Math.round(M*1e3)+"mm":M<1&&R<1/1e3?(M*1e3).toFixed(Math.ceil(-Math.log10(R*1e3)))+"mm":""}function x(M,R=1){return _(M/1e3,R/1e3)}var T=M=>{var R;const L=(0,l.useRef)(null),[z,j]=(0,l.useState)({x:0,y:0}),{majorColor:Z="rgba(0,0,0,0.2)",minorColor:ee="rgba(0,0,0,0.1)",textColor:W=(R=M.majorColor)!=null?R:"rgba(0,0,0,0.5)",width:se,height:ae,screenSpaceCellSize:ue=200,stringifyCoord:me=(ke,De,Oe)=>`${_(ke,Oe)}, ${_(De,Oe)}`}=M,_e=Math.ceil(se/ue)+2,Se=Math.ceil(ae/ue)+2;(0,l.useEffect)(()=>{if(!L.current)return;const ke=L.current.getContext("2d");if(!ke)return;const De=ue/10**Math.floor(Math.log10(M.transform.a)),Oe=M.transform.d<0?-1:1,Ue=ue/10**Math.log10(M.transform.a)/De;function je($n,bn,gn){const Mn=$n;let Gt,vr,nr;for(Gt=bn.x;Gt<=gn.x;Gt+=Mn)vr=(0,c.applyToPoint)(M.transform,{x:Gt,y:bn.y}),nr=(0,c.applyToPoint)(M.transform,{x:Gt,y:gn.y}),ke.beginPath(),ke.moveTo(vr.x,vr.y),ke.lineTo(nr.x,nr.y),ke.stroke();const on=d(bn.y,gn.y,Mn*Oe);for(const or of on)vr=(0,c.applyToPoint)(M.transform,{x:bn.x,y:or}),nr=(0,c.applyToPoint)(M.transform,{x:gn.x,y:or}),ke.beginPath(),ke.moveTo(vr.x,vr.y),ke.lineTo(nr.x,nr.y),ke.stroke()}function ze($n,bn,gn){const Mn=$n;let Gt;for(Gt=bn.x;Gt<=gn.x;Gt+=Mn)for(const vr of d(bn.y,gn.y,Mn*Oe)){const nr=(0,c.applyToPoint)(M.transform,{x:Gt,y:vr});ke.fillStyle=W,ke.font="12px sans-serif",ke.fillText(me(Gt,vr,$n),nr.x+2,nr.y-2)}}ke.clearRect(0,0,se,ae);const Ie=(0,c.applyToPoint)((0,c.inverse)(M.transform),{x:0,y:0}),at={x:Math.floor((Ie.x-De)/De)*De,y:Math.floor((Ie.y-De)/De+(Oe==-1?2:0))*De},ct={x:at.x+De*_e,y:at.y+De*Se*Oe},zt=De*5,Pt={x:Math.floor((Ie.x-zt)/zt)*zt,y:Math.floor((Ie.y-zt)/zt+(Oe==-1?2:0))*zt},Qt={x:Pt.x+zt*_e,y:Pt.y+zt*Se*Oe};ke.globalAlpha=1,ke.strokeStyle=Z,je(De,at,ct),ze(zt,Pt,Qt),ke.globalAlpha=1-Ue,je(zt/10,Pt,Qt),ke.globalAlpha=1-Ue,ke.strokeStyle=ee,je(De/10,at,ct),ke.globalAlpha=Math.max(((1-Ue)*10-5)/5,0),ze(zt/10,Pt,Qt),ke.globalAlpha=1;const en=(0,c.applyToPoint)(M.transform,z);ke.font="12px sans-serif",ke.fillStyle=W,ke.fillText(me(z.x,z.y,De),en.x+2,en.y-2),ke.strokeStyle=Z,ke.strokeRect(en.x-5,en.y-5,10,10)},[L,M.transform,z,se,ae]);const Ae=ke=>{if(!L.current)return;const De=ue/10/10**Math.floor(Math.log10(M.transform.a)),Oe=L.current.getBoundingClientRect(),Ne=(0,c.applyToPoint)((0,c.inverse)(M.transform),{x:ke.clientX-Oe.left,y:ke.clientY-Oe.top}),Ue=g(De,Ne);j(Ue)};return(0,u.jsx)("canvas",{onMouseUp:ke=>{ke.button===1&&Ae(ke)},onDoubleClick:Ae,ref:L,width:M.width,height:M.height})};return QK}var KK=L2t();function O2t(r,e,t){const n=(t.x-e.x)**2+(t.y-e.y)**2;if(n===0)return D6e(r,e);let i=((r.x-e.x)*(t.x-e.x)+(r.y-e.y)*(t.y-e.y))/n;i=Math.max(0,Math.min(1,i));const a={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};return D6e(r,a)}function D6e(r,e){const t=r.x-e.x,n=r.y-e.y;return Math.sqrt(t*t+n*n)}var z2t=!1;function U2t(r){if(r.sheet)return r.sheet;for(var e=0;e<document.styleSheets.length;e++)if(document.styleSheets[e].ownerNode===r)return document.styleSheets[e]}function k2t(r){var e=document.createElement("style");return e.setAttribute("data-emotion",r.key),r.nonce!==void 0&&e.setAttribute("nonce",r.nonce),e.appendChild(document.createTextNode("")),e.setAttribute("data-s",""),e}var I2t=function(){function r(t){var n=this;this._insertTag=function(i){var a;n.tags.length===0?n.insertionPoint?a=n.insertionPoint.nextSibling:n.prepend?a=n.container.firstChild:a=n.before:a=n.tags[n.tags.length-1].nextSibling,n.container.insertBefore(i,a),n.tags.push(i)},this.isSpeedy=t.speedy===void 0?!z2t:t.speedy,this.tags=[],this.ctr=0,this.nonce=t.nonce,this.key=t.key,this.container=t.container,this.prepend=t.prepend,this.insertionPoint=t.insertionPoint,this.before=null}var e=r.prototype;return e.hydrate=function(n){n.forEach(this._insertTag)},e.insert=function(n){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(k2t(this));var i=this.tags[this.tags.length-1];if(this.isSpeedy){var a=U2t(i);try{a.insertRule(n,a.cssRules.length)}catch{}}else i.appendChild(document.createTextNode(n));this.ctr++},e.flush=function(){this.tags.forEach(function(n){var i;return(i=n.parentNode)==null?void 0:i.removeChild(n)}),this.tags=[],this.ctr=0},r}(),u2="-ms-",JL="-moz-",x1="-webkit-",N6e="comm",JK="rule",eJ="decl",F2t="@import",L6e="@keyframes",B2t="@layer",H2t=Math.abs,eO=String.fromCharCode,V2t=Object.assign;function j2t(r,e){return N5(r,0)^45?(((e<<2^N5(r,0))<<2^N5(r,1))<<2^N5(r,2))<<2^N5(r,3):0}function O6e(r){return r.trim()}function G2t(r,e){return(r=e.exec(r))?r[0]:r}function b1(r,e,t){return r.replace(e,t)}function tJ(r,e){return r.indexOf(e)}function N5(r,e){return r.charCodeAt(e)|0}function q7(r,e,t){return r.slice(e,t)}function i4(r){return r.length}function nJ(r){return r.length}function tO(r,e){return e.push(r),r}function q2t(r,e){return r.map(e).join("")}var nO=1,y6=1,z6e=0,s3=0,ox=0,g6="";function rO(r,e,t,n,i,a,o){return{value:r,root:e,parent:t,type:n,props:i,children:a,line:nO,column:y6,length:o,return:""}}function Y7(r,e){return V2t(rO("",null,null,"",null,null,0),r,{length:-r.length},e)}function Y2t(){return ox}function X2t(){return ox=s3>0?N5(g6,--s3):0,y6--,ox===10&&(y6=1,nO--),ox}function R3(){return ox=s3<z6e?N5(g6,s3++):0,y6++,ox===10&&(y6=1,nO++),ox}function a4(){return N5(g6,s3)}function iO(){return s3}function X7(r,e){return q7(g6,r,e)}function W7(r){switch(r){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function U6e(r){return nO=y6=1,z6e=i4(g6=r),s3=0,[]}function k6e(r){return g6="",r}function aO(r){return O6e(X7(s3-1,rJ(r===91?r+2:r===40?r+1:r)))}function W2t(r){for(;(ox=a4())&&ox<33;)R3();return W7(r)>2||W7(ox)>3?"":" "}function $2t(r,e){for(;--e&&R3()&&!(ox<48||ox>102||ox>57&&ox<65||ox>70&&ox<97););return X7(r,iO()+(e<6&&a4()==32&&R3()==32))}function rJ(r){for(;R3();)switch(ox){case r:return s3;case 34:case 39:r!==34&&r!==39&&rJ(ox);break;case 40:r===41&&rJ(r);break;case 92:R3();break}return s3}function Z2t(r,e){for(;R3()&&r+ox!==57;)if(r+ox===84&&a4()===47)break;return"/*"+X7(e,s3-1)+"*"+eO(r===47?r:R3())}function Q2t(r){for(;!W7(a4());)R3();return X7(r,s3)}function K2t(r){return k6e(oO("",null,null,null,[""],r=U6e(r),0,[0],r))}function oO(r,e,t,n,i,a,o,s,l){for(var c=0,u=0,d=o,g=0,_=0,x=0,T=1,M=1,R=1,L=0,z="",j=i,Z=a,ee=n,W=z;M;)switch(x=L,L=R3()){case 40:if(x!=108&&N5(W,d-1)==58){tJ(W+=b1(aO(L),"&","&\f"),"&\f")!=-1&&(R=-1);break}case 34:case 39:case 91:W+=aO(L);break;case 9:case 10:case 13:case 32:W+=W2t(x);break;case 92:W+=$2t(iO()-1,7);continue;case 47:switch(a4()){case 42:case 47:tO(J2t(Z2t(R3(),iO()),e,t),l);break;default:W+="/"}break;case 123*T:s[c++]=i4(W)*R;case 125*T:case 59:case 0:switch(L){case 0:case 125:M=0;case 59+u:R==-1&&(W=b1(W,/\f/g,"")),_>0&&i4(W)-d&&tO(_>32?F6e(W+";",n,t,d-1):F6e(b1(W," ","")+";",n,t,d-2),l);break;case 59:W+=";";default:if(tO(ee=I6e(W,e,t,c,u,i,s,z,j=[],Z=[],d),a),L===123)if(u===0)oO(W,e,ee,ee,j,a,d,s,Z);else switch(g===99&&N5(W,3)===110?100:g){case 100:case 108:case 109:case 115:oO(r,ee,ee,n&&tO(I6e(r,ee,ee,0,0,i,s,z,i,j=[],d),Z),i,Z,d,s,n?j:Z);break;default:oO(W,ee,ee,ee,[""],Z,0,s,Z)}}c=u=_=0,T=R=1,z=W="",d=o;break;case 58:d=1+i4(W),_=x;default:if(T<1){if(L==123)--T;else if(L==125&&T++==0&&X2t()==125)continue}switch(W+=eO(L),L*T){case 38:R=u>0?1:(W+="\f",-1);break;case 44:s[c++]=(i4(W)-1)*R,R=1;break;case 64:a4()===45&&(W+=aO(R3())),g=a4(),u=d=i4(z=W+=Q2t(iO())),L++;break;case 45:x===45&&i4(W)==2&&(T=0)}}return a}function I6e(r,e,t,n,i,a,o,s,l,c,u){for(var d=i-1,g=i===0?a:[""],_=nJ(g),x=0,T=0,M=0;x<n;++x)for(var R=0,L=q7(r,d+1,d=H2t(T=o[x])),z=r;R<_;++R)(z=O6e(T>0?g[R]+" "+L:b1(L,/&\f/g,g[R])))&&(l[M++]=z);return rO(r,e,t,i===0?JK:s,l,c,u)}function J2t(r,e,t){return rO(r,e,t,N6e,eO(Y2t()),q7(r,2,-2),0)}function F6e(r,e,t,n){return rO(r,e,t,eJ,q7(r,0,n),q7(r,n+1,-1),n)}function _6(r,e){for(var t="",n=nJ(r),i=0;i<n;i++)t+=e(r[i],i,r,e)||"";return t}function e3t(r,e,t,n){switch(r.type){case B2t:if(r.children.length)break;case F2t:case eJ:return r.return=r.return||r.value;case N6e:return"";case L6e:return r.return=r.value+"{"+_6(r.children,n)+"}";case JK:r.value=r.props.join(",")}return i4(t=_6(r.children,n))?r.return=r.value+"{"+t+"}":""}function t3t(r){var e=nJ(r);return function(t,n,i,a){for(var o="",s=0;s<e;s++)o+=r[s](t,n,i,a)||"";return o}}function n3t(r){return function(e){e.root||(e=e.return)&&r(e)}}function r3t(r){var e=Object.create(null);return function(t){return e[t]===void 0&&(e[t]=r(t)),e[t]}}var i3t=function(e,t,n){for(var i=0,a=0;i=a,a=a4(),i===38&&a===12&&(t[n]=1),!W7(a);)R3();return X7(e,s3)},a3t=function(e,t){var n=-1,i=44;do switch(W7(i)){case 0:i===38&&a4()===12&&(t[n]=1),e[n]+=i3t(s3-1,t,n);break;case 2:e[n]+=aO(i);break;case 4:if(i===44){e[++n]=a4()===58?"&\f":"",t[n]=e[n].length;break}default:e[n]+=eO(i)}while(i=R3());return e},o3t=function(e,t){return k6e(a3t(U6e(e),t))},B6e=new WeakMap,s3t=function(e){if(!(e.type!=="rule"||!e.parent||e.length<1)){for(var t=e.value,n=e.parent,i=e.column===n.column&&e.line===n.line;n.type!=="rule";)if(n=n.parent,!n)return;if(!(e.props.length===1&&t.charCodeAt(0)!==58&&!B6e.get(n))&&!i){B6e.set(e,!0);for(var a=[],o=o3t(t,a),s=n.props,l=0,c=0;l<o.length;l++)for(var u=0;u<s.length;u++,c++)e.props[c]=a[l]?o[l].replace(/&\f/g,s[u]):s[u]+" "+o[l]}}},l3t=function(e){if(e.type==="decl"){var t=e.value;t.charCodeAt(0)===108&&t.charCodeAt(2)===98&&(e.return="",e.value="")}};function H6e(r,e){switch(j2t(r,e)){case 5103:return x1+"print-"+r+r;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return x1+r+r;case 5349:case 4246:case 4810:case 6968:case 2756:return x1+r+JL+r+u2+r+r;case 6828:case 4268:return x1+r+u2+r+r;case 6165:return x1+r+u2+"flex-"+r+r;case 5187:return x1+r+b1(r,/(\w+).+(:[^]+)/,x1+"box-$1$2"+u2+"flex-$1$2")+r;case 5443:return x1+r+u2+"flex-item-"+b1(r,/flex-|-self/,"")+r;case 4675:return x1+r+u2+"flex-line-pack"+b1(r,/align-content|flex-|-self/,"")+r;case 5548:return x1+r+u2+b1(r,"shrink","negative")+r;case 5292:return x1+r+u2+b1(r,"basis","preferred-size")+r;case 6060:return x1+"box-"+b1(r,"-grow","")+x1+r+u2+b1(r,"grow","positive")+r;case 4554:return x1+b1(r,/([^-])(transform)/g,"$1"+x1+"$2")+r;case 6187:return b1(b1(b1(r,/(zoom-|grab)/,x1+"$1"),/(image-set)/,x1+"$1"),r,"")+r;case 5495:case 3959:return b1(r,/(image-set\([^]*)/,x1+"$1$`$1");case 4968:return b1(b1(r,/(.+:)(flex-)?(.*)/,x1+"box-pack:$3"+u2+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+x1+r+r;case 4095:case 3583:case 4068:case 2532:return b1(r,/(.+)-inline(.+)/,x1+"$1$2")+r;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(i4(r)-1-e>6)switch(N5(r,e+1)){case 109:if(N5(r,e+4)!==45)break;case 102:return b1(r,/(.+:)(.+)-([^]+)/,"$1"+x1+"$2-$3$1"+JL+(N5(r,e+3)==108?"$3":"$2-$3"))+r;case 115:return~tJ(r,"stretch")?H6e(b1(r,"stretch","fill-available"),e)+r:r}break;case 4949:if(N5(r,e+1)!==115)break;case 6444:switch(N5(r,i4(r)-3-(~tJ(r,"!important")&&10))){case 107:return b1(r,":",":"+x1)+r;case 101:return b1(r,/(.+:)([^;!]+)(;|!.+)?/,"$1"+x1+(N5(r,14)===45?"inline-":"")+"box$3$1"+x1+"$2$3$1"+u2+"$2box$3")+r}break;case 5936:switch(N5(r,e+11)){case 114:return x1+r+u2+b1(r,/[svh]\w+-[tblr]{2}/,"tb")+r;case 108:return x1+r+u2+b1(r,/[svh]\w+-[tblr]{2}/,"tb-rl")+r;case 45:return x1+r+u2+b1(r,/[svh]\w+-[tblr]{2}/,"lr")+r}return x1+r+u2+r+r}return r}var c3t=function(e,t,n,i){if(e.length>-1&&!e.return)switch(e.type){case eJ:e.return=H6e(e.value,e.length);break;case L6e:return _6([Y7(e,{value:b1(e.value,"@","@"+x1)})],i);case JK:if(e.length)return q2t(e.props,function(a){switch(G2t(a,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return _6([Y7(e,{props:[b1(a,/:(read-\w+)/,":"+JL+"$1")]})],i);case"::placeholder":return _6([Y7(e,{props:[b1(a,/:(plac\w+)/,":"+x1+"input-$1")]}),Y7(e,{props:[b1(a,/:(plac\w+)/,":"+JL+"$1")]}),Y7(e,{props:[b1(a,/:(plac\w+)/,u2+"input-$1")]})],i)}return""})}},u3t=[c3t],f3t=function(e){var t=e.key;if(t==="css"){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,function(T){var M=T.getAttribute("data-emotion");M.indexOf(" ")!==-1&&(document.head.appendChild(T),T.setAttribute("data-s",""))})}var i=e.stylisPlugins||u3t,a={},o,s=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),function(T){for(var M=T.getAttribute("data-emotion").split(" "),R=1;R<M.length;R++)a[M[R]]=!0;s.push(T)});var l,c=[s3t,l3t];{var u,d=[e3t,n3t(function(T){u.insert(T)})],g=t3t(c.concat(i,d)),_=function(M){return _6(K2t(M),g)};l=function(M,R,L,z){u=L,_(M?M+"{"+R.styles+"}":R.styles),z&&(x.inserted[R.name]=!0)}}var x={key:t,sheet:new I2t({key:t,container:o,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:a,registered:{},insert:l};return x.sheet.hydrate(s),x};function d3t(r){for(var e=0,t,n=0,i=r.length;i>=4;++n,i-=4)t=r.charCodeAt(n)&255|(r.charCodeAt(++n)&255)<<8|(r.charCodeAt(++n)&255)<<16|(r.charCodeAt(++n)&255)<<24,t=(t&65535)*1540483477+((t>>>16)*59797<<16),t^=t>>>24,e=(t&65535)*1540483477+((t>>>16)*59797<<16)^(e&65535)*1540483477+((e>>>16)*59797<<16);switch(i){case 3:e^=(r.charCodeAt(n+2)&255)<<16;case 2:e^=(r.charCodeAt(n+1)&255)<<8;case 1:e^=r.charCodeAt(n)&255,e=(e&65535)*1540483477+((e>>>16)*59797<<16)}return e^=e>>>13,e=(e&65535)*1540483477+((e>>>16)*59797<<16),((e^e>>>15)>>>0).toString(36)}var h3t={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},p3t=!1,m3t=/[A-Z]|^ms/g,v3t=/_EMO_([^_]+?)_([^]*?)_EMO_/g,V6e=function(e){return e.charCodeAt(1)===45},j6e=function(e){return e!=null&&typeof e!="boolean"},iJ=r3t(function(r){return V6e(r)?r:r.replace(m3t,"-$&").toLowerCase()}),G6e=function(e,t){switch(e){case"animation":case"animationName":if(typeof t=="string")return t.replace(v3t,function(n,i,a){return VS={name:i,styles:a,next:VS},i})}return h3t[e]!==1&&!V6e(e)&&typeof t=="number"&&t!==0?t+"px":t},y3t="Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";function sO(r,e,t){if(t==null)return"";var n=t;if(n.__emotion_styles!==void 0)return n;switch(typeof t){case"boolean":return"";case"object":{var i=t;if(i.anim===1)return VS={name:i.name,styles:i.styles,next:VS},i.name;var a=t;if(a.styles!==void 0){var o=a.next;if(o!==void 0)for(;o!==void 0;)VS={name:o.name,styles:o.styles,next:VS},o=o.next;var s=a.styles+";";return s}return g3t(r,e,t)}}var l=t;if(e==null)return l;var c=e[l];return c!==void 0?c:l}function g3t(r,e,t){var n="";if(Array.isArray(t))for(var i=0;i<t.length;i++)n+=sO(r,e,t[i])+";";else for(var a in t){var o=t[a];if(typeof o!="object"){var s=o;e!=null&&e[s]!==void 0?n+=a+"{"+e[s]+"}":j6e(s)&&(n+=iJ(a)+":"+G6e(a,s)+";")}else{if(a==="NO_COMPONENT_SELECTOR"&&p3t)throw new Error(y3t);if(Array.isArray(o)&&typeof o[0]=="string"&&(e==null||e[o[0]]===void 0))for(var l=0;l<o.length;l++)j6e(o[l])&&(n+=iJ(a)+":"+G6e(a,o[l])+";");else{var c=sO(r,e,o);switch(a){case"animation":case"animationName":{n+=iJ(a)+":"+c+";";break}default:n+=a+"{"+c+"}"}}}}return n}var q6e=/label:\s*([^\s;{]+)\s*(;|$)/g,VS;function aJ(r,e,t){if(r.length===1&&typeof r[0]=="object"&&r[0]!==null&&r[0].styles!==void 0)return r[0];var n=!0,i="";VS=void 0;var a=r[0];if(a==null||a.raw===void 0)n=!1,i+=sO(t,e,a);else{var o=a;i+=o[0]}for(var s=1;s<r.length;s++)if(i+=sO(t,e,r[s]),n){var l=a;i+=l[s]}q6e.lastIndex=0;for(var c="",u;(u=q6e.exec(i))!==null;)c+="-"+u[1];var d=d3t(i)+c;return{name:d,styles:i,next:VS}}function Y6e(r,e,t){var n="";return t.split(" ").forEach(function(i){r[i]!==void 0?e.push(r[i]+";"):i&&(n+=i+" ")}),n}var _3t=function(e,t,n){var i=e.key+"-"+t.name;e.registered[i]===void 0&&(e.registered[i]=t.styles)},x3t=function(e,t,n){_3t(e,t);var i=e.key+"-"+t.name;if(e.inserted[t.name]===void 0){var a=t;do e.insert(t===a?"."+i:"",a,e.sheet,!0),a=a.next;while(a!==void 0)}};function X6e(r,e){if(r.inserted[e.name]===void 0)return r.insert("",e,r.sheet,!0)}function W6e(r,e,t){var n=[],i=Y6e(r,n,t);return n.length<2?t:i+e(n)}var b3t=function(e){var t=f3t(e);t.sheet.speedy=function(s){this.isSpeedy=s},t.compat=!0;var n=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var d=aJ(c,t.registered,void 0);return x3t(t,d),t.key+"-"+d.name},i=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var d=aJ(c,t.registered),g="animation-"+d.name;return X6e(t,{name:d.name,styles:"@keyframes "+g+"{"+d.styles+"}"}),g},a=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var d=aJ(c,t.registered);X6e(t,d)},o=function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];return W6e(t.registered,n,S3t(c))};return{css:n,cx:o,injectGlobal:a,keyframes:i,hydrate:function(l){l.forEach(function(c){t.inserted[c]=!0})},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:Y6e.bind(null,t.registered),merge:W6e.bind(null,t.registered,n)}},S3t=function r(e){for(var t="",n=0;n<e.length;n++){var i=e[n];if(i!=null){var a=void 0;switch(typeof i){case"boolean":break;case"object":{if(Array.isArray(i))a=r(i);else{a="";for(var o in i)i[o]&&o&&(a&&(a+=" "),a+=o)}break}default:a=i}a&&(t&&(t+=" "),t+=a)}}return t},E3t=b3t({key:"css"}),x6=E3t.css;function w3t(r){const e=new Map;let t=0;function n(i){for(const[,o]of e)if(o.has(i))return o;const a=new Set;return e.set(`connectivity_net${t++}`,a),a}for(const i of r){let a=null;for(const o of i){if(!a)a=n(o);else if(!a.has(o)){const s=n(o);if(s!==a){for(const l of s)a.add(l);e.delete(Array.from(e.entries()).find(([,l])=>l===s)[0])}}a.add(o)}}return Object.fromEntries(Array.from(e.entries()).map(([i,a])=>[i,Array.from(a)]))}var T3t=class{constructor(r){ui(this,"netMap");ui(this,"idToNetMap");this.netMap=r,this.idToNetMap={};for(const[e,t]of Object.entries(r))for(const n of t)this.idToNetMap[n]=e}addConnections(r){for(const e of r){const t=new Set;for(const i of e){const a=this.idToNetMap[i];a&&t.add(a)}let n;if(t.size===0)n=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[n]=[];else if(t.size===1)n=t.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{n=t.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const i of t)if(i!==n){this.netMap[n].push(...this.netMap[i]),this.netMap[i]=this.netMap[n];for(const a of this.netMap[n])this.idToNetMap[a]=n}}for(const i of e)this.netMap[n].includes(i)||this.netMap[n].push(i),this.idToNetMap[i]=n}}getIdsConnectedToNet(r){return this.netMap[r]||[]}getNetConnectedToId(r){return this.idToNetMap[r]}areIdsConnected(r,e){const t=this.getNetConnectedToId(r),n=this.getNetConnectedToId(e);return t===n||n===r||n===r}areAllIdsConnected(r){const e=this.getNetConnectedToId(r[0]);for(const t of r){const n=this.getNetConnectedToId(t);if(n===void 0||n!==e)return!1}return!0}},$6e=r=>{const e=[];for(const n of r)if(n.type==="source_trace")e.push([n.source_trace_id,...n.connected_source_port_ids??[],...n.connected_source_net_ids??[]].filter(Boolean));else if(n.type==="pcb_port"){const{pcb_port_id:i,source_port_id:a}=n;a&&i&&e.push([a,i])}else if(n.type==="pcb_smtpad"){const{pcb_smtpad_id:i,pcb_port_id:a}=n;a&&i&&e.push([i,a])}else if(n.type==="pcb_plated_hole"){const{pcb_plated_hole_id:i,pcb_port_id:a}=n;a&&i&&e.push([i,a])}else if(n.type==="pcb_trace"){const{pcb_trace_id:i,source_trace_id:a}=n;a&&i&&e.push([i,a])}const t=w3t(e);return new T3t(t)},M3t=Object.defineProperty,C3t=(r,e)=>{for(var t in e)M3t(r,t,{get:e[t],enumerable:!0})},Z6e={};C3t(Z6e,{all_layers:()=>xO,any_circuit_element:()=>SMe,any_soup_element:()=>EMe,any_source_component:()=>xTe,battery_capacity:()=>vTe,cad_component:()=>bMe,capacitance:()=>pJ,current:()=>Fbt,distance:()=>mc,frequency:()=>mTe,getZodPrefixedIdWithDefault:()=>i1,inductance:()=>pTe,layer_ref:()=>H9,layer_string:()=>DJ,length:()=>f_,pcb_board:()=>oMe,pcb_component:()=>qTe,pcb_fabrication_note_path:()=>vMe,pcb_fabrication_note_text:()=>mMe,pcb_group:()=>xMe,pcb_hole:()=>WTe,pcb_hole_circle_or_square_shape:()=>Gbt,pcb_hole_oval_shape:()=>qbt,pcb_keepout:()=>yMe,pcb_manual_edit_conflict_error:()=>_Me,pcb_missing_footprint_error:()=>gMe,pcb_placement_error:()=>sMe,pcb_plated_hole:()=>$Te,pcb_port:()=>ZTe,pcb_port_not_matched_error:()=>iMe,pcb_route_hint:()=>jTe,pcb_route_hints:()=>jbt,pcb_silkscreen_circle:()=>hMe,pcb_silkscreen_line:()=>cMe,pcb_silkscreen_oval:()=>pMe,pcb_silkscreen_path:()=>uMe,pcb_silkscreen_rect:()=>dMe,pcb_silkscreen_text:()=>fMe,pcb_smtpad:()=>QTe,pcb_solder_paste:()=>KTe,pcb_text:()=>JTe,pcb_trace:()=>nMe,pcb_trace_error:()=>rMe,pcb_trace_hint:()=>lMe,pcb_trace_route_point:()=>e4t,pcb_trace_route_point_via:()=>tMe,pcb_trace_route_point_wire:()=>eMe,pcb_via:()=>aMe,point:()=>Qy,point3:()=>hC,port_arrangement:()=>PTe,position:()=>Hbt,position3:()=>Vbt,resistance:()=>vO,rotation:()=>yO,route_hint_point:()=>GTe,schematic_box:()=>TTe,schematic_component:()=>DTe,schematic_component_port_arrangement_by_sides:()=>ATe,schematic_component_port_arrangement_by_size:()=>RTe,schematic_debug_line:()=>FTe,schematic_debug_object:()=>HTe,schematic_debug_object_base:()=>_O,schematic_debug_point:()=>BTe,schematic_debug_rect:()=>ITe,schematic_error:()=>kTe,schematic_line:()=>NTe,schematic_net_label:()=>UTe,schematic_path:()=>MTe,schematic_pin_styles:()=>CTe,schematic_port:()=>zTe,schematic_text:()=>OTe,schematic_trace:()=>LTe,schematic_voltage_probe:()=>VTe,size:()=>vJ,source_component_base:()=>L5,source_group:()=>ETe,source_led:()=>bJ,source_net:()=>wTe,source_port:()=>bTe,source_simple_battery:()=>EJ,source_simple_bug:()=>_J,source_simple_capacitor:()=>yJ,source_simple_chip:()=>xJ,source_simple_crystal:()=>_Te,source_simple_diode:()=>gO,source_simple_ground:()=>gTe,source_simple_inductor:()=>wJ,source_simple_mosfet:()=>PJ,source_simple_pin_header:()=>CJ,source_simple_potentiometer:()=>MJ,source_simple_power_source:()=>SJ,source_simple_push_button:()=>TJ,source_simple_resistor:()=>gJ,source_simple_resonator:()=>RJ,source_simple_transistor:()=>AJ,source_trace:()=>STe,supplier_name:()=>yTe,time:()=>Bbt,visible_layer:()=>C6,voltage:()=>mJ});var Ev;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const a={};for(const o of i)a[o]=o;return a},r.getValidEnumValues=i=>{const a=r.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(const s of a)o[s]=i[s];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(a){return i[a]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},r.find=(i,a)=>{for(const o of i)if(a(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(Ev||(Ev={}));var oJ;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(oJ||(oJ={}));var Sc=Ev.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Q4=r=>{switch(typeof r){case"undefined":return Sc.undefined;case"string":return Sc.string;case"number":return isNaN(r)?Sc.nan:Sc.number;case"boolean":return Sc.boolean;case"function":return Sc.function;case"bigint":return Sc.bigint;case"symbol":return Sc.symbol;case"object":return Array.isArray(r)?Sc.array:r===null?Sc.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?Sc.promise:typeof Map<"u"&&r instanceof Map?Sc.map:typeof Set<"u"&&r instanceof Set?Sc.set:typeof Date<"u"&&r instanceof Date?Sc.date:Sc.object;default:return Sc.unknown}},ss=Ev.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),R3t=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),bb=class VLe extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let s=n,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(o))):s[c]=s[c]||{_errors:[]},s=s[c],l++}}};return i(this),n}static assert(e){if(!(e instanceof VLe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ev.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};bb.create=r=>new bb(r);var b6=(r,e)=>{let t;switch(r.code){case ss.invalid_type:r.received===Sc.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case ss.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Ev.jsonStringifyReplacer)}`;break;case ss.unrecognized_keys:t=`Unrecognized key(s) in object: ${Ev.joinValues(r.keys,", ")}`;break;case ss.invalid_union:t="Invalid input";break;case ss.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Ev.joinValues(r.options)}`;break;case ss.invalid_enum_value:t=`Invalid enum value. Expected ${Ev.joinValues(r.options)}, received '${r.received}'`;break;case ss.invalid_arguments:t="Invalid function arguments";break;case ss.invalid_return_type:t="Invalid function return type";break;case ss.invalid_date:t="Invalid date";break;case ss.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Ev.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case ss.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case ss.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case ss.custom:t="Invalid input";break;case ss.invalid_intersection_types:t="Intersection results could not be merged";break;case ss.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case ss.not_finite:t="Number must be finite";break;default:t=e.defaultError,Ev.assertNever(r)}return{message:t}},Q6e=b6;function A3t(r){Q6e=r}function lO(){return Q6e}var cO=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,a=[...t,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="";const l=n.filter(c=>!!c).slice().reverse();for(const c of l)s=c(o,{data:e,defaultError:s}).message;return{...i,path:a,message:s}},P3t=[];function kl(r,e){const t=lO(),n=cO({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===b6?void 0:b6].filter(i=>!!i)});r.common.issues.push(n)}var l3=class jLe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return B0;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const a=await i.key,o=await i.value;n.push({key:a,value:o})}return jLe.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return B0;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[a.value]=o.value)}return{status:e.value,value:n}}},B0=Object.freeze({status:"aborted"}),S6=r=>({status:"dirty",value:r}),O2=r=>({status:"valid",value:r}),sJ=r=>r.status==="aborted",lJ=r=>r.status==="dirty",b8=r=>r.status==="valid",$7=r=>typeof Promise<"u"&&r instanceof Promise;function uO(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function K6e(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}var ef;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ef||(ef={}));var Z7,Q7,o4=class{constructor(r,e,t,n){this._cachedPath=[],this.parent=r,this.data=e,this._path=t,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},J6e=(r,e)=>{if(b8(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new bb(r.common.issues);return this._error=t,this._error}}};function Sp(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,s)=>{var l,c;const{message:u}=r;return o.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:(l=u??n)!==null&&l!==void 0?l:s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:s.defaultError}},description:i}}var Vp=class{get description(){return this._def.description}_getType(r){return Q4(r.data)}_getOrReturnCtx(r,e){return e||{common:r.parent.common,data:r.data,parsedType:Q4(r.data),schemaErrorMap:this._def.errorMap,path:r.path,parent:r.parent}}_processInputParams(r){return{status:new l3,ctx:{common:r.parent.common,data:r.data,parsedType:Q4(r.data),schemaErrorMap:this._def.errorMap,path:r.path,parent:r.parent}}}_parseSync(r){const e=this._parse(r);if($7(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(r){const e=this._parse(r);return Promise.resolve(e)}parse(r,e){const t=this.safeParse(r,e);if(t.success)return t.data;throw t.error}safeParse(r,e){var t;const n={common:{issues:[],async:(t=e==null?void 0:e.async)!==null&&t!==void 0?t:!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:Q4(r)},i=this._parseSync({data:r,path:n.path,parent:n});return J6e(n,i)}"~validate"(r){var e,t;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:Q4(r)};if(!this["~standard"].async)try{const i=this._parseSync({data:r,path:[],parent:n});return b8(i)?{value:i.value}:{issues:n.common.issues}}catch(i){!((t=(e=i==null?void 0:i.message)===null||e===void 0?void 0:e.toLowerCase())===null||t===void 0)&&t.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:r,path:[],parent:n}).then(i=>b8(i)?{value:i.value}:{issues:n.common.issues})}async parseAsync(r,e){const t=await this.safeParseAsync(r,e);if(t.success)return t.data;throw t.error}async safeParseAsync(r,e){const t={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:Q4(r)},n=this._parse({data:r,path:t.path,parent:t}),i=await($7(n)?n:Promise.resolve(n));return J6e(t,i)}refine(r,e){const t=n=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(n):e;return this._refinement((n,i)=>{const a=r(n),o=()=>i.addIssue({code:ss.custom,...t(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(s=>s?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(r,e){return this._refinement((t,n)=>r(t)?!0:(n.addIssue(typeof e=="function"?e(t,n):e),!1))}_refinement(r){return new Sb({schema:this,typeName:E0.ZodEffects,effect:{type:"refinement",refinement:r}})}superRefine(r){return this._refinement(r)}constructor(r){this.spa=this.safeParseAsync,this._def=r,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return s4.create(this,this._def)}nullable(){return GS.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return E8.create(this)}promise(){return M6.create(this,this._def)}or(r){return iC.create([this,r],this._def)}and(r){return aC.create(this,r,this._def)}transform(r){return new Sb({...Sp(this._def),schema:this,typeName:E0.ZodEffects,effect:{type:"transform",transform:r}})}default(r){const e=typeof r=="function"?r:()=>r;return new uC({...Sp(this._def),innerType:this,defaultValue:e,typeName:E0.ZodDefault})}brand(){return new fJ({typeName:E0.ZodBranded,type:this,...Sp(this._def)})}catch(r){const e=typeof r=="function"?r:()=>r;return new fC({...Sp(this._def),innerType:this,catchValue:e,typeName:E0.ZodCatch})}describe(r){const e=this.constructor;return new e({...this._def,description:r})}pipe(r){return dJ.create(this,r)}readonly(){return dC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},D3t=/^c[^\s-]{8,}$/i,N3t=/^[0-9a-z]+$/,L3t=/^[0-9A-HJKMNP-TV-Z]{26}$/i,O3t=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,z3t=/^[a-z0-9_-]{21}$/i,U3t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,k3t=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,I3t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,F3t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",cJ,B3t=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,H3t=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,V3t=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,j3t=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,G3t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,q3t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,eTe="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Y3t=new RegExp(`^${eTe}$`);function tTe(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function X3t(r){return new RegExp(`^${tTe(r)}$`)}function nTe(r){let e=`${eTe}T${tTe(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function W3t(r,e){return!!((e==="v4"||!e)&&B3t.test(r)||(e==="v6"||!e)&&V3t.test(r))}function $3t(r,e){if(!U3t.test(r))return!1;try{const[t]=r.split("."),n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||!i.typ||!i.alg||e&&i.alg!==e)}catch{return!1}}function Z3t(r,e){return!!((e==="v4"||!e)&&H3t.test(r)||(e==="v6"||!e)&&j3t.test(r))}var E6=class qC extends Vp{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Sc.string){const a=this._getOrReturnCtx(e);return kl(a,{code:ss.invalid_type,expected:Sc.string,received:a.parsedType}),B0}const n=new l3;let i;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),kl(i,{code:ss.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),kl(i,{code:ss.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,s=e.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(e,i),o?kl(i,{code:ss.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&kl(i,{code:ss.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")I3t.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"email",code:ss.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")cJ||(cJ=new RegExp(F3t,"u")),cJ.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"emoji",code:ss.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")O3t.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"uuid",code:ss.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")z3t.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"nanoid",code:ss.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")D3t.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"cuid",code:ss.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")N3t.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"cuid2",code:ss.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")L3t.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"ulid",code:ss.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),kl(i,{validation:"url",code:ss.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"regex",code:ss.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),kl(i,{code:ss.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),kl(i,{code:ss.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),kl(i,{code:ss.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?nTe(a).test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{code:ss.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Y3t.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{code:ss.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?X3t(a).test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{code:ss.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?k3t.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"duration",code:ss.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?W3t(e.data,a.version)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"ip",code:ss.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?$3t(e.data,a.alg)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"jwt",code:ss.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Z3t(e.data,a.version)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"cidr",code:ss.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?G3t.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"base64",code:ss.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?q3t.test(e.data)||(i=this._getOrReturnCtx(e,i),kl(i,{validation:"base64url",code:ss.invalid_string,message:a.message}),n.dirty()):Ev.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:ss.invalid_string,...ef.errToObj(n)})}_addCheck(e){return new qC({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ef.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ef.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ef.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ef.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ef.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ef.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ef.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ef.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ef.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ef.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ef.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ef.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ef.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...ef.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...ef.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ef.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ef.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...ef.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ef.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ef.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ef.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ef.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ef.errToObj(t)})}nonempty(e){return this.min(1,ef.errToObj(e))}trim(){return new qC({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new qC({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new qC({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};E6.create=r=>{var e;return new E6({checks:[],typeName:E0.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Sp(r)})};function Q3t(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,a=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return a%o/Math.pow(10,i)}var K7=class Gne extends Vp{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Sc.number){const a=this._getOrReturnCtx(e);return kl(a,{code:ss.invalid_type,expected:Sc.number,received:a.parsedType}),B0}let n;const i=new l3;for(const a of this._def.checks)a.kind==="int"?Ev.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),kl(n,{code:ss.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),kl(n,{code:ss.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),kl(n,{code:ss.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?Q3t(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),kl(n,{code:ss.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),kl(n,{code:ss.not_finite,message:a.message}),i.dirty()):Ev.assertNever(a);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ef.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ef.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ef.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ef.toString(t))}setLimit(e,t,n,i){return new Gne({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ef.toString(i)}]})}_addCheck(e){return new Gne({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ef.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ef.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ef.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ef.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ef.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ef.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ef.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ef.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ef.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Ev.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};K7.create=r=>new K7({checks:[],typeName:E0.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Sp(r)});var J7=class qne extends Vp{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Sc.bigint)return this._getInvalidInput(e);let n;const i=new l3;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),kl(n,{code:ss.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),kl(n,{code:ss.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),kl(n,{code:ss.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):Ev.assertNever(a);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return kl(t,{code:ss.invalid_type,expected:Sc.bigint,received:t.parsedType}),B0}gte(e,t){return this.setLimit("min",e,!0,ef.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ef.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ef.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ef.toString(t))}setLimit(e,t,n,i){return new qne({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ef.toString(i)}]})}_addCheck(e){return new qne({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ef.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ef.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ef.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ef.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ef.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};J7.create=r=>{var e;return new J7({checks:[],typeName:E0.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Sp(r)})};var eC=class extends Vp{_parse(r){if(this._def.coerce&&(r.data=!!r.data),this._getType(r)!==Sc.boolean){const t=this._getOrReturnCtx(r);return kl(t,{code:ss.invalid_type,expected:Sc.boolean,received:t.parsedType}),B0}return O2(r.data)}};eC.create=r=>new eC({typeName:E0.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Sp(r)});var tC=class GLe extends Vp{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Sc.date){const a=this._getOrReturnCtx(e);return kl(a,{code:ss.invalid_type,expected:Sc.date,received:a.parsedType}),B0}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return kl(a,{code:ss.invalid_date}),B0}const n=new l3;let i;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),kl(i,{code:ss.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),kl(i,{code:ss.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):Ev.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new GLe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ef.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ef.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};tC.create=r=>new tC({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:E0.ZodDate,...Sp(r)});var fO=class extends Vp{_parse(r){if(this._getType(r)!==Sc.symbol){const t=this._getOrReturnCtx(r);return kl(t,{code:ss.invalid_type,expected:Sc.symbol,received:t.parsedType}),B0}return O2(r.data)}};fO.create=r=>new fO({typeName:E0.ZodSymbol,...Sp(r)});var nC=class extends Vp{_parse(r){if(this._getType(r)!==Sc.undefined){const t=this._getOrReturnCtx(r);return kl(t,{code:ss.invalid_type,expected:Sc.undefined,received:t.parsedType}),B0}return O2(r.data)}};nC.create=r=>new nC({typeName:E0.ZodUndefined,...Sp(r)});var rC=class extends Vp{_parse(r){if(this._getType(r)!==Sc.null){const t=this._getOrReturnCtx(r);return kl(t,{code:ss.invalid_type,expected:Sc.null,received:t.parsedType}),B0}return O2(r.data)}};rC.create=r=>new rC({typeName:E0.ZodNull,...Sp(r)});var w6=class extends Vp{constructor(){super(...arguments),this._any=!0}_parse(r){return O2(r.data)}};w6.create=r=>new w6({typeName:E0.ZodAny,...Sp(r)});var S8=class extends Vp{constructor(){super(...arguments),this._unknown=!0}_parse(r){return O2(r.data)}};S8.create=r=>new S8({typeName:E0.ZodUnknown,...Sp(r)});var K4=class extends Vp{_parse(r){const e=this._getOrReturnCtx(r);return kl(e,{code:ss.invalid_type,expected:Sc.never,received:e.parsedType}),B0}};K4.create=r=>new K4({typeName:E0.ZodNever,...Sp(r)});var dO=class extends Vp{_parse(r){if(this._getType(r)!==Sc.undefined){const t=this._getOrReturnCtx(r);return kl(t,{code:ss.invalid_type,expected:Sc.void,received:t.parsedType}),B0}return O2(r.data)}};dO.create=r=>new dO({typeName:E0.ZodVoid,...Sp(r)});var E8=class bU extends Vp{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==Sc.array)return kl(t,{code:ss.invalid_type,expected:Sc.array,received:t.parsedType}),B0;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,s=t.data.length<i.exactLength.value;(o||s)&&(kl(t,{code:o?ss.too_big:ss.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(kl(t,{code:ss.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(kl(t,{code:ss.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,s)=>i.type._parseAsync(new o4(t,o,t.path,s)))).then(o=>l3.mergeArray(n,o));const a=[...t.data].map((o,s)=>i.type._parseSync(new o4(t,o,t.path,s)));return l3.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new bU({...this._def,minLength:{value:e,message:ef.toString(t)}})}max(e,t){return new bU({...this._def,maxLength:{value:e,message:ef.toString(t)}})}length(e,t){return new bU({...this._def,exactLength:{value:e,message:ef.toString(t)}})}nonempty(e){return this.min(1,e)}};E8.create=(r,e)=>new E8({type:r,minLength:null,maxLength:null,exactLength:null,typeName:E0.ZodArray,...Sp(e)});function T6(r){if(r instanceof X3){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=s4.create(T6(n))}return new X3({...r._def,shape:()=>e})}else return r instanceof E8?new E8({...r._def,type:T6(r.element)}):r instanceof s4?s4.create(T6(r.unwrap())):r instanceof GS?GS.create(T6(r.unwrap())):r instanceof jS?jS.create(r.items.map(e=>T6(e))):r}var X3=class Lb extends Vp{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Ev.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==Sc.object){const c=this._getOrReturnCtx(e);return kl(c,{code:ss.invalid_type,expected:Sc.object,received:c.parsedType}),B0}const{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof K4&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||s.push(c);const l=[];for(const c of o){const u=a[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new o4(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof K4){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of s)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")s.length>0&&(kl(i,{code:ss.unrecognized_keys,keys:s}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of s){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new o4(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,g=await u.value;c.push({key:d,value:g,alwaysSet:u.alwaysSet})}return c}).then(c=>l3.mergeObjectSync(n,c)):l3.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return ef.errToObj,new Lb({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,a,o,s;const l=(o=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(s=ef.errToObj(e).message)!==null&&s!==void 0?s:l}:{message:l}}}:{}})}strip(){return new Lb({...this._def,unknownKeys:"strip"})}passthrough(){return new Lb({...this._def,unknownKeys:"passthrough"})}extend(e){return new Lb({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Lb({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:E0.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Lb({...this._def,catchall:e})}pick(e){const t={};return Ev.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Lb({...this._def,shape:()=>t})}omit(e){const t={};return Ev.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Lb({...this._def,shape:()=>t})}deepPartial(){return T6(this)}partial(e){const t={};return Ev.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Lb({...this._def,shape:()=>t})}required(e){const t={};return Ev.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof s4;)a=a._def.innerType;t[n]=a}}),new Lb({...this._def,shape:()=>t})}keyof(){return oTe(Ev.objectKeys(this.shape))}};X3.create=(r,e)=>new X3({shape:()=>r,unknownKeys:"strip",catchall:K4.create(),typeName:E0.ZodObject,...Sp(e)}),X3.strictCreate=(r,e)=>new X3({shape:()=>r,unknownKeys:"strict",catchall:K4.create(),typeName:E0.ZodObject,...Sp(e)}),X3.lazycreate=(r,e)=>new X3({shape:r,unknownKeys:"strip",catchall:K4.create(),typeName:E0.ZodObject,...Sp(e)});var iC=class extends Vp{_parse(r){const{ctx:e}=this._processInputParams(r),t=this._def.options;function n(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return e.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new bb(o.ctx.common.issues));return kl(e,{code:ss.invalid_union,unionErrors:a}),B0}if(e.common.async)return Promise.all(t.map(async i=>{const a={...e,common:{...e.common,issues:[]},parent:null};return{result:await i._parseAsync({data:e.data,path:e.path,parent:a}),ctx:a}})).then(n);{let i;const a=[];for(const s of t){const l={...e,common:{...e.common,issues:[]},parent:null},c=s._parseSync({data:e.data,path:e.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!i&&(i={result:c,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return e.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(s=>new bb(s));return kl(e,{code:ss.invalid_union,unionErrors:o}),B0}}get options(){return this._def.options}};iC.create=(r,e)=>new iC({options:r,typeName:E0.ZodUnion,...Sp(e)});var J4=r=>r instanceof oC?J4(r.schema):r instanceof Sb?J4(r.innerType()):r instanceof sC?[r.value]:r instanceof lC?r.options:r instanceof cC?Ev.objectValues(r.enum):r instanceof uC?J4(r._def.innerType):r instanceof nC?[void 0]:r instanceof rC?[null]:r instanceof s4?[void 0,...J4(r.unwrap())]:r instanceof GS?[null,...J4(r.unwrap())]:r instanceof fJ||r instanceof dC?J4(r.unwrap()):r instanceof fC?J4(r._def.innerType):[],rTe=class qLe extends Vp{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Sc.object)return kl(t,{code:ss.invalid_type,expected:Sc.object,received:t.parsedType}),B0;const n=this.discriminator,i=t.data[n],a=this.optionsMap.get(i);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(kl(t,{code:ss.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),B0)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const a of t){const o=J4(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const s of o){if(i.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);i.set(s,a)}}return new qLe({typeName:E0.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Sp(n)})}};function uJ(r,e){const t=Q4(r),n=Q4(e);if(r===e)return{valid:!0,data:r};if(t===Sc.object&&n===Sc.object){const i=Ev.objectKeys(e),a=Ev.objectKeys(r).filter(s=>i.indexOf(s)!==-1),o={...r,...e};for(const s of a){const l=uJ(r[s],e[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(t===Sc.array&&n===Sc.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<r.length;a++){const o=r[a],s=e[a],l=uJ(o,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return t===Sc.date&&n===Sc.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var aC=class extends Vp{_parse(r){const{status:e,ctx:t}=this._processInputParams(r),n=(i,a)=>{if(sJ(i)||sJ(a))return B0;const o=uJ(i.value,a.value);return o.valid?((lJ(i)||lJ(a))&&e.dirty(),{status:e.value,value:o.data}):(kl(t,{code:ss.invalid_intersection_types}),B0)};return t.common.async?Promise.all([this._def.left._parseAsync({data:t.data,path:t.path,parent:t}),this._def.right._parseAsync({data:t.data,path:t.path,parent:t})]).then(([i,a])=>n(i,a)):n(this._def.left._parseSync({data:t.data,path:t.path,parent:t}),this._def.right._parseSync({data:t.data,path:t.path,parent:t}))}};aC.create=(r,e,t)=>new aC({left:r,right:e,typeName:E0.ZodIntersection,...Sp(t)});var jS=class YLe extends Vp{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Sc.array)return kl(n,{code:ss.invalid_type,expected:Sc.array,received:n.parsedType}),B0;if(n.data.length<this._def.items.length)return kl(n,{code:ss.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),B0;!this._def.rest&&n.data.length>this._def.items.length&&(kl(n,{code:ss.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((o,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new o4(n,o,n.path,s)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>l3.mergeArray(t,o)):l3.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new YLe({...this._def,rest:e})}};jS.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jS({items:r,typeName:E0.ZodTuple,rest:null,...Sp(e)})};var iTe=class Yne extends Vp{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Sc.object)return kl(n,{code:ss.invalid_type,expected:Sc.object,received:n.parsedType}),B0;const i=[],a=this._def.keyType,o=this._def.valueType;for(const s in n.data)i.push({key:a._parse(new o4(n,s,n.path,s)),value:o._parse(new o4(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?l3.mergeObjectAsync(t,i):l3.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Vp?new Yne({keyType:e,valueType:t,typeName:E0.ZodRecord,...Sp(n)}):new Yne({keyType:E6.create(),valueType:e,typeName:E0.ZodRecord,...Sp(t)})}},hO=class extends Vp{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(r){const{status:e,ctx:t}=this._processInputParams(r);if(t.parsedType!==Sc.map)return kl(t,{code:ss.invalid_type,expected:Sc.map,received:t.parsedType}),B0;const n=this._def.keyType,i=this._def.valueType,a=[...t.data.entries()].map(([o,s],l)=>({key:n._parse(new o4(t,o,t.path,[l,"key"])),value:i._parse(new o4(t,s,t.path,[l,"value"]))}));if(t.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const s of a){const l=await s.key,c=await s.value;if(l.status==="aborted"||c.status==="aborted")return B0;(l.status==="dirty"||c.status==="dirty")&&e.dirty(),o.set(l.value,c.value)}return{status:e.value,value:o}})}else{const o=new Map;for(const s of a){const l=s.key,c=s.value;if(l.status==="aborted"||c.status==="aborted")return B0;(l.status==="dirty"||c.status==="dirty")&&e.dirty(),o.set(l.value,c.value)}return{status:e.value,value:o}}}};hO.create=(r,e,t)=>new hO({valueType:e,keyType:r,typeName:E0.ZodMap,...Sp(t)});var pO=class Xne extends Vp{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Sc.set)return kl(n,{code:ss.invalid_type,expected:Sc.set,received:n.parsedType}),B0;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(kl(n,{code:ss.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(kl(n,{code:ss.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const a=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return B0;u.status==="dirty"&&t.dirty(),c.add(u.value)}return{status:t.value,value:c}}const s=[...n.data.values()].map((l,c)=>a._parse(new o4(n,l,n.path,c)));return n.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(e,t){return new Xne({...this._def,minSize:{value:e,message:ef.toString(t)}})}max(e,t){return new Xne({...this._def,maxSize:{value:e,message:ef.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};pO.create=(r,e)=>new pO({valueType:r,minSize:null,maxSize:null,typeName:E0.ZodSet,...Sp(e)});var aTe=class SU extends Vp{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Sc.function)return kl(t,{code:ss.invalid_type,expected:Sc.function,received:t.parsedType}),B0;function n(s,l){return cO({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,lO(),b6].filter(c=>!!c),issueData:{code:ss.invalid_arguments,argumentsError:l}})}function i(s,l){return cO({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,lO(),b6].filter(c=>!!c),issueData:{code:ss.invalid_return_type,returnTypeError:l}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof M6){const s=this;return O2(async function(...l){const c=new bb([]),u=await s._def.args.parseAsync(l,a).catch(_=>{throw c.addIssue(n(l,_)),c}),d=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(d,a).catch(_=>{throw c.addIssue(i(d,_)),c})})}else{const s=this;return O2(function(...l){const c=s._def.args.safeParse(l,a);if(!c.success)throw new bb([n(l,c.error)]);const u=Reflect.apply(o,this,c.data),d=s._def.returns.safeParse(u,a);if(!d.success)throw new bb([i(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new SU({...this._def,args:jS.create(e).rest(S8.create())})}returns(e){return new SU({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new SU({args:e||jS.create([]).rest(S8.create()),returns:t||S8.create(),typeName:E0.ZodFunction,...Sp(n)})}},oC=class extends Vp{get schema(){return this._def.getter()}_parse(r){const{ctx:e}=this._processInputParams(r);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};oC.create=(r,e)=>new oC({getter:r,typeName:E0.ZodLazy,...Sp(e)});var sC=class extends Vp{_parse(r){if(r.data!==this._def.value){const e=this._getOrReturnCtx(r);return kl(e,{received:e.data,code:ss.invalid_literal,expected:this._def.value}),B0}return{status:"valid",value:r.data}}get value(){return this._def.value}};sC.create=(r,e)=>new sC({value:r,typeName:E0.ZodLiteral,...Sp(e)});function oTe(r,e){return new lC({values:r,typeName:E0.ZodEnum,...Sp(e)})}var lC=class Wne extends Vp{constructor(){super(...arguments),Z7.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return kl(t,{expected:Ev.joinValues(n),received:t.parsedType,code:ss.invalid_type}),B0}if(uO(this,Z7)||K6e(this,Z7,new Set(this._def.values)),!uO(this,Z7).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return kl(t,{received:t.data,code:ss.invalid_enum_value,options:n}),B0}return O2(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Wne.create(e,{...this._def,...t})}exclude(e,t=this._def){return Wne.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Z7=new WeakMap,lC.create=oTe;var cC=class extends Vp{constructor(){super(...arguments),Q7.set(this,void 0)}_parse(r){const e=Ev.getValidEnumValues(this._def.values),t=this._getOrReturnCtx(r);if(t.parsedType!==Sc.string&&t.parsedType!==Sc.number){const n=Ev.objectValues(e);return kl(t,{expected:Ev.joinValues(n),received:t.parsedType,code:ss.invalid_type}),B0}if(uO(this,Q7)||K6e(this,Q7,new Set(Ev.getValidEnumValues(this._def.values))),!uO(this,Q7).has(r.data)){const n=Ev.objectValues(e);return kl(t,{received:t.data,code:ss.invalid_enum_value,options:n}),B0}return O2(r.data)}get enum(){return this._def.values}};Q7=new WeakMap,cC.create=(r,e)=>new cC({values:r,typeName:E0.ZodNativeEnum,...Sp(e)});var M6=class extends Vp{unwrap(){return this._def.type}_parse(r){const{ctx:e}=this._processInputParams(r);if(e.parsedType!==Sc.promise&&e.common.async===!1)return kl(e,{code:ss.invalid_type,expected:Sc.promise,received:e.parsedType}),B0;const t=e.parsedType===Sc.promise?e.data:Promise.resolve(e.data);return O2(t.then(n=>this._def.type.parseAsync(n,{path:e.path,errorMap:e.common.contextualErrorMap})))}};M6.create=(r,e)=>new M6({type:r,typeName:E0.ZodPromise,...Sp(e)});var Sb=class extends Vp{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E0.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(r){const{status:e,ctx:t}=this._processInputParams(r),n=this._def.effect||null,i={addIssue:a=>{kl(t,a),a.fatal?e.abort():e.dirty()},get path(){return t.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){const a=n.transform(t.data,i);if(t.common.async)return Promise.resolve(a).then(async o=>{if(e.value==="aborted")return B0;const s=await this._def.schema._parseAsync({data:o,path:t.path,parent:t});return s.status==="aborted"?B0:s.status==="dirty"||e.value==="dirty"?S6(s.value):s});{if(e.value==="aborted")return B0;const o=this._def.schema._parseSync({data:a,path:t.path,parent:t});return o.status==="aborted"?B0:o.status==="dirty"||e.value==="dirty"?S6(o.value):o}}if(n.type==="refinement"){const a=o=>{const s=n.refinement(o,i);if(t.common.async)return Promise.resolve(s);if(s instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(t.common.async===!1){const o=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});return o.status==="aborted"?B0:(o.status==="dirty"&&e.dirty(),a(o.value),{status:e.value,value:o.value})}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(o=>o.status==="aborted"?B0:(o.status==="dirty"&&e.dirty(),a(o.value).then(()=>({status:e.value,value:o.value}))))}if(n.type==="transform")if(t.common.async===!1){const a=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(!b8(a))return a;const o=n.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:o}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(a=>b8(a)?Promise.resolve(n.transform(a.value,i)).then(o=>({status:e.value,value:o})):a);Ev.assertNever(n)}};Sb.create=(r,e,t)=>new Sb({schema:r,typeName:E0.ZodEffects,effect:e,...Sp(t)}),Sb.createWithPreprocess=(r,e,t)=>new Sb({schema:e,effect:{type:"preprocess",transform:r},typeName:E0.ZodEffects,...Sp(t)});var s4=class extends Vp{_parse(r){return this._getType(r)===Sc.undefined?O2(void 0):this._def.innerType._parse(r)}unwrap(){return this._def.innerType}};s4.create=(r,e)=>new s4({innerType:r,typeName:E0.ZodOptional,...Sp(e)});var GS=class extends Vp{_parse(r){return this._getType(r)===Sc.null?O2(null):this._def.innerType._parse(r)}unwrap(){return this._def.innerType}};GS.create=(r,e)=>new GS({innerType:r,typeName:E0.ZodNullable,...Sp(e)});var uC=class extends Vp{_parse(r){const{ctx:e}=this._processInputParams(r);let t=e.data;return e.parsedType===Sc.undefined&&(t=this._def.defaultValue()),this._def.innerType._parse({data:t,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};uC.create=(r,e)=>new uC({innerType:r,typeName:E0.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Sp(e)});var fC=class extends Vp{_parse(r){const{ctx:e}=this._processInputParams(r),t={...e,common:{...e.common,issues:[]}},n=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t}});return $7(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new bb(t.common.issues)},input:t.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new bb(t.common.issues)},input:t.data})}}removeCatch(){return this._def.innerType}};fC.create=(r,e)=>new fC({innerType:r,typeName:E0.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Sp(e)});var mO=class extends Vp{_parse(r){if(this._getType(r)!==Sc.nan){const t=this._getOrReturnCtx(r);return kl(t,{code:ss.invalid_type,expected:Sc.nan,received:t.parsedType}),B0}return{status:"valid",value:r.data}}};mO.create=r=>new mO({typeName:E0.ZodNaN,...Sp(r)});var K3t=Symbol("zod_brand"),fJ=class extends Vp{_parse(r){const{ctx:e}=this._processInputParams(r),t=e.data;return this._def.type._parse({data:t,path:e.path,parent:e})}unwrap(){return this._def.type}},dJ=class XLe extends Vp{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?B0:a.status==="dirty"?(t.dirty(),S6(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?B0:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new XLe({in:e,out:t,typeName:E0.ZodPipeline})}},dC=class extends Vp{_parse(r){const e=this._def.innerType._parse(r),t=n=>(b8(n)&&(n.value=Object.freeze(n.value)),n);return $7(e)?e.then(n=>t(n)):t(e)}unwrap(){return this._def.innerType}};dC.create=(r,e)=>new dC({innerType:r,typeName:E0.ZodReadonly,...Sp(e)});function sTe(r,e={},t){return r?w6.create().superRefine((n,i)=>{var a,o;if(!r(n)){const s=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,l=(o=(a=s.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,c=typeof s=="string"?{message:s}:s;i.addIssue({code:"custom",...c,fatal:l})}}):w6.create()}var J3t={object:X3.lazycreate},E0;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(E0||(E0={}));var ebt=(r,e={message:`Input not instance of ${r.name}`})=>sTe(t=>t instanceof r,e),lTe=E6.create,cTe=K7.create,tbt=mO.create,nbt=J7.create,uTe=eC.create,rbt=tC.create,ibt=fO.create,abt=nC.create,obt=rC.create,sbt=w6.create,lbt=S8.create,cbt=K4.create,ubt=dO.create,fbt=E8.create,dbt=X3.create,hbt=X3.strictCreate,pbt=iC.create,mbt=rTe.create,vbt=aC.create,ybt=jS.create,gbt=iTe.create,_bt=hO.create,xbt=pO.create,bbt=aTe.create,Sbt=oC.create,Ebt=sC.create,wbt=lC.create,Tbt=cC.create,Mbt=M6.create,fTe=Sb.create,Cbt=s4.create,Rbt=GS.create,Abt=Sb.createWithPreprocess,Pbt=dJ.create,Dbt=()=>lTe().optional(),Nbt=()=>cTe().optional(),Lbt=()=>uTe().optional(),Obt={string:r=>E6.create({...r,coerce:!0}),number:r=>K7.create({...r,coerce:!0}),boolean:r=>eC.create({...r,coerce:!0}),bigint:r=>J7.create({...r,coerce:!0}),date:r=>tC.create({...r,coerce:!0})},zbt=B0,Ht=Object.freeze({__proto__:null,defaultErrorMap:b6,setErrorMap:A3t,getErrorMap:lO,makeIssue:cO,EMPTY_PATH:P3t,addIssueToContext:kl,ParseStatus:l3,INVALID:B0,DIRTY:S6,OK:O2,isAborted:sJ,isDirty:lJ,isValid:b8,isAsync:$7,get util(){return Ev},get objectUtil(){return oJ},ZodParsedType:Sc,getParsedType:Q4,ZodType:Vp,datetimeRegex:nTe,ZodString:E6,ZodNumber:K7,ZodBigInt:J7,ZodBoolean:eC,ZodDate:tC,ZodSymbol:fO,ZodUndefined:nC,ZodNull:rC,ZodAny:w6,ZodUnknown:S8,ZodNever:K4,ZodVoid:dO,ZodArray:E8,ZodObject:X3,ZodUnion:iC,ZodDiscriminatedUnion:rTe,ZodIntersection:aC,ZodTuple:jS,ZodRecord:iTe,ZodMap:hO,ZodSet:pO,ZodFunction:aTe,ZodLazy:oC,ZodLiteral:sC,ZodEnum:lC,ZodNativeEnum:cC,ZodPromise:M6,ZodEffects:Sb,ZodTransformer:Sb,ZodOptional:s4,ZodNullable:GS,ZodDefault:uC,ZodCatch:fC,ZodNaN:mO,BRAND:K3t,ZodBranded:fJ,ZodPipeline:dJ,ZodReadonly:dC,custom:sTe,Schema:Vp,ZodSchema:Vp,late:J3t,get ZodFirstPartyTypeKind(){return E0},coerce:Obt,any:sbt,array:fbt,bigint:nbt,boolean:uTe,date:rbt,discriminatedUnion:mbt,effect:fTe,enum:wbt,function:bbt,instanceof:ebt,intersection:vbt,lazy:Sbt,literal:Ebt,map:_bt,nan:tbt,nativeEnum:Tbt,never:cbt,null:obt,nullable:Rbt,number:cTe,object:dbt,oboolean:Lbt,onumber:Nbt,optional:Cbt,ostring:Dbt,pipeline:Pbt,preprocess:Abt,promise:Mbt,record:gbt,set:xbt,strictObject:hbt,string:lTe,symbol:ibt,transformer:fTe,tuple:ybt,undefined:abt,union:pbt,unknown:lbt,void:ubt,NEVER:zbt,ZodIssueCode:ss,quotelessJson:R3t,ZodError:bb}),Ubt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",kbt=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=Ubt[t[r]&63];return e},dTe={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},hJ=new Set;for(const[r,e]of Object.entries(dTe)){hJ.add(r);for(const t of Object.keys(e.variants))hJ.add(t)}function Ibt(r){for(const[e,t]of Object.entries(dTe))if(r in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[r]};return{baseUnit:r,conversionFactor:1}}var hTe={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12},Eb=r=>{var s;if(typeof r>"u")return{parsedUnit:null,unitOfValue:null,value:null};if(typeof r=="string"&&r.match(/^[\d\.]+$/))return{value:Number.parseFloat(r),parsedUnit:null,unitOfValue:null};if(typeof r=="number")return{value:r,parsedUnit:null,unitOfValue:null};if(typeof r=="object"&&"x"in r&&"y"in r){const{parsedUnit:l,unitOfValue:c}=Eb(r.x);return{parsedUnit:l,unitOfValue:c,value:{x:Eb(r.x).value,y:Eb(r.y).value}}}const t=(s=r.toString().split("").reverse().join("").match(/[^\d\s]+/))==null?void 0:s[0];if(!t)throw new Error(`Could not determine unit: "${r}"`);const n=t.split("").reverse().join(""),i=r.slice(0,-n.length);if(n in hTe&&!hJ.has(n)){const l=hTe[n];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(i)*l}}const{baseUnit:a,conversionFactor:o}=Ibt(n);return{parsedUnit:n,unitOfValue:a,value:o*Number.parseFloat(i)}},vO=Ht.string().or(Ht.number()).transform(r=>Eb(r).value),pJ=Ht.string().or(Ht.number()).transform(r=>Eb(r).value),pTe=Ht.string().or(Ht.number()).transform(r=>Eb(r).value),mJ=Ht.string().or(Ht.number()).transform(r=>Eb(r).value),f_=Ht.string().or(Ht.number()).transform(r=>Eb(r).value),mTe=Ht.string().or(Ht.number()).transform(r=>Eb(r).value),mc=f_,Fbt=Ht.string().or(Ht.number()).transform(r=>Eb(r).value),Bbt=Ht.string().or(Ht.number()).transform(r=>Eb(r).value),yO=Ht.string().or(Ht.number()).transform(r=>typeof r=="number"?r:r.endsWith("deg")?Number.parseFloat(r.split("deg")[0]):r.endsWith("rad")?Number.parseFloat(r.split("rad")[0])*180/Math.PI:Number.parseFloat(r)),vTe=Ht.number().or(Ht.string().endsWith("mAh")).transform(r=>{if(typeof r=="string"){const e=r.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return r}).describe("Battery capacity in mAh"),Qy=Ht.object({x:mc,y:mc}),Hbt=Qy,hC=Ht.object({x:mc,y:mc,z:mc}),Vbt=hC,vJ=Ht.object({width:Ht.number(),height:Ht.number()}),i1=r=>Ht.string().optional().default(()=>`${r}_${kbt(10)}`),yTe=Ht.enum(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),L5=Ht.object({type:Ht.literal("source_component"),ftype:Ht.string().optional(),source_component_id:Ht.string(),name:Ht.string(),manufacturer_part_number:Ht.string().optional(),supplier_part_numbers:Ht.record(yTe,Ht.array(Ht.string())).optional(),display_value:Ht.string().optional()}),yJ=L5.extend({ftype:Ht.literal("simple_capacitor"),capacitance:pJ,display_capacitance:Ht.string().optional(),max_decoupling_trace_length:mc.optional()}),gJ=L5.extend({ftype:Ht.literal("simple_resistor"),resistance:vO,display_resistance:Ht.string().optional()}),gO=L5.extend({ftype:Ht.literal("simple_diode")}),gTe=L5.extend({ftype:Ht.literal("simple_ground")}),_J=L5.extend({ftype:Ht.literal("simple_bug")}).describe("@deprecated"),xJ=L5.extend({ftype:Ht.literal("simple_chip")}),bJ=gO.extend({ftype:Ht.literal("led")}),SJ=L5.extend({ftype:Ht.literal("simple_power_source"),voltage:mJ}),EJ=L5.extend({ftype:Ht.literal("simple_battery"),capacity:vTe}),wJ=L5.extend({ftype:Ht.literal("simple_inductor"),inductance:pTe}),TJ=L5.extend({ftype:Ht.literal("simple_push_button")}),MJ=L5.extend({ftype:Ht.literal("simple_potentiometer"),max_resistance:vO}),_Te=L5.extend({ftype:Ht.literal("simple_crystal"),frequency:Ht.number().describe("Frequency in Hz"),load_capacitance:Ht.number().optional().describe("Load capacitance in pF")}),CJ=L5.extend({ftype:Ht.literal("simple_pin_header"),pin_count:Ht.number(),gender:Ht.enum(["male","female"]).optional().default("male")}),RJ=L5.extend({ftype:Ht.literal("simple_resonator"),load_capacitance:pJ,equivalent_series_resistance:vO.optional(),frequency:mTe}),AJ=L5.extend({ftype:Ht.literal("simple_transistor"),transistor_type:Ht.enum(["npn","pnp"])}),PJ=L5.extend({ftype:Ht.literal("simple_mosfet"),channel_type:Ht.enum(["n","p"]),mosfet_mode:Ht.enum(["enhancement","depletion"])}),xTe=Ht.union([gJ,yJ,gO,gTe,xJ,_J,bJ,SJ,EJ,wJ,TJ,MJ,_Te,CJ,RJ,AJ,PJ]),bTe=Ht.object({type:Ht.literal("source_port"),pin_number:Ht.number().optional(),port_hints:Ht.array(Ht.string()).optional(),name:Ht.string(),source_port_id:Ht.string(),source_component_id:Ht.string()}),STe=Ht.object({type:Ht.literal("source_trace"),source_trace_id:Ht.string(),connected_source_port_ids:Ht.array(Ht.string()),connected_source_net_ids:Ht.array(Ht.string()),subcircuit_connectivity_map_key:Ht.string().optional(),max_length:Ht.number().optional(),display_name:Ht.string().optional()}),ETe=Ht.object({type:Ht.literal("source_group"),source_group_id:Ht.string(),name:Ht.string().optional()}),wTe=Ht.object({type:Ht.literal("source_net"),source_net_id:Ht.string(),name:Ht.string(),member_source_group_ids:Ht.array(Ht.string()),is_power:Ht.boolean().optional(),is_ground:Ht.boolean().optional(),is_digital_signal:Ht.boolean().optional(),is_analog_signal:Ht.boolean().optional(),trace_width:Ht.number().optional()}),TTe=Ht.object({type:Ht.literal("schematic_box"),schematic_component_id:Ht.string(),width:mc,height:mc,x:mc,y:mc}).describe("Draws a box on the schematic"),MTe=Ht.object({type:Ht.literal("schematic_path"),schematic_component_id:Ht.string(),fill_color:Ht.enum(["red","blue"]).optional(),is_filled:Ht.boolean().optional(),points:Ht.array(Qy)}),CTe=Ht.record(Ht.object({left_margin:f_.optional(),right_margin:f_.optional(),top_margin:f_.optional(),bottom_margin:f_.optional()})),RTe=Ht.object({left_size:Ht.number(),right_size:Ht.number(),top_size:Ht.number().optional(),bottom_size:Ht.number().optional()}),ATe=Ht.object({left_side:Ht.object({pins:Ht.array(Ht.number()),direction:Ht.enum(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Ht.object({pins:Ht.array(Ht.number()),direction:Ht.enum(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Ht.object({pins:Ht.array(Ht.number()),direction:Ht.enum(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Ht.object({pins:Ht.array(Ht.number()),direction:Ht.enum(["left-to-right","right-to-left"]).optional()}).optional()}),PTe=Ht.union([RTe,ATe]),DTe=Ht.object({type:Ht.literal("schematic_component"),rotation:yO.default(0),size:vJ,center:Qy,source_component_id:Ht.string(),schematic_component_id:Ht.string(),pin_spacing:f_.optional(),pin_styles:CTe.optional(),box_width:f_.optional(),symbol_name:Ht.string().optional(),port_arrangement:PTe.optional(),port_labels:Ht.record(Ht.string()).optional(),symbol_display_value:Ht.string().optional()}),NTe=Ht.object({type:Ht.literal("schematic_line"),schematic_component_id:Ht.string(),x1:mc,x2:mc,y1:mc,y2:mc}),LTe=Ht.object({type:Ht.literal("schematic_trace"),schematic_trace_id:Ht.string(),source_trace_id:Ht.string(),junctions:Ht.array(Ht.object({x:Ht.number(),y:Ht.number()})),edges:Ht.array(Ht.object({from:Ht.object({x:Ht.number(),y:Ht.number()}),to:Ht.object({x:Ht.number(),y:Ht.number()}),is_crossing:Ht.boolean().optional(),from_schematic_port_id:Ht.string().optional(),to_schematic_port_id:Ht.string().optional()}))}),OTe=Ht.object({type:Ht.literal("schematic_text"),schematic_component_id:Ht.string(),schematic_text_id:Ht.string(),text:Ht.string(),position:Ht.object({x:mc,y:mc}),rotation:Ht.number().default(0),anchor:Ht.enum(["center","left","right","top","bottom"]).default("center"),color:Ht.string().default("#000000")}),zTe=Ht.object({type:Ht.literal("schematic_port"),schematic_port_id:Ht.string(),source_port_id:Ht.string(),schematic_component_id:Ht.string().optional(),center:Qy,facing_direction:Ht.enum(["up","down","left","right"]).optional(),distance_from_component_edge:Ht.number().optional(),side_of_component:Ht.enum(["top","bottom","left","right"]).optional(),true_ccw_index:Ht.number().optional(),pin_number:Ht.number().optional(),display_pin_label:Ht.string().optional()}).describe("Defines a port on a schematic component"),UTe=Ht.object({type:Ht.literal("schematic_net_label"),source_net_id:Ht.string(),center:Qy,anchor_position:Qy.optional(),anchor_side:Ht.enum(["top","bottom","left","right"]),text:Ht.string(),symbol_name:Ht.string().optional()}),kTe=Ht.object({type:Ht.literal("schematic_error"),schematic_error_id:Ht.string(),error_type:Ht.literal("schematic_port_not_found"),message:Ht.string()}).describe("Defines a schematic error on the schematic"),_O=Ht.object({type:Ht.literal("schematic_debug_object"),label:Ht.string().optional()}),ITe=_O.extend({shape:Ht.literal("rect"),center:Qy,size:vJ}),FTe=_O.extend({shape:Ht.literal("line"),start:Qy,end:Qy}),BTe=_O.extend({shape:Ht.literal("point"),center:Qy}),HTe=Ht.discriminatedUnion("shape",[ITe,FTe,BTe]),VTe=Ht.object({type:Ht.literal("schematic_voltage_probe"),schematic_voltage_probe_id:Ht.string(),position:Qy,schematic_trace_id:Ht.string(),voltage:mJ.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),xO=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],DJ=Ht.enum(xO),H9=DJ.or(Ht.object({name:DJ})).transform(r=>typeof r=="string"?r:r.name),C6=Ht.enum(["top","bottom"]),jTe=Ht.object({x:mc,y:mc,via:Ht.boolean().optional(),via_to_layer:H9.optional()}),jbt=Ht.array(jTe),GTe=Ht.object({x:mc,y:mc,via:Ht.boolean().optional(),to_layer:H9.optional(),trace_width:mc.optional()}),qTe=Ht.object({type:Ht.literal("pcb_component"),pcb_component_id:i1("pcb_component"),source_component_id:Ht.string(),center:Qy,layer:H9,rotation:yO,width:f_,height:f_}).describe("Defines a component on the PCB"),YTe=Ht.object({type:Ht.literal("pcb_hole"),pcb_hole_id:i1("pcb_hole"),hole_shape:Ht.enum(["circle","square"]),hole_diameter:Ht.number(),x:mc,y:mc}),Gbt=YTe.describe("Defines a circular or square hole on the PCB"),XTe=Ht.object({type:Ht.literal("pcb_hole"),pcb_hole_id:i1("pcb_hole"),hole_shape:Ht.literal("oval"),hole_width:Ht.number(),hole_height:Ht.number(),x:mc,y:mc}),qbt=XTe.describe("Defines an oval hole on the PCB"),WTe=YTe.or(XTe),Ybt=Ht.object({type:Ht.literal("pcb_plated_hole"),shape:Ht.literal("circle"),outer_diameter:Ht.number(),hole_diameter:Ht.number(),x:mc,y:mc,layers:Ht.array(H9),port_hints:Ht.array(Ht.string()).optional(),pcb_component_id:Ht.string().optional(),pcb_port_id:Ht.string().optional(),pcb_plated_hole_id:i1("pcb_plated_hole")}),Xbt=Ht.object({type:Ht.literal("pcb_plated_hole"),shape:Ht.enum(["oval","pill"]),outer_width:Ht.number(),outer_height:Ht.number(),hole_width:Ht.number(),hole_height:Ht.number(),x:mc,y:mc,layers:Ht.array(H9),port_hints:Ht.array(Ht.string()).optional(),pcb_component_id:Ht.string().optional(),pcb_port_id:Ht.string().optional(),pcb_plated_hole_id:i1("pcb_plated_hole")}),Wbt=Ht.object({type:Ht.literal("pcb_plated_hole"),shape:Ht.literal("circular_hole_with_rect_pad"),hole_shape:Ht.literal("circle"),pad_shape:Ht.literal("rect"),hole_diameter:Ht.number(),rect_pad_width:Ht.number(),rect_pad_height:Ht.number(),x:mc,y:mc,layers:Ht.array(H9),port_hints:Ht.array(Ht.string()).optional(),pcb_component_id:Ht.string().optional(),pcb_port_id:Ht.string().optional(),pcb_plated_hole_id:i1("pcb_plated_hole")}),$Te=Ht.union([Ybt,Xbt,Wbt]),ZTe=Ht.object({type:Ht.literal("pcb_port"),pcb_port_id:i1("pcb_port"),source_port_id:Ht.string(),pcb_component_id:Ht.string(),x:mc,y:mc,layers:Ht.array(H9)}).describe("Defines a port on the PCB"),$bt=Ht.object({type:Ht.literal("pcb_smtpad"),shape:Ht.literal("circle"),pcb_smtpad_id:i1("pcb_smtpad"),x:mc,y:mc,radius:Ht.number(),layer:H9,port_hints:Ht.array(Ht.string()).optional(),pcb_component_id:Ht.string().optional(),pcb_port_id:Ht.string().optional()}),Zbt=Ht.object({type:Ht.literal("pcb_smtpad"),shape:Ht.literal("rect"),pcb_smtpad_id:i1("pcb_smtpad"),x:mc,y:mc,width:Ht.number(),height:Ht.number(),layer:H9,port_hints:Ht.array(Ht.string()).optional(),pcb_component_id:Ht.string().optional(),pcb_port_id:Ht.string().optional()}),Qbt=Ht.object({type:Ht.literal("pcb_smtpad"),shape:Ht.literal("rotated_rect"),pcb_smtpad_id:i1("pcb_smtpad"),x:mc,y:mc,width:Ht.number(),height:Ht.number(),ccw_rotation:yO,layer:H9,port_hints:Ht.array(Ht.string()).optional(),pcb_component_id:Ht.string().optional(),pcb_port_id:Ht.string().optional()}),QTe=Ht.union([$bt,Zbt,Qbt]).describe("Defines an SMT pad on the PCB"),Kbt=Ht.object({type:Ht.literal("pcb_solder_paste"),shape:Ht.literal("circle"),pcb_solder_paste_id:i1("pcb_solder_paste"),x:mc,y:mc,radius:Ht.number(),layer:H9,pcb_component_id:Ht.string().optional(),pcb_smtpad_id:Ht.string().optional()}),Jbt=Ht.object({type:Ht.literal("pcb_solder_paste"),shape:Ht.literal("rect"),pcb_solder_paste_id:i1("pcb_solder_paste"),x:mc,y:mc,width:Ht.number(),height:Ht.number(),layer:H9,pcb_component_id:Ht.string().optional(),pcb_smtpad_id:Ht.string().optional()}),KTe=Ht.union([Kbt,Jbt]).describe("Defines solderpaste on the PCB"),JTe=Ht.object({type:Ht.literal("pcb_text"),pcb_text_id:i1("pcb_text"),text:Ht.string(),center:Qy,layer:H9,width:f_,height:f_,lines:Ht.number(),align:Ht.enum(["bottom-left"])}).describe("Defines text on the PCB"),eMe=Ht.object({route_type:Ht.literal("wire"),x:mc,y:mc,width:mc,start_pcb_port_id:Ht.string().optional(),end_pcb_port_id:Ht.string().optional(),layer:H9}),tMe=Ht.object({route_type:Ht.literal("via"),x:mc,y:mc,from_layer:Ht.string(),to_layer:Ht.string()}),e4t=Ht.union([eMe,tMe]),nMe=Ht.object({type:Ht.literal("pcb_trace"),source_trace_id:Ht.string().optional(),pcb_component_id:Ht.string().optional(),pcb_trace_id:i1("pcb_trace"),route_thickness_mode:Ht.enum(["constant","interpolated"]).default("constant").optional(),route_order_index:Ht.number().optional(),should_round_corners:Ht.boolean().optional(),trace_length:Ht.number().optional(),route:Ht.array(Ht.union([Ht.object({route_type:Ht.literal("wire"),x:mc,y:mc,width:mc,start_pcb_port_id:Ht.string().optional(),end_pcb_port_id:Ht.string().optional(),layer:H9}),Ht.object({route_type:Ht.literal("via"),x:mc,y:mc,from_layer:Ht.string(),to_layer:Ht.string()})]))}).describe("Defines a trace on the PCB"),rMe=Ht.object({type:Ht.literal("pcb_trace_error"),pcb_trace_error_id:i1("pcb_trace_error"),error_type:Ht.literal("pcb_trace_error"),message:Ht.string(),center:Qy.optional(),pcb_trace_id:Ht.string(),source_trace_id:Ht.string(),pcb_component_ids:Ht.array(Ht.string()),pcb_port_ids:Ht.array(Ht.string())}).describe("Defines a trace error on the PCB"),iMe=Ht.object({type:Ht.literal("pcb_port_not_matched_error"),pcb_error_id:i1("pcb_error"),message:Ht.string(),pcb_component_ids:Ht.array(Ht.string())}).describe("Defines a trace error on the PCB where a port is not matched"),aMe=Ht.object({type:Ht.literal("pcb_via"),pcb_via_id:i1("pcb_via"),x:mc,y:mc,outer_diameter:mc.default("0.6mm"),hole_diameter:mc.default("0.25mm"),from_layer:H9.optional(),to_layer:H9.optional(),layers:Ht.array(H9),pcb_trace_id:Ht.string().optional()}).describe("Defines a via on the PCB"),oMe=Ht.object({type:Ht.literal("pcb_board"),pcb_board_id:i1("pcb_board"),width:f_,height:f_,center:Qy,thickness:f_.optional().default(1.4),num_layers:Ht.number().optional().default(4),outline:Ht.array(Qy).optional()}).describe("Defines the board outline of the PCB"),sMe=Ht.object({type:Ht.literal("pcb_placement_error"),pcb_placement_error_id:i1("pcb_placement_error"),message:Ht.string()}).describe("Defines a placement error on the PCB"),lMe=Ht.object({type:Ht.literal("pcb_trace_hint"),pcb_trace_hint_id:i1("pcb_trace_hint"),pcb_port_id:Ht.string(),pcb_component_id:Ht.string(),route:Ht.array(GTe)}).describe("A hint that can be used during generation of a PCB trace"),cMe=Ht.object({type:Ht.literal("pcb_silkscreen_line"),pcb_silkscreen_line_id:i1("pcb_silkscreen_line"),pcb_component_id:Ht.string(),stroke_width:mc.default("0.1mm"),x1:mc,y1:mc,x2:mc,y2:mc,layer:C6}).describe("Defines a silkscreen line on the PCB"),uMe=Ht.object({type:Ht.literal("pcb_silkscreen_path"),pcb_silkscreen_path_id:i1("pcb_silkscreen_path"),pcb_component_id:Ht.string(),layer:C6,route:Ht.array(Qy),stroke_width:f_}).describe("Defines a silkscreen path on the PCB"),fMe=Ht.object({type:Ht.literal("pcb_silkscreen_text"),pcb_silkscreen_text_id:i1("pcb_silkscreen_text"),font:Ht.literal("tscircuit2024").default("tscircuit2024"),font_size:mc.default("0.2mm"),pcb_component_id:Ht.string(),text:Ht.string(),ccw_rotation:Ht.number().optional(),layer:H9,is_mirrored:Ht.boolean().default(!1).optional(),anchor_position:Qy.default({x:0,y:0}),anchor_alignment:Ht.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center")}).describe("Defines silkscreen text on the PCB"),dMe=Ht.object({type:Ht.literal("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:i1("pcb_silkscreen_rect"),pcb_component_id:Ht.string(),center:Qy,width:f_,height:f_,layer:H9}).describe("Defines a silkscreen rect on the PCB"),hMe=Ht.object({type:Ht.literal("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:i1("pcb_silkscreen_circle"),pcb_component_id:Ht.string(),center:Qy,radius:f_,layer:C6}).describe("Defines a silkscreen circle on the PCB"),pMe=Ht.object({type:Ht.literal("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:i1("pcb_silkscreen_oval"),pcb_component_id:Ht.string(),center:Qy,radius_x:mc,radius_y:mc,layer:C6}).describe("Defines a silkscreen oval on the PCB"),mMe=Ht.object({type:Ht.literal("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:i1("pcb_fabrication_note_text"),font:Ht.literal("tscircuit2024").default("tscircuit2024"),font_size:mc.default("1mm"),pcb_component_id:Ht.string(),text:Ht.string(),layer:C6,anchor_position:Qy.default({x:0,y:0}),anchor_alignment:Ht.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Ht.string().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),vMe=Ht.object({type:Ht.literal("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:i1("pcb_fabrication_note_path"),pcb_component_id:Ht.string(),layer:H9,route:Ht.array(Qy),stroke_width:f_,color:Ht.string().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),yMe=Ht.object({type:Ht.literal("pcb_keepout"),shape:Ht.literal("rect"),center:Qy,width:mc,height:mc,pcb_keepout_id:Ht.string(),layers:Ht.array(Ht.string()),description:Ht.string().optional()}).or(Ht.object({type:Ht.literal("pcb_keepout"),shape:Ht.literal("circle"),center:Qy,radius:mc,pcb_keepout_id:Ht.string(),layers:Ht.array(Ht.string()),description:Ht.string().optional()})),gMe=Ht.object({type:Ht.literal("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:i1("pcb_missing_footprint_error"),error_type:Ht.literal("pcb_missing_footprint_error"),source_component_id:Ht.string(),message:Ht.string()}).describe("Defines a missing footprint error on the PCB"),_Me=Ht.object({type:Ht.literal("pcb_manual_edit_conflict_error"),pcb_error_id:i1("pcb_manual_edit_conflict_error"),message:Ht.string(),pcb_component_id:Ht.string(),source_component_id:Ht.string()}).describe("Error emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),xMe=Ht.object({type:Ht.literal("pcb_group"),pcb_group_id:i1("pcb_group"),width:f_,height:f_,center:Qy,pcb_component_ids:Ht.array(Ht.string()),name:Ht.string().optional(),description:Ht.string().optional()}).describe("Defines a group of components on the PCB"),bMe=Ht.object({type:Ht.literal("cad_component"),cad_component_id:Ht.string(),pcb_component_id:Ht.string(),source_component_id:Ht.string(),position:hC,rotation:hC.optional(),size:hC.optional(),layer:H9.optional(),footprinter_string:Ht.string().optional(),model_obj_url:Ht.string().optional(),model_stl_url:Ht.string().optional(),model_3mf_url:Ht.string().optional(),model_jscad:Ht.any().optional()}).describe("Defines a component on the PCB"),SMe=Ht.union([STe,bTe,xTe,bJ,wTe,ETe,_J,xJ,yJ,gO,gJ,SJ,EJ,wJ,CJ,RJ,AJ,PJ,MJ,TJ,qTe,WTe,gMe,_Me,$Te,yMe,ZTe,JTe,nMe,aMe,QTe,KTe,oMe,xMe,lMe,cMe,uMe,fMe,dMe,hMe,pMe,rMe,sMe,iMe,vMe,mMe,TTe,OTe,NTe,DTe,zTe,LTe,MTe,kTe,UTe,HTe,VTe,bMe]),EMe=SMe,NJ=(r,e={})=>{let t=r._internal_store;if(!t){t={counts:{}},r._internal_store=t;for(const i of r){const a=i.type,o=i[`${a}_id`];if(!o)continue;const s=Number.parseInt(o.split("_").pop());Number.isNaN(s)||(t.counts[a]=Math.max(t.counts[a]??0,s))}}return new Proxy({},{get:(i,a)=>a==="toArray"?()=>r:{get:o=>r.find(s=>s.type===a&&s[`${a}_id`]===o),getUsing:o=>{const s=Object.keys(o);if(s.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const l=s[0],c=l.replace("_id",""),u=r.find(d=>d.type===c&&d[l]===o[l]);return u?r.find(d=>d.type===a&&d[`${a}_id`]===u[`${a}_id`]):null},getWhere:o=>{const s=Object.keys(o);return r.find(l=>l.type===a&&s.every(c=>l[c]===o[c]))},list:o=>{const s=o?Object.keys(o):[];return r.filter(l=>l.type===a&&s.every(c=>l[c]===o[c]))},insert:o=>{var c;(c=t.counts)[a]??(c[a]=-1),t.counts[a]++;const s=t.counts[a],l={type:a,[`${a}_id`]:`${a}_${s}`,...o};return e.validateInserts&&(Z6e[a]??EMe).parse(l),r.push(l),l},delete:o=>{const s=r.find(l=>l[`${a}_id`]===o);s&&r.splice(r.indexOf(s),1)},update:(o,s)=>{const l=r.find(c=>c.type===a&&c[`${a}_id`]===o);if(l)return Object.assign(l,s),l},select:o=>{if(a==="source_component")return r.find(s=>s.type==="source_component"&&s.name===o.replace(/\./g,""));if(a==="pcb_port"||a==="source_port"||a==="schematic_port"){const[s,l]=o.replace(/\./g,"").split(/[\s\>]+/),c=r.find(d=>d.type==="source_component"&&d.name===s);if(!c)return null;const u=r.find(d=>d.type==="source_port"&&d.source_component_id===c.source_component_id&&(d.name===l||(d.port_hints??[]).includes(l)));if(!u)return null;if(a==="source_port")return u;if(a==="pcb_port")return r.find(d=>d.type==="pcb_port"&&d.source_port_id===u.source_port_id);if(a==="schematic_port")return r.find(d=>d.type==="schematic_port"&&d.source_port_id===u.source_port_id)}}}})};NJ.unparsed=NJ;var qS=NJ,t4t=(r,e)=>{if(r.type==="pcb_plated_hole"||r.type==="pcb_hole"||r.type==="pcb_via"||r.type==="pcb_smtpad"||r.type==="pcb_port"){const{x:t,y:n}=_i(e,{x:r.x,y:r.y});r.x=t,r.y=n}else if(r.type==="pcb_keepout"||r.type==="pcb_board")r.center=_i(e,r.center);else if(r.type==="pcb_silkscreen_text"||r.type==="pcb_fabrication_note_text")r.anchor_position=_i(e,r.anchor_position);else if(r.type==="pcb_silkscreen_circle"||r.type==="pcb_silkscreen_rect"||r.type==="pcb_component")r.center=_i(e,r.center);else if(r.type==="pcb_silkscreen_path"||r.type==="pcb_trace"||r.type==="pcb_fabrication_note_path")r.route=r.route.map(t=>{const n=_i(e,t);return t.x=n.x,t.y=n.y,t});else if(r.type==="pcb_silkscreen_line"){const t={x:r.x1,y:r.y1},n={x:r.x2,y:r.y2},i=_i(e,t),a=_i(e,n);r.x1=i.x,r.y1=i.y,r.x2=a.x,r.y2=a.y}else if(r.type==="cad_component"){const t=_i(e,{x:r.position.x,y:r.position.y});r.position.x=t.x,r.position.y=t.y}return r};function n4t(r){let e=0;if(r.length==0)return e;for(var t=0;t<r.length;t++){var n=r.charCodeAt(t);e=(e<<5)-e+n,e=e&e}return Math.abs(e)}var wMe=[["#69d2e7","#a7dbd8","#e0e4cc","#f38630","#fa6900"],["#fe4365","#fc9d9a","#f9cdad","#c8c8a9","#83af9b"],["#ecd078","#d95b43","#c02942","#542437","#53777a"],["#556270","#4ecdc4","#c7f464","#ff6b6b","#c44d58"],["#774f38","#e08e79","#f1d4af","#ece5ce","#c5e0dc"],["#e8ddcb","#cdb380","#036564","#033649","#031634"],["#490a3d","#bd1550","#e97f02","#f8ca00","#8a9b0f"],["#594f4f","#547980","#45ada8","#9de0ad","#e5fcc2"],["#00a0b0","#6a4a3c","#cc333f","#eb6841","#edc951"],["#e94e77","#d68189","#c6a49a","#c6e5d9","#f4ead5"],["#3fb8af","#7fc7af","#dad8a7","#ff9e9d","#ff3d7f"],["#d9ceb2","#948c75","#d5ded9","#7a6a53","#99b2b7"],["#ffffff","#cbe86b","#f2e9e1","#1c140d","#cbe86b"],["#efffcd","#dce9be","#555152","#2e2633","#99173c"],["#343838","#005f6b","#008c9e","#00b4cc","#00dffc"],["#413e4a","#73626e","#b38184","#f0b49e","#f7e4be"],["#ff4e50","#fc913a","#f9d423","#ede574","#e1f5c4"],["#99b898","#fecea8","#ff847c","#e84a5f","#2a363b"],["#655643","#80bca3","#f6f7bd","#e6ac27","#bf4d28"],["#00a8c6","#40c0cb","#f9f2e7","#aee239","#8fbe00"],["#351330","#424254","#64908a","#e8caa4","#cc2a41"],["#554236","#f77825","#d3ce3d","#f1efa5","#60b99a"],["#5d4157","#838689","#a8caba","#cad7b2","#ebe3aa"],["#8c2318","#5e8c6a","#88a65e","#bfb35a","#f2c45a"],["#fad089","#ff9c5b","#f5634a","#ed303c","#3b8183"],["#ff4242","#f4fad2","#d4ee5e","#e1edb9","#f0f2eb"],["#f8b195","#f67280","#c06c84","#6c5b7b","#355c7d"],["#d1e751","#ffffff","#000000","#4dbce9","#26ade4"],["#1b676b","#519548","#88c425","#bef202","#eafde6"],["#5e412f","#fcebb6","#78c0a8","#f07818","#f0a830"],["#bcbdac","#cfbe27","#f27435","#f02475","#3b2d38"],["#452632","#91204d","#e4844a","#e8bf56","#e2f7ce"],["#eee6ab","#c5bc8e","#696758","#45484b","#36393b"],["#f0d8a8","#3d1c00","#86b8b1","#f2d694","#fa2a00"],["#2a044a","#0b2e59","#0d6759","#7ab317","#a0c55f"],["#f04155","#ff823a","#f2f26f","#fff7bd","#95cfb7"],["#b9d7d9","#668284","#2a2829","#493736","#7b3b3b"],["#bbbb88","#ccc68d","#eedd99","#eec290","#eeaa88"],["#b3cc57","#ecf081","#ffbe40","#ef746f","#ab3e5b"],["#a3a948","#edb92e","#f85931","#ce1836","#009989"],["#300030","#480048","#601848","#c04848","#f07241"],["#67917a","#170409","#b8af03","#ccbf82","#e33258"],["#aab3ab","#c4cbb7","#ebefc9","#eee0b7","#e8caaf"],["#e8d5b7","#0e2430","#fc3a51","#f5b349","#e8d5b9"],["#ab526b","#bca297","#c5ceae","#f0e2a4","#f4ebc3"],["#607848","#789048","#c0d860","#f0f0d8","#604848"],["#b6d8c0","#c8d9bf","#dadabd","#ecdbbc","#fedcba"],["#a8e6ce","#dcedc2","#ffd3b5","#ffaaa6","#ff8c94"],["#3e4147","#fffedf","#dfba69","#5a2e2e","#2a2c31"],["#fc354c","#29221f","#13747d","#0abfbc","#fcf7c5"],["#cc0c39","#e6781e","#c8cf02","#f8fcc1","#1693a7"],["#1c2130","#028f76","#b3e099","#ffeaad","#d14334"],["#a7c5bd","#e5ddcb","#eb7b59","#cf4647","#524656"],["#dad6ca","#1bb0ce","#4f8699","#6a5e72","#563444"],["#5c323e","#a82743","#e15e32","#c0d23e","#e5f04c"],["#edebe6","#d6e1c7","#94c7b6","#403b33","#d3643b"],["#fdf1cc","#c6d6b8","#987f69","#e3ad40","#fcd036"],["#230f2b","#f21d41","#ebebbc","#bce3c5","#82b3ae"],["#b9d3b0","#81bda4","#b28774","#f88f79","#f6aa93"],["#3a111c","#574951","#83988e","#bcdea5","#e6f9bc"],["#5e3929","#cd8c52","#b7d1a3","#dee8be","#fcf7d3"],["#1c0113","#6b0103","#a30006","#c21a01","#f03c02"],["#000000","#9f111b","#b11623","#292c37","#cccccc"],["#382f32","#ffeaf2","#fcd9e5","#fbc5d8","#f1396d"],["#e3dfba","#c8d6bf","#93ccc6","#6cbdb5","#1a1f1e"],["#f6f6f6","#e8e8e8","#333333","#990100","#b90504"],["#1b325f","#9cc4e4","#e9f2f9","#3a89c9","#f26c4f"],["#a1dbb2","#fee5ad","#faca66","#f7a541","#f45d4c"],["#c1b398","#605951","#fbeec2","#61a6ab","#accec0"],["#5e9fa3","#dcd1b4","#fab87f","#f87e7b","#b05574"],["#951f2b","#f5f4d7","#e0dfb1","#a5a36c","#535233"],["#8dccad","#988864","#fea6a2","#f9d6ac","#ffe9af"],["#2d2d29","#215a6d","#3ca2a2","#92c7a3","#dfece6"],["#413d3d","#040004","#c8ff00","#fa023c","#4b000f"],["#eff3cd","#b2d5ba","#61ada0","#248f8d","#605063"],["#ffefd3","#fffee4","#d0ecea","#9fd6d2","#8b7a5e"],["#cfffdd","#b4dec1","#5c5863","#a85163","#ff1f4c"],["#9dc9ac","#fffec7","#f56218","#ff9d2e","#919167"],["#4e395d","#827085","#8ebe94","#ccfc8e","#dc5b3e"],["#a8a7a7","#cc527a","#e8175d","#474747","#363636"],["#f8edd1","#d88a8a","#474843","#9d9d93","#c5cfc6"],["#046d8b","#309292","#2fb8ac","#93a42a","#ecbe13"],["#f38a8a","#55443d","#a0cab5","#cde9ca","#f1edd0"],["#a70267","#f10c49","#fb6b41","#f6d86b","#339194"],["#ff003c","#ff8a00","#fabe28","#88c100","#00c176"],["#ffedbf","#f7803c","#f54828","#2e0d23","#f8e4c1"],["#4e4d4a","#353432","#94ba65","#2790b0","#2b4e72"],["#0ca5b0","#4e3f30","#fefeeb","#f8f4e4","#a5b3aa"],["#4d3b3b","#de6262","#ffb88c","#ffd0b3","#f5e0d3"],["#fffbb7","#a6f6af","#66b6ab","#5b7c8d","#4f2958"],["#edf6ee","#d1c089","#b3204d","#412e28","#151101"],["#9d7e79","#ccac95","#9a947c","#748b83","#5b756c"],["#fcfef5","#e9ffe1","#cdcfb7","#d6e6c3","#fafbe3"],["#9cddc8","#bfd8ad","#ddd9ab","#f7af63","#633d2e"],["#30261c","#403831","#36544f","#1f5f61","#0b8185"],["#aaff00","#ffaa00","#ff00aa","#aa00ff","#00aaff"],["#d1313d","#e5625c","#f9bf76","#8eb2c5","#615375"],["#ffe181","#eee9e5","#fad3b2","#ffba7f","#ff9c97"],["#73c8a9","#dee1b6","#e1b866","#bd5532","#373b44"],["#805841","#dcf7f3","#fffcdd","#ffd8d8","#f5a2a2"]],r4t=r=>{var s,l,c;let{x:e,y:t,width:n,height:i}={...r,...r.size,...r.center,...r.position};r.x1!==void 0&&r.x2!==void 0&&r.y1!==void 0&&r.y2!==void 0&&(e=(r.x1+r.x2)/2,t=(r.y1+r.y2)/2,n=Math.abs(r.x1-r.x2),i=Math.abs(r.y1-r.y2));const a=r.text||r.name||((s=r.source)==null?void 0:s.text)||((l=r.source)==null?void 0:l.name)||"?",o=r;return e===void 0||t===void 0?null:(n===void 0&&"outer_diameter"in r&&(n=r.outer_diameter,i=r.outer_diameter),(n===void 0||i===void 0)&&(n=.1,i=.1),{x:e,y:t,width:n,height:i,title:a,content:o,bg_color:((c=wMe[n4t(r.type||a)%wMe.length])==null?void 0:c[4])??"#f00"})},i4t=r=>!!r,a4t=r=>{const e=r.filter(c=>c.type.startsWith("pcb_")).concat(r.filter(c=>c.type==="pcb_trace").flatMap(c=>c.route)).map(c=>r4t(c)).filter(i4t);if(e.length===0)return{center:{x:0,y:0},width:0,height:0};let t=e[0].x-e[0].width/2,n=e[0].x+e[0].width/2,i=e[0].y-e[0].height/2,a=e[0].y+e[0].height/2;for(const c of e.slice(1))t=Math.min(t,c.x-c.width/2),n=Math.max(n,c.x+c.width/2),i=Math.min(i,c.y-c.height/2),a=Math.max(a,c.y+c.height/2);const o=n-t,s=a-i;return{center:{x:t+o/2,y:i+s/2},width:o,height:s}},o4t=(r={})=>wct(e=>({selected_layer:"top",pcb_viewer_id:`pcb_viewer_${Math.random().toString().slice(2,10)}`,in_edit_mode:!1,in_move_footprint_mode:!1,in_draw_trace_mode:!1,is_moving_component:!1,is_drawing_trace:!1,is_mouse_over_container:!1,is_showing_multiple_traces_length:!1,is_showing_rats_nest:!1,...r,selectLayer:t=>e({selected_layer:t}),setEditMode:t=>e({in_edit_mode:t!=="off",in_move_footprint_mode:t==="move_footprint",in_draw_trace_mode:t==="draw_trace",is_moving_component:!1,is_drawing_trace:!1}),setIsShowingRatsNest:t=>e({is_showing_rats_nest:t}),setIsMovingComponent:t=>e({is_moving_component:t}),setIsDrawingTrace:t=>e({is_drawing_trace:t}),setIsMouseOverContainer:t=>e({is_mouse_over_container:t}),setIsShowingMultipleTracesLength:t=>e({is_showing_multiple_traces_length:t})})),f2=r=>{const e=Ct.useContext(TMe);return Uct(e,r)},TMe=Ct.createContext(null),s4t=({children:r,initialState:e})=>{const t=Ct.useMemo(()=>o4t(e),[]);return _t.jsx(TMe.Provider,{value:t,children:r})},l4t=(r,e)=>{if(r.find(n=>n.type==="pcb_trace_hint"&&n.pcb_trace_hint_id===e.pcb_trace_hint_id))r=r.map(n=>n.pcb_trace_hint_id===e.pcb_trace_hint_id?{...n,route:e.route}:n);else{const n=qS(r).pcb_port.get(e.pcb_port_id);r=r.filter(i=>!(i.type==="pcb_trace_hint"&&i.pcb_port_id===e.pcb_port_id)).concat([{type:"pcb_trace_hint",pcb_trace_hint_id:e.pcb_trace_hint_id,route:e.route,pcb_port_id:e.pcb_port_id,pcb_component_id:n==null?void 0:n.pcb_component_id}])}return r},c4t=(r,e)=>{r=JSON.parse(JSON.stringify(r));for(const t of e)if(t.pcb_edit_event_type==="edit_component_location"){const n=iv(t.new_center.x-t.original_center.x,t.new_center.y-t.original_center.y);r=r.map(i=>i.pcb_component_id!==t.pcb_component_id?i:t4t(i,n))}else t.pcb_edit_event_type==="edit_trace_hint"&&(r=l4t(r,t));return r},u4t=()=>{const r=f2(t=>t.pcb_viewer_id),e=(t,n)=>Py(t,{containerId:r,...n});return e.error=(t,n)=>Py.error(t,{containerId:r,...n}),e.promise=Py.promise,e},f4t=()=>{Ct.useEffect(()=>{N2t()},[]);const r=f2(e=>e.pcb_viewer_id);return _t.jsx(D2t,{position:"top-center",containerId:r})},d4t=function(){},MMe=typeof window<"u",h4t=MMe?Ct.useLayoutEffect:Ct.useEffect,p4t=h4t,CMe={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function m4t(){var r=Ct.useState(null),e=r[0],t=r[1],n=Ct.useState(CMe),i=n[0],a=n[1],o=Ct.useMemo(function(){return new window.ResizeObserver(function(s){if(s[0]){var l=s[0].contentRect,c=l.x,u=l.y,d=l.width,g=l.height,_=l.top,x=l.left,T=l.bottom,M=l.right;a({x:c,y:u,width:d,height:g,top:_,left:x,bottom:T,right:M})}})},[]);return p4t(function(){if(e)return o.observe(e),function(){o.disconnect()}},[e]),[t,i]}var v4t=MMe&&typeof window.ResizeObserver<"u"?m4t:function(){return[d4t,CMe]},y4t=(r={})=>{const e=Ct.useRef(null),[t,n]=Ct.useState(0),i=r.canvasElm??e.current,[a,o]=Ct.useState(r.initialTransform??D_()),[s,l]=Ct.useState(0),[c,u]=Ct.useReducer(M=>M+1,0),d=Ct.useCallback(M=>{r.onSetTransform&&r.onSetTransform(M),r.transform||o(M)},[r.onSetTransform,o]),g=Ct.useCallback(M=>{d(M),u()},[d]),_=r.transform??a,x=Ct.useCallback(()=>{n(Date.now())},[]);Ct.useEffect(()=>{const M=r.canvasElm??e.current;if(M&&!i){l(s+1);return}if(!M){const me=setTimeout(()=>{l(s+1)},100);return()=>clearTimeout(me)}let R=r.transform??a,L={x:0,y:0},z={x:0,y:0},j=!1;const Z=me=>({x:me.pageX-M.getBoundingClientRect().left-window.scrollX,y:me.pageY-M.getBoundingClientRect().top-window.scrollY});function ee(me){r.enabled!==!1&&(r.shouldDrag&&!r.shouldDrag(me)||(L=Z(me),!(Date.now()-t<100)&&(j=!0,me.preventDefault())))}function W(me){if(!j||r.enabled===!1||r.shouldDrag&&!r.shouldDrag(me))return;z=Z(me);const _e=ch(iv(z.x-L.x,z.y-L.y),R);d(_e),R=_e,j=!1}function se(me){Z(me),!(!j||r.enabled===!1)&&(r.shouldDrag&&!r.shouldDrag(me)||(z=Z(me),d(ch(iv(z.x-L.x,z.y-L.y),R))))}function ae(me){if(r.enabled===!1||r.shouldDrag&&!r.shouldDrag(me))return;const _e=Z(me),Se=ch(iv(_e.x,_e.y),M2(1-me.deltaY/1e3,1-me.deltaY/1e3),iv(-_e.x,-_e.y),R);d(Se),R=Se,me.preventDefault()}function ue(me){if(!j||r.shouldDrag&&!r.shouldDrag(me))return;if(M){const Se=M.getBoundingClientRect();if(me.clientX>=Se.left+10&&me.clientX<=Se.right-10&&me.clientY>=Se.top+10&&me.clientY<=Se.bottom-10)return}j=!1,z=Z(me);const _e=ch(iv(z.x-L.x,z.y-L.y),R);d(_e),R=_e}return M.addEventListener("mousedown",ee),M.addEventListener("mouseup",W),window.addEventListener("mousemove",se),M.addEventListener("mouseout",ue),M.addEventListener("wheel",ae),()=>{M.removeEventListener("mousedown",ee),M.removeEventListener("mouseup",W),window.removeEventListener("mousemove",se),M.removeEventListener("mouseout",ue),M.removeEventListener("wheel",ae)}},[i,s,c,t,r.enabled,r.shouldDrag]);const T=Ct.useCallback(M=>_i(_,M),[_]);return{ref:e,transform:_,applyTransformToPoint:T,setTransform:g,cancelDrag:x}},g4t=y4t,c5={"3d_viewer":{background_bottom:"rgb(102, 102, 128)",background_top:"rgb(204, 204, 230)",board:"rgb(51, 43, 23)",copper:"rgb(179, 156, 0)",silkscreen_bottom:"rgb(230, 230, 230)",silkscreen_top:"rgb(230, 230, 230)",soldermask:"rgb(20, 51, 36)",solderpaste:"rgb(128, 128, 128)"},board:{anchor:"rgb(255, 38, 226)",aux_items:"rgb(255, 255, 255)",b_adhes:"rgb(0, 0, 132)",b_crtyd:"rgb(255, 38, 226)",b_fab:"rgb(88, 93, 132)",b_mask:"rgba(2, 255, 238, 0.400)",b_paste:"rgb(0, 194, 194)",b_silks:"rgb(232, 178, 167)",background:"rgb(0, 16, 35)",cmts_user:"rgb(89, 148, 220)",copper:{b:"rgb(77, 127, 196)",f:"rgb(200, 52, 52)",in1:"rgb(127, 200, 127)",in10:"rgb(237, 124, 51)",in11:"rgb(91, 195, 235)",in12:"rgb(247, 111, 142)",in13:"rgb(167, 165, 198)",in14:"rgb(40, 204, 217)",in15:"rgb(232, 178, 167)",in16:"rgb(242, 237, 161)",in17:"rgb(237, 124, 51)",in18:"rgb(91, 195, 235)",in19:"rgb(247, 111, 142)",in2:"rgb(206, 125, 44)",in20:"rgb(167, 165, 198)",in21:"rgb(40, 204, 217)",in22:"rgb(232, 178, 167)",in23:"rgb(242, 237, 161)",in24:"rgb(237, 124, 51)",in25:"rgb(91, 195, 235)",in26:"rgb(247, 111, 142)",in27:"rgb(167, 165, 198)",in28:"rgb(40, 204, 217)",in29:"rgb(232, 178, 167)",in3:"rgb(79, 203, 203)",in30:"rgb(242, 237, 161)",in4:"rgb(219, 98, 139)",in5:"rgb(167, 165, 198)",in6:"rgb(40, 204, 217)",in7:"rgb(232, 178, 167)",in8:"rgb(242, 237, 161)",in9:"rgb(141, 203, 129)"},cursor:"rgb(255, 255, 255)",drc:"rgb(194, 194, 194)",drc_error:"rgba(215, 91, 107, 0.800)",drc_exclusion:"rgb(255, 255, 255)",drc_warning:"rgba(255, 208, 66, 0.902)",dwgs_user:"rgb(194, 194, 194)",eco1_user:"rgb(180, 219, 210)",eco2_user:"rgb(216, 200, 82)",edge_cuts:"rgb(208, 210, 205)",f_adhes:"rgb(132, 0, 132)",f_crtyd:"rgb(255, 0, 245)",f_fab:"rgb(175, 175, 175)",f_mask:"rgba(216, 100, 255, 0.400)",f_paste:"rgba(180, 160, 154, 0.902)",f_silks:"rgb(242, 237, 161)",footprint_text_back:"rgb(0, 0, 132)",footprint_text_front:"rgb(194, 194, 194)",footprint_text_invisible:"rgb(132, 132, 132)",grid:"rgb(132, 132, 132)",grid_axes:"rgb(194, 194, 194)",margin:"rgb(255, 38, 226)",microvia:"rgb(0, 132, 132)",no_connect:"rgb(0, 0, 132)",pad_back:"rgb(77, 127, 196)",pad_front:"rgb(200, 52, 52)",pad_plated_hole:"rgb(194, 194, 0)",pad_through_hole:"rgb(227, 183, 46)",plated_hole:"rgb(26, 196, 210)",ratsnest:"rgba(245, 255, 213, 0.702)",select_overlay:"rgb(4, 255, 67)",through_via:"rgb(236, 236, 236)",user_1:"rgb(194, 194, 194)",user_2:"rgb(89, 148, 220)",user_3:"rgb(180, 219, 210)",user_4:"rgb(216, 200, 82)",user_5:"rgb(194, 194, 194)",user_6:"rgb(89, 148, 220)",user_7:"rgb(180, 219, 210)",user_8:"rgb(216, 200, 82)",user_9:"rgb(232, 178, 167)",via_blind_buried:"rgb(187, 151, 38)",via_hole:"rgb(227, 183, 46)",via_micro:"rgb(0, 132, 132)",via_through:"rgb(236, 236, 236)",worksheet:"rgb(200, 114, 171)"},gerbview:{axes:"rgb(0, 0, 132)",background:"rgb(0, 0, 0)",dcodes:"rgb(255, 255, 255)",grid:"rgb(132, 132, 132)",layers:["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)"],negative_objects:"rgb(132, 132, 132)",worksheet:"rgb(0, 0, 132)"},palette:["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)"],schematic:{anchor:"rgb(0, 0, 255)",aux_items:"rgb(0, 0, 0)",background:"rgb(33, 33, 33)",brightened:"rgb(204, 204, 204)",bus:"rgb(0, 96, 192)",bus_junction:"rgb(0, 96, 192)",component_body:"rgb(44, 44, 44)",component_outline:"rgb(192, 0, 0)",cursor:"rgb(224, 224, 224)",erc_error:"rgba(192, 48, 48, 0.800)",erc_warning:"rgba(192, 140, 0, 0.800)",fields:"rgb(128, 0, 160)",grid:"rgb(60, 60, 60)",grid_axes:"rgb(60, 60, 60)",hidden:"rgb(194, 194, 194)",junction:"rgb(0, 160, 0)",label_global:"rgb(0, 160, 224)",label_hier:"rgb(160, 160, 0)",label_local:"rgb(192, 192, 192)",net_name:"rgb(224, 224, 224)",no_connect:"rgb(97, 43, 224)",note:"rgb(192, 192, 0)",override_item_colors:!1,pin:"rgb(192, 0, 0)",pin_name:"rgb(192, 192, 192)",pin_number:"rgb(192, 0, 0)",reference:"rgb(192, 192, 192)",shadow:"rgba(102, 179, 255, 0.800)",sheet:"rgb(128, 0, 160)",sheet_background:"rgba(255, 255, 255, 0.000)",sheet_fields:"rgb(160, 160, 0)",sheet_filename:"rgb(160, 160, 0)",sheet_label:"rgb(160, 160, 0)",sheet_name:"rgb(0, 160, 204)",value:"rgb(192, 192, 192)",wire:"rgb(0, 160, 0)",worksheet:"rgb(192, 0, 0)"}},l4=(r,e=1)=>{if(Math.abs(r.a)!==Math.abs(r.d))throw new Error("Cannot scale non-uniformly");return e*Math.abs(r.a)},wb={elementOverlay:30,dimensionOverlay:30,editTraceHintOverlay:30,errorOverlay:30,ratsNestOverlay:20,toolbarOverlay:20,topLayer:10},R6={red:"red",black:"black",green:"green",board:"rgb(255, 255, 255)",other:"#eee",top:c5.board.copper.f,inner1:c5.board.copper.in1,inner2:c5.board.copper.in2,inner4:c5.board.copper.in4,inner5:c5.board.copper.in5,inner6:c5.board.copper.in6,inner7:c5.board.copper.in7,inner8:c5.board.copper.in8,bottom:c5.board.copper.b,drill:c5.board.anchor,keepout:c5.board.background,tkeepout:c5.board.b_crtyd,tplace:c5.board.b_silks,top_silkscreen:c5.board.f_silks,bottom_silkscreen:c5.board.b_silks,top_fabrication:c5.board.f_fab,bottom_fabrication:c5.board.b_fab,...c5.board},_4t=["top","inner1","inner2","inner3","inner4","inner5","inner6","bottom"],x4t=class{constructor(r){ui(this,"canvasLayerMap");ui(this,"ctxLayerMap");ui(this,"aperture");ui(this,"transform");ui(this,"foregroundLayer","top");ui(this,"lastPoint");this.canvasLayerMap=r,this.ctxLayerMap=Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t.getContext("2d")])),this.transform=D_(),this.transform.d*=-1,this.transform=ch(this.transform,iv(0,-500)),this.lastPoint={x:0,y:0},this.equip({})}clear(){for(const r of Object.values(this.ctxLayerMap))r.clearRect(0,0,r.canvas.width,r.canvas.height)}equip(r){this.aperture={fontSize:0,shape:"circle",mode:"add",size:0,color:"red",layer:"top",opacity:this.foregroundLayer===r.color?1:.5,...r}}drawMeshPattern(r,e,t,n,i,a=45){const o=this.getLayerCtx(),[s,l]=_i(this.transform,[r,e]),[c,u]=_i(this.transform,[r+t,e+n]),d=l4(this.transform,i);o.lineWidth=1,o.strokeStyle=this.aperture.color;const g=_=>{const x=Math.sin(_),T=Math.cos(_),M=Math.sqrt(Math.pow(c-s,2)+Math.pow(u-l,2));for(let R=-M;R<=M;R+=d)o.beginPath(),o.moveTo(s+R*T-M*x,l+R*x+M*T),o.lineTo(s+R*T+M*x,l+R*x-M*T),o.stroke()};g(a*Math.PI/180),g((a+90)*Math.PI/180)}rect(r,e,t,n,i){const[a,o]=_i(this.transform,[r-t/2,e-n/2]),[s,l]=_i(this.transform,[r+t/2,e+n/2]);this.applyAperture();const c=this.getLayerCtx();i?(c.save(),c.beginPath(),c.rect(a,o,s-a,l-o),c.clip(),this.drawMeshPattern(r-t/2,e-n/2,t,n,.15),c.restore(),c.strokeRect(a,o,s-a,l-o)):c.fillRect(a,o,s-a,l-o)}rotatedRect(r,e,t,n,i,a){const o=this.getLayerCtx();this.applyAperture();const[s,l]=_i(this.transform,[r-t/2,e-n/2]),[c,u]=_i(this.transform,[r+t/2,e+n/2]);o.save();const[d,g]=_i(this.transform,[r,e]);o.translate(d,g);const _=360-i;i&&o.rotate(_*Math.PI/180),o.translate(-d,-g),a?(o.beginPath(),o.rect(s,l,c-s,u-l),o.clip(),this.drawMeshPattern(r-t/2,e-n/2,t,n,.15),o.strokeRect(s,l,c-s,u-l)):o.fillRect(s,l,c-s,u-l),o.restore()}circle(r,e,t,n){const i=l4(this.transform,t),[a,o]=_i(this.transform,[r,e]);this.applyAperture();const s=this.getLayerCtx();n?(s.save(),s.beginPath(),s.arc(a,o,i,0,2*Math.PI),s.clip(),this.drawMeshPattern(r-t,e-t,t*2,t*2,.15),s.restore(),s.beginPath(),s.arc(a,o,i,0,2*Math.PI),s.stroke()):(s.beginPath(),s.arc(a,o,i,0,2*Math.PI),s.fill())}oval(r,e,t,n){const i=l4(this.transform,t),a=l4(this.transform,n),[o,s]=_i(this.transform,[r,e]);this.applyAperture();const l=this.getLayerCtx();l.beginPath(),l.ellipse(o,s,i,a,0,0,2*Math.PI),l.fill(),l.closePath()}pill(r,e,t,n){const[i,a]=_i(this.transform,[r-t/2,e+n/2]),o=l4(this.transform,t),s=l4(this.transform,n),l=Math.min(o,s)/2;this.applyAperture();const c=this.getLayerCtx();c.beginPath(),c.arc(i+l,a+l,l,Math.PI,Math.PI*1.5),c.arc(i+o-l,a+l,l,Math.PI*1.5,0),c.arc(i+o-l,a+s-l,l,0,Math.PI*.5),c.arc(i+l,a+s-l,l,Math.PI*.5,Math.PI),c.fill(),c.closePath()}polygon(r){if(r.length<3)return;this.applyAperture();const e=this.getLayerCtx(),t=r.map(i=>_i(this.transform,[i.x,i.y]));e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let i=1;i<t.length;i++)e.lineTo(t[i][0],t[i][1]);e.closePath(),e.fill();const n=l4(this.transform,this.aperture.size);e.lineWidth=n,e.stroke()}debugText(r,e,t){const[n,i]=_i(this.transform,[e,t]);this.applyAperture();const a=this.getLayerCtx();a.font="10px sans-serif",a.fillText(r,n,i)}getLayerCtx(){const r=this.ctxLayerMap[this.aperture.layer];if(!r)throw new Error(`No context for layer "${this.aperture.layer}"`);return r}orderAndFadeLayers(){const{canvasLayerMap:r,foregroundLayer:e}=this,t=new Set([e,"drill","other","board"]);["drill","board",e,..._4t.filter(i=>i!==e)].forEach((i,a)=>{const o=r[i];o&&(o.style.zIndex=`${wb.topLayer-a}`,o.style.opacity=t.has(i)?"1":"0.5")})}applyAperture(){const{transform:r,aperture:e}=this;let{size:t,mode:n,color:i,fontSize:a,layer:o}=e;o in this.ctxLayerMap||(this.aperture.layer="other");const s=this.getLayerCtx();if(!s)throw new Error(`No context for layer "${this.foregroundLayer}"`);if(i||(i="undefined"),s.lineWidth=l4(r,t),s.lineCap="round",n==="add"){let l=(i==null?void 0:i[0])==="#"||i!=null&&i.startsWith("rgb")?i:R6[i==null?void 0:i.toLowerCase()]?R6[i==null?void 0:i.toLowerCase()]:null;l===null&&(console.warn(`Color mapping for "${i}" not found`),l="white"),s.fillStyle=l,s.strokeStyle=l}else s.globalCompositeOperation="destination-out",s.fillStyle="rgba(0,0,0,1)",s.strokeStyle="rgba(0,0,0,1)";s.font=`${l4(Fb(r),a)}px sans-serif`}moveTo(r,e){this.lastPoint={x:r,y:e}}lineTo(r,e){const[t,n]=_i(this.transform,[r,e]),{size:i,shape:a,mode:o}=this.aperture,s=l4(this.transform,i);let{lastPoint:l}=this;const c=_i(this.transform,l);this.applyAperture();const u=this.getLayerCtx();a==="square"&&u.fillRect(c.x-s/2,c.y-s/2,s,s),u.beginPath(),u.moveTo(c.x,c.y),u.lineTo(t,n),u.stroke(),u.closePath(),a==="square"&&u.fillRect(t-s/2,n-s/2,s,s),this.lastPoint={x:r,y:e}}};function b4t(r){const{lines:e,anchorPoint:t,ccwRotation:n}=r;if(!n)return e;const i=n*Math.PI/180,a=y3(i),o=ch(iv(t.x,t.y),a,iv(-t.x,-t.y));return _i(o,t),e.map(s=>({...s,x1:_i(o,{x:s.x1,y:s.y1}).x,y1:_i(o,{x:s.x1,y:s.y1}).y,x2:_i(o,{x:s.x2,y:s.y2}).x,y2:_i(o,{x:s.x2,y:s.y2}).y}))}var RMe={0:"M0.4544564813877358 0L0.2723441540828736 0.03592830447352719L0.1086847233315459 0.14528754990019965L0.020630545837255005 0.3040632652221331L0 0.5395277421960205L0.049259221760993496 0.7369487828466779L0.18080513776237842 0.9005494166306564L0.37036887043974215 0.9872116270037247L0.5864663759301132 1L0.8148695622827444 0.9332890276148733L0.9326583645506394 0.8113052246023419L1 0.4031281830668562L0.833288960385582 0.09886798567812842L0.6801767918233781 0.02483708485091681L0.4544564813877358 0",1:"M 0.198 0.272 L 0.537 0 L 0.54 1",2:"M0.069593147751606 0.19461498231706575L0.1039380353319058 0.1224291500164194L0.20543361884368308 0.05510832064153169L0.3717712794432549 0.009452970962689482L0.4785344452623127 0L0.663238590738758 0.008714098643339864L0.8017933618843684 0.04769189395915288L0.8775637379550322 0.10746757678258442L0.9047778372591005 0.17693069668193287L0.9029710920770878 0.2231347105796246L0.8704496788008566 0.30047744598157516L0.7292906538577354 0.4508486051631194L0.3737955032119913 0.7369006417749693L0 1L1 1",3:"M0.03917438899874637 0.19855364635107545L0.15510940508963084 0.06745632622133718L0.37598645522339846 0L0.8486391893813088 0.0652271323161611L0.9782182415054349 0.21747394183735683L0.9213133780517754 0.3547560290117714L0.6504271515903481 0.4543436297681271L0.22975249764129613 0.48476611625264143L0.7659038682744629 0.5411919558122493L0.9258712987734741 0.6203185665660985L1 0.7458360609169667L0.8938813281118737 0.9059190913045964L0.6166890258875837 1L0.261528440153542 0.9874861530507921L0 0.8837289530851273",4:"M0.7328897338403042 0L0 0.6684672518568535L1 0.6684672518568535M0.7243346007604563 0.4530722484807562L0.7243346007604563 1",5:"M 0 0 L 0 0.4973 L 0.4262 0.4319 L 0.7305 0.4565 L 0.8516 0.5009 L 0.9357 0.5639 L 1 0.7356 L 0.9696 0.8248 L 0.8898 0.895 L 0.733 0.9602 L 0.5518 0.9945 L 0.3814 1 L 0.2379 0.9821 L 0.1219 0.947 L 0 0.8748 M 0 0 L 1 0",6:"M0.6964601700926856 0L0.3639239026215478 0.0743562375769351L0.1415931962925719 0.21735490179786915L0.009977939399608712 0.46336322325406004L0.00029622007592593224 0.7083131475173043L0.09408885043224748 0.8746809149767036L0.3379247445101846 0.9876686500961888L0.7109203869569624 1L0.9260852957913362 0.9103558029693921L1 0.7716571969091733L0.9824294723385016 0.6390635485705886L0.7446504992867332 0.4733643097729175L0.31028858071607296 0.47578021640899115L0.1208702146816024 0.5481452483973847L0 0.6616669755788906",7:"M0 0L1 0L0.9246479649697582 0.030539772727272752L0.8850302419354837 0.05075757575757579L0.7922946068548385 0.11079545454545457L0.7419268208165322 0.15213068181818185L0.6907258064516127 0.20202020202020204L0.6400666267641127 0.26122159090909086L0.5913243447580644 0.33049242424242414L0.5458740234374998 0.4105902777777778L0.5050907258064514 0.5022727272727272L0.4703495148689514 0.6062973484848484L0.43257456133442534 0.787133049242424L0.41612903225806447 1",8:"M0.5143001078924863 0L0.16007477667923162 0.10731570786949331L0.14924628550868277 0.3146018498698755L0.2939585848842112 0.41617921794558677L0.8648302624811545 0.5385163833653317L1 0.7775820770511038L0.8180842915260376 0.9505845566922285L0.41968938540525413 1L0.08062381919779889 0.882831681184498L0 0.6936376947135333L0.17150171673893433 0.5188652309607817L0.6529263782780712 0.4242818653203618L0.8650205888491803 0.29644027376796367L0.8702067371119496 0.09910067291661573L0.5143001078924863 0",9:"M1 0.25379591792994305L0.9514789771111742 0.11679361536614272L0.8702482473521467 0.05711741614054847L0.7327445265851579 0.015213872471965633L0.525248180711544 0L0.3292056884418538 0.012928195113745608L0.15997632037247655 0.058762870026191856L0.05266940041228321 0.12882439350476L0 0.2562067822770946L0.11316462894512366 0.4121335905917837L0.2403060136479954 0.4603365890068938L0.4097241967586011 0.4745978388276783L0.8642414300184816 0.420815170259988L0.9732054796346318 0.34537434075898393L1 0.25379591792994305M0.9647426784191072 0.35488595400360495L0.4756895081034974 1",A:"M0 1L0.4808333333333333 0L1 1M0.24250000000000002 0.6099439775910365L0.7341666666666666 0.6099439775910365",B:"M0 1L0 0.0117369978777208L0.30665717153513444 0L0.5874522807082946 0.03451403469442413L0.7766202217193218 0.15033936404895643L0.7471969743588041 0.31967962568332936L0.5246013359741988 0.4102978954282461L0.04378745314885416 0.44918617613783574L0.5112949594180156 0.469692928091109L0.8540266515643348 0.5552749498651879L1 0.6868463175009967L0.9880091196159324 0.8570018204672155L0.922301719975498 0.9321708046604659L0.7584266951758925 0.9932594737131338L0 1",C:"M1 0.23038928858890784L0.9328355511865092 0.12426412616785204L0.8096380839483327 0.04912601676267708L0.5763225801788256 0L0.4039037709527492 0.015028068281399815L0.2519579390951737 0.06533979308999706L0.10359458463139784 0.18146243506591617L0 0.4862728453971315L0.08129580872733055 0.792689266886982L0.20257034847159672 0.9160822255736587L0.3286572892798542 0.9738230826074175L0.5742878414421707 1L0.7883510303801312 0.9665431511195721L0.946851033994232 0.8689071500976585L1 0.7311049027121912",D:"M0 1L0.015604366822624637 0.020770988281483303L0.22564758265176144 0L0.3865476147957666 0.0024153386496795644L0.6479126635475078 0.051745644338731314L0.841191887805517 0.15827717679529366L0.9517008345536152 0.30172260586872185L0.9957536578687336 0.4504541551987709L1 0.5624359222498485L0.9798483279164735 0.6584121775234548L0.9386273319285215 0.7395945263504481L0.806292129480815 0.8624239259880274L0.6296239151398265 0.9406169638094516L0.3397492767598845 0.9954164354263132L0 1",E:"M0 0L0 1M0 0L1 0M0 0.5L0.7 0.5M0 1L1 1",F:"M0 0L0 1M0.011363636363636364 0.006802721088435374L1 0.006802721088435374M0.011363636363636364 0.4965986394557823L0.8409090909090909 0.4965986394557823",G:"M0.902666857540557 0.03860785012651126L0.6504261864675637 0L0.3838947267237336 0.015442305268228053L0.21293332876776194 0.07706794377239819L0.07799659974941617 0.1994951236187481L0 0.46380381528937314L0.04159964421546915 0.7502491408002389L0.13176692977834842 0.8535497868383203L0.2709176262273927 0.936767572377719L0.4386472596876406 0.9891638569283179L0.6145513562841309 1L0.7782254421419019 0.9585373611026471L0.9092650433859927 0.8540372997461425L1 0.5556012645283437L0.5583959277303046 0.55491741080559",H:"M0 0L0 1M0 0.4788732394366197L0.989010989010989 0.4788732394366197M1 0L1 1",I:"M0.5 0L0.5 1",J:"M0.9976457238788704 0L1 0.7396412315872798L0.9773931362096968 0.8322033314977973L0.9345115952458736 0.882296255506608L0.8743862896259549 0.9221331222466961L0.8024024079884948 0.9526431718061675L0.6443996712151668 0.9893997797356828L0.5035848940343224 1L0.3127211130319937 0.9877004749449337L0.17201910858386513 0.9539509911894274L0.10357419806379677 0.9212555066079295L0.053656568662899015 0.8816079295154184L0.020759483663648916 0.8360407488986785L0.003376206348523566 0.7855864537444934L0 0.7312775330396476",K:"M0 0L0 1M0.8787878787878788 0.06666666666666667L0 0.6148148148148148M0.3333333333333333 0.45925925925925926L1 0.9777777777777777",L:"M0 0L0 1L1 1",M:"M0 1L0 0L0.5 0.6512L1 0L1 1",N:"M0 1L0 0L1 1L0.9803729146221786 0",O:"M0.4718499217948183 1L0.2896765846490613 0.9606979309189402L0.12315162147934663 0.8411184486080473L0 0.4352399966492615L0.11730398524516283 0.13145645436014852L0.2612197451988078 0.04493357858878059L0.5104071592772554 0L0.7450113425917159 0.05393013710105273L0.882367950645524 0.15242300282020502L1 0.5224527406249126L0.9414597290654386 0.7560662329321755L0.8371289514446183 0.8910800547287298L0.6518259868433511 0.9830452628933628L0.4718499217948183 1",P:"M0 1L0 0.018871774228013626L0.29609603495819875 0L0.5609840637427541 0.011794858892508529L0.7332142696692472 0.04353904702296349L0.8102258645858864 0.0691965055027166L0.9330504315465442 0.14445061754775845L0.9876391714147118 0.22527816445836535L1 0.3434414070631638L0.9510549958116356 0.41772808046663146L0.8746646891596713 0.45879131862541683L0.7528523813396283 0.49171525113425024L0.5766919939969619 0.5153253033973054L0.33725744877712827 0.5284469008187558L0.025622667325582785 0.529905468802775",Q:"M0.4618887943546369 0.9755918167206952L0.28356128136544534 0.9372490397450218L0.12055179272160406 0.8205882753548176L0 0.4246165790405623L0.1148276047430244 0.12824784112887844L0.25570518844754375 0.043836831567190586L0.49963205786237674 0L0.7292835601228574 0.0526138004304122L0.8637404608452104 0.14870263423138746L0.9788892040030622 0.5097006183769648L0.9215847647858059 0.7376120297474734L0.8194564929275405 0.869330409436378L0.6380654214095985 0.9590509139448092L0.4618887943546369 0.9755918167206952M0.5824181120212351 0.6861805006946525L1 1",R:"M0 0.9928375167236815L0 0.02590227442068435L0.3611517274211098 0L0.6146286724700761 0.008660554424468435L0.7675462459194776 0.035269459580494614L0.831839975516866 0.056961676692569484L0.8847592491838954 0.08519560521497332L0.9238557535364527 0.120683646438422L0.9583303225312839 0.21691797435320384L0.955092470586235 0.3022616904894429L0.9198097669001631 0.3640573439322699L0.8564862239866702 0.40639258627024005L0.7691258543593579 0.43335506909190874L0.601775027203482 0.4539166070813109L0.023939064200217658 0.46997623755243123M0.5038084874863982 0.5108023922274467L1 1",S:"M0.8886929689221953 0.15146982162688968L0.7276173683050475 0.013780286031594946L0.34582323121005076 0L0.1318235250900008 0.09920162734298861L0.0444543935052531 0.2811287071349243L0.08064065829108809 0.3709571405906485L0.21603115127470426 0.4485505768228281L0.7525409135992945 0.5111160926769565L0.9330263665417677 0.5850732219351329L1 0.7129938124702524L0.9117772389978691 0.9130572743138187L0.6423187128058188 1L0.29586019579751677 0.9935291584506244L0.10638454191462794 0.9229845198431584L0 0.7570771288048773",T:"M0 0L1 0M0.5148514851485149 0L0.5148514851485149 1",U:"M0 0L0.0023103778751369115 0.5467447428390111L0.01823032542100219 0.6954785891481812L0.05895528135268338 0.8056480226151669L0.13703402031421133 0.8894445726483398L0.23918400876232196 0.9448524533417946L0.3917887458926616 0.9848674531975652L0.584341627875137 1L0.7194816196604602 0.9848501456716763L0.8303268115073934 0.9449411544119768L0.8966613970084885 0.898186315516197L0.9251437568455642 0.867453197565408L0.9687114937020809 0.7890904895145239L0.9890470974808324 0.6852857184065537L1 0.0014769088758762145",V:"M0 0L0.5348837209302325 1L1 0",W:"M0 0L0.23300090661831369 0.9873417721518988L0.49954669084315495 0.30081906180193585L0.7851314596554849 1L1 0.0215934475055845",X:"M0 0L0.9893617021276596 1M1 0L0.010638297872340425 1",Y:"M0 0L0.4860515021459227 0.44712562100780695M1 0.0014194464158977947L0.48927038626609437 0.44996451383960256L0.5075107296137339 1",Z:"M0 0L1 0L0 1L1 1",".":"M 0.49 1 L 0.41 1","*":"M 0.5 0.25 L 0.8 0.25 M 0.5 0.25 L 0.5927 0.4402 M 0.5 0.25 L 0.2573 0.3676 M 0.5 0.25 L 0.2573 0.1324 M 0.5 0.25 L 0.599 0.055","(":"M0.75 0L0.25 0.5L0.25 0.5L0.75 1",")":"M0.25 0L0.75 0.5L0.75 0.5L0.25 1","-":"M0 0.5L1 0.5","+":"M 0 0.5 L 1 0.5 M 0.5 0.125 L 0.5 0.875","=":"M0 0.25L1 0.25M0 0.75L1 0.75",_:"M0 1 L1 1","[":"M0.75 0L0.25 0L0.25 1L0.75 1","]":"M0.25 0L0.75 0L0.75 1L0.25 1","<":"M0.75 0L0.25 0.5L0.25 0.5L0.75 1",">":"M0.25 0L0.75 0.5L0.75 0.5L0.25 1","'":"M 0.5 0 L 0.5 0.5",'"':"M 0.25 0 L 0.25 0.5 M 0.75 0 L 0.75 0.5"},LJ={};for(const r in RMe){LJ[r]=[];const e=RMe[r].split("M").slice(1).map(t=>t.split("L").map(n=>n.trim().split(" ").map(parseFloat)));for(const t of e)for(let n=0;n<t.length-1;n++)LJ[r].push({x1:t[n][0],y1:1-t[n][1],x2:t[n+1][0],y2:1-t[n+1][1]})}var AMe=.6,PMe=.2,S4t=r=>r.text.length*r.size*AMe+(r.text.length-1)*r.size*PMe,E4t=r=>{const e=r.size/8,t=r.size*AMe,n=r.size*PMe,i=[];for(let a=0;a<r.text.length;a++){const o=r.text[a],s=LJ[o.toUpperCase()];if(s)for(const{x1:l,y1:c,x2:u,y2:d}of s)i.push({pcb_drawing_type:"line",x1:r.x+(t+n)*a+t*l,y1:r.y+r.size*c,x2:r.x+(t+n)*a+t*u,y2:r.y+r.size*d,width:e,layer:r.layer,unit:r.unit})}return i};function w8(r){return r.is_mouse_over||r.is_in_highlighted_net?e2e(R6[r.layer]).lighten(.5).rgb().toString():R6[r.layer]}var DMe=(r,e)=>{r.equip({size:e.zoomIndependent?e.width/r.transform.a:e.width,shape:e.squareCap?"square":"circle",color:w8(e),layer:e.layer}),r.moveTo(e.x1,e.y1),r.lineTo(e.x2,e.y2)},w4t=(r,e)=>{r.equip({fontSize:e.size,color:e.layer});let t={x:0,y:0};const n=S4t(e),i=e.size;e.align==="top_left"?t.y=-i:e.align==="bottom_right"?t.x=-n:e.align==="top_right"?(t.x=-n,t.y=-i):e.align==="center"&&(t.x=-n/2,t.y=-i/2),e.x??(e.x=0),e.y??(e.y=0);const a={x:e.x,y:e.y};let o=E4t({...e,x:e.x+t.x,y:e.y+t.y});if(e.ccw_rotation){const s={lines:o,anchorPoint:a,ccwRotation:e.ccw_rotation};o=b4t(s)}for(const s of o)DMe(r,s)},T4t=(r,e)=>{r.equip({color:w8(e),layer:e.layer}),r.rect(e.x,e.y,e.w,e.h,e.mesh_fill)},M4t=(r,e)=>{r.equip({color:w8(e),layer:e.layer}),r.rotatedRect(e.x,e.y,e.w,e.h,e.ccw_rotation)},C4t=(r,e)=>{r.equip({color:w8(e),layer:e.layer}),r.circle(e.x,e.y,e.r,e.mesh_fill)},R4t=(r,e)=>{r.equip({color:w8(e),layer:e.layer}),r.oval(e.x,e.y,e.rX,e.rY)},A4t=(r,e)=>{r.equip({color:w8(e),layer:e.layer}),r.pill(e.x,e.y,e.w,e.h)},P4t=(r,e)=>{r.equip({color:w8(e),layer:e.layer}),r.polygon(e.points)},D4t=(r,e)=>{var t;switch(e.pcb_drawing_type){case"line":return DMe(r,e);case"text":return w4t(r,e);case"rect":return((t=e._element)==null?void 0:t.shape)==="rotated_rect"?M4t(r,{...e,ccw_rotation:e._element.ccw_rotation,mesh_fill:e.mesh_fill}):T4t(r,e);case"circle":return C4t(r,e);case"oval":return R4t(r,e);case"pill":return A4t(r,e);case"polygon":return P4t(r,e)}},N4t=(r,e)=>{e.sort((t,n)=>{const i=["bottom","top","drill"];return i.indexOf(t.layer)-i.indexOf(n.layer)}),e.forEach(t=>D4t(r,t))},L4t=({primitives:r,transform:e,grid:t,width:n=500,height:i=500})=>{const a=Ct.useRef(),o=f2(s=>s.selected_layer);return Ct.useEffect(()=>{if(!a.current||Object.keys(a.current).length===0)return;const s=new x4t(a.current);e&&(s.transform=e),s.clear(),s.foregroundLayer=o,N4t(s,r),s.orderAndFadeLayers()},[r,e,o]),_t.jsxs("div",{style:{backgroundColor:"black",width:n,height:i,position:"relative"},children:[_t.jsx(KK.SuperGrid,{textColor:"rgba(0,255,0,0.8)",majorColor:"rgba(0,255,0,0.4)",minorColor:"rgba(0,255,0,0.2)",screenSpaceCellSize:200,width:n,height:i,transform:e,stringifyCoord:(s,l,c)=>`${KK.toMMSI(s,c)}, ${KK.toMMSI(l,c)}`}),xO.map(s=>s.replace(/-/g,"")).concat(["drill","other"]).map((s,l)=>_t.jsx("canvas",{ref:c=>{a.current??(a.current={}),a.current[s]=c},style:{position:"absolute",left:0,top:0,pointerEvents:"none"},width:n,height:i},s))]})};function O4t(r,e){if(r.length<2)throw new Error("Stroke must have at least two points");const t=r.map(d=>Array.isArray(d)?{x:d[0],y:d[1]}:d),n=[],i=[];function a(d,g){const _=g.x-d.x,x=g.y-d.y,T=Math.sqrt(_*_+x*x);return{x:-x/T,y:_/T}}function o(d,g,_,x){const T=x/2,M={x:d.x+g.x*T*_,y:d.y+g.y*T*_};_>0?n.push(M):i.unshift(M)}const s=a(t[0],t[1]),l=t[0].trace_width??e;o(t[0],s,1,l),o(t[0],s,-1,l);for(let d=1;d<t.length-1;d++){const g=t[d-1],_=t[d],x=t[d+1],T=a(g,_),M=a(_,x),R=T.x+M.x,L=T.y+M.y,z=Math.sqrt(R*R+L*L),j=_.trace_width??e;if(z/2>2*(j/2))o(_,T,1,j),o(_,M,1,j),o(_,T,-1,j),o(_,M,-1,j);else{const ee=1/z;o(_,{x:R*ee,y:L*ee},1,j),o(_,{x:R*ee,y:L*ee},-1,j)}}const c=a(t[t.length-2],t[t.length-1]),u=t[t.length-1].trace_width??e;return o(t[t.length-1],c,1,u),o(t[t.length-1],c,-1,u),[...n,...i]}var O1=0,z4t=(r,e)=>{var o;const t="pcb_component_id"in r?e.find(s=>s.type==="pcb_component"&&s.pcb_component_id===r.pcb_component_id):void 0,n=t&&"source_component_id"in t?e.find(s=>s.type==="source_component"&&s.source_component_id===t.source_component_id):void 0,i="source_port_id"in r?r.source_port_id:"pcb_port_id"in r?(o=qS(e).pcb_port.get(r.pcb_port_id))==null?void 0:o.source_port_id:void 0,a=i?e.find(s=>s.type==="source_port"&&s.source_port_id===i):void 0;switch(r.type){case"pcb_board":{const{width:s,height:l,center:c,outline:u}=r;return u&&u.length>2?u.map((d,g,_)=>({_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:d.x,y1:d.y,x2:g===_.length-1?_[0].x:_[g+1].x,y2:g===_.length-1?_[0].y:_[g+1].y,width:1,zoomIndependent:!0,layer:"board",_element:r})):[{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y-l/2,x2:c.x+s/2,y2:c.y-l/2,width:1,zoomIndependent:!0,layer:"board",_element:r},{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y+l/2,x2:c.x+s/2,y2:c.y+l/2,width:1,zoomIndependent:!0,layer:"board",_element:r},{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y-l/2,x2:c.x-s/2,y2:c.y+l/2,width:1,zoomIndependent:!0,layer:"board",_element:r},{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:c.x+s/2,y1:c.y-l/2,x2:c.x+s/2,y2:c.y+l/2,width:1,zoomIndependent:!0,layer:"board",_element:r}]}case"pcb_smtpad":{if(r.shape==="rect"||r.shape==="rotated_rect"){const{shape:s,x:l,y:c,width:u,height:d,layer:g}=r;return[{_pcb_drawing_object_id:`rect_${O1++}`,pcb_drawing_type:"rect",x:l,y:c,w:u,h:d,layer:g||"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a}]}else if(r.shape==="circle"){const{x:s,y:l,radius:c,layer:u}=r;return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:c,layer:u||"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a}]}return[]}case"pcb_hole":{if(r.hole_shape==="circle"||!r.hole_shape){const{x:s,y:l,hole_diameter:c}=r;return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:c/2,layer:"drill",_element:r,_parent_pcb_component:t,_parent_source_component:n}]}return[]}case"pcb_plated_hole":if(r.shape==="circle"){const{x:s,y:l,hole_diameter:c,outer_diameter:u}=r;return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:u/2,layer:"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a},{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:c/2,layer:"drill",_element:r}]}else if(r.shape==="oval"){const{x:s,y:l,outer_height:c,outer_width:u,hole_height:d,hole_width:g}=r;return[{_pcb_drawing_object_id:`oval_${O1++}`,pcb_drawing_type:"oval",x:s,y:l,rX:u/2,rY:c/2,layer:"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a},{_pcb_drawing_object_id:`oval_${O1++}`,_element:r,pcb_drawing_type:"oval",x:s,y:l,rX:g/2,rY:d/2,layer:"drill"}]}else if(r.shape==="pill"){const{x:s,y:l,outer_height:c,outer_width:u,hole_height:d,hole_width:g}=r;return[{_pcb_drawing_object_id:`pill_${O1++}`,pcb_drawing_type:"pill",x:s,y:l,w:u,h:c,layer:"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a},{_pcb_drawing_object_id:`pill_${O1++}`,_element:r,pcb_drawing_type:"pill",x:s,y:l,w:g,h:d,layer:"drill"}]}else return[];case"pcb_keepout":if(r.shape==="circle"){const{center:s,radius:l}=r;return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s.x,y:s.y,r:l,layer:"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,mesh_fill:!0}]}else if(r.shape==="rect"){const{x:s,y:l,width:c,height:u}=r;return[{_pcb_drawing_object_id:`rect_${O1++}`,pcb_drawing_type:"rect",x:s,y:l,w:c,h:u,layer:"top",_element:r,_parent_pcb_component:t,_parent_source_component:n,mesh_fill:!0}]}case"pcb_trace":{const s=[];if(r.route_thickness_mode==="interpolated"){const u=r.route.map(g=>({x:g.x,y:g.y,trace_width:g.route_type==="wire"?g.width:.5})),d=O4t(u,.5);return s.push({_pcb_drawing_object_id:`polygon_${O1++}`,_element:r,pcb_drawing_type:"polygon",points:d,layer:r.route[0].layer}),r.route.forEach(g=>{g.route_type==="via"&&s.push({_pcb_drawing_object_id:`circle_${O1++}`,_element:r,pcb_drawing_type:"circle",x:g.x,y:g.y,radius:g.outer_diameter/2,fill:!0,layer:r.route.layer})}),s}let l=null,c=null;for(const u of r.route)u.route_type==="wire"&&(l!==null&&c!==null&&s.push({_pcb_drawing_object_id:`line_${O1++}`,_element:r,pcb_drawing_type:"line",x1:l,y1:c,x2:u.x,y2:u.y,width:u.width,squareCap:!1,layer:u.layer}),l=u.x,c=u.y);return s}case"pcb_via":{const{x:s,y:l,outer_diameter:c,hole_diameter:u,from_layer:d,to_layer:g}=r;return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:c/2,layer:d,_element:r,_parent_pcb_component:t,_parent_source_component:n},{_pcb_drawing_object_id:`circle_${O1++}`,_element:r,pcb_drawing_type:"circle",x:s,y:l,r:u/2,layer:"drill",_parent_pcb_component:t,_parent_source_component:n},{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:s,y:l,r:c/2,layer:g,_element:r,_parent_pcb_component:t,_parent_source_component:n}]}case"pcb_silkscreen_rect":return[{_pcb_drawing_object_id:`rect_${O1++}`,pcb_drawing_type:"rect",x:r.center.x,y:r.center.y,w:r.width,h:r.height,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_circle":return[{_pcb_drawing_object_id:`circle_${O1++}`,pcb_drawing_type:"circle",x:r.center.x,y:r.center.y,r:r.radius,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_oval":return[{_pcb_drawing_object_id:`oval_${O1++}`,pcb_drawing_type:"oval",x:r.center.x,y:r.center.y,rX:r.radius_x/2,rY:r.radius_y/2,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_pill":return[{_pcb_drawing_object_id:`pill_${O1++}`,pcb_drawing_type:"pill",x:r.center.x,y:r.center.y,w:r.width,h:r.height,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_line":return[{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,width:.1,squareCap:!1,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_fabrication_note_path":case"pcb_silkscreen_path":{const{pcb_component_id:s,route:l,type:c}=r;let u;return c==="pcb_silkscreen_path"?u=r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen":c==="pcb_fabrication_note_path"&&(u="top_fabrication"),l.slice(0,-1).map((d,g)=>{const _=l[g+1];return{_pcb_drawing_object_id:`line_${O1++}`,pcb_drawing_type:"line",x1:d.x,y1:d.y,x2:_.x,y2:_.y,width:r.stroke_width??.1,squareCap:!1,layer:u,_element:r,_parent_pcb_component:t,_parent_source_component:n,_source_port:a}}).filter(Boolean)}case"pcb_silkscreen_text":return[{_pcb_drawing_object_id:`text_${O1++}`,pcb_drawing_type:"text",x:r.anchor_position.x,y:r.anchor_position.y,layer:r.layer==="bottom"?"bottom_silkscreen":"top_silkscreen",align:r.anchor_alignment??"center",text:r.text,size:r.font_size,ccw_rotation:r.ccw_rotation}];case"pcb_fabrication_note_text":return[{_pcb_drawing_object_id:`text_${O1++}`,pcb_drawing_type:"text",x:r.anchor_position.x,y:r.anchor_position.y,layer:r.layer==="bottom"?"bottom_fabrication":"top_fabrication",size:r.font_size,align:r.anchor_alignment??"center",text:r.text}]}return[]};function U4t({primitiveElement:r,elements:e}){let t=r.trace_length?`${r.trace_length.toFixed(3)}`:"";const n=qS(e).source_trace.get(r==null?void 0:r.source_trace_id);if(n!=null&&n.display_name&&(n!=null&&n.max_length?t+=` / ${n.max_length}mm `:t+=" mm ",t+=`(${n.display_name})`),!t)return null;const i=r.trace_length&&(n==null?void 0:n.max_length)&&r.trace_length>n.max_length;return{text:t,isOverLength:i}}function k4t(r){const{primitives:e,is_showing_multiple_traces_length:t,elements:n}=r,i=e.filter(l=>l._element.type==="pcb_trace"),a=n.filter(l=>l.type==="source_trace"),o=e.filter(l=>l._element.type!=="pcb_trace"),s=i.filter(l=>a.some(c=>l._element.type==="pcb_trace"&&l._element.source_trace_id===c.source_trace_id&&c.max_length!==void 0));if(!t)return[...o,...s];if(i.length>1){const l=i.reduce((c,u)=>{const d=c._element.trace_length;return u._element.trace_length<d?u:c},i[0]);return[...o,l]}return e}var I4t={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},F4t=r=>{const{_element:e,_parent_pcb_component:t,_parent_source_component:n,_source_port:i}=r;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{let a="";n&&"name"in n&&n.name&&(a+=`.${n.name} > `);const o=Array.from(new Set((e.port_hints??[]).concat((i==null?void 0:i.port_hints)??[]))).sort((s,l)=>l.localeCompare(s));return a+=o.map(s=>s.match(/^[0-9]+$/)?`port.${s}`:`.${s}`).join(", "),a}default:return""}},B4t={top:"red",bottom:"aqua"},H4t=({primitive:r,mousePos:e,elements:t})=>{var x;const[n,i]=Ct.useState(!1),a=r._element;Ct.useEffect(()=>{setTimeout(()=>{i(!0)},100)},[]);let[o,s,l,c]=[r.screen_x,r.screen_y,r.screen_w,r.screen_h];const u=r.same_space_index??0,d=26,g=B4t[(x=r==null?void 0:r._element)==null?void 0:x.layer]??"red";let _=0;if(a.type==="pcb_smtpad"&&(a==null?void 0:a.shape)==="rotated_rect"&&(_=a==null?void 0:a.ccw_rotation),a.type==="pcb_trace"){const M=U4t({primitiveElement:a,elements:t});if(!M)return null;const R=e.y-35;return _t.jsx("div",{style:{zIndex:wb.elementOverlay,position:"absolute",left:e.x,top:R,color:g,pointerEvents:"none",transform:"translateX(-50%)"},children:_t.jsx("div",{style:{backgroundColor:"#f2efcc",color:M.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:M.text})})}return _t.jsx("div",{style:{zIndex:wb.elementOverlay,position:"absolute",left:o-l/2-8,top:s-c/2-8,width:l+16,height:c+16,color:g,transform:`rotate(${-_}deg)`,transformOrigin:"center center"},children:_t.jsx("div",{style:{width:n?`calc(100% + ${d*2*u}px)`:"100%",height:n?`calc(100% + ${d*2*u}px)`:"100%",marginLeft:n?`${-d*u}px`:0,marginTop:n?`${-d*u}px`:0,border:`1px solid ${g}`,opacity:n||u===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:_t.jsx("div",{style:{position:"absolute",bottom:c+20+d*u,marginRight:n?`${-d*u}px`:0,marginBottom:n?0:-d*u,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${_}deg)`,minWidth:"45px",textAlign:"center"},children:F4t(r)})})})},V4t=({highlightedPrimitives:r,mousePos:e,elements:t})=>{const[n,i]=f2(s=>[s.is_moving_component,s.is_showing_multiple_traces_length]),a=r.some(s=>s._element.type==="pcb_smtpad")&&r.some(s=>s._element.type==="pcb_trace");let o=r;return a&&(o=o.filter(s=>s._element.type==="pcb_smtpad")),o=k4t({primitives:o,is_showing_multiple_traces_length:i,elements:t}),_t.jsx("div",{style:I4t,children:!n&&o.map((s,l)=>_t.jsx(H4t,{primitive:s,mousePos:e,elements:t},l))})};function j4t(r,e){return r.size!==e.size?!1:Array.from(r).every(t=>e.has(t))}var G4t=({elements:r,children:e,transform:t,primitives:n,onMouseHoverOverPrimitives:i})=>{const[a,o]=Ct.useState([]),[s,l]=Ct.useState({x:0,y:0}),c=Ct.useMemo(()=>{var d,g;const u=[];for(const _ of a){if(((d=_._element)==null?void 0:d.type)==="pcb_via"||((g=_._element)==null?void 0:g.type)==="pcb_component"||(_==null?void 0:_.layer)==="drill")continue;const x=_i(t,_),T="w"in _?_.w:"r"in _?_.r*2:0,M="h"in _?_.h:"r"in _?_.r*2:0,R={w:T*t.a,h:M*t.a};let L=u.filter(z=>x.x===z.screen_x&&x.y===z.screen_y&&R.w===z.screen_w&&R.h===z.screen_h).length;u.push({..._,screen_x:x.x,screen_y:x.y,screen_w:R.w,screen_h:R.h,same_space_index:L})}return u},[a,t]);return _t.jsxs("div",{style:{position:"relative"},onMouseMove:u=>{var d;if(t){const g=u.currentTarget.getBoundingClientRect(),_=u.clientX-g.left,x=u.clientY-g.top;l({x:_,y:x});const T=_i(Fb(t),{x:_,y:x}),M=[];for(const R of n){if(!R._element)continue;if("x1"in R&&((d=R._element)==null?void 0:d.type)==="pcb_trace"){const j=O2t({x:T.x,y:T.y},{x:R.x1,y:R.y1},{x:R.x2,y:R.y2}),Z=R.width||.5,ee=Math.max(Z*25,2)/t.a;j<ee&&M.push(R);continue}if(!("x"in R&&"y"in R))continue;let L=0,z=0;if("w"in R&&"h"in R)L=R.w,z=R.h;else if("r"in R)L=R.r*2,z=R.r*2;else continue;Math.abs(R.x-T.x)<L/2&&Math.abs(R.y-T.y)<z/2&&M.push(R)}if(j4t(new Set(M.map(R=>R._pcb_drawing_object_id)),new Set(a.map(R=>R._pcb_drawing_object_id))))return;o(M),i(M)}},children:[e,_t.jsx(V4t,{elements:r,mousePos:s,highlightedPrimitives:c})]})},q4t=({children:r,transform:e})=>{e||(e=D_());const[t,n]=Ct.useState(!1),[i,a]=Ct.useState(!1),[o,s]=Ct.useState({x:0,y:0}),[l,c]=Ct.useState({x:0,y:0}),u=Ct.useRef({x:0,y:0}),d=Ct.useRef(null),g=d.current,_=g==null?void 0:g.getBoundingClientRect();Ct.useEffect(()=>{const R=d.current,L=Z=>{Z.key==="d"&&(s({x:u.current.x,y:u.current.y}),c({x:u.current.x,y:u.current.y}),n(ee=>!ee),a(!0),Z.preventDefault()),Z.key==="Escape"&&(n(!1),a(!1))},z=()=>{R&&R.addEventListener("keydown",L)},j=()=>{R&&R.removeEventListener("keydown",L)};return R&&(R.addEventListener("focus",z),R.addEventListener("blur",j),R.addEventListener("mouseenter",z),R.addEventListener("mouseleave",j)),()=>{R&&(R.removeEventListener("focus",z),R.removeEventListener("blur",j),R.removeEventListener("mouseenter",z),R.removeEventListener("mouseleave",j))}},[d]);const x=_i(e,o),T=_i(e,l),M={left:Math.min(x.x,T.x),right:Math.max(x.x,T.x),top:Math.min(x.y,T.y),bottom:Math.max(x.y,T.y),flipX:x.x>T.x,flipY:x.y>T.y,width:0,height:0};return M.width=M.right-M.left,M.height=M.bottom-M.top,_t.jsxs("div",{ref:d,tabIndex:0,style:{position:"relative"},onMouseEnter:()=>{d.current&&d.current.focus()},onMouseLeave:()=>{d.current&&d.current.blur()},onMouseMove:R=>{const L=R.currentTarget.getBoundingClientRect(),z=R.clientX-L.left,j=R.clientY-L.top,Z=_i(Fb(e),{x:z,y:j});u.current.x=Z.x,u.current.y=Z.y,i&&c({x:Z.x,y:Z.y})},onMouseDown:()=>{i?a(!1):t&&n(!1)},children:[r,t&&_t.jsxs(_t.Fragment,{children:[_t.jsx("div",{style:{position:"absolute",left:M.left,width:M.width,textAlign:"center",top:x.y+2,color:"red",mixBlendMode:"difference",pointerEvents:"none",marginTop:M.flipY?0:-20,fontSize:12,fontFamily:"sans-serif",zIndex:wb.dimensionOverlay},children:Math.abs(o.x-l.x).toFixed(2)}),_t.jsx("div",{style:{position:"absolute",left:T.x,height:M.height,display:"flex",flexDirection:"column",justifyContent:"center",top:M.top,color:"red",pointerEvents:"none",mixBlendMode:"difference",fontSize:12,fontFamily:"sans-serif",zIndex:wb.dimensionOverlay},children:_t.jsx("div",{style:{marginLeft:M.flipX?"-100%":4,paddingRight:4},children:Math.abs(o.y-l.y).toFixed(2)})}),_t.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:wb.dimensionOverlay},width:_.width,height:_.height,children:[_t.jsx("defs",{children:_t.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:_t.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),_t.jsx("line",{x1:x.x,y1:x.y,x2:T.x,y2:T.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),_t.jsx("line",{x1:x.x,y1:x.y,x2:T.x,y2:x.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),_t.jsx("line",{x1:T.x,y1:x.y,x2:T.x,y2:T.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),_t.jsxs("div",{style:{right:0,bottom:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4},children:["(",o.x.toFixed(2),",",o.y.toFixed(2),")",_t.jsx("br",{}),"(",l.x.toFixed(2),",",l.y.toFixed(2),")",_t.jsx("br",{}),"dist:"," ",Math.sqrt(Math.pow(l.x-o.x,2)+Math.pow(l.y-o.y,2)).toFixed(2)]})]})]})},Y4t={name:"@tscircuit/pcb-viewer",version:"1.11.28",main:"dist/index.js",type:"module",repository:"tscircuit/pcb-viewer",license:"MIT",scripts:{start:"storybook dev -p 6006",build:"tsup ./src/index.tsx --platform browser --dts --sourcemap --format esm --outDir dist",yalc:"npm run build && yalc push",storybook:"storybook dev -p 6006","build-storybook":"storybook build",format:"biome format . --write","format:check":"biome format ."},files:["dist"],devDependencies:{"@biomejs/biome":"^1.9.4","@semantic-release/commit-analyzer":"^9.0.2","@semantic-release/git":"^10.0.1","@semantic-release/npm":"^9.0.1","@semantic-release/release-notes-generator":"^10.0.3","@storybook/nextjs":"^8.0.6","@storybook/react":"^8.0.6","@swc/core":"^1.4.12","@tscircuit/core":"0.0.272","@tscircuit/eagle-xml-converter":"^1.0.0","@tscircuit/props":"^0.0.130","@tscircuit/soup-util":"^0.0.41","@types/color":"^3.0.6","@types/node":"18.7.23","@types/react":"^18.3.3","circuit-json":"^0.0.128",next:"^14.1.4","pixi.js":"^8.6.6",react:"^18.2.0","react-dom":"^18.2.0","react-use":"^17.4.0",storybook:"^8.0.6",tsup:"^8.0.2","type-fest":"^3.0.0",typescript:"^5.4.4","use-mouse-matrix-transform":"^1.3.0",zod:"^3.23.5"},peerDependencies:{react:"*","@tscircuit/core":"*"},dependencies:{"@emotion/css":"^11.11.2","circuit-json-to-connectivity-map":"^0.0.18","@tscircuit/math-utils":"^0.0.10","circuit-to-svg":"^0.0.36",color:"^4.2.3","react-supergrid":"^1.0.10","react-toastify":"^10.0.5","transformation-matrix":"^2.13.0",zustand:"^4.5.2"}},YS=(r,e)=>{const t=f2(n=>n.is_mouse_over_container);Ct.useEffect(()=>{if(!r||typeof e!="function")return;const n=i=>{const a=r.split("+"),o=a.includes("ctrl"),s=a.includes("shift"),l=a.includes("alt"),c=a.includes("meta"),u=a[a.length-1];t&&(!o||i.ctrlKey)&&(!s||i.shiftKey)&&(!l||i.altKey)&&(!c||i.metaKey)&&i.key.toLowerCase()===u.toLowerCase()&&(i.preventDefault(),e())};return window.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n)}},[r,e])},X4t=({name:r,selected:e,onClick:t})=>_t.jsxs("div",{className:x6`
12847
12847
  margin-top: 2px;
12848
12848
  padding: 4px;