@tscircuit/eval 0.0.344 → 0.0.346

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.
@@ -141,7 +141,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}});var VB=te(dx=>{"use strict";var Pxt
141
141
  :is(button, input, select, textarea, optgroup, option)[disabled],
142
142
  optgroup[disabled] > option,
143
143
  fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
144
- )`,enabled:":not(:disabled)",checked:":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",required:":is(input, select, textarea)[required]",optional:":is(input, select, textarea):not([required])",selected:"option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",checkbox:"[type=checkbox]",file:"[type=file]",password:"[type=password]",radio:"[type=radio]",reset:"[type=reset]",image:"[type=image]",submit:"[type=submit]",parent:":not(:empty)",header:":is(h1, h2, h3, h4, h5, h6)",button:":is(button, input[type=button])",input:":is(input, textarea, select, button)",text:"input:is(:not([type!='']), [type=text])"};var Gr=Xt(Qc(),1);var QP={};function t5(e,t){return e===Gr.default.falseFunc?Gr.default.falseFunc:n=>t.isTag(n)&&e(n)}function e5(e,t){let n=t.getSiblings(e);if(n.length<=1)return[];let i=n.indexOf(e);return i<0||i===n.length-1?[]:n.slice(i+1).filter(t.isTag)}function JP(e){return{xmlMode:!!e.xmlMode,lowerCaseAttributeNames:!!e.lowerCaseAttributeNames,lowerCaseTags:!!e.lowerCaseTags,quirksMode:!!e.quirksMode,cacheResults:!!e.cacheResults,pseudos:e.pseudos,adapter:e.adapter,equals:e.equals}}var KP=(e,t,n,i,r)=>{let o=r(t,JP(n),i);return o===Gr.default.trueFunc?e:o===Gr.default.falseFunc?Gr.default.falseFunc:s=>o(s)&&e(s)},Oy={is:KP,matches:KP,where:KP,not(e,t,n,i,r){let o=r(t,JP(n),i);return o===Gr.default.falseFunc?e:o===Gr.default.trueFunc?Gr.default.falseFunc:s=>!o(s)&&e(s)},has(e,t,n,i,r){let{adapter:o}=n,s=JP(n);s.relativeSelector=!0;let a=t.some(u=>u.some(dd))?[QP]:void 0,c=r(t,s,a);if(c===Gr.default.falseFunc)return Gr.default.falseFunc;let l=t5(c,o);if(a&&c!==Gr.default.trueFunc){let{shouldTestNextSiblings:u=!1}=c;return h=>{if(!e(h))return!1;a[0]=h;let f=o.getChildren(h),_=u?[...f,...e5(h,o)]:f;return o.existsOne(l,_)}}return u=>e(u)&&o.existsOne(l,o.getChildren(u))}};function aO(e,t,n,i,r){var o;let{name:s,data:a}=t;if(Array.isArray(a)){if(!(s in Oy))throw new Error(`Unknown pseudo-class :${s}(${a})`);return Oy[s](e,a,n,i,r)}let c=(o=n.pseudos)===null||o===void 0?void 0:o[s],l=typeof c=="string"?c:ZP[s];if(typeof l=="string"){if(a!=null)throw new Error(`Pseudo ${s} doesn't have any arguments`);let u=hd(l);return Oy.is(e,u,n,i,r)}if(typeof c=="function")return WP(c,s,a,1),u=>c(u,a)&&e(u);if(s in md)return md[s](e,a,n,i);if(s in Ry){let u=Ry[s];return WP(u,s,a,2),h=>u(h,n,a)&&e(h)}throw new Error(`Unknown pseudo-class :${s}`)}function n5(e,t){let n=t.getParent(e);return n&&t.isTag(n)?n:null}function cO(e,t,n,i,r){let{adapter:o,equals:s}=n;switch(t.type){case ie.PseudoElement:throw new Error("Pseudo-elements are not supported by css-select");case ie.ColumnCombinator:throw new Error("Column combinators are not yet supported by css-select");case ie.Attribute:{if(t.namespace!=null)throw new Error("Namespaced attributes are not yet supported by css-select");return(!n.xmlMode||n.lowerCaseAttributeNames)&&(t.name=t.name.toLowerCase()),iO[t.action](e,t,n)}case ie.Pseudo:return aO(e,t,n,i,r);case ie.Tag:{if(t.namespace!=null)throw new Error("Namespaced tag names are not yet supported by css-select");let{name:a}=t;return(!n.xmlMode||n.lowerCaseTags)&&(a=a.toLowerCase()),function(l){return o.getName(l)===a&&e(l)}}case ie.Descendant:{if(n.cacheResults===!1||typeof WeakSet>"u")return function(l){let u=l;for(;u=n5(u,o);)if(e(u))return!0;return!1};let a=new WeakSet;return function(l){let u=l;for(;u=n5(u,o);)if(!a.has(u)){if(o.isTag(u)&&e(u))return!0;a.add(u)}return!1}}case"_flexibleDescendant":return function(c){let l=c;do if(e(l))return!0;while(l=n5(l,o));return!1};case ie.Parent:return function(c){return o.getChildren(c).some(l=>o.isTag(l)&&e(l))};case ie.Child:return function(c){let l=o.getParent(c);return l!=null&&o.isTag(l)&&e(l)};case ie.Sibling:return function(c){let l=o.getSiblings(c);for(let u=0;u<l.length;u++){let h=l[u];if(s(c,h))break;if(o.isTag(h)&&e(h))return!0}return!1};case ie.Adjacent:return o.prevElementSibling?function(c){let l=o.prevElementSibling(c);return l!=null&&e(l)}:function(c){let l=o.getSiblings(c),u;for(let h=0;h<l.length;h++){let f=l[h];if(s(c,f))break;o.isTag(f)&&(u=f)}return!!u&&e(u)};case ie.Universal:{if(t.namespace!=null&&t.namespace!=="*")throw new Error("Namespaced universal selectors are not yet supported by css-select");return e}}}function lO(e,t,n){let i=Ly(e,t,n);return t5(i,t.adapter)}function Ly(e,t,n){let i=typeof e=="string"?hd(e):e;return Fy(i,t,n)}function uO(e){return e.type===ie.Pseudo&&(e.name==="scope"||Array.isArray(e.data)&&e.data.some(t=>t.some(uO)))}var Zht={type:ie.Descendant},Kht={type:"_flexibleDescendant"},Jht={type:ie.Pseudo,name:"scope",data:null};function Qht(e,{adapter:t},n){let i=!!n?.every(r=>{let o=t.isTag(r)&&t.getParent(r);return r===QP||o&&t.isTag(o)});for(let r of e){if(!(r.length>0&&dd(r[0])&&r[0].type!==ie.Descendant))if(i&&!r.some(uO))r.unshift(Zht);else continue;r.unshift(Jht)}}function Fy(e,t,n){var i;e.forEach(GP),n=(i=t.context)!==null&&i!==void 0?i:n;let r=Array.isArray(n),o=n&&(Array.isArray(n)?n:[n]);if(t.relativeSelector!==!1)Qht(e,t,o);else if(e.some(c=>c.length>0&&dd(c[0])))throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");let s=!1,a=e.map(c=>{if(c.length>=2){let[l,u]=c;l.type!==ie.Pseudo||l.name!=="scope"||(r&&u.type===ie.Descendant?c[1]=Kht:(u.type===ie.Adjacent||u.type===ie.Sibling)&&(s=!0))}return tdt(c,t,o)}).reduce(edt,Ps.default.falseFunc);return a.shouldTestNextSiblings=s,a}function tdt(e,t,n){var i;return e.reduce((r,o)=>r===Ps.default.falseFunc?Ps.default.falseFunc:cO(r,o,t,n,Fy),(i=t.rootFunc)!==null&&i!==void 0?i:Ps.default.trueFunc)}function edt(e,t){return t===Ps.default.falseFunc||e===Ps.default.trueFunc?e:e===Ps.default.falseFunc||t===Ps.default.trueFunc?t:function(i){return e(i)||t(i)}}var pO=(e,t)=>e===t,ndt={adapter:Ay,equals:pO};function hO(e){var t,n,i,r;let o=e??ndt;return(t=o.adapter)!==null&&t!==void 0||(o.adapter=Ay),(n=o.equals)!==null&&n!==void 0||(o.equals=(r=(i=o.adapter)===null||i===void 0?void 0:i.equals)!==null&&r!==void 0?r:pO),o}function r5(e){return function(n,i,r){let o=hO(i);return e(n,o,r)}}var L6t=r5(lO),F6t=r5(Ly),z6t=r5(Fy);function dO(e){return function(n,i,r){let o=hO(r);typeof n!="function"&&(n=Ly(n,o,i));let s=idt(i,o.adapter,n.shouldTestNextSiblings);return e(n,s,o)}}function idt(e,t,n=!1){return n&&(e=rdt(e,t)),Array.isArray(e)?t.removeSubsets(e):t.getChildren(e)}function rdt(e,t){let n=Array.isArray(e)?e.slice(0):[e],i=n.length;for(let r=0;r<i;r++){let o=e5(n[r],t);n.push(...o)}return n}var o5=dO((e,t,n)=>e===i5.default.falseFunc||!t||t.length===0?[]:n.adapter.findAll(e,t)),zy=dO((e,t,n)=>e===i5.default.falseFunc||!t||t.length===0?null:n.adapter.findOne(e,t));Z();St();Z();var HO=Xt(Pn(),1);St();var qO=Xt(Pn(),1),ZO=Xt(Pn(),1);St();Ao();h5();var d5=(e,t={})=>{let n=e._internal_store;if(!n){n={counts:{}},e._internal_store=n;for(let r of e){let o=r.type,s=r[`${o}_id`];if(!s)continue;let a=Number.parseInt(s.split("_").pop());Number.isNaN(a)||(n.counts[o]=Math.max(n.counts[o]??0,a))}}return new Proxy({},{get:(r,o)=>o==="toArray"?()=>e:{get:s=>e.find(a=>a.type===o&&a[`${o}_id`]===s),getUsing:s=>{let a=Object.keys(s);if(a.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");let c=a[0],l=c.replace("_id",""),u=e.find(h=>h.type===l&&h[c]===s[c]);return u?e.find(h=>h.type===o&&h[`${o}_id`]===u[`${o}_id`]):null},getWhere:s=>{let a=Object.keys(s);return e.find(c=>c.type===o&&a.every(l=>c[l]===s[l]))},list:s=>{let a=s?Object.keys(s):[];return e.filter(c=>c.type===o&&a.every(l=>c[l]===s[l]))},insert:s=>{var l;(l=n.counts)[o]??(l[o]=-1),n.counts[o]++;let a=n.counts[o],c={type:o,[`${o}_id`]:`${o}_${a}`,...s};return t.validateInserts&&(Gc[o]??Hc).parse(c),e.push(c),c},delete:s=>{let a=e.find(c=>c[`${o}_id`]===s);a&&e.splice(e.indexOf(a),1)},update:(s,a)=>{let c=e.find(l=>l[`${o}_id`]===s);if(c)return Object.assign(c,a),c},select:s=>{if(o==="source_component")return e.find(a=>a.type==="source_component"&&a.name===s.replace(/\./g,""));if(o==="pcb_port"||o==="source_port"||o==="schematic_port"){let[a,c]=s.replace(/\./g,"").split(/[\s\>]+/),l=e.find(h=>h.type==="source_component"&&h.name===a);if(!l)return null;let u=e.find(h=>h.type==="source_port"&&h.source_component_id===l.source_component_id&&(h.name===c||(h.port_hints??[]).includes(c)));if(!u)return null;if(o==="source_port")return u;if(o==="pcb_port")return e.find(h=>h.type==="pcb_port"&&h.source_port_id===u.source_port_id);if(o==="schematic_port")return e.find(h=>h.type==="schematic_port"&&h.source_port_id===u.source_port_id)}}}})};d5.unparsed=d5;var MO=d5;var BRt=Xt(CO(),1);Xi();function Ts(e){let t=e.width/2,n=e.height/2;return{minX:e.center.x-t,maxX:e.center.x+t,minY:e.center.y-n,maxY:e.center.y+n}}function ap(e,t){let n=Ts(e),i=Ts(t),r=Math.max(n.minX-i.maxX,i.minX-n.maxX,0),o=Math.max(n.minY-i.maxY,i.minY-n.maxY,0),s={x:0,y:0},a={x:0,y:0};return r===0&&o===0?{distance:0,pointA:e.center,pointB:t.center}:(s.x=Ln(e.center.x,i.minX,i.maxX),s.y=Ln(e.center.y,i.minY,i.maxY),a.x=Ln(t.center.x,n.minX,n.maxX),a.y=Ln(t.center.y,n.minY,n.maxY),{distance:Math.hypot(s.x-a.x,s.y-a.y),pointA:s,pointB:a})}function Ln(e,t,n){return Math.max(t,Math.min(n,e))}function vd(e,t){let n=Number.POSITIVE_INFINITY,i={x:0,y:0},r={x:0,y:0};for(let o of e)for(let s of t){let{distance:a,pointA:c,pointB:l}=ap(o,s);a<n&&(n=a,i=c,r=l)}return{pointA:i,pointB:r,distance:n}}Xi();Xi();var FO="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var zO=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=FO[n[e]&63];return t};Xi();var al=(e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y),DO=(e,t)=>{let n=t.x-e.x,i=t.y-e.y;return Math.abs(n)>Math.abs(i)?{dx:Math.sign(n),dy:0}:{dx:0,dy:Math.sign(i)}},XO=(e,t,n)=>Math.abs(e.x-t.x)*Math.abs(n.dx)+Math.abs(e.y-t.y)*Math.abs(n.dy),VO=(e,t=.1)=>`${Math.round(e.x/t)},${Math.round(e.y/t)}`,$O=(e,t)=>Math.abs(e-t)<1e-4,GO=(e,t,{viaDiameter:n=.5}={})=>{let i=[];for(let r=0;r<e.length-1;r++){let[o,s]=[e[r],e[r+1]],a=r-1>=0?e[r-1]:null,c=$O(o.y,s.y),l=$O(o.x,s.x);if(!c&&!l)throw new Error(`getObstaclesFromTrace currently only supports horizontal and vertical traces (not diagonals) Conflicting trace: ${t}, start: (${o.x}, ${o.y}), end: (${s.x}, ${s.y})`);let u={type:"rect",layers:[o.layer],center:{x:(o.x+s.x)/2,y:(o.y+s.y)/2},width:c?Math.abs(o.x-s.x):.1,height:l?Math.abs(o.y-s.y):.1,connectedTo:[t]};if(i.push(u),a&&a.layer===o.layer&&o.layer!==s.layer){let h={type:"rect",layers:[o.layer,s.layer],center:{x:o.x,y:o.y},connectedTo:[t],width:n,height:n};i.push(h)}}return i},UO=class{constructor(e){T(this,"obstacles");T(this,"GRID_STEP",.1);this.obstacles=e.map(t=>({...t,left:t.center.x-t.width/2,right:t.center.x+t.width/2,top:t.center.y+t.height/2,bottom:t.center.y-t.height/2}))}getObstacleAt(e,t,n){n??(n=this.GRID_STEP);for(let i of this.obstacles){let r=i.width/2+n,o=i.height/2+n;if(e>=i.center.x-r&&e<=i.center.x+r&&t>=i.center.y-o&&t<=i.center.y+o)return i}return null}isObstacleAt(e,t,n){return this.getObstacleAt(e,t,n)!==null}getDirectionDistancesToNearestObstacle(e,t){let{GRID_STEP:n}=this,i={left:1/0,top:1/0,bottom:1/0,right:1/0};for(let r of this.obstacles)if(r.type==="rect"){let o=r.center.x-r.width/2-n,s=r.center.x+r.width/2+n,a=r.center.y+r.height/2+n,c=r.center.y-r.height/2-n;t>=c&&t<=a&&e>o&&(i.left=Math.min(i.left,e-s)),t>=c&&t<=a&&e<s&&(i.right=Math.min(i.right,o-e)),e>=o&&e<=s&&t<a&&(i.top=Math.min(i.top,c-t)),e>=o&&e<=s&&t>c&&(i.bottom=Math.min(i.bottom,t-a))}return i}getOrthoDirectionCollisionInfo(e,t,{margin:n=0}={}){let{x:i,y:r}=e,{dx:o,dy:s}=t,a=1/0,c=null;for(let l of this.obstacles){let u=l.left-n,h=l.right+n,f=l.top+n,_=l.bottom-n,y=null;o===1&&s===0?r>_&&r<f&&i<l.left&&(y=l.left-i):o===-1&&s===0?r>_&&r<f&&i>l.right&&(y=i-l.right):o===0&&s===1?i>u&&i<h&&r<l.bottom&&(y=l.bottom-r):o===0&&s===-1&&i>u&&i<h&&r>l.top&&(y=r-l.top),y!==null&&y<a&&(a=y,c=l)}return{dx:o,dy:s,wallDistance:a,obstacle:c}}getObstaclesOverlappingRegion(e){let t=[];for(let n of this.obstacles){let{left:i,right:r,top:o,bottom:s}=n;i<=e.maxX&&r>=e.minX&&o<=e.maxY&&s>=e.minY&&t.push(n)}return t}};function udt(e){if(e.length<4)return e;let t=[{...e[0]}],n=e[0].layer;for(let i=1;i<e.length;i++){let r={start:e[i-1],end:e[i]},o=e[i].route_type==="via"||e[i-1].route_type==="via";if(e[i].layer!==n||o){t.push({...e[i]}),n=e[i].layer;continue}let s=!1,a=null,c=-1;for(let u=0;u<t.length-1;u++){let h={start:t[u],end:t[u+1]};if(h.start.layer===r.start.layer&&h.start.layer===r.start.layer){let f=pdt(h,r);if(f){s=!0,a={...f,layer:n},c=u;break}}}s&&a&&(t.splice(c+1),t.push(a));let l=t[t.length-1];(l.x!==e[i].x||l.y!==e[i].y)&&t.push(e[i])}return t}function pdt(e,t){if(e.start.x===e.end.x&&t.start.x===t.end.x||e.start.y===e.end.y&&t.start.y===t.end.y)return null;let n;if(e.start.x===e.end.x){let i=e.start.x,r=t.start.y;n={...e.start,x:i,y:r}}else{let i=t.start.x,r=e.start.y;n={...e.start,x:i,y:r}}return BO(n,e)&&BO(n,t)?n:null}function BO(e,t){return e.x>=Math.min(t.start.x,t.end.x)&&e.x<=Math.max(t.start.x,t.end.x)&&e.y>=Math.min(t.start.y,t.end.y)&&e.y<=Math.max(t.start.y,t.end.y)}function hdt(e){let t=[e[0]];for(let n=1;n<e.length-1;n++){let[i,r,o]=[e[n-1],e[n],e[n+1]];t.push(r),!(r.route_type!=="wire"||i.route_type!=="wire"||o.route_type!=="wire")&&i.layer===r.layer&&r.layer!==o.layer&&t.push({route_type:"via",from_layer:r.layer,to_layer:o.layer,x:r.x,y:r.y})}return t.push(e[e.length-1]),t}var DRt=(0,qO.default)("autorouter:shortenPathWithShortcuts");function ddt(e,t){if(e.length<=2)return e;let n=[e[0]];for(let i=1;i<e.length;i++){let r={start:n[n.length-1],end:e[i]},o=-1,s=r.start.x===r.end.x,a=r.start.y===r.end.y;for(let c=i+1;c<e.length;c++){if(c<=o)continue;let l={start:e[c],end:e[c+1]};if(!l.end)continue;let u=l.start.x===l.end.x,h=l.start.y===l.end.y,f=s&&u,_=a&&h;if(_&&f||!(f||_))continue;let x=!1,v=Math.min(r.start.x,r.end.x),w=Math.max(r.start.x,r.end.x),S=Math.min(l.start.x,l.end.x),k=Math.max(l.start.x,l.end.x),E=Math.min(r.start.y,r.end.y),R=Math.max(r.start.y,r.end.y),I=Math.min(l.start.y,l.end.y),C=Math.max(l.start.y,l.end.y);if(_?x=v<=k&&w>=S:f&&(x=E<=C&&R>=I),!x)continue;let M=[],A=n[n.length-1],L=e[c+2];if(!L)continue;_&&S<w&&L.x===S&&M.push({x:S,y:r.start.y,layer:r.start.layer}),_&&k>v&&L.x===k&&M.push({x:k,y:r.start.y,layer:r.start.layer}),f&&I<R&&L.y===I&&M.push({x:r.start.x,y:I,layer:r.start.layer}),f&&C>E&&L.y===C&&M.push({x:r.start.x,y:C,layer:r.start.layer});let B=null;for(let D of M)if(!(t(A,D)||t(L,D))){B=D;break}if(B){n.push(B),i=c+1,o=c+1;break}}o===-1&&n.push(e[i])}return n[n.length-1]!==e[e.length-1]&&n.push(e[e.length-1]),n}var sl=(0,HO.default)("autorouting-dataset:astar"),WO=class{constructor(e){T(this,"openSet",[]);T(this,"closedSet",new Set);T(this,"debug",!1);T(this,"debugSolutions");T(this,"debugMessage",null);T(this,"debugTraceCount",0);T(this,"input");T(this,"obstacles");T(this,"allObstacles");T(this,"startNode");T(this,"goalPoint");T(this,"GRID_STEP");T(this,"OBSTACLE_MARGIN");T(this,"MAX_ITERATIONS");T(this,"isRemovePathLoopsEnabled");T(this,"isShortenPathWithShortcutsEnabled");T(this,"GREEDY_MULTIPLIER",1.1);T(this,"iterations",-1);this.input=e.input,this.allObstacles=e.input.obstacles,this.startNode=e.startNode,this.goalPoint=e.goalPoint?{l:0,...e.goalPoint}:void 0,this.GRID_STEP=e.GRID_STEP??.1,this.OBSTACLE_MARGIN=e.OBSTACLE_MARGIN??.15,this.MAX_ITERATIONS=e.MAX_ITERATIONS??100,this.debug=e.debug??sl.enabled,this.isRemovePathLoopsEnabled=e.isRemovePathLoopsEnabled??!1,this.isShortenPathWithShortcutsEnabled=e.isShortenPathWithShortcutsEnabled??!1,this.debug&&(sl.enabled=!0),sl.enabled&&(this.debugSolutions={},this.debugMessage="")}getNeighbors(e){return[]}isSameNode(e,t){return al(e,t)<this.GRID_STEP}computeG(e,t){return e.g+al(e,t)}computeH(e){return al(e,this.goalPoint)}getNodeName(e){return VO(e,this.GRID_STEP)}solveOneStep(){this.iterations+=1;let{openSet:e,closedSet:t,GRID_STEP:n,goalPoint:i}=this;e.sort((a,c)=>a.f-c.f);let r=e.shift();if(this.computeH(r)<=n*2)return{solved:!0,current:r,newNeighbors:[]};this.closedSet.add(this.getNodeName(r));let s=[];for(let a of this.getNeighbors(r)){if(t.has(this.getNodeName(a)))continue;let c=this.computeG(r,a),l=this.openSet.find(u=>this.isSameNode(u,a));if(!l||c<l.g){let u=this.computeH(a),h=c+u*this.GREEDY_MULTIPLIER,f={...a,g:c,h:u,f:h,obstacleHit:a.obstacleHit??void 0,manDistFromParent:al(r,a),nodesInPath:r.nodesInPath+1,parent:r,enterMarginCost:a.enterMarginCost,travelMarginCostFactor:a.travelMarginCostFactor};e.push(f),s.push(f)}}return sl.enabled&&(e.sort((a,c)=>a.f-c.f),this.drawDebugSolution({current:r,newNeighbors:s})),{solved:!1,current:r,newNeighbors:s}}getStartNode(e){return{x:e.pointsToConnect[0].x,y:e.pointsToConnect[0].y,manDistFromParent:0,f:0,g:0,h:0,nodesInPath:0,parent:null}}layerToIndex(e){return 0}indexToLayer(e){return"top"}preprocessConnectionBeforeSolving(e){return e}solveConnection(e){if(e.pointsToConnect.length>2)throw new Error("GeneralizedAstarAutorouter doesn't currently support 2+ points in a connection");e=this.preprocessConnectionBeforeSolving(e);let{pointsToConnect:t}=e;for(this.iterations=0,this.closedSet=new Set,this.startNode=this.getStartNode(e),this.goalPoint={...t[t.length-1],l:this.layerToIndex(t[t.length-1].layer)},this.openSet=[this.startNode];this.iterations<this.MAX_ITERATIONS;){let{solved:n,current:i}=this.solveOneStep();if(n){let r=[],o=i;for(;o;){let s=o.l;r.unshift({x:o.x,y:o.y,layer:s!==void 0?this.indexToLayer(s):t[0].layer}),o=o.parent}return sl.enabled&&(this.debugMessage+=`t${this.debugTraceCount}: ${this.iterations} iterations
144
+ )`,enabled:":not(:disabled)",checked:":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",required:":is(input, select, textarea)[required]",optional:":is(input, select, textarea):not([required])",selected:"option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",checkbox:"[type=checkbox]",file:"[type=file]",password:"[type=password]",radio:"[type=radio]",reset:"[type=reset]",image:"[type=image]",submit:"[type=submit]",parent:":not(:empty)",header:":is(h1, h2, h3, h4, h5, h6)",button:":is(button, input[type=button])",input:":is(input, textarea, select, button)",text:"input:is(:not([type!='']), [type=text])"};var Gr=Xt(Qc(),1);var QP={};function t5(e,t){return e===Gr.default.falseFunc?Gr.default.falseFunc:n=>t.isTag(n)&&e(n)}function e5(e,t){let n=t.getSiblings(e);if(n.length<=1)return[];let i=n.indexOf(e);return i<0||i===n.length-1?[]:n.slice(i+1).filter(t.isTag)}function JP(e){return{xmlMode:!!e.xmlMode,lowerCaseAttributeNames:!!e.lowerCaseAttributeNames,lowerCaseTags:!!e.lowerCaseTags,quirksMode:!!e.quirksMode,cacheResults:!!e.cacheResults,pseudos:e.pseudos,adapter:e.adapter,equals:e.equals}}var KP=(e,t,n,i,r)=>{let o=r(t,JP(n),i);return o===Gr.default.trueFunc?e:o===Gr.default.falseFunc?Gr.default.falseFunc:s=>o(s)&&e(s)},Oy={is:KP,matches:KP,where:KP,not(e,t,n,i,r){let o=r(t,JP(n),i);return o===Gr.default.falseFunc?e:o===Gr.default.trueFunc?Gr.default.falseFunc:s=>!o(s)&&e(s)},has(e,t,n,i,r){let{adapter:o}=n,s=JP(n);s.relativeSelector=!0;let a=t.some(u=>u.some(dd))?[QP]:void 0,c=r(t,s,a);if(c===Gr.default.falseFunc)return Gr.default.falseFunc;let l=t5(c,o);if(a&&c!==Gr.default.trueFunc){let{shouldTestNextSiblings:u=!1}=c;return h=>{if(!e(h))return!1;a[0]=h;let f=o.getChildren(h),_=u?[...f,...e5(h,o)]:f;return o.existsOne(l,_)}}return u=>e(u)&&o.existsOne(l,o.getChildren(u))}};function aO(e,t,n,i,r){var o;let{name:s,data:a}=t;if(Array.isArray(a)){if(!(s in Oy))throw new Error(`Unknown pseudo-class :${s}(${a})`);return Oy[s](e,a,n,i,r)}let c=(o=n.pseudos)===null||o===void 0?void 0:o[s],l=typeof c=="string"?c:ZP[s];if(typeof l=="string"){if(a!=null)throw new Error(`Pseudo ${s} doesn't have any arguments`);let u=hd(l);return Oy.is(e,u,n,i,r)}if(typeof c=="function")return WP(c,s,a,1),u=>c(u,a)&&e(u);if(s in md)return md[s](e,a,n,i);if(s in Ry){let u=Ry[s];return WP(u,s,a,2),h=>u(h,n,a)&&e(h)}throw new Error(`Unknown pseudo-class :${s}`)}function n5(e,t){let n=t.getParent(e);return n&&t.isTag(n)?n:null}function cO(e,t,n,i,r){let{adapter:o,equals:s}=n;switch(t.type){case ie.PseudoElement:throw new Error("Pseudo-elements are not supported by css-select");case ie.ColumnCombinator:throw new Error("Column combinators are not yet supported by css-select");case ie.Attribute:{if(t.namespace!=null)throw new Error("Namespaced attributes are not yet supported by css-select");return(!n.xmlMode||n.lowerCaseAttributeNames)&&(t.name=t.name.toLowerCase()),iO[t.action](e,t,n)}case ie.Pseudo:return aO(e,t,n,i,r);case ie.Tag:{if(t.namespace!=null)throw new Error("Namespaced tag names are not yet supported by css-select");let{name:a}=t;return(!n.xmlMode||n.lowerCaseTags)&&(a=a.toLowerCase()),function(l){return o.getName(l)===a&&e(l)}}case ie.Descendant:{if(n.cacheResults===!1||typeof WeakSet>"u")return function(l){let u=l;for(;u=n5(u,o);)if(e(u))return!0;return!1};let a=new WeakSet;return function(l){let u=l;for(;u=n5(u,o);)if(!a.has(u)){if(o.isTag(u)&&e(u))return!0;a.add(u)}return!1}}case"_flexibleDescendant":return function(c){let l=c;do if(e(l))return!0;while(l=n5(l,o));return!1};case ie.Parent:return function(c){return o.getChildren(c).some(l=>o.isTag(l)&&e(l))};case ie.Child:return function(c){let l=o.getParent(c);return l!=null&&o.isTag(l)&&e(l)};case ie.Sibling:return function(c){let l=o.getSiblings(c);for(let u=0;u<l.length;u++){let h=l[u];if(s(c,h))break;if(o.isTag(h)&&e(h))return!0}return!1};case ie.Adjacent:return o.prevElementSibling?function(c){let l=o.prevElementSibling(c);return l!=null&&e(l)}:function(c){let l=o.getSiblings(c),u;for(let h=0;h<l.length;h++){let f=l[h];if(s(c,f))break;o.isTag(f)&&(u=f)}return!!u&&e(u)};case ie.Universal:{if(t.namespace!=null&&t.namespace!=="*")throw new Error("Namespaced universal selectors are not yet supported by css-select");return e}}}function lO(e,t,n){let i=Ly(e,t,n);return t5(i,t.adapter)}function Ly(e,t,n){let i=typeof e=="string"?hd(e):e;return Fy(i,t,n)}function uO(e){return e.type===ie.Pseudo&&(e.name==="scope"||Array.isArray(e.data)&&e.data.some(t=>t.some(uO)))}var Zht={type:ie.Descendant},Kht={type:"_flexibleDescendant"},Jht={type:ie.Pseudo,name:"scope",data:null};function Qht(e,{adapter:t},n){let i=!!n?.every(r=>{let o=t.isTag(r)&&t.getParent(r);return r===QP||o&&t.isTag(o)});for(let r of e){if(!(r.length>0&&dd(r[0])&&r[0].type!==ie.Descendant))if(i&&!r.some(uO))r.unshift(Zht);else continue;r.unshift(Jht)}}function Fy(e,t,n){var i;e.forEach(GP),n=(i=t.context)!==null&&i!==void 0?i:n;let r=Array.isArray(n),o=n&&(Array.isArray(n)?n:[n]);if(t.relativeSelector!==!1)Qht(e,t,o);else if(e.some(c=>c.length>0&&dd(c[0])))throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");let s=!1,a=e.map(c=>{if(c.length>=2){let[l,u]=c;l.type!==ie.Pseudo||l.name!=="scope"||(r&&u.type===ie.Descendant?c[1]=Kht:(u.type===ie.Adjacent||u.type===ie.Sibling)&&(s=!0))}return tdt(c,t,o)}).reduce(edt,Ps.default.falseFunc);return a.shouldTestNextSiblings=s,a}function tdt(e,t,n){var i;return e.reduce((r,o)=>r===Ps.default.falseFunc?Ps.default.falseFunc:cO(r,o,t,n,Fy),(i=t.rootFunc)!==null&&i!==void 0?i:Ps.default.trueFunc)}function edt(e,t){return t===Ps.default.falseFunc||e===Ps.default.trueFunc?e:e===Ps.default.falseFunc||t===Ps.default.trueFunc?t:function(i){return e(i)||t(i)}}var pO=(e,t)=>e===t,ndt={adapter:Ay,equals:pO};function hO(e){var t,n,i,r;let o=e??ndt;return(t=o.adapter)!==null&&t!==void 0||(o.adapter=Ay),(n=o.equals)!==null&&n!==void 0||(o.equals=(r=(i=o.adapter)===null||i===void 0?void 0:i.equals)!==null&&r!==void 0?r:pO),o}function r5(e){return function(n,i,r){let o=hO(i);return e(n,o,r)}}var L6t=r5(lO),F6t=r5(Ly),z6t=r5(Fy);function dO(e){return function(n,i,r){let o=hO(r);typeof n!="function"&&(n=Ly(n,o,i));let s=idt(i,o.adapter,n.shouldTestNextSiblings);return e(n,s,o)}}function idt(e,t,n=!1){return n&&(e=rdt(e,t)),Array.isArray(e)?t.removeSubsets(e):t.getChildren(e)}function rdt(e,t){let n=Array.isArray(e)?e.slice(0):[e],i=n.length;for(let r=0;r<i;r++){let o=e5(n[r],t);n.push(...o)}return n}var o5=dO((e,t,n)=>e===i5.default.falseFunc||!t||t.length===0?[]:n.adapter.findAll(e,t)),zy=dO((e,t,n)=>e===i5.default.falseFunc||!t||t.length===0?null:n.adapter.findOne(e,t));Z();St();Z();var HO=Xt(Pn(),1);St();var qO=Xt(Pn(),1),ZO=Xt(Pn(),1);St();Ao();h5();var d5=(e,t={})=>{let n=e._internal_store;if(!n){n={counts:{}},e._internal_store=n;for(let r of e){let o=r.type,s=r[`${o}_id`];if(!s)continue;let a=Number.parseInt(s.split("_").pop());Number.isNaN(a)||(n.counts[o]=Math.max(n.counts[o]??0,a))}}return new Proxy({},{get:(r,o)=>o==="toArray"?()=>e:{get:s=>e.find(a=>a.type===o&&a[`${o}_id`]===s),getUsing:s=>{let a=Object.keys(s);if(a.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");let c=a[0],l=c.replace("_id",""),u=e.find(h=>h.type===l&&h[c]===s[c]);return u?e.find(h=>h.type===o&&h[`${o}_id`]===u[`${o}_id`]):null},getWhere:s=>{let a=Object.keys(s);return e.find(c=>c.type===o&&a.every(l=>c[l]===s[l]))},list:s=>{let a=s?Object.keys(s):[];return e.filter(c=>c.type===o&&a.every(l=>c[l]===s[l]))},insert:s=>{var l;(l=n.counts)[o]??(l[o]=-1),n.counts[o]++;let a=n.counts[o],c={type:o,[`${o}_id`]:`${o}_${a}`,...s};return t.validateInserts&&(Gc[o]??Hc).parse(c),e.push(c),c},delete:s=>{let a=e.find(c=>c[`${o}_id`]===s);a&&e.splice(e.indexOf(a),1)},update:(s,a)=>{let c=e.find(l=>l.type===o&&l[`${o}_id`]===s);if(c)return Object.assign(c,a),c},select:s=>{if(o==="source_component")return e.find(a=>a.type==="source_component"&&a.name===s.replace(/\./g,""));if(o==="pcb_port"||o==="source_port"||o==="schematic_port"){let[a,c]=s.replace(/\./g,"").split(/[\s\>]+/),l=e.find(h=>h.type==="source_component"&&h.name===a);if(!l)return null;let u=e.find(h=>h.type==="source_port"&&h.source_component_id===l.source_component_id&&(h.name===c||(h.port_hints??[]).includes(c)));if(!u)return null;if(o==="source_port")return u;if(o==="pcb_port")return e.find(h=>h.type==="pcb_port"&&h.source_port_id===u.source_port_id);if(o==="schematic_port")return e.find(h=>h.type==="schematic_port"&&h.source_port_id===u.source_port_id)}}}})};d5.unparsed=d5;var MO=d5;var BRt=Xt(CO(),1);Xi();function Ts(e){let t=e.width/2,n=e.height/2;return{minX:e.center.x-t,maxX:e.center.x+t,minY:e.center.y-n,maxY:e.center.y+n}}function ap(e,t){let n=Ts(e),i=Ts(t),r=Math.max(n.minX-i.maxX,i.minX-n.maxX,0),o=Math.max(n.minY-i.maxY,i.minY-n.maxY,0),s={x:0,y:0},a={x:0,y:0};return r===0&&o===0?{distance:0,pointA:e.center,pointB:t.center}:(s.x=Ln(e.center.x,i.minX,i.maxX),s.y=Ln(e.center.y,i.minY,i.maxY),a.x=Ln(t.center.x,n.minX,n.maxX),a.y=Ln(t.center.y,n.minY,n.maxY),{distance:Math.hypot(s.x-a.x,s.y-a.y),pointA:s,pointB:a})}function Ln(e,t,n){return Math.max(t,Math.min(n,e))}function vd(e,t){let n=Number.POSITIVE_INFINITY,i={x:0,y:0},r={x:0,y:0};for(let o of e)for(let s of t){let{distance:a,pointA:c,pointB:l}=ap(o,s);a<n&&(n=a,i=c,r=l)}return{pointA:i,pointB:r,distance:n}}Xi();Xi();var FO="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var zO=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=FO[n[e]&63];return t};Xi();var al=(e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y),DO=(e,t)=>{let n=t.x-e.x,i=t.y-e.y;return Math.abs(n)>Math.abs(i)?{dx:Math.sign(n),dy:0}:{dx:0,dy:Math.sign(i)}},XO=(e,t,n)=>Math.abs(e.x-t.x)*Math.abs(n.dx)+Math.abs(e.y-t.y)*Math.abs(n.dy),VO=(e,t=.1)=>`${Math.round(e.x/t)},${Math.round(e.y/t)}`,$O=(e,t)=>Math.abs(e-t)<1e-4,GO=(e,t,{viaDiameter:n=.5}={})=>{let i=[];for(let r=0;r<e.length-1;r++){let[o,s]=[e[r],e[r+1]],a=r-1>=0?e[r-1]:null,c=$O(o.y,s.y),l=$O(o.x,s.x);if(!c&&!l)throw new Error(`getObstaclesFromTrace currently only supports horizontal and vertical traces (not diagonals) Conflicting trace: ${t}, start: (${o.x}, ${o.y}), end: (${s.x}, ${s.y})`);let u={type:"rect",layers:[o.layer],center:{x:(o.x+s.x)/2,y:(o.y+s.y)/2},width:c?Math.abs(o.x-s.x):.1,height:l?Math.abs(o.y-s.y):.1,connectedTo:[t]};if(i.push(u),a&&a.layer===o.layer&&o.layer!==s.layer){let h={type:"rect",layers:[o.layer,s.layer],center:{x:o.x,y:o.y},connectedTo:[t],width:n,height:n};i.push(h)}}return i},UO=class{constructor(e){T(this,"obstacles");T(this,"GRID_STEP",.1);this.obstacles=e.map(t=>({...t,left:t.center.x-t.width/2,right:t.center.x+t.width/2,top:t.center.y+t.height/2,bottom:t.center.y-t.height/2}))}getObstacleAt(e,t,n){n??(n=this.GRID_STEP);for(let i of this.obstacles){let r=i.width/2+n,o=i.height/2+n;if(e>=i.center.x-r&&e<=i.center.x+r&&t>=i.center.y-o&&t<=i.center.y+o)return i}return null}isObstacleAt(e,t,n){return this.getObstacleAt(e,t,n)!==null}getDirectionDistancesToNearestObstacle(e,t){let{GRID_STEP:n}=this,i={left:1/0,top:1/0,bottom:1/0,right:1/0};for(let r of this.obstacles)if(r.type==="rect"){let o=r.center.x-r.width/2-n,s=r.center.x+r.width/2+n,a=r.center.y+r.height/2+n,c=r.center.y-r.height/2-n;t>=c&&t<=a&&e>o&&(i.left=Math.min(i.left,e-s)),t>=c&&t<=a&&e<s&&(i.right=Math.min(i.right,o-e)),e>=o&&e<=s&&t<a&&(i.top=Math.min(i.top,c-t)),e>=o&&e<=s&&t>c&&(i.bottom=Math.min(i.bottom,t-a))}return i}getOrthoDirectionCollisionInfo(e,t,{margin:n=0}={}){let{x:i,y:r}=e,{dx:o,dy:s}=t,a=1/0,c=null;for(let l of this.obstacles){let u=l.left-n,h=l.right+n,f=l.top+n,_=l.bottom-n,y=null;o===1&&s===0?r>_&&r<f&&i<l.left&&(y=l.left-i):o===-1&&s===0?r>_&&r<f&&i>l.right&&(y=i-l.right):o===0&&s===1?i>u&&i<h&&r<l.bottom&&(y=l.bottom-r):o===0&&s===-1&&i>u&&i<h&&r>l.top&&(y=r-l.top),y!==null&&y<a&&(a=y,c=l)}return{dx:o,dy:s,wallDistance:a,obstacle:c}}getObstaclesOverlappingRegion(e){let t=[];for(let n of this.obstacles){let{left:i,right:r,top:o,bottom:s}=n;i<=e.maxX&&r>=e.minX&&o<=e.maxY&&s>=e.minY&&t.push(n)}return t}};function udt(e){if(e.length<4)return e;let t=[{...e[0]}],n=e[0].layer;for(let i=1;i<e.length;i++){let r={start:e[i-1],end:e[i]},o=e[i].route_type==="via"||e[i-1].route_type==="via";if(e[i].layer!==n||o){t.push({...e[i]}),n=e[i].layer;continue}let s=!1,a=null,c=-1;for(let u=0;u<t.length-1;u++){let h={start:t[u],end:t[u+1]};if(h.start.layer===r.start.layer&&h.start.layer===r.start.layer){let f=pdt(h,r);if(f){s=!0,a={...f,layer:n},c=u;break}}}s&&a&&(t.splice(c+1),t.push(a));let l=t[t.length-1];(l.x!==e[i].x||l.y!==e[i].y)&&t.push(e[i])}return t}function pdt(e,t){if(e.start.x===e.end.x&&t.start.x===t.end.x||e.start.y===e.end.y&&t.start.y===t.end.y)return null;let n;if(e.start.x===e.end.x){let i=e.start.x,r=t.start.y;n={...e.start,x:i,y:r}}else{let i=t.start.x,r=e.start.y;n={...e.start,x:i,y:r}}return BO(n,e)&&BO(n,t)?n:null}function BO(e,t){return e.x>=Math.min(t.start.x,t.end.x)&&e.x<=Math.max(t.start.x,t.end.x)&&e.y>=Math.min(t.start.y,t.end.y)&&e.y<=Math.max(t.start.y,t.end.y)}function hdt(e){let t=[e[0]];for(let n=1;n<e.length-1;n++){let[i,r,o]=[e[n-1],e[n],e[n+1]];t.push(r),!(r.route_type!=="wire"||i.route_type!=="wire"||o.route_type!=="wire")&&i.layer===r.layer&&r.layer!==o.layer&&t.push({route_type:"via",from_layer:r.layer,to_layer:o.layer,x:r.x,y:r.y})}return t.push(e[e.length-1]),t}var DRt=(0,qO.default)("autorouter:shortenPathWithShortcuts");function ddt(e,t){if(e.length<=2)return e;let n=[e[0]];for(let i=1;i<e.length;i++){let r={start:n[n.length-1],end:e[i]},o=-1,s=r.start.x===r.end.x,a=r.start.y===r.end.y;for(let c=i+1;c<e.length;c++){if(c<=o)continue;let l={start:e[c],end:e[c+1]};if(!l.end)continue;let u=l.start.x===l.end.x,h=l.start.y===l.end.y,f=s&&u,_=a&&h;if(_&&f||!(f||_))continue;let x=!1,v=Math.min(r.start.x,r.end.x),w=Math.max(r.start.x,r.end.x),S=Math.min(l.start.x,l.end.x),k=Math.max(l.start.x,l.end.x),E=Math.min(r.start.y,r.end.y),R=Math.max(r.start.y,r.end.y),I=Math.min(l.start.y,l.end.y),C=Math.max(l.start.y,l.end.y);if(_?x=v<=k&&w>=S:f&&(x=E<=C&&R>=I),!x)continue;let M=[],A=n[n.length-1],L=e[c+2];if(!L)continue;_&&S<w&&L.x===S&&M.push({x:S,y:r.start.y,layer:r.start.layer}),_&&k>v&&L.x===k&&M.push({x:k,y:r.start.y,layer:r.start.layer}),f&&I<R&&L.y===I&&M.push({x:r.start.x,y:I,layer:r.start.layer}),f&&C>E&&L.y===C&&M.push({x:r.start.x,y:C,layer:r.start.layer});let B=null;for(let D of M)if(!(t(A,D)||t(L,D))){B=D;break}if(B){n.push(B),i=c+1,o=c+1;break}}o===-1&&n.push(e[i])}return n[n.length-1]!==e[e.length-1]&&n.push(e[e.length-1]),n}var sl=(0,HO.default)("autorouting-dataset:astar"),WO=class{constructor(e){T(this,"openSet",[]);T(this,"closedSet",new Set);T(this,"debug",!1);T(this,"debugSolutions");T(this,"debugMessage",null);T(this,"debugTraceCount",0);T(this,"input");T(this,"obstacles");T(this,"allObstacles");T(this,"startNode");T(this,"goalPoint");T(this,"GRID_STEP");T(this,"OBSTACLE_MARGIN");T(this,"MAX_ITERATIONS");T(this,"isRemovePathLoopsEnabled");T(this,"isShortenPathWithShortcutsEnabled");T(this,"GREEDY_MULTIPLIER",1.1);T(this,"iterations",-1);this.input=e.input,this.allObstacles=e.input.obstacles,this.startNode=e.startNode,this.goalPoint=e.goalPoint?{l:0,...e.goalPoint}:void 0,this.GRID_STEP=e.GRID_STEP??.1,this.OBSTACLE_MARGIN=e.OBSTACLE_MARGIN??.15,this.MAX_ITERATIONS=e.MAX_ITERATIONS??100,this.debug=e.debug??sl.enabled,this.isRemovePathLoopsEnabled=e.isRemovePathLoopsEnabled??!1,this.isShortenPathWithShortcutsEnabled=e.isShortenPathWithShortcutsEnabled??!1,this.debug&&(sl.enabled=!0),sl.enabled&&(this.debugSolutions={},this.debugMessage="")}getNeighbors(e){return[]}isSameNode(e,t){return al(e,t)<this.GRID_STEP}computeG(e,t){return e.g+al(e,t)}computeH(e){return al(e,this.goalPoint)}getNodeName(e){return VO(e,this.GRID_STEP)}solveOneStep(){this.iterations+=1;let{openSet:e,closedSet:t,GRID_STEP:n,goalPoint:i}=this;e.sort((a,c)=>a.f-c.f);let r=e.shift();if(this.computeH(r)<=n*2)return{solved:!0,current:r,newNeighbors:[]};this.closedSet.add(this.getNodeName(r));let s=[];for(let a of this.getNeighbors(r)){if(t.has(this.getNodeName(a)))continue;let c=this.computeG(r,a),l=this.openSet.find(u=>this.isSameNode(u,a));if(!l||c<l.g){let u=this.computeH(a),h=c+u*this.GREEDY_MULTIPLIER,f={...a,g:c,h:u,f:h,obstacleHit:a.obstacleHit??void 0,manDistFromParent:al(r,a),nodesInPath:r.nodesInPath+1,parent:r,enterMarginCost:a.enterMarginCost,travelMarginCostFactor:a.travelMarginCostFactor};e.push(f),s.push(f)}}return sl.enabled&&(e.sort((a,c)=>a.f-c.f),this.drawDebugSolution({current:r,newNeighbors:s})),{solved:!1,current:r,newNeighbors:s}}getStartNode(e){return{x:e.pointsToConnect[0].x,y:e.pointsToConnect[0].y,manDistFromParent:0,f:0,g:0,h:0,nodesInPath:0,parent:null}}layerToIndex(e){return 0}indexToLayer(e){return"top"}preprocessConnectionBeforeSolving(e){return e}solveConnection(e){if(e.pointsToConnect.length>2)throw new Error("GeneralizedAstarAutorouter doesn't currently support 2+ points in a connection");e=this.preprocessConnectionBeforeSolving(e);let{pointsToConnect:t}=e;for(this.iterations=0,this.closedSet=new Set,this.startNode=this.getStartNode(e),this.goalPoint={...t[t.length-1],l:this.layerToIndex(t[t.length-1].layer)},this.openSet=[this.startNode];this.iterations<this.MAX_ITERATIONS;){let{solved:n,current:i}=this.solveOneStep();if(n){let r=[],o=i;for(;o;){let s=o.l;r.unshift({x:o.x,y:o.y,layer:s!==void 0?this.indexToLayer(s):t[0].layer}),o=o.parent}return sl.enabled&&(this.debugMessage+=`t${this.debugTraceCount}: ${this.iterations} iterations
145
145
  `),this.isRemovePathLoopsEnabled&&(r=udt(r)),this.isShortenPathWithShortcutsEnabled&&(r=ddt(r,(s,a)=>{if(s.x===a.x&&s.y===a.y)return!1;let c=this.obstacles.getOrthoDirectionCollisionInfo({x:s.x,y:s.y,l:this.layerToIndex(s.layer)??0},{dx:Math.sign(a.x-s.x),dy:Math.sign(a.y-s.y),dl:0},{margin:.05}),l=Math.sqrt((s.x-a.x)**2+(s.y-a.y)**2);return c.wallDistance<l})),{solved:!0,route:r,connectionName:e.name}}if(this.openSet.length===0)break}return sl.enabled&&(this.debugMessage+=`t${this.debugTraceCount}: ${this.iterations} iterations (failed)
