@tscircuit/cli 0.1.1161 → 0.1.1163

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
@@ -10751,6 +10751,7 @@ var require_constants3 = __commonJS((exports2, module2) => {
10751
10751
  var path2 = __require("path");
10752
10752
  var WIN_SLASH = "\\\\/";
10753
10753
  var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
10754
+ var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
10754
10755
  var DOT_LITERAL = "\\.";
10755
10756
  var PLUS_LITERAL = "\\+";
10756
10757
  var QMARK_LITERAL = "\\?";
@@ -10798,6 +10799,7 @@ var require_constants3 = __commonJS((exports2, module2) => {
10798
10799
  END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
10799
10800
  };
10800
10801
  var POSIX_REGEX_SOURCE = {
10802
+ __proto__: null,
10801
10803
  alnum: "a-zA-Z0-9",
10802
10804
  alpha: "a-zA-Z",
10803
10805
  ascii: "\\x00-\\x7F",
@@ -10814,6 +10816,7 @@ var require_constants3 = __commonJS((exports2, module2) => {
10814
10816
  xdigit: "A-Fa-f0-9"
10815
10817
  };
10816
10818
  module2.exports = {
10819
+ DEFAULT_MAX_EXTGLOB_RECURSION,
10817
10820
  MAX_LENGTH: 1024 * 64,
10818
10821
  POSIX_REGEX_SOURCE,
10819
10822
  REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
@@ -10823,6 +10826,7 @@ var require_constants3 = __commonJS((exports2, module2) => {
10823
10826
  REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
10824
10827
  REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
10825
10828
  REPLACEMENTS: {
10829
+ __proto__: null,
10826
10830
  "***": "*",
10827
10831
  "**/**": "**",
10828
10832
  "**/**/**": "**"
@@ -11288,6 +11292,213 @@ var require_parse3 = __commonJS((exports2, module2) => {
11288
11292
  var syntaxError = (type, char) => {
11289
11293
  return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
11290
11294
  };
11295
+ var splitTopLevel = (input) => {
11296
+ const parts = [];
11297
+ let bracket = 0;
11298
+ let paren = 0;
11299
+ let quote = 0;
11300
+ let value = "";
11301
+ let escaped = false;
11302
+ for (const ch of input) {
11303
+ if (escaped === true) {
11304
+ value += ch;
11305
+ escaped = false;
11306
+ continue;
11307
+ }
11308
+ if (ch === "\\") {
11309
+ value += ch;
11310
+ escaped = true;
11311
+ continue;
11312
+ }
11313
+ if (ch === '"') {
11314
+ quote = quote === 1 ? 0 : 1;
11315
+ value += ch;
11316
+ continue;
11317
+ }
11318
+ if (quote === 0) {
11319
+ if (ch === "[") {
11320
+ bracket++;
11321
+ } else if (ch === "]" && bracket > 0) {
11322
+ bracket--;
11323
+ } else if (bracket === 0) {
11324
+ if (ch === "(") {
11325
+ paren++;
11326
+ } else if (ch === ")" && paren > 0) {
11327
+ paren--;
11328
+ } else if (ch === "|" && paren === 0) {
11329
+ parts.push(value);
11330
+ value = "";
11331
+ continue;
11332
+ }
11333
+ }
11334
+ }
11335
+ value += ch;
11336
+ }
11337
+ parts.push(value);
11338
+ return parts;
11339
+ };
11340
+ var isPlainBranch = (branch) => {
11341
+ let escaped = false;
11342
+ for (const ch of branch) {
11343
+ if (escaped === true) {
11344
+ escaped = false;
11345
+ continue;
11346
+ }
11347
+ if (ch === "\\") {
11348
+ escaped = true;
11349
+ continue;
11350
+ }
11351
+ if (/[?*+@!()[\]{}]/.test(ch)) {
11352
+ return false;
11353
+ }
11354
+ }
11355
+ return true;
11356
+ };
11357
+ var normalizeSimpleBranch = (branch) => {
11358
+ let value = branch.trim();
11359
+ let changed = true;
11360
+ while (changed === true) {
11361
+ changed = false;
11362
+ if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
11363
+ value = value.slice(2, -1);
11364
+ changed = true;
11365
+ }
11366
+ }
11367
+ if (!isPlainBranch(value)) {
11368
+ return;
11369
+ }
11370
+ return value.replace(/\\(.)/g, "$1");
11371
+ };
11372
+ var hasRepeatedCharPrefixOverlap = (branches) => {
11373
+ const values = branches.map(normalizeSimpleBranch).filter(Boolean);
11374
+ for (let i = 0;i < values.length; i++) {
11375
+ for (let j = i + 1;j < values.length; j++) {
11376
+ const a = values[i];
11377
+ const b = values[j];
11378
+ const char = a[0];
11379
+ if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
11380
+ continue;
11381
+ }
11382
+ if (a === b || a.startsWith(b) || b.startsWith(a)) {
11383
+ return true;
11384
+ }
11385
+ }
11386
+ }
11387
+ return false;
11388
+ };
11389
+ var parseRepeatedExtglob = (pattern, requireEnd = true) => {
11390
+ if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
11391
+ return;
11392
+ }
11393
+ let bracket = 0;
11394
+ let paren = 0;
11395
+ let quote = 0;
11396
+ let escaped = false;
11397
+ for (let i = 1;i < pattern.length; i++) {
11398
+ const ch = pattern[i];
11399
+ if (escaped === true) {
11400
+ escaped = false;
11401
+ continue;
11402
+ }
11403
+ if (ch === "\\") {
11404
+ escaped = true;
11405
+ continue;
11406
+ }
11407
+ if (ch === '"') {
11408
+ quote = quote === 1 ? 0 : 1;
11409
+ continue;
11410
+ }
11411
+ if (quote === 1) {
11412
+ continue;
11413
+ }
11414
+ if (ch === "[") {
11415
+ bracket++;
11416
+ continue;
11417
+ }
11418
+ if (ch === "]" && bracket > 0) {
11419
+ bracket--;
11420
+ continue;
11421
+ }
11422
+ if (bracket > 0) {
11423
+ continue;
11424
+ }
11425
+ if (ch === "(") {
11426
+ paren++;
11427
+ continue;
11428
+ }
11429
+ if (ch === ")") {
11430
+ paren--;
11431
+ if (paren === 0) {
11432
+ if (requireEnd === true && i !== pattern.length - 1) {
11433
+ return;
11434
+ }
11435
+ return {
11436
+ type: pattern[0],
11437
+ body: pattern.slice(2, i),
11438
+ end: i
11439
+ };
11440
+ }
11441
+ }
11442
+ }
11443
+ };
11444
+ var getStarExtglobSequenceOutput = (pattern) => {
11445
+ let index = 0;
11446
+ const chars = [];
11447
+ while (index < pattern.length) {
11448
+ const match = parseRepeatedExtglob(pattern.slice(index), false);
11449
+ if (!match || match.type !== "*") {
11450
+ return;
11451
+ }
11452
+ const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
11453
+ if (branches.length !== 1) {
11454
+ return;
11455
+ }
11456
+ const branch = normalizeSimpleBranch(branches[0]);
11457
+ if (!branch || branch.length !== 1) {
11458
+ return;
11459
+ }
11460
+ chars.push(branch);
11461
+ index += match.end + 1;
11462
+ }
11463
+ if (chars.length < 1) {
11464
+ return;
11465
+ }
11466
+ const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
11467
+ return `${source}*`;
11468
+ };
11469
+ var repeatedExtglobRecursion = (pattern) => {
11470
+ let depth = 0;
11471
+ let value = pattern.trim();
11472
+ let match = parseRepeatedExtglob(value);
11473
+ while (match) {
11474
+ depth++;
11475
+ value = match.body.trim();
11476
+ match = parseRepeatedExtglob(value);
11477
+ }
11478
+ return depth;
11479
+ };
11480
+ var analyzeRepeatedExtglob = (body, options) => {
11481
+ if (options.maxExtglobRecursion === false) {
11482
+ return { risky: false };
11483
+ }
11484
+ const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
11485
+ const branches = splitTopLevel(body).map((branch) => branch.trim());
11486
+ if (branches.length > 1) {
11487
+ if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
11488
+ return { risky: true };
11489
+ }
11490
+ }
11491
+ for (const branch of branches) {
11492
+ const safeOutput = getStarExtglobSequenceOutput(branch);
11493
+ if (safeOutput) {
11494
+ return { risky: true, safeOutput };
11495
+ }
11496
+ if (repeatedExtglobRecursion(branch) > max) {
11497
+ return { risky: true };
11498
+ }
11499
+ }
11500
+ return { risky: false };
11501
+ };
11291
11502
  var parse = (input, options) => {
11292
11503
  if (typeof input !== "string") {
11293
11504
  throw new TypeError("Expected a string");
@@ -11420,6 +11631,8 @@ var require_parse3 = __commonJS((exports2, module2) => {
11420
11631
  token.prev = prev;
11421
11632
  token.parens = state.parens;
11422
11633
  token.output = state.output;
11634
+ token.startIndex = state.index;
11635
+ token.tokensIndex = tokens.length;
11423
11636
  const output = (opts.capture ? "(" : "") + token.open;
11424
11637
  increment("parens");
11425
11638
  push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
@@ -11427,6 +11640,26 @@ var require_parse3 = __commonJS((exports2, module2) => {
11427
11640
  extglobs.push(token);
11428
11641
  };
11429
11642
  const extglobClose = (token) => {
11643
+ const literal = input.slice(token.startIndex, state.index + 1);
11644
+ const body = input.slice(token.startIndex + 2, state.index);
11645
+ const analysis = analyzeRepeatedExtglob(body, opts);
11646
+ if ((token.type === "plus" || token.type === "star") && analysis.risky) {
11647
+ const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : undefined;
11648
+ const open = tokens[token.tokensIndex];
11649
+ open.type = "text";
11650
+ open.value = literal;
11651
+ open.output = safeOutput || utils.escapeRegex(literal);
11652
+ for (let i = token.tokensIndex + 1;i < tokens.length; i++) {
11653
+ tokens[i].value = "";
11654
+ tokens[i].output = "";
11655
+ delete tokens[i].suffix;
11656
+ }
11657
+ state.output = token.output + open.output;
11658
+ state.backtrack = true;
11659
+ push({ type: "paren", extglob: true, value, output: "" });
11660
+ decrement("parens");
11661
+ return;
11662
+ }
11430
11663
  let output = token.close + (opts.capture ? ")" : "");
11431
11664
  let rest;
11432
11665
  if (token.type === "negate") {
@@ -34156,7 +34389,7 @@ function parseAndConvertSiUnit(v3) {
34156
34389
  value: conversionFactor * Number.parseFloat(numberPart)
34157
34390
  };
34158
34391
  }
34159
- function applyToPoint19(matrix, point2) {
34392
+ function applyToPoint20(matrix, point2) {
34160
34393
  return Array.isArray(point2) ? [
34161
34394
  matrix.a * point2[0] + matrix.c * point2[1] + matrix.e,
34162
34395
  matrix.b * point2[0] + matrix.d * point2[1] + matrix.f
@@ -36772,25 +37005,25 @@ var __create3, __defProp3, __getOwnPropDesc2, __getOwnPropNames3, __getProtoOf3,
36772
37005
  throw new Error(`Invalid sideOrDir: ${sideOrDir}`);
36773
37006
  }, transformSchematicElement = (elm, matrix) => {
36774
37007
  if (elm.type === "schematic_component") {
36775
- elm.center = applyToPoint19(matrix, elm.center);
37008
+ elm.center = applyToPoint20(matrix, elm.center);
36776
37009
  } else if (elm.type === "schematic_port") {
36777
- elm.center = applyToPoint19(matrix, elm.center);
37010
+ elm.center = applyToPoint20(matrix, elm.center);
36778
37011
  if (elm.facing_direction) {
36779
37012
  elm.facing_direction = rotateDirection(elm.facing_direction, -(Math.atan2(matrix.b, matrix.a) / Math.PI) * 2);
36780
37013
  }
36781
37014
  } else if (elm.type === "schematic_text") {
36782
- elm.position = applyToPoint19(matrix, elm.position);
37015
+ elm.position = applyToPoint20(matrix, elm.position);
36783
37016
  } else if (elm.type === "schematic_trace") {
36784
37017
  const anyElm = elm;
36785
37018
  anyElm.route = (anyElm.route ?? []).map((rp2) => {
36786
- const tp2 = applyToPoint19(matrix, rp2);
37019
+ const tp2 = applyToPoint20(matrix, rp2);
36787
37020
  rp2.x = tp2.x;
36788
37021
  rp2.y = tp2.y;
36789
37022
  return rp2;
36790
37023
  });
36791
37024
  if (Array.isArray(anyElm.junctions)) {
36792
37025
  anyElm.junctions = anyElm.junctions.map((j2) => {
36793
- const tp2 = applyToPoint19(matrix, j2);
37026
+ const tp2 = applyToPoint20(matrix, j2);
36794
37027
  j2.x = tp2.x;
36795
37028
  j2.y = tp2.y;
36796
37029
  return j2;
@@ -36798,18 +37031,18 @@ var __create3, __defProp3, __getOwnPropDesc2, __getOwnPropNames3, __getProtoOf3,
36798
37031
  }
36799
37032
  if (Array.isArray(anyElm.edges)) {
36800
37033
  anyElm.edges = anyElm.edges.map((e2) => {
36801
- e2.from = applyToPoint19(matrix, e2.from);
36802
- e2.to = applyToPoint19(matrix, e2.to);
37034
+ e2.from = applyToPoint20(matrix, e2.from);
37035
+ e2.to = applyToPoint20(matrix, e2.to);
36803
37036
  return e2;
36804
37037
  });
36805
37038
  }
36806
37039
  } else if (elm.type === "schematic_box") {
36807
- const { x: x3, y } = applyToPoint19(matrix, { x: elm.x, y: elm.y });
37040
+ const { x: x3, y } = applyToPoint20(matrix, { x: elm.x, y: elm.y });
36808
37041
  elm.x = x3;
36809
37042
  elm.y = y;
36810
37043
  } else if (elm.type === "schematic_line") {
36811
- const { x: x12, y: y12 } = applyToPoint19(matrix, { x: elm.x1, y: elm.y1 });
36812
- const { x: x22, y: y22 } = applyToPoint19(matrix, { x: elm.x2, y: elm.y2 });
37044
+ const { x: x12, y: y12 } = applyToPoint20(matrix, { x: elm.x1, y: elm.y1 });
37045
+ const { x: x22, y: y22 } = applyToPoint20(matrix, { x: elm.x2, y: elm.y2 });
36813
37046
  elm.x1 = x12;
36814
37047
  elm.y1 = y12;
36815
37048
  elm.x2 = x22;
@@ -36822,7 +37055,7 @@ var __create3, __defProp3, __getOwnPropDesc2, __getOwnPropNames3, __getProtoOf3,
36822
37055
  const tsr = decomposeTSR(matrix);
36823
37056
  const flipPadWidthHeight = Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1;
36824
37057
  if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
36825
- const { x: x3, y } = applyToPoint19(matrix, {
37058
+ const { x: x3, y } = applyToPoint20(matrix, {
36826
37059
  x: Number(elm.x),
36827
37060
  y: Number(elm.y)
36828
37061
  });
@@ -36830,7 +37063,7 @@ var __create3, __defProp3, __getOwnPropDesc2, __getOwnPropNames3, __getProtoOf3,
36830
37063
  elm.y = y;
36831
37064
  if (elm.type === "pcb_smtpad" && elm.shape === "polygon" && Array.isArray(elm.points)) {
36832
37065
  elm.points = elm.points.map((point2) => {
36833
- const tp2 = applyToPoint19(matrix, { x: point2.x, y: point2.y });
37066
+ const tp2 = applyToPoint20(matrix, { x: point2.x, y: point2.y });
36834
37067
  return {
36835
37068
  x: tp2.x,
36836
37069
  y: tp2.y
@@ -36838,13 +37071,13 @@ var __create3, __defProp3, __getOwnPropDesc2, __getOwnPropNames3, __getProtoOf3,
36838
37071
  });
36839
37072
  }
36840
37073
  } else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
36841
- elm.center = applyToPoint19(matrix, elm.center);
37074
+ elm.center = applyToPoint20(matrix, elm.center);
36842
37075
  } else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text" || elm.type === "pcb_note_text") {
36843
- elm.anchor_position = applyToPoint19(matrix, elm.anchor_position);
37076
+ elm.anchor_position = applyToPoint20(matrix, elm.anchor_position);
36844
37077
  } else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_note_rect" || elm.type === "pcb_courtyard_rect" || elm.type === "pcb_courtyard_circle") {
36845
- elm.center = applyToPoint19(matrix, elm.center);
37078
+ elm.center = applyToPoint20(matrix, elm.center);
36846
37079
  } else if (elm.type === "pcb_component") {
36847
- elm.center = applyToPoint19(matrix, elm.center);
37080
+ elm.center = applyToPoint20(matrix, elm.center);
36848
37081
  elm.rotation = elm.rotation + tsr.rotation.angle / Math.PI * 180;
36849
37082
  elm.rotation = elm.rotation % 360;
36850
37083
  if (flipPadWidthHeight) {
@@ -36852,21 +37085,21 @@ var __create3, __defProp3, __getOwnPropDesc2, __getOwnPropNames3, __getProtoOf3,
36852
37085
  }
36853
37086
  } else if (elm.type === "pcb_courtyard_outline") {
36854
37087
  elm.outline = elm.outline.map((p) => {
36855
- const tp2 = applyToPoint19(matrix, p);
37088
+ const tp2 = applyToPoint20(matrix, p);
36856
37089
  p.x = tp2.x;
36857
37090
  p.y = tp2.y;
36858
37091
  return p;
36859
37092
  });
36860
37093
  } else if (elm.type === "pcb_courtyard_polygon") {
36861
37094
  elm.points = elm.points.map((p) => {
36862
- const tp2 = applyToPoint19(matrix, p);
37095
+ const tp2 = applyToPoint20(matrix, p);
36863
37096
  p.x = tp2.x;
36864
37097
  p.y = tp2.y;
36865
37098
  return p;
36866
37099
  });
36867
37100
  } else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path" || elm.type === "pcb_note_path") {
36868
37101
  elm.route = elm.route.map((rp2) => {
36869
- const tp2 = applyToPoint19(matrix, rp2);
37102
+ const tp2 = applyToPoint20(matrix, rp2);
36870
37103
  rp2.x = tp2.x;
36871
37104
  rp2.y = tp2.y;
36872
37105
  return rp2;
@@ -36874,14 +37107,14 @@ var __create3, __defProp3, __getOwnPropDesc2, __getOwnPropNames3, __getProtoOf3,
36874
37107
  } else if (elm.type === "pcb_silkscreen_line" || elm.type === "pcb_note_line") {
36875
37108
  const p12 = { x: elm.x1, y: elm.y1 };
36876
37109
  const p22 = { x: elm.x2, y: elm.y2 };
36877
- const p1t = applyToPoint19(matrix, p12);
36878
- const p2t = applyToPoint19(matrix, p22);
37110
+ const p1t = applyToPoint20(matrix, p12);
37111
+ const p2t = applyToPoint20(matrix, p22);
36879
37112
  elm.x1 = p1t.x;
36880
37113
  elm.y1 = p1t.y;
36881
37114
  elm.x2 = p2t.x;
36882
37115
  elm.y2 = p2t.y;
36883
37116
  } else if (elm.type === "cad_component") {
36884
- const newPos = applyToPoint19(matrix, {
37117
+ const newPos = applyToPoint20(matrix, {
36885
37118
  x: elm.position.x,
36886
37119
  y: elm.position.y
36887
37120
  });
@@ -46663,7 +46896,7 @@ function createSvgObjectsFromPcbTraceError(pcbTraceError, circuitJson, ctx) {
46663
46896
  return createSvgObjectsForViaTraceError(pcbTraceError, via, ctx);
46664
46897
  }
46665
46898
  if (pcbTraceError.center) {
46666
- const screenCenter = applyToPoint19(transform2, {
46899
+ const screenCenter = applyToPoint20(transform2, {
46667
46900
  x: pcbTraceError.center.x,
46668
46901
  y: pcbTraceError.center.y
46669
46902
  });
@@ -46708,11 +46941,11 @@ function createSvgObjectsFromPcbTraceError(pcbTraceError, circuitJson, ctx) {
46708
46941
  } else
46709
46942
  return [];
46710
46943
  }
46711
- const screenPort1 = applyToPoint19(transform2, {
46944
+ const screenPort1 = applyToPoint20(transform2, {
46712
46945
  x: port1.x,
46713
46946
  y: port1.y
46714
46947
  });
46715
- const screenPort2 = applyToPoint19(transform2, {
46948
+ const screenPort2 = applyToPoint20(transform2, {
46716
46949
  x: port2.x,
46717
46950
  y: port2.y
46718
46951
  });
@@ -46796,11 +47029,11 @@ function createSvgObjectsFromPcbTraceError(pcbTraceError, circuitJson, ctx) {
46796
47029
  function createSvgObjectsForViaTraceError(pcbTraceError, via, ctx) {
46797
47030
  const { transform: transform2 } = ctx;
46798
47031
  if (pcbTraceError.center && via) {
46799
- const screenCenter = applyToPoint19(transform2, {
47032
+ const screenCenter = applyToPoint20(transform2, {
46800
47033
  x: pcbTraceError.center.x,
46801
47034
  y: pcbTraceError.center.y
46802
47035
  });
46803
- const screenVia = applyToPoint19(transform2, {
47036
+ const screenVia = applyToPoint20(transform2, {
46804
47037
  x: via.x,
46805
47038
  y: via.y
46806
47039
  });
@@ -46974,7 +47207,7 @@ function createSvgObjectsFromPcbFootprintOverlapError(error, circuitJson, ctx) {
46974
47207
  if (filteredReferencedElements.length > 0) {
46975
47208
  const centerX = filteredReferencedElements.reduce((sum, el2) => sum + el2.x, 0) / filteredReferencedElements.length;
46976
47209
  const centerY = filteredReferencedElements.reduce((sum, el2) => sum + el2.y, 0) / filteredReferencedElements.length;
46977
- const screenCenter = applyToPoint19(transform2, { x: centerX, y: centerY });
47210
+ const screenCenter = applyToPoint20(transform2, { x: centerX, y: centerY });
46978
47211
  svgObjects.push({
46979
47212
  name: "rect",
46980
47213
  type: "element",
@@ -47012,7 +47245,7 @@ function createSvgObjectsFromPcbFootprintOverlapError(error, circuitJson, ctx) {
47012
47245
  value: ""
47013
47246
  });
47014
47247
  for (const element of filteredReferencedElements) {
47015
- const screenPos = applyToPoint19(transform2, { x: element.x, y: element.y });
47248
+ const screenPos = applyToPoint20(transform2, { x: element.x, y: element.y });
47016
47249
  svgObjects.push({
47017
47250
  name: "rect",
47018
47251
  type: "element",
@@ -47064,7 +47297,7 @@ function createSvgObjectsFromPcbCourtyardOverlapError(error, circuitJson, ctx) {
47064
47297
  return [];
47065
47298
  const midX = componentCenters.reduce((s, c) => s + c.x, 0) / componentCenters.length;
47066
47299
  const midY = componentCenters.reduce((s, c) => s + c.y, 0) / componentCenters.length;
47067
- const screenMid = applyToPoint19(transform2, { x: midX, y: midY });
47300
+ const screenMid = applyToPoint20(transform2, { x: midX, y: midY });
47068
47301
  svgObjects.push({
47069
47302
  name: "rect",
47070
47303
  type: "element",
@@ -47106,7 +47339,7 @@ function createSvgObjectsFromPcbCourtyardOverlapError(error, circuitJson, ctx) {
47106
47339
  value: ""
47107
47340
  });
47108
47341
  for (const center of componentCenters) {
47109
- const screenPos = applyToPoint19(transform2, center);
47342
+ const screenPos = applyToPoint20(transform2, center);
47110
47343
  svgObjects.push({
47111
47344
  name: "rect",
47112
47345
  type: "element",
@@ -47125,7 +47358,7 @@ function createSvgObjectsFromPcbCourtyardOverlapError(error, circuitJson, ctx) {
47125
47358
  });
47126
47359
  }
47127
47360
  if (componentCenters.length === 2) {
47128
- const mapped = componentCenters.map((c) => applyToPoint19(transform2, c));
47361
+ const mapped = componentCenters.map((c) => applyToPoint20(transform2, c));
47129
47362
  const s12 = mapped[0];
47130
47363
  const s2 = mapped[1];
47131
47364
  svgObjects.push({
@@ -47180,8 +47413,8 @@ function createSvgObjectsFromPcbComponentOutsideBoardError(error, circuitJson, c
47180
47413
  const bounds = getComponentBounds(error, circuitJson);
47181
47414
  if (!bounds)
47182
47415
  return [];
47183
- const topLeft = applyToPoint19(transform2, { x: bounds.min_x, y: bounds.min_y });
47184
- const bottomRight = applyToPoint19(transform2, {
47416
+ const topLeft = applyToPoint20(transform2, { x: bounds.min_x, y: bounds.min_y });
47417
+ const bottomRight = applyToPoint20(transform2, {
47185
47418
  x: bounds.max_x,
47186
47419
  y: bounds.max_y
47187
47420
  });
@@ -47255,7 +47488,7 @@ function createSvgObjectsFromPcbFabricationNotePath(fabNotePath, ctx) {
47255
47488
  const lastPoint = fabNotePath.route[fabNotePath.route.length - 1];
47256
47489
  const isClosed = firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y;
47257
47490
  const path42 = fabNotePath.route.slice(0, isClosed ? -1 : undefined).map((point2, index) => {
47258
- const [x3, y] = applyToPoint19(transform2, [point2.x, point2.y]);
47491
+ const [x3, y] = applyToPoint20(transform2, [point2.x, point2.y]);
47259
47492
  return index === 0 ? `M ${x3} ${y}` : `L ${x3} ${y}`;
47260
47493
  }).join(" ") + (isClosed ? " Z" : "");
47261
47494
  return [
@@ -47294,7 +47527,7 @@ function createSvgObjectsFromPcbFabricationNoteText(pcbFabNoteText, ctx) {
47294
47527
  debugPcb(`[pcb_fabrication_note_text] Invalid anchor_position for "${pcbFabNoteText.pcb_fabrication_note_text_id}": expected {x: number, y: number}, got ${JSON.stringify(anchor_position)}`);
47295
47528
  return [];
47296
47529
  }
47297
- const [transformedX, transformedY] = applyToPoint19(transform2, [
47530
+ const [transformedX, transformedY] = applyToPoint20(transform2, [
47298
47531
  anchor_position.x,
47299
47532
  anchor_position.y
47300
47533
  ]);
@@ -47373,11 +47606,11 @@ function createSvgObjectsFromPcbFabricationNoteRect(fabricationNoteRect, ctx) {
47373
47606
  }
47374
47607
  const halfWidth = width / 2;
47375
47608
  const halfHeight = height / 2;
47376
- const [topLeftX, topLeftY] = applyToPoint19(transform2, [
47609
+ const [topLeftX, topLeftY] = applyToPoint20(transform2, [
47377
47610
  center.x - halfWidth,
47378
47611
  center.y + halfHeight
47379
47612
  ]);
47380
- const [bottomRightX, bottomRightY] = applyToPoint19(transform2, [
47613
+ const [bottomRightX, bottomRightY] = applyToPoint20(transform2, [
47381
47614
  center.x + halfWidth,
47382
47615
  center.y - halfHeight
47383
47616
  ]);
@@ -47524,11 +47757,11 @@ function createSvgObjectsFromPcbFabricationNoteDimension(dimension, ctx) {
47524
47757
  y: toBase.y - perpendicular.y * arrowHalfWidth
47525
47758
  })
47526
47759
  ];
47527
- const [lineStartX, lineStartY] = applyToPoint19(transform2, [
47760
+ const [lineStartX, lineStartY] = applyToPoint20(transform2, [
47528
47761
  fromBase.x,
47529
47762
  fromBase.y
47530
47763
  ]);
47531
- const [lineEndX, lineEndY] = applyToPoint19(transform2, [toBase.x, toBase.y]);
47764
+ const [lineEndX, lineEndY] = applyToPoint20(transform2, [toBase.x, toBase.y]);
47532
47765
  const strokeWidth = arrowSize / 5 * Math.abs(transform2.a);
47533
47766
  const lineColor = color || "rgba(255,255,255,0.5)";
47534
47767
  const extensionDirection = hasOffsetDirection && (Math.abs(normalizedOffsetDirection.x) > Number.EPSILON || Math.abs(normalizedOffsetDirection.y) > Number.EPSILON) ? normalizedOffsetDirection : perpendicular;
@@ -47538,8 +47771,8 @@ function createSvgObjectsFromPcbFabricationNoteDimension(dimension, ctx) {
47538
47771
  x: anchor.x + extensionDirection.x * extensionLength,
47539
47772
  y: anchor.y + extensionDirection.y * extensionLength
47540
47773
  };
47541
- const [startX, startY] = applyToPoint19(transform2, [anchor.x, anchor.y]);
47542
- const [endX, endY] = applyToPoint19(transform2, [endPoint.x, endPoint.y]);
47774
+ const [startX, startY] = applyToPoint20(transform2, [anchor.x, anchor.y]);
47775
+ const [endX, endY] = applyToPoint20(transform2, [endPoint.x, endPoint.y]);
47543
47776
  return {
47544
47777
  name: "path",
47545
47778
  type: "element",
@@ -47560,11 +47793,11 @@ function createSvgObjectsFromPcbFabricationNoteDimension(dimension, ctx) {
47560
47793
  x: (from.x + to2.x) / 2 + offsetVector.x,
47561
47794
  y: (from.y + to2.y) / 2 + offsetVector.y
47562
47795
  };
47563
- const [screenFromX, screenFromY] = applyToPoint19(transform2, [
47796
+ const [screenFromX, screenFromY] = applyToPoint20(transform2, [
47564
47797
  fromOffset.x,
47565
47798
  fromOffset.y
47566
47799
  ]);
47567
- const [screenToX, screenToY] = applyToPoint19(transform2, [
47800
+ const [screenToX, screenToY] = applyToPoint20(transform2, [
47568
47801
  toOffset.x,
47569
47802
  toOffset.y
47570
47803
  ]);
@@ -47594,7 +47827,7 @@ function createSvgObjectsFromPcbFabricationNoteDimension(dimension, ctx) {
47594
47827
  x: midPoint.x + perpendicular.x * textOffset,
47595
47828
  y: midPoint.y + perpendicular.y * textOffset
47596
47829
  };
47597
- const [textX, textY] = applyToPoint19(transform2, [textPoint.x, textPoint.y]);
47830
+ const [textX, textY] = applyToPoint20(transform2, [textPoint.x, textPoint.y]);
47598
47831
  const transformedFontSize = font_size * Math.abs(transform2.a);
47599
47832
  const children = [
47600
47833
  ...extensionSegments,
@@ -47681,7 +47914,7 @@ function createSvgObjectsFromPcbFabricationNoteDimension(dimension, ctx) {
47681
47914
  }
47682
47915
  ];
47683
47916
  function toScreen(point2) {
47684
- const [x3, y] = applyToPoint19(transform2, [point2.x, point2.y]);
47917
+ const [x3, y] = applyToPoint20(transform2, [point2.x, point2.y]);
47685
47918
  return { x: x3, y };
47686
47919
  }
47687
47920
  }
@@ -47762,11 +47995,11 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
47762
47995
  y: toBase.y - perpendicular.y * arrowHalfWidth
47763
47996
  })
47764
47997
  ];
47765
- const [lineStartX, lineStartY] = applyToPoint19(transform2, [
47998
+ const [lineStartX, lineStartY] = applyToPoint20(transform2, [
47766
47999
  fromBase.x,
47767
48000
  fromBase.y
47768
48001
  ]);
47769
- const [lineEndX, lineEndY] = applyToPoint19(transform2, [toBase.x, toBase.y]);
48002
+ const [lineEndX, lineEndY] = applyToPoint20(transform2, [toBase.x, toBase.y]);
47770
48003
  const strokeWidth = arrow_size / 5 * Math.abs(transform2.a);
47771
48004
  const lineColor = color || colorMap.board.user_2;
47772
48005
  const extensionDirection = hasOffsetDirection && (Math.abs(normalizedOffsetDirection.x) > Number.EPSILON || Math.abs(normalizedOffsetDirection.y) > Number.EPSILON) ? normalizedOffsetDirection : perpendicular;
@@ -47776,8 +48009,8 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
47776
48009
  x: anchor.x + extensionDirection.x * extensionLength,
47777
48010
  y: anchor.y + extensionDirection.y * extensionLength
47778
48011
  };
47779
- const [startX, startY] = applyToPoint19(transform2, [anchor.x, anchor.y]);
47780
- const [endX, endY] = applyToPoint19(transform2, [endPoint.x, endPoint.y]);
48012
+ const [startX, startY] = applyToPoint20(transform2, [anchor.x, anchor.y]);
48013
+ const [endX, endY] = applyToPoint20(transform2, [endPoint.x, endPoint.y]);
47781
48014
  return {
47782
48015
  name: "path",
47783
48016
  type: "element",
@@ -47798,11 +48031,11 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
47798
48031
  x: (from.x + to2.x) / 2 + offsetVector.x,
47799
48032
  y: (from.y + to2.y) / 2 + offsetVector.y
47800
48033
  };
47801
- const [screenFromX, screenFromY] = applyToPoint19(transform2, [
48034
+ const [screenFromX, screenFromY] = applyToPoint20(transform2, [
47802
48035
  fromOffset.x,
47803
48036
  fromOffset.y
47804
48037
  ]);
47805
- const [screenToX, screenToY] = applyToPoint19(transform2, [
48038
+ const [screenToX, screenToY] = applyToPoint20(transform2, [
47806
48039
  toOffset.x,
47807
48040
  toOffset.y
47808
48041
  ]);
@@ -47832,7 +48065,7 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
47832
48065
  x: midPoint.x + perpendicular.x * textOffset,
47833
48066
  y: midPoint.y + perpendicular.y * textOffset
47834
48067
  };
47835
- const [textX, textY] = applyToPoint19(transform2, [textPoint.x, textPoint.y]);
48068
+ const [textX, textY] = applyToPoint20(transform2, [textPoint.x, textPoint.y]);
47836
48069
  const transformedFontSize = font_size * Math.abs(transform2.a);
47837
48070
  const children = [
47838
48071
  ...extensionSegments,
@@ -47915,7 +48148,7 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
47915
48148
  }
47916
48149
  ];
47917
48150
  function toScreen(point2) {
47918
- const [x3, y] = applyToPoint19(transform2, [point2.x, point2.y]);
48151
+ const [x3, y] = applyToPoint20(transform2, [point2.x, point2.y]);
47919
48152
  return { x: x3, y };
47920
48153
  }
47921
48154
  }
@@ -47936,7 +48169,7 @@ function createSvgObjectsFromPcbNoteText(note, ctx) {
47936
48169
  debugPcb(`[pcb_note_text] Invalid text for "${note.pcb_note_text_id}": expected non-empty string, got ${JSON.stringify(text)}`);
47937
48170
  return [];
47938
48171
  }
47939
- const [x3, y] = applyToPoint19(transform2, [anchor_position.x, anchor_position.y]);
48172
+ const [x3, y] = applyToPoint20(transform2, [anchor_position.x, anchor_position.y]);
47940
48173
  const transformedFontSize = font_size * Math.abs(transform2.a);
47941
48174
  let textAnchor = "middle";
47942
48175
  let dominantBaseline = "central";
@@ -48031,11 +48264,11 @@ function createSvgObjectsFromPcbNoteRect(noteRect, ctx) {
48031
48264
  }
48032
48265
  const halfWidth = width / 2;
48033
48266
  const halfHeight = height / 2;
48034
- const [topLeftX, topLeftY] = applyToPoint19(transform2, [
48267
+ const [topLeftX, topLeftY] = applyToPoint20(transform2, [
48035
48268
  center.x - halfWidth,
48036
48269
  center.y + halfHeight
48037
48270
  ]);
48038
- const [bottomRightX, bottomRightY] = applyToPoint19(transform2, [
48271
+ const [bottomRightX, bottomRightY] = applyToPoint20(transform2, [
48039
48272
  center.x + halfWidth,
48040
48273
  center.y - halfHeight
48041
48274
  ]);
@@ -48104,7 +48337,7 @@ function createSvgObjectsFromPcbNotePath(notePath, ctx) {
48104
48337
  }
48105
48338
  }
48106
48339
  const pathD = notePath.route.map((point2, index) => {
48107
- const [x3, y] = applyToPoint19(transform2, [point2.x, point2.y]);
48340
+ const [x3, y] = applyToPoint20(transform2, [point2.x, point2.y]);
48108
48341
  return index === 0 ? `M ${x3} ${y}` : `L ${x3} ${y}`;
48109
48342
  }).join(" ");
48110
48343
  const strokeWidth = notePath.stroke_width * Math.abs(transform2.a);
@@ -48133,8 +48366,8 @@ function createSvgObjectsFromPcbNoteLine(noteLine, ctx) {
48133
48366
  debugPcb(`[pcb_note_line] Invalid coordinates for "${noteLine.pcb_note_line_id}": expected x1, y1, x2, y2 as numbers, got x1=${JSON.stringify(x12)}, y1=${JSON.stringify(y12)}, x2=${JSON.stringify(x22)}, y2=${JSON.stringify(y22)}`);
48134
48367
  return [];
48135
48368
  }
48136
- const [startX, startY] = applyToPoint19(transform2, [x12, y12]);
48137
- const [endX, endY] = applyToPoint19(transform2, [x22, y22]);
48369
+ const [startX, startY] = applyToPoint20(transform2, [x12, y12]);
48370
+ const [endX, endY] = applyToPoint20(transform2, [x22, y22]);
48138
48371
  const baseStrokeWidth = typeof stroke_width === "number" ? stroke_width : 0;
48139
48372
  const transformedStrokeWidth = baseStrokeWidth * Math.abs(transform2.a);
48140
48373
  const attributes = {
@@ -48166,7 +48399,7 @@ function createSvgObjectsFromPcbNoteLine(noteLine, ctx) {
48166
48399
  }
48167
48400
  function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
48168
48401
  const { transform: transform2, colorMap: colorMap2, showSolderMask } = ctx;
48169
- const [x3, y] = applyToPoint19(transform2, [hole.x, hole.y]);
48402
+ const [x3, y] = applyToPoint20(transform2, [hole.x, hole.y]);
48170
48403
  const layer = Array.isArray(hole.layers) && hole.layers[0] || hole.layer || "top";
48171
48404
  const maskLayer = layer;
48172
48405
  const isCoveredWithSolderMask = Boolean(hole.is_covered_with_solder_mask);
@@ -48464,7 +48697,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
48464
48697
  const xStr = rotation2 ? (-scaledRectPadWidth / 2).toString() : (x3 - scaledRectPadWidth / 2).toString();
48465
48698
  const yStr = rotation2 ? (-scaledRectPadHeight / 2).toString() : (y - scaledRectPadHeight / 2).toString();
48466
48699
  const holeRadius = scaledHoleDiameter / 2;
48467
- const [holeCx, holeCy] = applyToPoint19(transform2, [
48700
+ const [holeCx, holeCy] = applyToPoint20(transform2, [
48468
48701
  h.x + (h.hole_offset_x ?? 0),
48469
48702
  h.y + (h.hole_offset_y ?? 0)
48470
48703
  ]);
@@ -48627,7 +48860,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
48627
48860
  const pillHoleWithOffsets = pillHole;
48628
48861
  const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
48629
48862
  const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
48630
- const [holeCenterX, holeCenterY] = applyToPoint19(transform2, [
48863
+ const [holeCenterX, holeCenterY] = applyToPoint20(transform2, [
48631
48864
  pillHole.x + holeOffsetX,
48632
48865
  pillHole.y + holeOffsetY
48633
48866
  ]);
@@ -48766,7 +48999,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
48766
48999
  const rotatedHoleWithOffsets = rotatedHole;
48767
49000
  const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
48768
49001
  const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
48769
- const [holeCenterX, holeCenterY] = applyToPoint19(transform2, [
49002
+ const [holeCenterX, holeCenterY] = applyToPoint20(transform2, [
48770
49003
  rotatedHole.x + holeOffsetX,
48771
49004
  rotatedHole.y + holeOffsetY
48772
49005
  ]);
@@ -48905,9 +49138,9 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
48905
49138
  const padOutline = polygonHole.pad_outline || [];
48906
49139
  const holeX = polygonHole.x ?? 0;
48907
49140
  const holeY = polygonHole.y ?? 0;
48908
- const padPoints = padOutline.map((point2) => applyToPoint19(transform2, [holeX + point2.x, holeY + point2.y]));
49141
+ const padPoints = padOutline.map((point2) => applyToPoint20(transform2, [holeX + point2.x, holeY + point2.y]));
48909
49142
  const padPointsString = padPoints.map((p) => p.join(",")).join(" ");
48910
- const [holeCenterX, holeCenterY] = applyToPoint19(transform2, [
49143
+ const [holeCenterX, holeCenterY] = applyToPoint20(transform2, [
48911
49144
  holeX + polygonHole.hole_offset_x,
48912
49145
  holeY + polygonHole.hole_offset_y
48913
49146
  ]);
@@ -49018,7 +49251,7 @@ function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
49018
49251
  if (!silkscreenPath.route || !Array.isArray(silkscreenPath.route))
49019
49252
  return [];
49020
49253
  let path42 = silkscreenPath.route.map((point2, index) => {
49021
- const [x3, y] = applyToPoint19(transform2, [point2.x, point2.y]);
49254
+ const [x3, y] = applyToPoint20(transform2, [point2.x, point2.y]);
49022
49255
  return index === 0 ? `M ${x3} ${y}` : `L ${x3} ${y}`;
49023
49256
  }).join(" ");
49024
49257
  const firstPoint = silkscreenPath.route[0];
@@ -49128,7 +49361,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
49128
49361
  debugPcb(`[pcb_silkscreen_text] Invalid anchor_position for "${pcbSilkscreenText.pcb_silkscreen_text_id}": expected {x: number, y: number}, got ${JSON.stringify(anchor_position)}`);
49129
49362
  return [];
49130
49363
  }
49131
- const [transformedX, transformedY] = applyToPoint19(transform2, [
49364
+ const [transformedX, transformedY] = applyToPoint20(transform2, [
49132
49365
  anchor_position.x,
49133
49366
  anchor_position.y
49134
49367
  ]);
@@ -49336,7 +49569,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
49336
49569
  debugPcb(`[pcb_silkscreen_rect] Invalid data for "${pcb_silkscreen_rect_id}": expected center {x: number, y: number}, width: number, height: number, got center=${JSON.stringify(center)}, width=${JSON.stringify(width)}, height=${JSON.stringify(height)}`);
49337
49570
  return [];
49338
49571
  }
49339
- const [transformedX, transformedY] = applyToPoint19(transform2, [
49572
+ const [transformedX, transformedY] = applyToPoint20(transform2, [
49340
49573
  center.x,
49341
49574
  center.y
49342
49575
  ]);
@@ -49486,7 +49719,7 @@ function createSvgObjectsFromPcbCopperText(pcbCopperText, ctx) {
49486
49719
  return [];
49487
49720
  if (!anchor_position)
49488
49721
  return [];
49489
- const [ax2, ay2] = applyToPoint19(transform2, [
49722
+ const [ax2, ay2] = applyToPoint20(transform2, [
49490
49723
  anchor_position.x,
49491
49724
  anchor_position.y
49492
49725
  ]);
@@ -49643,7 +49876,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
49643
49876
  console.error("Invalid PCB Silkscreen Circle data:", { center, radius });
49644
49877
  return [];
49645
49878
  }
49646
- const [transformedX, transformedY] = applyToPoint19(transform2, [
49879
+ const [transformedX, transformedY] = applyToPoint20(transform2, [
49647
49880
  center.x,
49648
49881
  center.y
49649
49882
  ]);
@@ -49686,8 +49919,8 @@ function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
49686
49919
  debugPcb(`[pcb_silkscreen_line] Invalid coordinates for "${pcb_silkscreen_line_id}": expected x1, y1, x2, y2 as numbers, got x1=${JSON.stringify(x12)}, y1=${JSON.stringify(y12)}, x2=${JSON.stringify(x22)}, y2=${JSON.stringify(y22)}`);
49687
49920
  return [];
49688
49921
  }
49689
- const [transformedX1, transformedY1] = applyToPoint19(transform2, [x12, y12]);
49690
- const [transformedX2, transformedY2] = applyToPoint19(transform2, [x22, y22]);
49922
+ const [transformedX1, transformedY1] = applyToPoint20(transform2, [x12, y12]);
49923
+ const [transformedX2, transformedY2] = applyToPoint20(transform2, [x22, y22]);
49691
49924
  const transformedStrokeWidth = stroke_width * Math.abs(transform2.a);
49692
49925
  const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
49693
49926
  return [
@@ -49722,7 +49955,7 @@ function createSvgObjectsFromPcbSilkscreenPill(pcbSilkscreenPill, ctx) {
49722
49955
  } = pcbSilkscreenPill;
49723
49956
  if (layerFilter && layer !== layerFilter)
49724
49957
  return [];
49725
- const [transformedX, transformedY] = applyToPoint19(transform2, [
49958
+ const [transformedX, transformedY] = applyToPoint20(transform2, [
49726
49959
  center.x,
49727
49960
  center.y
49728
49961
  ]);
@@ -49772,7 +50005,7 @@ function createSvgObjectsFromPcbSilkscreenOval(pcbSilkscreenOval, ctx) {
49772
50005
  debugPcb(`[pcb_silkscreen_oval] Invalid data for "${pcb_silkscreen_oval_id}": expected center {x: number, y: number}, radius_x: number, radius_y: number, got center=${JSON.stringify(center)}, radius_x=${JSON.stringify(radius_x)}, radius_y=${JSON.stringify(radius_y)}`);
49773
50006
  return [];
49774
50007
  }
49775
- const [transformedX, transformedY] = applyToPoint19(transform2, [
50008
+ const [transformedX, transformedY] = applyToPoint20(transform2, [
49776
50009
  center.x,
49777
50010
  center.y
49778
50011
  ]);
@@ -49819,7 +50052,7 @@ function createSvgObjectsFromPcbCourtyardRect(pcbCourtyardRect, ctx) {
49819
50052
  debugPcb(`[pcb_courtyard_rect] Invalid data for "${pcb_courtyard_rect_id}": expected center {x: number, y: number}, width: number, height: number, got center=${JSON.stringify(center)}, width=${JSON.stringify(width)}, height=${JSON.stringify(height)}`);
49820
50053
  return [];
49821
50054
  }
49822
- const [transformedX, transformedY] = applyToPoint19(transform2, [
50055
+ const [transformedX, transformedY] = applyToPoint20(transform2, [
49823
50056
  center.x,
49824
50057
  center.y
49825
50058
  ]);
@@ -49869,7 +50102,7 @@ function createSvgObjectsFromPcbCourtyardPolygon(pcbCourtyardPolygon, ctx) {
49869
50102
  debugPcb(`[pcb_courtyard_polygon] Invalid data for "${pcb_courtyard_polygon_id}": expected non-empty array of points, got ${JSON.stringify(points)}`);
49870
50103
  return [];
49871
50104
  }
49872
- const transformedPoints = points.map((p) => applyToPoint19(transform2, [p.x, p.y]));
50105
+ const transformedPoints = points.map((p) => applyToPoint20(transform2, [p.x, p.y]));
49873
50106
  const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
49874
50107
  const transformedStrokeWidth = 0.05 * Math.abs(transform2.a);
49875
50108
  const strokeColor = color ?? (layer === "bottom" ? colorMap2.courtyard.bottom : colorMap2.courtyard.top);
@@ -49901,7 +50134,7 @@ function createSvgObjectsFromPcbCourtyardOutline(pcbCourtyardOutline, ctx) {
49901
50134
  debugPcb(`[pcb_courtyard_outline] Invalid data for "${pcb_courtyard_outline_id}": expected non-empty array of points, got ${JSON.stringify(outline)}`);
49902
50135
  return [];
49903
50136
  }
49904
- const transformedPoints = outline.map((p) => applyToPoint19(transform2, [p.x, p.y]));
50137
+ const transformedPoints = outline.map((p) => applyToPoint20(transform2, [p.x, p.y]));
49905
50138
  const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
49906
50139
  const transformedStrokeWidth = 0.05 * Math.abs(transform2.a);
49907
50140
  const strokeColor = layer === "bottom" ? colorMap2.courtyard.bottom : colorMap2.courtyard.top;
@@ -49938,7 +50171,7 @@ function createSvgObjectsFromPcbCourtyardCircle(pcbCourtyardCircle, ctx) {
49938
50171
  console.error(`[pcb_courtyard_circle] Invalid data for "${pcb_courtyard_circle_id}": expected center {x: number, y: number}, radius: number, got center=${JSON.stringify(center)}, radius=${JSON.stringify(radius)}`);
49939
50172
  return [];
49940
50173
  }
49941
- const [transformedX, transformedY] = applyToPoint19(transform2, [
50174
+ const [transformedX, transformedY] = applyToPoint20(transform2, [
49942
50175
  center.x,
49943
50176
  center.y
49944
50177
  ]);
@@ -49983,8 +50216,8 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
49983
50216
  if (start.is_inside_copper_pour === true && end.is_inside_copper_pour === true) {
49984
50217
  continue;
49985
50218
  }
49986
- const startPoint = applyToPoint19(transform2, [start.x, start.y]);
49987
- const endPoint = applyToPoint19(transform2, [end.x, end.y]);
50219
+ const startPoint = applyToPoint20(transform2, [start.x, start.y]);
50220
+ const endPoint = applyToPoint20(transform2, [end.x, end.y]);
49988
50221
  const layer = "layer" in start ? start.layer : ("layer" in end) ? end.layer : null;
49989
50222
  if (!layer)
49990
50223
  continue;
@@ -50050,7 +50283,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
50050
50283
  if (pad.shape === "rect" || pad.shape === "rotated_rect") {
50051
50284
  const width = pad.width * Math.abs(transform2.a);
50052
50285
  const height = pad.height * Math.abs(transform2.d);
50053
- const [x3, y] = applyToPoint19(transform2, [pad.x, pad.y]);
50286
+ const [x3, y] = applyToPoint20(transform2, [pad.x, pad.y]);
50054
50287
  const cornerRadiusValue = pad.corner_radius ?? pad.rect_border_radius ?? 0;
50055
50288
  const scaledBorderRadius = cornerRadiusValue * Math.abs(transform2.a);
50056
50289
  const m = {
@@ -50300,7 +50533,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
50300
50533
  const width = pad.width * Math.abs(transform2.a);
50301
50534
  const height = pad.height * Math.abs(transform2.d);
50302
50535
  const radius = pad.radius * Math.abs(transform2.a);
50303
- const [x3, y] = applyToPoint19(transform2, [pad.x, pad.y]);
50536
+ const [x3, y] = applyToPoint20(transform2, [pad.x, pad.y]);
50304
50537
  const rotationTransformAttributes = isRotated ? {
50305
50538
  transform: `translate(${x3} ${y}) rotate(${-(pad.ccw_rotation ?? 0)})`
50306
50539
  } : undefined;
@@ -50418,7 +50651,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
50418
50651
  }
50419
50652
  if (pad.shape === "circle") {
50420
50653
  const radius = pad.radius * Math.abs(transform2.a);
50421
- const [x3, y] = applyToPoint19(transform2, [pad.x, pad.y]);
50654
+ const [x3, y] = applyToPoint20(transform2, [pad.x, pad.y]);
50422
50655
  const padElement = {
50423
50656
  name: "circle",
50424
50657
  type: "element",
@@ -50507,7 +50740,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
50507
50740
  return [substrateElement, padElement];
50508
50741
  }
50509
50742
  if (pad.shape === "polygon") {
50510
- const points = (pad.points ?? []).map((point2) => applyToPoint19(transform2, [point2.x, point2.y]));
50743
+ const points = (pad.points ?? []).map((point2) => applyToPoint20(transform2, [point2.x, point2.y]));
50511
50744
  const padElement = {
50512
50745
  name: "polygon",
50513
50746
  type: "element",
@@ -50615,11 +50848,11 @@ function createAnchorOffsetIndicators(params2) {
50615
50848
  displayYOffset
50616
50849
  } = params2;
50617
50850
  const objects = [];
50618
- const [screenGroupAnchorX, screenGroupAnchorY] = applyToPoint19(transform2, [
50851
+ const [screenGroupAnchorX, screenGroupAnchorY] = applyToPoint20(transform2, [
50619
50852
  groupAnchorPosition.x,
50620
50853
  groupAnchorPosition.y
50621
50854
  ]);
50622
- const [screenComponentX, screenComponentY] = applyToPoint19(transform2, [
50855
+ const [screenComponentX, screenComponentY] = applyToPoint20(transform2, [
50623
50856
  componentPosition.x,
50624
50857
  componentPosition.y
50625
50858
  ]);
@@ -50955,25 +51188,25 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
50955
51188
  let path42;
50956
51189
  if (outline && Array.isArray(outline) && outline.length >= 3) {
50957
51190
  path42 = outline.map((point2, index) => {
50958
- const [x3, y] = applyToPoint19(transform2, [point2.x, point2.y]);
51191
+ const [x3, y] = applyToPoint20(transform2, [point2.x, point2.y]);
50959
51192
  return index === 0 ? `M ${x3} ${y}` : `L ${x3} ${y}`;
50960
51193
  }).join(" ");
50961
51194
  } else {
50962
51195
  const halfWidth = width / 2;
50963
51196
  const halfHeight = height / 2;
50964
- const topLeft = applyToPoint19(transform2, [
51197
+ const topLeft = applyToPoint20(transform2, [
50965
51198
  center.x - halfWidth,
50966
51199
  center.y - halfHeight
50967
51200
  ]);
50968
- const topRight = applyToPoint19(transform2, [
51201
+ const topRight = applyToPoint20(transform2, [
50969
51202
  center.x + halfWidth,
50970
51203
  center.y - halfHeight
50971
51204
  ]);
50972
- const bottomRight = applyToPoint19(transform2, [
51205
+ const bottomRight = applyToPoint20(transform2, [
50973
51206
  center.x + halfWidth,
50974
51207
  center.y + halfHeight
50975
51208
  ]);
50976
- const bottomLeft = applyToPoint19(transform2, [
51209
+ const bottomLeft = applyToPoint20(transform2, [
50977
51210
  center.x - halfWidth,
50978
51211
  center.y + halfHeight
50979
51212
  ]);
@@ -51041,19 +51274,19 @@ function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
51041
51274
  const center = pcbPanel.center ?? { x: width / 2, y: height / 2 };
51042
51275
  const halfWidth = width / 2;
51043
51276
  const halfHeight = height / 2;
51044
- const topLeft = applyToPoint19(transform2, [
51277
+ const topLeft = applyToPoint20(transform2, [
51045
51278
  center.x - halfWidth,
51046
51279
  center.y - halfHeight
51047
51280
  ]);
51048
- const topRight = applyToPoint19(transform2, [
51281
+ const topRight = applyToPoint20(transform2, [
51049
51282
  center.x + halfWidth,
51050
51283
  center.y - halfHeight
51051
51284
  ]);
51052
- const bottomRight = applyToPoint19(transform2, [
51285
+ const bottomRight = applyToPoint20(transform2, [
51053
51286
  center.x + halfWidth,
51054
51287
  center.y + halfHeight
51055
51288
  ]);
51056
- const bottomLeft = applyToPoint19(transform2, [
51289
+ const bottomLeft = applyToPoint20(transform2, [
51057
51290
  center.x - halfWidth,
51058
51291
  center.y + halfHeight
51059
51292
  ]);
@@ -51080,7 +51313,7 @@ function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
51080
51313
  }
51081
51314
  function createSvgObjectsFromPcbVia(hole, ctx) {
51082
51315
  const { transform: transform2, colorMap: colorMap2 } = ctx;
51083
- const [x3, y] = applyToPoint19(transform2, [hole.x, hole.y]);
51316
+ const [x3, y] = applyToPoint20(transform2, [hole.x, hole.y]);
51084
51317
  const scaledOuterWidth = hole.outer_diameter * Math.abs(transform2.a);
51085
51318
  const scaledOuterHeight = hole.outer_diameter * Math.abs(transform2.a);
51086
51319
  const scaledHoleWidth = hole.hole_diameter * Math.abs(transform2.a);
@@ -51127,7 +51360,7 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
51127
51360
  function createSvgObjectsFromPcbHole(hole, ctx) {
51128
51361
  const { transform: transform2, colorMap: colorMap2, showSolderMask } = ctx;
51129
51362
  const layer = ctx.layer ?? "top";
51130
- const [x3, y] = applyToPoint19(transform2, [hole.x, hole.y]);
51363
+ const [x3, y] = applyToPoint20(transform2, [hole.x, hole.y]);
51131
51364
  const isCoveredWithSolderMask = Boolean(hole.is_covered_with_solder_mask);
51132
51365
  const soldermaskMargin = (hole.soldermask_margin ?? 0) * Math.abs(transform2.a);
51133
51366
  const shouldShowSolderMask = showSolderMask && isCoveredWithSolderMask && soldermaskMargin !== 0;
@@ -51625,11 +51858,11 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
51625
51858
  });
51626
51859
  const svgObjects = [];
51627
51860
  for (const line of ratsNestLines) {
51628
- const transformedStart = applyToPoint19(transform2, [
51861
+ const transformedStart = applyToPoint20(transform2, [
51629
51862
  line.startPoint.x,
51630
51863
  line.startPoint.y
51631
51864
  ]);
51632
- const transformedEnd = applyToPoint19(transform2, [
51865
+ const transformedEnd = applyToPoint20(transform2, [
51633
51866
  line.endPoint.x,
51634
51867
  line.endPoint.y
51635
51868
  ]);
@@ -51658,7 +51891,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
51658
51891
  const { transform: transform2, colorMap: colorMap2 } = ctx;
51659
51892
  if (cutout.shape === "rect") {
51660
51893
  const rectCutout = cutout;
51661
- const [cx2, cy2] = applyToPoint19(transform2, [
51894
+ const [cx2, cy2] = applyToPoint20(transform2, [
51662
51895
  rectCutout.center.x,
51663
51896
  rectCutout.center.y
51664
51897
  ]);
@@ -51698,7 +51931,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
51698
51931
  }
51699
51932
  if (cutout.shape === "circle") {
51700
51933
  const circleCutout = cutout;
51701
- const [cx2, cy2] = applyToPoint19(transform2, [
51934
+ const [cx2, cy2] = applyToPoint20(transform2, [
51702
51935
  circleCutout.center.x,
51703
51936
  circleCutout.center.y
51704
51937
  ]);
@@ -51725,7 +51958,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
51725
51958
  const polygonCutout = cutout;
51726
51959
  if (!polygonCutout.points || polygonCutout.points.length === 0)
51727
51960
  return [];
51728
- const transformedPoints = polygonCutout.points.map((p) => applyToPoint19(transform2, [p.x, p.y]));
51961
+ const transformedPoints = polygonCutout.points.map((p) => applyToPoint20(transform2, [p.x, p.y]));
51729
51962
  const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
51730
51963
  return [
51731
51964
  {
@@ -51753,7 +51986,7 @@ function createSvgObjectsFromPcbCutoutPath(cutoutPath, ctx) {
51753
51986
  const lastPoint = cutoutPath.route[cutoutPath.route.length - 1];
51754
51987
  const isClosed = firstPoint && lastPoint && firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y;
51755
51988
  const path42 = cutoutPath.route.slice(0, isClosed ? -1 : undefined).map((point2, index) => {
51756
- const [x3, y] = applyToPoint19(transform2, [point2.x, point2.y]);
51989
+ const [x3, y] = applyToPoint20(transform2, [point2.x, point2.y]);
51757
51990
  return index === 0 ? `M ${x3} ${y}` : `L ${x3} ${y}`;
51758
51991
  }).join(" ") + (isClosed ? " Z" : "");
51759
51992
  return [
@@ -51855,7 +52088,7 @@ function createSvgObjectsFromPcbKeepout(keepout, ctx) {
51855
52088
  }
51856
52089
  if (keepout.shape === "rect") {
51857
52090
  const rectKeepout = keepout;
51858
- const [cx2, cy2] = applyToPoint19(transform2, [
52091
+ const [cx2, cy2] = applyToPoint20(transform2, [
51859
52092
  rectKeepout.center.x,
51860
52093
  rectKeepout.center.y
51861
52094
  ]);
@@ -51894,7 +52127,7 @@ function createSvgObjectsFromPcbKeepout(keepout, ctx) {
51894
52127
  });
51895
52128
  } else if (keepout.shape === "circle") {
51896
52129
  const circleKeepout = keepout;
51897
- const [cx2, cy2] = applyToPoint19(transform2, [
52130
+ const [cx2, cy2] = applyToPoint20(transform2, [
51898
52131
  circleKeepout.center.x,
51899
52132
  circleKeepout.center.y
51900
52133
  ]);
@@ -51933,7 +52166,7 @@ function ringToPathD(vertices, transform2) {
51933
52166
  if (vertices.length === 0)
51934
52167
  return "";
51935
52168
  const transformedVertices = vertices.map((v3) => {
51936
- const [x3, y] = applyToPoint19(transform2, [v3.x, v3.y]);
52169
+ const [x3, y] = applyToPoint20(transform2, [v3.x, v3.y]);
51937
52170
  return { ...v3, x: x3, y };
51938
52171
  });
51939
52172
  let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
@@ -52018,7 +52251,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
52018
52251
  const maskOverlayColor = layer === "bottom" ? colorMap2.soldermaskOverCopper.bottom : colorMap2.soldermaskOverCopper.top;
52019
52252
  const maskOverlayOpacity = "0.9";
52020
52253
  if (pour.shape === "rect") {
52021
- const [cx2, cy2] = applyToPoint19(transform2, [pour.center.x, pour.center.y]);
52254
+ const [cx2, cy2] = applyToPoint20(transform2, [pour.center.x, pour.center.y]);
52022
52255
  const scaledWidth = pour.width * Math.abs(transform2.a);
52023
52256
  const scaledHeight = pour.height * Math.abs(transform2.d);
52024
52257
  const svgRotation = -(pour.rotation ?? 0);
@@ -52068,7 +52301,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
52068
52301
  if (pour.shape === "polygon") {
52069
52302
  if (!pour.points || pour.points.length === 0)
52070
52303
  return [];
52071
- const transformedPoints = pour.points.map((p) => applyToPoint19(transform2, [p.x, p.y]));
52304
+ const transformedPoints = pour.points.map((p) => applyToPoint20(transform2, [p.x, p.y]));
52072
52305
  const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
52073
52306
  const copperPolygon = {
52074
52307
  name: "polygon",
@@ -52277,7 +52510,7 @@ function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majo
52277
52510
  function createSvgObjectsFromPcbComponent(component, ctx) {
52278
52511
  const { transform: transform2, circuitJson } = ctx;
52279
52512
  const { center, width, height, rotation: rotation2 = 0 } = component;
52280
- const [x3, y] = applyToPoint19(transform2, [center.x, center.y]);
52513
+ const [x3, y] = applyToPoint20(transform2, [center.x, center.y]);
52281
52514
  const scaledWidth = width * Math.abs(transform2.a);
52282
52515
  const scaledHeight = height * Math.abs(transform2.d);
52283
52516
  const transformStr = `translate(${x3}, ${y}) rotate(${-rotation2}) scale(1, -1)`;
@@ -52380,7 +52613,7 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
52380
52613
  }
52381
52614
  if (outline && outline.length >= 3 && outline.every((point2) => point2 && typeof point2.x === "number" && typeof point2.y === "number")) {
52382
52615
  const path42 = outline.map((point2, index) => {
52383
- const [x3, y] = applyToPoint19(transform2, [point2.x, point2.y]);
52616
+ const [x3, y] = applyToPoint20(transform2, [point2.x, point2.y]);
52384
52617
  return index === 0 ? `M ${x3} ${y}` : `L ${x3} ${y}`;
52385
52618
  }).join(" ");
52386
52619
  svgObjects.push({
@@ -52401,11 +52634,11 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
52401
52634
  }
52402
52635
  const halfWidth = width / 2;
52403
52636
  const halfHeight = height / 2;
52404
- const [topLeftX, topLeftY] = applyToPoint19(transform2, [
52637
+ const [topLeftX, topLeftY] = applyToPoint20(transform2, [
52405
52638
  center.x - halfWidth,
52406
52639
  center.y + halfHeight
52407
52640
  ]);
52408
- const [bottomRightX, bottomRightY] = applyToPoint19(transform2, [
52641
+ const [bottomRightX, bottomRightY] = applyToPoint20(transform2, [
52409
52642
  center.x + halfWidth,
52410
52643
  center.y - halfHeight
52411
52644
  ]);
@@ -53307,8 +53540,8 @@ function createSvgObjects({
53307
53540
  }
53308
53541
  }
53309
53542
  function createSvgObjectFromPcbBoundary(transform2, minX, minY, maxX, maxY) {
53310
- const [x12, y12] = applyToPoint19(transform2, [minX, minY]);
53311
- const [x22, y22] = applyToPoint19(transform2, [maxX, maxY]);
53543
+ const [x12, y12] = applyToPoint20(transform2, [minX, minY]);
53544
+ const [x22, y22] = applyToPoint20(transform2, [maxX, maxY]);
53312
53545
  const width = Math.abs(x22 - x12);
53313
53546
  const height = Math.abs(y22 - y12);
53314
53547
  const x3 = Math.min(x12, x22);
@@ -53337,25 +53570,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform2, style = {}) {
53337
53570
  let path42;
53338
53571
  if (outline && Array.isArray(outline) && outline.length >= 3) {
53339
53572
  path42 = outline.map((point2, index) => {
53340
- const [x3, y] = applyToPoint19(transform2, [point2.x, point2.y]);
53573
+ const [x3, y] = applyToPoint20(transform2, [point2.x, point2.y]);
53341
53574
  return index === 0 ? `M ${x3} ${y}` : `L ${x3} ${y}`;
53342
53575
  }).join(" ");
53343
53576
  } else {
53344
53577
  const halfWidth = width / 2;
53345
53578
  const halfHeight = height / 2;
53346
- const topLeft = applyToPoint19(transform2, [
53579
+ const topLeft = applyToPoint20(transform2, [
53347
53580
  center.x - halfWidth,
53348
53581
  center.y - halfHeight
53349
53582
  ]);
53350
- const topRight = applyToPoint19(transform2, [
53583
+ const topRight = applyToPoint20(transform2, [
53351
53584
  center.x + halfWidth,
53352
53585
  center.y - halfHeight
53353
53586
  ]);
53354
- const bottomRight = applyToPoint19(transform2, [
53587
+ const bottomRight = applyToPoint20(transform2, [
53355
53588
  center.x + halfWidth,
53356
53589
  center.y + halfHeight
53357
53590
  ]);
53358
- const bottomLeft = applyToPoint19(transform2, [
53591
+ const bottomLeft = applyToPoint20(transform2, [
53359
53592
  center.x - halfWidth,
53360
53593
  center.y + halfHeight
53361
53594
  ]);
@@ -53385,8 +53618,8 @@ function createSvgObjectsFromAssemblyComponent(params2, ctx) {
53385
53618
  const { center, width, height, rotation: rotation2 = 0, layer = "top" } = elm;
53386
53619
  if (!center || typeof width !== "number" || typeof height !== "number")
53387
53620
  return null;
53388
- const [x3, y] = applyToPoint19(transform2, [center.x, center.y]);
53389
- const [pinX, pinY] = applyToPoint19(transform2, [portPosition.x, portPosition.y]);
53621
+ const [x3, y] = applyToPoint20(transform2, [center.x, center.y]);
53622
+ const [pinX, pinY] = applyToPoint20(transform2, [portPosition.x, portPosition.y]);
53390
53623
  const scaledWidth = width * Math.abs(transform2.a);
53391
53624
  const scaledHeight = height * Math.abs(transform2.d);
53392
53625
  const isTopLayer = layer === "top";
@@ -53524,7 +53757,7 @@ function getRectPathData(w3, h, rotation2) {
53524
53757
  }
53525
53758
  function createSvgObjectsFromAssemblyHole(hole, ctx) {
53526
53759
  const { transform: transform2 } = ctx;
53527
- const [x3, y] = applyToPoint19(transform2, [hole.x, hole.y]);
53760
+ const [x3, y] = applyToPoint20(transform2, [hole.x, hole.y]);
53528
53761
  if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
53529
53762
  const scaledDiameter = hole.hole_diameter * Math.abs(transform2.a);
53530
53763
  const radius = scaledDiameter / 2;
@@ -53588,7 +53821,7 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
53588
53821
  }
53589
53822
  function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
53590
53823
  const { transform: transform2 } = ctx;
53591
- const [x3, y] = applyToPoint19(transform2, [hole.x, hole.y]);
53824
+ const [x3, y] = applyToPoint20(transform2, [hole.x, hole.y]);
53592
53825
  if (hole.shape === "pill") {
53593
53826
  const scaledOuterWidth = hole.outer_width * Math.abs(transform2.a);
53594
53827
  const scaledOuterHeight = hole.outer_height * Math.abs(transform2.a);
@@ -53682,7 +53915,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
53682
53915
  const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform2.a);
53683
53916
  const rectCcwRotation = circularHole.rect_ccw_rotation ?? 0;
53684
53917
  const holeRadius = scaledHoleDiameter / 2;
53685
- const [holeCx, holeCy] = applyToPoint19(transform2, [
53918
+ const [holeCx, holeCy] = applyToPoint20(transform2, [
53686
53919
  circularHole.x + circularHole.hole_offset_x,
53687
53920
  circularHole.y + circularHole.hole_offset_y
53688
53921
  ]);
@@ -53744,7 +53977,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
53744
53977
  const pillHoleWithOffsets = pillHole;
53745
53978
  const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
53746
53979
  const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
53747
- const [holeCenterX, holeCenterY] = applyToPoint19(transform2, [
53980
+ const [holeCenterX, holeCenterY] = applyToPoint20(transform2, [
53748
53981
  pillHole.x + holeOffsetX,
53749
53982
  pillHole.y + holeOffsetY
53750
53983
  ]);
@@ -53804,7 +54037,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
53804
54037
  const rotatedHoleWithOffsets = rotatedHole;
53805
54038
  const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
53806
54039
  const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
53807
- const [holeCenterX, holeCenterY] = applyToPoint19(transform2, [
54040
+ const [holeCenterX, holeCenterY] = applyToPoint20(transform2, [
53808
54041
  rotatedHole.x + holeOffsetX,
53809
54042
  rotatedHole.y + holeOffsetY
53810
54043
  ]);
@@ -53863,7 +54096,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
53863
54096
  if (pad.shape === "rect" || pad.shape === "rotated_rect") {
53864
54097
  const width = pad.width * Math.abs(transform2.a);
53865
54098
  const height = pad.height * Math.abs(transform2.d);
53866
- const [x3, y] = applyToPoint19(transform2, [pad.x, pad.y]);
54099
+ const [x3, y] = applyToPoint20(transform2, [pad.x, pad.y]);
53867
54100
  const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform2.a);
53868
54101
  if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
53869
54102
  return [
@@ -53915,7 +54148,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
53915
54148
  const width = pad.width * Math.abs(transform2.a);
53916
54149
  const height = pad.height * Math.abs(transform2.d);
53917
54150
  const radius = pad.radius * Math.abs(transform2.a);
53918
- const [x3, y] = applyToPoint19(transform2, [pad.x, pad.y]);
54151
+ const [x3, y] = applyToPoint20(transform2, [pad.x, pad.y]);
53919
54152
  return [
53920
54153
  {
53921
54154
  name: "rect",
@@ -53938,7 +54171,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
53938
54171
  }
53939
54172
  if (pad.shape === "circle") {
53940
54173
  const radius = pad.radius * Math.abs(transform2.a);
53941
- const [x3, y] = applyToPoint19(transform2, [pad.x, pad.y]);
54174
+ const [x3, y] = applyToPoint20(transform2, [pad.x, pad.y]);
53942
54175
  return [
53943
54176
  {
53944
54177
  name: "circle",
@@ -53957,7 +54190,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
53957
54190
  ];
53958
54191
  }
53959
54192
  if (pad.shape === "polygon") {
53960
- const points = (pad.points ?? []).map((point2) => applyToPoint19(transform2, [point2.x, point2.y]));
54193
+ const points = (pad.points ?? []).map((point2) => applyToPoint20(transform2, [point2.x, point2.y]));
53961
54194
  return [
53962
54195
  {
53963
54196
  name: "polygon",
@@ -54117,8 +54350,8 @@ function createSvgObjects2(elm, ctx, soup) {
54117
54350
  }
54118
54351
  }
54119
54352
  function createSvgObjectFromAssemblyBoundary(transform2, minX, minY, maxX, maxY) {
54120
- const [x12, y12] = applyToPoint19(transform2, [minX, minY]);
54121
- const [x22, y22] = applyToPoint19(transform2, [maxX, maxY]);
54353
+ const [x12, y12] = applyToPoint20(transform2, [minX, minY]);
54354
+ const [x22, y22] = applyToPoint20(transform2, [maxX, maxY]);
54122
54355
  const width = Math.abs(x22 - x12);
54123
54356
  const height = Math.abs(y22 - y12);
54124
54357
  const x3 = Math.min(x12, x22);
@@ -54145,25 +54378,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
54145
54378
  let path42;
54146
54379
  if (outline && Array.isArray(outline) && outline.length >= 3) {
54147
54380
  path42 = outline.map((point2, index) => {
54148
- const [x3, y] = applyToPoint19(transform2, [point2.x, point2.y]);
54381
+ const [x3, y] = applyToPoint20(transform2, [point2.x, point2.y]);
54149
54382
  return index === 0 ? `M ${x3} ${y}` : `L ${x3} ${y}`;
54150
54383
  }).join(" ");
54151
54384
  } else {
54152
54385
  const halfWidth = width / 2;
54153
54386
  const halfHeight = height / 2;
54154
- const topLeft = applyToPoint19(transform2, [
54387
+ const topLeft = applyToPoint20(transform2, [
54155
54388
  center.x - halfWidth,
54156
54389
  center.y - halfHeight
54157
54390
  ]);
54158
- const topRight = applyToPoint19(transform2, [
54391
+ const topRight = applyToPoint20(transform2, [
54159
54392
  center.x + halfWidth,
54160
54393
  center.y - halfHeight
54161
54394
  ]);
54162
- const bottomRight = applyToPoint19(transform2, [
54395
+ const bottomRight = applyToPoint20(transform2, [
54163
54396
  center.x + halfWidth,
54164
54397
  center.y + halfHeight
54165
54398
  ]);
54166
- const bottomLeft = applyToPoint19(transform2, [
54399
+ const bottomLeft = applyToPoint20(transform2, [
54167
54400
  center.x - halfWidth,
54168
54401
  center.y + halfHeight
54169
54402
  ]);
@@ -54181,10 +54414,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
54181
54414
  const halfWidth = width2 / 2;
54182
54415
  const halfHeight = height2 / 2;
54183
54416
  const [tl2, tr2, br2, bl2] = [
54184
- applyToPoint19(transform2, [x3 - halfWidth, y - halfHeight]),
54185
- applyToPoint19(transform2, [x3 + halfWidth, y - halfHeight]),
54186
- applyToPoint19(transform2, [x3 + halfWidth, y + halfHeight]),
54187
- applyToPoint19(transform2, [x3 - halfWidth, y + halfHeight])
54417
+ applyToPoint20(transform2, [x3 - halfWidth, y - halfHeight]),
54418
+ applyToPoint20(transform2, [x3 + halfWidth, y - halfHeight]),
54419
+ applyToPoint20(transform2, [x3 + halfWidth, y + halfHeight]),
54420
+ applyToPoint20(transform2, [x3 - halfWidth, y + halfHeight])
54188
54421
  ];
54189
54422
  path42 += ` M ${tl2[0]} ${tl2[1]} L ${tr2[0]} ${tr2[1]} L ${br2[0]} ${br2[1]} L ${bl2[0]} ${bl2[1]} Z`;
54190
54423
  } else if (cutout.shape === "circle") {}
@@ -54237,7 +54470,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
54237
54470
  if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
54238
54471
  return [];
54239
54472
  }
54240
- const [x3, y] = applyToPoint19(transform2, [center.x, center.y]);
54473
+ const [x3, y] = applyToPoint20(transform2, [center.x, center.y]);
54241
54474
  const scaledWidth = width * Math.abs(transform2.a);
54242
54475
  const scaledHeight = height * Math.abs(transform2.d);
54243
54476
  const transformStr = `translate(${x3}, ${y})`;
@@ -54298,7 +54531,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
54298
54531
  }
54299
54532
  function createSvgObjectsFromPinoutHole(hole, ctx) {
54300
54533
  const { transform: transform2 } = ctx;
54301
- const [x3, y] = applyToPoint19(transform2, [hole.x, hole.y]);
54534
+ const [x3, y] = applyToPoint20(transform2, [hole.x, hole.y]);
54302
54535
  if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
54303
54536
  const scaledDiameter = hole.hole_diameter * Math.abs(transform2.a);
54304
54537
  const radius = scaledDiameter / 2;
@@ -54362,7 +54595,7 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
54362
54595
  }
54363
54596
  function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
54364
54597
  const { transform: transform2 } = ctx;
54365
- const [x3, y] = applyToPoint19(transform2, [hole.x, hole.y]);
54598
+ const [x3, y] = applyToPoint20(transform2, [hole.x, hole.y]);
54366
54599
  if (hole.shape === "pill") {
54367
54600
  const scaledOuterWidth = hole.outer_width * Math.abs(transform2.a);
54368
54601
  const scaledOuterHeight = hole.outer_height * Math.abs(transform2.a);
@@ -54594,7 +54827,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
54594
54827
  if (pad.shape === "rect" || pad.shape === "rotated_rect") {
54595
54828
  const width = pad.width * Math.abs(transform2.a);
54596
54829
  const height = pad.height * Math.abs(transform2.d);
54597
- const [x3, y] = applyToPoint19(transform2, [pad.x, pad.y]);
54830
+ const [x3, y] = applyToPoint20(transform2, [pad.x, pad.y]);
54598
54831
  if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
54599
54832
  return [
54600
54833
  {
@@ -54637,7 +54870,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
54637
54870
  const width = pad.width * Math.abs(transform2.a);
54638
54871
  const height = pad.height * Math.abs(transform2.d);
54639
54872
  const radius = pad.radius * Math.abs(transform2.a);
54640
- const [x3, y] = applyToPoint19(transform2, [pad.x, pad.y]);
54873
+ const [x3, y] = applyToPoint20(transform2, [pad.x, pad.y]);
54641
54874
  return [
54642
54875
  {
54643
54876
  name: "rect",
@@ -54660,7 +54893,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
54660
54893
  }
54661
54894
  if (pad.shape === "circle") {
54662
54895
  const radius = pad.radius * Math.abs(transform2.a);
54663
- const [x3, y] = applyToPoint19(transform2, [pad.x, pad.y]);
54896
+ const [x3, y] = applyToPoint20(transform2, [pad.x, pad.y]);
54664
54897
  return [
54665
54898
  {
54666
54899
  name: "circle",
@@ -54679,7 +54912,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
54679
54912
  ];
54680
54913
  }
54681
54914
  if (pad.shape === "polygon") {
54682
- const points = (pad.points ?? []).map((point2) => applyToPoint19(transform2, [point2.x, point2.y]));
54915
+ const points = (pad.points ?? []).map((point2) => applyToPoint20(transform2, [point2.x, point2.y]));
54683
54916
  return [
54684
54917
  {
54685
54918
  name: "polygon",
@@ -54764,7 +54997,7 @@ function createSvgObjectsFromPinoutPort(pcb_port2, ctx) {
54764
54997
  if (!label_info)
54765
54998
  return [];
54766
54999
  const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
54767
- const [port_x, port_y] = applyToPoint19(ctx.transform, [pcb_port2.x, pcb_port2.y]);
55000
+ const [port_x, port_y] = applyToPoint20(ctx.transform, [pcb_port2.x, pcb_port2.y]);
54768
55001
  const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
54769
55002
  const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
54770
55003
  const elbow_path = calculateElbow({
@@ -54914,7 +55147,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
54914
55147
  const other_pins = pinout_labels.filter((l) => Math.abs(l.pcb_port.x - primary_x) >= 0.2);
54915
55148
  const mapToEdgePort = (pinout_label) => ({
54916
55149
  pcb_port: pinout_label.pcb_port,
54917
- y: applyToPoint19(transform2, [
55150
+ y: applyToPoint20(transform2, [
54918
55151
  pinout_label.pcb_port.x,
54919
55152
  pinout_label.pcb_port.y
54920
55153
  ])[1],
@@ -54929,7 +55162,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
54929
55162
  } else {
54930
55163
  edge_ports = pinout_labels.map((pinout_label) => ({
54931
55164
  pcb_port: pinout_label.pcb_port,
54932
- y: applyToPoint19(transform2, [
55165
+ y: applyToPoint20(transform2, [
54933
55166
  pinout_label.pcb_port.x,
54934
55167
  pinout_label.pcb_port.y
54935
55168
  ])[1],
@@ -54938,7 +55171,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
54938
55171
  }
54939
55172
  if (edge_ports.length === 0)
54940
55173
  return;
54941
- const board_edge_x = applyToPoint19(transform2, [
55174
+ const board_edge_x = applyToPoint20(transform2, [
54942
55175
  edge === "left" ? board_bounds.minX : board_bounds.maxX,
54943
55176
  0
54944
55177
  ])[0];
@@ -55285,7 +55518,7 @@ function drawSchematicGrid(params2) {
55285
55518
  const labelCells = params2.labelCells ?? false;
55286
55519
  const gridLines = [];
55287
55520
  const transformPoint = (x3, y) => {
55288
- const [transformedX, transformedY] = applyToPoint19(params2.transform, [x3, y]);
55521
+ const [transformedX, transformedY] = applyToPoint20(params2.transform, [x3, y]);
55289
55522
  return { x: transformedX, y: transformedY };
55290
55523
  };
55291
55524
  for (let x3 = Math.floor(minX);x3 <= Math.ceil(maxX); x3 += cellSize) {
@@ -55369,10 +55602,10 @@ function drawSchematicLabeledPoints(params2) {
55369
55602
  const { points, transform: transform2 } = params2;
55370
55603
  const labeledPointsGroup = [];
55371
55604
  for (const point2 of points) {
55372
- const [x12, y12] = applyToPoint19(transform2, [point2.x - 0.1, point2.y - 0.1]);
55373
- const [x22, y22] = applyToPoint19(transform2, [point2.x + 0.1, point2.y + 0.1]);
55374
- const [x3, y32] = applyToPoint19(transform2, [point2.x - 0.1, point2.y + 0.1]);
55375
- const [x4, y4] = applyToPoint19(transform2, [point2.x + 0.1, point2.y - 0.1]);
55605
+ const [x12, y12] = applyToPoint20(transform2, [point2.x - 0.1, point2.y - 0.1]);
55606
+ const [x22, y22] = applyToPoint20(transform2, [point2.x + 0.1, point2.y + 0.1]);
55607
+ const [x3, y32] = applyToPoint20(transform2, [point2.x - 0.1, point2.y + 0.1]);
55608
+ const [x4, y4] = applyToPoint20(transform2, [point2.x + 0.1, point2.y - 0.1]);
55376
55609
  labeledPointsGroup.push({
55377
55610
  name: "path",
55378
55611
  type: "element",
@@ -55383,7 +55616,7 @@ function drawSchematicLabeledPoints(params2) {
55383
55616
  "stroke-opacity": "0.7"
55384
55617
  }
55385
55618
  });
55386
- const [labelX, labelY] = applyToPoint19(transform2, [
55619
+ const [labelX, labelY] = applyToPoint20(transform2, [
55387
55620
  point2.x + 0.15,
55388
55621
  point2.y - 0.15
55389
55622
  ]);
@@ -55600,7 +55833,7 @@ function createSvgObjectsFromSchVoltageProbe({
55600
55833
  transform: transform2,
55601
55834
  colorMap: colorMap2
55602
55835
  }) {
55603
- const [screenX, screenY] = applyToPoint19(transform2, [
55836
+ const [screenX, screenY] = applyToPoint20(transform2, [
55604
55837
  probe.position.x,
55605
55838
  probe.position.y
55606
55839
  ]);
@@ -55777,11 +56010,11 @@ function createSvgObjectsFromSchDebugObject({
55777
56010
  transform: transform2
55778
56011
  }) {
55779
56012
  if (debugObject.shape === "rect") {
55780
- let [screenLeft, screenTop] = applyToPoint19(transform2, [
56013
+ let [screenLeft, screenTop] = applyToPoint20(transform2, [
55781
56014
  debugObject.center.x - debugObject.size.width / 2,
55782
56015
  debugObject.center.y - debugObject.size.height / 2
55783
56016
  ]);
55784
- let [screenRight, screenBottom] = applyToPoint19(transform2, [
56017
+ let [screenRight, screenBottom] = applyToPoint20(transform2, [
55785
56018
  debugObject.center.x + debugObject.size.width / 2,
55786
56019
  debugObject.center.y + debugObject.size.height / 2
55787
56020
  ]);
@@ -55791,7 +56024,7 @@ function createSvgObjectsFromSchDebugObject({
55791
56024
  ];
55792
56025
  const width = Math.abs(screenRight - screenLeft);
55793
56026
  const height = Math.abs(screenBottom - screenTop);
55794
- const [screenCenterX, screenCenterY] = applyToPoint19(transform2, [
56027
+ const [screenCenterX, screenCenterY] = applyToPoint20(transform2, [
55795
56028
  debugObject.center.x,
55796
56029
  debugObject.center.y
55797
56030
  ]);
@@ -55837,11 +56070,11 @@ function createSvgObjectsFromSchDebugObject({
55837
56070
  ];
55838
56071
  }
55839
56072
  if (debugObject.shape === "line") {
55840
- const [screenStartX, screenStartY] = applyToPoint19(transform2, [
56073
+ const [screenStartX, screenStartY] = applyToPoint20(transform2, [
55841
56074
  debugObject.start.x,
55842
56075
  debugObject.start.y
55843
56076
  ]);
55844
- const [screenEndX, screenEndY] = applyToPoint19(transform2, [
56077
+ const [screenEndX, screenEndY] = applyToPoint20(transform2, [
55845
56078
  debugObject.end.x,
55846
56079
  debugObject.end.y
55847
56080
  ]);
@@ -55904,11 +56137,11 @@ function createSchematicTrace({
55904
56137
  const edge = edges[edgeIndex];
55905
56138
  if (edge.is_crossing)
55906
56139
  continue;
55907
- const [screenFromX, screenFromY] = applyToPoint19(transform2, [
56140
+ const [screenFromX, screenFromY] = applyToPoint20(transform2, [
55908
56141
  edge.from.x,
55909
56142
  edge.from.y
55910
56143
  ]);
55911
- const [screenToX, screenToY] = applyToPoint19(transform2, [
56144
+ const [screenToX, screenToY] = applyToPoint20(transform2, [
55912
56145
  edge.to.x,
55913
56146
  edge.to.y
55914
56147
  ]);
@@ -55953,11 +56186,11 @@ function createSchematicTrace({
55953
56186
  for (const edge of edges) {
55954
56187
  if (!edge.is_crossing)
55955
56188
  continue;
55956
- const [screenFromX, screenFromY] = applyToPoint19(transform2, [
56189
+ const [screenFromX, screenFromY] = applyToPoint20(transform2, [
55957
56190
  edge.from.x,
55958
56191
  edge.from.y
55959
56192
  ]);
55960
- const [screenToX, screenToY] = applyToPoint19(transform2, [
56193
+ const [screenToX, screenToY] = applyToPoint20(transform2, [
55961
56194
  edge.to.x,
55962
56195
  edge.to.y
55963
56196
  ]);
@@ -56001,7 +56234,7 @@ function createSchematicTrace({
56001
56234
  }
56002
56235
  if (trace.junctions) {
56003
56236
  for (const junction of trace.junctions) {
56004
- const [screenX, screenY] = applyToPoint19(transform2, [
56237
+ const [screenX, screenY] = applyToPoint20(transform2, [
56005
56238
  junction.x,
56006
56239
  junction.y
56007
56240
  ]);
@@ -56058,8 +56291,8 @@ function createSvgObjectsFromSchematicLine({
56058
56291
  transform: transform2,
56059
56292
  colorMap: colorMap2
56060
56293
  }) {
56061
- const p12 = applyToPoint19(transform2, { x: schLine.x1, y: schLine.y1 });
56062
- const p22 = applyToPoint19(transform2, { x: schLine.x2, y: schLine.y2 });
56294
+ const p12 = applyToPoint20(transform2, { x: schLine.x1, y: schLine.y1 });
56295
+ const p22 = applyToPoint20(transform2, { x: schLine.x2, y: schLine.y2 });
56063
56296
  const strokeWidth = schLine.stroke_width ?? 0.02;
56064
56297
  const transformedStrokeWidth = Math.abs(transform2.a) * strokeWidth;
56065
56298
  return [
@@ -56091,7 +56324,7 @@ function createSvgObjectsFromSchematicCircle({
56091
56324
  transform: transform2,
56092
56325
  colorMap: colorMap2
56093
56326
  }) {
56094
- const center = applyToPoint19(transform2, schCircle.center);
56327
+ const center = applyToPoint20(transform2, schCircle.center);
56095
56328
  const transformedRadius = Math.abs(transform2.a) * schCircle.radius;
56096
56329
  const strokeWidth = schCircle.stroke_width ?? 0.02;
56097
56330
  const transformedStrokeWidth = Math.abs(transform2.a) * strokeWidth;
@@ -56124,7 +56357,7 @@ function createSvgObjectsFromSchematicRect({
56124
56357
  transform: transform2,
56125
56358
  colorMap: colorMap2
56126
56359
  }) {
56127
- const center = applyToPoint19(transform2, schRect.center);
56360
+ const center = applyToPoint20(transform2, schRect.center);
56128
56361
  const transformedWidth = Math.abs(transform2.a) * schRect.width;
56129
56362
  const transformedHeight = Math.abs(transform2.d) * schRect.height;
56130
56363
  const strokeWidth = schRect.stroke_width ?? 0.02;
@@ -56163,7 +56396,7 @@ function createSvgObjectsFromSchematicArc({
56163
56396
  transform: transform2,
56164
56397
  colorMap: colorMap2
56165
56398
  }) {
56166
- const center = applyToPoint19(transform2, schArc.center);
56399
+ const center = applyToPoint20(transform2, schArc.center);
56167
56400
  const transformedRadius = Math.abs(transform2.a) * schArc.radius;
56168
56401
  const strokeWidth = schArc.stroke_width ?? 0.02;
56169
56402
  const transformedStrokeWidth = Math.abs(transform2.a) * strokeWidth;
@@ -56216,7 +56449,7 @@ function createSvgObjectsFromSchematicPath({
56216
56449
  if (!schPath.points || schPath.points.length < 2) {
56217
56450
  return [];
56218
56451
  }
56219
- const transformedPoints = schPath.points.map((p) => applyToPoint19(transform2, { x: p.x, y: p.y }));
56452
+ const transformedPoints = schPath.points.map((p) => applyToPoint20(transform2, { x: p.x, y: p.y }));
56220
56453
  const pathD = transformedPoints.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`).join(" ");
56221
56454
  return [
56222
56455
  {
@@ -57163,7 +57396,7 @@ function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
57163
57396
  const { transform: transform2, layer: layerFilter } = ctx;
57164
57397
  if (layerFilter && solderPaste.layer !== layerFilter)
57165
57398
  return [];
57166
- const [x3, y] = applyToPoint19(transform2, [solderPaste.x, solderPaste.y]);
57399
+ const [x3, y] = applyToPoint20(transform2, [solderPaste.x, solderPaste.y]);
57167
57400
  if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
57168
57401
  const width = solderPaste.width * Math.abs(transform2.a);
57169
57402
  const height = solderPaste.height * Math.abs(transform2.d);
@@ -57372,8 +57605,8 @@ function createSvgObjects4({ elm, ctx }) {
57372
57605
  }
57373
57606
  }
57374
57607
  function createSvgObjectFromPcbBoundary2(transform2, minX, minY, maxX, maxY) {
57375
- const [x12, y12] = applyToPoint19(transform2, [minX, minY]);
57376
- const [x22, y22] = applyToPoint19(transform2, [maxX, maxY]);
57608
+ const [x12, y12] = applyToPoint20(transform2, [minX, minY]);
57609
+ const [x22, y22] = applyToPoint20(transform2, [maxX, maxY]);
57377
57610
  const width = Math.abs(x22 - x12);
57378
57611
  const height = Math.abs(y22 - y12);
57379
57612
  const x3 = Math.min(x12, x22);
@@ -57690,7 +57923,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
57690
57923
  realCenter,
57691
57924
  realToScreenTransform
57692
57925
  }) => {
57693
- const screenCenter = applyToPoint19(realToScreenTransform, realCenter);
57926
+ const screenCenter = applyToPoint20(realToScreenTransform, realCenter);
57694
57927
  return {
57695
57928
  type: "element",
57696
57929
  name: "text",
@@ -57776,8 +58009,8 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
57776
58009
  minY: Math.min(...paths.flatMap((p) => p.points.map((pt2) => pt2.y))),
57777
58010
  maxY: Math.max(...paths.flatMap((p) => p.points.map((pt2) => pt2.y)))
57778
58011
  };
57779
- const [screenMinX, screenMinY] = applyToPoint19(compose5(realToScreenTransform, transformFromSymbolToReal), [bounds.minX, bounds.minY]);
57780
- const [screenMaxX, screenMaxY] = applyToPoint19(compose5(realToScreenTransform, transformFromSymbolToReal), [bounds.maxX, bounds.maxY]);
58012
+ const [screenMinX, screenMinY] = applyToPoint20(compose5(realToScreenTransform, transformFromSymbolToReal), [bounds.minX, bounds.minY]);
58013
+ const [screenMaxX, screenMaxY] = applyToPoint20(compose5(realToScreenTransform, transformFromSymbolToReal), [bounds.maxX, bounds.maxY]);
57781
58014
  const rectHeight = Math.abs(screenMaxY - screenMinY);
57782
58015
  const rectY = Math.min(screenMinY, screenMaxY);
57783
58016
  const rectWidth = Math.abs(screenMaxX - screenMinX);
@@ -57803,7 +58036,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
57803
58036
  name: "path",
57804
58037
  attributes: {
57805
58038
  d: points.map((p, i) => {
57806
- const [x3, y] = applyToPoint19(compose5(realToScreenTransform, transformFromSymbolToReal), [p.x, p.y]);
58039
+ const [x3, y] = applyToPoint20(compose5(realToScreenTransform, transformFromSymbolToReal), [p.x, p.y]);
57807
58040
  return `${i === 0 ? "M" : "L"} ${x3} ${y}`;
57808
58041
  }).join(" ") + (closed ? " Z" : ""),
57809
58042
  stroke: colorMap2.schematic.component_outline,
@@ -57816,7 +58049,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
57816
58049
  });
57817
58050
  }
57818
58051
  for (const text of texts) {
57819
- const screenTextPos = applyToPoint19(compose5(realToScreenTransform, transformFromSymbolToReal), text);
58052
+ const screenTextPos = applyToPoint20(compose5(realToScreenTransform, transformFromSymbolToReal), text);
57820
58053
  let textValue = "";
57821
58054
  const isReferenceText = text.text === "{REF}";
57822
58055
  if (isReferenceText) {
@@ -57855,7 +58088,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
57855
58088
  });
57856
58089
  }
57857
58090
  for (const box of boxes) {
57858
- const screenBoxPos = applyToPoint19(compose5(realToScreenTransform, transformFromSymbolToReal), box);
58091
+ const screenBoxPos = applyToPoint20(compose5(realToScreenTransform, transformFromSymbolToReal), box);
57859
58092
  const symbolToScreenScale = compose5(realToScreenTransform, transformFromSymbolToReal).a;
57860
58093
  svgObjects.push({
57861
58094
  name: "rect",
@@ -57874,7 +58107,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
57874
58107
  for (const port of symbol.ports) {
57875
58108
  if (connectedSymbolPorts.has(port))
57876
58109
  continue;
57877
- const screenPortPos = applyToPoint19(compose5(realToScreenTransform, transformFromSymbolToReal), port);
58110
+ const screenPortPos = applyToPoint20(compose5(realToScreenTransform, transformFromSymbolToReal), port);
57878
58111
  svgObjects.push({
57879
58112
  type: "element",
57880
58113
  name: "circle",
@@ -57891,7 +58124,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
57891
58124
  });
57892
58125
  }
57893
58126
  for (const circle of circles) {
57894
- const screenCirclePos = applyToPoint19(compose5(realToScreenTransform, transformFromSymbolToReal), circle);
58127
+ const screenCirclePos = applyToPoint20(compose5(realToScreenTransform, transformFromSymbolToReal), circle);
57895
58128
  const screenRadius = Math.abs(circle.radius * realToScreenTransform.a);
57896
58129
  svgObjects.push({
57897
58130
  type: "element",
@@ -57958,8 +58191,8 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
57958
58191
  realEdgePos.y += realPinLineLength;
57959
58192
  break;
57960
58193
  }
57961
- const screenSchPortPos = applyToPoint19(transform2, schPort.center);
57962
- const screenRealEdgePos = applyToPoint19(transform2, realEdgePos);
58194
+ const screenSchPortPos = applyToPoint20(transform2, schPort.center);
58195
+ const screenRealEdgePos = applyToPoint20(transform2, realEdgePos);
57963
58196
  const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
57964
58197
  const is_drawn_with_inversion_circle = schPort.is_drawn_with_inversion_circle ?? false;
57965
58198
  const BUBBLE_RADIUS_MM = 0.06;
@@ -57980,7 +58213,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
57980
58213
  break;
57981
58214
  }
57982
58215
  }
57983
- const screenLineEnd = applyToPoint19(transform2, realLineEnd);
58216
+ const screenLineEnd = applyToPoint20(transform2, realLineEnd);
57984
58217
  if (is_drawn_with_inversion_circle) {
57985
58218
  const bubbleRadiusPx = Math.abs(transform2.a) * BUBBLE_RADIUS_MM;
57986
58219
  const bubbleCenter = { ...screenRealEdgePos };
@@ -58137,7 +58370,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58137
58370
  } else {
58138
58371
  realPinNumberPos.y += 0.02;
58139
58372
  }
58140
- const screenPinNumberTextPos = applyToPoint19(transform2, realPinNumberPos);
58373
+ const screenPinNumberTextPos = applyToPoint20(transform2, realPinNumberPos);
58141
58374
  svgObjects.push({
58142
58375
  name: "text",
58143
58376
  type: "element",
@@ -58177,7 +58410,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58177
58410
  const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
58178
58411
  realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
58179
58412
  realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
58180
- const screenPinNumberTextPos = applyToPoint19(transform2, realPinNumberPos);
58413
+ const screenPinNumberTextPos = applyToPoint20(transform2, realPinNumberPos);
58181
58414
  const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
58182
58415
  if (!label)
58183
58416
  return [];
@@ -58223,7 +58456,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58223
58456
  transform: transform2,
58224
58457
  colorMap: colorMap2
58225
58458
  }) => {
58226
- const center = applyToPoint19(transform2, elm.position);
58459
+ const center = applyToPoint20(transform2, elm.position);
58227
58460
  const textAnchorMap = {
58228
58461
  center: "middle",
58229
58462
  center_right: "end",
@@ -58305,11 +58538,11 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58305
58538
  colorMap: colorMap2
58306
58539
  }) => {
58307
58540
  const svgObjects = [];
58308
- const componentScreenTopLeft = applyToPoint19(transform2, {
58541
+ const componentScreenTopLeft = applyToPoint20(transform2, {
58309
58542
  x: schComponent.center.x - schComponent.size.width / 2,
58310
58543
  y: schComponent.center.y + schComponent.size.height / 2
58311
58544
  });
58312
- const componentScreenBottomRight = applyToPoint19(transform2, {
58545
+ const componentScreenBottomRight = applyToPoint20(transform2, {
58313
58546
  x: schComponent.center.x + schComponent.size.width / 2,
58314
58547
  y: schComponent.center.y - schComponent.size.height / 2
58315
58548
  });
@@ -58416,10 +58649,10 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58416
58649
  x: symbolBounds.minX,
58417
58650
  y: (symbolBounds.minY + symbolBounds.maxY) / 2
58418
58651
  };
58419
- const rotatedSymbolEnd = applyToPoint19(rotationMatrix, symbolEndPoint);
58652
+ const rotatedSymbolEnd = applyToPoint20(rotationMatrix, symbolEndPoint);
58420
58653
  const symbolToRealTransform = compose5(translate5(realAnchorPosition.x - rotatedSymbolEnd.x, realAnchorPosition.y - rotatedSymbolEnd.y), rotationMatrix, scale4(1));
58421
- const [screenMinX, screenMinY] = applyToPoint19(compose5(realToScreenTransform, symbolToRealTransform), [bounds.minX, bounds.minY]);
58422
- const [screenMaxX, screenMaxY] = applyToPoint19(compose5(realToScreenTransform, symbolToRealTransform), [bounds.maxX, bounds.maxY]);
58654
+ const [screenMinX, screenMinY] = applyToPoint20(compose5(realToScreenTransform, symbolToRealTransform), [bounds.minX, bounds.minY]);
58655
+ const [screenMaxX, screenMaxY] = applyToPoint20(compose5(realToScreenTransform, symbolToRealTransform), [bounds.maxX, bounds.maxY]);
58423
58656
  const rectHeight = Math.abs(screenMaxY - screenMinY);
58424
58657
  const rectY = Math.min(screenMinY, screenMaxY);
58425
58658
  const rectWidth = Math.abs(screenMaxX - screenMinX);
@@ -58440,7 +58673,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58440
58673
  });
58441
58674
  for (const path42 of symbolPaths) {
58442
58675
  const symbolPath = path42.points.map((p, i) => {
58443
- const [x3, y] = applyToPoint19(compose5(realToScreenTransform, symbolToRealTransform), [p.x, p.y]);
58676
+ const [x3, y] = applyToPoint20(compose5(realToScreenTransform, symbolToRealTransform), [p.x, p.y]);
58444
58677
  return `${i === 0 ? "M" : "L"} ${x3} ${y}`;
58445
58678
  }).join(" ");
58446
58679
  svgObjects.push({
@@ -58458,7 +58691,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58458
58691
  });
58459
58692
  }
58460
58693
  for (const text of symbolTexts) {
58461
- const screenTextPos = applyToPoint19(compose5(realToScreenTransform, symbolToRealTransform), text);
58694
+ const screenTextPos = applyToPoint20(compose5(realToScreenTransform, symbolToRealTransform), text);
58462
58695
  let textValue = text.text;
58463
58696
  if (textValue === "{REF}") {
58464
58697
  textValue = labelText || "";
@@ -58497,7 +58730,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58497
58730
  });
58498
58731
  }
58499
58732
  for (const box of symbolBoxes) {
58500
- const screenBoxPos = applyToPoint19(compose5(realToScreenTransform, symbolToRealTransform), box);
58733
+ const screenBoxPos = applyToPoint20(compose5(realToScreenTransform, symbolToRealTransform), box);
58501
58734
  const symbolToScreenScale = compose5(realToScreenTransform, symbolToRealTransform).a;
58502
58735
  svgObjects.push({
58503
58736
  name: "rect",
@@ -58514,7 +58747,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58514
58747
  });
58515
58748
  }
58516
58749
  for (const circle of symbolCircles) {
58517
- const screenCirclePos = applyToPoint19(compose5(realToScreenTransform, symbolToRealTransform), circle);
58750
+ const screenCirclePos = applyToPoint20(compose5(realToScreenTransform, symbolToRealTransform), circle);
58518
58751
  const symbolToScreenScale = compose5(realToScreenTransform, symbolToRealTransform).a;
58519
58752
  svgObjects.push({
58520
58753
  name: "circle",
@@ -58551,12 +58784,12 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58551
58784
  const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
58552
58785
  const fontSizeMm = getSchMmFontSize("net_label");
58553
58786
  const textWidthFSR = estimateTextWidth(labelText || "");
58554
- const screenCenter = applyToPoint19(realToScreenTransform, schNetLabel.center);
58787
+ const screenCenter = applyToPoint20(realToScreenTransform, schNetLabel.center);
58555
58788
  const realTextGrowthVec = getUnitVectorFromOutsideToEdge(schNetLabel.anchor_side);
58556
58789
  const screenTextGrowthVec = { ...realTextGrowthVec };
58557
58790
  screenTextGrowthVec.y *= -1;
58558
58791
  const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
58559
- const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint19(realToScreenTransform, schNetLabel.anchor_position) : {
58792
+ const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint20(realToScreenTransform, schNetLabel.anchor_position) : {
58560
58793
  x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
58561
58794
  y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
58562
58795
  };
@@ -58591,7 +58824,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58591
58824
  x: ARROW_POINT_WIDTH_FSR,
58592
58825
  y: -0.6
58593
58826
  }
58594
- ].map((fontRelativePoint) => applyToPoint19(compose5(realToScreenTransform, translate5(realAnchorPosition.x, realAnchorPosition.y), scale4(fontSizeMm), rotate6(pathRotation / 180 * Math.PI)), fontRelativePoint));
58827
+ ].map((fontRelativePoint) => applyToPoint20(compose5(realToScreenTransform, translate5(realAnchorPosition.x, realAnchorPosition.y), scale4(fontSizeMm), rotate6(pathRotation / 180 * Math.PI)), fontRelativePoint));
58595
58828
  const pathD = `
58596
58829
  M ${screenOutlinePoints[0].x},${screenOutlinePoints[0].y}
58597
58830
  L ${screenOutlinePoints[1].x},${screenOutlinePoints[1].y}
@@ -58661,11 +58894,11 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58661
58894
  transform: transform2,
58662
58895
  colorMap: colorMap2
58663
58896
  }) => {
58664
- const topLeft = applyToPoint19(transform2, {
58897
+ const topLeft = applyToPoint20(transform2, {
58665
58898
  x: schematicBox.x,
58666
58899
  y: schematicBox.y
58667
58900
  });
58668
- const bottomRight = applyToPoint19(transform2, {
58901
+ const bottomRight = applyToPoint20(transform2, {
58669
58902
  x: schematicBox.x + schematicBox.width,
58670
58903
  y: schematicBox.y + schematicBox.height
58671
58904
  });
@@ -58727,11 +58960,11 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58727
58960
  const svgObjects = [];
58728
58961
  const borderStrokeWidth = border_width * Math.abs(transform2.a);
58729
58962
  const gridStrokeWidth = getSchStrokeSize(transform2);
58730
- const [screenTopLeftX, screenTopLeftY] = applyToPoint19(transform2, [
58963
+ const [screenTopLeftX, screenTopLeftY] = applyToPoint20(transform2, [
58731
58964
  topLeftX,
58732
58965
  topLeftY
58733
58966
  ]);
58734
- const [screenBottomRightX, screenBottomRightY] = applyToPoint19(transform2, [
58967
+ const [screenBottomRightX, screenBottomRightY] = applyToPoint20(transform2, [
58735
58968
  topLeftX + totalWidth,
58736
58969
  topLeftY - totalHeight
58737
58970
  ]);
@@ -58759,8 +58992,8 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58759
58992
  const segmentEndY = segmentStartY - row_heights[j2];
58760
58993
  const isMerged = cells.some((cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j2 && cell.end_row_index >= j2);
58761
58994
  if (!isMerged) {
58762
- const start = applyToPoint19(transform2, { x: currentX, y: segmentStartY });
58763
- const end = applyToPoint19(transform2, { x: currentX, y: segmentEndY });
58995
+ const start = applyToPoint20(transform2, { x: currentX, y: segmentStartY });
58996
+ const end = applyToPoint20(transform2, { x: currentX, y: segmentEndY });
58764
58997
  svgObjects.push({
58765
58998
  name: "line",
58766
58999
  type: "element",
@@ -58787,11 +59020,11 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58787
59020
  const segmentEndX = segmentStartX + column_widths[j2];
58788
59021
  const isMerged = cells.some((cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j2 && cell.end_column_index >= j2);
58789
59022
  if (!isMerged) {
58790
- const start = applyToPoint19(transform2, {
59023
+ const start = applyToPoint20(transform2, {
58791
59024
  x: segmentStartX,
58792
59025
  y: currentY
58793
59026
  });
58794
- const end = applyToPoint19(transform2, { x: segmentEndX, y: currentY });
59027
+ const end = applyToPoint20(transform2, { x: segmentEndX, y: currentY });
58795
59028
  svgObjects.push({
58796
59029
  name: "line",
58797
59030
  type: "element",
@@ -58833,7 +59066,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58833
59066
  } else if (vertical_align === "bottom") {
58834
59067
  realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
58835
59068
  }
58836
- const screenTextAnchorPos = applyToPoint19(transform2, realTextAnchorPos);
59069
+ const screenTextAnchorPos = applyToPoint20(transform2, realTextAnchorPos);
58837
59070
  const fontSize = getSchScreenFontSize(transform2, "reference_designator", cell.font_size);
58838
59071
  const textAnchorMap = {
58839
59072
  left: "start",
@@ -58885,7 +59118,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58885
59118
  schPort,
58886
59119
  transform: transform2
58887
59120
  }) => {
58888
- const screenSchPortPos = applyToPoint19(transform2, schPort.center);
59121
+ const screenSchPortPos = applyToPoint20(transform2, schPort.center);
58889
59122
  const pinRadiusPx = Math.abs(transform2.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
58890
59123
  return [
58891
59124
  {
@@ -58935,7 +59168,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58935
59168
  const svgObjects = [];
58936
59169
  const radiusPx = Math.abs(transform2.a) * PIN_CIRCLE_RADIUS_MM3;
58937
59170
  const strokeWidth = Math.abs(transform2.a) * PIN_CIRCLE_RADIUS_MM3;
58938
- const screenPos = applyToPoint19(transform2, schPort.center);
59171
+ const screenPos = applyToPoint20(transform2, schPort.center);
58939
59172
  svgObjects.push({
58940
59173
  name: "circle",
58941
59174
  type: "element",
@@ -58982,7 +59215,7 @@ var import_debug2, svgAlphabet, lineAlphabet, debug2, debugPcb, debugSch, DEFAUL
58982
59215
  textAnchor = "middle";
58983
59216
  break;
58984
59217
  }
58985
- const screenLabelPos = applyToPoint19(transform2, labelPos);
59218
+ const screenLabelPos = applyToPoint20(transform2, labelPos);
58986
59219
  const fontSizePx = getSchScreenFontSize(transform2, "pin_number");
58987
59220
  if (schPort.facing_direction === "up" || schPort.facing_direction === "down") {
58988
59221
  rotation2 = `rotate(-90 ${screenLabelPos.x} ${screenLabelPos.y})`;
@@ -98176,7 +98409,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
98176
98409
  // lib/getVersion.ts
98177
98410
  import { createRequire as createRequire2 } from "node:module";
98178
98411
  // package.json
98179
- var version = "0.1.1160";
98412
+ var version = "0.1.1162";
98180
98413
  var package_default = {
98181
98414
  name: "@tscircuit/cli",
98182
98415
  version,
@@ -98208,7 +98441,7 @@ var package_default = {
98208
98441
  "bun-match-svg": "^0.0.12",
98209
98442
  chokidar: "4.0.1",
98210
98443
  "circuit-json": "^0.0.403",
98211
- "circuit-json-to-kicad": "^0.0.87",
98444
+ "circuit-json-to-kicad": "^0.0.89",
98212
98445
  "circuit-json-to-readable-netlist": "^0.0.15",
98213
98446
  "circuit-json-to-spice": "^0.0.10",
98214
98447
  "circuit-json-to-tscircuit": "^0.0.9",
@@ -98240,10 +98473,12 @@ var package_default = {
98240
98473
  redaxios: "^0.5.1",
98241
98474
  semver: "^7.6.3",
98242
98475
  tempy: "^3.1.0",
98243
- tscircuit: "0.0.1519-libonly",
98476
+ tscircuit: "0.0.1563-libonly",
98244
98477
  tsx: "^4.7.1",
98245
98478
  "typed-ky": "^0.0.4",
98246
- zod: "^3.23.8"
98479
+ zod: "^3.23.8",
98480
+ "circuit-json-to-step": "^0.0.19",
98481
+ stepts: "^0.0.3"
98247
98482
  },
98248
98483
  peerDependencies: {
98249
98484
  tscircuit: "*"
@@ -102190,6 +102425,8 @@ import { Segment, SegmentNet } from "kicadts";
102190
102425
  import { applyToPoint as applyToPoint14 } from "transformation-matrix";
102191
102426
  import { Via, ViaNet } from "kicadts";
102192
102427
  import { applyToPoint as applyToPoint15 } from "transformation-matrix";
102428
+ import { Footprint as Footprint4 } from "kicadts";
102429
+ import { applyToPoint as applyToPoint16 } from "transformation-matrix";
102193
102430
  import { GrLine } from "kicadts";
102194
102431
  import {
102195
102432
  At as At2,
@@ -102198,8 +102435,8 @@ import {
102198
102435
  TextEffectsFont as TextEffectsFont10,
102199
102436
  TextEffectsJustify as TextEffectsJustify3
102200
102437
  } from "kicadts";
102201
- import { applyToPoint as applyToPoint16 } from "transformation-matrix";
102202
- import { applyToPoint as applyToPoint18 } from "transformation-matrix";
102438
+ import { applyToPoint as applyToPoint17 } from "transformation-matrix";
102439
+ import { applyToPoint as applyToPoint19 } from "transformation-matrix";
102203
102440
  import {
102204
102441
  GrText as GrText2,
102205
102442
  TextEffects as TextEffects11,
@@ -102207,7 +102444,7 @@ import {
102207
102444
  TextEffectsJustify as TextEffectsJustify4,
102208
102445
  At as At3
102209
102446
  } from "kicadts";
102210
- import { applyToPoint as applyToPoint17 } from "transformation-matrix";
102447
+ import { applyToPoint as applyToPoint18 } from "transformation-matrix";
102211
102448
  import { cju as cju3 } from "@tscircuit/circuit-json-util";
102212
102449
  import { cju as cju4 } from "@tscircuit/circuit-json-util";
102213
102450
  import { parseKicadSexpr as parseKicadSexpr2, KicadSch as KicadSch2 } from "kicadts";
@@ -102215,7 +102452,7 @@ import { KicadSymbolLib } from "kicadts";
102215
102452
  import { parseKicadMod } from "kicadts";
102216
102453
  import {
102217
102454
  parseKicadSexpr as parseKicadSexpr3,
102218
- Footprint as Footprint4,
102455
+ Footprint as Footprint5,
102219
102456
  Property as Property3,
102220
102457
  TextEffects as TextEffects12,
102221
102458
  TextEffectsFont as TextEffectsFont12
@@ -104844,7 +105081,7 @@ var AddFootprintsStage = class extends ConverterStage {
104844
105081
  const pcbPlatedHoles = this.ctx.db.pcb_plated_hole?.list().filter((hole) => hole.pcb_component_id === component.pcb_component_id) || [];
104845
105082
  const { pads: thruHolePads } = convertPlatedHoles(pcbPlatedHoles, component.center, component.rotation || 0, component.pcb_component_id, nextPadNumber, getNetInfo);
104846
105083
  fpPads.push(...thruHolePads);
104847
- const pcbHoles = this.ctx.db.pcb_hole?.list().filter((hole) => hole.subcircuit_id === component.subcircuit_id) || [];
105084
+ const pcbHoles = this.ctx.db.pcb_hole?.list().filter((hole) => hole.pcb_component_id === component.pcb_component_id) || [];
104848
105085
  const npthPads = convertNpthHoles(pcbHoles, component.center, component.rotation || 0);
104849
105086
  fpPads.push(...npthPads);
104850
105087
  footprint.fpPads = fpPads;
@@ -105116,6 +105353,52 @@ var AddViasStage = class extends ConverterStage {
105116
105353
  return this.ctx.kicadPcb;
105117
105354
  }
105118
105355
  };
105356
+ var AddStandalonePcbElements = class extends ConverterStage {
105357
+ holesProcessed = 0;
105358
+ standaloneHoles = [];
105359
+ constructor(input, ctx) {
105360
+ super(input, ctx);
105361
+ this.standaloneHoles = this.ctx.db.pcb_hole.list().filter((hole) => !hole.pcb_component_id);
105362
+ }
105363
+ _step() {
105364
+ const { kicadPcb, c2kMatPcb } = this.ctx;
105365
+ if (!kicadPcb) {
105366
+ throw new Error("KicadPcb instance not initialized in context");
105367
+ }
105368
+ if (!c2kMatPcb) {
105369
+ throw new Error("PCB transformation matrix not initialized in context");
105370
+ }
105371
+ if (this.holesProcessed >= this.standaloneHoles.length) {
105372
+ this.finished = true;
105373
+ return;
105374
+ }
105375
+ const hole = this.standaloneHoles[this.holesProcessed];
105376
+ if (!hole) {
105377
+ this.holesProcessed++;
105378
+ return;
105379
+ }
105380
+ const boardOrigin = applyToPoint16(c2kMatPcb, { x: 0, y: 0 });
105381
+ const footprintSeed = `standalone_hole:${hole.pcb_hole_id}:${hole.x},${hole.y}`;
105382
+ const footprint = new Footprint4({
105383
+ libraryLink: "tscircuit:MountingHole",
105384
+ layer: "F.Cu",
105385
+ at: [boardOrigin.x, boardOrigin.y, 0],
105386
+ uuid: generateDeterministicUuid(footprintSeed)
105387
+ });
105388
+ const ccwRotationDegrees = 0;
105389
+ const npthPads = convertNpthHoles([hole], { x: 0, y: 0 }, ccwRotationDegrees);
105390
+ if (npthPads.length > 0) {
105391
+ footprint.fpPads = npthPads;
105392
+ const footprints = kicadPcb.footprints;
105393
+ footprints.push(footprint);
105394
+ kicadPcb.footprints = footprints;
105395
+ }
105396
+ this.holesProcessed++;
105397
+ }
105398
+ getOutput() {
105399
+ return this.ctx.kicadPcb;
105400
+ }
105401
+ };
105119
105402
  function createFabricationNoteTextFromCircuitJson({
105120
105403
  textElement,
105121
105404
  c2kMatPcb
@@ -105123,7 +105406,7 @@ function createFabricationNoteTextFromCircuitJson({
105123
105406
  if (!textElement.text || !textElement.anchor_position) {
105124
105407
  return null;
105125
105408
  }
105126
- const transformedPos = applyToPoint16(c2kMatPcb, {
105409
+ const transformedPos = applyToPoint17(c2kMatPcb, {
105127
105410
  x: textElement.anchor_position.x,
105128
105411
  y: textElement.anchor_position.y
105129
105412
  });
@@ -105179,7 +105462,7 @@ function createGrTextFromCircuitJson({
105179
105462
  if (!textElement.text || !textElement.anchor_position) {
105180
105463
  return null;
105181
105464
  }
105182
- const transformedPos = applyToPoint17(c2kMatPcb, {
105465
+ const transformedPos = applyToPoint18(c2kMatPcb, {
105183
105466
  x: textElement.anchor_position.x,
105184
105467
  y: textElement.anchor_position.y
105185
105468
  });
@@ -105247,11 +105530,11 @@ var AddGraphicsStage = class extends ConverterStage {
105247
105530
  const endPoint = path16.route[i + 1];
105248
105531
  if (!startPoint || !endPoint)
105249
105532
  continue;
105250
- const transformedStart = applyToPoint18(c2kMatPcb, {
105533
+ const transformedStart = applyToPoint19(c2kMatPcb, {
105251
105534
  x: startPoint.x,
105252
105535
  y: startPoint.y
105253
105536
  });
105254
- const transformedEnd = applyToPoint18(c2kMatPcb, {
105537
+ const transformedEnd = applyToPoint19(c2kMatPcb, {
105255
105538
  x: endPoint.x,
105256
105539
  y: endPoint.y
105257
105540
  });
@@ -105315,7 +105598,7 @@ var AddGraphicsStage = class extends ConverterStage {
105315
105598
  { x: board.center.x - halfWidth, y: board.center.y + halfHeight }
105316
105599
  ];
105317
105600
  }
105318
- const transformedCorners = corners.map((corner) => applyToPoint18(c2kMatPcb, corner));
105601
+ const transformedCorners = corners.map((corner) => applyToPoint19(c2kMatPcb, corner));
105319
105602
  for (let i = 0;i < transformedCorners.length; i++) {
105320
105603
  const start = transformedCorners[i];
105321
105604
  const end = transformedCorners[(i + 1) % transformedCorners.length];
@@ -105369,6 +105652,7 @@ var CircuitJsonToKicadPcbConverter = class {
105369
105652
  }),
105370
105653
  new AddTracesStage(circuitJson, this.ctx),
105371
105654
  new AddViasStage(circuitJson, this.ctx),
105655
+ new AddStandalonePcbElements(circuitJson, this.ctx),
105372
105656
  new AddGraphicsStage(circuitJson, this.ctx)
105373
105657
  ];
105374
105658
  }
@@ -105772,7 +106056,7 @@ function createTextEffects3(metadataEffects) {
105772
106056
  function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
105773
106057
  try {
105774
106058
  const parsed = parseKicadSexpr3(kicadModString);
105775
- const footprint = parsed.find((node) => node instanceof Footprint4);
106059
+ const footprint = parsed.find((node) => node instanceof Footprint5);
105776
106060
  if (!footprint) {
105777
106061
  return kicadModString;
105778
106062
  }
@@ -197576,7 +197860,7 @@ function rectanglePolygon({
197576
197860
  if (rotationDeg) {
197577
197861
  const matrix2 = rotateDEG(rotationDeg, cx2, cy2);
197578
197862
  const rotatedCorners = corners.map((pt3) => {
197579
- const p3 = applyToPoint19(matrix2, { x: pt3.x, y: pt3.y });
197863
+ const p3 = applyToPoint20(matrix2, { x: pt3.x, y: pt3.y });
197580
197864
  return new Point$3(p3.x, p3.y);
197581
197865
  });
197582
197866
  poly = new Polygon$1(rotatedCorners);
@@ -197641,7 +197925,7 @@ function computeOverlapDistance(compPoly, boardPoly, componentCenter, componentW
197641
197925
  }
197642
197926
  const matrix2 = rotateDEG(rotationDeg, componentCenter.x, componentCenter.y);
197643
197927
  const rotatePoint3 = (pt3) => {
197644
- const p3 = applyToPoint19(matrix2, pt3);
197928
+ const p3 = applyToPoint20(matrix2, pt3);
197645
197929
  return new Point$3(p3.x, p3.y);
197646
197930
  };
197647
197931
  const rotatedPoints = corners.concat(midpoints).map(rotatePoint3);
@@ -215948,7 +216232,7 @@ var PrimitiveComponent2 = class extends Renderable {
215948
216232
  return null;
215949
216233
  for (const position2 of placementConfigPositions) {
215950
216234
  if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
215951
- const center2 = applyToPoint19(this._computePcbGlobalTransformBeforeLayout(), position2.center);
216235
+ const center2 = applyToPoint20(this._computePcbGlobalTransformBeforeLayout(), position2.center);
215952
216236
  return center2;
215953
216237
  }
215954
216238
  }
@@ -215965,7 +216249,7 @@ var PrimitiveComponent2 = class extends Renderable {
215965
216249
  return null;
215966
216250
  for (const position2 of placementConfigPositions) {
215967
216251
  if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
215968
- const center2 = applyToPoint19(this.computeSchematicGlobalTransform(), position2.center);
216252
+ const center2 = applyToPoint20(this.computeSchematicGlobalTransform(), position2.center);
215969
216253
  return center2;
215970
216254
  }
215971
216255
  }
@@ -215985,13 +216269,13 @@ var PrimitiveComponent2 = class extends Renderable {
215985
216269
  return null;
215986
216270
  }
215987
216271
  _getGlobalPcbPositionBeforeLayout() {
215988
- return applyToPoint19(this._computePcbGlobalTransformBeforeLayout(), {
216272
+ return applyToPoint20(this._computePcbGlobalTransformBeforeLayout(), {
215989
216273
  x: 0,
215990
216274
  y: 0
215991
216275
  });
215992
216276
  }
215993
216277
  _getGlobalSchematicPositionBeforeLayout() {
215994
- return applyToPoint19(this.computeSchematicGlobalTransform(), { x: 0, y: 0 });
216278
+ return applyToPoint20(this.computeSchematicGlobalTransform(), { x: 0, y: 0 });
215995
216279
  }
215996
216280
  _getBoard() {
215997
216281
  let current2 = this;
@@ -218468,7 +218752,7 @@ function Trace_doInitialPcbManualTraceRender(trace) {
218468
218752
  viaToLayer = pt3.toLayer;
218469
218753
  }
218470
218754
  }
218471
- const finalCoordinates = isGlobalPosition ? coordinates : applyToPoint19(transform2, coordinates);
218755
+ const finalCoordinates = isGlobalPosition ? coordinates : applyToPoint20(transform2, coordinates);
218472
218756
  if (isViaPoint) {
218473
218757
  route.push({
218474
218758
  route_type: "via",
@@ -219303,7 +219587,7 @@ var CourtyardOutline = class extends PrimitiveComponent2 {
219303
219587
  pcb_component_id,
219304
219588
  layer,
219305
219589
  outline: props.outline.map((p3) => {
219306
- const transformedPosition = applyToPoint19(transform2, {
219590
+ const transformedPosition = applyToPoint20(transform2, {
219307
219591
  x: p3.x,
219308
219592
  y: p3.y
219309
219593
  });
@@ -219480,7 +219764,7 @@ var Cutout = class extends PrimitiveComponent2 {
219480
219764
  inserted_pcb_cutout = db.pcb_cutout.insert(circleData);
219481
219765
  } else if (props.shape === "polygon") {
219482
219766
  const transform2 = this._computePcbGlobalTransformBeforeLayout();
219483
- const transformedPoints = props.points.map((p3) => applyToPoint19(transform2, p3));
219767
+ const transformedPoints = props.points.map((p3) => applyToPoint20(transform2, p3));
219484
219768
  const polygonData = {
219485
219769
  shape: "polygon",
219486
219770
  points: transformedPoints,
@@ -219641,7 +219925,7 @@ var FabricationNotePath = class extends PrimitiveComponent2 {
219641
219925
  layer,
219642
219926
  color: props.color,
219643
219927
  route: props.route.map((p3) => {
219644
- const transformedPosition = applyToPoint19(transform2, {
219928
+ const transformedPosition = applyToPoint20(transform2, {
219645
219929
  x: p3.x,
219646
219930
  y: p3.y
219647
219931
  });
@@ -220134,8 +220418,8 @@ var PcbNoteLine = class extends PrimitiveComponent2 {
220134
220418
  const subcircuit = this.getSubcircuit();
220135
220419
  const group = this.getGroup();
220136
220420
  const transform2 = this._computePcbGlobalTransformBeforeLayout();
220137
- const start = applyToPoint19(transform2, { x: props.x1, y: props.y1 });
220138
- const end = applyToPoint19(transform2, { x: props.x2, y: props.y2 });
220421
+ const start = applyToPoint20(transform2, { x: props.x1, y: props.y1 });
220422
+ const end = applyToPoint20(transform2, { x: props.x2, y: props.y2 });
220139
220423
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
220140
220424
  const pcb_note_line2 = db.pcb_note_line.insert({
220141
220425
  pcb_component_id,
@@ -220200,7 +220484,7 @@ var PcbNotePath = class extends PrimitiveComponent2 {
220200
220484
  const { x: x3, y: y32, ...rest } = point6;
220201
220485
  const numericX = typeof x3 === "string" ? parseFloat(x3) : x3;
220202
220486
  const numericY = typeof y32 === "string" ? parseFloat(y32) : y32;
220203
- const transformed = applyToPoint19(transform2, { x: numericX, y: numericY });
220487
+ const transformed = applyToPoint20(transform2, { x: numericX, y: numericY });
220204
220488
  return { ...rest, x: transformed.x, y: transformed.y };
220205
220489
  });
220206
220490
  const pcb_note_path2 = db.pcb_note_path.insert({
@@ -220261,7 +220545,7 @@ var PcbNoteRect = class extends PrimitiveComponent2 {
220261
220545
  const { db } = this.root;
220262
220546
  const { _parsedProps: props } = this;
220263
220547
  const transform2 = this._computePcbGlobalTransformBeforeLayout();
220264
- const center2 = applyToPoint19(transform2, { x: 0, y: 0 });
220548
+ const center2 = applyToPoint20(transform2, { x: 0, y: 0 });
220265
220549
  const subcircuit = this.getSubcircuit();
220266
220550
  const group = this.getGroup();
220267
220551
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
@@ -220322,7 +220606,7 @@ var PcbNoteText = class extends PrimitiveComponent2 {
220322
220606
  const { db } = this.root;
220323
220607
  const { _parsedProps: props } = this;
220324
220608
  const transform2 = this._computePcbGlobalTransformBeforeLayout();
220325
- const anchorPosition = applyToPoint19(transform2, { x: 0, y: 0 });
220609
+ const anchorPosition = applyToPoint20(transform2, { x: 0, y: 0 });
220326
220610
  const subcircuit = this.getSubcircuit();
220327
220611
  const group = this.getGroup();
220328
220612
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
@@ -220391,7 +220675,7 @@ var PcbTrace = class extends PrimitiveComponent2 {
220391
220675
  const parentTransform = this._computePcbGlobalTransformBeforeLayout();
220392
220676
  const transformedRoute = props.route.map((point6) => {
220393
220677
  const { x: x3, y: y32, ...restOfPoint } = point6;
220394
- const transformedPoint = applyToPoint19(parentTransform, { x: x3, y: y32 });
220678
+ const transformedPoint = applyToPoint20(parentTransform, { x: x3, y: y32 });
220395
220679
  if (point6.route_type === "wire" && point6.layer) {
220396
220680
  return {
220397
220681
  ...transformedPoint,
@@ -220818,8 +221102,8 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
220818
221102
  }
220819
221103
  const subcircuit = this.getSubcircuit();
220820
221104
  const transform2 = this._computePcbGlobalTransformBeforeLayout();
220821
- const p12 = applyToPoint19(transform2, { x: props.x1, y: props.y1 });
220822
- const p222 = applyToPoint19(transform2, { x: props.x2, y: props.y2 });
221105
+ const p12 = applyToPoint20(transform2, { x: props.x1, y: props.y1 });
221106
+ const p222 = applyToPoint20(transform2, { x: props.x2, y: props.y2 });
220823
221107
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id;
220824
221108
  const pcb_silkscreen_line2 = db.pcb_silkscreen_line.insert({
220825
221109
  pcb_component_id,
@@ -220886,7 +221170,7 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
220886
221170
  pcb_component_id,
220887
221171
  layer,
220888
221172
  route: props.route.map((p3) => {
220889
- const transformedPosition = applyToPoint19(transform2, {
221173
+ const transformedPosition = applyToPoint20(transform2, {
220890
221174
  x: p3.x,
220891
221175
  y: p3.y
220892
221176
  });
@@ -221096,7 +221380,7 @@ var SilkscreenText = class extends PrimitiveComponent2 {
221096
221380
  });
221097
221381
  const fontSize = props.fontSize ?? resolvedPcbSxFontSize ?? this.getInheritedProperty("pcbStyle")?.silkscreenFontSize ?? this._footprinterFontSize ?? 1;
221098
221382
  const hasResolvedPcbSxPosition = resolvedPcbSxPcbX !== undefined || resolvedPcbSxPcbY !== undefined;
221099
- const position2 = hasResolvedPcbSxPosition && this._footprinterFontSize !== undefined ? applyToPoint19(compose5(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), isFlipped ? flipY() : identity5()), {
221383
+ const position2 = hasResolvedPcbSxPosition && this._footprinterFontSize !== undefined ? applyToPoint20(compose5(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), isFlipped ? flipY() : identity5()), {
221100
221384
  x: this.resolvePcbCoordinate({
221101
221385
  rawValue: resolvedPcbSxPcbX ?? props.pcbX ?? 0,
221102
221386
  axis: "pcbX"
@@ -221382,7 +221666,7 @@ var SmtPad = class extends PrimitiveComponent2 {
221382
221666
  });
221383
221667
  } else if (props.shape === "polygon") {
221384
221668
  const transformedPoints = props.points.map((point6) => {
221385
- const transformed = applyToPoint19(globalTransform, {
221669
+ const transformed = applyToPoint20(globalTransform, {
221386
221670
  x: distance.parse(point6.x),
221387
221671
  y: distance.parse(point6.y)
221388
221672
  });
@@ -222229,7 +222513,7 @@ var Port = class extends PrimitiveComponent2 {
222229
222513
  }
222230
222514
  }
222231
222515
  const transform2 = compose5(parentNormalComponent.computeSchematicGlobalTransform(), translate5(-symbol.center.x, -symbol.center.y));
222232
- return applyToPoint19(transform2, schematicSymbolPortDef);
222516
+ return applyToPoint20(transform2, schematicSymbolPortDef);
222233
222517
  }
222234
222518
  const parentBoxDim = parentNormalComponent?._getSchematicBoxDimensions();
222235
222519
  if (parentBoxDim && this.props.pinNumber !== undefined) {
@@ -222237,7 +222521,7 @@ var Port = class extends PrimitiveComponent2 {
222237
222521
  if (!localPortPosition) {
222238
222522
  throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);
222239
222523
  }
222240
- return applyToPoint19(parentNormalComponent.computeSchematicGlobalTransform(), localPortPosition);
222524
+ return applyToPoint20(parentNormalComponent.computeSchematicGlobalTransform(), localPortPosition);
222241
222525
  }
222242
222526
  throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`);
222243
222527
  }
@@ -222599,15 +222883,15 @@ var Port = class extends PrimitiveComponent2 {
222599
222883
  const { db } = this.root;
222600
222884
  const schPort = db.schematic_port.get(this.schematic_port_id);
222601
222885
  if (schPort) {
222602
- const newCenter = applyToPoint19(transform2, schPort.center);
222886
+ const newCenter = applyToPoint20(transform2, schPort.center);
222603
222887
  db.schematic_port.update(this.schematic_port_id, {
222604
222888
  center: newCenter
222605
222889
  });
222606
222890
  if (this.schematic_stem_line_id) {
222607
222891
  const line2 = db.schematic_line.get(this.schematic_stem_line_id);
222608
222892
  if (line2) {
222609
- const p12 = applyToPoint19(transform2, { x: line2.x1, y: line2.y1 });
222610
- const p222 = applyToPoint19(transform2, { x: line2.x2, y: line2.y2 });
222893
+ const p12 = applyToPoint20(transform2, { x: line2.x1, y: line2.y1 });
222894
+ const p222 = applyToPoint20(transform2, { x: line2.x2, y: line2.y2 });
222611
222895
  db.schematic_line.update(this.schematic_stem_line_id, {
222612
222896
  x1: p12.x,
222613
222897
  y1: p12.y,
@@ -226170,7 +226454,7 @@ var TraceHint = class extends PrimitiveComponent2 {
226170
226454
  return [];
226171
226455
  const globalTransform = this._computePcbGlobalTransformBeforeLayout();
226172
226456
  return offsets.map((offset) => ({
226173
- ...applyToPoint19(globalTransform, offset),
226457
+ ...applyToPoint20(globalTransform, offset),
226174
226458
  via: offset.via,
226175
226459
  to_layer: offset.to_layer,
226176
226460
  trace_width: offset.trace_width
@@ -233614,13 +233898,13 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
233614
233898
  const target = this.getSubcircuit().selectOne(input);
233615
233899
  if (!target) {
233616
233900
  this.renderError(`FabricationNoteDimension could not find selector "${input}"`);
233617
- return applyToPoint19(transform2, { x: 0, y: 0 });
233901
+ return applyToPoint20(transform2, { x: 0, y: 0 });
233618
233902
  }
233619
233903
  return target._getGlobalPcbPositionBeforeLayout();
233620
233904
  }
233621
233905
  const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
233622
233906
  const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
233623
- return applyToPoint19(transform2, { x: numericX, y: numericY });
233907
+ return applyToPoint20(transform2, { x: numericX, y: numericY });
233624
233908
  }
233625
233909
  doInitialPcbPrimitiveRender() {
233626
233910
  if (this.root?.pcbDisabled)
@@ -233720,7 +234004,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
233720
234004
  const target = this.getSubcircuit().selectOne(`.${input}`);
233721
234005
  if (!target) {
233722
234006
  this.renderError(`PcbNoteDimension could not find selector "${input}"`);
233723
- return applyToPoint19(transform2, { x: 0, y: 0 });
234007
+ return applyToPoint20(transform2, { x: 0, y: 0 });
233724
234008
  }
233725
234009
  const targetPcbComponentId = target.pcb_component_id;
233726
234010
  const root = this.root;
@@ -233737,7 +234021,7 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
233737
234021
  }
233738
234022
  const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
233739
234023
  const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
233740
- return applyToPoint19(transform2, { x: numericX, y: numericY });
234024
+ return applyToPoint20(transform2, { x: numericX, y: numericY });
233741
234025
  }
233742
234026
  doInitialPcbPrimitiveRender() {
233743
234027
  if (this.root?.pcbDisabled)
@@ -234016,7 +234300,7 @@ var NetLabel = class extends PrimitiveComponent2 {
234016
234300
  const connectedPorts = this._getConnectedPorts();
234017
234301
  if (connectedPorts.length > 0) {
234018
234302
  const portPos = connectedPorts[0]._getGlobalSchematicPositionBeforeLayout();
234019
- const parentCenter = applyToPoint19(this.parent?.computeSchematicGlobalTransform?.() ?? identity5(), { x: 0, y: 0 });
234303
+ const parentCenter = applyToPoint20(this.parent?.computeSchematicGlobalTransform?.() ?? identity5(), { x: 0, y: 0 });
234020
234304
  return translate5(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
234021
234305
  }
234022
234306
  }
@@ -235289,7 +235573,7 @@ var SchematicText = class extends PrimitiveComponent2 {
235289
235573
  const text = db.schematic_text.get(this.schematic_text_id);
235290
235574
  if (!text)
235291
235575
  return;
235292
- const newPosition = applyToPoint19(transform2, text.position);
235576
+ const newPosition = applyToPoint20(transform2, text.position);
235293
235577
  db.schematic_text.update(this.schematic_text_id, {
235294
235578
  position: { x: newPosition.x, y: newPosition.y }
235295
235579
  });
@@ -235339,8 +235623,8 @@ var SchematicLine = class extends PrimitiveComponent2 {
235339
235623
  const line2 = db.schematic_line.get(this.schematic_line_id);
235340
235624
  if (!line2)
235341
235625
  return;
235342
- const p12 = applyToPoint19(transform2, { x: line2.x1, y: line2.y1 });
235343
- const p222 = applyToPoint19(transform2, { x: line2.x2, y: line2.y2 });
235626
+ const p12 = applyToPoint20(transform2, { x: line2.x1, y: line2.y1 });
235627
+ const p222 = applyToPoint20(transform2, { x: line2.x2, y: line2.y2 });
235344
235628
  db.schematic_line.update(this.schematic_line_id, {
235345
235629
  x1: p12.x,
235346
235630
  y1: p12.y,
@@ -235397,11 +235681,11 @@ var SchematicRect = class extends PrimitiveComponent2 {
235397
235681
  const rect = db.schematic_rect.get(this.schematic_rect_id);
235398
235682
  if (!rect)
235399
235683
  return;
235400
- const topLeft = applyToPoint19(transform2, {
235684
+ const topLeft = applyToPoint20(transform2, {
235401
235685
  x: rect.center.x - rect.width / 2,
235402
235686
  y: rect.center.y + rect.height / 2
235403
235687
  });
235404
- const bottomRight = applyToPoint19(transform2, {
235688
+ const bottomRight = applyToPoint20(transform2, {
235405
235689
  x: rect.center.x + rect.width / 2,
235406
235690
  y: rect.center.y - rect.height / 2
235407
235691
  });
@@ -235466,8 +235750,8 @@ var SchematicArc = class extends PrimitiveComponent2 {
235466
235750
  const arc2 = db.schematic_arc.get(this.schematic_arc_id);
235467
235751
  if (!arc2)
235468
235752
  return;
235469
- const newCenter = applyToPoint19(transform2, arc2.center);
235470
- const edgePoint = applyToPoint19(transform2, {
235753
+ const newCenter = applyToPoint20(transform2, arc2.center);
235754
+ const edgePoint = applyToPoint20(transform2, {
235471
235755
  x: arc2.center.x + arc2.radius,
235472
235756
  y: arc2.center.y
235473
235757
  });
@@ -235525,8 +235809,8 @@ var SchematicCircle = class extends PrimitiveComponent2 {
235525
235809
  const circle2 = db.schematic_circle.get(this.schematic_circle_id);
235526
235810
  if (!circle2)
235527
235811
  return;
235528
- const newCenter = applyToPoint19(transform2, circle2.center);
235529
- const edgePoint = applyToPoint19(transform2, {
235812
+ const newCenter = applyToPoint20(transform2, circle2.center);
235813
+ const edgePoint = applyToPoint20(transform2, {
235530
235814
  x: circle2.center.x + circle2.radius,
235531
235815
  y: circle2.center.y
235532
235816
  });
@@ -235731,7 +236015,7 @@ var SchematicPath = class extends PrimitiveComponent2 {
235731
236015
  if (!path42)
235732
236016
  continue;
235733
236017
  const newPoints = path42.points.map((point6) => {
235734
- const transformed = applyToPoint19(transform2, point6);
236018
+ const transformed = applyToPoint20(transform2, point6);
235735
236019
  return { x: transformed.x, y: transformed.y };
235736
236020
  });
235737
236021
  db.schematic_path.update(pathId, {
@@ -242157,11 +242441,11 @@ import {
242157
242441
 
242158
242442
  // node_modules/dsn-converter/dist/index.js
242159
242443
  import { su as su7 } from "@tscircuit/soup-util";
242160
- import { applyToPoint as applyToPoint21, scale as scale6 } from "transformation-matrix";
242444
+ import { applyToPoint as applyToPoint22, scale as scale6 } from "transformation-matrix";
242161
242445
  import { su as su23 } from "@tscircuit/soup-util";
242162
242446
  import Debug4 from "debug";
242163
242447
  import { su as su33 } from "@tscircuit/soup-util";
242164
- import { applyToPoint as applyToPoint22, scale as scale22 } from "transformation-matrix";
242448
+ import { applyToPoint as applyToPoint23, scale as scale22 } from "transformation-matrix";
242165
242449
  import { su as su42 } from "@tscircuit/soup-util";
242166
242450
  import Debug22 from "debug";
242167
242451
  import { scale as scale32, applyToPoint as applyToPoint92 } from "transformation-matrix";
@@ -242397,7 +242681,7 @@ function processComponentsAndPads(componentGroups, circuitElements, pcb) {
242397
242681
  const sourceComponent = su7(circuitElements).source_component.list().find((e4) => e4.source_component_id === pcbComponent?.source_component_id);
242398
242682
  const footprintName = getFootprintName(sourceComponent, pcbComponent);
242399
242683
  const componentName = sourceComponent?.name || "Unknown";
242400
- const circuitSpaceCoordinates = applyToPoint21(transformMmToUm, pcbComponent.center);
242684
+ const circuitSpaceCoordinates = applyToPoint22(transformMmToUm, pcbComponent.center);
242401
242685
  if (!componentsByFootprint.has(footprintName)) {
242402
242686
  componentsByFootprint.set(footprintName, []);
242403
242687
  }
@@ -242909,7 +243193,7 @@ function processPlatedHoles(componentGroups, circuitElements, pcb) {
242909
243193
  componentsByFootprint.set(key, []);
242910
243194
  componentsByFootprint.get(key).push({
242911
243195
  componentName: sourceComponent?.name || "Unknown",
242912
- coordinates: applyToPoint22(transformMmToUm2, pcbComponent.center),
243196
+ coordinates: applyToPoint23(transformMmToUm2, pcbComponent.center),
242913
243197
  rotation: pcbComponent.rotation || 0,
242914
243198
  value: getComponentValue(sourceComponent),
242915
243199
  sourceComponent
@@ -243297,6 +243581,2195 @@ var debug102 = Debug10("dsn-converter:parse-dsn-to-dsn-json");
243297
243581
 
243298
243582
  // lib/shared/export-snippet.ts
243299
243583
  var import_jszip5 = __toESM2(require_lib4(), 1);
243584
+
243585
+ // node_modules/stepts/dist/index.js
243586
+ var Entity = class {
243587
+ static parse(_a3, _ctx) {
243588
+ throw new Error("not implemented");
243589
+ }
243590
+ };
243591
+ var eid = (n3) => n3;
243592
+ var Ref = class {
243593
+ constructor(id2) {
243594
+ this.id = id2;
243595
+ }
243596
+ resolve(repo) {
243597
+ const e4 = repo.get(this.id);
243598
+ if (!e4)
243599
+ throw new Error(`Unresolved #${this.id}`);
243600
+ return e4;
243601
+ }
243602
+ toString() {
243603
+ return `#${this.id}`;
243604
+ }
243605
+ };
243606
+ var stepStr = (s2) => `'${s2.replace(/'/g, "''")}'`;
243607
+ var fmtNum = (n3) => Number.isInteger(n3) ? `${n3}.` : `${n3}`;
243608
+ var Repository = class {
243609
+ map = /* @__PURE__ */ new Map;
243610
+ order = [];
243611
+ maxId = 0;
243612
+ schema = "AP214";
243613
+ units = { length: "MM", angle: "RAD", solidAngle: "SR" };
243614
+ set(id2, e4) {
243615
+ if (!this.map.has(id2)) {
243616
+ this.order.push(id2);
243617
+ if (id2 > this.maxId)
243618
+ this.maxId = id2;
243619
+ }
243620
+ this.map.set(id2, e4);
243621
+ }
243622
+ add(e4) {
243623
+ this.maxId++;
243624
+ const id2 = eid(this.maxId);
243625
+ this.set(id2, e4);
243626
+ return new Ref(id2);
243627
+ }
243628
+ get(id2) {
243629
+ return this.map.get(id2);
243630
+ }
243631
+ entries() {
243632
+ return this.order.map((id2) => [id2, this.map.get(id2)]);
243633
+ }
243634
+ toPartFile(meta) {
243635
+ const now = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "-");
243636
+ const hdr = [
243637
+ "ISO-10303-21;",
243638
+ "HEADER;",
243639
+ `FILE_DESCRIPTION((${stepStr(meta.name)}),'2;1');`,
243640
+ `FILE_NAME(${stepStr(meta.name)},${stepStr(now)},(${stepStr(meta.author ?? "tscircuit")}),(${stepStr(meta.org ?? "tscircuit")}),${stepStr("generator")},${stepStr("")},${stepStr("")});`,
243641
+ `FILE_SCHEMA(('${this.schema === "AP214" ? "AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }" : "AP242_MANAGED_MODEL_BASED_3D_ENGINEERING"}'));`,
243642
+ "ENDSEC;",
243643
+ "DATA;"
243644
+ ];
243645
+ const data = this.entries().map(([id2, e4]) => `#${id2} = ${e4.toStep(this)};`);
243646
+ const ftr = ["ENDSEC;", "END-ISO-10303-21;"];
243647
+ return [...hdr, ...data, ...ftr].join(`
243648
+ `);
243649
+ }
243650
+ };
243651
+ var registry = /* @__PURE__ */ new Map;
243652
+ function register(type, parser) {
243653
+ registry.set(type, parser);
243654
+ }
243655
+ function getParser(type) {
243656
+ return registry.get(type);
243657
+ }
243658
+ var Axis2Placement3D = class _Axis2Placement3D extends Entity {
243659
+ constructor(name, location, axis, refDirection) {
243660
+ super();
243661
+ this.name = name;
243662
+ this.location = location;
243663
+ this.axis = axis;
243664
+ this.refDirection = refDirection;
243665
+ }
243666
+ type = "AXIS2_PLACEMENT_3D";
243667
+ static parse(a2, ctx) {
243668
+ const name = ctx.parseString(a2[0]);
243669
+ const loc = ctx.parseRef(a2[1]);
243670
+ const axis = a2[2] !== "$" ? ctx.parseRef(a2[2]) : undefined;
243671
+ const refd = a2[3] !== "$" ? ctx.parseRef(a2[3]) : undefined;
243672
+ return new _Axis2Placement3D(name, loc, axis, refd);
243673
+ }
243674
+ toStep() {
243675
+ const A4 = this.axis ? this.axis.toString() : "$";
243676
+ const R4 = this.refDirection ? this.refDirection.toString() : "$";
243677
+ return `AXIS2_PLACEMENT_3D(${stepStr(this.name)},${this.location},${A4},${R4})`;
243678
+ }
243679
+ };
243680
+ register("AXIS2_PLACEMENT_3D", Axis2Placement3D.parse.bind(Axis2Placement3D));
243681
+ var CartesianPoint = class _CartesianPoint extends Entity {
243682
+ constructor(name, x3, y4, z21) {
243683
+ super();
243684
+ this.name = name;
243685
+ this.x = x3;
243686
+ this.y = y4;
243687
+ this.z = z21;
243688
+ }
243689
+ type = "CARTESIAN_POINT";
243690
+ static parse(a2, ctx) {
243691
+ const name = ctx.parseString(a2[0]);
243692
+ const coords = a2[1].replace(/^\(|\)$/g, "").split(",").map(ctx.parseNumber);
243693
+ return new _CartesianPoint(name, coords[0], coords[1], coords[2] ?? 0);
243694
+ }
243695
+ toStep() {
243696
+ return `CARTESIAN_POINT(${stepStr(this.name)},(${fmtNum(this.x)},${fmtNum(this.y)},${fmtNum(this.z)}))`;
243697
+ }
243698
+ };
243699
+ register("CARTESIAN_POINT", CartesianPoint.parse.bind(CartesianPoint));
243700
+ var Circle3 = class _Circle extends Entity {
243701
+ constructor(name, placement, radius) {
243702
+ super();
243703
+ this.name = name;
243704
+ this.placement = placement;
243705
+ this.radius = radius;
243706
+ }
243707
+ type = "CIRCLE";
243708
+ static parse(a2, ctx) {
243709
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
243710
+ const pl4 = ctx.parseRef(a2[1]);
243711
+ const r4 = ctx.parseNumber(a2[2]);
243712
+ return new _Circle(name, pl4, r4);
243713
+ }
243714
+ toStep() {
243715
+ return `CIRCLE(${this.name ? `'${this.name}'` : "''"},${this.placement},${fmtNum(this.radius)})`;
243716
+ }
243717
+ };
243718
+ register("CIRCLE", Circle3.parse.bind(Circle3));
243719
+ var CylindricalSurface = class _CylindricalSurface extends Entity {
243720
+ constructor(name, position2, radius) {
243721
+ super();
243722
+ this.name = name;
243723
+ this.position = position2;
243724
+ this.radius = radius;
243725
+ }
243726
+ type = "CYLINDRICAL_SURFACE";
243727
+ static parse(a2, ctx) {
243728
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
243729
+ const position2 = ctx.parseRef(a2[1]);
243730
+ const radius = ctx.parseNumber(a2[2]);
243731
+ return new _CylindricalSurface(name, position2, radius);
243732
+ }
243733
+ toStep() {
243734
+ return `CYLINDRICAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.radius)})`;
243735
+ }
243736
+ };
243737
+ register("CYLINDRICAL_SURFACE", CylindricalSurface.parse.bind(CylindricalSurface));
243738
+ var Direction = class _Direction extends Entity {
243739
+ constructor(name, dx2, dy2, dz) {
243740
+ super();
243741
+ this.name = name;
243742
+ this.dx = dx2;
243743
+ this.dy = dy2;
243744
+ this.dz = dz;
243745
+ }
243746
+ type = "DIRECTION";
243747
+ static parse(a2, ctx) {
243748
+ const name = ctx.parseString(a2[0]);
243749
+ const comps = a2[1].replace(/^\(|\)$/g, "").split(",").map(ctx.parseNumber);
243750
+ return new _Direction(name, comps[0], comps[1], comps[2] ?? 0);
243751
+ }
243752
+ toStep() {
243753
+ return `DIRECTION(${stepStr(this.name)},(${fmtNum(this.dx)},${fmtNum(this.dy)},${fmtNum(this.dz)}))`;
243754
+ }
243755
+ };
243756
+ register("DIRECTION", Direction.parse.bind(Direction));
243757
+ var Line3 = class _Line extends Entity {
243758
+ constructor(name, pnt, dir) {
243759
+ super();
243760
+ this.name = name;
243761
+ this.pnt = pnt;
243762
+ this.dir = dir;
243763
+ }
243764
+ type = "LINE";
243765
+ static parse(a2, ctx) {
243766
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
243767
+ const p3 = ctx.parseRef(a2[1]);
243768
+ const vecTok = a2[2];
243769
+ if (vecTok.startsWith("VECTOR(")) {
243770
+ throw new Error("Inline VECTOR in LINE is not supported - VECTOR should be a separate entity");
243771
+ }
243772
+ const vec = ctx.parseRef(vecTok);
243773
+ return new _Line(name, p3, vec);
243774
+ }
243775
+ toStep() {
243776
+ return `LINE(${this.name ? `'${this.name}'` : "''"},${this.pnt},${this.dir})`;
243777
+ }
243778
+ };
243779
+ register("LINE", Line3.parse.bind(Line3));
243780
+ var Plane = class _Plane extends Entity {
243781
+ constructor(name, placement) {
243782
+ super();
243783
+ this.name = name;
243784
+ this.placement = placement;
243785
+ }
243786
+ type = "PLANE";
243787
+ static parse(a2, ctx) {
243788
+ return new _Plane(ctx.parseString(a2[0]), ctx.parseRef(a2[1]));
243789
+ }
243790
+ toStep() {
243791
+ return `PLANE(${stepStr(this.name)},${this.placement})`;
243792
+ }
243793
+ };
243794
+ register("PLANE", Plane.parse.bind(Plane));
243795
+ var ToroidalSurface = class _ToroidalSurface extends Entity {
243796
+ constructor(name, position2, majorRadius, minorRadius) {
243797
+ super();
243798
+ this.name = name;
243799
+ this.position = position2;
243800
+ this.majorRadius = majorRadius;
243801
+ this.minorRadius = minorRadius;
243802
+ }
243803
+ type = "TOROIDAL_SURFACE";
243804
+ static parse(a2, ctx) {
243805
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
243806
+ const position2 = ctx.parseRef(a2[1]);
243807
+ const majorRadius = ctx.parseNumber(a2[2]);
243808
+ const minorRadius = ctx.parseNumber(a2[3]);
243809
+ return new _ToroidalSurface(name, position2, majorRadius, minorRadius);
243810
+ }
243811
+ toStep() {
243812
+ return `TOROIDAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.majorRadius)},${fmtNum(this.minorRadius)})`;
243813
+ }
243814
+ };
243815
+ register("TOROIDAL_SURFACE", ToroidalSurface.parse.bind(ToroidalSurface));
243816
+ var Vector3 = class _Vector extends Entity {
243817
+ constructor(name, orientation3, magnitude) {
243818
+ super();
243819
+ this.name = name;
243820
+ this.orientation = orientation3;
243821
+ this.magnitude = magnitude;
243822
+ }
243823
+ type = "VECTOR";
243824
+ static parse(a2, ctx) {
243825
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
243826
+ const orientation3 = ctx.parseRef(a2[1]);
243827
+ const magnitude = ctx.parseNumber(a2[2]);
243828
+ return new _Vector(name, orientation3, magnitude);
243829
+ }
243830
+ toStep() {
243831
+ return `VECTOR(${stepStr(this.name)},${this.orientation},${fmtNum(this.magnitude)})`;
243832
+ }
243833
+ };
243834
+ register("VECTOR", Vector3.parse.bind(Vector3));
243835
+ var Ellipse = class _Ellipse extends Entity {
243836
+ constructor(name, placement, semiAxis1, semiAxis2) {
243837
+ super();
243838
+ this.name = name;
243839
+ this.placement = placement;
243840
+ this.semiAxis1 = semiAxis1;
243841
+ this.semiAxis2 = semiAxis2;
243842
+ }
243843
+ type = "ELLIPSE";
243844
+ static parse(a2, ctx) {
243845
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
243846
+ const placement = ctx.parseRef(a2[1]);
243847
+ const semiAxis1 = ctx.parseNumber(a2[2]);
243848
+ const semiAxis2 = ctx.parseNumber(a2[3]);
243849
+ return new _Ellipse(name, placement, semiAxis1, semiAxis2);
243850
+ }
243851
+ toStep() {
243852
+ return `ELLIPSE(${stepStr(this.name)},${this.placement},${fmtNum(this.semiAxis1)},${fmtNum(this.semiAxis2)})`;
243853
+ }
243854
+ };
243855
+ register("ELLIPSE", Ellipse.parse.bind(Ellipse));
243856
+ var ConicalSurface = class _ConicalSurface extends Entity {
243857
+ constructor(name, position2, radius, semiAngle) {
243858
+ super();
243859
+ this.name = name;
243860
+ this.position = position2;
243861
+ this.radius = radius;
243862
+ this.semiAngle = semiAngle;
243863
+ }
243864
+ type = "CONICAL_SURFACE";
243865
+ static parse(a2, ctx) {
243866
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
243867
+ const position2 = ctx.parseRef(a2[1]);
243868
+ const radius = ctx.parseNumber(a2[2]);
243869
+ const semiAngle = ctx.parseNumber(a2[3]);
243870
+ return new _ConicalSurface(name, position2, radius, semiAngle);
243871
+ }
243872
+ toStep() {
243873
+ return `CONICAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.radius)},${fmtNum(this.semiAngle)})`;
243874
+ }
243875
+ };
243876
+ register("CONICAL_SURFACE", ConicalSurface.parse.bind(ConicalSurface));
243877
+ var SphericalSurface = class _SphericalSurface extends Entity {
243878
+ constructor(name, position2, radius) {
243879
+ super();
243880
+ this.name = name;
243881
+ this.position = position2;
243882
+ this.radius = radius;
243883
+ }
243884
+ type = "SPHERICAL_SURFACE";
243885
+ static parse(a2, ctx) {
243886
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
243887
+ const position2 = ctx.parseRef(a2[1]);
243888
+ const radius = ctx.parseNumber(a2[2]);
243889
+ return new _SphericalSurface(name, position2, radius);
243890
+ }
243891
+ toStep() {
243892
+ return `SPHERICAL_SURFACE(${stepStr(this.name)},${this.position},${fmtNum(this.radius)})`;
243893
+ }
243894
+ };
243895
+ register("SPHERICAL_SURFACE", SphericalSurface.parse.bind(SphericalSurface));
243896
+ var BSplineCurveWithKnots = class _BSplineCurveWithKnots extends Entity {
243897
+ constructor(name, degree, controlPointsList, curveForm, closedCurve, selfIntersect, knotMultiplicities, knots, knotSpec) {
243898
+ super();
243899
+ this.name = name;
243900
+ this.degree = degree;
243901
+ this.controlPointsList = controlPointsList;
243902
+ this.curveForm = curveForm;
243903
+ this.closedCurve = closedCurve;
243904
+ this.selfIntersect = selfIntersect;
243905
+ this.knotMultiplicities = knotMultiplicities;
243906
+ this.knots = knots;
243907
+ this.knotSpec = knotSpec;
243908
+ }
243909
+ type = "B_SPLINE_CURVE_WITH_KNOTS";
243910
+ static parse(a2, ctx) {
243911
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
243912
+ const degree = ctx.parseNumber(a2[1]);
243913
+ const controlPoints = a2[2].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
243914
+ const curveForm = a2[3].trim();
243915
+ const closedCurve = a2[4].trim() === ".T.";
243916
+ const selfIntersect = a2[5].trim() === ".T.";
243917
+ const knotMults = a2[6].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseNumber(tok.trim()));
243918
+ const knots = a2[7].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseNumber(tok.trim()));
243919
+ const knotSpec = a2[8].trim();
243920
+ return new _BSplineCurveWithKnots(name, degree, controlPoints, curveForm, closedCurve, selfIntersect, knotMults, knots, knotSpec);
243921
+ }
243922
+ toStep() {
243923
+ const cps = `(${this.controlPointsList.join(",")})`;
243924
+ const kms = `(${this.knotMultiplicities.map(fmtNum).join(",")})`;
243925
+ const ks3 = `(${this.knots.map(fmtNum).join(",")})`;
243926
+ const closed = this.closedCurve ? ".T." : ".F.";
243927
+ const self2 = this.selfIntersect ? ".T." : ".F.";
243928
+ return `B_SPLINE_CURVE_WITH_KNOTS(${stepStr(this.name)},${this.degree},${cps},${this.curveForm},${closed},${self2},${kms},${ks3},${this.knotSpec})`;
243929
+ }
243930
+ };
243931
+ register("B_SPLINE_CURVE_WITH_KNOTS", BSplineCurveWithKnots.parse.bind(BSplineCurveWithKnots));
243932
+ var ColourRgb = class _ColourRgb extends Entity {
243933
+ constructor(name, r4, g6, b) {
243934
+ super();
243935
+ this.name = name;
243936
+ this.r = r4;
243937
+ this.g = g6;
243938
+ this.b = b;
243939
+ }
243940
+ type = "COLOUR_RGB";
243941
+ static parse(a2, ctx) {
243942
+ return new _ColourRgb(ctx.parseString(a2[0]), ctx.parseNumber(a2[1]), ctx.parseNumber(a2[2]), ctx.parseNumber(a2[3]));
243943
+ }
243944
+ toStep() {
243945
+ return `COLOUR_RGB(${stepStr(this.name)},${this.r},${this.g},${this.b})`;
243946
+ }
243947
+ };
243948
+ register("COLOUR_RGB", ColourRgb.parse.bind(ColourRgb));
243949
+ var FillAreaStyle = class _FillAreaStyle extends Entity {
243950
+ constructor(name, items) {
243951
+ super();
243952
+ this.name = name;
243953
+ this.items = items;
243954
+ }
243955
+ type = "FILL_AREA_STYLE";
243956
+ static parse(a2, ctx) {
243957
+ const items = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
243958
+ return new _FillAreaStyle(a2[0] === "$" ? "" : ctx.parseString(a2[0]), items);
243959
+ }
243960
+ toStep() {
243961
+ return `FILL_AREA_STYLE(${stepStr(this.name)},(${this.items.join(",")}))`;
243962
+ }
243963
+ };
243964
+ register("FILL_AREA_STYLE", FillAreaStyle.parse.bind(FillAreaStyle));
243965
+ var FillAreaStyleColour = class _FillAreaStyleColour extends Entity {
243966
+ constructor(name, colour) {
243967
+ super();
243968
+ this.name = name;
243969
+ this.colour = colour;
243970
+ }
243971
+ type = "FILL_AREA_STYLE_COLOUR";
243972
+ static parse(a2, ctx) {
243973
+ return new _FillAreaStyleColour(ctx.parseString(a2[0]), ctx.parseRef(a2[1]));
243974
+ }
243975
+ toStep() {
243976
+ return `FILL_AREA_STYLE_COLOUR(${stepStr(this.name)},${this.colour})`;
243977
+ }
243978
+ };
243979
+ register("FILL_AREA_STYLE_COLOUR", FillAreaStyleColour.parse.bind(FillAreaStyleColour));
243980
+ var MechanicalDesignGeometricPresentationRepresentation = class _MechanicalDesignGeometricPresentationRepresentation extends Entity {
243981
+ constructor(name, items, contextOfItems) {
243982
+ super();
243983
+ this.name = name;
243984
+ this.items = items;
243985
+ this.contextOfItems = contextOfItems;
243986
+ }
243987
+ type = "MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION";
243988
+ static parse(a2, ctx) {
243989
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
243990
+ const items = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
243991
+ const contextOfItems = ctx.parseRef(a2[2]);
243992
+ return new _MechanicalDesignGeometricPresentationRepresentation(name, items, contextOfItems);
243993
+ }
243994
+ toStep() {
243995
+ return `MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION(${stepStr(this.name)},(${this.items.join(",")}),${this.contextOfItems})`;
243996
+ }
243997
+ };
243998
+ register("MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION", MechanicalDesignGeometricPresentationRepresentation.parse.bind(MechanicalDesignGeometricPresentationRepresentation));
243999
+ var PresentationStyleAssignment = class _PresentationStyleAssignment extends Entity {
244000
+ constructor(items) {
244001
+ super();
244002
+ this.items = items;
244003
+ }
244004
+ type = "PRESENTATION_STYLE_ASSIGNMENT";
244005
+ static parse(a2, ctx) {
244006
+ const list = a2[0].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
244007
+ return new _PresentationStyleAssignment(list);
244008
+ }
244009
+ toStep() {
244010
+ return `PRESENTATION_STYLE_ASSIGNMENT((${this.items.join(",")}))`;
244011
+ }
244012
+ };
244013
+ register("PRESENTATION_STYLE_ASSIGNMENT", PresentationStyleAssignment.parse.bind(PresentationStyleAssignment));
244014
+ var StyledItem = class _StyledItem extends Entity {
244015
+ constructor(name, styles, item) {
244016
+ super();
244017
+ this.name = name;
244018
+ this.styles = styles;
244019
+ this.item = item;
244020
+ }
244021
+ type = "STYLED_ITEM";
244022
+ static parse(a2, ctx) {
244023
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244024
+ const styles = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
244025
+ const item = ctx.parseRef(a2[2]);
244026
+ return new _StyledItem(name, styles, item);
244027
+ }
244028
+ toStep() {
244029
+ return `STYLED_ITEM(${stepStr(this.name)},(${this.styles.join(",")}),${this.item})`;
244030
+ }
244031
+ };
244032
+ register("STYLED_ITEM", StyledItem.parse.bind(StyledItem));
244033
+ var SurfaceSideStyle = class _SurfaceSideStyle extends Entity {
244034
+ constructor(name, styles) {
244035
+ super();
244036
+ this.name = name;
244037
+ this.styles = styles;
244038
+ }
244039
+ type = "SURFACE_SIDE_STYLE";
244040
+ static parse(a2, ctx) {
244041
+ const list = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
244042
+ return new _SurfaceSideStyle(a2[0] === "$" ? "" : ctx.parseString(a2[0]), list);
244043
+ }
244044
+ toStep() {
244045
+ return `SURFACE_SIDE_STYLE(${stepStr(this.name)},(${this.styles.join(",")}))`;
244046
+ }
244047
+ };
244048
+ register("SURFACE_SIDE_STYLE", SurfaceSideStyle.parse.bind(SurfaceSideStyle));
244049
+ var SurfaceStyleFillArea = class _SurfaceStyleFillArea extends Entity {
244050
+ constructor(style) {
244051
+ super();
244052
+ this.style = style;
244053
+ }
244054
+ type = "SURFACE_STYLE_FILL_AREA";
244055
+ static parse(a2, ctx) {
244056
+ return new _SurfaceStyleFillArea(ctx.parseRef(a2[0]));
244057
+ }
244058
+ toStep() {
244059
+ return `SURFACE_STYLE_FILL_AREA(${this.style})`;
244060
+ }
244061
+ };
244062
+ register("SURFACE_STYLE_FILL_AREA", SurfaceStyleFillArea.parse.bind(SurfaceStyleFillArea));
244063
+ var SurfaceStyleUsage = class _SurfaceStyleUsage extends Entity {
244064
+ constructor(side, style) {
244065
+ super();
244066
+ this.side = side;
244067
+ this.style = style;
244068
+ }
244069
+ type = "SURFACE_STYLE_USAGE";
244070
+ static parse(a2, ctx) {
244071
+ return new _SurfaceStyleUsage(a2[0].trim(), ctx.parseRef(a2[1]));
244072
+ }
244073
+ toStep() {
244074
+ return `SURFACE_STYLE_USAGE(${this.side},${this.style})`;
244075
+ }
244076
+ };
244077
+ register("SURFACE_STYLE_USAGE", SurfaceStyleUsage.parse.bind(SurfaceStyleUsage));
244078
+ var AdvancedBrepShapeRepresentation = class _AdvancedBrepShapeRepresentation extends Entity {
244079
+ constructor(name, items, context) {
244080
+ super();
244081
+ this.name = name;
244082
+ this.items = items;
244083
+ this.context = context;
244084
+ }
244085
+ type = "ADVANCED_BREP_SHAPE_REPRESENTATION";
244086
+ static parse(a2, ctx) {
244087
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244088
+ const items = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
244089
+ const c3 = ctx.parseRef(a2[2]);
244090
+ return new _AdvancedBrepShapeRepresentation(name, items, c3);
244091
+ }
244092
+ toStep() {
244093
+ return `ADVANCED_BREP_SHAPE_REPRESENTATION(${stepStr(this.name)},(${this.items.join(",")}),${this.context})`;
244094
+ }
244095
+ };
244096
+ register("ADVANCED_BREP_SHAPE_REPRESENTATION", AdvancedBrepShapeRepresentation.parse.bind(AdvancedBrepShapeRepresentation));
244097
+ var ApplicationContext = class _ApplicationContext extends Entity {
244098
+ constructor(application) {
244099
+ super();
244100
+ this.application = application;
244101
+ }
244102
+ type = "APPLICATION_CONTEXT";
244103
+ static parse(a2, ctx) {
244104
+ const application = ctx.parseString(a2[0]);
244105
+ return new _ApplicationContext(application);
244106
+ }
244107
+ toStep() {
244108
+ return `APPLICATION_CONTEXT(${stepStr(this.application)})`;
244109
+ }
244110
+ };
244111
+ register("APPLICATION_CONTEXT", ApplicationContext.parse.bind(ApplicationContext));
244112
+ var ApplicationProtocolDefinition = class _ApplicationProtocolDefinition extends Entity {
244113
+ constructor(status, applicationInterpretedModelSchemaName, applicationProtocolYear, application) {
244114
+ super();
244115
+ this.status = status;
244116
+ this.applicationInterpretedModelSchemaName = applicationInterpretedModelSchemaName;
244117
+ this.applicationProtocolYear = applicationProtocolYear;
244118
+ this.application = application;
244119
+ }
244120
+ type = "APPLICATION_PROTOCOL_DEFINITION";
244121
+ static parse(a2, ctx) {
244122
+ const status = ctx.parseString(a2[0]);
244123
+ const schemaName = ctx.parseString(a2[1]);
244124
+ const year = ctx.parseNumber(a2[2]);
244125
+ const application = ctx.parseRef(a2[3]);
244126
+ return new _ApplicationProtocolDefinition(status, schemaName, year, application);
244127
+ }
244128
+ toStep() {
244129
+ return `APPLICATION_PROTOCOL_DEFINITION(${stepStr(this.status)},${stepStr(this.applicationInterpretedModelSchemaName)},${this.applicationProtocolYear},${this.application})`;
244130
+ }
244131
+ };
244132
+ register("APPLICATION_PROTOCOL_DEFINITION", ApplicationProtocolDefinition.parse.bind(ApplicationProtocolDefinition));
244133
+ var ContextDependentShapeRepresentation = class _ContextDependentShapeRepresentation extends Entity {
244134
+ constructor(representationRelation, representedProductRelation) {
244135
+ super();
244136
+ this.representationRelation = representationRelation;
244137
+ this.representedProductRelation = representedProductRelation;
244138
+ }
244139
+ type = "CONTEXT_DEPENDENT_SHAPE_REPRESENTATION";
244140
+ static parse(a2, ctx) {
244141
+ const representationRelation = ctx.parseRef(a2[0]);
244142
+ const representedProductRelation = ctx.parseRef(a2[1]);
244143
+ return new _ContextDependentShapeRepresentation(representationRelation, representedProductRelation);
244144
+ }
244145
+ toStep() {
244146
+ return `CONTEXT_DEPENDENT_SHAPE_REPRESENTATION(${this.representationRelation},${this.representedProductRelation})`;
244147
+ }
244148
+ };
244149
+ register("CONTEXT_DEPENDENT_SHAPE_REPRESENTATION", ContextDependentShapeRepresentation.parse.bind(ContextDependentShapeRepresentation));
244150
+ var ItemDefinedTransformation = class _ItemDefinedTransformation extends Entity {
244151
+ constructor(name, description, transformItem1, transformItem2) {
244152
+ super();
244153
+ this.name = name;
244154
+ this.description = description;
244155
+ this.transformItem1 = transformItem1;
244156
+ this.transformItem2 = transformItem2;
244157
+ }
244158
+ type = "ITEM_DEFINED_TRANSFORMATION";
244159
+ static parse(a2, ctx) {
244160
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244161
+ const description = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
244162
+ const item1 = ctx.parseRef(a2[2]);
244163
+ const item2 = ctx.parseRef(a2[3]);
244164
+ return new _ItemDefinedTransformation(name, description, item1, item2);
244165
+ }
244166
+ toStep() {
244167
+ return `ITEM_DEFINED_TRANSFORMATION(${stepStr(this.name)},${stepStr(this.description)},${this.transformItem1},${this.transformItem2})`;
244168
+ }
244169
+ };
244170
+ register("ITEM_DEFINED_TRANSFORMATION", ItemDefinedTransformation.parse.bind(ItemDefinedTransformation));
244171
+ var NextAssemblyUsageOccurrence = class _NextAssemblyUsageOccurrence extends Entity {
244172
+ constructor(id2, name, description, relatingProductDefinition, relatedProductDefinition, referenceDesignator) {
244173
+ super();
244174
+ this.id = id2;
244175
+ this.name = name;
244176
+ this.description = description;
244177
+ this.relatingProductDefinition = relatingProductDefinition;
244178
+ this.relatedProductDefinition = relatedProductDefinition;
244179
+ this.referenceDesignator = referenceDesignator;
244180
+ }
244181
+ type = "NEXT_ASSEMBLY_USAGE_OCCURRENCE";
244182
+ static parse(a2, ctx) {
244183
+ const id2 = ctx.parseString(a2[0]);
244184
+ const name = ctx.parseString(a2[1]);
244185
+ const description = a2[2] === "$" ? "" : ctx.parseString(a2[2]);
244186
+ const relating = ctx.parseRef(a2[3]);
244187
+ const related = ctx.parseRef(a2[4]);
244188
+ const designator = a2[5] === "$" ? "" : ctx.parseString(a2[5]);
244189
+ return new _NextAssemblyUsageOccurrence(id2, name, description, relating, related, designator);
244190
+ }
244191
+ toStep() {
244192
+ return `NEXT_ASSEMBLY_USAGE_OCCURRENCE(${stepStr(this.id)},${stepStr(this.name)},${this.description ? stepStr(this.description) : "$"},${this.relatingProductDefinition},${this.relatedProductDefinition},${this.referenceDesignator ? stepStr(this.referenceDesignator) : "$"})`;
244193
+ }
244194
+ };
244195
+ register("NEXT_ASSEMBLY_USAGE_OCCURRENCE", NextAssemblyUsageOccurrence.parse.bind(NextAssemblyUsageOccurrence));
244196
+ var Product = class _Product extends Entity {
244197
+ constructor(name, id2, description, frameOfReference) {
244198
+ super();
244199
+ this.name = name;
244200
+ this.id = id2;
244201
+ this.description = description;
244202
+ this.frameOfReference = frameOfReference;
244203
+ }
244204
+ type = "PRODUCT";
244205
+ static parse(a2, ctx) {
244206
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244207
+ const id2 = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
244208
+ const description = a2[2] === "$" ? "" : ctx.parseString(a2[2]);
244209
+ const refs = a2[3].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
244210
+ return new _Product(name, id2, description, refs);
244211
+ }
244212
+ toStep() {
244213
+ return `PRODUCT(${stepStr(this.name)},${stepStr(this.id)},${stepStr(this.description)},(${this.frameOfReference.join(",")}))`;
244214
+ }
244215
+ };
244216
+ register("PRODUCT", Product.parse.bind(Product));
244217
+ var ProductContext = class _ProductContext extends Entity {
244218
+ constructor(name, frameOfReference, disciplineType) {
244219
+ super();
244220
+ this.name = name;
244221
+ this.frameOfReference = frameOfReference;
244222
+ this.disciplineType = disciplineType;
244223
+ }
244224
+ type = "PRODUCT_CONTEXT";
244225
+ static parse(a2, ctx) {
244226
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244227
+ const frameOfReference = ctx.parseRef(a2[1]);
244228
+ const disciplineType = ctx.parseString(a2[2]);
244229
+ return new _ProductContext(name, frameOfReference, disciplineType);
244230
+ }
244231
+ toStep() {
244232
+ return `PRODUCT_CONTEXT(${stepStr(this.name)},${this.frameOfReference},${stepStr(this.disciplineType)})`;
244233
+ }
244234
+ };
244235
+ register("PRODUCT_CONTEXT", ProductContext.parse.bind(ProductContext));
244236
+ var ProductDefinition = class _ProductDefinition extends Entity {
244237
+ constructor(id2, description, formation, frameOfReference) {
244238
+ super();
244239
+ this.id = id2;
244240
+ this.description = description;
244241
+ this.formation = formation;
244242
+ this.frameOfReference = frameOfReference;
244243
+ }
244244
+ type = "PRODUCT_DEFINITION";
244245
+ static parse(a2, ctx) {
244246
+ const id2 = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244247
+ const description = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
244248
+ const formation = ctx.parseRef(a2[2]);
244249
+ const frameOfReference = ctx.parseRef(a2[3]);
244250
+ return new _ProductDefinition(id2, description, formation, frameOfReference);
244251
+ }
244252
+ toStep() {
244253
+ return `PRODUCT_DEFINITION(${stepStr(this.id)},${stepStr(this.description)},${this.formation},${this.frameOfReference})`;
244254
+ }
244255
+ };
244256
+ register("PRODUCT_DEFINITION", ProductDefinition.parse.bind(ProductDefinition));
244257
+ var ProductDefinitionContext = class _ProductDefinitionContext extends Entity {
244258
+ constructor(name, frameOfReference, lifecycleStage) {
244259
+ super();
244260
+ this.name = name;
244261
+ this.frameOfReference = frameOfReference;
244262
+ this.lifecycleStage = lifecycleStage;
244263
+ }
244264
+ type = "PRODUCT_DEFINITION_CONTEXT";
244265
+ static parse(a2, ctx) {
244266
+ const name = ctx.parseString(a2[0]);
244267
+ const frameOfReference = ctx.parseRef(a2[1]);
244268
+ const lifecycleStage = ctx.parseString(a2[2]);
244269
+ return new _ProductDefinitionContext(name, frameOfReference, lifecycleStage);
244270
+ }
244271
+ toStep() {
244272
+ return `PRODUCT_DEFINITION_CONTEXT(${stepStr(this.name)},${this.frameOfReference},${stepStr(this.lifecycleStage)})`;
244273
+ }
244274
+ };
244275
+ register("PRODUCT_DEFINITION_CONTEXT", ProductDefinitionContext.parse.bind(ProductDefinitionContext));
244276
+ var ProductDefinitionFormation = class _ProductDefinitionFormation extends Entity {
244277
+ constructor(id2, description, ofProduct) {
244278
+ super();
244279
+ this.id = id2;
244280
+ this.description = description;
244281
+ this.ofProduct = ofProduct;
244282
+ }
244283
+ type = "PRODUCT_DEFINITION_FORMATION";
244284
+ static parse(a2, ctx) {
244285
+ const id2 = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244286
+ const description = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
244287
+ const ofProduct = ctx.parseRef(a2[2]);
244288
+ return new _ProductDefinitionFormation(id2, description, ofProduct);
244289
+ }
244290
+ toStep() {
244291
+ return `PRODUCT_DEFINITION_FORMATION(${stepStr(this.id)},${stepStr(this.description)},${this.ofProduct})`;
244292
+ }
244293
+ };
244294
+ register("PRODUCT_DEFINITION_FORMATION", ProductDefinitionFormation.parse.bind(ProductDefinitionFormation));
244295
+ var ProductDefinitionShape = class _ProductDefinitionShape extends Entity {
244296
+ constructor(name, description, definition) {
244297
+ super();
244298
+ this.name = name;
244299
+ this.description = description;
244300
+ this.definition = definition;
244301
+ }
244302
+ type = "PRODUCT_DEFINITION_SHAPE";
244303
+ static parse(a2, ctx) {
244304
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244305
+ const description = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
244306
+ const definition = ctx.parseRef(a2[2]);
244307
+ return new _ProductDefinitionShape(name, description, definition);
244308
+ }
244309
+ toStep() {
244310
+ return `PRODUCT_DEFINITION_SHAPE(${stepStr(this.name)},${stepStr(this.description)},${this.definition})`;
244311
+ }
244312
+ };
244313
+ register("PRODUCT_DEFINITION_SHAPE", ProductDefinitionShape.parse.bind(ProductDefinitionShape));
244314
+ var ProductRelatedProductCategory = class _ProductRelatedProductCategory extends Entity {
244315
+ constructor(name, description, products) {
244316
+ super();
244317
+ this.name = name;
244318
+ this.description = description;
244319
+ this.products = products;
244320
+ }
244321
+ type = "PRODUCT_RELATED_PRODUCT_CATEGORY";
244322
+ static parse(a2, ctx) {
244323
+ const name = ctx.parseString(a2[0]);
244324
+ const description = a2[1] === "$" ? "" : ctx.parseString(a2[1]);
244325
+ const products = a2[2].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
244326
+ return new _ProductRelatedProductCategory(name, description, products);
244327
+ }
244328
+ toStep() {
244329
+ return `PRODUCT_RELATED_PRODUCT_CATEGORY(${stepStr(this.name)},${this.description ? stepStr(this.description) : "$"},(${this.products.join(",")}))`;
244330
+ }
244331
+ };
244332
+ register("PRODUCT_RELATED_PRODUCT_CATEGORY", ProductRelatedProductCategory.parse.bind(ProductRelatedProductCategory));
244333
+ var ShapeDefinitionRepresentation = class _ShapeDefinitionRepresentation extends Entity {
244334
+ constructor(definition, usedRepresentation) {
244335
+ super();
244336
+ this.definition = definition;
244337
+ this.usedRepresentation = usedRepresentation;
244338
+ }
244339
+ type = "SHAPE_DEFINITION_REPRESENTATION";
244340
+ static parse(a2, ctx) {
244341
+ const definition = ctx.parseRef(a2[0]);
244342
+ const usedRepresentation = ctx.parseRef(a2[1]);
244343
+ return new _ShapeDefinitionRepresentation(definition, usedRepresentation);
244344
+ }
244345
+ toStep() {
244346
+ return `SHAPE_DEFINITION_REPRESENTATION(${this.definition},${this.usedRepresentation})`;
244347
+ }
244348
+ };
244349
+ register("SHAPE_DEFINITION_REPRESENTATION", ShapeDefinitionRepresentation.parse.bind(ShapeDefinitionRepresentation));
244350
+ var ShapeRepresentation = class _ShapeRepresentation extends Entity {
244351
+ constructor(name, items, contextOfItems) {
244352
+ super();
244353
+ this.name = name;
244354
+ this.items = items;
244355
+ this.contextOfItems = contextOfItems;
244356
+ }
244357
+ type = "SHAPE_REPRESENTATION";
244358
+ static parse(a2, ctx) {
244359
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244360
+ const items = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
244361
+ const contextOfItems = ctx.parseRef(a2[2]);
244362
+ return new _ShapeRepresentation(name, items, contextOfItems);
244363
+ }
244364
+ toStep() {
244365
+ return `SHAPE_REPRESENTATION(${stepStr(this.name)},(${this.items.join(",")}),${this.contextOfItems})`;
244366
+ }
244367
+ };
244368
+ register("SHAPE_REPRESENTATION", ShapeRepresentation.parse.bind(ShapeRepresentation));
244369
+ var AdvancedFace = class _AdvancedFace extends Entity {
244370
+ constructor(name, bounds, surface, sameSense) {
244371
+ super();
244372
+ this.name = name;
244373
+ this.bounds = bounds;
244374
+ this.surface = surface;
244375
+ this.sameSense = sameSense;
244376
+ }
244377
+ type = "ADVANCED_FACE";
244378
+ static parse(a2, ctx) {
244379
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244380
+ const bounds = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
244381
+ const surf = ctx.parseRef(a2[2]);
244382
+ const ss3 = a2[3].trim() === ".T.";
244383
+ return new _AdvancedFace(name, bounds, surf, ss3);
244384
+ }
244385
+ toStep() {
244386
+ return `ADVANCED_FACE(${this.name ? `'${this.name}'` : "''"},(${this.bounds.join(",")}),${this.surface},${this.sameSense ? ".T." : ".F."})`;
244387
+ }
244388
+ };
244389
+ register("ADVANCED_FACE", AdvancedFace.parse.bind(AdvancedFace));
244390
+ var ClosedShell = class _ClosedShell extends Entity {
244391
+ constructor(name, faces) {
244392
+ super();
244393
+ this.name = name;
244394
+ this.faces = faces;
244395
+ }
244396
+ type = "CLOSED_SHELL";
244397
+ static parse(a2, ctx) {
244398
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244399
+ const faces = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok.trim()));
244400
+ return new _ClosedShell(name, faces);
244401
+ }
244402
+ toStep() {
244403
+ return `CLOSED_SHELL(${this.name ? `'${this.name}'` : "''"},(${this.faces.join(",")}))`;
244404
+ }
244405
+ };
244406
+ register("CLOSED_SHELL", ClosedShell.parse.bind(ClosedShell));
244407
+ var EdgeCurve = class _EdgeCurve extends Entity {
244408
+ constructor(name, start, end, curve, sameSense) {
244409
+ super();
244410
+ this.name = name;
244411
+ this.start = start;
244412
+ this.end = end;
244413
+ this.curve = curve;
244414
+ this.sameSense = sameSense;
244415
+ }
244416
+ type = "EDGE_CURVE";
244417
+ static parse(a2, ctx) {
244418
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244419
+ const s2 = ctx.parseRef(a2[1]);
244420
+ const e4 = ctx.parseRef(a2[2]);
244421
+ const c3 = ctx.parseRef(a2[3]);
244422
+ const same = a2[4].trim() === ".T.";
244423
+ return new _EdgeCurve(name, s2, e4, c3, same);
244424
+ }
244425
+ toStep() {
244426
+ return `EDGE_CURVE(${this.name ? `'${this.name}'` : "''"},${this.start},${this.end},${this.curve},${this.sameSense ? ".T." : ".F."})`;
244427
+ }
244428
+ };
244429
+ register("EDGE_CURVE", EdgeCurve.parse.bind(EdgeCurve));
244430
+ var EdgeLoop = class _EdgeLoop extends Entity {
244431
+ constructor(name, edges) {
244432
+ super();
244433
+ this.name = name;
244434
+ this.edges = edges;
244435
+ }
244436
+ type = "EDGE_LOOP";
244437
+ static parse(a2, ctx) {
244438
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244439
+ const list = a2[1].replace(/^\(|\)$/g, "").split(",").filter(Boolean).map((tok) => ctx.parseRef(tok));
244440
+ return new _EdgeLoop(name, list);
244441
+ }
244442
+ toStep() {
244443
+ return `EDGE_LOOP(${stepStr(this.name)},(${this.edges.join(",")}))`;
244444
+ }
244445
+ };
244446
+ register("EDGE_LOOP", EdgeLoop.parse.bind(EdgeLoop));
244447
+ var FaceBound = class _FaceBound extends Entity {
244448
+ constructor(name, bound, sameSense) {
244449
+ super();
244450
+ this.name = name;
244451
+ this.bound = bound;
244452
+ this.sameSense = sameSense;
244453
+ }
244454
+ type = "FACE_BOUND";
244455
+ static parse(a2, ctx) {
244456
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244457
+ return new _FaceBound(name, ctx.parseRef(a2[1]), a2[2].trim() === ".T.");
244458
+ }
244459
+ toStep() {
244460
+ return `FACE_BOUND(${stepStr(this.name)},${this.bound},${this.sameSense ? ".T." : ".F."})`;
244461
+ }
244462
+ };
244463
+ register("FACE_BOUND", FaceBound.parse.bind(FaceBound));
244464
+ var FaceOuterBound = class _FaceOuterBound extends Entity {
244465
+ constructor(name, bound, sameSense) {
244466
+ super();
244467
+ this.name = name;
244468
+ this.bound = bound;
244469
+ this.sameSense = sameSense;
244470
+ }
244471
+ type = "FACE_OUTER_BOUND";
244472
+ static parse(a2, ctx) {
244473
+ return new _FaceOuterBound(ctx.parseString(a2[0]), ctx.parseRef(a2[1]), a2[2].trim() === ".T.");
244474
+ }
244475
+ toStep() {
244476
+ return `FACE_OUTER_BOUND('${this.name}',${this.bound},${this.sameSense ? ".T." : ".F."})`;
244477
+ }
244478
+ };
244479
+ register("FACE_OUTER_BOUND", FaceOuterBound.parse.bind(FaceOuterBound));
244480
+ var ManifoldSolidBrep = class _ManifoldSolidBrep extends Entity {
244481
+ constructor(name, outer) {
244482
+ super();
244483
+ this.name = name;
244484
+ this.outer = outer;
244485
+ }
244486
+ type = "MANIFOLD_SOLID_BREP";
244487
+ static parse(a2, ctx) {
244488
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244489
+ return new _ManifoldSolidBrep(name, ctx.parseRef(a2[1]));
244490
+ }
244491
+ toStep() {
244492
+ return `MANIFOLD_SOLID_BREP(${stepStr(this.name)},${this.outer})`;
244493
+ }
244494
+ };
244495
+ register("MANIFOLD_SOLID_BREP", ManifoldSolidBrep.parse.bind(ManifoldSolidBrep));
244496
+ var OrientedEdge = class _OrientedEdge extends Entity {
244497
+ constructor(name, edge, orientation3) {
244498
+ super();
244499
+ this.name = name;
244500
+ this.edge = edge;
244501
+ this.orientation = orientation3;
244502
+ }
244503
+ type = "ORIENTED_EDGE";
244504
+ static parse(a2, ctx) {
244505
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244506
+ const edge = ctx.parseRef(a2[3]);
244507
+ const orient = a2[4]?.trim?.() === ".T." || a2[2]?.trim?.() === ".T.";
244508
+ return new _OrientedEdge(name, edge, orient);
244509
+ }
244510
+ toStep() {
244511
+ return `ORIENTED_EDGE(${stepStr(this.name)},*,*,${this.edge},${this.orientation ? ".T." : ".F."})`;
244512
+ }
244513
+ };
244514
+ register("ORIENTED_EDGE", OrientedEdge.parse.bind(OrientedEdge));
244515
+ var VertexPoint = class _VertexPoint extends Entity {
244516
+ constructor(name, pnt) {
244517
+ super();
244518
+ this.name = name;
244519
+ this.pnt = pnt;
244520
+ }
244521
+ type = "VERTEX_POINT";
244522
+ static parse(a2, ctx) {
244523
+ const name = a2[0] === "$" ? "" : ctx.parseString(a2[0]);
244524
+ return new _VertexPoint(name, ctx.parseRef(a2[1]));
244525
+ }
244526
+ toStep() {
244527
+ return `VERTEX_POINT(${this.name ? `'${this.name}'` : "''"},${this.pnt})`;
244528
+ }
244529
+ };
244530
+ register("VERTEX_POINT", VertexPoint.parse.bind(VertexPoint));
244531
+ var Unknown = class extends Entity {
244532
+ constructor(type, args) {
244533
+ super();
244534
+ this.type = type;
244535
+ this.args = args;
244536
+ }
244537
+ toStep() {
244538
+ if (this.args.length === 1 && this.args[0].startsWith("( ")) {
244539
+ const content = this.args[0].slice(2, -2).trim();
244540
+ const parts = content.split(/\s+(?=[A-Z_])/g);
244541
+ return `(
244542
+ ${parts.join(`
244543
+ `)}
244544
+ )`;
244545
+ }
244546
+ return `${this.type}(${this.args.join(",")})`;
244547
+ }
244548
+ };
244549
+ function tokenizeSTEP(data) {
244550
+ const entities = [];
244551
+ const dataStart = data.indexOf("DATA;");
244552
+ const dataEnd = data.indexOf("ENDSEC;", dataStart);
244553
+ if (dataStart === -1 || dataEnd === -1) {
244554
+ throw new Error("Could not find DATA section in STEP file");
244555
+ }
244556
+ const dataSection = data.substring(dataStart + 5, dataEnd);
244557
+ const entityPattern = /#(\d+)\s*=\s*/g;
244558
+ let match;
244559
+ const entityStarts = [];
244560
+ while ((match = entityPattern.exec(dataSection)) !== null) {
244561
+ entityStarts.push({
244562
+ index: match.index,
244563
+ id: parseInt(match[1], 10)
244564
+ });
244565
+ }
244566
+ for (let i2 = 0;i2 < entityStarts.length; i2++) {
244567
+ const start = entityStarts[i2];
244568
+ const nextStart = i2 + 1 < entityStarts.length ? entityStarts[i2 + 1].index : dataSection.length;
244569
+ const entityText = dataSection.substring(start.index, nextStart);
244570
+ const semiIndex = entityText.indexOf(";");
244571
+ if (semiIndex === -1) {
244572
+ throw new Error(`Could not find closing semicolon for entity #${start.id}`);
244573
+ }
244574
+ const fullEntity = entityText.substring(0, semiIndex + 1);
244575
+ if (fullEntity.match(/#\d+\s*=\s*\(/)) {
244576
+ const complexMatch = fullEntity.match(/#\d+\s*=\s*\(([\s\S]*)\);/);
244577
+ if (!complexMatch) {
244578
+ throw new Error(`Could not parse complex entity: ${fullEntity.substring(0, 100)}`);
244579
+ }
244580
+ entities.push({
244581
+ id: eid(start.id),
244582
+ type: "Unknown",
244583
+ args: [`( ${complexMatch[1].trim()} )`]
244584
+ });
244585
+ } else {
244586
+ const match2 = fullEntity.match(/#\d+\s*=\s*([A-Z0-9_]+)\s*\(([\s\S]*)\);/);
244587
+ if (!match2) {
244588
+ throw new Error(`Could not parse entity: ${fullEntity.substring(0, 100)}`);
244589
+ }
244590
+ const type = match2[1].trim();
244591
+ const argsBody = match2[2].trim();
244592
+ const args = splitArgs(argsBody);
244593
+ entities.push({ id: eid(start.id), type, args });
244594
+ }
244595
+ }
244596
+ return entities;
244597
+ }
244598
+ function splitArgs(s2) {
244599
+ const out = [];
244600
+ let buf = "";
244601
+ let depth = 0;
244602
+ let inStr = false;
244603
+ for (let i2 = 0;i2 < s2.length; i2++) {
244604
+ const c3 = s2[i2];
244605
+ if (c3 === "'" && s2[i2 - 1] !== "\\")
244606
+ inStr = !inStr;
244607
+ if (!inStr) {
244608
+ if (c3 === "(")
244609
+ depth++;
244610
+ if (c3 === ")")
244611
+ depth--;
244612
+ if (c3 === "," && depth === 0) {
244613
+ out.push(buf.trim());
244614
+ buf = "";
244615
+ continue;
244616
+ }
244617
+ }
244618
+ buf += c3;
244619
+ }
244620
+ if (buf.trim())
244621
+ out.push(buf.trim());
244622
+ return out;
244623
+ }
244624
+ function parseRepository(data) {
244625
+ const repo = new Repository;
244626
+ const ctx = {
244627
+ repo,
244628
+ parseRef(_tok) {
244629
+ const n3 = +_tok.replace("#", "").trim();
244630
+ return new Ref(eid(n3));
244631
+ },
244632
+ parseNumber(tok) {
244633
+ return Number(tok);
244634
+ },
244635
+ parseString(tok) {
244636
+ const m3 = tok.match(/^'(.*)'$/);
244637
+ if (!m3)
244638
+ throw new Error(`Expected string: ${tok}`);
244639
+ return m3[1].replace(/''/g, "'");
244640
+ }
244641
+ };
244642
+ for (const row of tokenizeSTEP(data)) {
244643
+ const parser = getParser(row.type);
244644
+ if (!parser) {
244645
+ repo.set(row.id, new Unknown(row.type, row.args));
244646
+ continue;
244647
+ }
244648
+ const entity = parser(row.args, ctx);
244649
+ repo.set(row.id, entity);
244650
+ }
244651
+ return repo;
244652
+ }
244653
+
244654
+ // node_modules/stepts/lib/core/EntityId.ts
244655
+ var eid2 = (n3) => n3;
244656
+
244657
+ // node_modules/circuit-json-to-step/dist/index.js
244658
+ function createBoxTriangles(box2) {
244659
+ const { center: center2, size: size2 } = box2;
244660
+ const halfX = size2.x / 2;
244661
+ const halfY = size2.y / 2;
244662
+ const halfZ = size2.z / 2;
244663
+ const corners = [
244664
+ { x: -halfX, y: -halfY, z: -halfZ },
244665
+ { x: halfX, y: -halfY, z: -halfZ },
244666
+ { x: halfX, y: halfY, z: -halfZ },
244667
+ { x: -halfX, y: halfY, z: -halfZ },
244668
+ { x: -halfX, y: -halfY, z: halfZ },
244669
+ { x: halfX, y: -halfY, z: halfZ },
244670
+ { x: halfX, y: halfY, z: halfZ },
244671
+ { x: -halfX, y: halfY, z: halfZ }
244672
+ ].map((p3) => ({ x: p3.x + center2.x, y: p3.y + center2.y, z: p3.z + center2.z }));
244673
+ const triangles = [
244674
+ {
244675
+ vertices: [corners[0], corners[1], corners[2]],
244676
+ normal: { x: 0, y: 0, z: -1 }
244677
+ },
244678
+ {
244679
+ vertices: [corners[0], corners[2], corners[3]],
244680
+ normal: { x: 0, y: 0, z: -1 }
244681
+ },
244682
+ {
244683
+ vertices: [corners[4], corners[6], corners[5]],
244684
+ normal: { x: 0, y: 0, z: 1 }
244685
+ },
244686
+ {
244687
+ vertices: [corners[4], corners[7], corners[6]],
244688
+ normal: { x: 0, y: 0, z: 1 }
244689
+ },
244690
+ {
244691
+ vertices: [corners[0], corners[5], corners[1]],
244692
+ normal: { x: 0, y: -1, z: 0 }
244693
+ },
244694
+ {
244695
+ vertices: [corners[0], corners[4], corners[5]],
244696
+ normal: { x: 0, y: -1, z: 0 }
244697
+ },
244698
+ {
244699
+ vertices: [corners[2], corners[6], corners[7]],
244700
+ normal: { x: 0, y: 1, z: 0 }
244701
+ },
244702
+ {
244703
+ vertices: [corners[2], corners[7], corners[3]],
244704
+ normal: { x: 0, y: 1, z: 0 }
244705
+ },
244706
+ {
244707
+ vertices: [corners[0], corners[3], corners[7]],
244708
+ normal: { x: -1, y: 0, z: 0 }
244709
+ },
244710
+ {
244711
+ vertices: [corners[0], corners[7], corners[4]],
244712
+ normal: { x: -1, y: 0, z: 0 }
244713
+ },
244714
+ {
244715
+ vertices: [corners[1], corners[6], corners[2]],
244716
+ normal: { x: 1, y: 0, z: 0 }
244717
+ },
244718
+ {
244719
+ vertices: [corners[1], corners[5], corners[6]],
244720
+ normal: { x: 1, y: 0, z: 0 }
244721
+ }
244722
+ ];
244723
+ return triangles;
244724
+ }
244725
+ function createStepFacesFromTriangles(repo, triangles) {
244726
+ const faces = [];
244727
+ for (const triangle of triangles) {
244728
+ const v12 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", triangle.vertices[0].x, triangle.vertices[0].y, triangle.vertices[0].z))));
244729
+ const v23 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", triangle.vertices[1].x, triangle.vertices[1].y, triangle.vertices[1].z))));
244730
+ const v3 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", triangle.vertices[2].x, triangle.vertices[2].y, triangle.vertices[2].z))));
244731
+ const p12 = v12.resolve(repo).pnt.resolve(repo);
244732
+ const p23 = v23.resolve(repo).pnt.resolve(repo);
244733
+ const createEdge = (vStart, vEnd) => {
244734
+ const pStart = vStart.resolve(repo).pnt.resolve(repo);
244735
+ const pEnd = vEnd.resolve(repo).pnt.resolve(repo);
244736
+ const dir = repo.add(new Direction("", pEnd.x - pStart.x, pEnd.y - pStart.y, pEnd.z - pStart.z));
244737
+ const vec = repo.add(new Vector3("", dir, 1));
244738
+ const line2 = repo.add(new Line3("", vStart.resolve(repo).pnt, vec));
244739
+ return repo.add(new EdgeCurve("", vStart, vEnd, line2, true));
244740
+ };
244741
+ const edge1 = createEdge(v12, v23);
244742
+ const edge2 = createEdge(v23, v3);
244743
+ const edge3 = createEdge(v3, v12);
244744
+ const edgeLoop = repo.add(new EdgeLoop("", [
244745
+ repo.add(new OrientedEdge("", edge1, true)),
244746
+ repo.add(new OrientedEdge("", edge2, true)),
244747
+ repo.add(new OrientedEdge("", edge3, true))
244748
+ ]));
244749
+ const normalDir = repo.add(new Direction("", triangle.normal.x, triangle.normal.y, triangle.normal.z));
244750
+ const refX = p23.x - p12.x;
244751
+ const refY = p23.y - p12.y;
244752
+ const refZ = p23.z - p12.z;
244753
+ const refDir = repo.add(new Direction("", refX, refY, refZ));
244754
+ const placement = repo.add(new Axis2Placement3D("", v12.resolve(repo).pnt, normalDir, refDir));
244755
+ const plane = repo.add(new Plane("", placement));
244756
+ const face = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", edgeLoop, true))], plane, true));
244757
+ faces.push(face);
244758
+ }
244759
+ return faces;
244760
+ }
244761
+ async function generateComponentMeshes(options) {
244762
+ const {
244763
+ repo,
244764
+ circuitJson,
244765
+ boardThickness,
244766
+ includeExternalMeshes = false,
244767
+ excludeCadComponentIds,
244768
+ excludePcbComponentIds,
244769
+ pcbComponentIdsWithStepUrl
244770
+ } = options;
244771
+ const solids = [];
244772
+ try {
244773
+ const filteredCircuitJson = circuitJson.filter((e4) => {
244774
+ if (e4.type === "pcb_board")
244775
+ return false;
244776
+ if (e4.type === "cad_component" && e4.cad_component_id && excludeCadComponentIds?.has(e4.cad_component_id)) {
244777
+ return false;
244778
+ }
244779
+ if (e4.type === "pcb_component" && e4.pcb_component_id && excludePcbComponentIds?.has(e4.pcb_component_id)) {
244780
+ return false;
244781
+ }
244782
+ if (e4.type === "cad_component" && e4.model_step_url) {
244783
+ return false;
244784
+ }
244785
+ if (e4.type === "cad_component" && e4.pcb_component_id && pcbComponentIdsWithStepUrl?.has(e4.pcb_component_id)) {
244786
+ return false;
244787
+ }
244788
+ return true;
244789
+ }).map((e4) => {
244790
+ if (!includeExternalMeshes && e4.type === "cad_component") {
244791
+ return {
244792
+ ...e4,
244793
+ model_3mf_url: undefined,
244794
+ model_obj_url: undefined,
244795
+ model_stl_url: undefined,
244796
+ model_glb_url: undefined,
244797
+ model_gltf_url: undefined
244798
+ };
244799
+ }
244800
+ return e4;
244801
+ });
244802
+ const gltfModule = "circuit-json-to-gltf";
244803
+ const { convertCircuitJsonTo3D } = await import(gltfModule);
244804
+ const scene3d = await convertCircuitJsonTo3D(filteredCircuitJson, {
244805
+ boardThickness,
244806
+ renderBoardTextures: false
244807
+ });
244808
+ const allTriangles = [];
244809
+ for (const box2 of scene3d.boxes) {
244810
+ if (box2.mesh && "triangles" in box2.mesh) {
244811
+ allTriangles.push(...box2.mesh.triangles);
244812
+ } else {
244813
+ const boxTriangles = createBoxTriangles(box2);
244814
+ allTriangles.push(...boxTriangles);
244815
+ }
244816
+ }
244817
+ if (allTriangles.length > 0) {
244818
+ const transformedTriangles = allTriangles.map((tri) => ({
244819
+ vertices: tri.vertices.map((v3) => ({
244820
+ x: v3.x,
244821
+ y: v3.z,
244822
+ z: v3.y
244823
+ })),
244824
+ normal: {
244825
+ x: tri.normal.x,
244826
+ y: tri.normal.z,
244827
+ z: tri.normal.y
244828
+ }
244829
+ }));
244830
+ const componentFaces = createStepFacesFromTriangles(repo, transformedTriangles);
244831
+ const componentShell = repo.add(new ClosedShell("", componentFaces));
244832
+ const componentSolid = repo.add(new ManifoldSolidBrep("Components", componentShell));
244833
+ solids.push(componentSolid);
244834
+ }
244835
+ } catch (error) {
244836
+ console.warn("Failed to generate component mesh:", error);
244837
+ }
244838
+ return solids;
244839
+ }
244840
+ var EXCLUDED_ENTITY_TYPES = /* @__PURE__ */ new Set([
244841
+ "APPLICATION_CONTEXT",
244842
+ "APPLICATION_PROTOCOL_DEFINITION",
244843
+ "PRODUCT",
244844
+ "PRODUCT_CONTEXT",
244845
+ "PRODUCT_DEFINITION",
244846
+ "PRODUCT_DEFINITION_FORMATION",
244847
+ "PRODUCT_DEFINITION_CONTEXT",
244848
+ "PRODUCT_DEFINITION_SHAPE",
244849
+ "SHAPE_DEFINITION_REPRESENTATION",
244850
+ "ADVANCED_BREP_SHAPE_REPRESENTATION",
244851
+ "MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION",
244852
+ "PRESENTATION_STYLE_ASSIGNMENT",
244853
+ "SURFACE_STYLE_USAGE",
244854
+ "SURFACE_SIDE_STYLE",
244855
+ "SURFACE_STYLE_FILL_AREA",
244856
+ "FILL_AREA_STYLE",
244857
+ "FILL_AREA_STYLE_COLOUR",
244858
+ "COLOUR_RGB",
244859
+ "STYLED_ITEM",
244860
+ "CURVE_STYLE",
244861
+ "DRAUGHTING_PRE_DEFINED_CURVE_FONT",
244862
+ "PRODUCT_RELATED_PRODUCT_CATEGORY",
244863
+ "NEXT_ASSEMBLY_USAGE_OCCURRENCE",
244864
+ "CONTEXT_DEPENDENT_SHAPE_REPRESENTATION",
244865
+ "ITEM_DEFINED_TRANSFORMATION"
244866
+ ]);
244867
+ function asVector3(value) {
244868
+ return {
244869
+ x: value?.x ?? 0,
244870
+ y: value?.y ?? 0,
244871
+ z: value?.z ?? 0
244872
+ };
244873
+ }
244874
+ function toRadians(rotation4) {
244875
+ const factor = Math.PI / 180;
244876
+ return {
244877
+ x: rotation4.x * factor,
244878
+ y: rotation4.y * factor,
244879
+ z: rotation4.z * factor
244880
+ };
244881
+ }
244882
+ function transformPoint(point5, rotation4, translation) {
244883
+ const rotated = rotateVector(point5, rotation4);
244884
+ return [
244885
+ rotated[0] + translation.x,
244886
+ rotated[1] + translation.y,
244887
+ rotated[2] + translation.z
244888
+ ];
244889
+ }
244890
+ function transformDirection(vector2, rotation4) {
244891
+ return rotateVector(vector2, rotation4);
244892
+ }
244893
+ function rotateVector(vector2, rotation4) {
244894
+ let [x3, y4, z21] = vector2;
244895
+ if (rotation4.x !== 0) {
244896
+ const cosX = Math.cos(rotation4.x);
244897
+ const sinX = Math.sin(rotation4.x);
244898
+ const y12 = y4 * cosX - z21 * sinX;
244899
+ const z110 = y4 * sinX + z21 * cosX;
244900
+ y4 = y12;
244901
+ z21 = z110;
244902
+ }
244903
+ if (rotation4.y !== 0) {
244904
+ const cosY = Math.cos(rotation4.y);
244905
+ const sinY = Math.sin(rotation4.y);
244906
+ const x12 = x3 * cosY + z21 * sinY;
244907
+ const z110 = -x3 * sinY + z21 * cosY;
244908
+ x3 = x12;
244909
+ z21 = z110;
244910
+ }
244911
+ if (rotation4.z !== 0) {
244912
+ const cosZ = Math.cos(rotation4.z);
244913
+ const sinZ = Math.sin(rotation4.z);
244914
+ const x12 = x3 * cosZ - y4 * sinZ;
244915
+ const y12 = x3 * sinZ + y4 * cosZ;
244916
+ x3 = x12;
244917
+ y4 = y12;
244918
+ }
244919
+ return [x3, y4, z21];
244920
+ }
244921
+ async function readStepFile(modelUrl) {
244922
+ if (!/^https?:\/\//i.test(modelUrl)) {
244923
+ throw new Error(`Only HTTP(S) URLs are supported. For local files, read the file content and pass it directly. Received: ${modelUrl}`);
244924
+ }
244925
+ const globalFetch = globalThis.fetch;
244926
+ if (!globalFetch) {
244927
+ throw new Error("fetch is not available in this environment");
244928
+ }
244929
+ const res2 = await globalFetch(modelUrl);
244930
+ if (!res2.ok) {
244931
+ throw new Error(`HTTP ${res2.status} ${res2.statusText}`);
244932
+ }
244933
+ return await res2.text();
244934
+ }
244935
+ async function mergeExternalStepModels(options) {
244936
+ const { repo, circuitJson, boardThickness, fsMap } = options;
244937
+ const cadComponents = circuitJson.filter((item) => item?.type === "cad_component" && typeof item.model_step_url === "string");
244938
+ const pcbComponentMap = /* @__PURE__ */ new Map;
244939
+ for (const item of circuitJson) {
244940
+ if (item?.type === "pcb_component" && item.pcb_component_id) {
244941
+ pcbComponentMap.set(item.pcb_component_id, item);
244942
+ }
244943
+ }
244944
+ const solids = [];
244945
+ const handledComponentIds = /* @__PURE__ */ new Set;
244946
+ const handledPcbComponentIds = /* @__PURE__ */ new Set;
244947
+ for (const component of cadComponents) {
244948
+ const componentId = component.cad_component_id ?? "";
244949
+ const stepUrl = component.model_step_url;
244950
+ try {
244951
+ const stepText = fsMap?.[stepUrl] ?? await readStepFile(stepUrl);
244952
+ if (!stepText.trim()) {
244953
+ throw new Error("STEP file is empty");
244954
+ }
244955
+ const pcbComponent = component.pcb_component_id ? pcbComponentMap.get(component.pcb_component_id) : undefined;
244956
+ const layer = pcbComponent?.layer?.toLowerCase();
244957
+ const transform2 = {
244958
+ translation: asVector3(component.position),
244959
+ rotation: asVector3(component.rotation)
244960
+ };
244961
+ const componentSolids = mergeSingleStepModel(repo, stepText, transform2, {
244962
+ layer,
244963
+ boardThickness
244964
+ });
244965
+ if (componentSolids.length > 0) {
244966
+ if (componentId) {
244967
+ handledComponentIds.add(componentId);
244968
+ }
244969
+ const pcbComponentId = component.pcb_component_id;
244970
+ if (pcbComponentId) {
244971
+ handledPcbComponentIds.add(pcbComponentId);
244972
+ }
244973
+ }
244974
+ solids.push(...componentSolids);
244975
+ } catch (error) {
244976
+ console.warn(`Failed to merge STEP model from ${stepUrl}:`, error);
244977
+ }
244978
+ }
244979
+ return { solids, handledComponentIds, handledPcbComponentIds };
244980
+ }
244981
+ function mergeSingleStepModel(targetRepo, stepText, transform2, placement) {
244982
+ const sourceRepo = parseRepository(stepText);
244983
+ let entries = sourceRepo.entries().map(([id2, entity]) => [Number(id2), entity]).filter(([, entity]) => !EXCLUDED_ENTITY_TYPES.has(entity.type));
244984
+ entries = pruneInvalidEntries(entries);
244985
+ adjustTransformForPlacement(entries, transform2, placement);
244986
+ applyTransform(entries, transform2);
244987
+ const idMapping = allocateIds(targetRepo, entries);
244988
+ remapReferences(entries, idMapping);
244989
+ for (const [oldId, entity] of entries) {
244990
+ const mappedId = idMapping.get(oldId);
244991
+ if (mappedId === undefined)
244992
+ continue;
244993
+ targetRepo.set(eid2(mappedId), entity);
244994
+ }
244995
+ const solids = [];
244996
+ for (const [oldId, entity] of entries) {
244997
+ if (entity instanceof ManifoldSolidBrep) {
244998
+ const mappedId = idMapping.get(oldId);
244999
+ if (mappedId !== undefined) {
245000
+ solids.push(new Ref(eid2(mappedId)));
245001
+ }
245002
+ }
245003
+ }
245004
+ return solids;
245005
+ }
245006
+ function adjustTransformForPlacement(entries, transform2, placement) {
245007
+ if (!placement)
245008
+ return;
245009
+ const points = [];
245010
+ for (const [, entity] of entries) {
245011
+ if (entity instanceof CartesianPoint) {
245012
+ points.push([entity.x, entity.y, entity.z]);
245013
+ }
245014
+ }
245015
+ if (!points.length)
245016
+ return;
245017
+ const rotationRadians = toRadians(transform2.rotation);
245018
+ let minX = Infinity;
245019
+ let minY = Infinity;
245020
+ let minZ = Infinity;
245021
+ let maxX = -Infinity;
245022
+ let maxY = -Infinity;
245023
+ let maxZ = -Infinity;
245024
+ for (const point5 of points) {
245025
+ const [x3, y4, z21] = rotateVector(point5, rotationRadians);
245026
+ if (x3 < minX)
245027
+ minX = x3;
245028
+ if (y4 < minY)
245029
+ minY = y4;
245030
+ if (z21 < minZ)
245031
+ minZ = z21;
245032
+ if (x3 > maxX)
245033
+ maxX = x3;
245034
+ if (y4 > maxY)
245035
+ maxY = y4;
245036
+ if (z21 > maxZ)
245037
+ maxZ = z21;
245038
+ }
245039
+ if (!Number.isFinite(minX))
245040
+ return;
245041
+ const center2 = {
245042
+ x: (minX + maxX) / 2,
245043
+ y: (minY + maxY) / 2,
245044
+ z: (minZ + maxZ) / 2
245045
+ };
245046
+ const normalizedLayer = placement.layer?.toLowerCase() === "bottom" ? "bottom" : "top";
245047
+ const boardThickness = placement.boardThickness ?? 0;
245048
+ const targetX = transform2.translation.x;
245049
+ const targetY = transform2.translation.y;
245050
+ const targetZ = transform2.translation.z;
245051
+ const THROUGH_HOLE_Z_TOLERANCE = 0.001;
245052
+ const isThroughHoleComponent = minZ < -THROUGH_HOLE_Z_TOLERANCE && maxZ > THROUGH_HOLE_Z_TOLERANCE;
245053
+ transform2.translation.x = targetX - center2.x;
245054
+ transform2.translation.y = targetY - center2.y;
245055
+ if (isThroughHoleComponent) {
245056
+ transform2.translation.z = boardThickness;
245057
+ }
245058
+ if (!isThroughHoleComponent && boardThickness > 0) {
245059
+ const halfThickness = boardThickness / 2;
245060
+ const offsetZ = targetZ - halfThickness;
245061
+ if (normalizedLayer === "bottom") {
245062
+ transform2.translation.z = -maxZ + offsetZ;
245063
+ transform2.rotation.x = normalizeDegrees2(transform2.rotation.x + 180);
245064
+ } else {
245065
+ transform2.translation.z = boardThickness - minZ + offsetZ;
245066
+ }
245067
+ } else if (!isThroughHoleComponent) {
245068
+ transform2.translation.z = targetZ - center2.z;
245069
+ }
245070
+ }
245071
+ function normalizeDegrees2(value) {
245072
+ const wrapped = value % 360;
245073
+ return wrapped < 0 ? wrapped + 360 : wrapped;
245074
+ }
245075
+ function pruneInvalidEntries(entries) {
245076
+ let remaining = entries.slice();
245077
+ let remainingIds = new Set(remaining.map(([id2]) => id2));
245078
+ let changed = true;
245079
+ while (changed) {
245080
+ changed = false;
245081
+ const toRemove = /* @__PURE__ */ new Set;
245082
+ for (const [entityId, entity] of remaining) {
245083
+ const refs = collectReferencedIds(entity);
245084
+ for (const refId of refs) {
245085
+ if (!remainingIds.has(refId)) {
245086
+ toRemove.add(entityId);
245087
+ break;
245088
+ }
245089
+ }
245090
+ }
245091
+ if (toRemove.size > 0) {
245092
+ changed = true;
245093
+ remaining = remaining.filter(([id2]) => !toRemove.has(id2));
245094
+ remainingIds = new Set(remaining.map(([id2]) => id2));
245095
+ }
245096
+ }
245097
+ return remaining;
245098
+ }
245099
+ function collectReferencedIds(entity) {
245100
+ const result = /* @__PURE__ */ new Set;
245101
+ collectReferencedIdsRecursive(entity, result, /* @__PURE__ */ new Set);
245102
+ return result;
245103
+ }
245104
+ function collectReferencedIdsRecursive(value, result, seen) {
245105
+ if (!value)
245106
+ return;
245107
+ if (value instanceof Ref) {
245108
+ result.add(Number(value.id));
245109
+ return;
245110
+ }
245111
+ if (value instanceof Unknown) {
245112
+ for (const arg of value.args) {
245113
+ arg.replace(/#(\d+)/g, (_4, num) => {
245114
+ result.add(Number(num));
245115
+ return _4;
245116
+ });
245117
+ }
245118
+ return;
245119
+ }
245120
+ if (Array.isArray(value)) {
245121
+ for (const item of value) {
245122
+ collectReferencedIdsRecursive(item, result, seen);
245123
+ }
245124
+ return;
245125
+ }
245126
+ if (typeof value === "object") {
245127
+ if (seen.has(value)) {
245128
+ return;
245129
+ }
245130
+ seen.add(value);
245131
+ for (const entry of Object.values(value)) {
245132
+ collectReferencedIdsRecursive(entry, result, seen);
245133
+ }
245134
+ }
245135
+ }
245136
+ function applyTransform(entries, transform2) {
245137
+ const rotation4 = toRadians(transform2.rotation);
245138
+ for (const [, entity] of entries) {
245139
+ if (entity instanceof CartesianPoint) {
245140
+ const [x3, y4, z21] = transformPoint([entity.x, entity.y, entity.z], rotation4, transform2.translation);
245141
+ entity.x = x3;
245142
+ entity.y = y4;
245143
+ entity.z = z21;
245144
+ } else if (entity instanceof Direction) {
245145
+ const [dx2, dy2, dz] = transformDirection([entity.dx, entity.dy, entity.dz], rotation4);
245146
+ const length2 = Math.hypot(dx2, dy2, dz);
245147
+ if (length2 > 0) {
245148
+ entity.dx = dx2 / length2;
245149
+ entity.dy = dy2 / length2;
245150
+ entity.dz = dz / length2;
245151
+ }
245152
+ }
245153
+ }
245154
+ }
245155
+ function allocateIds(targetRepo, entries) {
245156
+ let nextId = getNextEntityId(targetRepo);
245157
+ const idMapping = /* @__PURE__ */ new Map;
245158
+ for (const [oldId] of entries) {
245159
+ idMapping.set(oldId, nextId);
245160
+ nextId += 1;
245161
+ }
245162
+ return idMapping;
245163
+ }
245164
+ function getNextEntityId(repo) {
245165
+ let maxId = 0;
245166
+ for (const [id2] of repo.entries()) {
245167
+ const numericId = Number(id2);
245168
+ if (numericId > maxId) {
245169
+ maxId = numericId;
245170
+ }
245171
+ }
245172
+ return maxId + 1;
245173
+ }
245174
+ function remapReferences(entries, idMapping) {
245175
+ for (const [, entity] of entries) {
245176
+ remapValue(entity, idMapping, /* @__PURE__ */ new Set);
245177
+ }
245178
+ }
245179
+ function remapValue(value, idMapping, seen) {
245180
+ if (!value)
245181
+ return;
245182
+ if (value instanceof Ref) {
245183
+ const mapped = idMapping.get(Number(value.id));
245184
+ if (mapped !== undefined) {
245185
+ value.id = eid2(mapped);
245186
+ }
245187
+ return;
245188
+ }
245189
+ if (value instanceof Unknown) {
245190
+ value.args = value.args.map((arg) => arg.replace(/#(\d+)/g, (match, num) => {
245191
+ const mapped = idMapping.get(Number(num));
245192
+ return mapped !== undefined ? `#${mapped}` : match;
245193
+ }));
245194
+ return;
245195
+ }
245196
+ if (Array.isArray(value)) {
245197
+ for (const item of value) {
245198
+ remapValue(item, idMapping, seen);
245199
+ }
245200
+ return;
245201
+ }
245202
+ if (typeof value === "object") {
245203
+ if (seen.has(value))
245204
+ return;
245205
+ seen.add(value);
245206
+ for (const key of Object.keys(value)) {
245207
+ remapValue(value[key], idMapping, seen);
245208
+ }
245209
+ }
245210
+ }
245211
+ function normalizeStepNumericExponents(stepText) {
245212
+ return stepText.replace(/(-?(?:\d+\.\d*|\.\d+|\d+))e([+-]?\d+)/g, (_match, mantissa, exponent) => `${mantissa}E${exponent}`);
245213
+ }
245214
+ var package_default4 = {
245215
+ name: "circuit-json-to-step",
245216
+ main: "dist/index.js",
245217
+ version: "0.0.18",
245218
+ type: "module",
245219
+ scripts: {
245220
+ "pull-reference": `git clone https://github.com/tscircuit/circuit-json.git && find circuit-json/tests -name '*.test.ts' -exec bash -c 'mv "$0" "\${0%.test.ts}.ts"' {} \\; && git clone https://github.com/tscircuit/stepts.git && find stepts/tests -name '*.test.ts' -exec bash -c 'mv "$0" "\${0%.test.ts}.ts"' {} \\;`,
245221
+ test: "bun test",
245222
+ "test:update-snapshots": "BUN_UPDATE_SNAPSHOTS=1 bun test",
245223
+ build: "tsup-node ./lib/index.ts --format esm --dts",
245224
+ format: "biome format --write .",
245225
+ "format:check": "biome format .",
245226
+ start: "bun site/index.html",
245227
+ "build:site": "bun build site/index.html --outdir=site-export"
245228
+ },
245229
+ devDependencies: {
245230
+ "@biomejs/biome": "^2.3.8",
245231
+ "@resvg/resvg-js": "^2.6.2",
245232
+ "@resvg/resvg-wasm": "^2.6.2",
245233
+ "@tscircuit/circuit-json-util": "^0.0.75",
245234
+ "@types/bun": "latest",
245235
+ "circuit-json": "^0.0.286",
245236
+ "looks-same": "^10.0.1",
245237
+ "occt-import-js": "^0.0.23",
245238
+ poppygl: "^0.0.17",
245239
+ stepts: "^0.0.3",
245240
+ tsup: "^8.5.0"
245241
+ },
245242
+ peerDependencies: {
245243
+ "@tscircuit/circuit-json-util": "*",
245244
+ typescript: "^5"
245245
+ },
245246
+ dependencies: {
245247
+ "circuit-json-to-connectivity-map": "^0.0.22",
245248
+ "circuit-json-to-gltf": "^0.0.87",
245249
+ "circuit-to-svg": "^0.0.327",
245250
+ "schematic-symbols": "^0.0.202"
245251
+ }
245252
+ };
245253
+ var VERSION = package_default4.version;
245254
+ function getPillGeometry(hole) {
245255
+ const centerX = typeof hole.x === "number" ? hole.x : hole.x.value;
245256
+ const centerY = typeof hole.y === "number" ? hole.y : hole.y.value;
245257
+ const width = hole.hole_width;
245258
+ const height = hole.hole_height;
245259
+ const ccwRotation = hole.ccw_rotation ?? 0;
245260
+ const rotation4 = ccwRotation * Math.PI / 180;
245261
+ const isHorizontal2 = width >= height;
245262
+ const radius = Math.min(width, height) / 2;
245263
+ const straightHalfLength = Math.abs(width - height) / 2;
245264
+ return {
245265
+ centerX,
245266
+ centerY,
245267
+ width,
245268
+ height,
245269
+ rotation: rotation4,
245270
+ radius,
245271
+ straightHalfLength,
245272
+ isHorizontal: isHorizontal2
245273
+ };
245274
+ }
245275
+ function rotatePoint3(x3, y4, centerX, centerY, angle) {
245276
+ const cos2 = Math.cos(angle);
245277
+ const sin2 = Math.sin(angle);
245278
+ const dx2 = x3 - centerX;
245279
+ const dy2 = y4 - centerY;
245280
+ return {
245281
+ x: centerX + dx2 * cos2 - dy2 * sin2,
245282
+ y: centerY + dx2 * sin2 + dy2 * cos2
245283
+ };
245284
+ }
245285
+ function createLineEdge(repo, v12, v23) {
245286
+ const p12 = v12.resolve(repo).pnt.resolve(repo);
245287
+ const p23 = v23.resolve(repo).pnt.resolve(repo);
245288
+ const dx2 = p23.x - p12.x;
245289
+ const dy2 = p23.y - p12.y;
245290
+ const dz = p23.z - p12.z;
245291
+ const length2 = Math.sqrt(dx2 * dx2 + dy2 * dy2 + dz * dz);
245292
+ if (length2 < 0.0000000001) {
245293
+ const dir2 = repo.add(new Direction("", 1, 0, 0));
245294
+ const vec2 = repo.add(new Vector3("", dir2, 0.0000000001));
245295
+ const line22 = repo.add(new Line3("", v12.resolve(repo).pnt, vec2));
245296
+ return repo.add(new EdgeCurve("", v12, v23, line22, true));
245297
+ }
245298
+ const dir = repo.add(new Direction("", dx2 / length2, dy2 / length2, dz / length2));
245299
+ const vec = repo.add(new Vector3("", dir, length2));
245300
+ const line2 = repo.add(new Line3("", v12.resolve(repo).pnt, vec));
245301
+ return repo.add(new EdgeCurve("", v12, v23, line2, true));
245302
+ }
245303
+ function createArcEdge(repo, centerX, centerY, z21, radius, startAngle, endAngle, rotation4, centerX0, centerY0) {
245304
+ const startX = centerX + radius * Math.cos(startAngle);
245305
+ const startY = centerY + radius * Math.sin(startAngle);
245306
+ const endX = centerX + radius * Math.cos(endAngle);
245307
+ const endY = centerY + radius * Math.sin(endAngle);
245308
+ const startRotated = rotatePoint3(startX, startY, centerX0, centerY0, rotation4);
245309
+ const endRotated = rotatePoint3(endX, endY, centerX0, centerY0, rotation4);
245310
+ const startVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", startRotated.x, startRotated.y, z21))));
245311
+ const endVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", endRotated.x, endRotated.y, z21))));
245312
+ const centerRotated = rotatePoint3(centerX, centerY, centerX0, centerY0, rotation4);
245313
+ const centerPoint = repo.add(new CartesianPoint("", centerRotated.x, centerRotated.y, z21));
245314
+ const normalDir = repo.add(new Direction("", 0, 0, -1));
245315
+ const refAngle = rotation4;
245316
+ const refDir = repo.add(new Direction("", Math.cos(refAngle), Math.sin(refAngle), 0));
245317
+ const placement = repo.add(new Axis2Placement3D("", centerPoint, normalDir, refDir));
245318
+ const circle2 = repo.add(new Circle3("", placement, radius));
245319
+ return repo.add(new EdgeCurve("", startVertex, endVertex, circle2, false));
245320
+ }
245321
+ function createPillHoleLoop(repo, hole, z21, xDir) {
245322
+ const geom = getPillGeometry(hole);
245323
+ const {
245324
+ centerX,
245325
+ centerY,
245326
+ radius,
245327
+ straightHalfLength,
245328
+ rotation: rotation4,
245329
+ isHorizontal: isHorizontal2
245330
+ } = geom;
245331
+ const edges = [];
245332
+ if (isHorizontal2) {
245333
+ const capOffset = straightHalfLength;
245334
+ const rightArc = createArcEdge(repo, centerX + capOffset, centerY, z21, radius, -Math.PI / 2, Math.PI / 2, rotation4, centerX, centerY);
245335
+ edges.push(rightArc);
245336
+ const bottomStart = rotatePoint3(centerX + capOffset, centerY - radius, centerX, centerY, rotation4);
245337
+ const bottomEnd = rotatePoint3(centerX - capOffset, centerY - radius, centerX, centerY, rotation4);
245338
+ const bottomV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, z21))));
245339
+ const bottomV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, z21))));
245340
+ edges.push(createLineEdge(repo, bottomV1, bottomV2));
245341
+ const leftArc = createArcEdge(repo, centerX - capOffset, centerY, z21, radius, Math.PI / 2, 3 * Math.PI / 2, rotation4, centerX, centerY);
245342
+ edges.push(leftArc);
245343
+ const topStart = rotatePoint3(centerX - capOffset, centerY + radius, centerX, centerY, rotation4);
245344
+ const topEnd = rotatePoint3(centerX + capOffset, centerY + radius, centerX, centerY, rotation4);
245345
+ const topV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", topStart.x, topStart.y, z21))));
245346
+ const topV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", topEnd.x, topEnd.y, z21))));
245347
+ edges.push(createLineEdge(repo, topV1, topV2));
245348
+ } else {
245349
+ const capOffset = straightHalfLength;
245350
+ const topArc = createArcEdge(repo, centerX, centerY - capOffset, z21, radius, Math.PI, 0, rotation4, centerX, centerY);
245351
+ edges.push(topArc);
245352
+ const rightStart = rotatePoint3(centerX + radius, centerY - capOffset, centerX, centerY, rotation4);
245353
+ const rightEnd = rotatePoint3(centerX + radius, centerY + capOffset, centerX, centerY, rotation4);
245354
+ const rightV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", rightStart.x, rightStart.y, z21))));
245355
+ const rightV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", rightEnd.x, rightEnd.y, z21))));
245356
+ edges.push(createLineEdge(repo, rightV1, rightV2));
245357
+ const bottomArc = createArcEdge(repo, centerX, centerY + capOffset, z21, radius, 0, Math.PI, rotation4, centerX, centerY);
245358
+ edges.push(bottomArc);
245359
+ const leftStart = rotatePoint3(centerX - radius, centerY + capOffset, centerX, centerY, rotation4);
245360
+ const leftEnd = rotatePoint3(centerX - radius, centerY - capOffset, centerX, centerY, rotation4);
245361
+ const leftV1 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", leftStart.x, leftStart.y, z21))));
245362
+ const leftV2 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", leftEnd.x, leftEnd.y, z21))));
245363
+ edges.push(createLineEdge(repo, leftV1, leftV2));
245364
+ }
245365
+ const orientedEdges = edges.map((edge) => repo.add(new OrientedEdge("", edge, true)));
245366
+ return repo.add(new EdgeLoop("", orientedEdges));
245367
+ }
245368
+ function createPillCylindricalFaces(repo, hole, boardThickness, xDir, zDir) {
245369
+ const geom = getPillGeometry(hole);
245370
+ const {
245371
+ centerX,
245372
+ centerY,
245373
+ radius,
245374
+ straightHalfLength,
245375
+ rotation: rotation4,
245376
+ isHorizontal: isHorizontal2
245377
+ } = geom;
245378
+ const faces = [];
245379
+ if (isHorizontal2) {
245380
+ const capOffset = straightHalfLength;
245381
+ faces.push(createCylindricalWall(repo, centerX + capOffset, centerY, radius, -Math.PI / 2, Math.PI / 2, rotation4, centerX, centerY, boardThickness, zDir, xDir));
245382
+ faces.push(createPlanarWall(repo, centerX - capOffset, centerY - radius, centerX + capOffset, centerY - radius, rotation4, centerX, centerY, boardThickness, zDir));
245383
+ faces.push(createCylindricalWall(repo, centerX - capOffset, centerY, radius, Math.PI / 2, 3 * Math.PI / 2, rotation4, centerX, centerY, boardThickness, zDir, xDir));
245384
+ faces.push(createPlanarWall(repo, centerX + capOffset, centerY + radius, centerX - capOffset, centerY + radius, rotation4, centerX, centerY, boardThickness, zDir));
245385
+ } else {
245386
+ const capOffset = straightHalfLength;
245387
+ faces.push(createCylindricalWall(repo, centerX, centerY - capOffset, radius, Math.PI, 0, rotation4, centerX, centerY, boardThickness, zDir, xDir));
245388
+ faces.push(createPlanarWall(repo, centerX + radius, centerY - capOffset, centerX + radius, centerY + capOffset, rotation4, centerX, centerY, boardThickness, zDir));
245389
+ faces.push(createCylindricalWall(repo, centerX, centerY + capOffset, radius, 0, Math.PI, rotation4, centerX, centerY, boardThickness, zDir, xDir));
245390
+ faces.push(createPlanarWall(repo, centerX - radius, centerY + capOffset, centerX - radius, centerY - capOffset, rotation4, centerX, centerY, boardThickness, zDir));
245391
+ }
245392
+ return faces;
245393
+ }
245394
+ function createCylindricalWall(repo, centerX, centerY, radius, startAngle, endAngle, rotation4, centerX0, centerY0, boardThickness, zDir, xDir) {
245395
+ const bottomStartX = centerX + radius * Math.cos(startAngle);
245396
+ const bottomStartY = centerY + radius * Math.sin(startAngle);
245397
+ const bottomEndX = centerX + radius * Math.cos(endAngle);
245398
+ const bottomEndY = centerY + radius * Math.sin(endAngle);
245399
+ const bottomStart = rotatePoint3(bottomStartX, bottomStartY, centerX0, centerY0, rotation4);
245400
+ const bottomEnd = rotatePoint3(bottomEndX, bottomEndY, centerX0, centerY0, rotation4);
245401
+ const bottomStartVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, 0))));
245402
+ const bottomEndVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, 0))));
245403
+ const topStart = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, boardThickness))));
245404
+ const topEnd = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, boardThickness))));
245405
+ const centerRotated = rotatePoint3(centerX, centerY, centerX0, centerY0, rotation4);
245406
+ const bottomCenter = repo.add(new CartesianPoint("", centerRotated.x, centerRotated.y, 0));
245407
+ const bottomPlacement = repo.add(new Axis2Placement3D("", bottomCenter, repo.add(new Direction("", 0, 0, -1)), xDir));
245408
+ const bottomCircle = repo.add(new Circle3("", bottomPlacement, radius));
245409
+ const bottomArc = repo.add(new EdgeCurve("", bottomStartVertex, bottomEndVertex, bottomCircle, false));
245410
+ const topCenter = repo.add(new CartesianPoint("", centerRotated.x, centerRotated.y, boardThickness));
245411
+ const topPlacement = repo.add(new Axis2Placement3D("", topCenter, zDir, xDir));
245412
+ const topCircle = repo.add(new Circle3("", topPlacement, radius));
245413
+ const topArc = repo.add(new EdgeCurve("", topEnd, topStart, topCircle, false));
245414
+ const v12 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, 0))));
245415
+ const v23 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomStart.x, bottomStart.y, boardThickness))));
245416
+ const v3 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, 0))));
245417
+ const v4 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", bottomEnd.x, bottomEnd.y, boardThickness))));
245418
+ const dir1 = repo.add(new Direction("", 0, 0, 1));
245419
+ const vec1 = repo.add(new Vector3("", dir1, boardThickness));
245420
+ const line1 = repo.add(new Line3("", v12.resolve(repo).pnt, vec1));
245421
+ const edge1 = repo.add(new EdgeCurve("", v12, v23, line1, true));
245422
+ const dir2 = repo.add(new Direction("", 0, 0, 1));
245423
+ const vec2 = repo.add(new Vector3("", dir2, boardThickness));
245424
+ const line2 = repo.add(new Line3("", v3.resolve(repo).pnt, vec2));
245425
+ const edge2 = repo.add(new EdgeCurve("", v3, v4, line2, true));
245426
+ const loop = repo.add(new EdgeLoop("", [
245427
+ repo.add(new OrientedEdge("", bottomArc, true)),
245428
+ repo.add(new OrientedEdge("", edge2, true)),
245429
+ repo.add(new OrientedEdge("", topArc, false)),
245430
+ repo.add(new OrientedEdge("", edge1, false))
245431
+ ]));
245432
+ const cylinderPlacement = repo.add(new Axis2Placement3D("", bottomCenter, zDir, xDir));
245433
+ const cylinderSurface = repo.add(new CylindricalSurface("", cylinderPlacement, radius));
245434
+ return repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", loop, true))], cylinderSurface, false));
245435
+ }
245436
+ function createPlanarWall(repo, startX, startY, endX, endY, rotation4, centerX0, centerY0, boardThickness, zDir) {
245437
+ const start = rotatePoint3(startX, startY, centerX0, centerY0, rotation4);
245438
+ const end = rotatePoint3(endX, endY, centerX0, centerY0, rotation4);
245439
+ const v12 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", start.x, start.y, 0))));
245440
+ const v23 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", end.x, end.y, 0))));
245441
+ const v3 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", end.x, end.y, boardThickness))));
245442
+ const v4 = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", start.x, start.y, boardThickness))));
245443
+ const dx2 = end.x - start.x;
245444
+ const dy2 = end.y - start.y;
245445
+ const edgeLength = Math.sqrt(dx2 * dx2 + dy2 * dy2);
245446
+ const bottomDir = repo.add(new Direction("", dx2 / edgeLength, dy2 / edgeLength, 0));
245447
+ const bottomVec = repo.add(new Vector3("", bottomDir, edgeLength));
245448
+ const bottomLine = repo.add(new Line3("", v12.resolve(repo).pnt, bottomVec));
245449
+ const bottomEdge = repo.add(new EdgeCurve("", v12, v23, bottomLine, true));
245450
+ const topDir = repo.add(new Direction("", dx2 / edgeLength, dy2 / edgeLength, 0));
245451
+ const topVec = repo.add(new Vector3("", topDir, edgeLength));
245452
+ const topLine = repo.add(new Line3("", v4.resolve(repo).pnt, topVec));
245453
+ const topEdge = repo.add(new EdgeCurve("", v4, v3, topLine, true));
245454
+ const vertDir = repo.add(new Direction("", 0, 0, 1));
245455
+ const vertVec1 = repo.add(new Vector3("", vertDir, boardThickness));
245456
+ const vertLine1 = repo.add(new Line3("", v23.resolve(repo).pnt, vertVec1));
245457
+ const vertEdge1 = repo.add(new EdgeCurve("", v23, v3, vertLine1, true));
245458
+ const vertVec2 = repo.add(new Vector3("", vertDir, boardThickness));
245459
+ const vertLine2 = repo.add(new Line3("", v12.resolve(repo).pnt, vertVec2));
245460
+ const vertEdge2 = repo.add(new EdgeCurve("", v12, v4, vertLine2, true));
245461
+ const loop = repo.add(new EdgeLoop("", [
245462
+ repo.add(new OrientedEdge("", bottomEdge, true)),
245463
+ repo.add(new OrientedEdge("", vertEdge1, true)),
245464
+ repo.add(new OrientedEdge("", topEdge, false)),
245465
+ repo.add(new OrientedEdge("", vertEdge2, false))
245466
+ ]));
245467
+ const normalDir = repo.add(new Direction("", dy2 / edgeLength, -dx2 / edgeLength, 0));
245468
+ const refDir = repo.add(new Direction("", dx2 / edgeLength, dy2 / edgeLength, 0));
245469
+ const planeOrigin = repo.add(new CartesianPoint("", start.x, start.y, 0));
245470
+ const placement = repo.add(new Axis2Placement3D("", planeOrigin, normalDir, refDir));
245471
+ const plane = repo.add(new Plane("", placement));
245472
+ return repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", loop, true))], plane, true));
245473
+ }
245474
+ async function circuitJsonToStep(circuitJson, options = {}) {
245475
+ const repo = new Repository;
245476
+ const pcbBoard = circuitJson.find((item) => item.type === "pcb_board");
245477
+ const holes = circuitJson.filter((item) => item.type === "pcb_hole" || item.type === "pcb_plated_hole");
245478
+ const boardWidth = options.boardWidth ?? pcbBoard?.width;
245479
+ const boardHeight = options.boardHeight ?? pcbBoard?.height;
245480
+ const boardThickness = options.boardThickness ?? pcbBoard?.thickness ?? 1.6;
245481
+ const productName = options.productName ?? "PCB";
245482
+ const boardCenterX = pcbBoard?.center?.x ?? 0;
245483
+ const boardCenterY = pcbBoard?.center?.y ?? 0;
245484
+ if (!boardWidth || !boardHeight) {
245485
+ throw new Error("Board dimensions not found. Either provide boardWidth and boardHeight in options, or include a pcb_board in the circuit JSON with width and height properties.");
245486
+ }
245487
+ const appContext = repo.add(new ApplicationContext("core data for automotive mechanical design processes"));
245488
+ repo.add(new ApplicationProtocolDefinition("international standard", "automotive_design", 2010, appContext));
245489
+ const productContext = repo.add(new ProductContext("", appContext, "mechanical"));
245490
+ const productDescription = `Generated by circuit-json-to-step v${VERSION}`;
245491
+ const product = repo.add(new Product(productName, productName, productDescription, [productContext]));
245492
+ const productDefContext = repo.add(new ProductDefinitionContext("part definition", appContext, "design"));
245493
+ const productDefFormation = repo.add(new ProductDefinitionFormation("", "", product));
245494
+ const productDef = repo.add(new ProductDefinition("", "", productDefFormation, productDefContext));
245495
+ const productDefShape = repo.add(new ProductDefinitionShape("", "", productDef));
245496
+ const lengthUnit = repo.add(new Unknown("", [
245497
+ "( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) )"
245498
+ ]));
245499
+ const angleUnit = repo.add(new Unknown("", [
245500
+ "( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) )"
245501
+ ]));
245502
+ const solidAngleUnit = repo.add(new Unknown("", [
245503
+ "( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() )"
245504
+ ]));
245505
+ const uncertainty = repo.add(new Unknown("UNCERTAINTY_MEASURE_WITH_UNIT", [
245506
+ `LENGTH_MEASURE(1.E-07)`,
245507
+ `${lengthUnit}`,
245508
+ `'distance_accuracy_value'`,
245509
+ `'Maximum Tolerance'`
245510
+ ]));
245511
+ const geomContext = repo.add(new Unknown("", [
245512
+ `( GEOMETRIC_REPRESENTATION_CONTEXT(3) GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((${uncertainty})) GLOBAL_UNIT_ASSIGNED_CONTEXT((${lengthUnit},${angleUnit},${solidAngleUnit})) REPRESENTATION_CONTEXT('${productName}','3D') )`
245513
+ ]));
245514
+ const outline = pcbBoard?.outline;
245515
+ let bottomVertices;
245516
+ let topVertices;
245517
+ if (outline && Array.isArray(outline) && outline.length >= 3) {
245518
+ const cleanedOutline = [];
245519
+ for (let i2 = 0;i2 < outline.length; i2++) {
245520
+ const current2 = outline[i2];
245521
+ const next = outline[(i2 + 1) % outline.length];
245522
+ const dx2 = next.x - current2.x;
245523
+ const dy2 = next.y - current2.y;
245524
+ const dist = Math.sqrt(dx2 * dx2 + dy2 * dy2);
245525
+ if (dist > 0.000001) {
245526
+ cleanedOutline.push(current2);
245527
+ }
245528
+ }
245529
+ if (cleanedOutline.length < 3) {
245530
+ throw new Error(`Outline has too few unique vertices after removing duplicates (${cleanedOutline.length}). Need at least 3.`);
245531
+ }
245532
+ bottomVertices = cleanedOutline.map((point5) => repo.add(new VertexPoint("", repo.add(new CartesianPoint("", point5.x, point5.y, 0)))));
245533
+ topVertices = cleanedOutline.map((point5) => repo.add(new VertexPoint("", repo.add(new CartesianPoint("", point5.x, point5.y, boardThickness)))));
245534
+ } else {
245535
+ const halfWidth = boardWidth / 2;
245536
+ const halfHeight = boardHeight / 2;
245537
+ const corners = [
245538
+ [boardCenterX - halfWidth, boardCenterY - halfHeight, 0],
245539
+ [boardCenterX + halfWidth, boardCenterY - halfHeight, 0],
245540
+ [boardCenterX + halfWidth, boardCenterY + halfHeight, 0],
245541
+ [boardCenterX - halfWidth, boardCenterY + halfHeight, 0],
245542
+ [boardCenterX - halfWidth, boardCenterY - halfHeight, boardThickness],
245543
+ [boardCenterX + halfWidth, boardCenterY - halfHeight, boardThickness],
245544
+ [boardCenterX + halfWidth, boardCenterY + halfHeight, boardThickness],
245545
+ [boardCenterX - halfWidth, boardCenterY + halfHeight, boardThickness]
245546
+ ];
245547
+ const vertices = corners.map(([x3, y4, z21]) => repo.add(new VertexPoint("", repo.add(new CartesianPoint("", x3, y4, z21)))));
245548
+ bottomVertices = [vertices[0], vertices[1], vertices[2], vertices[3]];
245549
+ topVertices = [vertices[4], vertices[5], vertices[6], vertices[7]];
245550
+ }
245551
+ function createEdge(v12, v23) {
245552
+ const p12 = v12.resolve(repo).pnt.resolve(repo);
245553
+ const p23 = v23.resolve(repo).pnt.resolve(repo);
245554
+ const dx2 = p23.x - p12.x;
245555
+ const dy2 = p23.y - p12.y;
245556
+ const dz = p23.z - p12.z;
245557
+ const length2 = Math.sqrt(dx2 * dx2 + dy2 * dy2 + dz * dz);
245558
+ if (length2 < 0.0000000001) {
245559
+ const dir2 = repo.add(new Direction("", 1, 0, 0));
245560
+ const vec2 = repo.add(new Vector3("", dir2, 0.0000000001));
245561
+ const line22 = repo.add(new Line3("", v12.resolve(repo).pnt, vec2));
245562
+ return repo.add(new EdgeCurve("", v12, v23, line22, true));
245563
+ }
245564
+ const dir = repo.add(new Direction("", dx2 / length2, dy2 / length2, dz / length2));
245565
+ const vec = repo.add(new Vector3("", dir, length2));
245566
+ const line2 = repo.add(new Line3("", v12.resolve(repo).pnt, vec));
245567
+ return repo.add(new EdgeCurve("", v12, v23, line2, true));
245568
+ }
245569
+ const bottomEdges = [];
245570
+ const topEdges = [];
245571
+ const verticalEdges = [];
245572
+ for (let i2 = 0;i2 < bottomVertices.length; i2++) {
245573
+ const v12 = bottomVertices[i2];
245574
+ const v23 = bottomVertices[(i2 + 1) % bottomVertices.length];
245575
+ bottomEdges.push(createEdge(v12, v23));
245576
+ }
245577
+ for (let i2 = 0;i2 < topVertices.length; i2++) {
245578
+ const v12 = topVertices[i2];
245579
+ const v23 = topVertices[(i2 + 1) % topVertices.length];
245580
+ topEdges.push(createEdge(v12, v23));
245581
+ }
245582
+ for (let i2 = 0;i2 < bottomVertices.length; i2++) {
245583
+ verticalEdges.push(createEdge(bottomVertices[i2], topVertices[i2]));
245584
+ }
245585
+ const origin = repo.add(new CartesianPoint("", 0, 0, 0));
245586
+ const xDir = repo.add(new Direction("", 1, 0, 0));
245587
+ const zDir = repo.add(new Direction("", 0, 0, 1));
245588
+ const bottomFrame = repo.add(new Axis2Placement3D("", origin, repo.add(new Direction("", 0, 0, -1)), xDir));
245589
+ const bottomPlane = repo.add(new Plane("", bottomFrame));
245590
+ const bottomLoop = repo.add(new EdgeLoop("", bottomEdges.map((edge) => repo.add(new OrientedEdge("", edge, true)))));
245591
+ const bottomHoleLoops = [];
245592
+ for (const hole of holes) {
245593
+ const holeShape = hole.hole_shape || hole.shape;
245594
+ if (holeShape === "circle") {
245595
+ const holeX = typeof hole.x === "number" ? hole.x : hole.x.value;
245596
+ const holeY = typeof hole.y === "number" ? hole.y : hole.y.value;
245597
+ const radius = hole.hole_diameter / 2;
245598
+ const holeCenter = repo.add(new CartesianPoint("", holeX, holeY, 0));
245599
+ const holeVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, 0))));
245600
+ const holePlacement = repo.add(new Axis2Placement3D("", holeCenter, repo.add(new Direction("", 0, 0, -1)), xDir));
245601
+ const holeCircle = repo.add(new Circle3("", holePlacement, radius));
245602
+ const holeEdge = repo.add(new EdgeCurve("", holeVertex, holeVertex, holeCircle, true));
245603
+ const holeLoop = repo.add(new EdgeLoop("", [repo.add(new OrientedEdge("", holeEdge, false))]));
245604
+ bottomHoleLoops.push(repo.add(new FaceBound("", holeLoop, true)));
245605
+ } else if (holeShape === "rotated_pill" || holeShape === "pill") {
245606
+ const pillLoop = createPillHoleLoop(repo, hole, 0, xDir);
245607
+ bottomHoleLoops.push(repo.add(new FaceBound("", pillLoop, true)));
245608
+ }
245609
+ }
245610
+ const bottomFace = repo.add(new AdvancedFace("", [
245611
+ repo.add(new FaceOuterBound("", bottomLoop, true)),
245612
+ ...bottomHoleLoops
245613
+ ], bottomPlane, true));
245614
+ const topOrigin = repo.add(new CartesianPoint("", 0, 0, boardThickness));
245615
+ const topFrame = repo.add(new Axis2Placement3D("", topOrigin, zDir, xDir));
245616
+ const topPlane = repo.add(new Plane("", topFrame));
245617
+ const topLoop = repo.add(new EdgeLoop("", topEdges.map((edge) => repo.add(new OrientedEdge("", edge, false)))));
245618
+ const topHoleLoops = [];
245619
+ for (const hole of holes) {
245620
+ const holeShape = hole.hole_shape || hole.shape;
245621
+ if (holeShape === "circle") {
245622
+ const holeX = typeof hole.x === "number" ? hole.x : hole.x.value;
245623
+ const holeY = typeof hole.y === "number" ? hole.y : hole.y.value;
245624
+ const radius = hole.hole_diameter / 2;
245625
+ const holeCenter = repo.add(new CartesianPoint("", holeX, holeY, boardThickness));
245626
+ const holeVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, boardThickness))));
245627
+ const holePlacement = repo.add(new Axis2Placement3D("", holeCenter, zDir, xDir));
245628
+ const holeCircle = repo.add(new Circle3("", holePlacement, radius));
245629
+ const holeEdge = repo.add(new EdgeCurve("", holeVertex, holeVertex, holeCircle, true));
245630
+ const holeLoop = repo.add(new EdgeLoop("", [repo.add(new OrientedEdge("", holeEdge, true))]));
245631
+ topHoleLoops.push(repo.add(new FaceBound("", holeLoop, true)));
245632
+ } else if (holeShape === "rotated_pill" || holeShape === "pill") {
245633
+ const pillLoop = createPillHoleLoop(repo, hole, boardThickness, xDir);
245634
+ topHoleLoops.push(repo.add(new FaceBound("", pillLoop, true)));
245635
+ }
245636
+ }
245637
+ const topFace = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", topLoop, true)), ...topHoleLoops], topPlane, true));
245638
+ const sideFaces = [];
245639
+ for (let i2 = 0;i2 < bottomEdges.length; i2++) {
245640
+ const nextI = (i2 + 1) % bottomEdges.length;
245641
+ const bottomV1Pnt = bottomVertices[i2].resolve(repo).pnt;
245642
+ const bottomV2Pnt = bottomVertices[nextI].resolve(repo).pnt;
245643
+ const bottomV1 = bottomV1Pnt.resolve(repo);
245644
+ const bottomV2 = bottomV2Pnt.resolve(repo);
245645
+ const edgeDir = {
245646
+ x: bottomV2.x - bottomV1.x,
245647
+ y: bottomV2.y - bottomV1.y,
245648
+ z: 0
245649
+ };
245650
+ const normalDir = repo.add(new Direction("", edgeDir.y, -edgeDir.x, 0));
245651
+ const refDir = repo.add(new Direction("", edgeDir.x, edgeDir.y, 0));
245652
+ const sideFrame = repo.add(new Axis2Placement3D("", bottomV1Pnt, normalDir, refDir));
245653
+ const sidePlane = repo.add(new Plane("", sideFrame));
245654
+ const sideLoop = repo.add(new EdgeLoop("", [
245655
+ repo.add(new OrientedEdge("", bottomEdges[i2], true)),
245656
+ repo.add(new OrientedEdge("", verticalEdges[nextI], true)),
245657
+ repo.add(new OrientedEdge("", topEdges[i2], false)),
245658
+ repo.add(new OrientedEdge("", verticalEdges[i2], false))
245659
+ ]));
245660
+ const sideFace = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", sideLoop, true))], sidePlane, true));
245661
+ sideFaces.push(sideFace);
245662
+ }
245663
+ const holeCylindricalFaces = [];
245664
+ for (const hole of holes) {
245665
+ const holeShape = hole.hole_shape || hole.shape;
245666
+ if (holeShape === "circle") {
245667
+ const holeX = typeof hole.x === "number" ? hole.x : hole.x.value;
245668
+ const holeY = typeof hole.y === "number" ? hole.y : hole.y.value;
245669
+ const radius = hole.hole_diameter / 2;
245670
+ const bottomHoleCenter = repo.add(new CartesianPoint("", holeX, holeY, 0));
245671
+ const bottomHoleVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, 0))));
245672
+ const bottomHolePlacement = repo.add(new Axis2Placement3D("", bottomHoleCenter, repo.add(new Direction("", 0, 0, -1)), xDir));
245673
+ const bottomHoleCircle = repo.add(new Circle3("", bottomHolePlacement, radius));
245674
+ const bottomHoleEdge = repo.add(new EdgeCurve("", bottomHoleVertex, bottomHoleVertex, bottomHoleCircle, true));
245675
+ const topHoleCenter = repo.add(new CartesianPoint("", holeX, holeY, boardThickness));
245676
+ const topHoleVertex = repo.add(new VertexPoint("", repo.add(new CartesianPoint("", holeX + radius, holeY, boardThickness))));
245677
+ const topHolePlacement = repo.add(new Axis2Placement3D("", topHoleCenter, zDir, xDir));
245678
+ const topHoleCircle = repo.add(new Circle3("", topHolePlacement, radius));
245679
+ const topHoleEdge = repo.add(new EdgeCurve("", topHoleVertex, topHoleVertex, topHoleCircle, true));
245680
+ const holeCylinderLoop = repo.add(new EdgeLoop("", [
245681
+ repo.add(new OrientedEdge("", bottomHoleEdge, true)),
245682
+ repo.add(new OrientedEdge("", topHoleEdge, false))
245683
+ ]));
245684
+ const holeCylinderPlacement = repo.add(new Axis2Placement3D("", bottomHoleCenter, zDir, xDir));
245685
+ const holeCylinderSurface = repo.add(new CylindricalSurface("", holeCylinderPlacement, radius));
245686
+ const holeCylinderFace = repo.add(new AdvancedFace("", [repo.add(new FaceOuterBound("", holeCylinderLoop, true))], holeCylinderSurface, false));
245687
+ holeCylindricalFaces.push(holeCylinderFace);
245688
+ } else if (holeShape === "rotated_pill" || holeShape === "pill") {
245689
+ const pillFaces = createPillCylindricalFaces(repo, hole, boardThickness, xDir, zDir);
245690
+ holeCylindricalFaces.push(...pillFaces);
245691
+ }
245692
+ }
245693
+ const allFaces = [bottomFace, topFace, ...sideFaces, ...holeCylindricalFaces];
245694
+ const shell = repo.add(new ClosedShell("", allFaces));
245695
+ const solid = repo.add(new ManifoldSolidBrep(productName, shell));
245696
+ const allSolids = [solid];
245697
+ let handledComponentIds = /* @__PURE__ */ new Set;
245698
+ let handledPcbComponentIds = /* @__PURE__ */ new Set;
245699
+ if (options.includeComponents && options.includeExternalMeshes) {
245700
+ const mergeResult = await mergeExternalStepModels({
245701
+ repo,
245702
+ circuitJson,
245703
+ boardThickness,
245704
+ fsMap: options.fsMap
245705
+ });
245706
+ handledComponentIds = mergeResult.handledComponentIds;
245707
+ handledPcbComponentIds = mergeResult.handledPcbComponentIds;
245708
+ allSolids.push(...mergeResult.solids);
245709
+ }
245710
+ if (options.includeComponents) {
245711
+ const pcbComponentIdsWithStepUrl = /* @__PURE__ */ new Set;
245712
+ for (const item of circuitJson) {
245713
+ if (item.type === "cad_component" && item.model_step_url && item.pcb_component_id) {
245714
+ pcbComponentIdsWithStepUrl.add(item.pcb_component_id);
245715
+ }
245716
+ }
245717
+ const hasComponentsNeedingMesh = circuitJson.some((item) => {
245718
+ if (item.type === "cad_component") {
245719
+ if (item.cad_component_id && handledComponentIds.has(item.cad_component_id)) {
245720
+ return false;
245721
+ }
245722
+ if (item.pcb_component_id && pcbComponentIdsWithStepUrl.has(item.pcb_component_id)) {
245723
+ return false;
245724
+ }
245725
+ return !item.model_step_url;
245726
+ }
245727
+ if (item.type === "pcb_component") {
245728
+ if (item.pcb_component_id && handledPcbComponentIds.has(item.pcb_component_id)) {
245729
+ return false;
245730
+ }
245731
+ if (item.pcb_component_id && pcbComponentIdsWithStepUrl.has(item.pcb_component_id)) {
245732
+ return false;
245733
+ }
245734
+ return true;
245735
+ }
245736
+ return false;
245737
+ });
245738
+ if (hasComponentsNeedingMesh) {
245739
+ const componentSolids = await generateComponentMeshes({
245740
+ repo,
245741
+ circuitJson,
245742
+ boardThickness,
245743
+ includeExternalMeshes: options.includeExternalMeshes,
245744
+ excludeCadComponentIds: handledComponentIds,
245745
+ excludePcbComponentIds: handledPcbComponentIds,
245746
+ pcbComponentIdsWithStepUrl
245747
+ });
245748
+ allSolids.push(...componentSolids);
245749
+ }
245750
+ }
245751
+ const styledItems = [];
245752
+ allSolids.forEach((solidRef, index) => {
245753
+ const isBoard = index === 0;
245754
+ const [r4, g6, b] = isBoard ? [0.2, 0.6, 0.2] : [0.75, 0.75, 0.75];
245755
+ const color = repo.add(new ColourRgb("", r4, g6, b));
245756
+ const fillColor = repo.add(new FillAreaStyleColour("", color));
245757
+ const fillStyle = repo.add(new FillAreaStyle("", [fillColor]));
245758
+ const surfaceFill = repo.add(new SurfaceStyleFillArea(fillStyle));
245759
+ const surfaceSide = repo.add(new SurfaceSideStyle("", [surfaceFill]));
245760
+ const surfaceUsage = repo.add(new SurfaceStyleUsage(".BOTH.", surfaceSide));
245761
+ const presStyle = repo.add(new PresentationStyleAssignment([surfaceUsage]));
245762
+ const styledItem = repo.add(new StyledItem("", [presStyle], solidRef));
245763
+ styledItems.push(styledItem);
245764
+ });
245765
+ repo.add(new MechanicalDesignGeometricPresentationRepresentation("", styledItems, geomContext));
245766
+ const shapeRep = repo.add(new AdvancedBrepShapeRepresentation(productName, allSolids, geomContext));
245767
+ repo.add(new ShapeDefinitionRepresentation(productDefShape, shapeRep));
245768
+ const stepText = repo.toPartFile({ name: productName });
245769
+ return normalizeStepNumericExponents(stepText);
245770
+ }
245771
+
245772
+ // lib/shared/export-snippet.ts
243300
245773
  var writeFileAsync = promisify3(fs53.writeFile);
243301
245774
  var ALLOWED_EXPORT_FORMATS = [
243302
245775
  "json",
@@ -243312,7 +245785,8 @@ var ALLOWED_EXPORT_FORMATS = [
243312
245785
  "kicad_pcb",
243313
245786
  "kicad_zip",
243314
245787
  "kicad-library",
243315
- "srj"
245788
+ "srj",
245789
+ "step"
243316
245790
  ];
243317
245791
  var OUTPUT_EXTENSIONS = {
243318
245792
  json: ".circuit.json",
@@ -243328,7 +245802,8 @@ var OUTPUT_EXTENSIONS = {
243328
245802
  kicad_pcb: ".kicad_pcb",
243329
245803
  kicad_zip: "-kicad.zip",
243330
245804
  "kicad-library": "",
243331
- srj: ".simple-route.json"
245805
+ srj: ".simple-route.json",
245806
+ step: ".step"
243332
245807
  };
243333
245808
  var exportSnippet = async ({
243334
245809
  filePath,
@@ -243479,6 +245954,9 @@ var exportSnippet = async ({
243479
245954
  outputContent = await zip.generateAsync({ type: "nodebuffer" });
243480
245955
  break;
243481
245956
  }
245957
+ case "step":
245958
+ outputContent = await circuitJsonToStep(circuitJson);
245959
+ break;
243482
245960
  default:
243483
245961
  outputContent = JSON.stringify(circuitJson, null, 2);
243484
245962
  }
@@ -250930,7 +253408,7 @@ var any_circuit_element2 = external_exports2.union([
250930
253408
  var any_soup_element2 = any_circuit_element2;
250931
253409
  expectTypesMatch3(true);
250932
253410
  expectStringUnionsMatch2(true);
250933
- function applyToPoint23(matrix2, point22) {
253411
+ function applyToPoint24(matrix2, point22) {
250934
253412
  return Array.isArray(point22) ? [
250935
253413
  matrix2.a * point22[0] + matrix2.c * point22[1] + matrix2.e,
250936
253414
  matrix2.b * point22[0] + matrix2.d * point22[1] + matrix2.f
@@ -251894,7 +254372,7 @@ var transformPCBElement2 = (elm, matrix2) => {
251894
254372
  const tsr = decomposeTSR2(matrix2);
251895
254373
  const flipPadWidthHeight = Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1;
251896
254374
  if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
251897
- const { x: x3, y: y4 } = applyToPoint23(matrix2, {
254375
+ const { x: x3, y: y4 } = applyToPoint24(matrix2, {
251898
254376
  x: Number(elm.x),
251899
254377
  y: Number(elm.y)
251900
254378
  });
@@ -251902,7 +254380,7 @@ var transformPCBElement2 = (elm, matrix2) => {
251902
254380
  elm.y = y4;
251903
254381
  if (elm.type === "pcb_smtpad" && elm.shape === "polygon" && Array.isArray(elm.points)) {
251904
254382
  elm.points = elm.points.map((point22) => {
251905
- const tp3 = applyToPoint23(matrix2, { x: point22.x, y: point22.y });
254383
+ const tp3 = applyToPoint24(matrix2, { x: point22.x, y: point22.y });
251906
254384
  return {
251907
254385
  x: tp3.x,
251908
254386
  y: tp3.y
@@ -251910,13 +254388,13 @@ var transformPCBElement2 = (elm, matrix2) => {
251910
254388
  });
251911
254389
  }
251912
254390
  } else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
251913
- elm.center = applyToPoint23(matrix2, elm.center);
254391
+ elm.center = applyToPoint24(matrix2, elm.center);
251914
254392
  } else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text" || elm.type === "pcb_note_text") {
251915
- elm.anchor_position = applyToPoint23(matrix2, elm.anchor_position);
254393
+ elm.anchor_position = applyToPoint24(matrix2, elm.anchor_position);
251916
254394
  } else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_note_rect" || elm.type === "pcb_courtyard_rect" || elm.type === "pcb_courtyard_circle") {
251917
- elm.center = applyToPoint23(matrix2, elm.center);
254395
+ elm.center = applyToPoint24(matrix2, elm.center);
251918
254396
  } else if (elm.type === "pcb_component") {
251919
- elm.center = applyToPoint23(matrix2, elm.center);
254397
+ elm.center = applyToPoint24(matrix2, elm.center);
251920
254398
  elm.rotation = elm.rotation + tsr.rotation.angle / Math.PI * 180;
251921
254399
  elm.rotation = elm.rotation % 360;
251922
254400
  if (flipPadWidthHeight) {
@@ -251924,21 +254402,21 @@ var transformPCBElement2 = (elm, matrix2) => {
251924
254402
  }
251925
254403
  } else if (elm.type === "pcb_courtyard_outline") {
251926
254404
  elm.outline = elm.outline.map((p3) => {
251927
- const tp3 = applyToPoint23(matrix2, p3);
254405
+ const tp3 = applyToPoint24(matrix2, p3);
251928
254406
  p3.x = tp3.x;
251929
254407
  p3.y = tp3.y;
251930
254408
  return p3;
251931
254409
  });
251932
254410
  } else if (elm.type === "pcb_courtyard_polygon") {
251933
254411
  elm.points = elm.points.map((p3) => {
251934
- const tp3 = applyToPoint23(matrix2, p3);
254412
+ const tp3 = applyToPoint24(matrix2, p3);
251935
254413
  p3.x = tp3.x;
251936
254414
  p3.y = tp3.y;
251937
254415
  return p3;
251938
254416
  });
251939
254417
  } else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path" || elm.type === "pcb_note_path") {
251940
254418
  elm.route = elm.route.map((rp3) => {
251941
- const tp3 = applyToPoint23(matrix2, rp3);
254419
+ const tp3 = applyToPoint24(matrix2, rp3);
251942
254420
  rp3.x = tp3.x;
251943
254421
  rp3.y = tp3.y;
251944
254422
  return rp3;
@@ -251946,14 +254424,14 @@ var transformPCBElement2 = (elm, matrix2) => {
251946
254424
  } else if (elm.type === "pcb_silkscreen_line" || elm.type === "pcb_note_line") {
251947
254425
  const p12 = { x: elm.x1, y: elm.y1 };
251948
254426
  const p23 = { x: elm.x2, y: elm.y2 };
251949
- const p1t = applyToPoint23(matrix2, p12);
251950
- const p2t = applyToPoint23(matrix2, p23);
254427
+ const p1t = applyToPoint24(matrix2, p12);
254428
+ const p2t = applyToPoint24(matrix2, p23);
251951
254429
  elm.x1 = p1t.x;
251952
254430
  elm.y1 = p1t.y;
251953
254431
  elm.x2 = p2t.x;
251954
254432
  elm.y2 = p2t.y;
251955
254433
  } else if (elm.type === "cad_component") {
251956
- const newPos = applyToPoint23(matrix2, {
254434
+ const newPos = applyToPoint24(matrix2, {
251957
254435
  x: elm.position.x,
251958
254436
  y: elm.position.y
251959
254437
  });
@@ -252708,15 +255186,15 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
252708
255186
  for (const e4 of circuitElements) {
252709
255187
  if (e4.type === "pcb_cutout") {
252710
255188
  if (e4.shape === "polygon") {
252711
- e4.points = e4.points.map((p3) => applyToPoint23(matrix2, p3));
255189
+ e4.points = e4.points.map((p3) => applyToPoint24(matrix2, p3));
252712
255190
  } else if (e4.shape === "circle" || e4.shape === "rect") {
252713
- e4.center = applyToPoint23(matrix2, e4.center);
255191
+ e4.center = applyToPoint24(matrix2, e4.center);
252714
255192
  } else if ("route" in e4) {
252715
255193
  const cutoutPath = e4;
252716
- cutoutPath.route = cutoutPath.route.map((p3) => applyToPoint23(matrix2, p3));
255194
+ cutoutPath.route = cutoutPath.route.map((p3) => applyToPoint24(matrix2, p3));
252717
255195
  }
252718
255196
  } else if (e4.type === "pcb_smtpad" && e4.shape === "polygon") {
252719
- e4.points = e4.points.map((p3) => applyToPoint23(matrix2, p3));
255197
+ e4.points = e4.points.map((p3) => applyToPoint24(matrix2, p3));
252720
255198
  }
252721
255199
  }
252722
255200
  const cad = circuitElements.find((e4) => e4.type === "cad_component");
@@ -257359,7 +259837,7 @@ var any_circuit_element3 = z160.union([
257359
259837
  var any_soup_element3 = any_circuit_element3;
257360
259838
  expectTypesMatch4(true);
257361
259839
  expectStringUnionsMatch3(true);
257362
- function applyToPoint25(matrix2, point22) {
259840
+ function applyToPoint26(matrix2, point22) {
257363
259841
  return Array.isArray(point22) ? [
257364
259842
  matrix2.a * point22[0] + matrix2.c * point22[1] + matrix2.e,
257365
259843
  matrix2.b * point22[0] + matrix2.d * point22[1] + matrix2.f
@@ -258322,7 +260800,7 @@ var transformPCBElement3 = (elm, matrix2) => {
258322
260800
  const tsr = decomposeTSR3(matrix2);
258323
260801
  const flipPadWidthHeight = Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1;
258324
260802
  if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
258325
- const { x: x3, y: y4 } = applyToPoint25(matrix2, {
260803
+ const { x: x3, y: y4 } = applyToPoint26(matrix2, {
258326
260804
  x: Number(elm.x),
258327
260805
  y: Number(elm.y)
258328
260806
  });
@@ -258330,7 +260808,7 @@ var transformPCBElement3 = (elm, matrix2) => {
258330
260808
  elm.y = y4;
258331
260809
  if (elm.type === "pcb_smtpad" && elm.shape === "polygon" && Array.isArray(elm.points)) {
258332
260810
  elm.points = elm.points.map((point22) => {
258333
- const tp3 = applyToPoint25(matrix2, { x: point22.x, y: point22.y });
260811
+ const tp3 = applyToPoint26(matrix2, { x: point22.x, y: point22.y });
258334
260812
  return {
258335
260813
  x: tp3.x,
258336
260814
  y: tp3.y
@@ -258338,13 +260816,13 @@ var transformPCBElement3 = (elm, matrix2) => {
258338
260816
  });
258339
260817
  }
258340
260818
  } else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
258341
- elm.center = applyToPoint25(matrix2, elm.center);
260819
+ elm.center = applyToPoint26(matrix2, elm.center);
258342
260820
  } else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text" || elm.type === "pcb_note_text") {
258343
- elm.anchor_position = applyToPoint25(matrix2, elm.anchor_position);
260821
+ elm.anchor_position = applyToPoint26(matrix2, elm.anchor_position);
258344
260822
  } else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect" || elm.type === "pcb_note_rect" || elm.type === "pcb_courtyard_rect" || elm.type === "pcb_courtyard_circle") {
258345
- elm.center = applyToPoint25(matrix2, elm.center);
260823
+ elm.center = applyToPoint26(matrix2, elm.center);
258346
260824
  } else if (elm.type === "pcb_component") {
258347
- elm.center = applyToPoint25(matrix2, elm.center);
260825
+ elm.center = applyToPoint26(matrix2, elm.center);
258348
260826
  elm.rotation = elm.rotation + tsr.rotation.angle / Math.PI * 180;
258349
260827
  elm.rotation = elm.rotation % 360;
258350
260828
  if (flipPadWidthHeight) {
@@ -258352,21 +260830,21 @@ var transformPCBElement3 = (elm, matrix2) => {
258352
260830
  }
258353
260831
  } else if (elm.type === "pcb_courtyard_outline") {
258354
260832
  elm.outline = elm.outline.map((p3) => {
258355
- const tp3 = applyToPoint25(matrix2, p3);
260833
+ const tp3 = applyToPoint26(matrix2, p3);
258356
260834
  p3.x = tp3.x;
258357
260835
  p3.y = tp3.y;
258358
260836
  return p3;
258359
260837
  });
258360
260838
  } else if (elm.type === "pcb_courtyard_polygon") {
258361
260839
  elm.points = elm.points.map((p3) => {
258362
- const tp3 = applyToPoint25(matrix2, p3);
260840
+ const tp3 = applyToPoint26(matrix2, p3);
258363
260841
  p3.x = tp3.x;
258364
260842
  p3.y = tp3.y;
258365
260843
  return p3;
258366
260844
  });
258367
260845
  } else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path" || elm.type === "pcb_note_path") {
258368
260846
  elm.route = elm.route.map((rp3) => {
258369
- const tp3 = applyToPoint25(matrix2, rp3);
260847
+ const tp3 = applyToPoint26(matrix2, rp3);
258370
260848
  rp3.x = tp3.x;
258371
260849
  rp3.y = tp3.y;
258372
260850
  return rp3;
@@ -258374,14 +260852,14 @@ var transformPCBElement3 = (elm, matrix2) => {
258374
260852
  } else if (elm.type === "pcb_silkscreen_line" || elm.type === "pcb_note_line") {
258375
260853
  const p12 = { x: elm.x1, y: elm.y1 };
258376
260854
  const p23 = { x: elm.x2, y: elm.y2 };
258377
- const p1t = applyToPoint25(matrix2, p12);
258378
- const p2t = applyToPoint25(matrix2, p23);
260855
+ const p1t = applyToPoint26(matrix2, p12);
260856
+ const p2t = applyToPoint26(matrix2, p23);
258379
260857
  elm.x1 = p1t.x;
258380
260858
  elm.y1 = p1t.y;
258381
260859
  elm.x2 = p2t.x;
258382
260860
  elm.y2 = p2t.y;
258383
260861
  } else if (elm.type === "cad_component") {
258384
- const newPos = applyToPoint25(matrix2, {
260862
+ const newPos = applyToPoint26(matrix2, {
258385
260863
  x: elm.position.x,
258386
260864
  y: elm.position.y
258387
260865
  });
@@ -259133,15 +261611,15 @@ var convertEasyEdaJsonToCircuitJson2 = (easyEdaJson, { useModelCdn, shouldRecent
259133
261611
  for (const e4 of circuitElements) {
259134
261612
  if (e4.type === "pcb_cutout") {
259135
261613
  if (e4.shape === "polygon") {
259136
- e4.points = e4.points.map((p3) => applyToPoint25(matrix2, p3));
261614
+ e4.points = e4.points.map((p3) => applyToPoint26(matrix2, p3));
259137
261615
  } else if (e4.shape === "circle" || e4.shape === "rect") {
259138
- e4.center = applyToPoint25(matrix2, e4.center);
261616
+ e4.center = applyToPoint26(matrix2, e4.center);
259139
261617
  } else if ("route" in e4) {
259140
261618
  const cutoutPath = e4;
259141
- cutoutPath.route = cutoutPath.route.map((p3) => applyToPoint25(matrix2, p3));
261619
+ cutoutPath.route = cutoutPath.route.map((p3) => applyToPoint26(matrix2, p3));
259142
261620
  }
259143
261621
  } else if (e4.type === "pcb_smtpad" && e4.shape === "polygon") {
259144
- e4.points = e4.points.map((p3) => applyToPoint25(matrix2, p3));
261622
+ e4.points = e4.points.map((p3) => applyToPoint26(matrix2, p3));
259145
261623
  }
259146
261624
  }
259147
261625
  const cad = circuitElements.find((e4) => e4.type === "cad_component");
@@ -262823,7 +265301,7 @@ class ExtendedSearch {
262823
265301
  }
262824
265302
  }
262825
265303
  var registeredSearchers = [];
262826
- function register(...args) {
265304
+ function register2(...args) {
262827
265305
  registeredSearchers.push(...args);
262828
265306
  }
262829
265307
  function createSearcher(pattern, options) {
@@ -263155,7 +265633,7 @@ Fuse2.config = Config;
263155
265633
  Fuse2.parseQuery = parse3;
263156
265634
  }
263157
265635
  {
263158
- register(ExtendedSearch);
265636
+ register2(ExtendedSearch);
263159
265637
  }
263160
265638
 
263161
265639
  // cli/search/register.ts