@tscircuit/cli 0.1.1480 → 0.1.1482

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.
package/dist/cli/main.js CHANGED
@@ -34587,7 +34587,7 @@ function compose7(...matrices) {
34587
34587
  function isUndefined2(val) {
34588
34588
  return typeof val === "undefined";
34589
34589
  }
34590
- function rotate9(angle, cx2, cy2) {
34590
+ function rotate10(angle, cx2, cy2) {
34591
34591
  const cosAngle = cos(angle);
34592
34592
  const sinAngle = sin(angle);
34593
34593
  const rotationMatrix = {
@@ -34608,7 +34608,7 @@ function rotate9(angle, cx2, cy2) {
34608
34608
  ]);
34609
34609
  }
34610
34610
  function rotateDEG(angle, cx2 = undefined, cy2 = undefined) {
34611
- return rotate9(angle * PI / 180, cx2, cy2);
34611
+ return rotate10(angle * PI / 180, cx2, cy2);
34612
34612
  }
34613
34613
  function scale5(sx2, sy2 = undefined, cx2 = undefined, cy2 = undefined) {
34614
34614
  if (isUndefined2(sy2))
@@ -34799,13 +34799,13 @@ function doSegmentsIntersect(p12, q12, p22, q22) {
34799
34799
  if (o12 !== o22 && o3 !== o4) {
34800
34800
  return true;
34801
34801
  }
34802
- if (o12 === 0 && onSegment(p12, p22, q12))
34802
+ if (o12 === 0 && onSegment2(p12, p22, q12))
34803
34803
  return true;
34804
- if (o22 === 0 && onSegment(p12, q22, q12))
34804
+ if (o22 === 0 && onSegment2(p12, q22, q12))
34805
34805
  return true;
34806
- if (o3 === 0 && onSegment(p22, p12, q22))
34806
+ if (o3 === 0 && onSegment2(p22, p12, q22))
34807
34807
  return true;
34808
- if (o4 === 0 && onSegment(p22, q12, q22))
34808
+ if (o4 === 0 && onSegment2(p22, q12, q22))
34809
34809
  return true;
34810
34810
  return false;
34811
34811
  }
@@ -34815,7 +34815,7 @@ function orientation(p, q3, r3) {
34815
34815
  return 0;
34816
34816
  return val > 0 ? 1 : 2;
34817
34817
  }
34818
- function onSegment(p, q3, r3) {
34818
+ function onSegment2(p, q3, r3) {
34819
34819
  return q3.x <= Math.max(p.x, r3.x) && q3.x >= Math.min(p.x, r3.x) && q3.y <= Math.max(p.y, r3.y) && q3.y >= Math.min(p.y, r3.y);
34820
34820
  }
34821
34821
  function segmentsDistance(a12, a2, b12, b22) {
@@ -39149,7 +39149,7 @@ var init_chunk_SK323GHE = __esm(() => {
39149
39149
  element: "element",
39150
39150
  text: "text"
39151
39151
  };
39152
- var createNode2 = function createNode22(params2) {
39152
+ var createNode3 = function createNode22(params2) {
39153
39153
  return Object.assign({
39154
39154
  name: "",
39155
39155
  type: NodeType.element,
@@ -39177,7 +39177,7 @@ var init_chunk_SK323GHE = __esm(() => {
39177
39177
  current2 = rootNode;
39178
39178
  current2.name = data.value;
39179
39179
  } else {
39180
- var node = createNode2({
39180
+ var node = createNode3({
39181
39181
  name: data.value,
39182
39182
  parent: current2
39183
39183
  });
@@ -39210,7 +39210,7 @@ var init_chunk_SK323GHE = __esm(() => {
39210
39210
  break;
39211
39211
  case Type.text:
39212
39212
  if (current2) {
39213
- current2.children.push(createNode2({
39213
+ current2.children.push(createNode3({
39214
39214
  type: NodeType.text,
39215
39215
  value: data.value,
39216
39216
  parent: options.parentNodes ? current2 : null
@@ -39229,7 +39229,7 @@ var init_chunk_SK323GHE = __esm(() => {
39229
39229
  reader.reset = function() {
39230
39230
  lexer = Lexer.create({ debug: options.debug });
39231
39231
  lexer.on("data", handleLexerData);
39232
- rootNode = createNode2();
39232
+ rootNode = createNode3();
39233
39233
  current2 = null;
39234
39234
  attrName = "";
39235
39235
  reader.parse = lexer.write;
@@ -47699,7 +47699,7 @@ function createSvgObjectsFromPcbFabricationNoteText(pcbFabNoteText, ctx) {
47699
47699
  dominantBaseline = "text-after-edge";
47700
47700
  break;
47701
47701
  }
47702
- const textTransform = compose7(translate7(transformedX, transformedY), rotate9(Math.PI / 180));
47702
+ const textTransform = compose7(translate7(transformedX, transformedY), rotate10(Math.PI / 180));
47703
47703
  const svgObject = {
47704
47704
  name: "text",
47705
47705
  type: "element",
@@ -49528,7 +49528,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
49528
49528
  const rectW = width + padLeft + padRight;
49529
49529
  const rectH = height + padTop + padBottom;
49530
49530
  const strokeWidth = scaledFontSize * 0.15;
49531
- const knockoutTransform = toString(compose7(translate7(transformedX, transformedY), rotate9(-ccw_rotation * Math.PI / 180), ...applyMirror ? [scale5(-1, 1)] : [], scale5(scaleFactor, scaleFactor)));
49531
+ const knockoutTransform = toString(compose7(translate7(transformedX, transformedY), rotate10(-ccw_rotation * Math.PI / 180), ...applyMirror ? [scale5(-1, 1)] : [], scale5(scaleFactor, scaleFactor)));
49532
49532
  const maskId = `silkscreen-knockout-mask-${pcbSilkscreenText.pcb_silkscreen_text_id}-${silkscreenMaskIdCounter++}`;
49533
49533
  return [
49534
49534
  {
@@ -49641,7 +49641,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
49641
49641
  dominantBaseline = "central";
49642
49642
  break;
49643
49643
  }
49644
- const textTransform = compose7(translate7(transformedX, transformedY), rotate9(-ccw_rotation * Math.PI / 180), ...layer === "bottom" ? [scale5(-1, 1)] : []);
49644
+ const textTransform = compose7(translate7(transformedX, transformedY), rotate10(-ccw_rotation * Math.PI / 180), ...layer === "bottom" ? [scale5(-1, 1)] : []);
49645
49645
  const lines = text.split(`
49646
49646
  `);
49647
49647
  const children = lines.length === 1 ? [
@@ -49883,7 +49883,7 @@ function createSvgObjectsFromPcbCopperText(pcbCopperText, ctx) {
49883
49883
  const rectW = width2 + padX * 2;
49884
49884
  const rectH = height2 + padY * 2;
49885
49885
  const strokeWidth2 = scaledFontSize2 * 0.15;
49886
- const knockoutTransform = toString(compose7(translate7(ax2, ay2), rotate9(-ccw_rotation * Math.PI / 180), ...applyMirror ? [scale5(-1, 1)] : [], scale5(scaleFactor, scaleFactor)));
49886
+ const knockoutTransform = toString(compose7(translate7(ax2, ay2), rotate10(-ccw_rotation * Math.PI / 180), ...applyMirror ? [scale5(-1, 1)] : [], scale5(scaleFactor, scaleFactor)));
49887
49887
  const maskId = `knockout-mask-${pcbCopperText.pcb_copper_text_id}-${maskIdCounter++}`;
49888
49888
  return [
49889
49889
  {
@@ -49985,7 +49985,7 @@ function createSvgObjectsFromPcbCopperText(pcbCopperText, ctx) {
49985
49985
  offsetY = -height / 2;
49986
49986
  break;
49987
49987
  }
49988
- const textTransform = toString(compose7(translate7(ax2, ay2), rotate9(-ccw_rotation * Math.PI / 180), ...applyMirror ? [scale5(-1, 1)] : [], translate7(offsetX, offsetY), scale5(scaleFactor, scaleFactor)));
49988
+ const textTransform = toString(compose7(translate7(ax2, ay2), rotate10(-ccw_rotation * Math.PI / 180), ...applyMirror ? [scale5(-1, 1)] : [], translate7(offsetX, offsetY), scale5(scaleFactor, scaleFactor)));
49989
49989
  const strokeWidth = scaledFontSize * 0.15;
49990
49990
  return [
49991
49991
  {
@@ -52056,7 +52056,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
52056
52056
  width: scaledWidth.toString(),
52057
52057
  height: scaledHeight.toString(),
52058
52058
  fill: colorMap2.drill,
52059
- transform: toString(compose7(translate7(cx2, cy2), rotate9(svgRotation * Math.PI / 180))),
52059
+ transform: toString(compose7(translate7(cx2, cy2), rotate10(svgRotation * Math.PI / 180))),
52060
52060
  "data-type": "pcb_cutout",
52061
52061
  "data-pcb-layer": "drill"
52062
52062
  };
@@ -52407,7 +52407,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
52407
52407
  y: (-scaledHeight / 2).toString(),
52408
52408
  width: scaledWidth.toString(),
52409
52409
  height: scaledHeight.toString(),
52410
- transform: toString(compose7(translate7(cx2, cy2), rotate9(svgRotation * Math.PI / 180)))
52410
+ transform: toString(compose7(translate7(cx2, cy2), rotate10(svgRotation * Math.PI / 180)))
52411
52411
  };
52412
52412
  const copperRect = {
52413
52413
  name: "rect",
@@ -55394,15 +55394,15 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
55394
55394
  stagger_rank = geometric_middle_index - dist_from_middle;
55395
55395
  }
55396
55396
  const stagger_offset = stagger_offset_base + stagger_rank * (STAGGER_OFFSET_STEP * styleScale * pxPerMm);
55397
- const sign = edge === "left" ? -1 : 1;
55397
+ const sign2 = edge === "left" ? -1 : 1;
55398
55398
  const is_main_group_pin = main_group_indices.includes(i);
55399
55399
  const y_pos = is_all_main_group ? edge_ports[i].y : main_group_indices.length > 0 && is_main_group_pin ? edge_ports[i].y : current_y;
55400
55400
  const elbow_end = {
55401
- x: board_edge_x + sign * stagger_offset,
55401
+ x: board_edge_x + sign2 * stagger_offset,
55402
55402
  y: y_pos
55403
55403
  };
55404
55404
  const label_pos = {
55405
- x: board_edge_x + sign * aligned_label_offset,
55405
+ x: board_edge_x + sign2 * aligned_label_offset,
55406
55406
  y: y_pos
55407
55407
  };
55408
55408
  label_positions.set(pcb_port2.pcb_port_id, {
@@ -58785,7 +58785,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58785
58785
  y: schNetLabel.center.y - realTextGrowthVec.y * fullWidthFsr * fontSizeMm / 2
58786
58786
  };
58787
58787
  const pathRotation = 0;
58788
- const rotationMatrix = rotate9(pathRotation / 180 * Math.PI);
58788
+ const rotationMatrix = rotate10(pathRotation / 180 * Math.PI);
58789
58789
  const symbolBounds = {
58790
58790
  minX: Math.min(...symbol.primitives.flatMap((p) => p.type === "path" ? p.points.map((pt2) => pt2.x) : [])),
58791
58791
  maxX: Math.max(...symbol.primitives.flatMap((p) => p.type === "path" ? p.points.map((pt2) => pt2.x) : [])),
@@ -58971,7 +58971,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58971
58971
  x: ARROW_POINT_WIDTH_FSR,
58972
58972
  y: -0.6
58973
58973
  }
58974
- ].map((fontRelativePoint) => applyToPoint23(compose7(realToScreenTransform, translate7(realAnchorPosition.x, realAnchorPosition.y), scale5(fontSizeMm), rotate9(pathRotation / 180 * Math.PI)), fontRelativePoint));
58974
+ ].map((fontRelativePoint) => applyToPoint23(compose7(realToScreenTransform, translate7(realAnchorPosition.x, realAnchorPosition.y), scale5(fontSizeMm), rotate10(pathRotation / 180 * Math.PI)), fontRelativePoint));
58975
58975
  const pathD = `
58976
58976
  M ${screenOutlinePoints[0].x},${screenOutlinePoints[0].y}
58977
58977
  L ${screenOutlinePoints[1].x},${screenOutlinePoints[1].y}
@@ -100763,7 +100763,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
100763
100763
  // lib/getVersion.ts
100764
100764
  import { createRequire as createRequire2 } from "node:module";
100765
100765
  // package.json
100766
- var version = "0.1.1479";
100766
+ var version = "0.1.1481";
100767
100767
  var package_default = {
100768
100768
  name: "@tscircuit/cli",
100769
100769
  version,
@@ -100801,7 +100801,7 @@ var package_default = {
100801
100801
  "circuit-json": "^0.0.425",
100802
100802
  "circuit-json-to-bom-csv": "^0.0.7",
100803
100803
  "circuit-json-to-gerber": "^0.0.51",
100804
- "circuit-json-to-kicad": "0.0.137",
100804
+ "circuit-json-to-kicad": "0.0.150",
100805
100805
  "circuit-json-to-pnp-csv": "^0.0.7",
100806
100806
  "circuit-json-to-readable-netlist": "^0.0.15",
100807
100807
  "circuit-json-to-spice": "^0.0.10",
@@ -104838,12 +104838,466 @@ import {
104838
104838
  import { KicadPcb as KicadPcb2 } from "kicadts";
104839
104839
  import { cju as cju2 } from "@tscircuit/circuit-json-util";
104840
104840
  import { compose as compose6, translate as translate6, scale as scale4 } from "transformation-matrix";
104841
+
104842
+ // node_modules/earcut/src/earcut.js
104843
+ function earcut(data, holeIndices, dim = 2) {
104844
+ const hasHoles = holeIndices && holeIndices.length;
104845
+ const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
104846
+ let outerNode = linkedList(data, 0, outerLen, dim, true);
104847
+ const triangles = [];
104848
+ if (!outerNode || outerNode.next === outerNode.prev)
104849
+ return triangles;
104850
+ let minX, minY, invSize;
104851
+ if (hasHoles)
104852
+ outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
104853
+ if (data.length > 80 * dim) {
104854
+ minX = data[0];
104855
+ minY = data[1];
104856
+ let maxX = minX;
104857
+ let maxY = minY;
104858
+ for (let i = dim;i < outerLen; i += dim) {
104859
+ const x = data[i];
104860
+ const y = data[i + 1];
104861
+ if (x < minX)
104862
+ minX = x;
104863
+ if (y < minY)
104864
+ minY = y;
104865
+ if (x > maxX)
104866
+ maxX = x;
104867
+ if (y > maxY)
104868
+ maxY = y;
104869
+ }
104870
+ invSize = Math.max(maxX - minX, maxY - minY);
104871
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
104872
+ }
104873
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
104874
+ return triangles;
104875
+ }
104876
+ function linkedList(data, start, end, dim, clockwise) {
104877
+ let last;
104878
+ if (clockwise === signedArea(data, start, end, dim) > 0) {
104879
+ for (let i = start;i < end; i += dim)
104880
+ last = insertNode(i / dim | 0, data[i], data[i + 1], last);
104881
+ } else {
104882
+ for (let i = end - dim;i >= start; i -= dim)
104883
+ last = insertNode(i / dim | 0, data[i], data[i + 1], last);
104884
+ }
104885
+ if (last && equals(last, last.next)) {
104886
+ removeNode(last);
104887
+ last = last.next;
104888
+ }
104889
+ return last;
104890
+ }
104891
+ function filterPoints(start, end) {
104892
+ if (!start)
104893
+ return start;
104894
+ if (!end)
104895
+ end = start;
104896
+ let p = start, again;
104897
+ do {
104898
+ again = false;
104899
+ if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
104900
+ removeNode(p);
104901
+ p = end = p.prev;
104902
+ if (p === p.next)
104903
+ break;
104904
+ again = true;
104905
+ } else {
104906
+ p = p.next;
104907
+ }
104908
+ } while (again || p !== end);
104909
+ return end;
104910
+ }
104911
+ function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
104912
+ if (!ear)
104913
+ return;
104914
+ if (!pass && invSize)
104915
+ indexCurve(ear, minX, minY, invSize);
104916
+ let stop2 = ear;
104917
+ while (ear.prev !== ear.next) {
104918
+ const prev = ear.prev;
104919
+ const next = ear.next;
104920
+ if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
104921
+ triangles.push(prev.i, ear.i, next.i);
104922
+ removeNode(ear);
104923
+ ear = next.next;
104924
+ stop2 = next.next;
104925
+ continue;
104926
+ }
104927
+ ear = next;
104928
+ if (ear === stop2) {
104929
+ if (!pass) {
104930
+ earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
104931
+ } else if (pass === 1) {
104932
+ ear = cureLocalIntersections(filterPoints(ear), triangles);
104933
+ earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
104934
+ } else if (pass === 2) {
104935
+ splitEarcut(ear, triangles, dim, minX, minY, invSize);
104936
+ }
104937
+ break;
104938
+ }
104939
+ }
104940
+ }
104941
+ function isEar(ear) {
104942
+ const a = ear.prev, b = ear, c = ear.next;
104943
+ if (area(a, b, c) >= 0)
104944
+ return false;
104945
+ const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
104946
+ const x0 = Math.min(ax, bx, cx), y0 = Math.min(ay, by, cy), x1 = Math.max(ax, bx, cx), y1 = Math.max(ay, by, cy);
104947
+ let p = c.next;
104948
+ while (p !== a) {
104949
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
104950
+ return false;
104951
+ p = p.next;
104952
+ }
104953
+ return true;
104954
+ }
104955
+ function isEarHashed(ear, minX, minY, invSize) {
104956
+ const a = ear.prev, b = ear, c = ear.next;
104957
+ if (area(a, b, c) >= 0)
104958
+ return false;
104959
+ const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
104960
+ const x0 = Math.min(ax, bx, cx), y0 = Math.min(ay, by, cy), x1 = Math.max(ax, bx, cx), y1 = Math.max(ay, by, cy);
104961
+ const minZ = zOrder(x0, y0, minX, minY, invSize), maxZ = zOrder(x1, y1, minX, minY, invSize);
104962
+ let { prevZ: p, nextZ: n } = ear;
104963
+ while (p && p.z >= minZ && n && n.z <= maxZ) {
104964
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
104965
+ return false;
104966
+ p = p.prevZ;
104967
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
104968
+ return false;
104969
+ n = n.nextZ;
104970
+ }
104971
+ while (p && p.z >= minZ) {
104972
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
104973
+ return false;
104974
+ p = p.prevZ;
104975
+ }
104976
+ while (n && n.z <= maxZ) {
104977
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
104978
+ return false;
104979
+ n = n.nextZ;
104980
+ }
104981
+ return true;
104982
+ }
104983
+ function cureLocalIntersections(start, triangles) {
104984
+ let p = start;
104985
+ do {
104986
+ const a = p.prev, b = p.next.next;
104987
+ if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
104988
+ triangles.push(a.i, p.i, b.i);
104989
+ removeNode(p);
104990
+ removeNode(p.next);
104991
+ p = start = b;
104992
+ }
104993
+ p = p.next;
104994
+ } while (p !== start);
104995
+ return filterPoints(p);
104996
+ }
104997
+ function splitEarcut(start, triangles, dim, minX, minY, invSize) {
104998
+ let a = start;
104999
+ do {
105000
+ let b = a.next.next;
105001
+ while (b !== a.prev) {
105002
+ if (a.i !== b.i && isValidDiagonal(a, b)) {
105003
+ let c = splitPolygon(a, b);
105004
+ a = filterPoints(a, a.next);
105005
+ c = filterPoints(c, c.next);
105006
+ earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
105007
+ earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
105008
+ return;
105009
+ }
105010
+ b = b.next;
105011
+ }
105012
+ a = a.next;
105013
+ } while (a !== start);
105014
+ }
105015
+ function eliminateHoles(data, holeIndices, outerNode, dim) {
105016
+ const queue = [];
105017
+ for (let i = 0, len = holeIndices.length;i < len; i++) {
105018
+ const start = holeIndices[i] * dim;
105019
+ const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
105020
+ const list = linkedList(data, start, end, dim, false);
105021
+ if (list === list.next)
105022
+ list.steiner = true;
105023
+ queue.push(getLeftmost(list));
105024
+ }
105025
+ queue.sort(compareXYSlope);
105026
+ for (let i = 0;i < queue.length; i++) {
105027
+ outerNode = eliminateHole(queue[i], outerNode);
105028
+ }
105029
+ return outerNode;
105030
+ }
105031
+ function compareXYSlope(a, b) {
105032
+ let result = a.x - b.x;
105033
+ if (result === 0) {
105034
+ result = a.y - b.y;
105035
+ if (result === 0) {
105036
+ const aSlope = (a.next.y - a.y) / (a.next.x - a.x);
105037
+ const bSlope = (b.next.y - b.y) / (b.next.x - b.x);
105038
+ result = aSlope - bSlope;
105039
+ }
105040
+ }
105041
+ return result;
105042
+ }
105043
+ function eliminateHole(hole, outerNode) {
105044
+ const bridge = findHoleBridge(hole, outerNode);
105045
+ if (!bridge) {
105046
+ return outerNode;
105047
+ }
105048
+ const bridgeReverse = splitPolygon(bridge, hole);
105049
+ filterPoints(bridgeReverse, bridgeReverse.next);
105050
+ return filterPoints(bridge, bridge.next);
105051
+ }
105052
+ function findHoleBridge(hole, outerNode) {
105053
+ let p = outerNode;
105054
+ const hx = hole.x;
105055
+ const hy = hole.y;
105056
+ let qx = -Infinity;
105057
+ let m;
105058
+ if (equals(hole, p))
105059
+ return p;
105060
+ do {
105061
+ if (equals(hole, p.next))
105062
+ return p.next;
105063
+ else if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
105064
+ const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
105065
+ if (x <= hx && x > qx) {
105066
+ qx = x;
105067
+ m = p.x < p.next.x ? p : p.next;
105068
+ if (x === hx)
105069
+ return m;
105070
+ }
105071
+ }
105072
+ p = p.next;
105073
+ } while (p !== outerNode);
105074
+ if (!m)
105075
+ return null;
105076
+ const stop2 = m;
105077
+ const mx = m.x;
105078
+ const my = m.y;
105079
+ let tanMin = Infinity;
105080
+ p = m;
105081
+ do {
105082
+ if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
105083
+ const tan = Math.abs(hy - p.y) / (hx - p.x);
105084
+ if (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
105085
+ m = p;
105086
+ tanMin = tan;
105087
+ }
105088
+ }
105089
+ p = p.next;
105090
+ } while (p !== stop2);
105091
+ return m;
105092
+ }
105093
+ function sectorContainsSector(m, p) {
105094
+ return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
105095
+ }
105096
+ function indexCurve(start, minX, minY, invSize) {
105097
+ let p = start;
105098
+ do {
105099
+ if (p.z === 0)
105100
+ p.z = zOrder(p.x, p.y, minX, minY, invSize);
105101
+ p.prevZ = p.prev;
105102
+ p.nextZ = p.next;
105103
+ p = p.next;
105104
+ } while (p !== start);
105105
+ p.prevZ.nextZ = null;
105106
+ p.prevZ = null;
105107
+ sortLinked(p);
105108
+ }
105109
+ function sortLinked(list) {
105110
+ let numMerges;
105111
+ let inSize = 1;
105112
+ do {
105113
+ let p = list;
105114
+ let e;
105115
+ list = null;
105116
+ let tail = null;
105117
+ numMerges = 0;
105118
+ while (p) {
105119
+ numMerges++;
105120
+ let q = p;
105121
+ let pSize = 0;
105122
+ for (let i = 0;i < inSize; i++) {
105123
+ pSize++;
105124
+ q = q.nextZ;
105125
+ if (!q)
105126
+ break;
105127
+ }
105128
+ let qSize = inSize;
105129
+ while (pSize > 0 || qSize > 0 && q) {
105130
+ if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
105131
+ e = p;
105132
+ p = p.nextZ;
105133
+ pSize--;
105134
+ } else {
105135
+ e = q;
105136
+ q = q.nextZ;
105137
+ qSize--;
105138
+ }
105139
+ if (tail)
105140
+ tail.nextZ = e;
105141
+ else
105142
+ list = e;
105143
+ e.prevZ = tail;
105144
+ tail = e;
105145
+ }
105146
+ p = q;
105147
+ }
105148
+ tail.nextZ = null;
105149
+ inSize *= 2;
105150
+ } while (numMerges > 1);
105151
+ return list;
105152
+ }
105153
+ function zOrder(x, y, minX, minY, invSize) {
105154
+ x = (x - minX) * invSize | 0;
105155
+ y = (y - minY) * invSize | 0;
105156
+ x = (x | x << 8) & 16711935;
105157
+ x = (x | x << 4) & 252645135;
105158
+ x = (x | x << 2) & 858993459;
105159
+ x = (x | x << 1) & 1431655765;
105160
+ y = (y | y << 8) & 16711935;
105161
+ y = (y | y << 4) & 252645135;
105162
+ y = (y | y << 2) & 858993459;
105163
+ y = (y | y << 1) & 1431655765;
105164
+ return x | y << 1;
105165
+ }
105166
+ function getLeftmost(start) {
105167
+ let p = start, leftmost = start;
105168
+ do {
105169
+ if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y)
105170
+ leftmost = p;
105171
+ p = p.next;
105172
+ } while (p !== start);
105173
+ return leftmost;
105174
+ }
105175
+ function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
105176
+ return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
105177
+ }
105178
+ function pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, px, py) {
105179
+ return !(ax === px && ay === py) && pointInTriangle(ax, ay, bx, by, cx, cy, px, py);
105180
+ }
105181
+ function isValidDiagonal(a, b) {
105182
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (area(a.prev, a, b.prev) || area(a, b.prev, b)) || equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
105183
+ }
105184
+ function area(p, q, r) {
105185
+ return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
105186
+ }
105187
+ function equals(p1, p2) {
105188
+ return p1.x === p2.x && p1.y === p2.y;
105189
+ }
105190
+ function intersects(p1, q1, p2, q2) {
105191
+ const o1 = sign(area(p1, q1, p2));
105192
+ const o2 = sign(area(p1, q1, q2));
105193
+ const o3 = sign(area(p2, q2, p1));
105194
+ const o4 = sign(area(p2, q2, q1));
105195
+ if (o1 !== o2 && o3 !== o4)
105196
+ return true;
105197
+ if (o1 === 0 && onSegment(p1, p2, q1))
105198
+ return true;
105199
+ if (o2 === 0 && onSegment(p1, q2, q1))
105200
+ return true;
105201
+ if (o3 === 0 && onSegment(p2, p1, q2))
105202
+ return true;
105203
+ if (o4 === 0 && onSegment(p2, q1, q2))
105204
+ return true;
105205
+ return false;
105206
+ }
105207
+ function onSegment(p, q, r) {
105208
+ return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
105209
+ }
105210
+ function sign(num) {
105211
+ return num > 0 ? 1 : num < 0 ? -1 : 0;
105212
+ }
105213
+ function intersectsPolygon(a, b) {
105214
+ let p = a;
105215
+ do {
105216
+ if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b))
105217
+ return true;
105218
+ p = p.next;
105219
+ } while (p !== a);
105220
+ return false;
105221
+ }
105222
+ function locallyInside(a, b) {
105223
+ return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
105224
+ }
105225
+ function middleInside(a, b) {
105226
+ let p = a;
105227
+ let inside = false;
105228
+ const px = (a.x + b.x) / 2;
105229
+ const py = (a.y + b.y) / 2;
105230
+ do {
105231
+ if (p.y > py !== p.next.y > py && p.next.y !== p.y && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)
105232
+ inside = !inside;
105233
+ p = p.next;
105234
+ } while (p !== a);
105235
+ return inside;
105236
+ }
105237
+ function splitPolygon(a, b) {
105238
+ const a2 = createNode(a.i, a.x, a.y), b2 = createNode(b.i, b.x, b.y), an = a.next, bp = b.prev;
105239
+ a.next = b;
105240
+ b.prev = a;
105241
+ a2.next = an;
105242
+ an.prev = a2;
105243
+ b2.next = a2;
105244
+ a2.prev = b2;
105245
+ bp.next = b2;
105246
+ b2.prev = bp;
105247
+ return b2;
105248
+ }
105249
+ function insertNode(i, x, y, last) {
105250
+ const p = createNode(i, x, y);
105251
+ if (!last) {
105252
+ p.prev = p;
105253
+ p.next = p;
105254
+ } else {
105255
+ p.next = last.next;
105256
+ p.prev = last;
105257
+ last.next.prev = p;
105258
+ last.next = p;
105259
+ }
105260
+ return p;
105261
+ }
105262
+ function removeNode(p) {
105263
+ p.next.prev = p.prev;
105264
+ p.prev.next = p.next;
105265
+ if (p.prevZ)
105266
+ p.prevZ.nextZ = p.nextZ;
105267
+ if (p.nextZ)
105268
+ p.nextZ.prevZ = p.prevZ;
105269
+ }
105270
+ function createNode(i, x, y) {
105271
+ return {
105272
+ i,
105273
+ x,
105274
+ y,
105275
+ prev: null,
105276
+ next: null,
105277
+ z: 0,
105278
+ prevZ: null,
105279
+ nextZ: null,
105280
+ steiner: false
105281
+ };
105282
+ }
105283
+ function signedArea(data, start, end, dim) {
105284
+ let sum = 0;
105285
+ for (let i = start, j = end - dim;i < end; i += dim) {
105286
+ sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
105287
+ j = i;
105288
+ }
105289
+ return sum;
105290
+ }
105291
+
105292
+ // node_modules/circuit-json-to-kicad/dist/index.js
104841
105293
  import {
105294
+ Layer,
104842
105295
  Pts as Pts3,
104843
105296
  Xy as Xy3,
104844
105297
  Zone,
104845
105298
  ZoneConnectPads,
104846
105299
  ZoneFill,
105300
+ ZoneFilledPolygon,
104847
105301
  ZoneHatch,
104848
105302
  ZonePolygon
104849
105303
  } from "kicadts";
@@ -104929,7 +105383,7 @@ import { Via, ViaNet } from "kicadts";
104929
105383
  import { applyToPoint as applyToPoint18 } from "transformation-matrix";
104930
105384
  import { Footprint as Footprint4 } from "kicadts";
104931
105385
  import { applyToPoint as applyToPoint19 } from "transformation-matrix";
104932
- import { GrLine } from "kicadts";
105386
+ import { GrCircle, GrLine, GrPoly } from "kicadts";
104933
105387
  import {
104934
105388
  At as At2,
104935
105389
  GrText,
@@ -104938,7 +105392,7 @@ import {
104938
105392
  TextEffectsJustify as TextEffectsJustify3
104939
105393
  } from "kicadts";
104940
105394
  import { applyToPoint as applyToPoint20 } from "transformation-matrix";
104941
- import { applyToPoint as applyToPoint22 } from "transformation-matrix";
105395
+ import { applyToPoint as applyToPoint22, rotate as rotate9 } from "transformation-matrix";
104942
105396
  import {
104943
105397
  GrText as GrText2,
104944
105398
  TextEffects as TextEffects11,
@@ -105083,8 +105537,9 @@ function getReferencePrefixForComponent(sourceComponent) {
105083
105537
  }
105084
105538
  function getReferenceDesignator(sourceComponent) {
105085
105539
  const name = sourceComponent?.name;
105086
- if (isReferenceDesignator(name)) {
105087
- return name.trim();
105540
+ const trimmedName = name?.trim();
105541
+ if (trimmedName) {
105542
+ return trimmedName;
105088
105543
  }
105089
105544
  const prefix = getReferencePrefixForComponent(sourceComponent);
105090
105545
  return `${prefix}?`;
@@ -106682,6 +107137,8 @@ function generateDeterministicUuid(data) {
106682
107137
  const hash = simpleHash(data);
106683
107138
  return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-${hash.slice(12, 16)}-${hash.slice(16, 20)}-${hash.slice(20, 32)}`;
106684
107139
  }
107140
+ var isPcbCopperPour = (element) => element.type === "pcb_copper_pour";
107141
+ var getCopperPours = (circuitJson) => circuitJson.filter(isPcbCopperPour);
106685
107142
  var getCopperPourNetInfo = (pour, ctx) => {
106686
107143
  let connectivityKey = pour.source_net_id;
106687
107144
  if (connectivityKey) {
@@ -106692,19 +107149,13 @@ var getCopperPourNetInfo = (pour, ctx) => {
106692
107149
  return;
106693
107150
  return ctx.pcbNetMap?.get(connectivityKey);
106694
107151
  };
106695
- var getRingPoints = (ring, c2kMatPcb) => {
106696
- return (ring.vertices ?? []).map((point) => {
106697
- const transformedPoint = applyToPoint8(c2kMatPcb, point);
106698
- return new Xy3(transformedPoint.x, transformedPoint.y);
106699
- });
106700
- };
106701
- var getPolygonPoints = (points, c2kMatPcb) => {
107152
+ var convertPointsToKicadXy = (points, c2kMatPcb) => {
106702
107153
  return (points ?? []).map((point) => {
106703
107154
  const transformedPoint = applyToPoint8(c2kMatPcb, point);
106704
107155
  return new Xy3(transformedPoint.x, transformedPoint.y);
106705
107156
  });
106706
107157
  };
106707
- var rotatePointsToTopRight = (points) => {
107158
+ var rotateRingToStartAtTopRight = (points) => {
106708
107159
  if (points.length < 2)
106709
107160
  return points;
106710
107161
  let startIndex = 0;
@@ -106719,6 +107170,26 @@ var rotatePointsToTopRight = (points) => {
106719
107170
  }
106720
107171
  return [...points.slice(startIndex), ...points.slice(0, startIndex)];
106721
107172
  };
107173
+ var removeConsecutiveDuplicatePoints = (points) => {
107174
+ const dedupedPoints = [];
107175
+ for (const point of points) {
107176
+ const lastPoint = dedupedPoints[dedupedPoints.length - 1];
107177
+ if (lastPoint?.x === point.x && lastPoint.y === point.y) {
107178
+ continue;
107179
+ }
107180
+ dedupedPoints.push(point);
107181
+ }
107182
+ return dedupedPoints;
107183
+ };
107184
+ var removeRepeatedClosingPoint = (points) => {
107185
+ const dedupedPoints = [...points];
107186
+ const firstPoint = dedupedPoints[0];
107187
+ const lastPoint = dedupedPoints[dedupedPoints.length - 1];
107188
+ if (firstPoint && lastPoint && dedupedPoints.length > 1 && firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y) {
107189
+ dedupedPoints.pop();
107190
+ }
107191
+ return dedupedPoints;
107192
+ };
106722
107193
  var getRectRingPoints = (pour, c2kMatPcb) => {
106723
107194
  const ccwRotationDegrees = pour.rotation ?? 0;
106724
107195
  const cornerTransform = compose3(translate3(pour.center.x, pour.center.y), rotate(ccwRotationDegrees * Math.PI / 180));
@@ -106730,17 +107201,87 @@ var getRectRingPoints = (pour, c2kMatPcb) => {
106730
107201
  { x: halfWidth, y: halfHeight },
106731
107202
  { x: -halfWidth, y: halfHeight }
106732
107203
  ].map((corner) => applyToPoint8(cornerTransform, corner));
106733
- return rotatePointsToTopRight(getPolygonPoints(corners, c2kMatPcb));
107204
+ return convertPointsToKicadXy(corners, c2kMatPcb);
106734
107205
  };
106735
- var getCopperPourPolygonPoints = (pour, c2kMatPcb) => {
106736
- if (pour.shape === "rect") {
106737
- return getRectRingPoints(pour, c2kMatPcb);
107206
+ var getPolygonRingPoints = (pour, c2kMatPcb) => removeRepeatedClosingPoint(removeConsecutiveDuplicatePoints(rotateRingToStartAtTopRight(convertPointsToKicadXy(pour.points, c2kMatPcb))));
107207
+ var getBrepZoneRings = (pour, c2kMatPcb) => [
107208
+ removeRepeatedClosingPoint(removeConsecutiveDuplicatePoints(rotateRingToStartAtTopRight(convertPointsToKicadXy(pour.brep_shape.outer_ring.vertices, c2kMatPcb)))),
107209
+ pour.brep_shape.inner_rings.map((ring) => removeRepeatedClosingPoint(removeConsecutiveDuplicatePoints(rotateRingToStartAtTopRight(convertPointsToKicadXy(ring.vertices, c2kMatPcb))))).filter((ringPoints) => ringPoints.length >= 3)
107210
+ ];
107211
+ var getCopperPourZoneRings = (pour, c2kMatPcb) => {
107212
+ switch (pour.shape) {
107213
+ case "rect":
107214
+ return [
107215
+ removeRepeatedClosingPoint(removeConsecutiveDuplicatePoints(rotateRingToStartAtTopRight(getRectRingPoints(pour, c2kMatPcb)))),
107216
+ []
107217
+ ];
107218
+ case "polygon":
107219
+ return [getPolygonRingPoints(pour, c2kMatPcb), []];
107220
+ case "brep":
107221
+ return getBrepZoneRings(pour, c2kMatPcb);
106738
107222
  }
106739
- if (pour.shape === "polygon") {
106740
- return rotatePointsToTopRight(getPolygonPoints(pour.points, c2kMatPcb));
107223
+ };
107224
+ var createZonePolygons = (outerRing, innerRings) => {
107225
+ const polygons = [];
107226
+ if (outerRing.length >= 3) {
107227
+ polygons.push(new ZonePolygon(new Pts3(outerRing)));
107228
+ }
107229
+ for (const innerRing of innerRings) {
107230
+ if (innerRing.length < 3)
107231
+ continue;
107232
+ polygons.push(new ZonePolygon(new Pts3(innerRing)));
107233
+ }
107234
+ return polygons;
107235
+ };
107236
+ var getTriangleArea = (a, b, c) => Math.abs((a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) / 2);
107237
+ var createZoneFilledPolygons = (outerRing, innerRings, kicadLayer) => {
107238
+ if (outerRing.length < 3) {
107239
+ return [];
107240
+ }
107241
+ const layer = new Layer([kicadLayer]);
107242
+ if (innerRings.length === 0) {
107243
+ return [
107244
+ new ZoneFilledPolygon({
107245
+ layer,
107246
+ pts: new Pts3(outerRing)
107247
+ })
107248
+ ];
107249
+ }
107250
+ const flattenedPoints = [];
107251
+ const holeIndices = [];
107252
+ let pointIndex = 0;
107253
+ const addRing = (ring) => {
107254
+ for (const point of ring) {
107255
+ flattenedPoints.push(point.x, point.y);
107256
+ }
107257
+ pointIndex += ring.length;
107258
+ };
107259
+ addRing(outerRing);
107260
+ for (const innerRing of innerRings) {
107261
+ holeIndices.push(pointIndex);
107262
+ addRing(innerRing);
107263
+ }
107264
+ const triangleIndices = earcut(flattenedPoints, holeIndices, 2);
107265
+ const filledPolygons = [];
107266
+ for (let i = 0;i < triangleIndices.length; i += 3) {
107267
+ const trianglePoints = [];
107268
+ for (let offset = 0;offset < 3; offset++) {
107269
+ const pointOffset = triangleIndices[i + offset] * 2;
107270
+ const x = flattenedPoints[pointOffset];
107271
+ const y = flattenedPoints[pointOffset + 1];
107272
+ if (x === undefined || y === undefined)
107273
+ continue;
107274
+ trianglePoints.push(new Xy3(x, y));
107275
+ }
107276
+ if (trianglePoints.length !== 3 || getTriangleArea(trianglePoints[0], trianglePoints[1], trianglePoints[2]) === 0) {
107277
+ continue;
107278
+ }
107279
+ filledPolygons.push(new ZoneFilledPolygon({
107280
+ layer,
107281
+ pts: new Pts3(trianglePoints)
107282
+ }));
106741
107283
  }
106742
- const outerRing = pour.brep_shape?.outer_ring;
106743
- return outerRing ? rotatePointsToTopRight(getRingPoints(outerRing, c2kMatPcb)) : [];
107284
+ return filledPolygons;
106744
107285
  };
106745
107286
  var AddCopperPoursStage = class extends ConverterStage {
106746
107287
  _step() {
@@ -106751,19 +107292,18 @@ var AddCopperPoursStage = class extends ConverterStage {
106751
107292
  if (!c2kMatPcb) {
106752
107293
  throw new Error("PCB transformation matrix not initialized in context");
106753
107294
  }
106754
- const copperPours = this.ctx.db.pcb_copper_pour?.list();
106755
- for (const pour of copperPours ?? []) {
106756
- const polygonPoints = getCopperPourPolygonPoints(pour, c2kMatPcb);
106757
- if (polygonPoints.length < 3)
107295
+ const copperPours = getCopperPours(this.input);
107296
+ for (const pour of copperPours) {
107297
+ const [outerRing, innerRings] = getCopperPourZoneRings(pour, c2kMatPcb);
107298
+ if (outerRing.length < 3)
106758
107299
  continue;
106759
107300
  const netInfo = getCopperPourNetInfo(pour, this.ctx);
106760
107301
  const kicadLayer = getKicadLayer(pour.layer);
106761
- const polygonPts = new Pts3(polygonPoints);
106762
107302
  const zone = new Zone({
106763
107303
  net: netInfo?.id ?? 0,
106764
107304
  netName: netInfo?.name ?? "",
106765
107305
  layer: kicadLayer,
106766
- uuid: generateDeterministicUuid(`zone:${pour.pcb_copper_pour_id ?? ""}`),
107306
+ uuid: generateDeterministicUuid(`zone:${pour.pcb_copper_pour_id}`),
106767
107307
  hatch: new ZoneHatch("edge", 0.5),
106768
107308
  connectPads: new ZoneConnectPads({ enabled: true, clearance: 0.15 }),
106769
107309
  minThickness: 0.25,
@@ -106771,9 +107311,11 @@ var AddCopperPoursStage = class extends ConverterStage {
106771
107311
  fill: new ZoneFill({
106772
107312
  filled: true,
106773
107313
  thermalGap: 0.5,
106774
- thermalBridgeWidth: 0.5
107314
+ thermalBridgeWidth: 0.5,
107315
+ islandRemovalMode: 0
106775
107316
  }),
106776
- polygons: [new ZonePolygon(polygonPts)]
107317
+ polygons: createZonePolygons(outerRing, innerRings),
107318
+ filledPolygons: createZoneFilledPolygons(outerRing, innerRings, kicadLayer)
106777
107319
  });
106778
107320
  const zones = kicadPcb.zones;
106779
107321
  zones.push(zone);
@@ -107443,7 +107985,8 @@ function convertCourtyardRects(courtyardRects, componentCenter) {
107443
107985
  }
107444
107986
  return fpRects;
107445
107987
  }
107446
- function convertCourtyardOutlines(courtyardOutlines, componentCenter, componentRotation = 0) {
107988
+ function convertCourtyardOutlines(params2) {
107989
+ const { courtyardOutlines, componentCenter, componentRotation = 0 } = params2;
107447
107990
  const fpPolys = [];
107448
107991
  const cj2kicadMatrix = compose4(componentRotation !== 0 ? rotate2(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale2(1, -1), translate4(-componentCenter.x, -componentCenter.y));
107449
107992
  for (const outline of courtyardOutlines) {
@@ -107514,7 +108057,13 @@ function createFpTextFromCircuitJson({
107514
108057
  effects: textEffects
107515
108058
  });
107516
108059
  }
107517
- function convertSilkscreenTexts(silkscreenTexts, componentCenter, componentRotation, sourceComponentName) {
108060
+ function convertSilkscreenTexts(params2) {
108061
+ const {
108062
+ silkscreenTexts,
108063
+ componentCenter,
108064
+ componentRotation,
108065
+ sourceComponentName
108066
+ } = params2;
107518
108067
  const fpTexts = [];
107519
108068
  for (const textElement of silkscreenTexts) {
107520
108069
  const fpText = createFpTextFromCircuitJson({
@@ -107570,7 +108119,8 @@ function convertSilkscreenPaths(silkscreenPaths, { componentCenter, componentRot
107570
108119
  }
107571
108120
  return fpLines;
107572
108121
  }
107573
- function convertNoteTexts(noteTexts, componentCenter, componentRotation) {
108122
+ function convertNoteTexts(params2) {
108123
+ const { noteTexts, componentCenter, componentRotation } = params2;
107574
108124
  const fpTexts = [];
107575
108125
  for (const textElement of noteTexts) {
107576
108126
  const relX = textElement.anchor_position.x - componentCenter.x;
@@ -107600,17 +108150,19 @@ function create3DModelsFromCadComponent(cadComponent, componentCenter, options)
107600
108150
  const model = new FootprintModel3(modelUrl);
107601
108151
  if (cadComponent.position) {
107602
108152
  const boardLayerZOffset = options?.boardLayerZOffset ?? 0;
108153
+ const modelOriginPosition = cadComponent.model_origin_position;
107603
108154
  model.offset = {
107604
- x: (cadComponent.position.x || 0) - componentCenter.x,
107605
- y: (cadComponent.position.y || 0) - componentCenter.y,
107606
- z: (cadComponent.position.z || 0) - boardLayerZOffset
108155
+ x: (cadComponent.position.x || 0) - componentCenter.x - (modelOriginPosition?.x || 0),
108156
+ y: (cadComponent.position.y || 0) - componentCenter.y - (modelOriginPosition?.y || 0),
108157
+ z: (cadComponent.position.z || 0) - boardLayerZOffset - (modelOriginPosition?.z || 0)
107607
108158
  };
107608
108159
  }
107609
108160
  if (cadComponent.rotation) {
108161
+ const footprintRotation = options?.footprintRotation ?? 0;
107610
108162
  model.rotate = {
107611
108163
  x: cadComponent.rotation.x || 0,
107612
108164
  y: cadComponent.rotation.y || 0,
107613
- z: cadComponent.rotation.z || 0
108165
+ z: (cadComponent.rotation.z || 0) - footprintRotation
107614
108166
  };
107615
108167
  }
107616
108168
  if (cadComponent.model_unit_to_mm_scale_factor) {
@@ -107689,6 +108241,15 @@ function createSmdPadFromCircuitJson({
107689
108241
  }
107690
108242
  padSize = [pcbPad.width, pcbPad.height];
107691
108243
  rotation = pcbPad.ccw_rotation;
108244
+ } else if (pcbPad.shape === "pill") {
108245
+ padShape = "roundrect";
108246
+ padSize = [pcbPad.width, pcbPad.height];
108247
+ roundrect_rratio = pcbPad.radius / Math.min(pcbPad.width, pcbPad.height);
108248
+ } else if (pcbPad.shape === "rotated_pill") {
108249
+ padShape = "roundrect";
108250
+ padSize = [pcbPad.width, pcbPad.height];
108251
+ roundrect_rratio = pcbPad.radius / Math.min(pcbPad.width, pcbPad.height);
108252
+ rotation = pcbPad.ccw_rotation;
107692
108253
  } else if (pcbPad.shape === "rect") {
107693
108254
  const cornerRadius = pcbPad.corner_radius ?? pcbPad.rect_border_radius;
107694
108255
  if (cornerRadius) {
@@ -107712,6 +108273,7 @@ function createSmdPadFromCircuitJson({
107712
108273
  `${padLayer === "F.Cu" ? "F" : "B"}.Mask`
107713
108274
  ],
107714
108275
  solderMaskMargin: pcbPad.soldermask_margin,
108276
+ roundrectRatio: roundrect_rratio,
107715
108277
  uuid: generateDeterministicUuid(padData)
107716
108278
  });
107717
108279
  if (padOptions) {
@@ -107955,7 +108517,8 @@ function createNpthPadFromCircuitJson({
107955
108517
  uuid: crypto.randomUUID()
107956
108518
  });
107957
108519
  }
107958
- function convertNpthHoles(pcbHoles, componentCenter, componentRotation) {
108520
+ function convertNpthHoles(params2) {
108521
+ const { pcbHoles, componentCenter, componentRotation } = params2;
107959
108522
  const pads = [];
107960
108523
  for (const pcbHole of pcbHoles) {
107961
108524
  const pad = createNpthPadFromCircuitJson({
@@ -108028,9 +108591,18 @@ var AddFootprintsStage = class extends ConverterStage {
108028
108591
  });
108029
108592
  const fpTexts = footprint.fpTexts;
108030
108593
  const pcbSilkscreenTexts = this.ctx.db.pcb_silkscreen_text?.list().filter((text) => text.pcb_component_id === component.pcb_component_id) || [];
108031
- fpTexts.push(...convertSilkscreenTexts(pcbSilkscreenTexts, component.center, component.rotation || 0, sourceComponent?.name));
108594
+ fpTexts.push(...convertSilkscreenTexts({
108595
+ silkscreenTexts: pcbSilkscreenTexts,
108596
+ componentCenter: component.center,
108597
+ componentRotation: component.rotation || 0,
108598
+ sourceComponentName: sourceComponent?.name
108599
+ }));
108032
108600
  const pcbNoteTexts = this.ctx.db.pcb_note_text?.list().filter((text) => text.pcb_component_id === component.pcb_component_id) || [];
108033
- fpTexts.push(...convertNoteTexts(pcbNoteTexts, component.center, component.rotation || 0));
108601
+ fpTexts.push(...convertNoteTexts({
108602
+ noteTexts: pcbNoteTexts,
108603
+ componentCenter: component.center,
108604
+ componentRotation: component.rotation || 0
108605
+ }));
108034
108606
  footprint.fpTexts = fpTexts;
108035
108607
  const pcbSilkscreenPaths = this.ctx.db.pcb_silkscreen_path?.list().filter((path16) => path16.pcb_component_id === component.pcb_component_id) || [];
108036
108608
  const fpLines = footprint.fpLines ?? [];
@@ -108062,7 +108634,11 @@ var AddFootprintsStage = class extends ConverterStage {
108062
108634
  }, this.ctx);
108063
108635
  fpPads.push(...thruHolePads);
108064
108636
  const pcbHoles = this.ctx.db.pcb_hole?.list().filter((hole) => hole.pcb_component_id === component.pcb_component_id) || [];
108065
- const npthPads = convertNpthHoles(pcbHoles, component.center, component.rotation || 0);
108637
+ const npthPads = convertNpthHoles({
108638
+ pcbHoles,
108639
+ componentCenter: component.center,
108640
+ componentRotation: component.rotation || 0
108641
+ });
108066
108642
  fpPads.push(...npthPads);
108067
108643
  footprint.fpPads = fpPads;
108068
108644
  const pcbSilkscreenCircles = this.ctx.db.pcb_silkscreen_circle?.list().filter((circle) => circle.pcb_component_id === component.pcb_component_id) || [];
@@ -108080,7 +108656,11 @@ var AddFootprintsStage = class extends ConverterStage {
108080
108656
  fpRects.push(...convertCourtyardRects(pcbCourtyardRects, component.center));
108081
108657
  footprint.fpRects = fpRects;
108082
108658
  const pcbCourtyardOutlines = this.ctx.db.pcb_courtyard_outline?.list().filter((outline) => outline.pcb_component_id === component.pcb_component_id) || [];
108083
- const fpPolys = convertCourtyardOutlines(pcbCourtyardOutlines, component.center, component.rotation || 0);
108659
+ const fpPolys = convertCourtyardOutlines({
108660
+ courtyardOutlines: pcbCourtyardOutlines,
108661
+ componentCenter: component.center,
108662
+ componentRotation: component.rotation || 0
108663
+ });
108084
108664
  if (fpPolys.length > 0) {
108085
108665
  footprint.fpPolys = fpPolys;
108086
108666
  }
@@ -108088,7 +108668,10 @@ var AddFootprintsStage = class extends ConverterStage {
108088
108668
  const pcbBoard = this.ctx.db.pcb_board?.list()[0];
108089
108669
  const boardThickness = pcbBoard?.thickness ?? 0;
108090
108670
  const boardLayerZOffset = component.layer === "bottom" ? -(boardThickness / 2) : boardThickness / 2;
108091
- const models = create3DModelsFromCadComponent(cadComponent, component.center, { boardLayerZOffset });
108671
+ const models = create3DModelsFromCadComponent(cadComponent, component.center, {
108672
+ boardLayerZOffset,
108673
+ footprintRotation: component.rotation || 0
108674
+ });
108092
108675
  const KICAD_3D_BASE = "${KIPRJMOD}/3dmodels";
108093
108676
  if (models.length > 0) {
108094
108677
  if (this.includeBuiltin3dModels) {
@@ -108142,6 +108725,24 @@ var AddFootprintsStage = class extends ConverterStage {
108142
108725
  return this.ctx.kicadPcb;
108143
108726
  }
108144
108727
  };
108728
+ function getRoutePointLayer(point, pointRoleInSegment) {
108729
+ if ("layer" in point) {
108730
+ return point.layer;
108731
+ }
108732
+ if (point.route_type === "through_pad") {
108733
+ if (pointRoleInSegment === "start") {
108734
+ return point.end_layer;
108735
+ }
108736
+ return point.start_layer;
108737
+ }
108738
+ return;
108739
+ }
108740
+ function getRoutePointWidth(point) {
108741
+ if ("width" in point) {
108742
+ return point.width;
108743
+ }
108744
+ return;
108745
+ }
108145
108746
  var AddTracesStage = class extends ConverterStage {
108146
108747
  tracesProcessed = 0;
108147
108748
  pcbTraces = [];
@@ -108149,6 +108750,18 @@ var AddTracesStage = class extends ConverterStage {
108149
108750
  super(input, ctx);
108150
108751
  this.pcbTraces = this.ctx.db.pcb_trace.list();
108151
108752
  }
108753
+ getRoutePointPosition(point, pointRoleInSegment) {
108754
+ if ("x" in point && "y" in point) {
108755
+ return { x: point.x, y: point.y };
108756
+ }
108757
+ if (point.route_type !== "through_pad") {
108758
+ return null;
108759
+ }
108760
+ if (pointRoleInSegment === "start") {
108761
+ return { x: point.end.x, y: point.end.y };
108762
+ }
108763
+ return { x: point.start.x, y: point.start.y };
108764
+ }
108152
108765
  _step() {
108153
108766
  const { kicadPcb, c2kMatPcb, pcbNetMap } = this.ctx;
108154
108767
  if (!kicadPcb) {
@@ -108162,22 +108775,25 @@ var AddTracesStage = class extends ConverterStage {
108162
108775
  return;
108163
108776
  }
108164
108777
  const trace = this.pcbTraces[this.tracesProcessed];
108165
- if (!trace.route || trace.route.length < 2) {
108778
+ const route = trace.route;
108779
+ if (!route || route.length < 2) {
108166
108780
  this.tracesProcessed++;
108167
108781
  return;
108168
108782
  }
108169
- let lastKnownLayer = trace.route[0]?.layer;
108170
- for (let i = 0;i < trace.route.length - 1; i++) {
108171
- const startPoint = trace.route[i];
108172
- const endPoint = trace.route[i + 1];
108173
- const transformedStart = applyToPoint17(c2kMatPcb, {
108174
- x: startPoint.x,
108175
- y: startPoint.y
108176
- });
108177
- const transformedEnd = applyToPoint17(c2kMatPcb, {
108178
- x: endPoint.x,
108179
- y: endPoint.y
108180
- });
108783
+ let lastKnownLayer = getRoutePointLayer(route[0], "start");
108784
+ for (let i = 0;i < route.length - 1; i++) {
108785
+ const startPoint = route[i];
108786
+ const endPoint = route[i + 1];
108787
+ const startPosition = this.getRoutePointPosition(startPoint, "start");
108788
+ const endPosition = this.getRoutePointPosition(endPoint, "end");
108789
+ if (!startPosition || !endPosition) {
108790
+ throw new Error(`Unable to convert pcb_trace route segment ${trace.pcb_trace_id ?? this.tracesProcessed}:${i} to KiCad segment`);
108791
+ }
108792
+ const transformedStart = applyToPoint17(c2kMatPcb, startPosition);
108793
+ const transformedEnd = applyToPoint17(c2kMatPcb, endPosition);
108794
+ if (transformedStart.x === transformedEnd.x && transformedStart.y === transformedEnd.y) {
108795
+ continue;
108796
+ }
108181
108797
  let netInfo;
108182
108798
  if (pcbNetMap) {
108183
108799
  let connectivityKey = trace.subcircuit_connectivity_map_key;
@@ -108206,25 +108822,27 @@ var AddTracesStage = class extends ConverterStage {
108206
108822
  netInfo = pcbNetMap.get(connectivityKey);
108207
108823
  }
108208
108824
  }
108209
- const segmentLayerSource = startPoint.layer ?? endPoint.layer ?? lastKnownLayer;
108825
+ const segmentLayerSource = getRoutePointLayer(startPoint, "start") ?? getRoutePointLayer(endPoint, "end") ?? lastKnownLayer;
108210
108826
  const kicadLayer = getKicadLayer(segmentLayerSource);
108211
108827
  const segmentData = `segment:${transformedStart.x},${transformedStart.y}:${transformedEnd.x},${transformedEnd.y}:${kicadLayer}:${netInfo?.id ?? 0}`;
108212
108828
  const segment = new Segment({
108213
108829
  start: { x: transformedStart.x, y: transformedStart.y },
108214
108830
  end: { x: transformedEnd.x, y: transformedEnd.y },
108215
108831
  layer: kicadLayer,
108216
- width: startPoint.width ?? endPoint.width ?? trace.width ?? 0.25,
108832
+ width: getRoutePointWidth(startPoint) ?? getRoutePointWidth(endPoint) ?? trace.width ?? 0.25,
108217
108833
  net: new SegmentNet(netInfo?.id ?? 0),
108218
108834
  uuid: generateDeterministicUuid(segmentData)
108219
108835
  });
108220
108836
  const segments = kicadPcb.segments;
108221
108837
  segments.push(segment);
108222
108838
  kicadPcb.segments = segments;
108223
- if (startPoint.layer) {
108224
- lastKnownLayer = startPoint.layer;
108839
+ const startLayer = getRoutePointLayer(startPoint, "start");
108840
+ const endLayer = getRoutePointLayer(endPoint, "end");
108841
+ if (startLayer) {
108842
+ lastKnownLayer = startLayer;
108225
108843
  }
108226
- if (endPoint.layer) {
108227
- lastKnownLayer = endPoint.layer;
108844
+ if (endLayer) {
108845
+ lastKnownLayer = endLayer;
108228
108846
  }
108229
108847
  }
108230
108848
  this.tracesProcessed++;
@@ -108424,7 +109042,11 @@ var AddStandalonePcbElements = class extends ConverterStage {
108424
109042
  uuid: generateDeterministicUuid(footprintSeed)
108425
109043
  });
108426
109044
  const ccwRotationDegrees = 0;
108427
- const npthPads = convertNpthHoles([hole], { x: hole.x, y: hole.y }, ccwRotationDegrees);
109045
+ const npthPads = convertNpthHoles({
109046
+ pcbHoles: [hole],
109047
+ componentCenter: { x: hole.x, y: hole.y },
109048
+ componentRotation: ccwRotationDegrees
109049
+ });
108428
109050
  if (npthPads.length > 0) {
108429
109051
  footprint.fpPads = npthPads;
108430
109052
  const footprints = kicadPcb.footprints;
@@ -108575,7 +109197,8 @@ function createFabricationNoteTextFromCircuitJson({
108575
109197
  const grText = new GrText({
108576
109198
  text: textElement.text,
108577
109199
  layer: kicadLayer,
108578
- effects: textEffects
109200
+ effects: textEffects,
109201
+ uuid: generateDeterministicUuid(textElement.pcb_fabrication_note_text_id ?? textElement.text)
108579
109202
  });
108580
109203
  grText.position = position;
108581
109204
  return grText;
@@ -108632,7 +109255,8 @@ function createGrTextFromCircuitJson({
108632
109255
  const grText = new GrText2({
108633
109256
  text: textElement.text,
108634
109257
  layer: kicadLayer,
108635
- effects: textEffects
109258
+ effects: textEffects,
109259
+ uuid: generateDeterministicUuid(textElement.pcb_silkscreen_text_id ?? textElement.text)
108636
109260
  });
108637
109261
  grText.position = position;
108638
109262
  return grText;
@@ -108651,6 +109275,44 @@ var normalizeOutlineCorners = (corners) => {
108651
109275
  }
108652
109276
  return dedupedCorners;
108653
109277
  };
109278
+ var EDGE_CUTS_WIDTH = 0.1;
109279
+ var appendGraphicLine = (kicadPcb, grLine) => {
109280
+ const graphicLines = kicadPcb.graphicLines;
109281
+ graphicLines.push(grLine);
109282
+ kicadPcb.graphicLines = graphicLines;
109283
+ };
109284
+ var appendGraphicCircle = (kicadPcb, grCircle) => {
109285
+ const graphicCircles = kicadPcb.graphicCircles;
109286
+ graphicCircles.push(grCircle);
109287
+ kicadPcb.graphicCircles = graphicCircles;
109288
+ };
109289
+ var appendGraphicPoly = (kicadPcb, grPoly) => {
109290
+ const graphicPolys = kicadPcb.graphicPolys;
109291
+ graphicPolys.push(grPoly);
109292
+ kicadPcb.graphicPolys = graphicPolys;
109293
+ };
109294
+ var rotatePointAroundOrigin = (point, rotationDegrees = 0) => {
109295
+ if (!rotationDegrees)
109296
+ return point;
109297
+ return applyToPoint22(rotate9(rotationDegrees * Math.PI / 180), point);
109298
+ };
109299
+ var getRectCutoutCorners = (cutout) => {
109300
+ const halfWidth = cutout.width / 2;
109301
+ const halfHeight = cutout.height / 2;
109302
+ const localCorners = [
109303
+ { x: -halfWidth, y: -halfHeight },
109304
+ { x: halfWidth, y: -halfHeight },
109305
+ { x: halfWidth, y: halfHeight },
109306
+ { x: -halfWidth, y: halfHeight }
109307
+ ];
109308
+ return localCorners.map((point) => {
109309
+ const rotatedPoint = rotatePointAroundOrigin(point, cutout.rotation);
109310
+ return {
109311
+ x: rotatedPoint.x + cutout.center.x,
109312
+ y: rotatedPoint.y + cutout.center.y
109313
+ };
109314
+ });
109315
+ };
108654
109316
  var AddGraphicsStage = class extends ConverterStage {
108655
109317
  _step() {
108656
109318
  const { kicadPcb, c2kMatPcb } = this.ctx;
@@ -108688,9 +109350,7 @@ var AddGraphicsStage = class extends ConverterStage {
108688
109350
  layer: kicadLayer,
108689
109351
  width: path16.stroke_width || 0.15
108690
109352
  });
108691
- const graphicLines = kicadPcb.graphicLines;
108692
- graphicLines.push(grLine);
108693
- kicadPcb.graphicLines = graphicLines;
109353
+ appendGraphicLine(kicadPcb, grLine);
108694
109354
  }
108695
109355
  }
108696
109356
  const standaloneSilkscreenTexts = this.ctx.db.pcb_silkscreen_text?.list().filter((text) => !text.pcb_component_id) || [];
@@ -108753,11 +109413,62 @@ var AddGraphicsStage = class extends ConverterStage {
108753
109413
  start: { x: start.x, y: start.y },
108754
109414
  end: { x: end.x, y: end.y },
108755
109415
  layer: "Edge.Cuts",
108756
- width: 0.1
109416
+ width: EDGE_CUTS_WIDTH
108757
109417
  });
108758
- const graphicLines = kicadPcb.graphicLines;
108759
- graphicLines.push(edgeLine);
108760
- kicadPcb.graphicLines = graphicLines;
109418
+ appendGraphicLine(kicadPcb, edgeLine);
109419
+ }
109420
+ }
109421
+ const pcbCutouts = this.ctx.db.pcb_cutout?.list() || [];
109422
+ for (const cutout of pcbCutouts) {
109423
+ if (cutout.shape === "circle") {
109424
+ const transformedCenter = applyToPoint22(c2kMatPcb, cutout.center);
109425
+ const transformedEnd = applyToPoint22(c2kMatPcb, {
109426
+ x: cutout.center.x + cutout.radius,
109427
+ y: cutout.center.y
109428
+ });
109429
+ appendGraphicCircle(kicadPcb, new GrCircle({
109430
+ center: transformedCenter,
109431
+ end: transformedEnd,
109432
+ layer: "Edge.Cuts",
109433
+ width: EDGE_CUTS_WIDTH
109434
+ }));
109435
+ } else if (cutout.shape === "polygon") {
109436
+ const corners = normalizeOutlineCorners(cutout.points);
109437
+ if (corners.length < 3)
109438
+ continue;
109439
+ appendGraphicPoly(kicadPcb, new GrPoly({
109440
+ points: corners.map((point) => applyToPoint22(c2kMatPcb, point)),
109441
+ layer: "Edge.Cuts",
109442
+ width: EDGE_CUTS_WIDTH,
109443
+ fill: false
109444
+ }));
109445
+ } else if (cutout.shape === "rect") {
109446
+ const corners = normalizeOutlineCorners(getRectCutoutCorners(cutout));
109447
+ if (corners.length < 3)
109448
+ continue;
109449
+ appendGraphicPoly(kicadPcb, new GrPoly({
109450
+ points: corners.map((point) => applyToPoint22(c2kMatPcb, point)),
109451
+ layer: "Edge.Cuts",
109452
+ width: EDGE_CUTS_WIDTH,
109453
+ fill: false
109454
+ }));
109455
+ } else if (cutout.shape === "path") {
109456
+ if (!cutout.route || cutout.route.length < 2)
109457
+ continue;
109458
+ for (let i = 0;i < cutout.route.length - 1; i++) {
109459
+ const startPoint = cutout.route[i];
109460
+ const endPoint = cutout.route[i + 1];
109461
+ if (!startPoint || !endPoint)
109462
+ continue;
109463
+ const transformedStart = applyToPoint22(c2kMatPcb, startPoint);
109464
+ const transformedEnd = applyToPoint22(c2kMatPcb, endPoint);
109465
+ appendGraphicLine(kicadPcb, new GrLine({
109466
+ start: transformedStart,
109467
+ end: transformedEnd,
109468
+ layer: "Edge.Cuts",
109469
+ width: EDGE_CUTS_WIDTH
109470
+ }));
109471
+ }
108761
109472
  }
108762
109473
  }
108763
109474
  this.finished = true;
@@ -116114,7 +116825,7 @@ class RBush {
116114
116825
  search(bbox) {
116115
116826
  let node = this.data;
116116
116827
  const result = [];
116117
- if (!intersects(bbox, node))
116828
+ if (!intersects2(bbox, node))
116118
116829
  return result;
116119
116830
  const toBBox = this.toBBox;
116120
116831
  const nodesToSearch = [];
@@ -116122,7 +116833,7 @@ class RBush {
116122
116833
  for (let i = 0;i < node.children.length; i++) {
116123
116834
  const child = node.children[i];
116124
116835
  const childBBox = node.leaf ? toBBox(child) : child;
116125
- if (intersects(bbox, childBBox)) {
116836
+ if (intersects2(bbox, childBBox)) {
116126
116837
  if (node.leaf)
116127
116838
  result.push(child);
116128
116839
  else if (contains(bbox, childBBox))
@@ -116137,14 +116848,14 @@ class RBush {
116137
116848
  }
116138
116849
  collides(bbox) {
116139
116850
  let node = this.data;
116140
- if (!intersects(bbox, node))
116851
+ if (!intersects2(bbox, node))
116141
116852
  return false;
116142
116853
  const nodesToSearch = [];
116143
116854
  while (node) {
116144
116855
  for (let i = 0;i < node.children.length; i++) {
116145
116856
  const child = node.children[i];
116146
116857
  const childBBox = node.leaf ? this.toBBox(child) : child;
116147
- if (intersects(bbox, childBBox)) {
116858
+ if (intersects2(bbox, childBBox)) {
116148
116859
  if (node.leaf || contains(bbox, childBBox))
116149
116860
  return true;
116150
116861
  nodesToSearch.push(child);
@@ -116184,7 +116895,7 @@ class RBush {
116184
116895
  return this;
116185
116896
  }
116186
116897
  clear() {
116187
- this.data = createNode([]);
116898
+ this.data = createNode2([]);
116188
116899
  return this;
116189
116900
  }
116190
116901
  remove(item, equalsFn) {
@@ -116258,7 +116969,7 @@ class RBush {
116258
116969
  let M = this._maxEntries;
116259
116970
  let node;
116260
116971
  if (N <= M) {
116261
- node = createNode(items.slice(left, right + 1));
116972
+ node = createNode2(items.slice(left, right + 1));
116262
116973
  calcBBox(node, this.toBBox);
116263
116974
  return node;
116264
116975
  }
@@ -116266,7 +116977,7 @@ class RBush {
116266
116977
  height = Math.ceil(Math.log(N) / Math.log(M));
116267
116978
  M = Math.ceil(N / Math.pow(M, height - 1));
116268
116979
  }
116269
- node = createNode([]);
116980
+ node = createNode2([]);
116270
116981
  node.leaf = false;
116271
116982
  node.height = height;
116272
116983
  const N2 = Math.ceil(N / M);
@@ -116293,15 +117004,15 @@ class RBush {
116293
117004
  let targetNode;
116294
117005
  for (let i = 0;i < node.children.length; i++) {
116295
117006
  const child = node.children[i];
116296
- const area = bboxArea(child);
116297
- const enlargement = enlargedArea(bbox, child) - area;
117007
+ const area2 = bboxArea(child);
117008
+ const enlargement = enlargedArea(bbox, child) - area2;
116298
117009
  if (enlargement < minEnlargement) {
116299
117010
  minEnlargement = enlargement;
116300
- minArea = area < minArea ? area : minArea;
117011
+ minArea = area2 < minArea ? area2 : minArea;
116301
117012
  targetNode = child;
116302
117013
  } else if (enlargement === minEnlargement) {
116303
- if (area < minArea) {
116304
- minArea = area;
117014
+ if (area2 < minArea) {
117015
+ minArea = area2;
116305
117016
  targetNode = child;
116306
117017
  }
116307
117018
  }
@@ -116331,7 +117042,7 @@ class RBush {
116331
117042
  const m = this._minEntries;
116332
117043
  this._chooseSplitAxis(node, m, M);
116333
117044
  const splitIndex = this._chooseSplitIndex(node, m, M);
116334
- const newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
117045
+ const newNode = createNode2(node.children.splice(splitIndex, node.children.length - splitIndex));
116335
117046
  newNode.height = node.height;
116336
117047
  newNode.leaf = node.leaf;
116337
117048
  calcBBox(node, this.toBBox);
@@ -116342,7 +117053,7 @@ class RBush {
116342
117053
  this._splitRoot(node, newNode);
116343
117054
  }
116344
117055
  _splitRoot(node, newNode) {
116345
- this.data = createNode([node, newNode]);
117056
+ this.data = createNode2([node, newNode]);
116346
117057
  this.data.height = node.height + 1;
116347
117058
  this.data.leaf = false;
116348
117059
  calcBBox(this.data, this.toBBox);
@@ -116355,14 +117066,14 @@ class RBush {
116355
117066
  const bbox1 = distBBox(node, 0, i, this.toBBox);
116356
117067
  const bbox2 = distBBox(node, i, M, this.toBBox);
116357
117068
  const overlap = intersectionArea(bbox1, bbox2);
116358
- const area = bboxArea(bbox1) + bboxArea(bbox2);
117069
+ const area2 = bboxArea(bbox1) + bboxArea(bbox2);
116359
117070
  if (overlap < minOverlap) {
116360
117071
  minOverlap = overlap;
116361
117072
  index = i;
116362
- minArea = area < minArea ? area : minArea;
117073
+ minArea = area2 < minArea ? area2 : minArea;
116363
117074
  } else if (overlap === minOverlap) {
116364
- if (area < minArea) {
116365
- minArea = area;
117075
+ if (area2 < minArea) {
117076
+ minArea = area2;
116366
117077
  index = i;
116367
117078
  }
116368
117079
  }
@@ -116427,7 +117138,7 @@ function calcBBox(node, toBBox) {
116427
117138
  }
116428
117139
  function distBBox(node, k, p, toBBox, destNode) {
116429
117140
  if (!destNode)
116430
- destNode = createNode(null);
117141
+ destNode = createNode2(null);
116431
117142
  destNode.minX = Infinity;
116432
117143
  destNode.minY = Infinity;
116433
117144
  destNode.maxX = -Infinity;
@@ -116470,10 +117181,10 @@ function intersectionArea(a, b) {
116470
117181
  function contains(a, b) {
116471
117182
  return a.minX <= b.minX && a.minY <= b.minY && b.maxX <= a.maxX && b.maxY <= a.maxY;
116472
117183
  }
116473
- function intersects(a, b) {
117184
+ function intersects2(a, b) {
116474
117185
  return b.minX <= a.maxX && b.minY <= a.maxY && b.maxX >= a.minX && b.maxY >= a.minY;
116475
117186
  }
116476
- function createNode(children) {
117187
+ function createNode2(children) {
116477
117188
  return {
116478
117189
  children,
116479
117190
  height: 1,
@@ -117557,15 +118268,15 @@ var getLargestEmptySpaceFromPoint = (x, y, boardBounds, occupiedBounds, occupied
117557
118268
  return horizontalArea >= verticalArea ? horizontalFirst : verticalFirst;
117558
118269
  };
117559
118270
  var createEmptySpaceIndexItem = (bounds, boardArea, sequenceNumber) => {
117560
- const area = bounds.width * bounds.height;
118271
+ const area2 = bounds.width * bounds.height;
117561
118272
  return {
117562
118273
  id: `empty-space-${sequenceNumber}`,
117563
118274
  minX: bounds.min_x,
117564
118275
  minY: bounds.min_y,
117565
118276
  maxX: bounds.max_x,
117566
118277
  maxY: bounds.max_y,
117567
- area,
117568
- areaPercent: boardArea === 0 ? 0 : area / boardArea * 100,
118278
+ area: area2,
118279
+ areaPercent: boardArea === 0 ? 0 : area2 / boardArea * 100,
117569
118280
  bounds: toPlacementBounds(bounds)
117570
118281
  };
117571
118282
  };
@@ -117579,8 +118290,8 @@ var buildLargeEmptySpaces = (boardBounds, occupiedBounds, occupiedIndex, boardAr
117579
118290
  const bounds = getLargestEmptySpaceFromPoint(x, y, boardBounds, occupiedBounds, occupiedIndex);
117580
118291
  if (!bounds)
117581
118292
  continue;
117582
- const area = bounds.width * bounds.height;
117583
- if (area <= thresholdArea)
118293
+ const area2 = bounds.width * bounds.height;
118294
+ if (area2 <= thresholdArea)
117584
118295
  continue;
117585
118296
  const candidate = createEmptySpaceIndexItem(bounds, boardArea, sequenceNumber++);
117586
118297
  const overlappingSpaces = emptySpaceIndex.search(candidate).filter((space) => boundsOverlapWithArea(bounds, createBounds(space.minX, space.maxX, space.minY, space.maxY)));
@@ -117593,8 +118304,8 @@ var buildLargeEmptySpaces = (boardBounds, occupiedBounds, occupiedIndex, boardAr
117593
118304
  emptySpaceIndex.insert(candidate);
117594
118305
  }
117595
118306
  }
117596
- return emptySpaceIndex.all().map(({ area, areaPercent, bounds }) => ({
117597
- area,
118307
+ return emptySpaceIndex.all().map(({ area: area2, areaPercent, bounds }) => ({
118308
+ area: area2,
117598
118309
  areaPercent,
117599
118310
  bounds
117600
118311
  })).sort((a, b) => {
@@ -141734,7 +142445,7 @@ var require_reader4 = __commonJS22({
141734
142445
  element: "element",
141735
142446
  text: "text"
141736
142447
  };
141737
- var createNode2 = function createNode22(params2) {
142448
+ var createNode3 = function createNode22(params2) {
141738
142449
  return Object.assign({
141739
142450
  name: "",
141740
142451
  type: NodeType.element,
@@ -141762,7 +142473,7 @@ var require_reader4 = __commonJS22({
141762
142473
  current2 = rootNode;
141763
142474
  current2.name = data.value;
141764
142475
  } else {
141765
- var node = createNode2({
142476
+ var node = createNode3({
141766
142477
  name: data.value,
141767
142478
  parent: current2
141768
142479
  });
@@ -141795,7 +142506,7 @@ var require_reader4 = __commonJS22({
141795
142506
  break;
141796
142507
  case Type.text:
141797
142508
  if (current2) {
141798
- current2.children.push(createNode2({
142509
+ current2.children.push(createNode3({
141799
142510
  type: NodeType.text,
141800
142511
  value: data.value,
141801
142512
  parent: options.parentNodes ? current2 : null
@@ -141814,7 +142525,7 @@ var require_reader4 = __commonJS22({
141814
142525
  reader.reset = function() {
141815
142526
  lexer = Lexer.create({ debug: options.debug });
141816
142527
  lexer.on("data", handleLexerData);
141817
- rootNode = createNode2();
142528
+ rootNode = createNode3();
141818
142529
  current2 = null;
141819
142530
  attrName = "";
141820
142531
  reader.parse = lexer.write;
@@ -175787,13 +176498,13 @@ function doSegmentsIntersect2(p12, q12, p22, q22) {
175787
176498
  if (o12 !== o22 && o3 !== o4) {
175788
176499
  return true;
175789
176500
  }
175790
- if (o12 === 0 && onSegment2(p12, p22, q12))
176501
+ if (o12 === 0 && onSegment3(p12, p22, q12))
175791
176502
  return true;
175792
- if (o22 === 0 && onSegment2(p12, q22, q12))
176503
+ if (o22 === 0 && onSegment3(p12, q22, q12))
175793
176504
  return true;
175794
- if (o3 === 0 && onSegment2(p22, p12, q22))
176505
+ if (o3 === 0 && onSegment3(p22, p12, q22))
175795
176506
  return true;
175796
- if (o4 === 0 && onSegment2(p22, q12, q22))
176507
+ if (o4 === 0 && onSegment3(p22, q12, q22))
175797
176508
  return true;
175798
176509
  return false;
175799
176510
  }
@@ -175803,7 +176514,7 @@ function orientation2(p3, q22, r22) {
175803
176514
  return 0;
175804
176515
  return val > 0 ? 1 : 2;
175805
176516
  }
175806
- function onSegment2(p3, q22, r22) {
176517
+ function onSegment3(p3, q22, r22) {
175807
176518
  return q22.x <= Math.max(p3.x, r22.x) && q22.x >= Math.min(p3.x, r22.x) && q22.y <= Math.max(p3.y, r22.y) && q22.y >= Math.min(p3.y, r22.y);
175808
176519
  }
175809
176520
  function segmentsDistance2(a12, a2, b12, b22) {
@@ -175910,8 +176621,8 @@ var isPointInsidePolygon = (point5, polygon2) => {
175910
176621
  const yi22 = polygon2[i2].y;
175911
176622
  const xj = polygon2[j22].x;
175912
176623
  const yj = polygon2[j22].y;
175913
- const intersects2 = yi22 > point5.y !== yj > point5.y && point5.x < (xj - xi22) * (point5.y - yi22) / (yj - yi22) + xi22;
175914
- if (intersects2) {
176624
+ const intersects3 = yi22 > point5.y !== yj > point5.y && point5.x < (xj - xi22) * (point5.y - yi22) / (yj - yi22) + xi22;
176625
+ if (intersects3) {
175915
176626
  inside2 = !inside2;
175916
176627
  }
175917
176628
  }
@@ -197493,24 +198204,24 @@ function parse2(formula) {
197493
198204
  }
197494
198205
  let idx = 0;
197495
198206
  let a2 = 0;
197496
- let sign = readSign();
198207
+ let sign2 = readSign();
197497
198208
  let number = readNumber();
197498
198209
  if (idx < formula.length && formula.charAt(idx) === "n") {
197499
198210
  idx++;
197500
- a2 = sign * (number !== null && number !== undefined ? number : 1);
198211
+ a2 = sign2 * (number !== null && number !== undefined ? number : 1);
197501
198212
  skipWhitespace();
197502
198213
  if (idx < formula.length) {
197503
- sign = readSign();
198214
+ sign2 = readSign();
197504
198215
  skipWhitespace();
197505
198216
  number = readNumber();
197506
198217
  } else {
197507
- sign = number = 0;
198218
+ sign2 = number = 0;
197508
198219
  }
197509
198220
  }
197510
198221
  if (number === null || idx < formula.length) {
197511
198222
  throw new Error(`n-th rule couldn't be parsed ('${formula}')`);
197512
198223
  }
197513
- return [a2, sign * number];
198224
+ return [a2, sign2 * number];
197514
198225
  function readSign() {
197515
198226
  if (formula.charAt(idx) === "-") {
197516
198227
  idx++;
@@ -197574,7 +198285,7 @@ var filters = {
197574
198285
  return next(elem) && adapter.getText(elem).toLowerCase().includes(itext);
197575
198286
  };
197576
198287
  },
197577
- "nth-child"(next, rule, { adapter, equals }) {
198288
+ "nth-child"(next, rule, { adapter, equals: equals2 }) {
197578
198289
  const func = nthCheck(rule);
197579
198290
  if (func === import_boolbase3.default.falseFunc)
197580
198291
  return import_boolbase3.default.falseFunc;
@@ -197584,7 +198295,7 @@ var filters = {
197584
198295
  const siblings = adapter.getSiblings(elem);
197585
198296
  let pos = 0;
197586
198297
  for (let i2 = 0;i2 < siblings.length; i2++) {
197587
- if (equals(elem, siblings[i2]))
198298
+ if (equals2(elem, siblings[i2]))
197588
198299
  break;
197589
198300
  if (adapter.isTag(siblings[i2])) {
197590
198301
  pos++;
@@ -197593,7 +198304,7 @@ var filters = {
197593
198304
  return func(pos) && next(elem);
197594
198305
  };
197595
198306
  },
197596
- "nth-last-child"(next, rule, { adapter, equals }) {
198307
+ "nth-last-child"(next, rule, { adapter, equals: equals2 }) {
197597
198308
  const func = nthCheck(rule);
197598
198309
  if (func === import_boolbase3.default.falseFunc)
197599
198310
  return import_boolbase3.default.falseFunc;
@@ -197603,7 +198314,7 @@ var filters = {
197603
198314
  const siblings = adapter.getSiblings(elem);
197604
198315
  let pos = 0;
197605
198316
  for (let i2 = siblings.length - 1;i2 >= 0; i2--) {
197606
- if (equals(elem, siblings[i2]))
198317
+ if (equals2(elem, siblings[i2]))
197607
198318
  break;
197608
198319
  if (adapter.isTag(siblings[i2])) {
197609
198320
  pos++;
@@ -197612,7 +198323,7 @@ var filters = {
197612
198323
  return func(pos) && next(elem);
197613
198324
  };
197614
198325
  },
197615
- "nth-of-type"(next, rule, { adapter, equals }) {
198326
+ "nth-of-type"(next, rule, { adapter, equals: equals2 }) {
197616
198327
  const func = nthCheck(rule);
197617
198328
  if (func === import_boolbase3.default.falseFunc)
197618
198329
  return import_boolbase3.default.falseFunc;
@@ -197623,7 +198334,7 @@ var filters = {
197623
198334
  let pos = 0;
197624
198335
  for (let i2 = 0;i2 < siblings.length; i2++) {
197625
198336
  const currentSibling = siblings[i2];
197626
- if (equals(elem, currentSibling))
198337
+ if (equals2(elem, currentSibling))
197627
198338
  break;
197628
198339
  if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === adapter.getName(elem)) {
197629
198340
  pos++;
@@ -197632,7 +198343,7 @@ var filters = {
197632
198343
  return func(pos) && next(elem);
197633
198344
  };
197634
198345
  },
197635
- "nth-last-of-type"(next, rule, { adapter, equals }) {
198346
+ "nth-last-of-type"(next, rule, { adapter, equals: equals2 }) {
197636
198347
  const func = nthCheck(rule);
197637
198348
  if (func === import_boolbase3.default.falseFunc)
197638
198349
  return import_boolbase3.default.falseFunc;
@@ -197643,7 +198354,7 @@ var filters = {
197643
198354
  let pos = 0;
197644
198355
  for (let i2 = siblings.length - 1;i2 >= 0; i2--) {
197645
198356
  const currentSibling = siblings[i2];
197646
- if (equals(elem, currentSibling))
198357
+ if (equals2(elem, currentSibling))
197647
198358
  break;
197648
198359
  if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === adapter.getName(elem)) {
197649
198360
  pos++;
@@ -197659,12 +198370,12 @@ var filters = {
197659
198370
  };
197660
198371
  },
197661
198372
  scope(next, rule, options, context) {
197662
- const { equals } = options;
198373
+ const { equals: equals2 } = options;
197663
198374
  if (!context || context.length === 0) {
197664
198375
  return filters["root"](next, rule, options);
197665
198376
  }
197666
198377
  if (context.length === 1) {
197667
- return (elem) => equals(context[0], elem) && next(elem);
198378
+ return (elem) => equals2(context[0], elem) && next(elem);
197668
198379
  }
197669
198380
  return (elem) => context.includes(elem) && next(elem);
197670
198381
  },
@@ -197687,29 +198398,29 @@ var pseudos = {
197687
198398
  empty(elem, { adapter }) {
197688
198399
  return !adapter.getChildren(elem).some((elem2) => adapter.isTag(elem2) || adapter.getText(elem2) !== "");
197689
198400
  },
197690
- "first-child"(elem, { adapter, equals }) {
198401
+ "first-child"(elem, { adapter, equals: equals2 }) {
197691
198402
  if (adapter.prevElementSibling) {
197692
198403
  return adapter.prevElementSibling(elem) == null;
197693
198404
  }
197694
198405
  const firstChild = adapter.getSiblings(elem).find((elem2) => adapter.isTag(elem2));
197695
- return firstChild != null && equals(elem, firstChild);
198406
+ return firstChild != null && equals2(elem, firstChild);
197696
198407
  },
197697
- "last-child"(elem, { adapter, equals }) {
198408
+ "last-child"(elem, { adapter, equals: equals2 }) {
197698
198409
  const siblings = adapter.getSiblings(elem);
197699
198410
  for (let i2 = siblings.length - 1;i2 >= 0; i2--) {
197700
- if (equals(elem, siblings[i2]))
198411
+ if (equals2(elem, siblings[i2]))
197701
198412
  return true;
197702
198413
  if (adapter.isTag(siblings[i2]))
197703
198414
  break;
197704
198415
  }
197705
198416
  return false;
197706
198417
  },
197707
- "first-of-type"(elem, { adapter, equals }) {
198418
+ "first-of-type"(elem, { adapter, equals: equals2 }) {
197708
198419
  const siblings = adapter.getSiblings(elem);
197709
198420
  const elemName = adapter.getName(elem);
197710
198421
  for (let i2 = 0;i2 < siblings.length; i2++) {
197711
198422
  const currentSibling = siblings[i2];
197712
- if (equals(elem, currentSibling))
198423
+ if (equals2(elem, currentSibling))
197713
198424
  return true;
197714
198425
  if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === elemName) {
197715
198426
  break;
@@ -197717,12 +198428,12 @@ var pseudos = {
197717
198428
  }
197718
198429
  return false;
197719
198430
  },
197720
- "last-of-type"(elem, { adapter, equals }) {
198431
+ "last-of-type"(elem, { adapter, equals: equals2 }) {
197721
198432
  const siblings = adapter.getSiblings(elem);
197722
198433
  const elemName = adapter.getName(elem);
197723
198434
  for (let i2 = siblings.length - 1;i2 >= 0; i2--) {
197724
198435
  const currentSibling = siblings[i2];
197725
- if (equals(elem, currentSibling))
198436
+ if (equals2(elem, currentSibling))
197726
198437
  return true;
197727
198438
  if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === elemName) {
197728
198439
  break;
@@ -197730,12 +198441,12 @@ var pseudos = {
197730
198441
  }
197731
198442
  return false;
197732
198443
  },
197733
- "only-of-type"(elem, { adapter, equals }) {
198444
+ "only-of-type"(elem, { adapter, equals: equals2 }) {
197734
198445
  const elemName = adapter.getName(elem);
197735
- return adapter.getSiblings(elem).every((sibling) => equals(elem, sibling) || !adapter.isTag(sibling) || adapter.getName(sibling) !== elemName);
198446
+ return adapter.getSiblings(elem).every((sibling) => equals2(elem, sibling) || !adapter.isTag(sibling) || adapter.getName(sibling) !== elemName);
197736
198447
  },
197737
- "only-child"(elem, { adapter, equals }) {
197738
- return adapter.getSiblings(elem).every((sibling) => equals(elem, sibling) || !adapter.isTag(sibling));
198448
+ "only-child"(elem, { adapter, equals: equals2 }) {
198449
+ return adapter.getSiblings(elem).every((sibling) => equals2(elem, sibling) || !adapter.isTag(sibling));
197739
198450
  }
197740
198451
  };
197741
198452
  function verifyPseudoArgs(func, name, subselect, argIndex) {
@@ -197876,7 +198587,7 @@ function getElementParent(node, adapter) {
197876
198587
  return null;
197877
198588
  }
197878
198589
  function compileGeneralSelector(next, selector, options, context, compileToken2) {
197879
- const { adapter, equals } = options;
198590
+ const { adapter, equals: equals2 } = options;
197880
198591
  switch (selector.type) {
197881
198592
  case SelectorType.PseudoElement: {
197882
198593
  throw new Error("Pseudo-elements are not supported by css-select");
@@ -197960,7 +198671,7 @@ function compileGeneralSelector(next, selector, options, context, compileToken2)
197960
198671
  const siblings = adapter.getSiblings(elem);
197961
198672
  for (let i2 = 0;i2 < siblings.length; i2++) {
197962
198673
  const currentSibling = siblings[i2];
197963
- if (equals(elem, currentSibling))
198674
+ if (equals2(elem, currentSibling))
197964
198675
  break;
197965
198676
  if (adapter.isTag(currentSibling) && next(currentSibling)) {
197966
198677
  return true;
@@ -197981,7 +198692,7 @@ function compileGeneralSelector(next, selector, options, context, compileToken2)
197981
198692
  let lastElement;
197982
198693
  for (let i2 = 0;i2 < siblings.length; i2++) {
197983
198694
  const currentSibling = siblings[i2];
197984
- if (equals(elem, currentSibling))
198695
+ if (equals2(elem, currentSibling))
197985
198696
  break;
197986
198697
  if (adapter.isTag(currentSibling)) {
197987
198698
  lastElement = currentSibling;
@@ -201878,8 +202589,8 @@ var Arc = class extends Shape {
201878
202589
  }
201879
202590
  definiteIntegral(ymin = 0) {
201880
202591
  let f_arcs = this.breakToFunctional();
201881
- let area = f_arcs.reduce((acc, arc2) => acc + arc2.circularSegmentDefiniteIntegral(ymin), 0);
201882
- return area;
202592
+ let area2 = f_arcs.reduce((acc, arc2) => acc + arc2.circularSegmentDefiniteIntegral(ymin), 0);
202593
+ return area2;
201883
202594
  }
201884
202595
  circularSegmentDefiniteIntegral(ymin) {
201885
202596
  let segment2 = new Flatten.Segment(this.start, this.end);
@@ -202173,9 +202884,9 @@ var Edge = class {
202173
202884
  let largeArcFlag;
202174
202885
  let sweepFlag = arc2.counterClockwise ? "1" : "0";
202175
202886
  if (Flatten.Utils.EQ(arc2.sweep, 2 * Math.PI)) {
202176
- let sign = arc2.counterClockwise ? 1 : -1;
202177
- let halfArc1 = new Flatten.Arc(arc2.pc, arc2.r, arc2.startAngle, arc2.startAngle + sign * Math.PI, arc2.counterClockwise);
202178
- let halfArc2 = new Flatten.Arc(arc2.pc, arc2.r, arc2.startAngle + sign * Math.PI, arc2.endAngle, arc2.counterClockwise);
202887
+ let sign2 = arc2.counterClockwise ? 1 : -1;
202888
+ let halfArc1 = new Flatten.Arc(arc2.pc, arc2.r, arc2.startAngle, arc2.startAngle + sign2 * Math.PI, arc2.counterClockwise);
202889
+ let halfArc2 = new Flatten.Arc(arc2.pc, arc2.r, arc2.startAngle + sign2 * Math.PI, arc2.endAngle, arc2.counterClockwise);
202179
202890
  largeArcFlag = "0";
202180
202891
  return ` A${halfArc1.r},${halfArc1.r} 0 ${largeArcFlag},${sweepFlag} ${halfArc1.end.x},${halfArc1.end.y}
202181
202892
  A${halfArc2.r},${halfArc2.r} 0 ${largeArcFlag},${sweepFlag} ${halfArc2.end.x},${halfArc2.end.y}`;
@@ -202426,10 +203137,10 @@ var Face = class _Face extends CircularLinkedList {
202426
203137
  }
202427
203138
  orientation() {
202428
203139
  if (this._orientation === undefined) {
202429
- let area = this.signedArea();
202430
- if (Flatten.Utils.EQ_0(area)) {
203140
+ let area2 = this.signedArea();
203141
+ if (Flatten.Utils.EQ_0(area2)) {
202431
203142
  this._orientation = ORIENTATION.NOT_ORIENTABLE;
202432
- } else if (Flatten.Utils.LT(area, 0)) {
203143
+ } else if (Flatten.Utils.LT(area2, 0)) {
202433
203144
  this._orientation = ORIENTATION.CCW;
202434
203145
  } else {
202435
203146
  this._orientation = ORIENTATION.CW;
@@ -206453,16 +207164,16 @@ function simplifyCollinearSegments(outline, tolerance = 0.0000000001) {
206453
207164
  }
206454
207165
  return simplified;
206455
207166
  }
206456
- function signedArea(points) {
206457
- let area = 0;
207167
+ function signedArea2(points) {
207168
+ let area2 = 0;
206458
207169
  for (let i2 = 0;i2 < points.length; i2++) {
206459
207170
  const j22 = (i2 + 1) % points.length;
206460
207171
  const pi22 = points[i2];
206461
207172
  const pj = points[j22];
206462
- area += pi22.x * pj.y;
206463
- area -= pj.x * pi22.y;
207173
+ area2 += pi22.x * pj.y;
207174
+ area2 -= pj.x * pi22.y;
206464
207175
  }
206465
- return area / 2;
207176
+ return area2 / 2;
206466
207177
  }
206467
207178
  function extractFacePoints(face) {
206468
207179
  const points = [];
@@ -206485,10 +207196,10 @@ function parseFlattenPolygonLoops(polygon2) {
206485
207196
  const points = extractFacePoints(face);
206486
207197
  if (points.length < 3)
206487
207198
  continue;
206488
- const area = signedArea(points);
206489
- if (area > 0) {
207199
+ const area2 = signedArea2(points);
207200
+ if (area2 > 0) {
206490
207201
  obstacleFreeLoops.push(points);
206491
- } else if (area < 0) {
207202
+ } else if (area2 < 0) {
206492
207203
  obstacleContainingLoops.push(points);
206493
207204
  }
206494
207205
  }
@@ -207245,7 +207956,7 @@ function getOutwardNormal(outlineSegment, ccwFullOutline) {
207245
207956
  verts.push(seg[1]);
207246
207957
  }
207247
207958
  }
207248
- const signedArea2 = (() => {
207959
+ const signedArea22 = (() => {
207249
207960
  let a2 = 0;
207250
207961
  for (let i2 = 0;i2 < verts.length; i2++) {
207251
207962
  const v12 = verts[i2];
@@ -207254,8 +207965,8 @@ function getOutwardNormal(outlineSegment, ccwFullOutline) {
207254
207965
  }
207255
207966
  return a2 / 2;
207256
207967
  })();
207257
- const geometricOutward = signedArea2 > 0 ? right : left;
207258
- const isCW = signedArea2 < 0;
207968
+ const geometricOutward = signedArea22 > 0 ? right : left;
207969
+ const isCW = signedArea22 < 0;
207259
207970
  if (isCW) {
207260
207971
  return { x: -geometricOutward.x, y: -geometricOutward.y };
207261
207972
  }
@@ -207460,9 +208171,9 @@ var LargestRectOutsideOutlineFromPointSolver = class extends BaseSolver2 {
207460
208171
  if (xi22 === undefined || xj1 === undefined)
207461
208172
  continue;
207462
208173
  const width = xj1 - xi22;
207463
- const area = width * height;
207464
- if (area > bestArea) {
207465
- bestArea = area;
208174
+ const area2 = width * height;
208175
+ if (area2 > bestArea) {
208176
+ bestArea = area2;
207466
208177
  best = { x: xi22, y: maxBot, w: width, h: height };
207467
208178
  }
207468
208179
  }
@@ -207706,14 +208417,14 @@ var OutlineSegmentCandidatePointSolver = class extends BaseSolver2 {
207706
208417
  y: this.largestRectMidPoint.y + outwardNormal.y * 0.0001
207707
208418
  };
207708
208419
  const outlinePoints = this.ccwFullOutline.flatMap(([p3]) => p3);
207709
- let signedArea2 = 0;
208420
+ let signedArea22 = 0;
207710
208421
  for (let i2 = 0;i2 < outlinePoints.length; i2++) {
207711
208422
  const p122 = outlinePoints[i2];
207712
208423
  const p222 = outlinePoints[(i2 + 1) % outlinePoints.length];
207713
- signedArea2 += p122.x * p222.y - p222.x * p122.y;
208424
+ signedArea22 += p122.x * p222.y - p222.x * p122.y;
207714
208425
  }
207715
- signedArea2 /= 2;
207716
- const isCW = signedArea2 < 0;
208426
+ signedArea22 /= 2;
208427
+ const isCW = signedArea22 < 0;
207717
208428
  const rectSearchMode = isCW ? "inside" : "outside";
207718
208429
  const largestRectSolverParams = {
207719
208430
  ccwFullOutline: outlinePoints,
@@ -208762,26 +209473,26 @@ function getPolygonCentroid(points) {
208762
209473
  const sumY = points.reduce((sum, p3) => sum + p3.y, 0);
208763
209474
  return { x: sumX / points.length, y: sumY / points.length };
208764
209475
  }
208765
- let signedArea2 = 0;
209476
+ let signedArea22 = 0;
208766
209477
  let cx2 = 0;
208767
209478
  let cy2 = 0;
208768
209479
  for (let i2 = 0;i2 < points.length; i2++) {
208769
209480
  const p12 = points[i2];
208770
209481
  const p22 = points[(i2 + 1) % points.length];
208771
209482
  const crossProduct = p12.x * p22.y - p22.x * p12.y;
208772
- signedArea2 += crossProduct;
209483
+ signedArea22 += crossProduct;
208773
209484
  cx2 += (p12.x + p22.x) * crossProduct;
208774
209485
  cy2 += (p12.y + p22.y) * crossProduct;
208775
209486
  }
208776
- signedArea2 *= 0.5;
208777
- const area = Math.abs(signedArea2);
208778
- if (area < 0.0000000001) {
209487
+ signedArea22 *= 0.5;
209488
+ const area2 = Math.abs(signedArea22);
209489
+ if (area2 < 0.0000000001) {
208779
209490
  const sumX = points.reduce((sum, p3) => sum + p3.x, 0);
208780
209491
  const sumY = points.reduce((sum, p3) => sum + p3.y, 0);
208781
209492
  return { x: sumX / points.length, y: sumY / points.length };
208782
209493
  }
208783
- cx2 /= 6 * signedArea2;
208784
- cy2 /= 6 * signedArea2;
209494
+ cx2 /= 6 * signedArea22;
209495
+ cy2 /= 6 * signedArea22;
208785
209496
  return { x: cx2, y: cy2 };
208786
209497
  }
208787
209498
  var PackSolver2 = class extends BaseSolver2 {
@@ -218496,14 +219207,14 @@ var BJTCommand = class {
218496
219207
  this.props = props;
218497
219208
  }
218498
219209
  toSpiceString() {
218499
- const { name, collector, base, emitter, substrate, model, area } = this.props;
219210
+ const { name, collector, base, emitter, substrate, model, area: area2 } = this.props;
218500
219211
  let spiceString = `Q${name} ${collector} ${base} ${emitter}`;
218501
219212
  if (substrate) {
218502
219213
  spiceString += ` ${substrate}`;
218503
219214
  }
218504
219215
  spiceString += ` ${model}`;
218505
- if (area) {
218506
- spiceString += ` ${area}`;
219216
+ if (area2) {
219217
+ spiceString += ` ${area2}`;
218507
219218
  }
218508
219219
  return spiceString;
218509
219220
  }
@@ -218562,10 +219273,10 @@ var DiodeCommand = class {
218562
219273
  this.props = props;
218563
219274
  }
218564
219275
  toSpiceString() {
218565
- const { name, positiveNode, negativeNode, model, area } = this.props;
219276
+ const { name, positiveNode, negativeNode, model, area: area2 } = this.props;
218566
219277
  let spiceString = `D${name} ${positiveNode} ${negativeNode} ${model}`;
218567
- if (area) {
218568
- spiceString += ` ${area}`;
219278
+ if (area2) {
219279
+ spiceString += ` ${area2}`;
218569
219280
  }
218570
219281
  return spiceString;
218571
219282
  }
@@ -223381,14 +224092,14 @@ var PrimitiveComponent2 = class extends Renderable {
223381
224092
  computePcbPropsTransform() {
223382
224093
  const rotation4 = this._getPcbRotationBeforeLayout() ?? 0;
223383
224094
  const { pcbX, pcbY } = this.getResolvedPcbPositionProp();
223384
- const matrix2 = compose7(translate7(pcbX, pcbY), rotate9(rotation4 * Math.PI / 180));
224095
+ const matrix2 = compose7(translate7(pcbX, pcbY), rotate10(rotation4 * Math.PI / 180));
223385
224096
  return matrix2;
223386
224097
  }
223387
224098
  _computePcbGlobalTransformBeforeLayout() {
223388
224099
  const manualPlacement = this.getSubcircuit()._getPcbManualPlacementForComponent(this);
223389
224100
  if (manualPlacement && this.props.pcbX === undefined && this.props.pcbY === undefined) {
223390
224101
  const rotation4 = this._getPcbRotationBeforeLayout() ?? 0;
223391
- return compose7(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity6(), compose7(translate7(manualPlacement.x, manualPlacement.y), rotate9(rotation4 * Math.PI / 180)));
224102
+ return compose7(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity6(), compose7(translate7(manualPlacement.x, manualPlacement.y), rotate10(rotation4 * Math.PI / 180)));
223392
224103
  }
223393
224104
  if (this.isPcbPrimitive) {
223394
224105
  const primitiveContainer = this.getPrimitiveContainer();
@@ -232748,7 +233459,7 @@ var extractPcbPrimitivesFromCircuitJson = ({
232748
233459
  }) => {
232749
233460
  const componentCenter = pcbComponent.center || { x: 0, y: 0 };
232750
233461
  const componentRotation = pcbComponent.rotation || 0;
232751
- const absoluteToComponentRelativeTransform = inverse(compose7(translate7(componentCenter.x, componentCenter.y), rotate9(componentRotation * Math.PI / 180)));
233462
+ const absoluteToComponentRelativeTransform = inverse(compose7(translate7(componentCenter.x, componentCenter.y), rotate10(componentRotation * Math.PI / 180)));
232752
233463
  const relativeElements = db.toArray().filter((elm) => ("pcb_component_id" in elm) && elm.pcb_component_id === pcbComponent.pcb_component_id);
232753
233464
  const clonedRelativeElements = structuredClone(relativeElements);
232754
233465
  transformPCBElements(clonedRelativeElements, absoluteToComponentRelativeTransform);
@@ -234776,7 +235487,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
234776
235487
  if (!member)
234777
235488
  continue;
234778
235489
  const originalCenter2 = member.center;
234779
- const transformMatrix2 = compose7(group._computePcbGlobalTransformBeforeLayout(), translate7(center2.x + rotatedRel.x, center2.y + rotatedRel.y), rotate9(angleRad), translate7(-originalCenter2.x, -originalCenter2.y));
235490
+ const transformMatrix2 = compose7(group._computePcbGlobalTransformBeforeLayout(), translate7(center2.x + rotatedRel.x, center2.y + rotatedRel.y), rotate10(angleRad), translate7(-originalCenter2.x, -originalCenter2.y));
234780
235491
  const related = db.toArray().filter((elm) => ("pcb_component_id" in elm) && elm.pcb_component_id === memberId);
234781
235492
  transformPCBElements(related, transformMatrix2);
234782
235493
  updateCadRotation({
@@ -234801,7 +235512,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
234801
235512
  }
234802
235513
  const originalCenter2 = pcbComponent.center;
234803
235514
  const rotationDegrees2 = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
234804
- const transformMatrix2 = compose7(group._computePcbGlobalTransformBeforeLayout(), translate7(center2.x, center2.y), rotate9(rotationDegrees2 * Math.PI / 180), translate7(-originalCenter2.x, -originalCenter2.y));
235515
+ const transformMatrix2 = compose7(group._computePcbGlobalTransformBeforeLayout(), translate7(center2.x, center2.y), rotate10(rotationDegrees2 * Math.PI / 180), translate7(-originalCenter2.x, -originalCenter2.y));
234805
235516
  const related = db.toArray().filter((elm) => ("pcb_component_id" in elm) && elm.pcb_component_id === componentId);
234806
235517
  transformPCBElements(related, transformMatrix2);
234807
235518
  updateCadRotation({
@@ -234817,7 +235528,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
234817
235528
  continue;
234818
235529
  const originalCenter = pcbGroup.center;
234819
235530
  const rotationDegrees = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
234820
- const transformMatrix = compose7(group._computePcbGlobalTransformBeforeLayout(), translate7(center2.x, center2.y), rotate9(rotationDegrees * Math.PI / 180), translate7(-originalCenter.x, -originalCenter.y));
235531
+ const transformMatrix = compose7(group._computePcbGlobalTransformBeforeLayout(), translate7(center2.x, center2.y), rotate10(rotationDegrees * Math.PI / 180), translate7(-originalCenter.x, -originalCenter.y));
234821
235532
  const relatedElements = db.toArray().filter((elm) => {
234822
235533
  if ("source_group_id" in elm && elm.source_group_id) {
234823
235534
  if (elm.source_group_id === componentId) {
@@ -236372,15 +237083,15 @@ function nearlyEqual(a2, b22, tol = TOL2) {
236372
237083
  function pointEq(a2, b22, tol = TOL2) {
236373
237084
  return nearlyEqual(a2.x, b22.x, tol) && nearlyEqual(a2.y, b22.y, tol);
236374
237085
  }
236375
- function onSegment3(p3, a2, b22, tol = TOL2) {
237086
+ function onSegment32(p3, a2, b22, tol = TOL2) {
236376
237087
  const minX = Math.min(a2.x, b22.x) - tol;
236377
237088
  const maxX = Math.max(a2.x, b22.x) + tol;
236378
237089
  const minY = Math.min(a2.y, b22.y) - tol;
236379
237090
  const maxY = Math.max(a2.y, b22.y) + tol;
236380
237091
  if (p3.x < minX || p3.x > maxX || p3.y < minY || p3.y > maxY)
236381
237092
  return false;
236382
- const area = Math.abs((b22.x - a2.x) * (p3.y - a2.y) - (b22.y - a2.y) * (p3.x - a2.x));
236383
- return area <= tol;
237093
+ const area2 = Math.abs((b22.x - a2.x) * (p3.y - a2.y) - (b22.y - a2.y) * (p3.x - a2.x));
237094
+ return area2 <= tol;
236384
237095
  }
236385
237096
  function dedupePoints(points, tol = TOL2) {
236386
237097
  const map = /* @__PURE__ */ new Map;
@@ -236480,7 +237191,7 @@ function computeJunctions(traces, opts = {}) {
236480
237191
  }
236481
237192
  for (const pa22 of AEnds) {
236482
237193
  for (const eB of B32.edges) {
236483
- if (onSegment3(pa22, eB.from, eB.to, tol)) {
237194
+ if (onSegment32(pa22, eB.from, eB.to, tol)) {
236484
237195
  const aEdgesAtP = incidentEdgesAtPoint(A22, pa22, tol);
236485
237196
  const hasCorner = aEdgesAtP.some((eA) => !isParallel(eA, eB, tol));
236486
237197
  const aCorner = getCornerOrientationAtPoint(A22, pa22, tol);
@@ -236497,7 +237208,7 @@ function computeJunctions(traces, opts = {}) {
236497
237208
  }
236498
237209
  for (const pb of BEnds) {
236499
237210
  for (const eA of A22.edges) {
236500
- if (onSegment3(pb, eA.from, eA.to, tol)) {
237211
+ if (onSegment32(pb, eA.from, eA.to, tol)) {
236501
237212
  const bEdgesAtP = incidentEdgesAtPoint(B32, pb, tol);
236502
237213
  const hasCorner = bEdgesAtP.some((eB) => !isParallel(eA, eB, tol));
236503
237214
  const bCorner = getCornerOrientationAtPoint(B32, pb, tol);
@@ -239947,9 +240658,9 @@ function generatePanelTabsAndMouseBites(boards, options) {
239947
240658
  boardDimensions.push(Math.min(board.width, board.height));
239948
240659
  } else if (board.outline && board.outline.length > 0) {
239949
240660
  const outlinePolygon = new Polygon$1(board.outline.map((p3) => point4(p3.x, p3.y)));
239950
- const area = Math.abs(outlinePolygon.area());
239951
- if (area > 0) {
239952
- boardDimensions.push(Math.sqrt(area));
240661
+ const area2 = Math.abs(outlinePolygon.area());
240662
+ if (area2 > 0) {
240663
+ boardDimensions.push(Math.sqrt(area2));
239953
240664
  }
239954
240665
  }
239955
240666
  }
@@ -241994,8 +242705,8 @@ var isPointInRing = (point6, ring2) => {
241994
242705
  for (const current2 of ring2) {
241995
242706
  if (isPointOnSegment2(point6, previous, current2))
241996
242707
  return true;
241997
- const intersects2 = current2.y > point6.y !== previous.y > point6.y && point6.x < (previous.x - current2.x) * (point6.y - current2.y) / (previous.y - current2.y) + current2.x;
241998
- if (intersects2)
242708
+ const intersects3 = current2.y > point6.y !== previous.y > point6.y && point6.x < (previous.x - current2.x) * (point6.y - current2.y) / (previous.y - current2.y) + current2.x;
242709
+ if (intersects3)
241999
242710
  inside2 = !inside2;
242000
242711
  previous = current2;
242001
242712
  }
@@ -244191,8 +244902,8 @@ var clamp012 = (value) => Math.max(0, Math.min(1, value));
244191
244902
  var roundProbability = (value) => Number.parseFloat(value.toFixed(3));
244192
244903
  var getNodeDensity = (node) => {
244193
244904
  const layerCount = Math.max(node.availableZ?.length ?? 1, 1);
244194
- const area = Math.max(node.width * node.height, 0.001);
244195
- return node.portPoints.length / (area * layerCount);
244905
+ const area2 = Math.max(node.width * node.height, 0.001);
244906
+ return node.portPoints.length / (area2 * layerCount);
244196
244907
  };
244197
244908
  var getProbabilityOfFailure = (node, maxDensity, maxPortPointCount) => {
244198
244909
  const crampedPortPointCount = node.portPoints.filter((portPoint) => isCrampedPortPoint(portPoint.portPointId)).length;
@@ -252724,7 +253435,7 @@ import {
252724
253435
  applyToPoint as applyToPoint26,
252725
253436
  compose as compose9,
252726
253437
  identity as identity8,
252727
- rotate as rotate11,
253438
+ rotate as rotate12,
252728
253439
  translate as translate9
252729
253440
  } from "transformation-matrix";
252730
253441
  var defineExcellonDrillCommand = ({
@@ -254111,7 +254822,7 @@ var convertSoupToGerberCommands = (soup, opts = {}) => {
254111
254822
  }
254112
254823
  if (rotation4) {
254113
254824
  const rad = rotation4 * Math.PI / 180;
254114
- transforms.push(translate9(cx2, cy2), rotate11(rad), translate9(-cx2, -cy2));
254825
+ transforms.push(translate9(cx2, cy2), rotate12(rad), translate9(-cx2, -cy2));
254115
254826
  }
254116
254827
  const transformMatrix = transforms.length > 0 ? compose9(...transforms) : undefined;
254117
254828
  const applyTransform = (point5) => transformMatrix ? applyToPoint26(transformMatrix, point5) : point5;
@@ -254292,7 +255003,7 @@ var convertSoupToGerberCommands = (soup, opts = {}) => {
254292
255003
  let transformMatrix = identity8();
254293
255004
  if (rotation4) {
254294
255005
  const angle_rad = rotation4 * Math.PI / 180;
254295
- transformMatrix = rotate11(angle_rad);
255006
+ transformMatrix = rotate12(angle_rad);
254296
255007
  }
254297
255008
  transformMatrix = compose9(translate9(center2.x, center2.y), transformMatrix);
254298
255009
  const transformedPoints = points.map((p3) => applyToPoint26(transformMatrix, p3));
@@ -254653,7 +255364,7 @@ var convertSoupToGerberCommands = (soup, opts = {}) => {
254653
255364
  let transformMatrix2 = identity8();
254654
255365
  if (rotation4) {
254655
255366
  const angle_rad = rotation4 * Math.PI / 180;
254656
- transformMatrix2 = rotate11(angle_rad);
255367
+ transformMatrix2 = rotate12(angle_rad);
254657
255368
  }
254658
255369
  return compose9(translate9(center2.x, center2.y), transformMatrix2);
254659
255370
  };
@@ -272443,7 +273154,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
272443
273154
  if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => (key in env2))) {
272444
273155
  return 3;
272445
273156
  }
272446
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env2)) || env2.CI_NAME === "codeship") {
273157
+ if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign2) => (sign2 in env2)) || env2.CI_NAME === "codeship") {
272447
273158
  return 1;
272448
273159
  }
272449
273160
  return min;