146
146
  `),{solved:!1,connectionName:e.name}}createObstacleList({dominantLayer:e,connection:t,obstaclesFromTraces:n}){return new UO(this.allObstacles.filter(i=>!i.connectedTo.includes(t.name)).filter(i=>i.layers.includes(e)).concat(n??[]))}postprocessConnectionSolveResult(e,t){return t}solve(){let e=[],t=[];this.debugTraceCount=0;for(let n of this.input.connections){let i=n.pointsToConnect[0].layer??"top";this.debugTraceCount+=1,this.obstacles=this.createObstacleList({dominantLayer:i,connection:n,obstaclesFromTraces:t});let r=this.solveConnection(n);r=this.postprocessConnectionSolveResult(n,r),e.push(r),sl.enabled&&this.drawDebugTraceObstacles(t),r.solved&&t.push(...GO(r.route.map(o=>({x:o.x,y:o.y,layer:o.layer??i})),n.name))}return e}solveAndMapToTraces(){return this.solve().flatMap(t=>t.solved?[{type:"pcb_trace",pcb_trace_id:`pcb_trace_for_${t.connectionName}`,route:hdt(t.route.map(n=>({route_type:"wire",x:n.x,y:n.y,width:this.input.minTraceWidth,layer:n.layer})))}]:[])}getDebugGroup(){let e=`t${this.debugTraceCount}_iter[${this.iterations-1}]`;return this.iterations<30||this.iterations<100&&this.iterations%10===0||this.iterations<1e3&&this.iterations%100===0||!this.debugSolutions?e:null}drawDebugTraceObstacles(e){let{debugTraceCount:t,debugSolutions:n}=this;for(let i in n)i.startsWith(`t${t}_`)&&n[i].push(...e.map((r,o)=>({type:"pcb_smtpad",pcb_component_id:"",layer:r.layers[0],width:r.width,shape:"rect",x:r.center.x,y:r.center.y,pcb_smtpad_id:`trace_obstacle_${o}`,height:r.height})))}drawDebugSolution({current:e,newNeighbors:t}){let n=this.getDebugGroup();if(!n)return;let{openSet:i,debugTraceCount:r,debugSolutions:o}=this;o[n]??(o[n]=[]);let s=o[n];s.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${e.x}_${e.y}`,font:"tscircuit2024",font_size:.25,text:"X"+(e.l!==void 0?e.l:""),pcb_component_id:"",layer:"top",anchor_position:{x:e.x,y:e.y},anchor_alignment:"center"});for(let a=0;a<i.length;a++){let c=i[a];s.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${c.x}_${c.y}`,layer:"top",route:[[0,.05],[.05,0],[0,-.05],[-.05,0],[0,.05]].map(([l,u])=>({x:c.x+l,y:c.y+u})),stroke_width:.01}),s.push({type:"pcb_fabrication_note_text",pcb_fabrication_note_text_id:`debug_note_${c.x}_${c.y}`,font:"tscircuit2024",font_size:.03,text:a.toString(),pcb_component_id:"",layer:"top",anchor_position:{x:c.x,y:c.y},anchor_alignment:"center"})}if(e.parent){let a=[],c=e;for(;c;)a.unshift(c),c=c.parent;s.push({type:"pcb_fabrication_note_path",pcb_component_id:"",pcb_fabrication_note_path_id:`note_path_${e.x}_${e.y}`,layer:"top",route:a,stroke_width:.01})}}},fdt=(0,ZO.default)("autorouting-dataset:infinite-grid-ijump-astar:get-distance-to-overcome-obstacle");function y5({node:e,travelDir:t,wallDir:n,obstacle:i,obstacles:r,obstaclesInRow:o=0,OBSTACLE_MARGIN:s=.15,SHOULD_DETECT_CONJOINED_OBSTACLES:a=!1,MAX_CONJOINED_OBSTACLES:c=20}){let l;if(t.dx===0?t.dy>0?l=i.center.y+i.height/2-e.y:l=e.y-(i.center.y-i.height/2):t.dx>0?l=i.center.x+i.width/2-e.x:l=e.x-(i.center.x-i.width/2),l+=s,a&&o<c){let u=r.getObstacleAt(e.x+t.dx*l+n.dx*(n.wallDistance+.001),e.y+t.dy*l+n.dy*(n.wallDistance+.001));if(u===i)return l;if(u&&u.type==="rect"){let h=t.dy===0,f=h?i.height:i.width;if((h?u.height:u.width)>f)return fdt("next obstacle on path is bigger, not trying to overcome it"),l;let y=y5({node:{x:e.x+t.dx*l,y:e.y+t.dy*l},travelDir:t,wallDir:n,obstacle:u,obstacles:r,obstaclesInRow:o+1,SHOULD_DETECT_CONJOINED_OBSTACLES:a,MAX_CONJOINED_OBSTACLES:c,OBSTACLE_MARGIN:s});l+=y}}return l}var mdt=class extends WO{constructor(){super(...arguments);T(this,"MAX_ITERATIONS",200)}getNeighbors(t){let n=this.obstacles,i=this.goalPoint,r;t.parent?r=DO(t.parent,t):r=DO(t,i);let o=[{dx:0,dy:1},{dx:1,dy:0},{dx:0,dy:-1},{dx:-1,dy:0}].filter(a=>a.dx===r.dx*-1&&a.dy===r.dy*-1?!1:!(a.dx===r.dx&&a.dy===r.dy&&t.parent?.obstacleHit)).map(a=>n.getOrthoDirectionCollisionInfo(t,a,{margin:this.OBSTACLE_MARGIN})).filter(a=>a.wallDistance>=this.OBSTACLE_MARGIN),s=[];for(let a of o){let c=null;t?.obstacleHit&&(c=y5({node:t,travelDir:a,wallDir:{...r,wallDistance:this.OBSTACLE_MARGIN},obstacle:t.obstacleHit,obstacles:n,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));let l=XO(t,i,a),u=(a.dx===0||Math.sign(i.x-t.x)===a.dx)&&(a.dy===0||Math.sign(i.y-t.y)===a.dy);l<a.wallDistance&&l>0&&u?s.push({...a,travelDistance:l}):c!==null&&c<a.wallDistance?s.push({...a,travelDistance:c}):a.wallDistance!==1/0&&s.push({...a,travelDistance:a.wallDistance-this.OBSTACLE_MARGIN})}return s.filter(a=>!n.isObstacleAt(t.x+a.dx*a.travelDistance,t.y+a.dy*a.travelDistance)).map(a=>({x:t.x+a.dx*a.travelDistance,y:t.y+a.dy*a.travelDistance,obstacleHit:a.obstacle}))}};function _dt(e,t=4){let{center:n,width:i,height:r,rotation:o}=e,s=[],a=o*Math.PI/180,c=Math.cos(a),l=Math.sin(a),u=(o%360+360)%360;if(r<=i?u>=45&&u<135||u>=225&&u<315:u>=135&&u<225||u>=315||u<45){let f=i/t;for(let _=0;_<t;_++){let y=(_-t/2+.5)*f,x=-y*c,v=-y*l,w=f*1.1,S=Math.abs(r*c)+Math.abs(f*l);s.push({center:{x:n.x+x,y:n.y+v},width:w,height:S})}}else{let f=r/t;for(let _=0;_<t;_++){let y=(_-t/2+.5)*f,x=-y*l,v=y*c,w=Math.abs(i*c)+Math.abs(f*l),S=f*1.1;s.push({center:{x:n.x+x,y:n.y+v},width:w,height:S})}}return s}var Xy=["top","inner1","inner2","bottom"],KO=(e,t)=>{let n=r=>t?r.concat(r.map(o=>t?.getNetConnectedToId(o)).filter(Boolean)):r,i=[];for(let r of e)if(r.type==="pcb_smtpad"){if(r.shape==="circle")i.push({type:"oval",layers:[r.layer],center:{x:r.x,y:r.y},width:r.radius*2,height:r.radius*2,connectedTo:n([r.pcb_smtpad_id])});else if(r.shape==="rect")i.push({type:"rect",layers:[r.layer],center:{x:r.x,y:r.y},width:r.width,height:r.height,connectedTo:n([r.pcb_smtpad_id])});else if(r.shape==="rotated_rect"){let o={center:{x:r.x,y:r.y},width:r.width,height:r.height,rotation:r.ccw_rotation},s=_dt(o);for(let a of s)i.push({type:"rect",layers:[r.layer],center:a.center,width:a.width,height:a.height,connectedTo:n([r.pcb_smtpad_id])})}}else if(r.type==="pcb_keepout")r.shape==="circle"?i.push({type:"oval",layers:r.layers,center:{x:r.center.x,y:r.center.y},width:r.radius*2,height:r.radius*2,connectedTo:[]}):r.shape==="rect"&&i.push({type:"rect",layers:r.layers,center:{x:r.center.x,y:r.center.y},width:r.width,height:r.height,connectedTo:[]});else if(r.type==="pcb_hole")r.hole_shape==="oval"?i.push({type:"oval",center:{x:r.x,y:r.y},width:r.hole_width,height:r.hole_height,connectedTo:[]}):r.hole_shape==="square"?i.push({type:"rect",layers:Xy,center:{x:r.x,y:r.y},width:r.hole_diameter,height:r.hole_diameter,connectedTo:[]}):(r.hole_shape==="round"||r.hole_shape==="circle")&&i.push({type:"rect",layers:Xy,center:{x:r.x,y:r.y},width:r.hole_diameter,height:r.hole_diameter,connectedTo:[]});else if(r.type==="pcb_plated_hole")r.shape==="circle"?i.push({type:"oval",layers:Xy,center:{x:r.x,y:r.y},width:r.outer_diameter,height:r.outer_diameter,connectedTo:n([r.pcb_plated_hole_id])}):(r.shape==="oval"||r.shape==="pill")&&i.push({type:"oval",layers:Xy,center:{x:r.x,y:r.y},width:r.outer_width,height:r.outer_height,connectedTo:n([r.pcb_plated_hole_id])});else if(r.type==="pcb_trace"){let o=GO(r.route.map(s=>({x:s.x,y:s.y,layer:"layer"in s?s.layer:s.from_layer})),r.source_trace_id);i.push(...o)}else r.type==="pcb_via"&&i.push({type:"rect",layers:r.layers,center:{x:r.x,y:r.y},connectedTo:[],width:r.outer_diameter,height:r.outer_diameter});return i};function jO(e){let{pcbConnMap:t,goalElementId:n}=e;if(!n.startsWith("pcb_port_"))throw new Error(`Currently alternative goal boxes must have a goal id with prefix "pcb_port_" (got ${n})`);let i=t.getAllTracesConnectedToPort(n);return KO(i).map(r=>({...r,connectedTo:[n]}))}var JO=e=>{let{connection:t,pcbConnMap:n}=e;if(t.pointsToConnect.length!==2)throw new Error(`Connection must have exactly 2 points for alternative goal boxes (got ${t.pointsToConnect.length})`);let[i,r]=t.pointsToConnect;if(!i.pcb_port_id||!r.pcb_port_id)throw new Error(`Connection points must have pcb_port_id for alternative goal box calculation (got ${i.pcb_port_id} and ${r.pcb_port_id})`);let o=jO({goalElementId:i.pcb_port_id,pcbConnMap:n}).concat([{center:i,width:.01,height:.01,connectedTo:[i.pcb_port_id],layers:[i.layer],type:"rect"}]),s=jO({goalElementId:r.pcb_port_id,pcbConnMap:n}).concat([{center:r,width:.01,height:.01,connectedTo:[r.pcb_port_id],layers:[r.layer],type:"rect"}]);if(o.length<=1&&s.length<=1)return{...t,startPoint:i,endPoint:r,goalBoxes:[]};let a=vd(o,s),c,l,u;return o.length>=s.length?(c={...r,...a.pointB},l={...i,...a.pointA},u=o):(c={...i,...a.pointA},l={...r,...a.pointB},u=s),{startPoint:c,endPoint:l,goalBoxes:u,name:t.name,pointsToConnect:[c,l]}},ydt=(e,t={})=>{let n={minTraceWidth:.1};n.layerCount=t.layerCount??1,n.obstacles=KO(e,t.connMap),n.connections=[];for(let r of e)if(r.type==="source_trace"){let o={name:r.source_trace_id,pointsToConnect:r.connected_source_port_ids.map(s=>{let a=MO(e).pcb_port.getWhere({source_port_id:s});if(!a)throw new Error(`Could not find pcb_port for source_port_id "${s}"`);return{x:a.x,y:a.y,layer:a.layers?.[0]??"top",pcb_port_id:a.pcb_port_id}})};if(t.optimizeWithGoalBoxes){let s=new Yy(e);o=JO({connection:o,pcbConnMap:s})}n.connections.push(o),gdt(n.obstacles,o.pointsToConnect,o.name)}let i={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0};for(let r of n.obstacles)i.minX=Math.min(i.minX,r.center.x-r.width/2),i.maxX=Math.max(i.maxX,r.center.x+r.width/2),i.minY=Math.min(i.minY,r.center.y-r.height/2),i.maxY=Math.max(i.maxY,r.center.y+r.height/2);for(let r of n.connections)for(let o of r.pointsToConnect)i.minX=Math.min(i.minX,o.x),i.maxX=Math.max(i.maxX,o.x),i.minY=Math.min(i.minY,o.y),i.maxY=Math.max(i.maxY,o.y);return n.bounds=i,n},gdt=(e,t,n)=>{for(let i of t)for(let r of e)xdt(i,r)&&r.connectedTo.push(n)};function xdt(e,t){let n=t.width/2,i=t.height/2;if(t.type==="rect")return e.x>=t.center.x-n&&e.x<=t.center.x+n&&e.y>=t.center.y-i&&e.y<=t.center.y+i;if(t.type==="oval"){let r=(e.x-t.center.x)/n,o=(e.y-t.center.y)/i;return r*r+o*o<=1}return!1}function YO(e,t){let n=t.x>e.x?1:t.x<e.x?-1:0,i=t.y>e.y?1:t.y<e.y?-1:0,r=t.l>e.l?1:t.l<e.l?-1:0;return{dx:n,dy:i,dl:r}}var g5={1:["top"],2:["top","bottom"],4:["top","inner1","inner2","bottom"]},bdt=e=>g5[e];function QO(e,t){let i=g5[e].indexOf(t);if(i===-1)throw new Error(`Invalid layer for getLayerIndex (for layerCount === ${e}): "${t}"`);return i}function vdt(e,t){let i=g5[e][t];if(!i)throw new Error(`Invalid index for indexToLayer (for layerCount === ${e}): "${t}"`);return i}var wdt=class extends UO{constructor(t,n){super([]);T(this,"obstacles");T(this,"GRID_STEP",.1);T(this,"layerCount");this.layerCount=t;let i=bdt(t);this.obstacles=n.flatMap(r=>r.layers.filter(o=>i.includes(o)).map(o=>({...r,left:r.center.x-r.width/2,right:r.center.x+r.width/2,top:r.center.y+r.height/2,bottom:r.center.y-r.height/2,l:QO(t,o)})))}getObstacleAt(t,n,i,r){r??(r=this.GRID_STEP);for(let o of this.obstacles){if(o.l!==i)continue;let s=o.width/2+r,a=o.height/2+r;if(t>=o.center.x-s&&t<=o.center.x+s&&n>=o.center.y-a&&n<=o.center.y+a)return o}return null}isObstacleAt(t,n,i,r){return this.getObstacleAt(t,n,i,r)!==null}getDirectionDistancesToNearestObstacle3d(t,n,i){let{GRID_STEP:r}=this,o={left:1/0,top:1/0,bottom:1/0,right:1/0};for(let s of this.obstacles)if(s.l===i&&s.type==="rect"){let a=s.center.x-s.width/2-r,c=s.center.x+s.width/2+r,l=s.center.y+s.height/2+r,u=s.center.y-s.height/2-r;n>=u&&n<=l&&t>a&&(o.left=Math.min(o.left,t-c)),n>=u&&n<=l&&t<c&&(o.right=Math.min(o.right,a-t)),t>=a&&t<=c&&n<l&&(o.top=Math.min(o.top,u-n)),t>=a&&t<=c&&n>u&&(o.bottom=Math.min(o.bottom,n-l))}return o}getOrthoDirectionCollisionInfo(t,n,{margin:i=0}={}){let{x:r,y:o,l:s}=t,{dx:a,dy:c,dl:l}=n,u=1/0,h=null;if(l!==0){let f=s+l;return this.isObstacleAt(r,o,f,i)?(u=1,h=this.getObstacleAt(r,o,f,i)):u=1,{dx:a,dy:c,dl:l,wallDistance:u,obstacle:h}}else{for(let f of this.obstacles){if(f.l!==s)continue;let _=f.left-i,y=f.right+i,x=f.top+i,v=f.bottom-i,w=null;a===1&&c===0?o>v&&o<x&&r<f.left&&(w=f.left-r):a===-1&&c===0?o>v&&o<x&&r>f.right&&(w=r-f.right):a===0&&c===1?r>_&&r<y&&o<f.bottom&&(w=f.bottom-o):a===0&&c===-1&&r>_&&r<y&&o>f.top&&(w=o-f.top),w!==null&&w<u&&(u=w,h=f)}return{dx:a,dy:c,dl:0,wallDistance:u,obstacle:h}}}getObstaclesOverlappingRegion(t){let n=[];for(let i of this.obstacles){if(i.l!==t.l)continue;let{left:r,right:o,top:s,bottom:a}=i;r<=t.maxX&&o>=t.minX&&s>=t.minY&&a<=t.maxY&&n.push(i)}return n}},Vy=class extends WO{constructor(t){super(t);T(this,"MAX_ITERATIONS",500);T(this,"VIA_COST",4);T(this,"VIA_DIAMETER",.5);T(this,"allowLayerChange",!0);T(this,"layerCount");T(this,"obstacles");T(this,"optimizeWithGoalBoxes");T(this,"connMap");T(this,"pcbConnMap");T(this,"GOAL_RUSH_FACTOR",1.1);T(this,"defaultGoalViaMargin",.5);T(this,"marginsWithCosts");this.layerCount=t.input.layerCount??2,this.MAX_ITERATIONS=t.MAX_ITERATIONS??this.MAX_ITERATIONS,this.VIA_COST=t.VIA_COST??this.VIA_COST,this.connMap=t.connMap,this.pcbConnMap=t.pcbConnMap??new Yy,this.optimizeWithGoalBoxes=t.optimizeWithGoalBoxes??!1,this.obstacles=null,this.marginsWithCosts=t.marginsWithCosts??[{margin:1,enterCost:0,travelCostFactor:1},{margin:this.OBSTACLE_MARGIN,enterCost:10,travelCostFactor:2}]}get largestMargin(){return this.marginsWithCosts[0].margin}preprocessConnectionBeforeSolving(t){return this.optimizeWithGoalBoxes?JO({connection:t,pcbConnMap:this.pcbConnMap}):t}postprocessConnectionSolveResult(t,n){if(!n.solved)return n;if(this.optimizeWithGoalBoxes){let i=n.route.map(r=>({x:r.x,y:r.y,route_type:"wire",layer:r.layer,width:this.input.minTraceWidth}));i[0].start_pcb_port_id=t.pointsToConnect[0].pcb_port_id,i[i.length-1].end_pcb_port_id=t.pointsToConnect[1].pcb_port_id,this.pcbConnMap.addTrace({type:"pcb_trace",pcb_trace_id:`postprocess_trace_${zO(8)}`,route:i})}return n}createObstacleList({dominantLayer:t,connection:n,obstaclesFromTraces:i}){let r=this.connMap?this.connMap.getNetConnectedToId(n.name):n.name;if(!r)throw new Error(`The connection.name "${n.name}" wasn't present in the full connectivity map`);return new wdt(this.layerCount,this.allObstacles.filter(o=>!o.connectedTo.includes(r)).concat(i??[]))}computeG(t,n){let i=t.g+al(t,n)*(t.travelMarginCostFactor??1)+(n.enterMarginCost??0);return(n.l??t.l!==-1??-1)&&(i+=this.VIA_COST),i}computeH(t){let n=Math.abs(t.x-this.goalPoint.x),i=Math.abs(t.y-this.goalPoint.y),r=Math.abs(t.l-this.goalPoint.l);return(n+i)**this.GOAL_RUSH_FACTOR+r*this.VIA_COST}getStartNode(t){return{...super.getStartNode(t),l:this.layerToIndex(t.pointsToConnect[0].layer)}}layerToIndex(t){return QO(this.layerCount,t)}indexToLayer(t){return vdt(this.layerCount,t)}getNodeName(t){return`${VO(t,this.GRID_STEP)}-${t.l??0}`}hasSpaceForVia(t,n){return t.every(i=>this.obstacles.getObstaclesOverlappingRegion({minX:n.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:n.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:n.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:n.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:i}).length===0)}getNeighborsSurroundingGoal(t){let n=this.obstacles,i=this.goalPoint,r=[],o=[{dx:1,dy:0,dl:0},{dx:-1,dy:0,dl:0},{dx:0,dy:1,dl:0},{dx:0,dy:-1,dl:0}],s=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin;for(let a of o){let c={x:t.x+a.dx*s,y:t.y+a.dy*s,l:t.l+a.dl,obstacleHit:null};this.hasSpaceForVia([t.l,i.l],c)&&r.push(c)}return r}getNeighbors(t){let n=this.obstacles,i=this.goalPoint,r=al(t,i);if(r<=this.OBSTACLE_MARGIN)return this.getNeighborsSurroundingGoal(t);let o;t.parent?o=YO(t.parent,t):o=YO(t,i);let s=[{dx:0,dy:1,dl:0},{dx:1,dy:0,dl:0},{dx:0,dy:-1,dl:0},{dx:-1,dy:0,dl:0}],a=r>this.VIA_DIAMETER+this.OBSTACLE_MARGIN,c=al(t,this.startNode)>this.VIA_DIAMETER+this.OBSTACLE_MARGIN;this.allowLayerChange&&a&&c&&(t.l<this.layerCount-1&&s.push({dx:0,dy:0,dl:1}),t.l>0&&s.push({dx:0,dy:0,dl:-1}));let l=s.filter(h=>h.dx===o.dx*-1&&h.dy===o.dy*-1&&h.dl===o.dl*-1?!1:!(h.dx===o.dx&&h.dy===o.dy&&h.dl===o.dl&&t.parent?.obstacleHit)).map(h=>n.getOrthoDirectionCollisionInfo(t,h,{margin:this.OBSTACLE_MARGIN})).filter(h=>!(h.wallDistance<this.OBSTACLE_MARGIN)),u=[];for(let h of l){let f=h.dx===0&&h.dy===0&&h.dl===1,_=h.dx===0&&h.dy===0&&h.dl===-1;if((f||_)&&![t.l,t.l+h.dl].every(S=>n.getObstaclesOverlappingRegion({minX:t.x-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,minY:t.y-this.VIA_DIAMETER/2-this.OBSTACLE_MARGIN,maxX:t.x+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,maxY:t.y+this.VIA_DIAMETER/2+this.OBSTACLE_MARGIN,l:S}).length===0))continue;if(f){t.l<this.layerCount-1&&u.push({...h,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}if(_){t.l>0&&u.push({...h,travelDistance:0,enterMarginCost:0,travelMarginCostFactor:1});continue}let y=null;t?.obstacleHit&&(y=y5({node:t,travelDir:h,wallDir:{...o,wallDistance:this.OBSTACLE_MARGIN},obstacle:t.obstacleHit,obstacles:n,OBSTACLE_MARGIN:this.OBSTACLE_MARGIN,SHOULD_DETECT_CONJOINED_OBSTACLES:!0}));let x=XO(t,i,h),v=(h.dx===0||Math.sign(i.x-t.x)===h.dx)&&(h.dy===0||Math.sign(i.y-t.y)===h.dy);if(x<h.wallDistance&&x>0&&v){let w=t.l===i.l,S=0;!w&&Math.abs(x-r)<this.GRID_STEP&&(S=this.VIA_DIAMETER+this.OBSTACLE_MARGIN+this.defaultGoalViaMargin),u.push({...h,travelDistance:x-S,enterMarginCost:0,travelMarginCostFactor:1})}else if(y!==null&&y<h.wallDistance){for(let{margin:w,enterCost:S,travelCostFactor:k}of this.marginsWithCosts)y-this.OBSTACLE_MARGIN+w*2<h.wallDistance&&u.push({...h,travelDistance:y-this.OBSTACLE_MARGIN+w,enterMarginCost:S,travelMarginCostFactor:k});if(h.wallDistance===1/0)u.push({...h,travelDistance:x,enterMarginCost:0,travelMarginCostFactor:1});else if(h.wallDistance>this.largestMargin)for(let{margin:w,enterCost:S,travelCostFactor:k}of this.marginsWithCosts)h.wallDistance>this.largestMargin+w&&u.push({...h,travelDistance:h.wallDistance-w,enterMarginCost:S,travelMarginCostFactor:k})}else if(h.wallDistance!==1/0)for(let{margin:w,enterCost:S,travelCostFactor:k}of this.marginsWithCosts)h.wallDistance>w&&u.push({...h,travelDistance:h.wallDistance-w,enterMarginCost:S,travelMarginCostFactor:k})}return u.map(h=>({x:t.x+h.dx*h.travelDistance,y:t.y+h.dy*h.travelDistance,l:t.l+h.dl,obstacleHit:h.obstacle,travelMarginCostFactor:h.travelMarginCostFactor,enterMarginCost:h.enterMarginCost}))}};function tL(e){let t=ydt(e),n=new mdt({input:t});return{solution:n.solveAndMapToTraces(),debugSolutions:n.debugSolutions,debugMessage:n.debugMessage}}Z();Z();St();Z();Z();St();St();Z();Z();Z();Z();Z();St();Z();Z();Z();St();Z();Z();St();Z();Z();Z();Z();Z();Z();Z();Z();Z();Z();St();Z();St();Z();St();Z();St();St();Z();St();Z();Z();St();Z();Z();St();Z();St();Z();St();Z();St();Z();St();Z();St();Z();St();Z();Z();Z();Z();Z();Z();Z();Z();St();Z();St();Z();Z();St();Z();St();Z();Z();Z();St();Z();St();Z();Z();St();Z();Z();Z();Z();St();Z();St();Z();St();Z();St();Z();St();Z();Z();St();Z();Z();St();St();Z();Z();St();St();Z();St();Z();St();Z();St();Z();St();Z();St();Z();St();Z();Z();St();Z();St();Z();St();Z();St();Z();St();Z();St();Z();St();St();Z();St();Z();St();Z();Z();Z();var kt=e=>{};kt("extra props b");kt("missing props b");kt(!0);kt("property a has mismatched types");var Sdt=p.enum(["up","down","left","right"]),n7t=p.enum(["top-to-bottom","left-to-right","bottom-to-top","right-to-left"]);kt(!0);kt(!0);var No=p.array(p.string().or(p.number()));kt(!0);var Uy=p.object({x:G,y:G,z:G}),Pdt=p.object({x:p.union([p.number(),p.string()]),y:p.union([p.number(),p.string()]),z:p.union([p.number(),p.string()])}),Ma=p.object({rotationOffset:p.number().or(Pdt).optional(),positionOffset:Uy.optional(),size:Uy.optional(),modelUnitToMmScale:G.optional()});kt(!0);var Tdt=Ma.extend({stlUrl:p.string()}),Idt=Ma.extend({objUrl:p.string(),mtlUrl:p.string().optional()}),Mdt=Ma.extend({gltfUrl:p.string()}),Edt=Ma.extend({glbUrl:p.string()}),Cdt=Ma.extend({stepUrl:p.string()}),kdt=Ma.extend({wrlUrl:p.string()}),Adt=Ma.extend({jscad:p.record(p.any())}),oL=p.union([p.null(),p.string(),p.custom(e=>e&&typeof e=="object"&&"type"in e&&"props"in e),Tdt,Idt,Mdt,Edt,Cdt,kdt,Adt]);kt(!0);var Ndt=p.custom(e=>!0),Rdt=p.custom(e=>!0),un=p.object({pcbX:G.optional(),pcbY:G.optional(),pcbRotation:Fe.optional(),pcbPositionAnchor:p.string().optional(),layer:_e.optional(),pcbMarginTop:G.optional(),pcbMarginRight:G.optional(),pcbMarginBottom:G.optional(),pcbMarginLeft:G.optional(),pcbMarginX:G.optional(),pcbMarginY:G.optional(),pcbRelative:p.boolean().optional(),relative:p.boolean().optional()});kt(!0);var qy=p.object({pcbX:G.optional(),pcbY:G.optional(),pcbRotation:Fe.optional(),pcbPositionAnchor:p.string().optional(),pcbMarginTop:G.optional(),pcbMarginRight:G.optional(),pcbMarginBottom:G.optional(),pcbMarginLeft:G.optional(),pcbMarginX:G.optional(),pcbMarginY:G.optional(),schMarginTop:G.optional(),schMarginRight:G.optional(),schMarginBottom:G.optional(),schMarginLeft:G.optional(),schMarginX:G.optional(),schMarginY:G.optional(),schX:G.optional(),schY:G.optional(),schRotation:Fe.optional(),layer:_e.optional(),footprint:Ndt.optional(),symbol:Rdt.optional(),relative:p.boolean().optional(),schRelative:p.boolean().optional(),pcbRelative:p.boolean().optional()});kt(!0);var Odt=p.object({supplierPartNumbers:p.record(Bu,p.array(p.string())).optional()});kt(!0);var Ldt=p.object({providesPower:p.boolean().optional(),requiresPower:p.boolean().optional(),providesGround:p.boolean().optional(),requiresGround:p.boolean().optional(),providesVoltage:p.union([p.string(),p.number()]).optional(),requiresVoltage:p.union([p.string(),p.number()]).optional(),doNotConnect:p.boolean().optional(),includeInBoardPinout:p.boolean().optional(),ratsNestColor:p.string().optional()});kt(!0);var Fn=qy.merge(Odt).extend({key:p.any().optional(),name:p.string(),cadModel:oL.optional(),children:p.any().optional(),symbolName:p.string().optional(),doNotPlace:p.boolean().optional(),pinAttributes:p.record(p.string(),Ldt).optional()});kt(!0);var b5=["pin1","left","pin2","right"],Wy=["pin1","left","anode","pos","pin2","right","cathode","neg"],d7t=G.or(p.enum(["2x","3x","4x"])),Ea=p.enum(["vertical","horizontal","pos_top","pos_bottom","pos_left","pos_right","neg_top","neg_bottom","neg_left","neg_right"]).describe("horizontal means pins go 1->2 rightward and vertical means pins go 1->2 downward (generally, positive on top)");kt(!0);var Hy=p.object({pins:p.array(p.union([p.number(),p.string()])),direction:p.union([p.literal("top-to-bottom"),p.literal("left-to-right"),p.literal("bottom-to-top"),p.literal("right-to-left")])}),Sd=p.object({leftSize:p.number().optional().describe("@deprecated, use leftPinCount"),topSize:p.number().optional().describe("@deprecated, use topPinCount"),rightSize:p.number().optional().describe("@deprecated, use rightPinCount"),bottomSize:p.number().optional().describe("@deprecated, use bottomPinCount"),leftPinCount:p.number().optional(),rightPinCount:p.number().optional(),topPinCount:p.number().optional(),bottomPinCount:p.number().optional(),leftSide:Hy.optional(),rightSide:Hy.optional(),topSide:Hy.optional(),bottomSide:Hy.optional()}),v5=Sd;kt(!0);var Zy=p.record(p.object({marginLeft:G.optional(),marginRight:G.optional(),marginTop:G.optional(),marginBottom:G.optional(),leftMargin:G.optional(),rightMargin:G.optional(),topMargin:G.optional(),bottomMargin:G.optional()}));kt(!0);var Ur=p.string().regex(/^[A-Za-z0-9_]+$/),Pd=p.enum(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),cp=p.object({x:G,y:G}),Td=p.object({edit_event_id:p.string(),in_progress:p.boolean().optional(),created_at:p.number()});kt(!0);var Fdt=Td.extend({pcb_edit_event_type:p.literal("edit_component_location").describe("deprecated"),edit_event_type:p.literal("edit_pcb_component_location"),pcb_component_id:p.string(),original_center:p.object({x:p.number(),y:p.number()}),new_center:p.object({x:p.number(),y:p.number()})});kt(!0);var zdt=Td.extend({pcb_edit_event_type:p.literal("edit_trace_hint").describe("deprecated"),edit_event_type:p.literal("edit_pcb_trace_hint").optional(),pcb_port_id:p.string(),pcb_trace_hint_id:p.string().optional(),route:p.array(p.object({x:p.number(),y:p.number(),via:p.boolean().optional()}))});kt(!0);var Ddt=Td.extend({edit_event_type:p.literal("edit_schematic_component_location"),schematic_component_id:p.string(),original_center:p.object({x:p.number(),y:p.number()}),new_center:p.object({x:p.number(),y:p.number()})});kt(!0);var k7t=Td.extend({edit_event_type:p.literal("edit_pcb_group_location"),pcb_group_id:p.string(),original_center:p.object({x:p.number(),y:p.number()}),new_center:p.object({x:p.number(),y:p.number()})});kt(!0);var N7t=Td.extend({edit_event_type:p.literal("edit_schematic_group_location"),schematic_group_id:p.string(),original_center:p.object({x:p.number(),y:p.number()}),new_center:p.object({x:p.number(),y:p.number()})});kt(!0);var O7t=p.union([Fdt,zdt,Ddt]);kt(!0);var $dt=p.object({selector:p.string(),relative_to:p.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:ee});kt(!0);var Bdt=p.object({pcb_port_selector:p.string(),offsets:p.array(Yi)});kt(!0);var jdt=p.object({selector:p.string(),relative_to:p.string().optional().default("group_center").describe("Can be a selector or 'group_center'"),center:ee});kt(!0);var Ydt=p.object({pcb_placements:p.array($dt).optional(),manual_trace_hints:p.array(Bdt).optional(),schematic_placements:p.array(jdt).optional()});kt(!0);var Ky=p.string().or(p.array(p.string()).readonly()).or(p.array(p.string())),cl=e=>p.record(p.enum(e),Ky),wd=p.object({layoutMode:p.enum(["grid","flex","match-adapt","relative","none"]).optional(),position:p.enum(["absolute","relative"]).optional(),grid:p.boolean().optional(),gridCols:p.number().or(p.string()).optional(),gridRows:p.number().or(p.string()).optional(),gridTemplateRows:p.string().optional(),gridTemplateColumns:p.string().optional(),gridTemplate:p.string().optional(),gridGap:p.number().or(p.string()).optional(),gridRowGap:p.number().or(p.string()).optional(),gridColumnGap:p.number().or(p.string()).optional(),flex:p.boolean().or(p.string()).optional(),flexDirection:p.enum(["row","column"]).optional(),alignItems:p.enum(["start","center","end","stretch"]).optional(),justifyContent:p.enum(["start","center","end","stretch","space-between","space-around","space-evenly"]).optional(),flexRow:p.boolean().optional(),flexColumn:p.boolean().optional(),gap:p.number().or(p.string()).optional(),pack:p.boolean().optional().describe("Pack the contents of this group using a packing strategy"),packOrderStrategy:p.enum(["largest_to_smallest","first_to_last","highest_to_lowest_pin_count"]).optional(),packPlacementStrategy:p.enum(["shortest_connection_along_outline"]).optional(),padding:$.optional(),paddingLeft:$.optional(),paddingRight:$.optional(),paddingTop:$.optional(),paddingBottom:$.optional(),paddingX:$.optional(),paddingY:$.optional(),width:$.optional(),height:$.optional(),matchAdapt:p.boolean().optional(),matchAdaptTemplate:p.any().optional()});kt(!0);var eL=p.object({strokeWidth:$.optional(),dashed:p.boolean().optional(),solid:p.boolean().optional()}),Xdt=p.object({serverUrl:p.string().optional(),inputFormat:p.enum(["simplified","circuit-json"]).optional(),serverMode:p.enum(["job","solve-endpoint"]).optional(),serverCacheEnabled:p.boolean().optional(),cache:p.custom(e=>!0).optional(),traceClearance:$.optional(),groupMode:p.enum(["sequential_trace","subcircuit","sequential-trace"]).optional(),algorithmFn:p.custom(e=>typeof e=="function"||e===void 0).optional(),preset:p.enum(["sequential_trace","subcircuit","auto","auto_local","auto_cloud","freerouting","sequential-trace","auto-local","auto-cloud"]).optional(),local:p.boolean().optional()}),sL=p.union([Xdt,p.literal("sequential_trace"),p.literal("subcircuit"),p.literal("auto"),p.literal("auto_local"),p.literal("auto_cloud"),p.literal("freerouting"),p.literal("sequential-trace"),p.literal("auto-local"),p.literal("auto-cloud")]),aL=qy.extend({name:p.string().optional(),children:p.any().optional(),schTitle:p.string().optional(),key:p.any().optional(),showAsSchematicBox:p.boolean().optional(),connections:p.record(p.string(),Ky.optional()).optional(),schPinArrangement:v5.optional(),...wd.shape,grid:wd.shape.grid.describe("@deprecated use pcbGrid"),flex:wd.shape.flex.describe("@deprecated use pcbFlex"),pcbGrid:p.boolean().optional(),pcbGridCols:p.number().or(p.string()).optional(),pcbGridRows:p.number().or(p.string()).optional(),pcbGridTemplateRows:p.string().optional(),pcbGridTemplateColumns:p.string().optional(),pcbGridTemplate:p.string().optional(),pcbGridGap:p.number().or(p.string()).optional(),pcbGridRowGap:p.number().or(p.string()).optional(),pcbGridColumnGap:p.number().or(p.string()).optional(),pcbFlex:p.boolean().or(p.string()).optional(),pcbFlexGap:p.number().or(p.string()).optional(),pcbFlexDirection:p.enum(["row","column"]).optional(),pcbAlignItems:p.enum(["start","center","end","stretch"]).optional(),pcbJustifyContent:p.enum(["start","center","end","stretch","space-between","space-around","space-evenly"]).optional(),pcbFlexRow:p.boolean().optional(),pcbFlexColumn:p.boolean().optional(),pcbGap:p.number().or(p.string()).optional(),pcbPack:p.boolean().optional(),pcbPackGap:p.number().or(p.string()).optional(),schGrid:p.boolean().optional(),schGridCols:p.number().or(p.string()).optional(),schGridRows:p.number().or(p.string()).optional(),schGridTemplateRows:p.string().optional(),schGridTemplateColumns:p.string().optional(),schGridTemplate:p.string().optional(),schGridGap:p.number().or(p.string()).optional(),schGridRowGap:p.number().or(p.string()).optional(),schGridColumnGap:p.number().or(p.string()).optional(),schFlex:p.boolean().or(p.string()).optional(),schFlexGap:p.number().or(p.string()).optional(),schFlexDirection:p.enum(["row","column"]).optional(),schAlignItems:p.enum(["start","center","end","stretch"]).optional(),schJustifyContent:p.enum(["start","center","end","stretch","space-between","space-around","space-evenly"]).optional(),schFlexRow:p.boolean().optional(),schFlexColumn:p.boolean().optional(),schGap:p.number().or(p.string()).optional(),schPack:p.boolean().optional(),schMatchAdapt:p.boolean().optional(),pcbWidth:$.optional(),pcbHeight:$.optional(),schWidth:$.optional(),schHeight:$.optional(),pcbLayout:wd.optional(),schLayout:wd.optional(),cellBorder:eL.nullable().optional(),border:eL.nullable().optional(),schPadding:$.optional(),schPaddingLeft:$.optional(),schPaddingRight:$.optional(),schPaddingTop:$.optional(),schPaddingBottom:$.optional(),pcbPadding:$.optional(),pcbPaddingLeft:$.optional(),pcbPaddingRight:$.optional(),pcbPaddingTop:$.optional(),pcbPaddingBottom:$.optional()}),cL=p.custom(e=>"findPart"in e),w5=aL.extend({manualEdits:Ydt.optional(),schAutoLayoutEnabled:p.boolean().optional(),schTraceAutoLabelEnabled:p.boolean().optional(),schMaxTraceDistance:G.optional(),routingDisabled:p.boolean().optional(),defaultTraceWidth:$.optional(),minTraceWidth:$.optional(),partsEngine:cL.optional(),pcbRouteCache:p.custom(e=>!0).optional(),autorouter:sL.optional(),square:p.boolean().optional(),emptyArea:p.string().optional(),filledArea:p.string().optional(),width:G.optional(),height:G.optional(),outline:p.array(cp).optional(),outlineOffsetX:G.optional(),outlineOffsetY:G.optional()}),Vdt=w5.extend({subcircuit:p.literal(!0)}),lL=p.discriminatedUnion("subcircuit",[aL.extend({subcircuit:p.literal(!1).optional()}),Vdt]);kt(!0);kt(!0);kt(!0);var S5=w5.extend({material:p.enum(["fr4","fr1"]).default("fr4"),layers:p.union([p.literal(2),p.literal(4)]).default(2),borderRadius:G.optional(),boardAnchorPosition:cp.optional(),boardAnchorAlignment:Pd.optional()});kt(!0);var V7t=w5.extend({padding:G.optional(),paddingLeft:G.optional(),paddingRight:G.optional(),paddingTop:G.optional(),paddingBottom:G.optional()});kt(!0);var Hdt=p.string().or(p.array(p.string()).readonly()).or(p.array(p.string())),Gdt=p.custom().pipe(p.record(p.string(),Hdt)),Udt=p.record(Ur,Ur.or(p.array(Ur).readonly()).or(p.array(Ur)));kt(!0);var qdt=p.object({manufacturerPartNumber:p.string().optional(),supplierPartNumber:p.record(Bu,p.array(p.string())).optional()}),lp=Fn.extend({manufacturerPartNumber:p.string().optional(),pinLabels:Udt.optional(),showPinAliases:p.boolean().optional(),pcbPinLabels:p.record(p.string(),p.string()).optional(),internallyConnectedPins:p.array(p.array(p.union([p.string(),p.number()]))).optional(),externallyConnectedPins:p.array(p.array(p.string())).optional(),schPinArrangement:Sd.optional(),schPortArrangement:Sd.optional(),pinCompatibleVariants:p.array(qdt).optional(),schPinStyle:Zy.optional(),schPinSpacing:G.optional(),schWidth:G.optional(),schHeight:G.optional(),noSchematicRepresentation:p.boolean().optional(),connections:Gdt.optional()});kt(!0);var uL=lp;kt(!0);var P5=Fn.extend({manufacturerPartNumber:p.string().optional(),pinLabels:p.record(p.number().or(Ur),Ur.or(p.array(Ur))).optional(),schPinStyle:Zy.optional(),schPinSpacing:G.optional(),schWidth:G.optional(),schHeight:G.optional(),schDirection:p.enum(["left","right"]).optional(),schPinArrangement:v5.optional(),schPortArrangement:Sd.optional(),pcbPinLabels:p.record(p.string(),p.string()).optional(),pinCount:p.union([p.literal(2),p.literal(3)]).optional(),internallyConnectedPins:p.array(p.array(p.union([p.string(),p.number()]))).optional(),connections:p.custom().pipe(p.record(p.string(),Ky)).optional()});kt(!0);var pL=P5.extend({bridgedPins:p.array(p.array(p.string())).optional(),bridged:p.boolean().optional()});kt(!0);var J7t=Fn.extend({manufacturerPartNumber:p.string().optional(),pinLabels:p.record(p.number().or(Ur),Ur.or(p.array(Ur))).optional(),schPinStyle:Zy.optional(),schPinSpacing:G.optional(),schWidth:G.optional(),schHeight:G.optional(),schDirection:p.enum(["left","right"]).optional(),schPortArrangement:Sd.optional(),internallyConnectedPins:p.array(p.array(p.union([p.string(),p.number()]))).optional(),standard:p.enum(["usb_c","m2"]).optional()});kt(!0);var hL=Fn.extend({currentRating:p.union([p.number(),p.string()]),voltageRating:p.union([p.number(),p.string()]).optional(),schShowRatings:p.boolean().optional(),schOrientation:Ea.optional(),connections:p.record(p.string(),p.union([p.string(),p.array(p.string()).readonly(),p.array(p.string())])).optional()}),Gy=p.custom().transform(e=>{if(e!==void 0)return G.parse(e)}),dL=p.discriminatedUnion("shape",[un.omit({pcbRotation:!0,layer:!0}).extend({name:p.string().optional(),connectsTo:p.string().or(p.array(p.string())).optional(),shape:p.literal("circle"),holeDiameter:G,outerDiameter:G,portHints:No.optional()}),un.omit({layer:!0}).extend({name:p.string().optional(),connectsTo:p.string().or(p.array(p.string())).optional(),shape:p.literal("oval"),outerWidth:G,outerHeight:G,holeWidth:Gy,holeHeight:Gy,innerWidth:G.optional().describe("DEPRECATED use holeWidth"),innerHeight:G.optional().describe("DEPRECATED use holeHeight"),portHints:No.optional()}),un.omit({layer:!0}).extend({name:p.string().optional(),connectsTo:p.string().or(p.array(p.string())).optional(),shape:p.literal("pill"),rectPad:p.boolean().optional(),outerWidth:G,outerHeight:G,holeWidth:Gy,holeHeight:Gy,innerWidth:G.optional().describe("DEPRECATED use holeWidth"),innerHeight:G.optional().describe("DEPRECATED use holeHeight"),portHints:No.optional(),holeOffsetX:G.optional(),holeOffsetY:G.optional()}),un.omit({pcbRotation:!0,layer:!0}).extend({name:p.string().optional(),connectsTo:p.string().or(p.array(p.string())).optional(),shape:p.literal("circular_hole_with_rect_pad"),holeDiameter:G,rectPadWidth:G,rectPadHeight:G,rectBorderRadius:G.optional(),holeShape:p.literal("circle").optional(),padShape:p.literal("rect").optional(),portHints:No.optional(),holeOffsetX:G.optional(),holeOffsetY:G.optional()}),un.omit({pcbRotation:!0,layer:!0}).extend({name:p.string().optional(),connectsTo:p.string().or(p.array(p.string())).optional(),shape:p.literal("pill_hole_with_rect_pad"),holeShape:p.literal("pill"),padShape:p.literal("rect"),holeWidth:G,holeHeight:G,rectPadWidth:G,rectPadHeight:G,portHints:No.optional(),holeOffsetX:G.optional(),holeOffsetY:G.optional()})]).refine(e=>("innerWidth"in e&&e.innerWidth!==void 0&&(e.holeWidth??(e.holeWidth=e.innerWidth)),"innerHeight"in e&&e.innerHeight!==void 0&&(e.holeHeight??(e.holeHeight=e.innerHeight)),e));kt(!0);var Wdt=["pin1","pin2","pos","neg"],fL=Fn.extend({resistance:xa,pullupFor:p.string().optional(),pullupTo:p.string().optional(),pulldownFor:p.string().optional(),pulldownTo:p.string().optional(),schOrientation:Ea.optional(),connections:cl(Wdt).optional()}),mL=b5;kt(!0);var _L=Fn.extend({maxResistance:xa,pinVariant:p.enum(["two_pin","three_pin"]).optional()});kt(!0);var Zdt=b5,yL=Fn.extend({frequency:po,loadCapacitance:_s,manufacturerPartNumber:p.string().optional(),mpn:p.string().optional(),pinVariant:p.enum(["two_pin","four_pin"]).optional(),schOrientation:Ea.optional(),connections:cl(Zdt).optional()});kt(!0);var gL=Fn.extend({frequency:po,loadCapacitance:_s,pinVariant:p.enum(["no_ground","ground_pin","two_ground_pins"]).optional()});kt(!0);var hOt=S5.extend({leftPinCount:p.number().optional(),rightPinCount:p.number().optional(),topPinCount:p.number().optional(),bottomPinCount:p.number().optional(),leftPins:p.array(p.string()).optional(),rightPins:p.array(p.string()).optional(),topPins:p.array(p.string()).optional(),bottomPins:p.array(p.string()).optional(),pinPitch:G.optional(),innerHoles:p.boolean().optional()});kt(!0);var Kdt=["pin1","pin2","pos","neg","anode","cathode"],xL=Fn.extend({capacitance:_s,maxVoltageRating:Qn.optional(),schShowRatings:p.boolean().optional().default(!1),polarized:p.boolean().optional().default(!1),decouplingFor:p.string().optional(),decouplingTo:p.string().optional(),bypassFor:p.string().optional(),bypassTo:p.string().optional(),maxDecouplingTraceLength:p.number().optional(),schOrientation:Ea.optional(),connections:cl(Kdt).optional()}),bL=Wy;kt(!0);var _Ot=p.object({name:p.string(),connectsTo:p.string().or(p.array(p.string())).optional(),ratsNestColor:p.string().optional()});kt(!0);var gOt=p.object({name:p.string().optional(),pcbOnly:p.boolean().optional(),schOnly:p.boolean().optional()});kt(!0);var Jdt=p.object({pcb:p.literal(!0).optional(),xDist:G,left:p.string(),right:p.string(),edgeToEdge:p.literal(!0).optional(),centerToCenter:p.literal(!0).optional()});kt(!0);var Qdt=p.object({pcb:p.literal(!0).optional(),yDist:G,top:p.string(),bottom:p.string(),edgeToEdge:p.literal(!0).optional(),centerToCenter:p.literal(!0).optional()});kt(!0);var tft=p.object({pcb:p.literal(!0).optional(),sameY:p.literal(!0).optional(),for:p.array(p.string())});kt(!0);var eft=p.object({pcb:p.literal(!0).optional(),sameX:p.literal(!0).optional(),for:p.array(p.string())});kt(!0);var vL=p.union([Jdt,Qdt,tft,eft]);kt(!0);var nft=un.omit({layer:!0,pcbRotation:!0}).extend({name:p.string().optional(),shape:p.literal("rect"),width:G,height:G});kt(!0);var ift=un.omit({layer:!0,pcbRotation:!0}).extend({name:p.string().optional(),shape:p.literal("circle"),radius:G});kt(!0);var rft=un.omit({layer:!0,pcbRotation:!0}).extend({name:p.string().optional(),shape:p.literal("polygon"),points:p.array(cp)});kt(!0);var wL=p.discriminatedUnion("shape",[nft,ift,rft]),oft=un.omit({pcbRotation:!0}).extend({name:p.string().optional(),shape:p.literal("rect"),width:G,height:G,rectBorderRadius:G.optional(),portHints:No.optional(),coveredWithSolderMask:p.boolean().optional()});kt(!0);var sft=un.omit({pcbRotation:!0}).extend({name:p.string().optional(),shape:p.literal("rotated_rect"),width:G,height:G,ccwRotation:p.number(),portHints:No.optional(),coveredWithSolderMask:p.boolean().optional()});kt(!0);var aft=un.omit({pcbRotation:!0}).extend({name:p.string().optional(),shape:p.literal("circle"),radius:G,portHints:No.optional(),coveredWithSolderMask:p.boolean().optional()});kt(!0);var cft=un.omit({pcbRotation:!0}).extend({name:p.string().optional(),shape:p.literal("pill"),width:G,height:G,radius:G,portHints:No.optional(),coveredWithSolderMask:p.boolean().optional()});kt(!0);var lft=un.omit({pcbRotation:!0}).extend({name:p.string().optional(),shape:p.literal("polygon"),points:p.array(cp),portHints:No.optional(),coveredWithSolderMask:p.boolean().optional()});kt(!0);var SL=p.discriminatedUnion("shape",[aft,oft,sft,cft,lft]);kt(!0);var uft=un.omit({pcbRotation:!0}).extend({shape:p.literal("rect"),width:G,height:G});kt(!0);var pft=un.omit({pcbRotation:!0}).extend({shape:p.literal("circle"),radius:G});kt(!0);var SOt=p.union([pft,uft]);kt(!0);var hft=un.extend({name:p.string().optional(),shape:p.literal("circle").optional(),diameter:G.optional(),radius:G.optional()}).transform(e=>({...e,diameter:e.diameter??2*e.radius,radius:e.radius??e.diameter/2})),dft=un.extend({name:p.string().optional(),shape:p.literal("pill"),width:G,height:G}),PL=p.union([hft,dft]);kt(!0);var x5=p.union([p.string(),p.custom(e=>!!e.getPortSelector)]),nL=p.object({key:p.string().optional(),thickness:G.optional(),schematicRouteHints:p.array(cp).optional(),pcbRouteHints:p.array(Yi).optional(),pcbPathRelativeTo:p.string().optional(),pcbPath:p.array(cp).optional(),schDisplayLabel:p.string().optional(),schStroke:p.string().optional(),ratsNestColor:p.string().optional(),maxLength:G.optional()}),TL=p.union([nL.extend({path:p.array(x5)}),nL.extend({from:x5,to:x5})]),IL=p.object({originalLayer:_e.default("top").optional()});kt(!0);var ML=p.object({originalFacingDirection:p.enum(["up","down","left","right"]).default("right").optional()});kt(!0);var fft=p.number().or(p.string().endsWith("mAh")).transform(e=>{if(typeof e=="string"){let t=e.replace("mAh",""),n=Number.parseFloat(t);if(Number.isNaN(n))throw new Error("Invalid capacity");return n}return e}).describe("Battery capacity in mAh"),EL=Fn.extend({capacity:fft.optional(),voltage:Qn.optional(),standard:p.enum(["AA","AAA","9V","CR2032","18650","C"]).optional(),schOrientation:Ea.optional()});kt(!0);var mft=p.enum(["vertical","horizontal"]).describe("vertical means pins go 1->2 downward and horizontal means pins go 1->2 rightward");kt(!0);var CL=Fn.extend({pinCount:p.number(),pitch:G.optional(),schFacingDirection:p.enum(["up","down","left","right"]).optional(),gender:p.enum(["male","female","unpopulated"]).optional().default("male"),showSilkscreenPinLabels:p.boolean().optional(),pcbPinLabels:p.record(p.string(),p.string()).optional(),doubleRow:p.boolean().optional(),rightAngle:p.boolean().optional(),pcbOrientation:mft.optional(),holeDiameter:G.optional(),platedDiameter:G.optional(),pinLabels:p.record(p.string(),Ur).or(p.array(Ur)).optional(),connections:p.custom().pipe(p.record(p.string(),Ky)).optional(),facingDirection:p.enum(["left","right"]).optional(),schPinArrangement:v5.optional(),schPinStyle:Zy.optional(),schPinSpacing:G.optional(),schWidth:G.optional(),schHeight:G.optional()});kt(!0);var zOt=p.object({net:p.string().optional(),connection:p.string().optional(),schX:G.optional(),schY:G.optional(),schRotation:Fe.optional(),anchorSide:p.enum(["left","top","right","bottom"]).optional()});kt(!0);var kL=p.object({net:p.string().optional(),connection:p.string().optional(),connectsTo:p.string().or(p.array(p.string())).optional(),schX:G.optional(),schY:G.optional(),schRotation:Fe.optional(),anchorSide:p.enum(["left","top","right","bottom"]).optional()});kt(!0);var AL=lp.extend({});kt(!0);kt(!0);var _ft=["pin1","pin2","pin3","emitter","collector","base","gate","source","drain"],NL=Fn.extend({type:p.enum(["npn","pnp","bjt","jfet","mosfet","igbt"]),connections:cl(_ft).optional()});kt(!0);var RL=Fn.extend({channelType:p.enum(["n","p"]),mosfetMode:p.enum(["enhancement","depletion"])});kt(!0);var yft=b5,OL=Fn.extend({inductance:w1,maxCurrentRating:p.union([p.string(),p.number()]).optional(),schOrientation:Ea.optional(),connections:cl(yft).optional()});kt(!0);var gft=p.enum(["anode","cathode","pin1","pin2","pos","neg"]),xft=p.string().or(p.array(p.string()).readonly()).or(p.array(p.string())),bft=p.record(gft,xft),vft=p.enum(["standard","schottky","zener","avalanche","photo","tvs"]),LL=Fn.extend({connections:bft.optional(),variant:vft.optional().default("standard"),standard:p.boolean().optional(),schottky:p.boolean().optional(),zener:p.boolean().optional(),avalanche:p.boolean().optional(),photo:p.boolean().optional(),tvs:p.boolean().optional(),schOrientation:Ea.optional()}).superRefine((e,t)=>{if([e.standard,e.schottky,e.zener,e.avalanche,e.photo,e.tvs].filter(Boolean).length>1)return t.addIssue({code:p.ZodIssueCode.custom,message:"Exactly one diode variant must be enabled",path:[]}),p.INVALID}).transform(e=>{let t={...e,standard:!1,schottky:!1,zener:!1,avalanche:!1,photo:!1,tvs:!1};if(e.standard)t.standard=!0;else if(e.schottky)t.schottky=!0;else if(e.zener)t.zener=!0;else if(e.photo)t.photo=!0;else if(e.tvs)t.tvs=!0;else switch(e.variant){case"standard":t.standard=!0;break;case"schottky":t.schottky=!0;break;case"zener":t.zener=!0;break;case"avalanche":t.avalanche=!0;break;case"photo":t.photo=!0;break;case"tvs":t.tvs=!0;break;default:t.standard=!0}return t}),FL=Wy;kt(!0);var zL=Fn.extend({color:p.string().optional(),wavelength:p.string().optional(),schDisplayValue:p.string().optional(),schOrientation:Ea.optional(),connections:cl(Wy).optional(),laser:p.boolean().optional()}),DL=Wy,$L=Fn.extend({type:p.enum(["spst","spdt","dpst","dpdt"]).optional(),isNormallyClosed:p.boolean().optional().default(!1),spst:p.boolean().optional(),spdt:p.boolean().optional(),dpst:p.boolean().optional(),dpdt:p.boolean().optional()}).transform(e=>{let t={...e};switch(t.dpdt?t.type="dpdt":t.spst?t.type="spst":t.spdt?t.type="spdt":t.dpst&&(t.type="dpst"),t.type){case"spdt":t.spdt=!0;break;case"spst":t.spst=!0;break;case"dpst":t.dpst=!0;break;case"dpdt":t.dpdt=!0;break}return t});kt(!0);var BL=un.extend({text:p.string(),anchorAlignment:p.enum(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),font:p.enum(["tscircuit2024"]).optional(),fontSize:$.optional(),color:p.string().optional()}),jL=un.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:p.array(Yi),strokeWidth:$.optional(),color:p.string().optional()}),QOt=p.object({layer:p.string().optional(),thickness:G.optional(),route:p.array(Yi)}),YL=qy.extend({name:p.string().optional(),fromLayer:_e,toLayer:_e,holeDiameter:G,outerDiameter:G,connectsTo:p.string().or(p.array(p.string())).optional()});kt(!0);var XL=Fn.extend({footprintVariant:p.enum(["pad","through_hole"]).optional(),padShape:p.enum(["rect","circle"]).optional().default("circle"),padDiameter:G.optional(),holeDiameter:G.optional(),width:G.optional(),height:G.optional()}).refine(e=>e.footprintVariant!=="through_hole"||e.holeDiameter!==void 0,{message:"holeDiameter is required for through_hole testpoints"});kt(!0);var VL=un.omit({pcbRotation:!0,layer:!0}).extend({connection:p.string()});kt(!0);var HL=p.union([un.omit({pcbRotation:!0}).extend({shape:p.literal("circle"),radius:G}),un.extend({shape:p.literal("rect"),width:G,height:G})]),GL=p.object({name:p.string().optional(),layer:_e,connectsTo:p.string(),padMargin:G.optional(),traceMargin:G.optional()});kt(!0);var UL=p.object({originalLayer:_e.default("top").optional(),children:p.any().optional()});kt(!0);var wft=p.object({pcbX:G.optional(),pcbY:G.optional(),pcbZ:G.optional()}),Sft=Ma.extend({modelUrl:p.string()}),Pft=Sft.merge(wft);kt(!0);var qL=p.union([p.null(),p.string(),Pft]),WL=Fn.extend({voltage:Qn}),Tft=["pin1","pin2","pos","neg"],Ift=p.union([p.string(),p.number()]).transform(e=>typeof e=="string"?e.endsWith("%")?parseFloat(e.slice(0,-1))/100:parseFloat(e):e).pipe(p.number().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),mLt=Fn.extend({voltage:Qn.optional(),frequency:po.optional(),peakToPeakVoltage:Qn.optional(),waveShape:p.enum(["sinewave","square","triangle","sawtooth"]).optional(),phase:Fe.optional(),dutyCycle:Ift.optional(),connections:cl(Tft).optional()});kt(!0);var ZL=p.object({center:ee,radius:G,startAngleDegrees:Fe,endAngleDegrees:Fe,direction:p.enum(["clockwise","counterclockwise"]).default("counterclockwise"),strokeWidth:G.optional(),color:p.string().optional().default("#000000"),isDashed:p.boolean().optional().default(!1)}),KL=p.object({schX:G.optional(),schY:G.optional(),width:G.optional(),height:G.optional(),overlay:p.array(p.string()).optional(),padding:G.optional(),paddingLeft:G.optional(),paddingRight:G.optional(),paddingTop:G.optional(),paddingBottom:G.optional(),title:p.string().optional(),titleAlignment:Pd.default("top_left"),titleColor:p.string().optional(),titleFontSize:G.optional(),titleInside:p.boolean().default(!1),strokeStyle:p.enum(["solid","dashed"]).default("solid")}).refine(e=>e.width!==void 0&&e.height!==void 0||Array.isArray(e.overlay)&&e.overlay.length>0,{message:"Must provide either both `width` and `height`, or a non-empty `overlay` array."}).refine(e=>!(e.width!==void 0&&e.height!==void 0&&Array.isArray(e.overlay)&&e.overlay.length>0),{message:"Cannot provide both `width`/`height` and `overlay` at the same time."}),JL=p.object({center:ee,radius:G,strokeWidth:G.optional(),color:p.string().optional().default("#000000"),isFilled:p.boolean().optional().default(!1),fillColor:p.string().optional(),isDashed:p.boolean().optional().default(!1)}),QL=p.object({center:ee,width:G,height:G,rotation:Fe.default(0),strokeWidth:G.optional(),color:p.string().optional().default("#000000"),isFilled:p.boolean().optional().default(!1),fillColor:p.string().optional(),isDashed:p.boolean().optional().default(!1)}),tF=p.object({x1:G,y1:G,x2:G,y2:G,strokeWidth:G.optional(),color:p.string().optional().default("#000000"),isDashed:p.boolean().optional().default(!1)}),Mft=p.enum(["center","left","right","top","bottom"]),eF=p.object({schX:G.optional(),schY:G.optional(),text:p.string(),fontSize:p.number().default(1),anchor:p.union([Mft.describe("legacy"),Pd]).default("center"),color:p.string().default("#000000"),schRotation:Fe.default(0)}),ALt=p.object({points:p.array(ee),isFilled:p.boolean().optional().default(!1),fillColor:p.enum(["red","blue"]).optional()}),nF=p.object({schX:G.optional(),schY:G.optional(),children:p.any().optional(),cellPadding:G.optional(),borderWidth:G.optional(),anchor:Pd.optional(),fontSize:G.optional()});kt(!0);var iF=p.object({children:p.any().optional(),height:G.optional()});kt(!0);var rF=p.object({children:p.string().optional(),horizontalAlign:p.enum(["left","center","right"]).optional(),verticalAlign:p.enum(["top","middle","bottom"]).optional(),fontSize:G.optional(),rowSpan:p.number().optional(),colSpan:p.number().optional(),width:G.optional(),text:p.string().optional()});kt(!0);var oF=un.extend({text:p.string(),anchorAlignment:Pd.default("center"),font:p.enum(["tscircuit2024"]).optional(),fontSize:$.optional(),isKnockout:p.boolean().optional(),knockoutPadding:$.optional(),knockoutPaddingLeft:$.optional(),knockoutPaddingRight:$.optional(),knockoutPaddingTop:$.optional(),knockoutPaddingBottom:$.optional(),layers:p.array(_e).optional()}),sF=un.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({route:p.array(Yi),strokeWidth:$.optional()}),aF=un.omit({pcbX:!0,pcbY:!0,pcbRotation:!0}).extend({strokeWidth:G,x1:G,y1:G,x2:G,y2:G}),cF=un.omit({pcbRotation:!0}).extend({filled:p.boolean().default(!0).optional(),stroke:p.enum(["dashed","solid","none"]).optional(),strokeWidth:G.optional(),width:G,height:G}),lF=un.omit({pcbRotation:!0}).extend({isFilled:p.boolean().optional(),isOutline:p.boolean().optional(),strokeWidth:G.optional(),radius:G}),iL=p.object({x:G,y:G,via:p.boolean().optional(),toLayer:_e.optional()}),uF=p.object({for:p.string().optional().describe("Selector for the port you're targeting, not required if you're inside a trace"),order:p.number().optional(),offset:Yi.or(iL).optional(),offsets:p.array(Yi).or(p.array(iL)).optional(),traceWidth:p.number().optional()}),ZLt=qy.extend({name:p.string(),pinNumber:p.number().optional(),aliases:p.array(p.string()).optional(),direction:Sdt}),Eft=p.array(p.any()).describe("Circuit JSON"),pF=p.object({footprintCircuitJson:p.array(p.any()),cadModel:oL.optional()}),rL=p.function().args(p.string()).returns(p.promise(pF)).describe("A function that takes a path and returns Circuit JSON"),Cft=p.object({loadFromUrl:p.function().args(p.string()).returns(p.promise(pF)).describe("A function that takes a footprint file URL and returns Circuit JSON")}),kft=p.object({partsEngine:cL.optional(),autorouter:sL.optional(),registryApiUrl:p.string().optional(),cloudAutorouterUrl:p.string().optional(),projectName:p.string().optional(),projectBaseUrl:p.string().optional(),version:p.string().optional(),url:p.string().optional(),printBoardInformationToSilkscreen:p.boolean().optional(),localCacheEngine:p.any().optional(),pcbDisabled:p.boolean().optional(),schematicDisabled:p.boolean().optional(),partsEngineDisabled:p.boolean().optional(),footprintLibraryMap:p.record(p.string(),p.union([rL,p.record(p.string(),p.union([Eft,rL]))])).optional(),footprintFileParserMap:p.record(p.string(),Cft).optional()});kt(!0);var Aft=kft,JLt=Aft.pick({projectName:!0,projectBaseUrl:!0,version:!0,url:!0,printBoardInformationToSilkscreen:!0});kt(!0);Z();St();vs();Z();var Za=Xt(co(),1);vs();Z();function Ca(){return new T5}var T5=class e{constructor(){T(this,"index",{});T(this,"array",[])}size(){return this.array.length}empty(){return this.array.length===0}itemAt(t){return this.array[t]}contains(t){return this.index[t.id()]!==void 0}find(t){let n=this.index[t.id()];return n===void 0?void 0:this.array[n]}setDefault(t,n){let i=this.index[t.id()];if(i===void 0){let r=new Jy(t,n());return this.index[t.id()]=this.array.length,this.array.push(r),r}else return this.array[i]}insert(t,n){let i=new Jy(t,n),r=this.index[t.id()];return r===void 0?(this.index[t.id()]=this.array.length,this.array.push(i)):this.array[r]=i,i}erase(t){let n=this.index[t.id()];if(n===void 0)return;this.index[t.id()]=void 0;let i=this.array[n],r=this.array.pop();return i!==r&&(this.array[n]=r,this.index[r.first.id()]=n),i}copy(){let t=new e;for(let n=0;n<this.array.length;n++){let i=this.array[n].copy();t.array[n]=i,t.index[i.first.id()]=n}return t}},Jy=class e{constructor(t,n){T(this,"first");T(this,"second");this.first=t,this.second=n}copy(){return new e(this.first,this.second)}};var Is=class{constructor(t=""){T(this,"_name");T(this,"_value",0);T(this,"_context",null);T(this,"_id",Nft++);this._name=t}id(){return this._id}name(){return this._name}setName(t){this._name=t}context(){return this._context}setContext(t){this._context=t}value(){return this._value}setValue(t){this._value=t}plus(t){return new bn(this,t)}minus(t){return new bn(this,typeof t=="number"?-t:[-1,t])}multiply(t){return new bn([t,this])}divide(t){return new bn([1/t,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+"["+this._name+":"+this._value+"]"}},Nft=0;var bn=class e{constructor(){T(this,"_terms");T(this,"_constant");let t=Rft(arguments);this._terms=t.terms,this._constant=t.constant}terms(){return this._terms}constant(){return this._constant}value(){let t=this._constant;for(let n=0,i=this._terms.size();n<i;n++){let r=this._terms.itemAt(n);t+=r.first.value()*r.second}return t}plus(t){return new e(this,t)}minus(t){return new e(this,typeof t=="number"?-t:[-1,t])}multiply(t){return new e([t,this])}divide(t){return new e([1/t,this])}isConstant(){return this._terms.size()==0}toString(){let t=this._terms.array.map(function(n){return n.second+"*"+n.first.toString()}).join(" + ");return!this.isConstant()&&this._constant!==0&&(t+=" + "),t+=this._constant,t}};function Rft(e){let t=0,n=()=>0,i=Ca();for(let r=0,o=e.length;r<o;++r){let s=e[r];if(typeof s=="number")t+=s;else if(s instanceof Is)i.setDefault(s,n).second+=1;else if(s instanceof bn){t+=s.constant();let a=s.terms();for(let c=0,l=a.size();c<l;c++){let u=a.itemAt(c);i.setDefault(u.first,n).second+=u.second}}else if(s instanceof Array){if(s.length!==2)throw new Error("array must have length 2");let a=s[0],c=s[1];if(typeof a!="number")throw new Error("array item 0 must be a number");if(c instanceof Is)i.setDefault(c,n).second+=a;else if(c instanceof bn){t+=c.constant()*a;let l=c.terms();for(let u=0,h=l.size();u<h;u++){let f=l.itemAt(u);i.setDefault(f.first,n).second+=f.second*a}}else throw new Error("array item 1 must be a variable or expression")}else throw new Error("invalid Expression argument: "+s)}return{terms:i,constant:t}}var mo=class mo{static create(t,n,i,r=1){let o=0;return o+=Math.max(0,Math.min(1e3,t*r))*1e6,o+=Math.max(0,Math.min(1e3,n*r))*1e3,o+=Math.max(0,Math.min(1e3,i*r)),o}static clip(t){return Math.max(0,Math.min(mo.required,t))}};T(mo,"required",mo.create(1e3,1e3,1e3)),T(mo,"strong",mo.create(1,0,0)),T(mo,"medium",mo.create(0,1,0)),T(mo,"weak",mo.create(0,0,1));var mn=mo;var zn;(function(e){e[e.Le=0]="Le",e[e.Ge=1]="Ge",e[e.Eq=2]="Eq"})(zn||(zn={}));var ti=class{constructor(t,n,i,r=mn.required){T(this,"_expression");T(this,"_operator");T(this,"_strength");T(this,"_id",Oft++);this._operator=n,this._strength=mn.clip(r),i===void 0&&t instanceof bn?this._expression=t:this._expression=t.minus(i)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+" "+["<=",">=","="][this._operator]+" 0 ("+this._strength.toString()+")"}},Oft=0;var up=class{constructor(){T(this,"maxIterations",1e3);T(this,"_cnMap",Lft());T(this,"_rowMap",Fft());T(this,"_varMap",zft());T(this,"_editMap",Dft());T(this,"_infeasibleRows",[]);T(this,"_objective",new eg);T(this,"_artificial",null);T(this,"_idTick",0)}createConstraint(t,n,i,r=mn.required){let o=new ti(t,n,i,r);return this.addConstraint(o),o}addConstraint(t){if(this._cnMap.find(t)!==void 0)throw new Error("duplicate constraint");let i=this._createRow(t),r=i.row,o=i.tag,s=this._chooseSubject(r,o);if(s.type()===je.Invalid&&r.allDummies())if(Qy(r.constant()))s=o.marker;else throw new Error("unsatisfiable constraint");if(s.type()===je.Invalid){if(!this._addWithArtificialVariable(r))throw new Error("unsatisfiable constraint")}else r.solveFor(s),this._substitute(s,r),this._rowMap.insert(s,r);this._cnMap.insert(t,o),this._optimize(this._objective)}removeConstraint(t){let n=this._cnMap.erase(t);if(n===void 0)throw new Error("unknown constraint");this._removeConstraintEffects(t,n.second);let i=n.second.marker,r=this._rowMap.erase(i);if(r===void 0){let o=this._getMarkerLeavingSymbol(i);if(o.type()===je.Invalid)throw new Error("failed to find leaving row");r=this._rowMap.erase(o),r.second.solveForEx(o,i),this._substitute(i,r.second)}this._optimize(this._objective)}hasConstraint(t){return this._cnMap.contains(t)}getConstraints(){return this._cnMap.array.map(({first:t})=>t)}addEditVariable(t,n){if(this._editMap.find(t)!==void 0)throw new Error("duplicate edit variable");if(n=mn.clip(n),n===mn.required)throw new Error("bad required strength");let r=new bn(t),o=new ti(r,zn.Eq,void 0,n);this.addConstraint(o);let a={tag:this._cnMap.find(o).second,constraint:o,constant:0};this._editMap.insert(t,a)}removeEditVariable(t){let n=this._editMap.erase(t);if(n===void 0)throw new Error("unknown edit variable");this.removeConstraint(n.second.constraint)}hasEditVariable(t){return this._editMap.contains(t)}suggestValue(t,n){let i=this._editMap.find(t);if(i===void 0)throw new Error("unknown edit variable");let r=this._rowMap,o=i.second,s=n-o.constant;o.constant=n;let a=o.tag.marker,c=r.find(a);if(c!==void 0){c.second.add(-s)<0&&this._infeasibleRows.push(a),this._dualOptimize();return}let l=o.tag.other;if(c=r.find(l),c!==void 0){c.second.add(s)<0&&this._infeasibleRows.push(l),this._dualOptimize();return}for(let u=0,h=r.size();u<h;++u){let f=r.itemAt(u),_=f.second,y=_.coefficientFor(a);y!==0&&_.add(s*y)<0&&f.first.type()!==je.External&&this._infeasibleRows.push(f.first)}this._dualOptimize()}updateVariables(){let t=this._varMap,n=this._rowMap;for(let i=0,r=t.size();i<r;++i){let o=t.itemAt(i),s=n.find(o.second);s!==void 0?o.first.setValue(s.second.constant()):o.first.setValue(0)}}_getVarSymbol(t){let n=()=>this._makeSymbol(je.External);return this._varMap.setDefault(t,n).second}_createRow(t){let n=t.expression(),i=new eg(n.constant()),r=n.terms();for(let c=0,l=r.size();c<l;++c){let u=r.itemAt(c);if(!Qy(u.second)){let h=this._getVarSymbol(u.first),f=this._rowMap.find(h);f!==void 0?i.insertRow(f.second,u.second):i.insertSymbol(h,u.second)}}let o=this._objective,s=t.strength(),a={marker:ka,other:ka};switch(t.op()){case zn.Le:case zn.Ge:{let c=t.op()===zn.Le?1:-1,l=this._makeSymbol(je.Slack);if(a.marker=l,i.insertSymbol(l,c),s<mn.required){let u=this._makeSymbol(je.Error);a.other=u,i.insertSymbol(u,-c),o.insertSymbol(u,s)}break}case zn.Eq:{if(s<mn.required){let c=this._makeSymbol(je.Error),l=this._makeSymbol(je.Error);a.marker=c,a.other=l,i.insertSymbol(c,-1),i.insertSymbol(l,1),o.insertSymbol(c,s),o.insertSymbol(l,s)}else{let c=this._makeSymbol(je.Dummy);a.marker=c,i.insertSymbol(c)}break}}return i.constant()<0&&i.reverseSign(),{row:i,tag:a}}_chooseSubject(t,n){let i=t.cells();for(let o=0,s=i.size();o<s;++o){let a=i.itemAt(o);if(a.first.type()===je.External)return a.first}let r=n.marker.type();return(r===je.Slack||r===je.Error)&&t.coefficientFor(n.marker)<0?n.marker:(r=n.other.type(),(r===je.Slack||r===je.Error)&&t.coefficientFor(n.other)<0?n.other:ka)}_addWithArtificialVariable(t){let n=this._makeSymbol(je.Slack);this._rowMap.insert(n,t.copy()),this._artificial=t.copy(),this._optimize(this._artificial);let i=Qy(this._artificial.constant());this._artificial=null;let r=this._rowMap.erase(n);if(r!==void 0){let s=r.second;if(s.isConstant())return i;let a=this._anyPivotableSymbol(s);if(a.type()===je.Invalid)return!1;s.solveForEx(n,a),this._substitute(a,s),this._rowMap.insert(a,s)}let o=this._rowMap;for(let s=0,a=o.size();s<a;++s)o.itemAt(s).second.removeSymbol(n);return this._objective.removeSymbol(n),i}_substitute(t,n){let i=this._rowMap;for(let r=0,o=i.size();r<o;++r){let s=i.itemAt(r);s.second.substitute(t,n),s.second.constant()<0&&s.first.type()!==je.External&&this._infeasibleRows.push(s.first)}this._objective.substitute(t,n),this._artificial&&this._artificial.substitute(t,n)}_optimize(t){let n=0;for(;n<this.maxIterations;){let i=this._getEnteringSymbol(t);if(i.type()===je.Invalid)return;let r=this._getLeavingSymbol(i);if(r.type()===je.Invalid)throw new Error("the objective is unbounded");let o=this._rowMap.erase(r).second;o.solveForEx(r,i),this._substitute(i,o),this._rowMap.insert(i,o),n++}throw new Error("solver iterations exceeded")}_dualOptimize(){let t=this._rowMap,n=this._infeasibleRows;for(;n.length!==0;){let i=n.pop(),r=t.find(i);if(r!==void 0&&r.second.constant()<0){let o=this._getDualEnteringSymbol(r.second);if(o.type()===je.Invalid)throw new Error("dual optimize failed");let s=r.second;t.erase(i),s.solveForEx(i,o),this._substitute(o,s),t.insert(o,s)}}}_getEnteringSymbol(t){let n=t.cells();for(let i=0,r=n.size();i<r;++i){let o=n.itemAt(i),s=o.first;if(o.second<0&&s.type()!==je.Dummy)return s}return ka}_getDualEnteringSymbol(t){let n=Number.MAX_VALUE,i=ka,r=t.cells();for(let o=0,s=r.size();o<s;++o){let a=r.itemAt(o),c=a.first,l=a.second;if(l>0&&c.type()!==je.Dummy){let h=this._objective.coefficientFor(c)/l;h<n&&(n=h,i=c)}}return i}_getLeavingSymbol(t){let n=Number.MAX_VALUE,i=ka,r=this._rowMap;for(let o=0,s=r.size();o<s;++o){let a=r.itemAt(o),c=a.first;if(c.type()!==je.External){let l=a.second,u=l.coefficientFor(t);if(u<0){let h=-l.constant()/u;h<n&&(n=h,i=c)}}}return i}_getMarkerLeavingSymbol(t){let n=Number.MAX_VALUE,i=n,r=n,o=ka,s=o,a=o,c=o,l=this._rowMap;for(let u=0,h=l.size();u<h;++u){let f=l.itemAt(u),_=f.second,y=_.coefficientFor(t);if(y===0)continue;let x=f.first;if(x.type()===je.External)c=x;else if(y<0){let v=-_.constant()/y;v<i&&(i=v,s=x)}else{let v=_.constant()/y;v<r&&(r=v,a=x)}}return s!==o?s:a!==o?a:c}_removeConstraintEffects(t,n){n.marker.type()===je.Error&&this._removeMarkerEffects(n.marker,t.strength()),n.other.type()===je.Error&&this._removeMarkerEffects(n.other,t.strength())}_removeMarkerEffects(t,n){let i=this._rowMap.find(t);i!==void 0?this._objective.insertRow(i.second,-n):this._objective.insertSymbol(t,-n)}_anyPivotableSymbol(t){let n=t.cells();for(let i=0,r=n.size();i<r;++i){let o=n.itemAt(i),s=o.first.type();if(s===je.Slack||s===je.Error)return o.first}return ka}_makeSymbol(t){return new tg(t,this._idTick++)}};function Qy(e){let t=1e-8;return e<0?-e<t:e<t}function Lft(){return Ca()}function Fft(){return Ca()}function zft(){return Ca()}function Dft(){return Ca()}var je;(function(e){e[e.Invalid=0]="Invalid",e[e.External=1]="External",e[e.Slack=2]="Slack",e[e.Error=3]="Error",e[e.Dummy=4]="Dummy"})(je||(je={}));var tg=class{constructor(t,n){T(this,"_id");T(this,"_type");this._id=n,this._type=t}id(){return this._id}type(){return this._type}},ka=new tg(je.Invalid,-1),eg=class e{constructor(t=0){T(this,"_cellMap",Ca());T(this,"_constant");this._constant=t}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let t=this._cellMap;for(let n=0,i=t.size();n<i;++n)if(t.itemAt(n).first.type()!==je.Dummy)return!1;return!0}copy(){let t=new e(this._constant);return t._cellMap=this._cellMap.copy(),t}add(t){return this._constant+=t}insertSymbol(t,n=1){let i=this._cellMap.setDefault(t,()=>0);Qy(i.second+=n)&&this._cellMap.erase(t)}insertRow(t,n=1){this._constant+=t._constant*n;let i=t._cellMap;for(let r=0,o=i.size();r<o;++r){let s=i.itemAt(r);this.insertSymbol(s.first,s.second*n)}}removeSymbol(t){this._cellMap.erase(t)}reverseSign(){this._constant=-this._constant;let t=this._cellMap;for(let n=0,i=t.size();n<i;++n){let r=t.itemAt(n);r.second=-r.second}}solveFor(t){let n=this._cellMap,r=-1/n.erase(t).second;this._constant*=r;for(let o=0,s=n.size();o<s;++o)n.itemAt(o).second*=r}solveForEx(t,n){this.insertSymbol(t,-1),this.solveFor(n)}coefficientFor(t){let n=this._cellMap.find(t);return n!==void 0?n.second:0}substitute(t,n){let i=this._cellMap.erase(t);i!==void 0&&this.insertRow(n,i.second)}};var yY=Xt(Pn(),1);Z();St();Xi();var I5={};Mu(I5,{boundsAreaOverlap:()=>wF,boundsDistance:()=>SF,clamp:()=>Ln,computeDistanceBetweenBoxes:()=>ap,distSq:()=>gF,distance:()=>Si,doBoundsOverlap:()=>Md,doSegmentsIntersect:()=>cr,doesLineIntersectLine:()=>Aa,doesSegmentIntersectRect:()=>fF,findNearestPointsBetweenBoxSets:()=>vd,getBoundingBox:()=>Ts,getSegmentIntersection:()=>dF,getUnitVectorFromDirection:()=>og,getUnitVectorFromPointAToB:()=>rg,grid:()=>PF,midpoint:()=>yF,onSegment:()=>hp,orientation:()=>pp,pointToBoundsDistance:()=>_F,pointToBoxDistance:()=>mF,pointToSegmentClosestPoint:()=>vF,pointToSegmentDistance:()=>ei,range:()=>xF,segmentToBoundsMinDistance:()=>Id,segmentToBoxMinDistance:()=>bF,segmentToCircleMinDistance:()=>ig,segmentToSegmentMinDistance:()=>ng});function Aa([e,t],[n,i],{lineThickness:r=0}={}){return r===0?cr(e,t,n,i):$ft(e,t,n,i)<=r}function cr(e,t,n,i){let r=pp(e,t,n),o=pp(e,t,i),s=pp(n,i,e),a=pp(n,i,t);return!!(r!==o&&s!==a||r===0&&hp(e,n,t)||o===0&&hp(e,i,t)||s===0&&hp(n,e,i)||a===0&&hp(n,t,i))}function pp(e,t,n){let i=(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y);return i===0?0:i>0?1:2}function hp(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function $ft(e,t,n,i){if(e.x===t.x&&e.y===t.y)return ei(e,n,i);if(n.x===i.x&&n.y===i.y)return ei(n,e,t);if(cr(e,t,n,i))return 0;let r=[ei(e,n,i),ei(t,n,i),ei(n,e,t),ei(i,e,t)];return Math.min(...r)}function ei(e,t,n){let i=(n.x-t.x)**2+(n.y-t.y)**2;if(i===0)return Si(e,t);let r=((e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y))/i;r=Math.max(0,Math.min(1,r));let o={x:t.x+r*(n.x-t.x),y:t.y+r*(n.y-t.y)};return Si(e,o)}function Si(e,t){let n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)}function dF(e,t,n,i){let r=t.x-e.x,o=t.y-e.y,s=i.x-n.x,a=i.y-n.y,c=e.x-n.x,l=e.y-n.y,u=r*a-o*s;if(Math.abs(u)<1e-10)return null;let h=(l*s-c*a)/u,f=(r*l-o*c)/u,_=1e-9;if(h>=-_&&h<=1+_&&f>=-_&&f<=1+_){let y=e.x+h*r,x=e.y+h*o;return{x:y,y:x}}return null}function fF(e,t,n){let i=c=>c.x>=n.minX&&c.x<=n.maxX&&c.y>=n.minY&&c.y<=n.maxY;if(i(e)||i(t))return!0;let r={x:n.minX,y:n.minY},o={x:n.maxX,y:n.minY},s={x:n.minX,y:n.maxY},a={x:n.maxX,y:n.maxY};return cr(e,t,r,o)||cr(e,t,o,a)||cr(e,t,a,s)||cr(e,t,s,r)}function mF(e,t){let n=t.width/2,i=t.height/2,r=t.center.x-n,o=t.center.x+n,s=t.center.y-i,a=t.center.y+i;if(e.x>=r&&e.x<=o&&e.y>=s&&e.y<=a)return 0;let c=Ln(e.x,r,o),l=Ln(e.y,s,a);return Si(e,{x:c,y:l})}function _F(e,t){if(e.x>=t.minX&&e.x<=t.maxX&&e.y>=t.minY&&e.y<=t.maxY)return 0;let n=Ln(e.x,t.minX,t.maxX),i=Ln(e.y,t.minY,t.maxY);return Si(e,{x:n,y:i})}function yF(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function gF(e,t){let n=e.x-t.x,i=e.y-t.y;return n*n+i*i}function xF(e,t,n=1){if(n===0)throw new Error("step cannot be 0");let i,r;t===void 0?(i=0,r=e):(i=e,r=t);let o=[];if(n>0)for(let s=i;s<r;s+=n)o.push(s);else for(let s=i;s>r;s+=n)o.push(s);return o}function ng(e,t,n,i){if(e.x===t.x&&e.y===t.y)return ei(e,n,i);if(n.x===i.x&&n.y===i.y)return ei(n,e,t);if(cr(e,t,n,i))return 0;let r=[ei(e,n,i),ei(t,n,i),ei(n,e,t),ei(i,e,t)];return Math.min(...r)}function Id(e,t,n){let i={x:n.minX,y:n.minY},r={x:n.maxX,y:n.minY},o={x:n.minX,y:n.maxY},s={x:n.maxX,y:n.maxY};if(cr(e,t,i,r)||cr(e,t,r,s)||cr(e,t,s,o)||cr(e,t,o,i)||e.x>=n.minX&&e.x<=n.maxX&&e.y>=n.minY&&e.y<=n.maxY&&t.x>=n.minX&&t.x<=n.maxX&&t.y>=n.minY&&t.y<=n.maxY)return 0;let a=[ei(i,e,t),ei(r,e,t),ei(o,e,t),ei(s,e,t)];if(e.x>=n.minX&&e.x<=n.maxX&&e.y>=n.minY&&e.y<=n.maxY||t.x>=n.minX&&t.x<=n.maxX&&t.y>=n.minY&&t.y<=n.maxY)return 0;if(e.x<n.minX||e.x>n.maxX||e.y<n.minY||e.y>n.maxY){let c=Ln(e.x,n.minX,n.maxX),l=Ln(e.y,n.minY,n.maxY);a.push(Si(e,{x:c,y:l}))}if(t.x<n.minX||t.x>n.maxX||t.y<n.minY||t.y>n.maxY){let c=Ln(t.x,n.minX,n.maxX),l=Ln(t.y,n.minY,n.maxY);a.push(Si(t,{x:c,y:l}))}return Math.min(...a)}function bF(e,t,n){let i=n.width/2,r=n.height/2,o={minX:n.center.x-i,maxX:n.center.x+i,minY:n.center.y-r,maxY:n.center.y+r};return Id(e,t,o)}function ig(e,t,n){let i={x:n.x,y:n.y};if(e.x===t.x&&e.y===t.y)return Math.max(0,Si(e,i)-n.radius);let r={x:t.x-e.x,y:t.y-e.y},o={x:i.x-e.x,y:i.y-e.y},s=r.x*r.x+r.y*r.y,a=Math.max(0,Math.min(1,(r.x*o.x+r.y*o.y)/s)),c={x:e.x+a*r.x,y:e.y+a*r.y},l=Si(c,i);return Math.max(0,l-n.radius)}function vF(e,t,n){let i=n.x-t.x,r=n.y-t.y,o=i*i+r*r;if(o===0)return{x:t.x,y:t.y};let s=((e.x-t.x)*i+(e.y-t.y)*r)/o;return s=Math.max(0,Math.min(1,s)),{x:t.x+s*i,y:t.y+s*r}}var wF=(e,t)=>{let n=Math.max(0,Math.min(e.maxX,t.maxX)-Math.max(e.minX,t.minX)),i=Math.max(0,Math.min(e.maxY,t.maxY)-Math.max(e.minY,t.minY));return n*i};var SF=(e,t)=>{let n=e.maxX<t.minX?t.minX-e.maxX:t.maxX<e.minX?e.minX-t.maxX:0,i=e.maxY<t.minY?t.minY-e.maxY:t.maxY<e.minY?e.minY-t.maxY:0;return Math.sqrt(n*n+i*i)};var Md=(e,t)=>!(e.maxX<t.minX||t.maxX<e.minX||e.maxY<t.minY||t.maxY<e.minY);var rg=(e,t)=>{let n={x:t.x-e.x,y:t.y-e.y},i=Math.sqrt(n.x**2+n.y**2);return{x:n.x/i,y:n.y/i}},og=e=>{switch(e){case"up":return{x:0,y:1};case"down":return{x:0,y:-1};case"left":return{x:-1,y:0};case"right":return{x:1,y:0}}};function PF({rows:e,cols:t,xSpacing:n,ySpacing:i,width:r,height:o,offsetX:s=0,offsetY:a=0,yDirection:c="cartesian",centered:l=!0}){let u=n??1,h=i??1,f=r??t*u,_=o??e*h,y=l?-f/2:0,x=l?-_/2:0,v=r?r/t:u,w=o?o/e:h,S=[];for(let k=0;k<e;k++)for(let E=0;E<t;E++){let R=k*t+E,I=s+y+E*v+v/2,C=a+k*w+w/2,M=c==="cartesian"?a+x+(e-1-k)*w+w/2:a+x+k*w+w/2;S.push({index:R,center:{x:I,y:M},topLeft:{x:I-v/2,y:M+w/2},bottomRight:{x:I+v/2,y:M-w/2},row:k,col:E})}return S}St();Ed();var TF={name:"@tscircuit/capacity-autorouter",main:"./dist/index.js",version:"0.0.107",type:"module",files:["dist"],scripts:{start:"cosmos",build:"tsup ./lib/index.ts --minify terser --external @tscircuit/core --external circuit-to-svg --format esm --dts --sourcemap",bench:"bun test tests/spatial-index-bench.test.ts",format:"biome format --write .","format:check":"biome format .","vercel-build":"cosmos-export","repomix:lib":"repomix --ignore 'testing/**,**/TwoRouteHighDensitySolver/**,**/RouteStitchingSolver/**,solvers/CapacitySegmentPointOptimizer/CapacitySegmentPointOptimizer.ts' lib","bug-report":"bun run scripts/download-bug-report.ts"},devDependencies:{"@biomejs/biome":"^1.9.4","@radix-ui/react-icons":"^1.3.2","@radix-ui/react-menubar":"^1.1.14","@react-hook/resize-observer":"^2.0.2","@tscircuit/checks":"^0.0.36","@tscircuit/circuit-json-util":"^0.0.46","@tscircuit/core":"^0.0.337","@tscircuit/math-utils":"^0.0.18","@types/bun":"^1.2.16","@types/fast-json-stable-stringify":"^2.1.2","@types/object-hash":"^3.0.6","@types/rbush":"^4.0.0","@types/react":"^19.0.8","@types/react-dom":"^19.0.3","@vercel/node":"^5.1.7","@vitejs/plugin-react":"^4.3.4","bun-match-svg":"^0.0.9","circuit-json-to-connectivity-map":"^0.0.19","circuit-to-svg":"^0.0.110",clsx:"^2.1.1",flatbush:"^4.4.0","graphics-debug":"^0.0.44",rbush:"^4.0.1",react:"18","react-cosmos":"^6.2.3","react-cosmos-plugin-vite":"^6.2.0","react-dom":"18","react-konva":"18",recharts:"^2.15.1","tailwind-merge":"^3.2.0",terser:"^5.43.1",tsup:"^8.3.6","use-mouse-matrix-transform":"^1.3.0",vite:"^6.0.11","vite-tsconfig-paths":"^5.1.4"},peerDependencies:{typescript:"^5.7.3"},dependencies:{"fast-json-stable-stringify":"^2.1.0","object-hash":"^3.0.0"}};St();Xi();Oe();var tI=Xt(co(),1);St();var kz=Xt(k5(),1),Rz=Xt(k5(),1);var wg=(...e)=>{let t={points:[],lines:[],circles:[],rects:[]};return e.forEach((n,i)=>{n&&(n.lines&&(t.lines=[...t.lines||[],...n.lines.map(r=>({...r,step:i}))]),n.points&&(t.points=[...t.points||[],...n.points.map(r=>({...r,step:i}))]),n.circles&&(t.circles=[...t.circles||[],...n.circles.map(r=>({...r,step:i}))]),n.rects&&(t.rects=[...t.rects||[],...n.rects.map(r=>({...r,step:i}))]))}),t},an=class{constructor(){T(this,"MAX_ITERATIONS",1e3);T(this,"solved",!1);T(this,"failed",!1);T(this,"iterations",0);T(this,"progress",0);T(this,"error",null);T(this,"activeSubSolver");T(this,"failedSubSolvers");T(this,"timeToSolve");T(this,"stats",{});T(this,"cacheHit");T(this,"cacheKey");T(this,"cacheToSolveSpaceTransform")}step(){if(!this.solved&&!this.failed){this.iterations++;try{this._step()}catch(e){throw this.error=`${this.constructor.name} error: ${e}`,console.error(this.error),this.failed=!0,e}!this.solved&&this.iterations>this.MAX_ITERATIONS&&this.tryFinalAcceptance(),!this.solved&&this.iterations>this.MAX_ITERATIONS&&(this.error=`${this.constructor.name} ran out of iterations`,console.error(this.error),this.failed=!0),"computeProgress"in this&&(this.progress=this.computeProgress())}}_step(){}getConstructorParams(){throw new Error("getConstructorParams not implemented")}solve(){let e=Date.now();for(;!this.solved&&!this.failed;)this.step();let t=Date.now();this.timeToSolve=t-e}visualize(){return{lines:[],points:[],rects:[],circles:[]}}tryFinalAcceptance(){}preview(){return{lines:[],points:[],rects:[],circles:[]}}};function ur(){return ur=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},ur.apply(null,arguments)}function Ig(e,t){return(Ig=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n})(e,t)}function mz(e){return(mz=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(e)}function _z(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(_z=function(){return!!e})()}function Y5(e){var t=typeof Map=="function"?new Map:void 0;return Y5=function(n){if(n===null||!(function(r){try{return Function.toString.call(r).indexOf("[native code]")!==-1}catch{return typeof r=="function"}})(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(t!==void 0){if(t.has(n))return t.get(n);t.set(n,i)}function i(){return(function(r,o,s){if(_z())return Reflect.construct.apply(null,arguments);var a=[null];a.push.apply(a,o);var c=new(r.bind.apply(r,a));return s&&Ig(c,s.prototype),c})(n,arguments,mz(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ig(i,n)},Y5(e)}var lr=(function(e){var t,n;function i(r){var o;if(1)o=e.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+r+" for more information.")||this;else for(var s,a,c;c<s;c++);return(function(l){if(l===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return l})(o)}return n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,Ig(t,n),i})(Y5(Error));function BF(e,t){return e.substr(-t.length)===t}var Jft=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function jF(e){return typeof e!="string"?e:e.match(Jft)?parseFloat(e):e}var YF=function(e){return function(t,n){n===void 0&&(n="16px");var i=t,r=n;if(typeof t=="string"){if(!BF(t,"px"))throw new lr(69,e,t);i=jF(t)}if(typeof n=="string"){if(!BF(n,"px"))throw new lr(70,e,n);r=jF(n)}if(typeof i=="string")throw new lr(71,t,e);if(typeof r=="string")throw new lr(72,n,e);return""+i/r+e}};YF("em"),YF("rem");function A5(e){return Math.round(255*e)}function Qft(e,t,n){return A5(e)+","+A5(t)+","+A5(n)}function zd(e,t,n,i){if(i===void 0&&(i=Qft),t===0)return i(n,n,n);var r=(e%360+360)%360/60,o=(1-Math.abs(2*n-1))*t,s=o*(1-Math.abs(r%2-1)),a=0,c=0,l=0;r>=0&&r<1?(a=o,c=s):r>=1&&r<2?(a=s,c=o):r>=2&&r<3?(c=o,l=s):r>=3&&r<4?(c=s,l=o):r>=4&&r<5?(a=s,l=o):r>=5&&r<6&&(a=o,l=s);var u=n-o/2;return i(a+u,c+u,l+u)}var XF={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},tmt=/^#[a-fA-F0-9]{6}$/,emt=/^#[a-fA-F0-9]{8}$/,nmt=/^#[a-fA-F0-9]{3}$/,imt=/^#[a-fA-F0-9]{4}$/,N5=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,rmt=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,omt=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,smt=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function xp(e){if(typeof e!="string")throw new lr(3);var t=(function(f){if(typeof f!="string")return f;var _=f.toLowerCase();return XF[_]?"#"+XF[_]:f})(e);if(t.match(tmt))return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16)};if(t.match(emt)){var n=parseFloat((parseInt(""+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16),alpha:n}}if(t.match(nmt))return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16)};if(t.match(imt)){var i=parseFloat((parseInt(""+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16),alpha:i}}var r=N5.exec(t);if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10)};var o=rmt.exec(t.substring(0,50));if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10),alpha:parseFloat(""+o[4])>1?parseFloat(""+o[4])/100:parseFloat(""+o[4])};var s=omt.exec(t);if(s){var a="rgb("+zd(parseInt(""+s[1],10),parseInt(""+s[2],10)/100,parseInt(""+s[3],10)/100)+")",c=N5.exec(a);if(!c)throw new lr(4,t,a);return{red:parseInt(""+c[1],10),green:parseInt(""+c[2],10),blue:parseInt(""+c[3],10)}}var l=smt.exec(t.substring(0,50));if(l){var u="rgb("+zd(parseInt(""+l[1],10),parseInt(""+l[2],10)/100,parseInt(""+l[3],10)/100)+")",h=N5.exec(u);if(!h)throw new lr(4,t,u);return{red:parseInt(""+h[1],10),green:parseInt(""+h[2],10),blue:parseInt(""+h[3],10),alpha:parseFloat(""+l[4])>1?parseFloat(""+l[4])/100:parseFloat(""+l[4])}}throw new lr(5)}function Oa(e){return(function(t){var n,i=t.red/255,r=t.green/255,o=t.blue/255,s=Math.max(i,r,o),a=Math.min(i,r,o),c=(s+a)/2;if(s===a)return t.alpha!==void 0?{hue:0,saturation:0,lightness:c,alpha:t.alpha}:{hue:0,saturation:0,lightness:c};var l=s-a,u=c>.5?l/(2-s-a):l/(s+a);switch(s){case i:n=(r-o)/l+(r<o?6:0);break;case r:n=(o-i)/l+2;break;default:n=(i-r)/l+4}return n*=60,t.alpha!==void 0?{hue:n,saturation:u,lightness:c,alpha:t.alpha}:{hue:n,saturation:u,lightness:c}})(xp(e))}var X5=function(e){return e.length===7&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e};function pl(e){var t=e.toString(16);return t.length===1?"0"+t:t}function R5(e){return pl(Math.round(255*e))}function amt(e,t,n){return X5("#"+R5(e)+R5(t)+R5(n))}function ug(e,t,n){return zd(e,t,n,amt)}function V5(e,t,n){if(typeof e=="number"&&typeof t=="number"&&typeof n=="number")return X5("#"+pl(e)+pl(t)+pl(n));if(typeof e=="object"&&t===void 0&&n===void 0)return X5("#"+pl(e.red)+pl(e.green)+pl(e.blue));throw new lr(6)}function Ag(e,t,n,i){if(typeof e=="string"&&typeof t=="number"){var r=xp(e);return"rgba("+r.red+","+r.green+","+r.blue+","+t+")"}if(typeof e=="number"&&typeof t=="number"&&typeof n=="number"&&typeof i=="number")return i>=1?V5(e,t,n):"rgba("+e+","+t+","+n+","+i+")";if(typeof e=="object"&&t===void 0&&n===void 0&&i===void 0)return e.alpha>=1?V5(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new lr(7)}function La(e){if(typeof e!="object")throw new lr(8);if((function(t){return typeof t.red=="number"&&typeof t.green=="number"&&typeof t.blue=="number"&&typeof t.alpha=="number"})(e))return Ag(e);if((function(t){return typeof t.red=="number"&&typeof t.green=="number"&&typeof t.blue=="number"&&(typeof t.alpha!="number"||t.alpha===void 0)})(e))return V5(e);if((function(t){return typeof t.hue=="number"&&typeof t.saturation=="number"&&typeof t.lightness=="number"&&typeof t.alpha=="number"})(e))return(function(t,n,i,r){if(typeof t=="number"&&typeof n=="number"&&typeof i=="number"&&typeof r=="number")return r>=1?ug(t,n,i):"rgba("+zd(t,n,i)+","+r+")";if(typeof t=="object"&&n===void 0&&i===void 0&&r===void 0)return t.alpha>=1?ug(t.hue,t.saturation,t.lightness):"rgba("+zd(t.hue,t.saturation,t.lightness)+","+t.alpha+")";throw new lr(2)})(e);if((function(t){return typeof t.hue=="number"&&typeof t.saturation=="number"&&typeof t.lightness=="number"&&(typeof t.alpha!="number"||t.alpha===void 0)})(e))return(function(t,n,i){if(typeof t=="number"&&typeof n=="number"&&typeof i=="number")return ug(t,n,i);if(typeof t=="object"&&n===void 0&&i===void 0)return ug(t.hue,t.saturation,t.lightness);throw new lr(1)})(e);throw new lr(8)}function yz(e,t,n){return function(){var i=n.concat(Array.prototype.slice.call(arguments));return i.length>=t?e.apply(this,i):yz(e,t,i)}}function Tr(e){return yz(e,e.length,[])}Tr(function(e,t){if(t==="transparent")return t;var n=Oa(t);return La(ur({},n,{hue:n.hue+parseFloat(e)}))});function vp(e,t,n){return Math.max(e,Math.min(t,n))}Tr(function(e,t){if(t==="transparent")return t;var n=Oa(t);return La(ur({},n,{lightness:vp(0,1,n.lightness-parseFloat(e))}))});Tr(function(e,t){if(t==="transparent")return t;var n=Oa(t);return La(ur({},n,{saturation:vp(0,1,n.saturation-parseFloat(e))}))});Tr(function(e,t){if(t==="transparent")return t;var n=Oa(t);return La(ur({},n,{lightness:vp(0,1,n.lightness+parseFloat(e))}))});var gz=Tr(function(e,t,n){if(t==="transparent")return n;if(n==="transparent")return t;if(e===0)return n;var i=xp(t),r=ur({},i,{alpha:typeof i.alpha=="number"?i.alpha:1}),o=xp(n),s=ur({},o,{alpha:typeof o.alpha=="number"?o.alpha:1}),a=r.alpha-s.alpha,c=2*parseFloat(e)-1,l=((c*a===-1?c:c+a)/(1+c*a)+1)/2,u=1-l;return Ag({red:Math.floor(r.red*l+s.red*u),green:Math.floor(r.green*l+s.green*u),blue:Math.floor(r.blue*l+s.blue*u),alpha:r.alpha*parseFloat(e)+s.alpha*(1-parseFloat(e))})});Tr(function(e,t){if(t==="transparent")return t;var n=xp(t);return Ag(ur({},n,{alpha:vp(0,1,(100*(typeof n.alpha=="number"?n.alpha:1)+100*parseFloat(e))/100)}))});Tr(function(e,t){if(t==="transparent")return t;var n=Oa(t);return La(ur({},n,{saturation:vp(0,1,n.saturation+parseFloat(e))}))});Tr(function(e,t){return t==="transparent"?t:La(ur({},Oa(t),{hue:parseFloat(e)}))});Tr(function(e,t){return t==="transparent"?t:La(ur({},Oa(t),{lightness:parseFloat(e)}))});Tr(function(e,t){return t==="transparent"?t:La(ur({},Oa(t),{saturation:parseFloat(e)}))});Tr(function(e,t){return t==="transparent"?t:gz(parseFloat(e),"rgb(0, 0, 0)",t)});Tr(function(e,t){return t==="transparent"?t:gz(parseFloat(e),"rgb(255, 255, 255)",t)});var cmt=Tr(function(e,t){if(t==="transparent")return t;var n=xp(t);return Ag(ur({},n,{alpha:vp(0,1,+(100*(typeof n.alpha=="number"?n.alpha:1)-100*parseFloat(e)).toFixed(2)/100)}))}),VF=["blue","orange","purple","cyan","magenta","yellowgreen","darkgoldenrod","deeppink"],H5=(e,t)=>{let n={};for(let i=0;i<e.connections.length;i++){let r=e.connections[i],o=t?.getNetConnectedToId(r.name);o&&!n[o]&&(n[o]=`hsl(${300*i/e.connections.length}, 100%, 50%)`),n[r.name]=(o?n[o]:null)??`hsl(${340*i/e.connections.length}, 100%, 50%)`}return n},Dn=(e,t)=>{try{return cmt(t,e)}catch(n){return console.error(n),e}},Dd=(e,t)=>e==="top"?0:e==="bottom"?t-1:parseInt(e.slice(5)),Ro=(e,t=1)=>{let n=(("width"in e?e.width:e)/.5/2)**1.1*t;return e.availableZ?.length===1&&n>1?1:n},lmt=(e,t=.5,n=16)=>{let i=0,r=e;for(;i<n&&!(Ro({width:r})<=t);)r/=2,i++;return Math.max(1,i)};function xz(e,t,n=0,i=e.length-1,r=umt){for(;i>n;){if(i-n>600){let c=i-n+1,l=t-n+1,u=Math.log(c),h=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*h*(c-h)/c)*(l-c/2<0?-1:1);xz(e,t,Math.max(n,Math.floor(t-l*h/c+f)),Math.min(i,Math.floor(t+(c-l)*h/c+f)),r)}let o=e[t],s=n,a=i;for(kd(e,n,t),r(e[i],o)>0&&kd(e,n,i);s<a;){for(kd(e,s,a),s++,a--;r(e[s],o)<0;)s++;for(;r(e[a],o)>0;)a--}r(e[n],o)===0?kd(e,n,a):(a++,kd(e,a,i)),a<=t&&(n=a+1),t<=a&&(i=a-1)}}function kd(e,t,n){let i=e[t];e[t]=e[n],e[n]=i}function umt(e,t){return e<t?-1:e>t?1:0}var pmt=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data,n=[];if(!hg(e,t))return n;let i=this.toBBox,r=[];for(;t;){for(let o=0;o<t.children.length;o++){let s=t.children[o],a=t.leaf?i(s):s;hg(e,a)&&(t.leaf?n.push(s):L5(e,a)?this._all(s,n):r.push(s))}t=r.pop()}return n}collides(e){let t=this.data;if(!hg(e,t))return!1;let n=[];for(;t;){for(let i=0;i<t.children.length;i++){let r=t.children[i],o=t.leaf?this.toBBox(r):r;if(hg(e,o)){if(t.leaf||L5(e,o))return!0;n.push(r)}}t=n.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let n=0;n<e.length;n++)this.insert(e[n]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){let n=this.data;this.data=t,t=n}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=_p([]),this}remove(e,t){if(!e)return this;let n=this.data,i=this.toBBox(e),r=[],o=[],s,a,c;for(;n||r.length;){if(n||(n=r.pop(),a=r[r.length-1],s=o.pop(),c=!0),n.leaf){let l=hmt(e,n.children,t);if(l!==-1)return n.children.splice(l,1),r.push(n),this._condense(r),this}c||n.leaf||!L5(n,i)?a?(s++,n=a.children[s],c=!1):n=null:(r.push(n),o.push(s),s=0,a=n,n=n.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){let n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,i){let r=n-t+1,o,s=this._maxEntries;if(r<=s)return o=_p(e.slice(t,n+1)),mp(o,this.toBBox),o;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),o=_p([]),o.leaf=!1,o.height=i;let a=Math.ceil(r/s),c=a*Math.ceil(Math.sqrt(s));HF(e,t,n,c,this.compareMinX);for(let l=t;l<=n;l+=c){let u=Math.min(l+c-1,n);HF(e,l,u,a,this.compareMinY);for(let h=l;h<=u;h+=a){let f=Math.min(h+a-1,u);o.children.push(this._build(e,h,f,i-1))}}return mp(o,this.toBBox),o}_chooseSubtree(e,t,n,i){for(;i.push(t),!t.leaf&&i.length-1!==n;){let r,o=1/0,s=1/0;for(let a=0;a<t.children.length;a++){let c=t.children[a],l=O5(c),u=mmt(e,c)-l;u<s?(s=u,o=l<o?l:o,r=c):u===s&&l<o&&(o=l,r=c)}t=r||t.children[0]}return t}_insert(e,t,n){let i=n?e:this.toBBox(e),r=[],o=this._chooseSubtree(i,this.data,t,r);for(o.children.push(e),Nd(o,i);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(i,r,t)}_split(e,t){let n=e[t],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);let o=this._chooseSplitIndex(n,r,i),s=_p(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,mp(n,this.toBBox),mp(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(n,s)}_splitRoot(e,t){this.data=_p([e,t]),this.data.height=e.height+1,this.data.leaf=!1,mp(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let i,r=1/0,o=1/0;for(let s=t;s<=n-t;s++){let a=Ad(e,0,s,this.toBBox),c=Ad(e,s,n,this.toBBox),l=_mt(a,c),u=O5(a)+O5(c);l<r?(r=l,i=s,o=u<o?u:o):l===r&&u<o&&(o=u,i=s)}return i||n-t}_chooseSplitAxis(e,t,n){let i=e.leaf?this.compareMinX:dmt,r=e.leaf?this.compareMinY:fmt;this._allDistMargin(e,t,n,i)<this._allDistMargin(e,t,n,r)&&e.children.sort(i)}_allDistMargin(e,t,n,i){e.children.sort(i);let r=this.toBBox,o=Ad(e,0,t,r),s=Ad(e,n-t,n,r),a=pg(o)+pg(s);for(let c=t;c<n-t;c++){let l=e.children[c];Nd(o,e.leaf?r(l):l),a+=pg(o)}for(let c=n-t-1;c>=t;c--){let l=e.children[c];Nd(s,e.leaf?r(l):l),a+=pg(s)}return a}_adjustParentBBoxes(e,t,n){for(let i=n;i>=0;i--)Nd(t[i],e)}_condense(e){for(let t,n=e.length-1;n>=0;n--)e[n].children.length===0?n>0?(t=e[n-1].children,t.splice(t.indexOf(e[n]),1)):this.clear():mp(e[n],this.toBBox)}};function hmt(e,t,n){if(!n)return t.indexOf(e);for(let i=0;i<t.length;i++)if(n(e,t[i]))return i;return-1}function mp(e,t){Ad(e,0,e.children.length,t,e)}function Ad(e,t,n,i,r){r||(r=_p(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let o=t;o<n;o++){let s=e.children[o];Nd(r,e.leaf?i(s):s)}return r}function Nd(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function dmt(e,t){return e.minX-t.minX}function fmt(e,t){return e.minY-t.minY}function O5(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function pg(e){return e.maxX-e.minX+(e.maxY-e.minY)}function mmt(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function _mt(e,t){let n=Math.max(e.minX,t.minX),i=Math.max(e.minY,t.minY),r=Math.min(e.maxX,t.maxX),o=Math.min(e.maxY,t.maxY);return Math.max(0,r-n)*Math.max(0,o-i)}function L5(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function hg(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function _p(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function HF(e,t,n,i,r){let o=[t,n];for(;o.length;){if((n=o.pop())-(t=o.pop())<=i)continue;let s=t+Math.ceil((n-t)/i/2)*i;xz(e,s,t,n,r),o.push(t,s,s,n)}}var GF=class{constructor(e=9){T(this,"tree");this.tree=new pmt(e)}insert(e,t,n,i,r){this.tree.insert({minX:t,minY:n,maxX:i,maxY:r,data:e})}bulkLoad(e){let t=e.map(({item:n,minX:i,minY:r,maxX:o,maxY:s})=>({minX:i,minY:r,maxX:o,maxY:s,data:n}));this.tree.load(t)}search(e,t,n,i){return this.tree.search({minX:e,minY:t,maxX:n,maxY:i}).map(r=>r.data)}clear(){this.tree.clear()}},ymt=class{constructor(){this.ids=[],this.values=[],this.length=0}clear(){this.length=0}push(e,t){let n=this.length++;for(;n>0;){let i=n-1>>1,r=this.values[i];if(t>=r)break;this.ids[n]=this.ids[i],this.values[n]=r,n=i}this.ids[n]=e,this.values[n]=t}pop(){if(this.length===0)return;let e=this.ids[0];if(this.length--,this.length>0){let t=this.ids[0]=this.ids[this.length],n=this.values[0]=this.values[this.length],i=this.length>>1,r=0;for(;r<i;){let o=1+(r<<1),s=o+1,a=this.ids[o],c=this.values[o],l=this.values[s];if(s<this.length&&l<c&&(o=s,a=this.ids[s],c=l),c>=n)break;this.ids[r]=a,this.values[r]=c,r=o}this.ids[r]=t,this.values[r]=n}return e}peek(){if(this.length!==0)return this.ids[0]}peekValue(){if(this.length!==0)return this.values[0]}shrink(){this.ids.length=this.values.length=this.length}},UF=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],qF=class bz{static from(t,n=0){if(n%8!=0)throw new Error("byteOffset must be 8-byte aligned.");if(!t||t.byteLength===void 0||t.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[i,r]=new Uint8Array(t,n+0,2);if(i!==251)throw new Error("Data does not appear to be in a Flatbush format.");let o=r>>4;if(o!==3)throw new Error(`Got v${o} data when expected v3.`);let s=UF[15&r];if(!s)throw new Error("Unrecognized array type.");let[a]=new Uint16Array(t,n+2,1),[c]=new Uint32Array(t,n+4,1);return new bz(c,a,s,void 0,t,n)}constructor(t,n=16,i=Float64Array,r=ArrayBuffer,o,s=0){if(t===void 0)throw new Error("Missing required argument: numItems.");if(isNaN(t)||t<=0)throw new Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.byteOffset=s;let a=t,c=a;this._levelBounds=[4*a];do a=Math.ceil(a/this.nodeSize),c+=a,this._levelBounds.push(4*c);while(a!==1);this.ArrayType=i,this.IndexArrayType=c<16384?Uint16Array:Uint32Array;let l=UF.indexOf(this.ArrayType),u=4*c*this.ArrayType.BYTES_PER_ELEMENT;if(l<0)throw new Error(`Unexpected typed array class: ${i}.`);o&&o.byteLength!==void 0&&!o.buffer?(this.data=o,this._boxes=new this.ArrayType(this.data,s+8,4*c),this._indices=new this.IndexArrayType(this.data,s+8+u,c),this._pos=4*c,this.minX=this._boxes[this._pos-4],this.minY=this._boxes[this._pos-3],this.maxX=this._boxes[this._pos-2],this.maxY=this._boxes[this._pos-1]):(this.data=new r(8+u+c*this.IndexArrayType.BYTES_PER_ELEMENT),this._boxes=new this.ArrayType(this.data,8,4*c),this._indices=new this.IndexArrayType(this.data,8+u,c),this._pos=0,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,new Uint8Array(this.data,0,2).set([251,48+l]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t),this._queue=new ymt}add(t,n,i=t,r=n){let o=this._pos>>2,s=this._boxes;return this._indices[o]=o,s[this._pos++]=t,s[this._pos++]=n,s[this._pos++]=i,s[this._pos++]=r,t<this.minX&&(this.minX=t),n<this.minY&&(this.minY=n),i>this.maxX&&(this.maxX=i),r>this.maxY&&(this.maxY=r),o}finish(){if(this._pos>>2!==this.numItems)throw new Error(`Added ${this._pos>>2} items when expected ${this.numItems}.`);let t=this._boxes;if(this.numItems<=this.nodeSize)return t[this._pos++]=this.minX,t[this._pos++]=this.minY,t[this._pos++]=this.maxX,void(t[this._pos++]=this.maxY);let n=this.maxX-this.minX||1,i=this.maxY-this.minY||1,r=new Uint32Array(this.numItems);for(let o=0,s=0;o<this.numItems;o++){let a=t[s++],c=t[s++],l=t[s++],u=t[s++],h=Math.floor(65535*((a+l)/2-this.minX)/n),f=Math.floor(65535*((c+u)/2-this.minY)/i);r[o]=xmt(h,f)}G5(r,t,this._indices,0,this.numItems-1,this.nodeSize);for(let o=0,s=0;o<this._levelBounds.length-1;o++){let a=this._levelBounds[o];for(;s<a;){let c=s,l=t[s++],u=t[s++],h=t[s++],f=t[s++];for(let _=1;_<this.nodeSize&&s<a;_++)l=Math.min(l,t[s++]),u=Math.min(u,t[s++]),h=Math.max(h,t[s++]),f=Math.max(f,t[s++]);this._indices[this._pos>>2]=c,t[this._pos++]=l,t[this._pos++]=u,t[this._pos++]=h,t[this._pos++]=f}}}search(t,n,i,r,o){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let s=this._boxes.length-4,a=[],c=[];for(;s!==void 0;){let l=Math.min(s+4*this.nodeSize,ZF(s,this._levelBounds));for(let u=s;u<l;u+=4){if(i<this._boxes[u]||r<this._boxes[u+1]||t>this._boxes[u+2]||n>this._boxes[u+3])continue;let h=0|this._indices[u>>2];s>=4*this.numItems?a.push(h):(o===void 0||o(h))&&c.push(h)}s=a.pop()}return c}neighbors(t,n,i=1/0,r=1/0,o){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let s=this._boxes.length-4,a=this._queue,c=[],l=r*r;t:for(;s!==void 0;){let u=Math.min(s+4*this.nodeSize,ZF(s,this._levelBounds));for(let h=s;h<u;h+=4){let f=0|this._indices[h>>2],_=WF(t,this._boxes[h],this._boxes[h+2]),y=WF(n,this._boxes[h+1],this._boxes[h+3]),x=_*_+y*y;x>l||(s>=4*this.numItems?a.push(f<<1,x):(o===void 0||o(f))&&a.push(1+(f<<1),x))}for(;a.length&&1&a.peek();)if(a.peekValue()>l||(c.push(a.pop()>>1),c.length===i))break t;s=a.length?a.pop()>>1:void 0}return a.clear(),c}};function WF(e,t,n){return e<t?t-e:e<=n?0:e-n}function ZF(e,t){let n=0,i=t.length-1;for(;n<i;){let r=n+i>>1;t[r]>e?i=r:n=r+1}return t[n]}function G5(e,t,n,i,r,o){if(Math.floor(i/o)>=Math.floor(r/o))return;let s=e[i+r>>1],a=i-1,c=r+1;for(;;){do a++;while(e[a]<s);do c--;while(e[c]>s);if(a>=c)break;gmt(e,t,n,a,c)}G5(e,t,n,i,c,o),G5(e,t,n,c+1,r,o)}function gmt(e,t,n,i,r){let o=e[i];e[i]=e[r],e[r]=o;let s=4*i,a=4*r,c=t[s],l=t[s+1],u=t[s+2],h=t[s+3];t[s]=t[a],t[s+1]=t[a+1],t[s+2]=t[a+2],t[s+3]=t[a+3],t[a]=c,t[a+1]=l,t[a+2]=u,t[a+3]=h;let f=n[i];n[i]=n[r],n[r]=f}function xmt(e,t){let n=e^t,i=65535^n,r=65535^(e|t),o=e&(65535^t),s=n|i>>1,a=n>>1^n,c=r>>1^i&o>>1^r,l=n&r>>1^o>>1^o;n=s,i=a,r=c,o=l,s=n&n>>2^i&i>>2,a=n&i>>2^i&(n^i)>>2,c^=n&r>>2^i&o>>2,l^=i&r>>2^(n^i)&o>>2,n=s,i=a,r=c,o=l,s=n&n>>4^i&i>>4,a=n&i>>4^i&(n^i)>>4,c^=n&r>>4^i&o>>4,l^=i&r>>4^(n^i)&o>>4,n=s,i=a,r=c,o=l,c^=n&r>>8^i&o>>8,l^=i&r>>8^(n^i)&o>>8,n=c^c>>1,i=l^l>>1;let u=e^t,h=i|65535^(u|n);return u=16711935&(u|u<<8),u=252645135&(u|u<<4),u=858993459&(u|u<<2),u=1431655765&(u|u<<1),h=16711935&(h|h<<8),h=252645135&(h|h<<4),h=858993459&(h|h<<2),h=1431655765&(h|h<<1),(h<<1|u)>>>0}var bmt=class{constructor(e){T(this,"index");T(this,"items",[]);T(this,"currentIndex",0);T(this,"capacity");this.capacity=Math.max(1,e),this.index=new qF(this.capacity)}insert(e,t,n,i,r){if(this.currentIndex>=this.index.numItems)throw new Error("Exceeded initial capacity");this.items[this.currentIndex]=e,this.index.add(t,n,i,r),this.currentIndex++}finish(){this.index.finish()}search(e,t,n,i){return this.index.search(e,t,n,i).map(r=>this.items[r]||null).filter(Boolean)}clear(){this.items=[],this.currentIndex=0,this.index=new qF(this.capacity)}},vz=class{constructor(e="native",t=[]){T(this,"idx");T(this,"storage",[]);e==="flatbush"?t.length===0?(this.idx=new GF,e="rbush"):this.idx=new bmt(t.length):this.idx=e==="rbush"?new GF:new class{constructor(){T(this,"shi",new vmt(t))}insert(n){}search(n,i,r,o){let s=(n+r)/2,a=(i+o)/2,c=r-n,l=o-i;return this.shi.getNodesInArea(s,a,c,l)}clear(){}},t.forEach(n=>this.insert(n)),e==="flatbush"&&t.length>0&&this.idx.finish?.()}insert(e){this.storage.push(e),this.idx.insert(e,e.center.x-e.width/2,e.center.y-e.height/2,e.center.x+e.width/2,e.center.y+e.height/2)}search(e){return this.idx.search(e.minX,e.minY,e.maxX,e.maxY)}searchArea(e,t,n,i){return this.search({minX:e-n/2,minY:t-i/2,maxX:e+n/2,maxY:t+i/2})}},vmt=class{constructor(e){T(this,"buckets");T(this,"CELL_SIZE",.4);this.obstacles=e,this.buckets=new Map;for(let t=0;t<e.length;t++){let n=e[t],i=n.center.x-n.width/2,r=n.center.y-n.height/2,o=n.center.x+n.width/2,s=n.center.y+n.height/2;for(let a=i;a<=o;a+=this.CELL_SIZE)for(let c=r;c<=s;c+=this.CELL_SIZE){let l=this.getBucketKey(a,c),u=this.buckets.get(l);u?u.push([n,t]):this.buckets.set(l,[[n,t]])}}}getBucketKey(e,t){return`${Math.floor(e/this.CELL_SIZE)}x${Math.floor(t/this.CELL_SIZE)}`}getNodesInArea(e,t,n,i){let r=[],o=new Set,s=t-i/2,a=e+n/2,c=t+i/2;for(let l=e-n/2;l<=a;l+=this.CELL_SIZE)for(let u=s;u<=c;u+=this.CELL_SIZE){let h=this.getBucketKey(l,u),f=this.buckets.get(h)||[];for(let _ of f)o.has(_[1])||(o.add(_[1]),r.push(_[0]))}return r}},wmt=class{constructor(e){T(this,"buckets");T(this,"CELL_SIZE",5);this.targets=e,this.buckets=new Map;for(let t=0;t<e.length;t++){let n=e[t],i=Math.floor(n.bounds.minX/this.CELL_SIZE)*this.CELL_SIZE,r=Math.floor(n.bounds.minY/this.CELL_SIZE)*this.CELL_SIZE,o=n.bounds.maxX,s=n.bounds.maxY;for(let a=i;a<=o;a+=this.CELL_SIZE)for(let c=r;c<=s;c+=this.CELL_SIZE){let l=this.getBucketKey(a,c),u=this.buckets.get(l);u?u.push([n,t]):this.buckets.set(l,[[n,t]])}}}getBucketKey(e,t){return`${Math.floor(e/this.CELL_SIZE)}x${Math.floor(t/this.CELL_SIZE)}`}getTargetsInArea(e,t,n,i){let r=[],o=new Set,s=Math.floor((e-n/2)/this.CELL_SIZE)*this.CELL_SIZE,a=Math.floor((t-i/2)/this.CELL_SIZE)*this.CELL_SIZE,c=e+n/2,l=t+i/2;for(let u=s;u<=c;u+=this.CELL_SIZE)for(let h=a;h<=l;h+=this.CELL_SIZE){let f=this.getBucketKey(u,h),_=this.buckets.get(f)||[];for(let y of _)o.has(y[1])||(o.add(y[1]),r.push(y[0]))}return r}},Smt=class extends an{constructor(t,n={}){super();T(this,"unfinishedNodes");T(this,"finishedNodes");T(this,"nodeToXYOverlappingObstaclesMap");T(this,"layerCount");T(this,"MAX_DEPTH",4);T(this,"targets");T(this,"targetTree");T(this,"obstacleTree");T(this,"_nextNodeCounter",0);this.srj=t,this.opts=n,this.MAX_DEPTH=n?.capacityDepth??this.MAX_DEPTH,this.MAX_ITERATIONS=1e5,this.layerCount=t.layerCount??2;for(let s of t.obstacles)if(!s.zLayers){let a=[];for(let c of s.layers)a.push(Dd(c,t.layerCount));s.zLayers=a}let i={x:(t.bounds.minX+t.bounds.maxX)/2,y:(t.bounds.minY+t.bounds.maxY)/2},r={width:t.bounds.maxX-t.bounds.minX,height:t.bounds.maxY-t.bounds.minY},o=Math.max(r.width,r.height);this.unfinishedNodes=[{capacityMeshNodeId:this.getNextNodeId(),center:i,width:o,height:o,layer:"top",availableZ:[0,1],_depth:0,_containsTarget:!0,_containsObstacle:!0,_completelyInsideObstacle:!1}],this.finishedNodes=[],this.nodeToXYOverlappingObstaclesMap=new Map,this.obstacleTree=new vz("flatbush",this.srj.obstacles),this.targets=this.computeTargets(),this.targetTree=new wmt(this.targets)}computeTargets(){let t=[];for(let n of this.srj.connections)for(let i of n.pointsToConnect){let r=this.obstacleTree.searchArea(i.x,i.y,.01,.01).filter(a=>a.zLayers.some(c=>i.layer==="top"?c===0:c===1)),o={minX:i.x-.005,minY:i.y-.005,maxX:i.x+.005,maxY:i.y+.005};r.length>0&&(o={minX:Math.min(...r.map(a=>a.center.x-a.width/2)),minY:Math.min(...r.map(a=>a.center.y-a.height/2)),maxX:Math.max(...r.map(a=>a.center.x+a.width/2)),maxY:Math.max(...r.map(a=>a.center.y+a.height/2))});let s={...i,connectionName:n.name,availableZ:i.layer==="top"?[0]:[1],bounds:o};t.push(s)}return t}getNextNodeId(){return"cn"+this._nextNodeCounter++}getCapacityFromDepth(t){return(this.MAX_DEPTH-t+1)**2}getTargetIfNodeContainsTarget(t){let n=t.width>4*this.targetTree.CELL_SIZE?this.targets:this.targetTree.getTargetsInArea(t.center.x,t.center.y,t.width,t.height);for(let i of n)if(i.bounds.minX<=t.center.x+t.width/2&&i.bounds.maxX>=t.center.x-t.width/2&&i.bounds.minY<=t.center.y+t.height/2&&i.bounds.maxY>=t.center.y-t.height/2&&i.availableZ.some(r=>t.availableZ.includes(r)))return i;return null}getXYOverlappingObstacles(t){let n=this.nodeToXYOverlappingObstaclesMap.get(t.capacityMeshNodeId);if(n)return n;let i=[],r=t.center.x-t.width/2,o=t.center.x+t.width/2,s=t.center.y-t.height/2,a=t.center.y+t.height/2,c=t._parent?this.getXYOverlappingObstacles(t._parent):this.srj.obstacles;for(let l of c){let u=l.center.x-l.width/2,h=l.center.x+l.width/2,f=l.center.y-l.height/2,_=l.center.y+l.height/2;(o>=u&&r<=h&&a>=f&&s<=_||r>=u&&o<=h&&s>=f&&a<=_||u>=r&&h<=o&&f>=s&&_<=a)&&i.push(l)}return this.nodeToXYOverlappingObstaclesMap.set(t.capacityMeshNodeId,i),i}getXYZOverlappingObstacles(t){let n=this.getXYOverlappingObstacles(t),i=[];for(let r of n)t.availableZ.some(o=>r.zLayers.includes(o))&&i.push(r);return i}doesNodeOverlapObstacle(t){if(this.getXYZOverlappingObstacles(t).length>0)return!0;let n=t.center.x-t.width/2,i=t.center.x+t.width/2,r=t.center.y-t.height/2,o=t.center.y+t.height/2;return n<this.srj.bounds.minX||i>this.srj.bounds.maxX||r<this.srj.bounds.minY||o>this.srj.bounds.maxY}isNodeCompletelyInsideObstacle(t){let n=this.getXYZOverlappingObstacles(t),i=t.center.x-t.width/2,r=t.center.x+t.width/2,o=t.center.y-t.height/2,s=t.center.y+t.height/2;for(let a of n){let c=a.center.x-a.width/2,l=a.center.x+a.width/2,u=a.center.y-a.height/2,h=a.center.y+a.height/2;if(i>=c&&r<=l&&o>=u&&s<=h)return!0}return!1}getChildNodes(t){if(t._depth===this.MAX_DEPTH)return[];let n=[],i={width:t.width/2,height:t.height/2},r=[{x:t.center.x-i.width/2,y:t.center.y-i.height/2},{x:t.center.x+i.width/2,y:t.center.y-i.height/2},{x:t.center.x-i.width/2,y:t.center.y+i.height/2},{x:t.center.x+i.width/2,y:t.center.y+i.height/2}];for(let o of r){let s={capacityMeshNodeId:this.getNextNodeId(),center:o,width:i.width,height:i.height,layer:t.layer,availableZ:[0,1],_depth:(t._depth??0)+1,_parent:t};s._containsObstacle=this.doesNodeOverlapObstacle(s);let a=this.getTargetIfNodeContainsTarget(s);a&&(s._targetConnectionName=a.connectionName,s.availableZ=a.availableZ,s._containsTarget=!0),s._containsObstacle&&(s._completelyInsideObstacle=this.isNodeCompletelyInsideObstacle(s)),s._completelyInsideObstacle&&!s._containsTarget||n.push(s)}return n}shouldNodeBeXYSubdivided(t){return!(t._depth>=this.MAX_DEPTH)&&(!!t._containsTarget||!(!t._containsObstacle||t._completelyInsideObstacle))}_step(){let t=this.unfinishedNodes.pop();if(!t)return void(this.solved=!0);let n=this.getChildNodes(t),i=[],r=[];for(let o of n){let s=this.shouldNodeBeXYSubdivided(o);s?r.push(o):s||o._containsObstacle?!s&&o._containsTarget&&i.push(o):i.push(o)}this.unfinishedNodes.push(...r),this.finishedNodes.push(...i)}visualize(){let t={lines:[],points:[],rects:[],circles:[],coordinateSystem:"cartesian",title:"Capacity Mesh Visualization"};for(let i of this.srj.obstacles)t.rects.push({center:i.center,width:i.width,height:i.height,fill:i.zLayers?.length===1&&i.zLayers?.includes(1)?"rgba(0,0,255,0.3)":"rgba(255,0,0,0.3)",stroke:"red",label:["obstacle",`z: ${i.zLayers.join(",")}`].join(`
147
147
  `)});let n=[...this.finishedNodes,...this.unfinishedNodes];for(let i of n){let r=Math.min(...i.availableZ),o=this.unfinishedNodes.length>0&&i===this.unfinishedNodes[this.unfinishedNodes.length-1];t.rects.push({center:{x:i.center.x+r*i.width*.05,y:i.center.y-r*i.width*.05},width:Math.max(i.width-2,.8*i.width),height:Math.max(i.height-2,.8*i.height),fill:i._containsObstacle?"rgba(255,0,0,0.1)":{"0,1":"rgba(0,0,0,0.1)",0:"rgba(0,200,200, 0.1)",1:"rgba(0,0,200, 0.1)"}[i.availableZ.join(",")]??"rgba(0,200,200,0.1)",stroke:o?"rgba(255,165,0,0.5)":void 0,label:[i.capacityMeshNodeId,`availableZ: ${i.availableZ.join(",")}`,`target? ${i._containsTarget??!1}`,`obs? ${i._containsObstacle??!1}`,`${i.width.toFixed(2)}x${i.height.toFixed(2)}`,`capacity: ${Ro(i).toFixed(2)}`].join(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/eval",
3
3
  "main": "dist/lib/index.js",
4
- "version": "0.0.344",
4
+ "version": "0.0.346",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "bun run build:lib && bun run build:webworker && bun run build:blob-url && bun run build:runner && bun run build:worker-wrapper",