@tscircuit/cli 0.1.736 → 0.1.737

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +969 -523
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -67488,7 +67488,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
67488
67488
  "node_modules/fs.realpath/old.js"(exports3) {
67489
67489
  var pathModule = __require("path");
67490
67490
  var isWindows2 = process.platform === "win32";
67491
- var fs26 = __require("fs");
67491
+ var fs28 = __require("fs");
67492
67492
  var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
67493
67493
  function rethrow() {
67494
67494
  var callback;
@@ -67553,7 +67553,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
67553
67553
  base = m2[0];
67554
67554
  previous = "";
67555
67555
  if (isWindows2 && !knownHard[base]) {
67556
- fs26.lstatSync(base);
67556
+ fs28.lstatSync(base);
67557
67557
  knownHard[base] = true;
67558
67558
  }
67559
67559
  }
@@ -67571,7 +67571,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
67571
67571
  if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
67572
67572
  resolvedLink = cache[base];
67573
67573
  } else {
67574
- var stat4 = fs26.lstatSync(base);
67574
+ var stat4 = fs28.lstatSync(base);
67575
67575
  if (!stat4.isSymbolicLink()) {
67576
67576
  knownHard[base] = true;
67577
67577
  if (cache)
@@ -67586,8 +67586,8 @@ var require_dist8 = __commonJS((exports2, module2) => {
67586
67586
  }
67587
67587
  }
67588
67588
  if (linkTarget === null) {
67589
- fs26.statSync(base);
67590
- linkTarget = fs26.readlinkSync(base);
67589
+ fs28.statSync(base);
67590
+ linkTarget = fs28.readlinkSync(base);
67591
67591
  }
67592
67592
  resolvedLink = pathModule.resolve(previous, linkTarget);
67593
67593
  if (cache)
@@ -67624,7 +67624,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
67624
67624
  base = m2[0];
67625
67625
  previous = "";
67626
67626
  if (isWindows2 && !knownHard[base]) {
67627
- fs26.lstat(base, function(err) {
67627
+ fs28.lstat(base, function(err) {
67628
67628
  if (err)
67629
67629
  return cb(err);
67630
67630
  knownHard[base] = true;
@@ -67652,7 +67652,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
67652
67652
  if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
67653
67653
  return gotResolvedLink(cache[base]);
67654
67654
  }
67655
- return fs26.lstat(base, gotStat);
67655
+ return fs28.lstat(base, gotStat);
67656
67656
  }
67657
67657
  function gotStat(err, stat4) {
67658
67658
  if (err)
@@ -67669,10 +67669,10 @@ var require_dist8 = __commonJS((exports2, module2) => {
67669
67669
  return gotTarget(null, seenLinks[id], base);
67670
67670
  }
67671
67671
  }
67672
- fs26.stat(base, function(err2) {
67672
+ fs28.stat(base, function(err2) {
67673
67673
  if (err2)
67674
67674
  return cb(err2);
67675
- fs26.readlink(base, function(err3, target) {
67675
+ fs28.readlink(base, function(err3, target) {
67676
67676
  if (!isWindows2)
67677
67677
  seenLinks[id] = target;
67678
67678
  gotTarget(err3, target);
@@ -67702,9 +67702,9 @@ var require_dist8 = __commonJS((exports2, module2) => {
67702
67702
  realpath2.realpathSync = realpathSync;
67703
67703
  realpath2.monkeypatch = monkeypatch;
67704
67704
  realpath2.unmonkeypatch = unmonkeypatch;
67705
- var fs26 = __require("fs");
67706
- var origRealpath = fs26.realpath;
67707
- var origRealpathSync = fs26.realpathSync;
67705
+ var fs28 = __require("fs");
67706
+ var origRealpath = fs28.realpath;
67707
+ var origRealpathSync = fs28.realpathSync;
67708
67708
  var version2 = process.version;
67709
67709
  var ok = /^v[0-5]\./.test(version2);
67710
67710
  var old = require_old();
@@ -67742,12 +67742,12 @@ var require_dist8 = __commonJS((exports2, module2) => {
67742
67742
  }
67743
67743
  }
67744
67744
  function monkeypatch() {
67745
- fs26.realpath = realpath2;
67746
- fs26.realpathSync = realpathSync;
67745
+ fs28.realpath = realpath2;
67746
+ fs28.realpathSync = realpathSync;
67747
67747
  }
67748
67748
  function unmonkeypatch() {
67749
- fs26.realpath = origRealpath;
67750
- fs26.realpathSync = origRealpathSync;
67749
+ fs28.realpath = origRealpath;
67750
+ fs28.realpathSync = origRealpathSync;
67751
67751
  }
67752
67752
  }
67753
67753
  });
@@ -67973,8 +67973,8 @@ var require_dist8 = __commonJS((exports2, module2) => {
67973
67973
  return new Minimatch(pattern, options).match(p);
67974
67974
  };
67975
67975
  module22.exports = minimatch;
67976
- var path28 = require_path2();
67977
- minimatch.sep = path28.sep;
67976
+ var path210 = require_path2();
67977
+ minimatch.sep = path210.sep;
67978
67978
  var GLOBSTAR = Symbol("globstar **");
67979
67979
  minimatch.GLOBSTAR = GLOBSTAR;
67980
67980
  var expand = require_brace_expansion();
@@ -68465,8 +68465,8 @@ globstar while`, file, fr, pattern, pr, swallowee);
68465
68465
  if (f === "/" && partial)
68466
68466
  return true;
68467
68467
  const options = this.options;
68468
- if (path28.sep !== "/") {
68469
- f = f.split(path28.sep).join("/");
68468
+ if (path210.sep !== "/") {
68469
+ f = f.split(path210.sep).join("/");
68470
68470
  }
68471
68471
  f = f.split(slashSplit);
68472
68472
  this.debug(this.pattern, "split", f);
@@ -68556,8 +68556,8 @@ globstar while`, file, fr, pattern, pr, swallowee);
68556
68556
  function ownProp(obj, field) {
68557
68557
  return Object.prototype.hasOwnProperty.call(obj, field);
68558
68558
  }
68559
- var fs26 = __require("fs");
68560
- var path28 = __require("path");
68559
+ var fs28 = __require("fs");
68560
+ var path210 = __require("path");
68561
68561
  var minimatch = require_minimatch();
68562
68562
  var isAbsolute3 = __require("path").isAbsolute;
68563
68563
  var Minimatch = minimatch.Minimatch;
@@ -68611,7 +68611,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
68611
68611
  self2.stat = !!options.stat;
68612
68612
  self2.noprocess = !!options.noprocess;
68613
68613
  self2.absolute = !!options.absolute;
68614
- self2.fs = options.fs || fs26;
68614
+ self2.fs = options.fs || fs28;
68615
68615
  self2.maxLength = options.maxLength || Infinity;
68616
68616
  self2.cache = options.cache || /* @__PURE__ */ Object.create(null);
68617
68617
  self2.statCache = options.statCache || /* @__PURE__ */ Object.create(null);
@@ -68620,13 +68620,13 @@ globstar while`, file, fr, pattern, pr, swallowee);
68620
68620
  self2.changedCwd = false;
68621
68621
  var cwd = process.cwd();
68622
68622
  if (!ownProp(options, "cwd"))
68623
- self2.cwd = path28.resolve(cwd);
68623
+ self2.cwd = path210.resolve(cwd);
68624
68624
  else {
68625
- self2.cwd = path28.resolve(options.cwd);
68625
+ self2.cwd = path210.resolve(options.cwd);
68626
68626
  self2.changedCwd = self2.cwd !== cwd;
68627
68627
  }
68628
- self2.root = options.root || path28.resolve(self2.cwd, "/");
68629
- self2.root = path28.resolve(self2.root);
68628
+ self2.root = options.root || path210.resolve(self2.cwd, "/");
68629
+ self2.root = path210.resolve(self2.root);
68630
68630
  self2.cwdAbs = isAbsolute3(self2.cwd) ? self2.cwd : makeAbs(self2, self2.cwd);
68631
68631
  self2.nomount = !!options.nomount;
68632
68632
  if (process.platform === "win32") {
@@ -68709,13 +68709,13 @@ globstar while`, file, fr, pattern, pr, swallowee);
68709
68709
  function makeAbs(self2, f) {
68710
68710
  var abs = f;
68711
68711
  if (f.charAt(0) === "/") {
68712
- abs = path28.join(self2.root, f);
68712
+ abs = path210.join(self2.root, f);
68713
68713
  } else if (isAbsolute3(f) || f === "") {
68714
68714
  abs = f;
68715
68715
  } else if (self2.changedCwd) {
68716
- abs = path28.resolve(self2.cwd, f);
68716
+ abs = path210.resolve(self2.cwd, f);
68717
68717
  } else {
68718
- abs = path28.resolve(f);
68718
+ abs = path210.resolve(f);
68719
68719
  }
68720
68720
  if (process.platform === "win32")
68721
68721
  abs = abs.replace(/\\/g, "/");
@@ -68746,7 +68746,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
68746
68746
  var Minimatch = minimatch.Minimatch;
68747
68747
  var Glob = require_glob().Glob;
68748
68748
  var util = __require("util");
68749
- var path28 = __require("path");
68749
+ var path210 = __require("path");
68750
68750
  var assert2 = __require("assert");
68751
68751
  var isAbsolute3 = __require("path").isAbsolute;
68752
68752
  var common = require_common4();
@@ -68876,7 +68876,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
68876
68876
  e = prefix + e;
68877
68877
  }
68878
68878
  if (e.charAt(0) === "/" && !this.nomount) {
68879
- e = path28.join(this.root, e);
68879
+ e = path210.join(this.root, e);
68880
68880
  }
68881
68881
  this._emitMatch(index, e);
68882
68882
  }
@@ -69025,9 +69025,9 @@ See: https://github.com/isaacs/node-glob/issues/167`);
69025
69025
  if (prefix && isAbsolute3(prefix) && !this.nomount) {
69026
69026
  var trail = /[\/\\]$/.test(prefix);
69027
69027
  if (prefix.charAt(0) === "/") {
69028
- prefix = path28.join(this.root, prefix);
69028
+ prefix = path210.join(this.root, prefix);
69029
69029
  } else {
69030
- prefix = path28.resolve(this.root, prefix);
69030
+ prefix = path210.resolve(this.root, prefix);
69031
69031
  if (trail)
69032
69032
  prefix += "/";
69033
69033
  }
@@ -69214,7 +69214,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
69214
69214
  var Minimatch = minimatch.Minimatch;
69215
69215
  var inherits = require_inherits2();
69216
69216
  var EE = __require("events").EventEmitter;
69217
- var path28 = __require("path");
69217
+ var path210 = __require("path");
69218
69218
  var assert2 = __require("assert");
69219
69219
  var isAbsolute3 = __require("path").isAbsolute;
69220
69220
  var globSync = require_sync7();
@@ -69497,7 +69497,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
69497
69497
  e = prefix + e;
69498
69498
  }
69499
69499
  if (e.charAt(0) === "/" && !this.nomount) {
69500
- e = path28.join(this.root, e);
69500
+ e = path210.join(this.root, e);
69501
69501
  }
69502
69502
  this._emitMatch(index, e);
69503
69503
  }
@@ -69684,9 +69684,9 @@ See: https://github.com/isaacs/node-glob/issues/167`);
69684
69684
  if (prefix && isAbsolute3(prefix) && !this.nomount) {
69685
69685
  var trail = /[\/\\]$/.test(prefix);
69686
69686
  if (prefix.charAt(0) === "/") {
69687
- prefix = path28.join(this.root, prefix);
69687
+ prefix = path210.join(this.root, prefix);
69688
69688
  } else {
69689
- prefix = path28.resolve(this.root, prefix);
69689
+ prefix = path210.resolve(this.root, prefix);
69690
69690
  if (trail)
69691
69691
  prefix += "/";
69692
69692
  }
@@ -69763,8 +69763,8 @@ See: https://github.com/isaacs/node-glob/issues/167`);
69763
69763
  "node_modules/glob-promise/lib/index.js"(exports3, module22) {
69764
69764
  var glob2 = require_glob();
69765
69765
  var promise = function(pattern, options) {
69766
- return new Promise((resolve10, reject) => {
69767
- glob2(pattern, options, (err, files) => err === null ? resolve10(files) : reject(err));
69766
+ return new Promise((resolve11, reject) => {
69767
+ glob2(pattern, options, (err, files) => err === null ? resolve11(files) : reject(err));
69768
69768
  });
69769
69769
  };
69770
69770
  module22.exports = promise;
@@ -69870,7 +69870,7 @@ export default {
69870
69870
  }
69871
69871
  case "export-pathlist": {
69872
69872
  return `export default [
69873
- ` + Object.keys(vfs).map((path28) => ` "${path28}"`).join(`,
69873
+ ` + Object.keys(vfs).map((path210) => ` "${path210}"`).join(`,
69874
69874
  `) + `
69875
69875
  ]`;
69876
69876
  }
@@ -74125,7 +74125,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
74125
74125
  import { execSync as execSync2 } from "node:child_process";
74126
74126
  var import_semver2 = __toESM2(require_semver2(), 1);
74127
74127
  // package.json
74128
- var version = "0.1.734";
74128
+ var version = "0.1.736";
74129
74129
  var package_default = {
74130
74130
  name: "@tscircuit/cli",
74131
74131
  version,
@@ -74152,7 +74152,7 @@ var package_default = {
74152
74152
  chokidar: "4.0.1",
74153
74153
  "circuit-json": "0.0.325",
74154
74154
  "circuit-json-to-gltf": "^0.0.58",
74155
- "circuit-json-to-kicad": "^0.0.31",
74155
+ "circuit-json-to-kicad": "^0.0.33",
74156
74156
  "circuit-json-to-readable-netlist": "^0.0.13",
74157
74157
  "circuit-json-to-spice": "^0.0.10",
74158
74158
  "circuit-json-to-tscircuit": "^0.0.9",
@@ -80326,8 +80326,8 @@ Successfully cloned to:`));
80326
80326
  var import_perfect_cli = __toESM2(require_dist7(), 1);
80327
80327
 
80328
80328
  // lib/shared/export-snippet.ts
80329
- import fs28 from "node:fs";
80330
- import path30 from "node:path";
80329
+ import fs29 from "node:fs";
80330
+ import path31 from "node:path";
80331
80331
  import { promisify as promisify3 } from "node:util";
80332
80332
 
80333
80333
  // node_modules/circuit-json-to-readable-netlist/dist/index.js
@@ -81711,6 +81711,7 @@ import {
81711
81711
  TextEffectsFont,
81712
81712
  Xy
81713
81713
  } from "kicadts";
81714
+ import { symbols as symbols2 } from "schematic-symbols";
81714
81715
  import { symbols } from "schematic-symbols";
81715
81716
  import { applyToPoint as applyToPoint3, scale as createScaleMatrix } from "transformation-matrix";
81716
81717
  import {
@@ -81726,7 +81727,7 @@ import {
81726
81727
  TextEffectsJustify
81727
81728
  } from "kicadts";
81728
81729
  import { applyToPoint as applyToPoint23 } from "transformation-matrix";
81729
- import { symbols as symbols2 } from "schematic-symbols";
81730
+ import { symbols as symbols3 } from "schematic-symbols";
81730
81731
  import {
81731
81732
  SchematicSymbol as SchematicSymbol3,
81732
81733
  SymbolLibId as SymbolLibId2,
@@ -81808,6 +81809,8 @@ import {
81808
81809
  At as At2
81809
81810
  } from "kicadts";
81810
81811
  import { KicadSymbolLib } from "kicadts";
81812
+ import { parseKicadMod } from "kicadts";
81813
+ import { KicadSymbolLib as KicadSymbolLib2 } from "kicadts";
81811
81814
  var ConverterStage = class {
81812
81815
  MAX_ITERATIONS = 1000;
81813
81816
  iteration = 0;
@@ -81882,14 +81885,23 @@ function extractReferencePrefix(name) {
81882
81885
  const match = name.match(/^([A-Za-z]+)/);
81883
81886
  return match?.[1]?.toUpperCase() ?? "U";
81884
81887
  }
81888
+ function isBuiltinSymbol(symbolName) {
81889
+ return symbolName in symbols;
81890
+ }
81885
81891
  function getLibraryId(sourceComp, schematicComp, cadComponent) {
81886
81892
  if (sourceComp.type !== "source_component") {
81887
81893
  if (schematicComp.symbol_name) {
81894
+ if (isBuiltinSymbol(schematicComp.symbol_name)) {
81895
+ return `Device:${schematicComp.symbol_name}`;
81896
+ }
81888
81897
  return `Custom:${schematicComp.symbol_name}`;
81889
81898
  }
81890
81899
  return "Device:Component";
81891
81900
  }
81892
81901
  if (schematicComp.symbol_name) {
81902
+ if (isBuiltinSymbol(schematicComp.symbol_name)) {
81903
+ return `Device:${schematicComp.symbol_name}`;
81904
+ }
81893
81905
  return `Custom:${schematicComp.symbol_name}`;
81894
81906
  }
81895
81907
  const ergonomicName = getKicadCompatibleComponentName(sourceComp, cadComponent);
@@ -81966,7 +81978,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
81966
81978
  const symbolName = netLabel.symbol_name;
81967
81979
  if (!symbolName)
81968
81980
  return null;
81969
- const symbolData = symbols[symbolName];
81981
+ const symbolData = symbols2[symbolName];
81970
81982
  if (!symbolData)
81971
81983
  return null;
81972
81984
  const libId = `Custom:${symbolName}`;
@@ -81984,7 +81996,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
81984
81996
  if (symbolName.startsWith("generic_chip_")) {
81985
81997
  return this.createGenericChipSymbolData(schematicComponent, this.ctx.db);
81986
81998
  }
81987
- return symbols[symbolName] || null;
81999
+ return symbols2[symbolName] || null;
81988
82000
  }
81989
82001
  createGenericChipSymbolData(schematicComp, db) {
81990
82002
  const schematicPorts = db.schematic_port.list().filter((p) => p.schematic_component_id === schematicComp.schematic_component_id).sort((a, b) => (a.pin_number || 0) - (b.pin_number || 0));
@@ -82346,7 +82358,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
82346
82358
  this.finished = true;
82347
82359
  return;
82348
82360
  }
82349
- const symbols3 = [];
82361
+ const symbols4 = [];
82350
82362
  for (const schematicComponent of schematicComponents) {
82351
82363
  const sourceComponent = schematicComponent.source_component_id ? db.source_component.get(schematicComponent.source_component_id) : null;
82352
82364
  if (!sourceComponent)
@@ -82426,10 +82438,10 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
82426
82438
  project.paths.push(path28);
82427
82439
  instances.projects.push(project);
82428
82440
  symbol._sxInstances = instances;
82429
- symbols3.push(symbol);
82441
+ symbols4.push(symbol);
82430
82442
  }
82431
82443
  if (kicadSch) {
82432
- kicadSch.symbols = symbols3;
82444
+ kicadSch.symbols = symbols4;
82433
82445
  }
82434
82446
  this.finished = true;
82435
82447
  }
@@ -82445,7 +82457,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
82445
82457
  return { refTextPos: refTextPos2, valTextPos: valTextPos2 };
82446
82458
  }
82447
82459
  const symbolName = schematicComponent.symbol_name;
82448
- const symbol = symbols2[symbolName];
82460
+ const symbol = symbols3[symbolName];
82449
82461
  if (!symbol) {
82450
82462
  return {
82451
82463
  refTextPos: { x: symbolKicadPos.x, y: symbolKicadPos.y - 6 },
@@ -82549,7 +82561,7 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
82549
82561
  this.finished = true;
82550
82562
  return;
82551
82563
  }
82552
- const symbols3 = [];
82564
+ const symbols4 = [];
82553
82565
  const globalLabels = [];
82554
82566
  for (const netLabel of netLabels) {
82555
82567
  const labelText = netLabel.text || "";
@@ -82557,7 +82569,7 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
82557
82569
  if (symbolName) {
82558
82570
  const symbol = this.createSymbolFromNetLabel(netLabel, labelText, symbolName);
82559
82571
  if (symbol) {
82560
- symbols3.push(symbol);
82572
+ symbols4.push(symbol);
82561
82573
  }
82562
82574
  } else {
82563
82575
  const label = this.createGlobalLabel(netLabel, labelText);
@@ -82566,9 +82578,9 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
82566
82578
  }
82567
82579
  }
82568
82580
  }
82569
- if (kicadSch && symbols3.length > 0) {
82581
+ if (kicadSch && symbols4.length > 0) {
82570
82582
  const existingSymbols = kicadSch.symbols || [];
82571
- kicadSch.symbols = [...existingSymbols, ...symbols3];
82583
+ kicadSch.symbols = [...existingSymbols, ...symbols4];
82572
82584
  }
82573
82585
  if (kicadSch && globalLabels.length > 0) {
82574
82586
  kicadSch.globalLabels = [
@@ -83879,6 +83891,9 @@ var GenerateKicadSchAndPcbStage = class extends ConverterStage {
83879
83891
  }
83880
83892
  };
83881
83893
  var ExtractSymbolsStage = class extends ConverterStage {
83894
+ isCustomSymbol(libraryId) {
83895
+ return libraryId?.startsWith("Custom:") ?? false;
83896
+ }
83882
83897
  _step() {
83883
83898
  const schContent = this.ctx.kicadSchString;
83884
83899
  const fpLibraryName = this.ctx.fpLibraryName ?? "tscircuit";
@@ -83900,15 +83915,17 @@ var ExtractSymbolsStage = class extends ConverterStage {
83900
83915
  this.finished = true;
83901
83916
  return;
83902
83917
  }
83903
- const symbols3 = libSymbols.symbols ?? [];
83904
- for (const symbol of symbols3) {
83918
+ const symbols4 = libSymbols.symbols ?? [];
83919
+ for (const symbol of symbols4) {
83920
+ const isCustom = this.isCustomSymbol(symbol.libraryId);
83905
83921
  const symbolName = this.sanitizeSymbolName(symbol.libraryId);
83906
83922
  if (!uniqueSymbols.has(symbolName)) {
83907
83923
  symbol.libraryId = symbolName;
83908
83924
  this.updateFootprintProperty(symbol, fpLibraryName);
83909
83925
  uniqueSymbols.set(symbolName, {
83910
83926
  symbolName,
83911
- symbol
83927
+ symbol,
83928
+ isBuiltin: !isCustom
83912
83929
  });
83913
83930
  }
83914
83931
  }
@@ -83947,12 +83964,28 @@ function getBasename(filePath) {
83947
83964
  return parts[parts.length - 1] || filePath;
83948
83965
  }
83949
83966
  var ExtractFootprintsStage = class extends ConverterStage {
83967
+ findCustomFootprintNames() {
83968
+ const customNames = /* @__PURE__ */ new Set;
83969
+ const cadComponents = this.ctx.db.cad_component?.list() ?? [];
83970
+ const sourceComponents = this.ctx.db.source_component;
83971
+ for (const cadComponent of cadComponents) {
83972
+ if (!cadComponent.footprinter_string) {
83973
+ const sourceComp = cadComponent.source_component_id ? sourceComponents?.get(cadComponent.source_component_id) : null;
83974
+ if (sourceComp) {
83975
+ const footprintName = getKicadCompatibleComponentName(sourceComp, cadComponent);
83976
+ customNames.add(footprintName);
83977
+ }
83978
+ }
83979
+ }
83980
+ return customNames;
83981
+ }
83950
83982
  _step() {
83951
83983
  const kicadPcbString = this.ctx.kicadPcbString;
83952
83984
  const fpLibraryName = this.ctx.fpLibraryName ?? "tscircuit";
83953
83985
  if (!kicadPcbString) {
83954
83986
  throw new Error("PCB content not available. Run GenerateKicadSchAndPcbStage first.");
83955
83987
  }
83988
+ const customFootprintNames = this.findCustomFootprintNames();
83956
83989
  const uniqueFootprints = /* @__PURE__ */ new Map;
83957
83990
  try {
83958
83991
  const parsed = parseKicadSexpr2(kicadPcbString);
@@ -83964,9 +83997,13 @@ var ExtractFootprintsStage = class extends ConverterStage {
83964
83997
  }
83965
83998
  const footprints = pcb.footprints ?? [];
83966
83999
  for (const footprint of footprints) {
83967
- const sanitized = this.sanitizeFootprint(footprint, fpLibraryName);
83968
- if (!uniqueFootprints.has(sanitized.footprintName)) {
83969
- uniqueFootprints.set(sanitized.footprintName, sanitized);
84000
+ const footprintEntry = this.sanitizeFootprint({
84001
+ footprint,
84002
+ fpLibraryName,
84003
+ customFootprintNames
84004
+ });
84005
+ if (!uniqueFootprints.has(footprintEntry.footprintName)) {
84006
+ uniqueFootprints.set(footprintEntry.footprintName, footprintEntry);
83970
84007
  }
83971
84008
  }
83972
84009
  } catch (error) {
@@ -83975,10 +84012,15 @@ var ExtractFootprintsStage = class extends ConverterStage {
83975
84012
  this.ctx.footprintEntries = Array.from(uniqueFootprints.values());
83976
84013
  this.finished = true;
83977
84014
  }
83978
- sanitizeFootprint(footprint, fpLibraryName) {
84015
+ sanitizeFootprint({
84016
+ footprint,
84017
+ fpLibraryName,
84018
+ customFootprintNames
84019
+ }) {
83979
84020
  const libraryLink = footprint.libraryLink ?? "footprint";
83980
84021
  const parts = libraryLink.split(":");
83981
84022
  const footprintName = (parts.length > 1 ? parts[1] : parts[0])?.replace(/[\\\/]/g, "-").trim() || "footprint";
84023
+ const isBuiltin = !customFootprintNames.has(footprintName);
83982
84024
  footprint.libraryLink = footprintName;
83983
84025
  footprint.position = At2.from([0, 0, 0]);
83984
84026
  footprint.locked = false;
@@ -84026,7 +84068,8 @@ var ExtractFootprintsStage = class extends ConverterStage {
84026
84068
  return {
84027
84069
  footprintName,
84028
84070
  kicadModString: footprint.getString(),
84029
- model3dSourcePaths: modelFiles
84071
+ model3dSourcePaths: modelFiles,
84072
+ isBuiltin
84030
84073
  };
84031
84074
  }
84032
84075
  getOutput() {
@@ -84042,6 +84085,7 @@ var GenerateSymbolLibraryStage = class extends ConverterStage {
84042
84085
  if (!this.ctx.libraryOutput) {
84043
84086
  this.ctx.libraryOutput = {
84044
84087
  kicadSymString: "",
84088
+ symbols: [],
84045
84089
  footprints: [],
84046
84090
  fpLibTableString: "",
84047
84091
  symLibTableString: "",
@@ -84068,6 +84112,7 @@ var GenerateLibraryTablesStage = class extends ConverterStage {
84068
84112
  const libraryName = this.ctx.libraryName ?? "tscircuit";
84069
84113
  const fpLibraryName = this.ctx.fpLibraryName ?? "tscircuit";
84070
84114
  const footprintEntries = this.ctx.footprintEntries ?? [];
84115
+ const symbolEntries = this.ctx.symbolEntries ?? [];
84071
84116
  const model3dSourcePathsSet = /* @__PURE__ */ new Set;
84072
84117
  for (const fp of footprintEntries) {
84073
84118
  for (const modelPath of fp.model3dSourcePaths) {
@@ -84079,12 +84124,14 @@ var GenerateLibraryTablesStage = class extends ConverterStage {
84079
84124
  if (!this.ctx.libraryOutput) {
84080
84125
  this.ctx.libraryOutput = {
84081
84126
  kicadSymString: "",
84127
+ symbols: [],
84082
84128
  footprints: [],
84083
84129
  fpLibTableString: "",
84084
84130
  symLibTableString: "",
84085
84131
  model3dSourcePaths: []
84086
84132
  };
84087
84133
  }
84134
+ this.ctx.libraryOutput.symbols = symbolEntries;
84088
84135
  this.ctx.libraryOutput.footprints = footprintEntries;
84089
84136
  this.ctx.libraryOutput.fpLibTableString = fpLibTableString;
84090
84137
  this.ctx.libraryOutput.symLibTableString = symLibTableString;
@@ -84169,30 +84216,359 @@ var CircuitJsonToKicadLibraryConverter = class {
84169
84216
  return this.getOutput().model3dSourcePaths;
84170
84217
  }
84171
84218
  };
84219
+ function renameKicadFootprint(params2) {
84220
+ const { kicadFootprint, newKicadFootprintName, kicadLibraryName } = params2;
84221
+ const footprint = parseKicadMod(kicadFootprint.kicadModString);
84222
+ footprint.libraryLink = newKicadFootprintName;
84223
+ for (const model of footprint.models) {
84224
+ const currentPath = model.path;
84225
+ if (currentPath.includes("${KIPRJMOD}/")) {
84226
+ const filename = currentPath.split("/").pop() ?? "";
84227
+ model.path = `\${KIPRJMOD}/3dmodels/${kicadLibraryName}.3dshapes/${filename}`;
84228
+ }
84229
+ }
84230
+ return {
84231
+ footprintName: newKicadFootprintName,
84232
+ kicadModString: footprint.getString(),
84233
+ model3dSourcePaths: kicadFootprint.model3dSourcePaths
84234
+ };
84235
+ }
84236
+ function classifyKicadFootprints(ctx) {
84237
+ for (const extractedKicadComponent of ctx.extractedKicadComponents) {
84238
+ classifyFootprintsForComponent({
84239
+ ctx,
84240
+ extractedKicadComponent
84241
+ });
84242
+ }
84243
+ }
84244
+ function classifyFootprintsForComponent({
84245
+ ctx,
84246
+ extractedKicadComponent
84247
+ }) {
84248
+ const { tscircuitComponentName, kicadFootprints } = extractedKicadComponent;
84249
+ let hasAddedUserFootprint = false;
84250
+ for (const kicadFootprint of kicadFootprints) {
84251
+ if (kicadFootprint.isBuiltin) {
84252
+ addBuiltinFootprint({ ctx, kicadFootprint });
84253
+ } else {
84254
+ if (!hasAddedUserFootprint) {
84255
+ hasAddedUserFootprint = true;
84256
+ const renamedFootprint = renameKicadFootprint({
84257
+ kicadFootprint,
84258
+ newKicadFootprintName: tscircuitComponentName,
84259
+ kicadLibraryName: ctx.kicadLibraryName
84260
+ });
84261
+ addUserFootprint({ ctx, kicadFootprint: renamedFootprint });
84262
+ } else {
84263
+ addUserFootprint({ ctx, kicadFootprint });
84264
+ }
84265
+ }
84266
+ }
84267
+ }
84268
+ function addUserFootprint({
84269
+ ctx,
84270
+ kicadFootprint
84271
+ }) {
84272
+ const alreadyExists = ctx.userKicadFootprints.some((fp) => fp.footprintName === kicadFootprint.footprintName);
84273
+ if (!alreadyExists) {
84274
+ ctx.userKicadFootprints.push(kicadFootprint);
84275
+ }
84276
+ }
84277
+ function addBuiltinFootprint({
84278
+ ctx,
84279
+ kicadFootprint
84280
+ }) {
84281
+ const alreadyExists = ctx.builtinKicadFootprints.some((fp) => fp.footprintName === kicadFootprint.footprintName);
84282
+ if (!alreadyExists) {
84283
+ ctx.builtinKicadFootprints.push(kicadFootprint);
84284
+ }
84285
+ }
84286
+ function componentHasCustomFootprint(extractedKicadComponent) {
84287
+ return extractedKicadComponent.kicadFootprints.some((fp) => !fp.isBuiltin);
84288
+ }
84289
+ function renameKicadSymbol(params2) {
84290
+ const { kicadSymbol, newKicadSymbolName } = params2;
84291
+ const symbol = kicadSymbol.symbol;
84292
+ const oldName = symbol.libraryId;
84293
+ symbol.libraryId = newKicadSymbolName;
84294
+ if (oldName && symbol.subSymbols) {
84295
+ for (const subSymbol of symbol.subSymbols) {
84296
+ if (subSymbol.libraryId?.startsWith(oldName)) {
84297
+ const suffix = subSymbol.libraryId.slice(oldName.length);
84298
+ subSymbol.libraryId = newKicadSymbolName + suffix;
84299
+ }
84300
+ }
84301
+ }
84302
+ return { symbolName: newKicadSymbolName, symbol };
84303
+ }
84304
+ function updateKicadSymbolFootprint(params2) {
84305
+ const { kicadSymbol, kicadLibraryName, kicadFootprintName } = params2;
84306
+ const properties = kicadSymbol.symbol.properties ?? [];
84307
+ for (const prop of properties) {
84308
+ if (prop.key === "Footprint") {
84309
+ prop.value = `${kicadLibraryName}:${kicadFootprintName}`;
84310
+ }
84311
+ }
84312
+ }
84313
+ function updateBuiltinKicadSymbolFootprint(kicadSymbol) {
84314
+ const symbol = kicadSymbol.symbol;
84315
+ const properties = symbol.properties ?? [];
84316
+ for (const prop of properties) {
84317
+ if (prop.key === "Footprint" && prop.value) {
84318
+ const parts = prop.value.split(":");
84319
+ const footprintName = parts.length > 1 ? parts[1] : parts[0];
84320
+ prop.value = `tscircuit_builtin:${footprintName}`;
84321
+ }
84322
+ }
84323
+ return { symbolName: kicadSymbol.symbolName, symbol };
84324
+ }
84325
+ function classifyKicadSymbols(ctx) {
84326
+ for (const extractedKicadComponent of ctx.extractedKicadComponents) {
84327
+ classifySymbolsForComponent({
84328
+ ctx,
84329
+ extractedKicadComponent
84330
+ });
84331
+ }
84332
+ }
84333
+ function classifySymbolsForComponent({
84334
+ ctx,
84335
+ extractedKicadComponent
84336
+ }) {
84337
+ const { tscircuitComponentName, kicadSymbols } = extractedKicadComponent;
84338
+ const hasCustomFootprint = componentHasCustomFootprint(extractedKicadComponent);
84339
+ let hasAddedUserSymbol = false;
84340
+ for (const kicadSymbol of kicadSymbols) {
84341
+ if (!kicadSymbol.isBuiltin) {
84342
+ if (!hasAddedUserSymbol) {
84343
+ hasAddedUserSymbol = true;
84344
+ const renamedSymbol = renameKicadSymbol({
84345
+ kicadSymbol,
84346
+ newKicadSymbolName: tscircuitComponentName
84347
+ });
84348
+ if (hasCustomFootprint) {
84349
+ updateKicadSymbolFootprint({
84350
+ kicadSymbol: renamedSymbol,
84351
+ kicadLibraryName: ctx.kicadLibraryName,
84352
+ kicadFootprintName: tscircuitComponentName
84353
+ });
84354
+ }
84355
+ addUserSymbol({ ctx, kicadSymbol: renamedSymbol });
84356
+ } else {
84357
+ addUserSymbol({ ctx, kicadSymbol });
84358
+ }
84359
+ } else if (hasCustomFootprint && !hasAddedUserSymbol) {
84360
+ hasAddedUserSymbol = true;
84361
+ const renamedSymbol = renameKicadSymbol({
84362
+ kicadSymbol,
84363
+ newKicadSymbolName: tscircuitComponentName
84364
+ });
84365
+ updateKicadSymbolFootprint({
84366
+ kicadSymbol: renamedSymbol,
84367
+ kicadLibraryName: ctx.kicadLibraryName,
84368
+ kicadFootprintName: tscircuitComponentName
84369
+ });
84370
+ addUserSymbol({ ctx, kicadSymbol: renamedSymbol });
84371
+ } else {
84372
+ const updatedSymbol = updateBuiltinKicadSymbolFootprint(kicadSymbol);
84373
+ addBuiltinSymbol({ ctx, kicadSymbol: updatedSymbol });
84374
+ }
84375
+ }
84376
+ }
84377
+ function addUserSymbol({
84378
+ ctx,
84379
+ kicadSymbol
84380
+ }) {
84381
+ const alreadyExists = ctx.userKicadSymbols.some((s) => s.symbolName === kicadSymbol.symbolName);
84382
+ if (!alreadyExists) {
84383
+ ctx.userKicadSymbols.push(kicadSymbol);
84384
+ }
84385
+ }
84386
+ function addBuiltinSymbol({
84387
+ ctx,
84388
+ kicadSymbol
84389
+ }) {
84390
+ const alreadyExists = ctx.builtinKicadSymbols.some((s) => s.symbolName === kicadSymbol.symbolName);
84391
+ if (!alreadyExists) {
84392
+ ctx.builtinKicadSymbols.push(kicadSymbol);
84393
+ }
84394
+ }
84395
+ function generateSymLibTable(params2) {
84396
+ const { kicadLibraryName, includeBuiltin } = params2;
84397
+ let content = `(sym_lib_table
84398
+ `;
84399
+ content += ` (lib (name "${kicadLibraryName}")(type "KiCad")(uri "\${KIPRJMOD}/symbols/${kicadLibraryName}.kicad_sym")(options "")(descr ""))
84400
+ `;
84401
+ if (includeBuiltin) {
84402
+ content += ` (lib (name "tscircuit_builtin")(type "KiCad")(uri "\${KIPRJMOD}/symbols/tscircuit_builtin.kicad_sym")(options "")(descr ""))
84403
+ `;
84404
+ }
84405
+ content += `)
84406
+ `;
84407
+ return content;
84408
+ }
84409
+ function generateFpLibTable(params2) {
84410
+ const { kicadLibraryName, includeBuiltin } = params2;
84411
+ let content = `(fp_lib_table
84412
+ `;
84413
+ content += ` (lib (name "${kicadLibraryName}")(type "KiCad")(uri "\${KIPRJMOD}/footprints/${kicadLibraryName}.pretty")(options "")(descr ""))
84414
+ `;
84415
+ if (includeBuiltin) {
84416
+ content += ` (lib (name "tscircuit_builtin")(type "KiCad")(uri "\${KIPRJMOD}/footprints/tscircuit_builtin.pretty")(options "")(descr ""))
84417
+ `;
84418
+ }
84419
+ content += `)
84420
+ `;
84421
+ return content;
84422
+ }
84423
+ var KICAD_SYM_LIB_VERSION2 = 20211014;
84424
+ var KICAD_GENERATOR = "circuit-json-to-kicad";
84425
+ function buildKicadLibraryFiles(ctx) {
84426
+ buildUserSymbolLibrary(ctx);
84427
+ buildBuiltinSymbolLibrary(ctx);
84428
+ buildUserFootprintLibrary(ctx);
84429
+ buildBuiltinFootprintLibrary(ctx);
84430
+ buildLibraryTables(ctx);
84431
+ }
84432
+ function buildUserSymbolLibrary(ctx) {
84433
+ if (ctx.userKicadSymbols.length === 0)
84434
+ return;
84435
+ const symbolLib = new KicadSymbolLib2({
84436
+ version: KICAD_SYM_LIB_VERSION2,
84437
+ generator: KICAD_GENERATOR,
84438
+ symbols: ctx.userKicadSymbols.map((s) => s.symbol)
84439
+ });
84440
+ ctx.kicadProjectFsMap[`symbols/${ctx.kicadLibraryName}.kicad_sym`] = symbolLib.getString();
84441
+ }
84442
+ function buildBuiltinSymbolLibrary(ctx) {
84443
+ if (!ctx.includeBuiltins || ctx.builtinKicadSymbols.length === 0)
84444
+ return;
84445
+ const symbolLib = new KicadSymbolLib2({
84446
+ version: KICAD_SYM_LIB_VERSION2,
84447
+ generator: KICAD_GENERATOR,
84448
+ symbols: ctx.builtinKicadSymbols.map((s) => s.symbol)
84449
+ });
84450
+ ctx.kicadProjectFsMap["symbols/tscircuit_builtin.kicad_sym"] = symbolLib.getString();
84451
+ }
84452
+ function buildUserFootprintLibrary(ctx) {
84453
+ for (const kicadFootprint of ctx.userKicadFootprints) {
84454
+ const filePath = `footprints/${ctx.kicadLibraryName}.pretty/${kicadFootprint.footprintName}.kicad_mod`;
84455
+ ctx.kicadProjectFsMap[filePath] = kicadFootprint.kicadModString;
84456
+ }
84457
+ }
84458
+ function buildBuiltinFootprintLibrary(ctx) {
84459
+ if (!ctx.includeBuiltins || ctx.builtinKicadFootprints.length === 0)
84460
+ return;
84461
+ for (const kicadFootprint of ctx.builtinKicadFootprints) {
84462
+ const filePath = `footprints/tscircuit_builtin.pretty/${kicadFootprint.footprintName}.kicad_mod`;
84463
+ ctx.kicadProjectFsMap[filePath] = kicadFootprint.kicadModString;
84464
+ }
84465
+ }
84466
+ function buildLibraryTables(ctx) {
84467
+ const hasBuiltinFootprints = ctx.includeBuiltins && ctx.builtinKicadFootprints.length > 0;
84468
+ const hasBuiltinSymbols = ctx.includeBuiltins && ctx.builtinKicadSymbols.length > 0;
84469
+ ctx.kicadProjectFsMap["fp-lib-table"] = generateFpLibTable({
84470
+ kicadLibraryName: ctx.kicadLibraryName,
84471
+ includeBuiltin: hasBuiltinFootprints
84472
+ });
84473
+ ctx.kicadProjectFsMap["sym-lib-table"] = generateSymLibTable({
84474
+ kicadLibraryName: ctx.kicadLibraryName,
84475
+ includeBuiltin: hasBuiltinSymbols
84476
+ });
84477
+ }
84478
+ var KicadLibraryConverter = class {
84479
+ options;
84480
+ output = null;
84481
+ ctx;
84482
+ constructor(options) {
84483
+ this.options = options;
84484
+ this.ctx = createKicadLibraryConverterContext({
84485
+ kicadLibraryName: options.kicadLibraryName ?? "tscircuit_library",
84486
+ includeBuiltins: options.includeBuiltins ?? true
84487
+ });
84488
+ }
84489
+ async run() {
84490
+ this.ctx.builtTscircuitComponents = await this.buildTscircuitComponents();
84491
+ this.ctx.extractedKicadComponents = this.extractKicadComponents();
84492
+ classifyKicadFootprints(this.ctx);
84493
+ classifyKicadSymbols(this.ctx);
84494
+ buildKicadLibraryFiles(this.ctx);
84495
+ this.output = {
84496
+ kicadProjectFsMap: this.ctx.kicadProjectFsMap,
84497
+ model3dSourcePaths: this.ctx.model3dSourcePaths
84498
+ };
84499
+ }
84500
+ async buildTscircuitComponents() {
84501
+ const builtTscircuitComponents = [];
84502
+ const { entrypoint } = this.options;
84503
+ const exports2 = await this.options.getExportsFromTsxFile(entrypoint);
84504
+ const componentExports = exports2.filter((name) => /^[A-Z]/.test(name));
84505
+ for (const exportName of componentExports) {
84506
+ let componentPath = entrypoint;
84507
+ if (this.options.resolveExportPath) {
84508
+ const resolved = await this.options.resolveExportPath(entrypoint, exportName);
84509
+ if (resolved)
84510
+ componentPath = resolved;
84511
+ }
84512
+ const circuitJson = await this.options.buildFileToCircuitJson(componentPath, exportName);
84513
+ if (circuitJson && (!Array.isArray(circuitJson) || circuitJson.length > 0)) {
84514
+ builtTscircuitComponents.push({
84515
+ tscircuitComponentName: exportName,
84516
+ circuitJson
84517
+ });
84518
+ }
84519
+ }
84520
+ return builtTscircuitComponents;
84521
+ }
84522
+ extractKicadComponents() {
84523
+ const extractedKicadComponents = [];
84524
+ for (const builtTscircuitComponent of this.ctx.builtTscircuitComponents) {
84525
+ const { tscircuitComponentName, circuitJson } = builtTscircuitComponent;
84526
+ const libConverter = new CircuitJsonToKicadLibraryConverter(circuitJson, {
84527
+ libraryName: this.ctx.kicadLibraryName,
84528
+ footprintLibraryName: this.ctx.kicadLibraryName
84529
+ });
84530
+ libConverter.runUntilFinished();
84531
+ const libOutput = libConverter.getOutput();
84532
+ for (const path28 of libOutput.model3dSourcePaths) {
84533
+ if (!this.ctx.model3dSourcePaths.includes(path28)) {
84534
+ this.ctx.model3dSourcePaths.push(path28);
84535
+ }
84536
+ }
84537
+ extractedKicadComponents.push({
84538
+ tscircuitComponentName,
84539
+ kicadFootprints: libOutput.footprints,
84540
+ kicadSymbols: libOutput.symbols,
84541
+ model3dSourcePaths: libOutput.model3dSourcePaths
84542
+ });
84543
+ }
84544
+ return extractedKicadComponents;
84545
+ }
84546
+ getOutput() {
84547
+ if (!this.output) {
84548
+ throw new Error("Converter has not been run yet. Call run() before getOutput().");
84549
+ }
84550
+ return this.output;
84551
+ }
84552
+ };
84553
+ function createKicadLibraryConverterContext(params2) {
84554
+ return {
84555
+ kicadLibraryName: params2.kicadLibraryName,
84556
+ includeBuiltins: params2.includeBuiltins,
84557
+ builtTscircuitComponents: [],
84558
+ extractedKicadComponents: [],
84559
+ userKicadFootprints: [],
84560
+ builtinKicadFootprints: [],
84561
+ userKicadSymbols: [],
84562
+ builtinKicadSymbols: [],
84563
+ model3dSourcePaths: [],
84564
+ kicadProjectFsMap: {}
84565
+ };
84566
+ }
84172
84567
 
84173
- // lib/shared/export-snippet.ts
84174
- var import_jszip2 = __toESM2(require_lib4(), 1);
84175
-
84176
- // lib/shared/generate-circuit-json.tsx
84177
- var import_make_vfs2 = __toESM2(require_dist8(), 1);
84178
- import path29 from "node:path";
84568
+ // lib/shared/convert-to-kicad-library.tsx
84179
84569
  import fs27 from "node:fs";
84570
+ import path29 from "node:path";
84180
84571
  import { pathToFileURL } from "node:url";
84181
- import Debug11 from "debug";
84182
-
84183
- // lib/utils/abbreviate-stringify-object.ts
84184
- var abbreviateStringifyObject = (obj) => {
84185
- if (obj === null || obj === undefined)
84186
- return obj;
84187
- if (typeof obj !== "object")
84188
- return obj;
84189
- return JSON.stringify(Object.fromEntries(Object.entries(obj).map(([k, v]) => {
84190
- return [
84191
- k,
84192
- typeof v === "string" ? v.slice(0, 100) : typeof v === "object" && v !== null ? abbreviateStringifyObject(v) : v
84193
- ];
84194
- })));
84195
- };
84196
84572
 
84197
84573
  // lib/shared/importFromUserLand.ts
84198
84574
  import { createRequire as createRequire2 } from "node:module";
@@ -84223,8 +84599,99 @@ async function importFromUserLand(moduleName) {
84223
84599
  return import(moduleName);
84224
84600
  }
84225
84601
 
84226
- // lib/shared/generate-circuit-json.tsx
84602
+ // lib/shared/convert-to-kicad-library.tsx
84227
84603
  import { jsxDEV } from "react/jsx-dev-runtime";
84604
+ async function convertToKicadLibrary({
84605
+ filePath,
84606
+ libraryName,
84607
+ outputDir
84608
+ }) {
84609
+ const absoluteFilePath = path29.isAbsolute(filePath) ? filePath : path29.resolve(process.cwd(), filePath);
84610
+ const React = await importFromUserLand("react");
84611
+ globalThis.React = React;
84612
+ const userLandTscircuit = await importFromUserLand("tscircuit");
84613
+ const converter = new KicadLibraryConverter({
84614
+ kicadLibraryName: libraryName,
84615
+ entrypoint: absoluteFilePath,
84616
+ buildFileToCircuitJson: async (filePath2, componentName) => {
84617
+ try {
84618
+ const module2 = await import(pathToFileURL(filePath2).href);
84619
+ const Component = module2[componentName];
84620
+ if (!Component || typeof Component !== "function") {
84621
+ return null;
84622
+ }
84623
+ const runner = new userLandTscircuit.RootCircuit;
84624
+ runner.add(/* @__PURE__ */ jsxDEV(Component, {
84625
+ name: componentName
84626
+ }, undefined, false, undefined, this));
84627
+ await runner.renderUntilSettled();
84628
+ return await runner.getCircuitJson();
84629
+ } catch (error) {
84630
+ console.warn(`Failed to build ${componentName}: ${error instanceof Error ? error.message : error}`);
84631
+ return null;
84632
+ }
84633
+ },
84634
+ getExportsFromTsxFile: async (filePath2) => {
84635
+ const module2 = await import(pathToFileURL(filePath2).href);
84636
+ return Object.keys(module2);
84637
+ },
84638
+ includeBuiltins: true
84639
+ });
84640
+ await converter.run();
84641
+ const kicadLibOutput = converter.getOutput();
84642
+ fs27.mkdirSync(outputDir, { recursive: true });
84643
+ for (const [relativePath, content] of Object.entries(kicadLibOutput.kicadProjectFsMap)) {
84644
+ const fullPath = path29.join(outputDir, relativePath);
84645
+ const dir = path29.dirname(fullPath);
84646
+ fs27.mkdirSync(dir, { recursive: true });
84647
+ if (typeof content === "string") {
84648
+ fs27.writeFileSync(fullPath, content);
84649
+ } else {
84650
+ fs27.writeFileSync(fullPath, content);
84651
+ }
84652
+ }
84653
+ if (kicadLibOutput.model3dSourcePaths.length > 0) {
84654
+ const shapesDir = path29.join(outputDir, `3dmodels/${libraryName}.3dshapes`);
84655
+ fs27.mkdirSync(shapesDir, { recursive: true });
84656
+ for (const modelPath of kicadLibOutput.model3dSourcePaths) {
84657
+ if (fs27.existsSync(modelPath)) {
84658
+ const filename = path29.basename(modelPath);
84659
+ fs27.copyFileSync(modelPath, path29.join(shapesDir, filename));
84660
+ }
84661
+ }
84662
+ }
84663
+ return {
84664
+ outputDir,
84665
+ files: Object.keys(kicadLibOutput.kicadProjectFsMap)
84666
+ };
84667
+ }
84668
+
84669
+ // lib/shared/export-snippet.ts
84670
+ var import_jszip2 = __toESM2(require_lib4(), 1);
84671
+
84672
+ // lib/shared/generate-circuit-json.tsx
84673
+ var import_make_vfs2 = __toESM2(require_dist8(), 1);
84674
+ import path30 from "node:path";
84675
+ import fs28 from "node:fs";
84676
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
84677
+ import Debug11 from "debug";
84678
+
84679
+ // lib/utils/abbreviate-stringify-object.ts
84680
+ var abbreviateStringifyObject = (obj) => {
84681
+ if (obj === null || obj === undefined)
84682
+ return obj;
84683
+ if (typeof obj !== "object")
84684
+ return obj;
84685
+ return JSON.stringify(Object.fromEntries(Object.entries(obj).map(([k, v]) => {
84686
+ return [
84687
+ k,
84688
+ typeof v === "string" ? v.slice(0, 100) : typeof v === "object" && v !== null ? abbreviateStringifyObject(v) : v
84689
+ ];
84690
+ })));
84691
+ };
84692
+
84693
+ // lib/shared/generate-circuit-json.tsx
84694
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
84228
84695
  var debug11 = Debug11("tsci:generate-circuit-json");
84229
84696
  var ALLOWED_FILE_EXTENSIONS = [
84230
84697
  ".tsx",
@@ -84251,12 +84718,12 @@ async function generateCircuitJson({
84251
84718
  const runner = new userLandTscircuit.RootCircuit({
84252
84719
  platform: platformConfig
84253
84720
  });
84254
- const absoluteFilePath = path29.isAbsolute(filePath) ? filePath : path29.resolve(process.cwd(), filePath);
84255
- const projectDir = path29.dirname(absoluteFilePath);
84721
+ const absoluteFilePath = path30.isAbsolute(filePath) ? filePath : path30.resolve(process.cwd(), filePath);
84722
+ const projectDir = path30.dirname(absoluteFilePath);
84256
84723
  const resolvedOutputDir = outputDir ?? projectDir;
84257
- const relativeComponentPath = path29.relative(projectDir, absoluteFilePath);
84258
- const baseFileName = outputFileName || path29.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
84259
- const outputPath = path29.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
84724
+ const relativeComponentPath = path30.relative(projectDir, absoluteFilePath);
84725
+ const baseFileName = outputFileName || path30.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
84726
+ const outputPath = path30.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
84260
84727
  debug11(`Project directory: ${projectDir}`);
84261
84728
  debug11(`Relative component path: ${relativeComponentPath}`);
84262
84729
  debug11(`Output path: ${outputPath}`);
@@ -84276,7 +84743,7 @@ async function generateCircuitJson({
84276
84743
  return false;
84277
84744
  if (normalizedFilePath.match(/^\.[^/]/))
84278
84745
  return false;
84279
- if (!ALLOWED_FILE_EXTENSIONS.includes(path29.extname(normalizedFilePath)))
84746
+ if (!ALLOWED_FILE_EXTENSIONS.includes(path30.extname(normalizedFilePath)))
84280
84747
  return false;
84281
84748
  return true;
84282
84749
  },
@@ -84284,17 +84751,17 @@ async function generateCircuitJson({
84284
84751
  })
84285
84752
  };
84286
84753
  debug11(`fsMap: ${abbreviateStringifyObject(fsMap)}`);
84287
- const MainComponent = await import(pathToFileURL(absoluteFilePath).href);
84754
+ const MainComponent = await import(pathToFileURL2(absoluteFilePath).href);
84288
84755
  const Component = MainComponent.default || (Object.keys(MainComponent).find((k) => k[0] === k[0].toUpperCase()) !== undefined ? MainComponent[Object.keys(MainComponent).find((k) => k[0] === k[0].toUpperCase())] : undefined);
84289
84756
  if (!Component) {
84290
84757
  throw new Error(`No component found in "${absoluteFilePath}". Make sure you export a component.`);
84291
84758
  }
84292
- runner.add(/* @__PURE__ */ jsxDEV(Component, {}, undefined, false, undefined, this));
84759
+ runner.add(/* @__PURE__ */ jsxDEV2(Component, {}, undefined, false, undefined, this));
84293
84760
  await runner.renderUntilSettled();
84294
84761
  const circuitJson = await runner.getCircuitJson();
84295
84762
  if (saveToFile) {
84296
84763
  debug11(`Saving circuit JSON to ${outputPath}`);
84297
- fs27.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
84764
+ fs28.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
84298
84765
  }
84299
84766
  return {
84300
84767
  circuitJson,
@@ -84303,7 +84770,7 @@ async function generateCircuitJson({
84303
84770
  }
84304
84771
 
84305
84772
  // lib/shared/export-snippet.ts
84306
- var writeFileAsync = promisify3(fs28.writeFile);
84773
+ var writeFileAsync = promisify3(fs29.writeFile);
84307
84774
  var ALLOWED_EXPORT_FORMATS = [
84308
84775
  "json",
84309
84776
  "circuit-json",
@@ -84348,10 +84815,26 @@ var exportSnippet = async ({
84348
84815
  onError(`Invalid format: ${format}`);
84349
84816
  return onExit(1);
84350
84817
  }
84351
- const projectDir = path30.dirname(filePath);
84352
- const outputBaseName = path30.basename(filePath).replace(/\.[^.]+$/, "");
84818
+ const projectDir = path31.dirname(filePath);
84819
+ const outputBaseName = path31.basename(filePath).replace(/\.[^.]+$/, "");
84353
84820
  const outputFileName = `${outputBaseName}${OUTPUT_EXTENSIONS[format]}`;
84354
- const outputDestination = path30.join(projectDir, outputPath ?? outputFileName);
84821
+ const outputDestination = path31.join(projectDir, outputPath ?? outputFileName);
84822
+ if (format === "kicad-library") {
84823
+ try {
84824
+ const result = await convertToKicadLibrary({
84825
+ filePath,
84826
+ libraryName: outputBaseName,
84827
+ outputDir: outputDestination
84828
+ });
84829
+ if (writeFile) {
84830
+ onSuccess({ outputDestination: result.outputDir, outputContent: "" });
84831
+ }
84832
+ return onExit(0);
84833
+ } catch (err) {
84834
+ onError(`Error exporting KiCad library: ${err}`);
84835
+ return onExit(1);
84836
+ }
84837
+ }
84355
84838
  const circuitData = await generateCircuitJson({
84356
84839
  filePath,
84357
84840
  saveToFile: format === "circuit-json",
@@ -84409,43 +84892,6 @@ var exportSnippet = async ({
84409
84892
  outputContent = await zip.generateAsync({ type: "nodebuffer" });
84410
84893
  break;
84411
84894
  }
84412
- case "kicad-library": {
84413
- const libraryName = outputBaseName;
84414
- const fpLibName = outputBaseName;
84415
- const libConverter = new CircuitJsonToKicadLibraryConverter(circuitData.circuitJson, {
84416
- libraryName,
84417
- footprintLibraryName: fpLibName
84418
- });
84419
- libConverter.runUntilFinished();
84420
- const libOutput = libConverter.getOutput();
84421
- const libDir = outputDestination;
84422
- fs28.mkdirSync(libDir, { recursive: true });
84423
- fs28.writeFileSync(path30.join(libDir, `${libraryName}.kicad_sym`), libOutput.kicadSymString);
84424
- const fpDir = path30.join(libDir, `${fpLibName}.pretty`);
84425
- fs28.mkdirSync(fpDir, { recursive: true });
84426
- for (const fp of libOutput.footprints) {
84427
- fs28.writeFileSync(path30.join(fpDir, `${fp.footprintName}.kicad_mod`), `${fp.kicadModString}
84428
- `);
84429
- }
84430
- if (libOutput.model3dSourcePaths.length > 0) {
84431
- const shapesDir = path30.join(libDir, `${fpLibName}.3dshapes`);
84432
- fs28.mkdirSync(shapesDir, { recursive: true });
84433
- for (const modelPath of libOutput.model3dSourcePaths) {
84434
- if (fs28.existsSync(modelPath)) {
84435
- const filename = path30.basename(modelPath);
84436
- fs28.copyFileSync(modelPath, path30.join(shapesDir, filename));
84437
- }
84438
- }
84439
- }
84440
- fs28.writeFileSync(path30.join(libDir, "fp-lib-table"), libOutput.fpLibTableString);
84441
- fs28.writeFileSync(path30.join(libDir, "sym-lib-table"), libOutput.symLibTableString);
84442
- outputContent = "";
84443
- if (writeFile) {
84444
- onSuccess({ outputDestination: libDir, outputContent: "" });
84445
- return onExit(0);
84446
- }
84447
- break;
84448
- }
84449
84895
  default:
84450
84896
  outputContent = JSON.stringify(circuitData.circuitJson, null, 2);
84451
84897
  }
@@ -84573,12 +85019,12 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
84573
85019
  };
84574
85020
 
84575
85021
  // lib/eecircuit-engine/run-simulation.ts
84576
- import { promises as fs29, existsSync as existsSync12 } from "node:fs";
84577
- import path31 from "node:path";
85022
+ import { promises as fs30, existsSync as existsSync12 } from "node:fs";
85023
+ import path32 from "node:path";
84578
85024
  import os4 from "node:os";
84579
85025
  var sim = null;
84580
85026
  var fetchSimulation = async () => {
84581
- const tempFilePath = path31.join(os4.tmpdir(), "eecircuit-engine-1.5.2.mjs");
85027
+ const tempFilePath = path32.join(os4.tmpdir(), "eecircuit-engine-1.5.2.mjs");
84582
85028
  if (!existsSync12(tempFilePath)) {
84583
85029
  const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
84584
85030
  const response = await fetch(url);
@@ -84586,7 +85032,7 @@ var fetchSimulation = async () => {
84586
85032
  throw new Error(`Failed to fetch eecircuit-engine from ${url}: ${response.statusText}`);
84587
85033
  }
84588
85034
  const scriptContent = await response.text();
84589
- await fs29.writeFile(tempFilePath, scriptContent);
85035
+ await fs30.writeFile(tempFilePath, scriptContent);
84590
85036
  }
84591
85037
  const module2 = await import(tempFilePath);
84592
85038
  return module2.Simulation;
@@ -84675,8 +85121,8 @@ var resultToCsv = (result) => {
84675
85121
  };
84676
85122
 
84677
85123
  // cli/export/register.ts
84678
- import path32 from "node:path";
84679
- import { promises as fs30 } from "node:fs";
85124
+ import path33 from "node:path";
85125
+ import { promises as fs31 } from "node:fs";
84680
85126
  var registerExport = (program3) => {
84681
85127
  program3.command("export").description("Export tscircuit code to various formats").argument("<file>", "Path to the package file").option("-f, --format <format>", `Output format (${ALLOWED_EXPORT_FORMATS.join(", ")})`).option("-o, --output <path>", "Output file path").option("--disable-parts-engine", "Disable the parts engine").action(async (file, options) => {
84682
85128
  const formatOption = options.format ?? "json";
@@ -84688,12 +85134,12 @@ var registerExport = (program3) => {
84688
85134
  });
84689
85135
  if (circuitJson) {
84690
85136
  const spiceString = getSpiceWithPaddedSim(circuitJson);
84691
- const outputSpicePath = options.output ?? path32.join(path32.dirname(file), `${path32.basename(file, path32.extname(file))}.spice.cir`);
84692
- await fs30.writeFile(outputSpicePath, spiceString);
85137
+ const outputSpicePath = options.output ?? path33.join(path33.dirname(file), `${path33.basename(file, path33.extname(file))}.spice.cir`);
85138
+ await fs31.writeFile(outputSpicePath, spiceString);
84693
85139
  const { result } = await runSimulation(spiceString);
84694
85140
  const csvContent = resultToCsv(result);
84695
85141
  const outputCsvPath = outputSpicePath.replace(/\.spice\.cir$/, ".csv");
84696
- await fs30.writeFile(outputCsvPath, csvContent);
85142
+ await fs31.writeFile(outputCsvPath, csvContent);
84697
85143
  console.log(`Exported to ${outputSpicePath} and ${outputCsvPath} (simulation results)!`);
84698
85144
  }
84699
85145
  process.exit(0);
@@ -84921,14 +85367,14 @@ class KeyStore {
84921
85367
  }
84922
85368
  }
84923
85369
  function createKey(key) {
84924
- let path33 = null;
85370
+ let path34 = null;
84925
85371
  let id = null;
84926
85372
  let src = null;
84927
85373
  let weight = 1;
84928
85374
  let getFn = null;
84929
85375
  if (isString2(key) || isArray(key)) {
84930
85376
  src = key;
84931
- path33 = createKeyPath(key);
85377
+ path34 = createKeyPath(key);
84932
85378
  id = createKeyId(key);
84933
85379
  } else {
84934
85380
  if (!hasOwn.call(key, "name")) {
@@ -84942,11 +85388,11 @@ function createKey(key) {
84942
85388
  throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
84943
85389
  }
84944
85390
  }
84945
- path33 = createKeyPath(name);
85391
+ path34 = createKeyPath(name);
84946
85392
  id = createKeyId(name);
84947
85393
  getFn = key.getFn;
84948
85394
  }
84949
- return { path: path33, id, weight, src, getFn };
85395
+ return { path: path34, id, weight, src, getFn };
84950
85396
  }
84951
85397
  function createKeyPath(key) {
84952
85398
  return isArray(key) ? key : key.split(".");
@@ -84954,34 +85400,34 @@ function createKeyPath(key) {
84954
85400
  function createKeyId(key) {
84955
85401
  return isArray(key) ? key.join(".") : key;
84956
85402
  }
84957
- function get(obj, path33) {
85403
+ function get(obj, path34) {
84958
85404
  let list = [];
84959
85405
  let arr = false;
84960
- const deepGet = (obj2, path34, index) => {
85406
+ const deepGet = (obj2, path35, index) => {
84961
85407
  if (!isDefined(obj2)) {
84962
85408
  return;
84963
85409
  }
84964
- if (!path34[index]) {
85410
+ if (!path35[index]) {
84965
85411
  list.push(obj2);
84966
85412
  } else {
84967
- let key = path34[index];
85413
+ let key = path35[index];
84968
85414
  const value = obj2[key];
84969
85415
  if (!isDefined(value)) {
84970
85416
  return;
84971
85417
  }
84972
- if (index === path34.length - 1 && (isString2(value) || isNumber(value) || isBoolean(value))) {
85418
+ if (index === path35.length - 1 && (isString2(value) || isNumber(value) || isBoolean(value))) {
84973
85419
  list.push(toString(value));
84974
85420
  } else if (isArray(value)) {
84975
85421
  arr = true;
84976
85422
  for (let i = 0, len = value.length;i < len; i += 1) {
84977
- deepGet(value[i], path34, index + 1);
85423
+ deepGet(value[i], path35, index + 1);
84978
85424
  }
84979
- } else if (path34.length) {
84980
- deepGet(value, path34, index + 1);
85425
+ } else if (path35.length) {
85426
+ deepGet(value, path35, index + 1);
84981
85427
  }
84982
85428
  }
84983
85429
  };
84984
- deepGet(obj, isString2(path33) ? path33.split(".") : path33, 0);
85430
+ deepGet(obj, isString2(path34) ? path34.split(".") : path34, 0);
84985
85431
  return arr ? list : list[0];
84986
85432
  }
84987
85433
  var MatchOptions = {
@@ -86173,8 +86619,8 @@ var registerSearch = (program3) => {
86173
86619
  }
86174
86620
  if (kicadResults.length) {
86175
86621
  console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
86176
- kicadResults.forEach((path33, idx) => {
86177
- console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path33.replace(".kicad_mod", "").replace(".pretty", "")}`);
86622
+ kicadResults.forEach((path34, idx) => {
86623
+ console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path34.replace(".kicad_mod", "").replace(".pretty", "")}`);
86178
86624
  });
86179
86625
  }
86180
86626
  if (!onlyKicad && results.packages.length) {
@@ -91353,7 +91799,7 @@ var { paths: Ad, bounds: ss, refblocks: Pd } = xs;
91353
91799
  var U = e({ primitives: [...Object.values(Ad)], ports: [{ ...Pd.left1, labels: ["1"] }], center: { x: ss.centerX, y: ss.centerY } }).rotateRightFacingSymbol("right").labelPort("left1", ["1"]).build();
91354
91800
  var ms = r(U, "down");
91355
91801
  var ns = r(U, "left");
91356
- var fs31 = r(U, "up");
91802
+ var fs32 = r(U, "up");
91357
91803
  var g = { paths: { path11: { type: "path", points: [{ x: -0.39, y: 0 }, { x: 0.06, y: -0.01 }], color: "primary", fill: false }, "path40-0": { type: "path", points: [{ x: 0.07, y: 0.27 }, { x: 0.07, y: -0.28 }], color: "primary", fill: false }, "path40-0-5": { type: "path", points: [{ x: 0.28, y: 0.24 }, { x: 0.08, y: 0.11 }], color: "primary", fill: false }, "path40-0-5-0": { type: "path", points: [{ x: 0.29, y: -0.24 }, { x: 0.09, y: -0.11 }], color: "primary", fill: false }, "path12-1-5": { type: "path", points: [{ x: 0.29, y: 0.25 }, { x: 0.29, y: 0.54 }], color: "primary", fill: false }, "path12-1-5-3": { type: "path", points: [{ x: 0.29, y: -0.54 }, { x: 0.29, y: -0.25 }], color: "primary", fill: false }, path15: { type: "path", points: [{ x: 0.19, y: -0.1 }, { x: 0.12, y: -0.2 }, { x: 0.22, y: -0.2 }, { x: 0.19, y: -0.1 }], color: "primary", fill: true } }, texts: { top1: { type: "text", text: "{REF}", x: -0.08, y: 0.36 }, bottom1: { type: "text", text: "{VAL}", x: -0.07, y: -0.41 } }, refblocks: { top1: { x: 0.29, y: 0.55 }, bottom1: { x: 0.29, y: -0.55 }, left1: { x: -0.4, y: 0 } }, bounds: { minX: -0.43, maxX: 0.43, minY: -0.58, maxY: 0.58, width: 0.85, height: 1.16, centerX: 0, centerY: 0 }, circles: { "path1-0": { type: "circle", x: 0.14, y: 0, radius: 0.29, color: "primary", fill: false } } };
91358
91804
  var { paths: Fd, texts: XA, bounds: e0, refblocks: Mo, circles: Rd } = g;
91359
91805
  var hs = e({ primitives: [...Object.values(Fd), ...Object.values(Rd), { type: "text", text: "{REF}", x: -0.1, y: 0.3094553499999995 }, { type: "text", text: "{VAL}", x: -0.1, y: -0.3094553499999995 }], ports: [{ ...Mo.top1, labels: ["1", "collector"] }, { ...Mo.bottom1, labels: ["2", "emitter"] }, { ...Mo.left1, labels: ["3", "base"] }], size: { width: e0.width, height: e0.height }, center: { x: e0.centerX, y: e0.centerY } }).rotateRightFacingSymbol("right").changeTextAnchor("{REF}", "middle_right").changeTextAnchor("{VAL}", "middle_right").build();
@@ -91922,7 +92368,7 @@ var mb = Cl.primitives.find((t3) => t3.type === "text" && t3.text === "{VAL}");
91922
92368
  sb.anchor = "middle_left";
91923
92369
  mb.anchor = "middle_right";
91924
92370
  var B1 = Cl;
91925
- var q1 = { ac_voltmeter_down: Ul, ac_voltmeter_horz: Wl, ac_voltmeter_left: Zl, ac_voltmeter_right: Kl, ac_voltmeter_up: ep, ac_voltmeter_vert: op, avalanche_diode_down: lp, avalanche_diode_horz: pp, avalanche_diode_left: yp, avalanche_diode_right: xp, avalanche_diode_up: mp, avalanche_diode_vert: fp, backward_diode_down: cp, backward_diode_left: Dt, backward_diode_right: _p, backward_diode_up: gp, battery_horz: Wt, battery_vert: Ap, boxresistor_down: Fp, boxresistor_left: Ep, boxresistor_right: Lp, boxresistor_small_down: jp, boxresistor_small_left: zp, boxresistor_small_right: Jp, boxresistor_small_up: Mp, boxresistor_up: Ip, bridged_ground_down: Dp, bridged_ground_left: Wp, bridged_ground_right: te, bridged_ground_up: Qp, capacitor_down: ta, capacitor_left: ea, capacitor_polarized_down: oa, capacitor_polarized_left: ia, capacitor_polarized_right: pa, capacitor_polarized_up: ya, capacitor_right: xa, capacitor_up: ma, constant_current_diode_down: fa, constant_current_diode_horz: ha, constant_current_diode_left: da, constant_current_diode_right: ba, constant_current_diode_up: ga, constant_current_diode_vert: va, crystal_4pin_down: wa, crystal_4pin_left: Aa, crystal_4pin_right: Pa, crystal_4pin_up: Sa, crystal_down: Ra, crystal_left: Ta, crystal_right: Ea, crystal_up: Xa, darlington_pair_transistor_down: La, darlington_pair_transistor_horz: Va, darlington_pair_transistor_left: ja, darlington_pair_transistor_right: ka, darlington_pair_transistor_up: za, darlington_pair_transistor_vert: Oa, dc_ammeter_horz: wt, dc_ammeter_vert: Ca, dc_voltmeter_down: Ia, dc_voltmeter_horz: qa, dc_voltmeter_left: Ua, dc_voltmeter_right: Wa, dc_voltmeter_up: Za, dc_voltmeter_vert: Ka, diac_down: ty, diac_horz: ey, diac_left: ry, diac_right: oy, diac_up: iy, diac_vert: ly, diode_down: ay, diode_left: yy, diode_right: $2, diode_up: xy, dpdt_normally_closed_switch_down: my, dpdt_normally_closed_switch_left: ny, dpdt_normally_closed_switch_right: M, dpdt_normally_closed_switch_up: fy, dpdt_switch_down: cy, dpdt_switch_left: dy, dpdt_switch_right: C, dpdt_switch_up: by, dpst_normally_closed_switch_down: gy, dpst_normally_closed_switch_left: uy, dpst_normally_closed_switch_right: N, dpst_normally_closed_switch_up: vy, dpst_switch_down: Ay, dpst_switch_left: Py, dpst_switch_right: I, dpst_switch_up: Sy, ferrite_bead_down: Ry, ferrite_bead_left: Ty, ferrite_bead_right: Fe, ferrite_bead_up: Se, filled_diode_down: Yy, filled_diode_horz: Ly, filled_diode_left: jy, filled_diode_right: zy, filled_diode_up: Jy, filled_diode_vert: My, frequency_meter_horz: At3, frequency_meter_vert: By, fuse_horz: ke, fuse_vert: Uy, ground_down: Gy, ground_horz: Wy, ground_left: Hy, ground_right: Zy, ground_up: Qy, ground_vert: Ky2, ground2_down: ex, ground2_left: ox, ground2_right: lx, ground2_up: ax, gunn_diode_horz: yx, gunn_diode_vert: xx, icled_down: mx, icled_left: nx, icled_right: q, icled_up: fx, igbt_transistor_horz: ze, igbt_transistor_vert: dx, illuminated_push_button_normally_open_horz: Oe, illuminated_push_button_normally_open_vert: ux, inductor_down: Px, inductor_left: Sx, inductor_right: _t, inductor_up: $e, laser_diode_down: Fx, laser_diode_left: Rx, laser_diode_right: D, laser_diode_up: Tx, led_down: Lx, led_left: Vx, led_right: gt, led_up: Ce, light_dependent_resistor_horz: Ie, light_dependent_resistor_vert: $x, mosfet_depletion_normally_on_horz: qe, mosfet_depletion_normally_on_vert: Ix, mushroom_head_normally_open_momentary_horz: Ue, mushroom_head_normally_open_momentary_vert: Ux, n_channel_d_mosfet_transistor_horz: He, n_channel_d_mosfet_transistor_vert: Qx, n_channel_e_mosfet_transistor_horz: Qe, n_channel_e_mosfet_transistor_vert: os5, njfet_transistor_horz: t0, njfet_transistor_vert: ys, not_connected_down: ms, not_connected_left: ns, not_connected_right: U, not_connected_up: fs31, npn_bipolar_transistor_down: hs, npn_bipolar_transistor_horz: cs, npn_bipolar_transistor_left: ds, npn_bipolar_transistor_right: bs, npn_bipolar_transistor_up: _s, npn_bipolar_transistor_vert: gs, opamp_no_power_down: vs, opamp_no_power_left: ws, opamp_no_power_right: G, opamp_no_power_up: As, opamp_with_power_down: Ss, opamp_with_power_left: Fs, opamp_with_power_right: W, opamp_with_power_up: Rs, p_channel_d_mosfet_transistor_horz: a0, p_channel_d_mosfet_transistor_vert: Ls, p_channel_e_mosfet_transistor_horz: x0, p_channel_e_mosfet_transistor_vert: Os, photodiode_horz: s0, photodiode_vert: Cs, pjfet_transistor_horz: n0, pjfet_transistor_vert: Ds, pnp_bipolar_transistor_down: Us, pnp_bipolar_transistor_horz: Gs, pnp_bipolar_transistor_left: Ws, pnp_bipolar_transistor_right: Hs, pnp_bipolar_transistor_up: Zs, pnp_bipolar_transistor_vert: Qs, potentiometer_horz: g0, potentiometer_vert: rm, potentiometer2_down: pm, potentiometer2_left: am, potentiometer2_right: H, potentiometer2_up: ym, potentiometer3_down: xm, potentiometer3_left: sm, potentiometer3_right: mm, potentiometer3_up: nm, power_factor_meter_horz: S0, power_factor_meter_vert: dm, push_button_normally_closed_momentary_horz: R0, push_button_normally_closed_momentary_vert: um, push_button_normally_open_momentary_horz: E0, push_button_normally_open_momentary_vert: Pm, rectifier_diode_horz: L0, rectifier_diode_vert: Rm, resistor_down: Em, resistor_left: Xm, resistor_right: Vm, resistor_up: km, resonator_down: Om, resonator_horz: M0, resonator_left: Jm, resonator_right: K, resonator_up: $m, resonator_vert: Mm, schottky_diode_down: Nm, schottky_diode_left: Im, schottky_diode_right: tt, schottky_diode_up: Bm, silicon_controlled_rectifier_horz: C0, silicon_controlled_rectifier_vert: Um, solderjumper2_bridged12_down: Gm, solderjumper2_bridged12_left: Wm, solderjumper2_bridged12_right: Hm, solderjumper2_bridged12_up: Zm, solderjumper2_down: Qm, solderjumper2_left: Km, solderjumper2_right: tn, solderjumper2_up: en, solderjumper3_bridged12_down: rn, solderjumper3_bridged12_left: on2, solderjumper3_bridged12_right: ln, solderjumper3_bridged12_up: pn, solderjumper3_bridged123_down: an, solderjumper3_bridged123_left: yn, solderjumper3_bridged123_right: xn, solderjumper3_bridged123_up: sn, solderjumper3_bridged23_down: mn, solderjumper3_bridged23_left: nn, solderjumper3_bridged23_right: fn, solderjumper3_bridged23_up: hn, solderjumper3_down: cn, solderjumper3_left: dn, solderjumper3_right: bn, solderjumper3_up: _n, spdt_normally_closed_switch_down: un, spdt_normally_closed_switch_left: vn, spdt_normally_closed_switch_right: at, spdt_normally_closed_switch_up: wn, spdt_switch_down: Pn, spdt_switch_left: Sn, spdt_switch_right: yt, spdt_switch_up: Fn, spst_normally_closed_switch_down: Rn, spst_normally_closed_switch_left: Tn, spst_normally_closed_switch_right: xt, spst_normally_closed_switch_up: En, spst_switch_down: Yn, spst_switch_left: Xn, spst_switch_right: st, spst_switch_up: Ln, square_wave_down: Vn, square_wave_left: jn, square_wave_right: kn, square_wave_up: zn, step_recovery_diode_horz: N0, step_recovery_diode_vert: On, tachometer_horz: Tt, tachometer_vert: Cn, testpoint_down: Bn, testpoint_left: qn, testpoint_right: nt, testpoint_up: Gn, tilted_ground_down: Hn, tilted_ground_left: Zn, tilted_ground_right: ut, tilted_ground_up: B0, triac_horz: q0, triac_vert: t1, tunnel_diode_horz: U0, tunnel_diode_vert: i1, unijunction_transistor_horz: W0, unijunction_transistor_vert: s1, usbc: n1, var_meter_horz: Z0, var_meter_vert: c1, varactor_diode_horz: K0, varactor_diode_vert: g1, varistor_horz: er, varistor_vert: A1, varmeter_horz: Et, varmeter_vert: R1, vcc_down: T1, vcc_left: E1, vcc_right: Y1, vcc_up: X1, volt_meter_horz: or, volt_meter_vert: L1, watt_hour_meter_horz: Yt, watt_hour_meter_vert: z1, wattmeter_horz: Xt, wattmeter_vert: M1, zener_diode_horz: ar, zener_diode_vert: B1 };
92371
+ var q1 = { ac_voltmeter_down: Ul, ac_voltmeter_horz: Wl, ac_voltmeter_left: Zl, ac_voltmeter_right: Kl, ac_voltmeter_up: ep, ac_voltmeter_vert: op, avalanche_diode_down: lp, avalanche_diode_horz: pp, avalanche_diode_left: yp, avalanche_diode_right: xp, avalanche_diode_up: mp, avalanche_diode_vert: fp, backward_diode_down: cp, backward_diode_left: Dt, backward_diode_right: _p, backward_diode_up: gp, battery_horz: Wt, battery_vert: Ap, boxresistor_down: Fp, boxresistor_left: Ep, boxresistor_right: Lp, boxresistor_small_down: jp, boxresistor_small_left: zp, boxresistor_small_right: Jp, boxresistor_small_up: Mp, boxresistor_up: Ip, bridged_ground_down: Dp, bridged_ground_left: Wp, bridged_ground_right: te, bridged_ground_up: Qp, capacitor_down: ta, capacitor_left: ea, capacitor_polarized_down: oa, capacitor_polarized_left: ia, capacitor_polarized_right: pa, capacitor_polarized_up: ya, capacitor_right: xa, capacitor_up: ma, constant_current_diode_down: fa, constant_current_diode_horz: ha, constant_current_diode_left: da, constant_current_diode_right: ba, constant_current_diode_up: ga, constant_current_diode_vert: va, crystal_4pin_down: wa, crystal_4pin_left: Aa, crystal_4pin_right: Pa, crystal_4pin_up: Sa, crystal_down: Ra, crystal_left: Ta, crystal_right: Ea, crystal_up: Xa, darlington_pair_transistor_down: La, darlington_pair_transistor_horz: Va, darlington_pair_transistor_left: ja, darlington_pair_transistor_right: ka, darlington_pair_transistor_up: za, darlington_pair_transistor_vert: Oa, dc_ammeter_horz: wt, dc_ammeter_vert: Ca, dc_voltmeter_down: Ia, dc_voltmeter_horz: qa, dc_voltmeter_left: Ua, dc_voltmeter_right: Wa, dc_voltmeter_up: Za, dc_voltmeter_vert: Ka, diac_down: ty, diac_horz: ey, diac_left: ry, diac_right: oy, diac_up: iy, diac_vert: ly, diode_down: ay, diode_left: yy, diode_right: $2, diode_up: xy, dpdt_normally_closed_switch_down: my, dpdt_normally_closed_switch_left: ny, dpdt_normally_closed_switch_right: M, dpdt_normally_closed_switch_up: fy, dpdt_switch_down: cy, dpdt_switch_left: dy, dpdt_switch_right: C, dpdt_switch_up: by, dpst_normally_closed_switch_down: gy, dpst_normally_closed_switch_left: uy, dpst_normally_closed_switch_right: N, dpst_normally_closed_switch_up: vy, dpst_switch_down: Ay, dpst_switch_left: Py, dpst_switch_right: I, dpst_switch_up: Sy, ferrite_bead_down: Ry, ferrite_bead_left: Ty, ferrite_bead_right: Fe, ferrite_bead_up: Se, filled_diode_down: Yy, filled_diode_horz: Ly, filled_diode_left: jy, filled_diode_right: zy, filled_diode_up: Jy, filled_diode_vert: My, frequency_meter_horz: At3, frequency_meter_vert: By, fuse_horz: ke, fuse_vert: Uy, ground_down: Gy, ground_horz: Wy, ground_left: Hy, ground_right: Zy, ground_up: Qy, ground_vert: Ky2, ground2_down: ex, ground2_left: ox, ground2_right: lx, ground2_up: ax, gunn_diode_horz: yx, gunn_diode_vert: xx, icled_down: mx, icled_left: nx, icled_right: q, icled_up: fx, igbt_transistor_horz: ze, igbt_transistor_vert: dx, illuminated_push_button_normally_open_horz: Oe, illuminated_push_button_normally_open_vert: ux, inductor_down: Px, inductor_left: Sx, inductor_right: _t, inductor_up: $e, laser_diode_down: Fx, laser_diode_left: Rx, laser_diode_right: D, laser_diode_up: Tx, led_down: Lx, led_left: Vx, led_right: gt, led_up: Ce, light_dependent_resistor_horz: Ie, light_dependent_resistor_vert: $x, mosfet_depletion_normally_on_horz: qe, mosfet_depletion_normally_on_vert: Ix, mushroom_head_normally_open_momentary_horz: Ue, mushroom_head_normally_open_momentary_vert: Ux, n_channel_d_mosfet_transistor_horz: He, n_channel_d_mosfet_transistor_vert: Qx, n_channel_e_mosfet_transistor_horz: Qe, n_channel_e_mosfet_transistor_vert: os5, njfet_transistor_horz: t0, njfet_transistor_vert: ys, not_connected_down: ms, not_connected_left: ns, not_connected_right: U, not_connected_up: fs32, npn_bipolar_transistor_down: hs, npn_bipolar_transistor_horz: cs, npn_bipolar_transistor_left: ds, npn_bipolar_transistor_right: bs, npn_bipolar_transistor_up: _s, npn_bipolar_transistor_vert: gs, opamp_no_power_down: vs, opamp_no_power_left: ws, opamp_no_power_right: G, opamp_no_power_up: As, opamp_with_power_down: Ss, opamp_with_power_left: Fs, opamp_with_power_right: W, opamp_with_power_up: Rs, p_channel_d_mosfet_transistor_horz: a0, p_channel_d_mosfet_transistor_vert: Ls, p_channel_e_mosfet_transistor_horz: x0, p_channel_e_mosfet_transistor_vert: Os, photodiode_horz: s0, photodiode_vert: Cs, pjfet_transistor_horz: n0, pjfet_transistor_vert: Ds, pnp_bipolar_transistor_down: Us, pnp_bipolar_transistor_horz: Gs, pnp_bipolar_transistor_left: Ws, pnp_bipolar_transistor_right: Hs, pnp_bipolar_transistor_up: Zs, pnp_bipolar_transistor_vert: Qs, potentiometer_horz: g0, potentiometer_vert: rm, potentiometer2_down: pm, potentiometer2_left: am, potentiometer2_right: H, potentiometer2_up: ym, potentiometer3_down: xm, potentiometer3_left: sm, potentiometer3_right: mm, potentiometer3_up: nm, power_factor_meter_horz: S0, power_factor_meter_vert: dm, push_button_normally_closed_momentary_horz: R0, push_button_normally_closed_momentary_vert: um, push_button_normally_open_momentary_horz: E0, push_button_normally_open_momentary_vert: Pm, rectifier_diode_horz: L0, rectifier_diode_vert: Rm, resistor_down: Em, resistor_left: Xm, resistor_right: Vm, resistor_up: km, resonator_down: Om, resonator_horz: M0, resonator_left: Jm, resonator_right: K, resonator_up: $m, resonator_vert: Mm, schottky_diode_down: Nm, schottky_diode_left: Im, schottky_diode_right: tt, schottky_diode_up: Bm, silicon_controlled_rectifier_horz: C0, silicon_controlled_rectifier_vert: Um, solderjumper2_bridged12_down: Gm, solderjumper2_bridged12_left: Wm, solderjumper2_bridged12_right: Hm, solderjumper2_bridged12_up: Zm, solderjumper2_down: Qm, solderjumper2_left: Km, solderjumper2_right: tn, solderjumper2_up: en, solderjumper3_bridged12_down: rn, solderjumper3_bridged12_left: on2, solderjumper3_bridged12_right: ln, solderjumper3_bridged12_up: pn, solderjumper3_bridged123_down: an, solderjumper3_bridged123_left: yn, solderjumper3_bridged123_right: xn, solderjumper3_bridged123_up: sn, solderjumper3_bridged23_down: mn, solderjumper3_bridged23_left: nn, solderjumper3_bridged23_right: fn, solderjumper3_bridged23_up: hn, solderjumper3_down: cn, solderjumper3_left: dn, solderjumper3_right: bn, solderjumper3_up: _n, spdt_normally_closed_switch_down: un, spdt_normally_closed_switch_left: vn, spdt_normally_closed_switch_right: at, spdt_normally_closed_switch_up: wn, spdt_switch_down: Pn, spdt_switch_left: Sn, spdt_switch_right: yt, spdt_switch_up: Fn, spst_normally_closed_switch_down: Rn, spst_normally_closed_switch_left: Tn, spst_normally_closed_switch_right: xt, spst_normally_closed_switch_up: En, spst_switch_down: Yn, spst_switch_left: Xn, spst_switch_right: st, spst_switch_up: Ln, square_wave_down: Vn, square_wave_left: jn, square_wave_right: kn, square_wave_up: zn, step_recovery_diode_horz: N0, step_recovery_diode_vert: On, tachometer_horz: Tt, tachometer_vert: Cn, testpoint_down: Bn, testpoint_left: qn, testpoint_right: nt, testpoint_up: Gn, tilted_ground_down: Hn, tilted_ground_left: Zn, tilted_ground_right: ut, tilted_ground_up: B0, triac_horz: q0, triac_vert: t1, tunnel_diode_horz: U0, tunnel_diode_vert: i1, unijunction_transistor_horz: W0, unijunction_transistor_vert: s1, usbc: n1, var_meter_horz: Z0, var_meter_vert: c1, varactor_diode_horz: K0, varactor_diode_vert: g1, varistor_horz: er, varistor_vert: A1, varmeter_horz: Et, varmeter_vert: R1, vcc_down: T1, vcc_left: E1, vcc_right: Y1, vcc_up: X1, volt_meter_horz: or, volt_meter_vert: L1, watt_hour_meter_horz: Yt, watt_hour_meter_vert: z1, wattmeter_horz: Xt, wattmeter_vert: M1, zener_diode_horz: ar, zener_diode_vert: B1 };
91926
92372
  var Y$ = Object.fromEntries(Object.keys(q1).map((t3) => [t3, t3]));
91927
92373
  function doesLineIntersectLine([a12, a22], [b12, b22], {
91928
92374
  lineThickness = 0
@@ -93952,11 +94398,11 @@ var require_react_reconciler_development = __commonJS2({
93952
94398
  fiber = fiber.next, id2--;
93953
94399
  return fiber;
93954
94400
  }
93955
- function copyWithSetImpl(obj, path33, index, value) {
93956
- if (index >= path33.length)
94401
+ function copyWithSetImpl(obj, path34, index, value) {
94402
+ if (index >= path34.length)
93957
94403
  return value;
93958
- var key = path33[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
93959
- updated[key] = copyWithSetImpl(obj[key], path33, index + 1, value);
94404
+ var key = path34[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
94405
+ updated[key] = copyWithSetImpl(obj[key], path34, index + 1, value);
93960
94406
  return updated;
93961
94407
  }
93962
94408
  function copyWithRename(obj, oldPath, newPath) {
@@ -93976,11 +94422,11 @@ var require_react_reconciler_development = __commonJS2({
93976
94422
  index + 1 === oldPath.length ? (updated[newPath[index]] = updated[oldKey], isArrayImpl(updated) ? updated.splice(oldKey, 1) : delete updated[oldKey]) : updated[oldKey] = copyWithRenameImpl(obj[oldKey], oldPath, newPath, index + 1);
93977
94423
  return updated;
93978
94424
  }
93979
- function copyWithDeleteImpl(obj, path33, index) {
93980
- var key = path33[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
93981
- if (index + 1 === path33.length)
94425
+ function copyWithDeleteImpl(obj, path34, index) {
94426
+ var key = path34[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
94427
+ if (index + 1 === path34.length)
93982
94428
  return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
93983
- updated[key] = copyWithDeleteImpl(obj[key], path33, index + 1);
94429
+ updated[key] = copyWithDeleteImpl(obj[key], path34, index + 1);
93984
94430
  return updated;
93985
94431
  }
93986
94432
  function shouldSuspendImpl() {
@@ -103011,29 +103457,29 @@ Check the top-level render call using <` + componentName2 + ">.");
103011
103457
  var didWarnAboutNestedUpdates = false;
103012
103458
  var didWarnAboutFindNodeInStrictMode = {};
103013
103459
  var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
103014
- overrideHookState = function(fiber, id2, path33, value) {
103460
+ overrideHookState = function(fiber, id2, path34, value) {
103015
103461
  id2 = findHook(fiber, id2);
103016
- id2 !== null && (path33 = copyWithSetImpl(id2.memoizedState, path33, 0, value), id2.memoizedState = path33, id2.baseState = path33, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path33 = enqueueConcurrentRenderForLane(fiber, 2), path33 !== null && scheduleUpdateOnFiber(path33, fiber, 2));
103462
+ id2 !== null && (path34 = copyWithSetImpl(id2.memoizedState, path34, 0, value), id2.memoizedState = path34, id2.baseState = path34, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path34 = enqueueConcurrentRenderForLane(fiber, 2), path34 !== null && scheduleUpdateOnFiber(path34, fiber, 2));
103017
103463
  };
103018
- overrideHookStateDeletePath = function(fiber, id2, path33) {
103464
+ overrideHookStateDeletePath = function(fiber, id2, path34) {
103019
103465
  id2 = findHook(fiber, id2);
103020
- id2 !== null && (path33 = copyWithDeleteImpl(id2.memoizedState, path33, 0), id2.memoizedState = path33, id2.baseState = path33, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path33 = enqueueConcurrentRenderForLane(fiber, 2), path33 !== null && scheduleUpdateOnFiber(path33, fiber, 2));
103466
+ id2 !== null && (path34 = copyWithDeleteImpl(id2.memoizedState, path34, 0), id2.memoizedState = path34, id2.baseState = path34, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path34 = enqueueConcurrentRenderForLane(fiber, 2), path34 !== null && scheduleUpdateOnFiber(path34, fiber, 2));
103021
103467
  };
103022
103468
  overrideHookStateRenamePath = function(fiber, id2, oldPath, newPath) {
103023
103469
  id2 = findHook(fiber, id2);
103024
103470
  id2 !== null && (oldPath = copyWithRename(id2.memoizedState, oldPath, newPath), id2.memoizedState = oldPath, id2.baseState = oldPath, fiber.memoizedProps = assign2({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), oldPath !== null && scheduleUpdateOnFiber(oldPath, fiber, 2));
103025
103471
  };
103026
- overrideProps = function(fiber, path33, value) {
103027
- fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path33, 0, value);
103472
+ overrideProps = function(fiber, path34, value) {
103473
+ fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path34, 0, value);
103028
103474
  fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
103029
- path33 = enqueueConcurrentRenderForLane(fiber, 2);
103030
- path33 !== null && scheduleUpdateOnFiber(path33, fiber, 2);
103475
+ path34 = enqueueConcurrentRenderForLane(fiber, 2);
103476
+ path34 !== null && scheduleUpdateOnFiber(path34, fiber, 2);
103031
103477
  };
103032
- overridePropsDeletePath = function(fiber, path33) {
103033
- fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path33, 0);
103478
+ overridePropsDeletePath = function(fiber, path34) {
103479
+ fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path34, 0);
103034
103480
  fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
103035
- path33 = enqueueConcurrentRenderForLane(fiber, 2);
103036
- path33 !== null && scheduleUpdateOnFiber(path33, fiber, 2);
103481
+ path34 = enqueueConcurrentRenderForLane(fiber, 2);
103482
+ path34 !== null && scheduleUpdateOnFiber(path34, fiber, 2);
103037
103483
  };
103038
103484
  overridePropsRenamePath = function(fiber, oldPath, newPath) {
103039
103485
  fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
@@ -118370,10 +118816,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
118370
118816
  var setErrorHandler = null;
118371
118817
  var setSuspenseHandler = null;
118372
118818
  {
118373
- var copyWithDeleteImpl = function(obj, path33, index2) {
118374
- var key = path33[index2];
118819
+ var copyWithDeleteImpl = function(obj, path34, index2) {
118820
+ var key = path34[index2];
118375
118821
  var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
118376
- if (index2 + 1 === path33.length) {
118822
+ if (index2 + 1 === path34.length) {
118377
118823
  if (isArray2(updated)) {
118378
118824
  updated.splice(key, 1);
118379
118825
  } else {
@@ -118381,11 +118827,11 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
118381
118827
  }
118382
118828
  return updated;
118383
118829
  }
118384
- updated[key] = copyWithDeleteImpl(obj[key], path33, index2 + 1);
118830
+ updated[key] = copyWithDeleteImpl(obj[key], path34, index2 + 1);
118385
118831
  return updated;
118386
118832
  };
118387
- var copyWithDelete = function(obj, path33) {
118388
- return copyWithDeleteImpl(obj, path33, 0);
118833
+ var copyWithDelete = function(obj, path34) {
118834
+ return copyWithDeleteImpl(obj, path34, 0);
118389
118835
  };
118390
118836
  var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
118391
118837
  var oldKey = oldPath[index2];
@@ -118417,17 +118863,17 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
118417
118863
  }
118418
118864
  return copyWithRenameImpl(obj, oldPath, newPath, 0);
118419
118865
  };
118420
- var copyWithSetImpl = function(obj, path33, index2, value) {
118421
- if (index2 >= path33.length) {
118866
+ var copyWithSetImpl = function(obj, path34, index2, value) {
118867
+ if (index2 >= path34.length) {
118422
118868
  return value;
118423
118869
  }
118424
- var key = path33[index2];
118870
+ var key = path34[index2];
118425
118871
  var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
118426
- updated[key] = copyWithSetImpl(obj[key], path33, index2 + 1, value);
118872
+ updated[key] = copyWithSetImpl(obj[key], path34, index2 + 1, value);
118427
118873
  return updated;
118428
118874
  };
118429
- var copyWithSet = function(obj, path33, value) {
118430
- return copyWithSetImpl(obj, path33, 0, value);
118875
+ var copyWithSet = function(obj, path34, value) {
118876
+ return copyWithSetImpl(obj, path34, 0, value);
118431
118877
  };
118432
118878
  var findHook = function(fiber, id2) {
118433
118879
  var currentHook2 = fiber.memoizedState;
@@ -118437,10 +118883,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
118437
118883
  }
118438
118884
  return currentHook2;
118439
118885
  };
118440
- overrideHookState = function(fiber, id2, path33, value) {
118886
+ overrideHookState = function(fiber, id2, path34, value) {
118441
118887
  var hook = findHook(fiber, id2);
118442
118888
  if (hook !== null) {
118443
- var newState = copyWithSet(hook.memoizedState, path33, value);
118889
+ var newState = copyWithSet(hook.memoizedState, path34, value);
118444
118890
  hook.memoizedState = newState;
118445
118891
  hook.baseState = newState;
118446
118892
  fiber.memoizedProps = assign2({}, fiber.memoizedProps);
@@ -118450,10 +118896,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
118450
118896
  }
118451
118897
  }
118452
118898
  };
118453
- overrideHookStateDeletePath = function(fiber, id2, path33) {
118899
+ overrideHookStateDeletePath = function(fiber, id2, path34) {
118454
118900
  var hook = findHook(fiber, id2);
118455
118901
  if (hook !== null) {
118456
- var newState = copyWithDelete(hook.memoizedState, path33);
118902
+ var newState = copyWithDelete(hook.memoizedState, path34);
118457
118903
  hook.memoizedState = newState;
118458
118904
  hook.baseState = newState;
118459
118905
  fiber.memoizedProps = assign2({}, fiber.memoizedProps);
@@ -118476,8 +118922,8 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
118476
118922
  }
118477
118923
  }
118478
118924
  };
118479
- overrideProps = function(fiber, path33, value) {
118480
- fiber.pendingProps = copyWithSet(fiber.memoizedProps, path33, value);
118925
+ overrideProps = function(fiber, path34, value) {
118926
+ fiber.pendingProps = copyWithSet(fiber.memoizedProps, path34, value);
118481
118927
  if (fiber.alternate) {
118482
118928
  fiber.alternate.pendingProps = fiber.pendingProps;
118483
118929
  }
@@ -118486,8 +118932,8 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
118486
118932
  scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
118487
118933
  }
118488
118934
  };
118489
- overridePropsDeletePath = function(fiber, path33) {
118490
- fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path33);
118935
+ overridePropsDeletePath = function(fiber, path34) {
118936
+ fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path34);
118491
118937
  if (fiber.alternate) {
118492
118938
  fiber.alternate.pendingProps = fiber.pendingProps;
118493
118939
  }
@@ -124538,7 +124984,7 @@ var parsePin = (pinString) => {
124538
124984
  const colorMatch = pinString.match(/#[0-9A-F]{6}/);
124539
124985
  const labelColor = colorMatch ? colorMatch[0] : "";
124540
124986
  const pathMatch = pinString.match(/\^\^([^~]+)/);
124541
- const path33 = pathMatch ? pathMatch[1] : "";
124987
+ const path34 = pathMatch ? pathMatch[1] : "";
124542
124988
  const arrowMatch = pinString.match(/\^\^0~(.+)$/);
124543
124989
  const arrow = arrowMatch ? arrowMatch[1] : "";
124544
124990
  const r3 = Number.parseFloat(rotation2);
@@ -124552,7 +124998,7 @@ var parsePin = (pinString) => {
124552
124998
  rotation: Number.isNaN(r3) ? 0 : r3,
124553
124999
  label,
124554
125000
  labelColor,
124555
- path: path33,
125001
+ path: path34,
124556
125002
  arrow
124557
125003
  };
124558
125004
  };
@@ -124992,15 +125438,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
124992
125438
  }
124993
125439
  }
124994
125440
  const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
124995
- const path33 = [];
125441
+ const path34 = [];
124996
125442
  for (let i = 0;i <= numPoints; i++) {
124997
125443
  const t3 = i / numPoints;
124998
125444
  const angle2 = startAngle + t3 * (endAngle - startAngle);
124999
125445
  const x = centerX + radius * Math.cos(angle2);
125000
125446
  const y = centerY + radius * Math.sin(angle2);
125001
- path33.push({ x, y });
125447
+ path34.push({ x, y });
125002
125448
  }
125003
- return path33;
125449
+ return path34;
125004
125450
  }
125005
125451
  var __defProp4 = Object.defineProperty;
125006
125452
  var __export22 = (target, all) => {
@@ -126418,7 +126864,7 @@ var platedHoleWithRectPad = (pn2, x, y, holeDiameter, rectPadWidth, rectPadHeigh
126418
126864
  };
126419
126865
  };
126420
126866
  var silkscreenPin = ({
126421
- fs: fs32,
126867
+ fs: fs33,
126422
126868
  pn: pn2,
126423
126869
  anchor_x,
126424
126870
  anchor_y,
@@ -126461,7 +126907,7 @@ var silkscreenPin = ({
126461
126907
  type: "pcb_silkscreen_text",
126462
126908
  pcb_silkscreen_text_id: "silkscreen_text_1",
126463
126909
  font: "tscircuit2024",
126464
- font_size: fs32,
126910
+ font_size: fs33,
126465
126911
  pcb_component_id: "pcb_component_1",
126466
126912
  text: `{PIN${pn2}}`,
126467
126913
  layer,
@@ -134077,17 +134523,17 @@ var ObstacleList = class {
134077
134523
  return obstacles;
134078
134524
  }
134079
134525
  };
134080
- function removePathLoops(path33) {
134081
- if (path33.length < 4)
134082
- return path33;
134083
- const result = [{ ...path33[0] }];
134084
- let currentLayer = path33[0].layer;
134085
- for (let i = 1;i < path33.length; i++) {
134086
- const currentSegment = { start: path33[i - 1], end: path33[i] };
134087
- const isVia = path33[i].route_type === "via" || path33[i - 1].route_type === "via";
134088
- if (path33[i].layer !== currentLayer || isVia) {
134089
- result.push({ ...path33[i] });
134090
- currentLayer = path33[i].layer;
134526
+ function removePathLoops(path34) {
134527
+ if (path34.length < 4)
134528
+ return path34;
134529
+ const result = [{ ...path34[0] }];
134530
+ let currentLayer = path34[0].layer;
134531
+ for (let i = 1;i < path34.length; i++) {
134532
+ const currentSegment = { start: path34[i - 1], end: path34[i] };
134533
+ const isVia = path34[i].route_type === "via" || path34[i - 1].route_type === "via";
134534
+ if (path34[i].layer !== currentLayer || isVia) {
134535
+ result.push({ ...path34[i] });
134536
+ currentLayer = path34[i].layer;
134091
134537
  continue;
134092
134538
  }
134093
134539
  let intersectionFound = false;
@@ -134116,8 +134562,8 @@ function removePathLoops(path33) {
134116
134562
  result.push(intersectionPoint);
134117
134563
  }
134118
134564
  const lastPoint = result[result.length - 1];
134119
- if (lastPoint.x !== path33[i].x || lastPoint.y !== path33[i].y) {
134120
- result.push(path33[i]);
134565
+ if (lastPoint.x !== path34[i].x || lastPoint.y !== path34[i].y) {
134566
+ result.push(path34[i]);
134121
134567
  }
134122
134568
  }
134123
134569
  return result;
@@ -134606,10 +135052,10 @@ var GeneralizedAstarAutorouter = class {
134606
135052
  });
134607
135053
  }
134608
135054
  if (current2.parent) {
134609
- const path33 = [];
135055
+ const path34 = [];
134610
135056
  let p = current2;
134611
135057
  while (p) {
134612
- path33.unshift(p);
135058
+ path34.unshift(p);
134613
135059
  p = p.parent;
134614
135060
  }
134615
135061
  debugSolution.push({
@@ -134617,7 +135063,7 @@ var GeneralizedAstarAutorouter = class {
134617
135063
  pcb_component_id: "",
134618
135064
  pcb_fabrication_note_path_id: `note_path_${current2.x}_${current2.y}`,
134619
135065
  layer: "top",
134620
- route: path33,
135066
+ route: path34,
134621
135067
  stroke_width: 0.01
134622
135068
  });
134623
135069
  }
@@ -139539,13 +139985,13 @@ var RBush = class {
139539
139985
  return this;
139540
139986
  let node = this.data;
139541
139987
  const bbox = this.toBBox(item);
139542
- const path33 = [];
139988
+ const path34 = [];
139543
139989
  const indexes = [];
139544
139990
  let i, parent, goingUp;
139545
- while (node || path33.length) {
139991
+ while (node || path34.length) {
139546
139992
  if (!node) {
139547
- node = path33.pop();
139548
- parent = path33[path33.length - 1];
139993
+ node = path34.pop();
139994
+ parent = path34[path34.length - 1];
139549
139995
  i = indexes.pop();
139550
139996
  goingUp = true;
139551
139997
  }
@@ -139553,13 +139999,13 @@ var RBush = class {
139553
139999
  const index = findItem(item, node.children, equalsFn);
139554
140000
  if (index !== -1) {
139555
140001
  node.children.splice(index, 1);
139556
- path33.push(node);
139557
- this._condense(path33);
140002
+ path34.push(node);
140003
+ this._condense(path34);
139558
140004
  return this;
139559
140005
  }
139560
140006
  }
139561
140007
  if (!goingUp && !node.leaf && contains(node, bbox)) {
139562
- path33.push(node);
140008
+ path34.push(node);
139563
140009
  indexes.push(i);
139564
140010
  i = 0;
139565
140011
  parent = node;
@@ -139630,10 +140076,10 @@ var RBush = class {
139630
140076
  calcBBox(node, this.toBBox);
139631
140077
  return node;
139632
140078
  }
139633
- _chooseSubtree(bbox, node, level, path33) {
140079
+ _chooseSubtree(bbox, node, level, path34) {
139634
140080
  while (true) {
139635
- path33.push(node);
139636
- if (node.leaf || path33.length - 1 === level)
140081
+ path34.push(node);
140082
+ if (node.leaf || path34.length - 1 === level)
139637
140083
  break;
139638
140084
  let minArea = Infinity;
139639
140085
  let minEnlargement = Infinity;
@@ -139742,21 +140188,21 @@ var RBush = class {
139742
140188
  }
139743
140189
  return margin;
139744
140190
  }
139745
- _adjustParentBBoxes(bbox, path33, level) {
140191
+ _adjustParentBBoxes(bbox, path34, level) {
139746
140192
  for (let i = level;i >= 0; i--) {
139747
- extend(path33[i], bbox);
140193
+ extend(path34[i], bbox);
139748
140194
  }
139749
140195
  }
139750
- _condense(path33) {
139751
- for (let i = path33.length - 1, siblings;i >= 0; i--) {
139752
- if (path33[i].children.length === 0) {
140196
+ _condense(path34) {
140197
+ for (let i = path34.length - 1, siblings;i >= 0; i--) {
140198
+ if (path34[i].children.length === 0) {
139753
140199
  if (i > 0) {
139754
- siblings = path33[i - 1].children;
139755
- siblings.splice(siblings.indexOf(path33[i]), 1);
140200
+ siblings = path34[i - 1].children;
140201
+ siblings.splice(siblings.indexOf(path34[i]), 1);
139756
140202
  } else
139757
140203
  this.clear();
139758
140204
  } else
139759
- calcBBox(path33[i], this.toBBox);
140205
+ calcBBox(path34[i], this.toBBox);
139760
140206
  }
139761
140207
  }
139762
140208
  };
@@ -140901,7 +141347,7 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
140901
141347
  this.capacityPaths = capacityPaths;
140902
141348
  this.colorMap = colorMap ?? {};
140903
141349
  this.unprocessedNodeIds = [
140904
- ...new Set(capacityPaths.flatMap((path33) => path33.nodeIds))
141350
+ ...new Set(capacityPaths.flatMap((path34) => path34.nodeIds))
140905
141351
  ];
140906
141352
  this.nodePortSegments = /* @__PURE__ */ new Map;
140907
141353
  }
@@ -140912,17 +141358,17 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
140912
141358
  return;
140913
141359
  }
140914
141360
  const pathsGoingThroughNode = [];
140915
- for (const path33 of this.capacityPaths) {
140916
- const indexOfNodeInPath = path33.nodeIds.indexOf(nodeId);
141361
+ for (const path34 of this.capacityPaths) {
141362
+ const indexOfNodeInPath = path34.nodeIds.indexOf(nodeId);
140917
141363
  if (indexOfNodeInPath !== -1) {
140918
- pathsGoingThroughNode.push({ path: path33, indexOfNodeInPath });
141364
+ pathsGoingThroughNode.push({ path: path34, indexOfNodeInPath });
140919
141365
  }
140920
141366
  }
140921
141367
  const node = this.nodeMap.get(nodeId);
140922
141368
  const nodePortSegments = [];
140923
- for (const { path: path33, indexOfNodeInPath } of pathsGoingThroughNode) {
140924
- const entryNodeId = path33.nodeIds[indexOfNodeInPath - 1];
140925
- const exitNodeId = path33.nodeIds[indexOfNodeInPath + 1];
141369
+ for (const { path: path34, indexOfNodeInPath } of pathsGoingThroughNode) {
141370
+ const entryNodeId = path34.nodeIds[indexOfNodeInPath - 1];
141371
+ const exitNodeId = path34.nodeIds[indexOfNodeInPath + 1];
140926
141372
  for (const adjNodeId of [entryNodeId, exitNodeId]) {
140927
141373
  const adjNode = this.nodeMap.get(adjNodeId);
140928
141374
  if (!adjNode)
@@ -140935,7 +141381,7 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
140935
141381
  capacityMeshNodeId: nodeId,
140936
141382
  start: segment2.start,
140937
141383
  end: segment2.end,
140938
- connectionNames: [path33.connectionName],
141384
+ connectionNames: [path34.connectionName],
140939
141385
  availableZ: mutuallyAvailableZ
140940
141386
  };
140941
141387
  nodePortSegments.push(portSegment);
@@ -141741,37 +142187,37 @@ var SingleHighDensityRouteSolver = class extends BaseSolver {
141741
142187
  return neighbors;
141742
142188
  }
141743
142189
  getNodePath(node) {
141744
- const path33 = [];
142190
+ const path34 = [];
141745
142191
  while (node) {
141746
- path33.push(node);
142192
+ path34.push(node);
141747
142193
  node = node.parent;
141748
142194
  }
141749
- return path33;
142195
+ return path34;
141750
142196
  }
141751
142197
  getViasInNodePath(node) {
141752
- const path33 = this.getNodePath(node);
142198
+ const path34 = this.getNodePath(node);
141753
142199
  const vias = [];
141754
- for (let i = 0;i < path33.length - 1; i++) {
141755
- if (path33[i].z !== path33[i + 1].z) {
141756
- vias.push({ x: path33[i].x, y: path33[i].y });
142200
+ for (let i = 0;i < path34.length - 1; i++) {
142201
+ if (path34[i].z !== path34[i + 1].z) {
142202
+ vias.push({ x: path34[i].x, y: path34[i].y });
141757
142203
  }
141758
142204
  }
141759
142205
  return vias;
141760
142206
  }
141761
142207
  setSolvedPath(node) {
141762
- const path33 = this.getNodePath(node);
141763
- path33.reverse();
142208
+ const path34 = this.getNodePath(node);
142209
+ path34.reverse();
141764
142210
  const vias = [];
141765
- for (let i = 0;i < path33.length - 1; i++) {
141766
- if (path33[i].z !== path33[i + 1].z) {
141767
- vias.push({ x: path33[i].x, y: path33[i].y });
142211
+ for (let i = 0;i < path34.length - 1; i++) {
142212
+ if (path34[i].z !== path34[i + 1].z) {
142213
+ vias.push({ x: path34[i].x, y: path34[i].y });
141768
142214
  }
141769
142215
  }
141770
142216
  this.solvedPath = {
141771
142217
  connectionName: this.connectionName,
141772
142218
  traceThickness: this.traceThickness,
141773
142219
  viaDiameter: this.viaDiameter,
141774
- route: path33.map((node2) => ({ x: node2.x, y: node2.y, z: node2.z })).concat([this.B]),
142220
+ route: path34.map((node2) => ({ x: node2.x, y: node2.y, z: node2.z })).concat([this.B]),
141775
142221
  vias
141776
142222
  };
141777
142223
  }
@@ -142579,12 +143025,12 @@ function computeDumbbellPaths({
142579
143025
  specialType: circleCenter === A3 ? "A" : "B"
142580
143026
  };
142581
143027
  };
142582
- const subdivideOptimalPath = (path33, numSubdivisions) => {
142583
- if (path33.length < 2)
142584
- return path33;
142585
- const result = [path33[0]];
142586
- for (let i = 0;i < path33.length - 1; i++) {
142587
- const segment2 = { start: path33[i], end: path33[i + 1] };
143028
+ const subdivideOptimalPath = (path34, numSubdivisions) => {
143029
+ if (path34.length < 2)
143030
+ return path34;
143031
+ const result = [path34[0]];
143032
+ for (let i = 0;i < path34.length - 1; i++) {
143033
+ const segment2 = { start: path34[i], end: path34[i + 1] };
142588
143034
  const segmentMidpoint = {
142589
143035
  x: (segment2.start.x + segment2.end.x) / 2,
142590
143036
  y: (segment2.start.y + segment2.end.y) / 2
@@ -142646,7 +143092,7 @@ function computeDumbbellPaths({
142646
143092
  }
142647
143093
  subdivisionPoints.forEach((p) => result.push(p));
142648
143094
  }
142649
- result.push(path33[i + 1]);
143095
+ result.push(path34[i + 1]);
142650
143096
  }
142651
143097
  if (result.length > 1) {
142652
143098
  const filteredResult = [result[0]];
@@ -142881,13 +143327,13 @@ function computeDumbbellPaths({
142881
143327
  ].map((l, index) => ({ ...l, index }));
142882
143328
  };
142883
143329
  const subdivideJLinePath = (jLine, oppositePoint, r3, m2, numSubdivisions) => {
142884
- const path33 = jLine.points;
142885
- if (path33.length < 2)
142886
- return path33;
143330
+ const path34 = jLine.points;
143331
+ if (path34.length < 2)
143332
+ return path34;
142887
143333
  const minDistThreshold = r3 + m2;
142888
- const result = [path33[0]];
142889
- for (let i = 0;i < path33.length - 1; i++) {
142890
- const segment2 = { start: path33[i], end: path33[i + 1] };
143334
+ const result = [path34[0]];
143335
+ for (let i = 0;i < path34.length - 1; i++) {
143336
+ const segment2 = { start: path34[i], end: path34[i + 1] };
142891
143337
  const distToOpposite = pointToSegmentDistance22(oppositePoint, segment2.start, segment2.end);
142892
143338
  if (distToOpposite < minDistThreshold) {
142893
143339
  const closestPt = closestPointOnSegment(segment2, oppositePoint);
@@ -142956,26 +143402,26 @@ function computeDumbbellPaths({
142956
143402
  return { index: 0, path: [] };
142957
143403
  }
142958
143404
  const optimalPath2 = validPaths.sort((a, b3) => a.length - b3.length)[0];
142959
- const path33 = [...optimalPath2.path];
142960
- const firstPoint = path33[0];
142961
- const dist3 = distance3(firstPoint, path33[2]);
142962
- const dist4 = distance3(firstPoint, path33[3]);
143405
+ const path34 = [...optimalPath2.path];
143406
+ const firstPoint = path34[0];
143407
+ const dist3 = distance3(firstPoint, path34[2]);
143408
+ const dist4 = distance3(firstPoint, path34[3]);
142963
143409
  const closerIdx = dist3 < dist4 ? 2 : 3;
142964
- if (dist3 < distance3(firstPoint, path33[1]) || dist4 < distance3(firstPoint, path33[1])) {
142965
- path33.splice(1, closerIdx - 1);
143410
+ if (dist3 < distance3(firstPoint, path34[1]) || dist4 < distance3(firstPoint, path34[1])) {
143411
+ path34.splice(1, closerIdx - 1);
142966
143412
  }
142967
- const lastPoint = path33[path33.length - 1];
142968
- const distM3 = distance3(lastPoint, path33[path33.length - 3]);
142969
- const distM4 = distance3(lastPoint, path33[path33.length - 4]);
142970
- const closerLastIdx = distM3 < distM4 ? path33.length - 3 : path33.length - 4;
142971
- if (distM3 < distance3(lastPoint, path33[path33.length - 2]) || distM4 < distance3(lastPoint, path33[path33.length - 2])) {
142972
- path33.splice(closerLastIdx + 1, path33.length - closerLastIdx - 2);
143413
+ const lastPoint = path34[path34.length - 1];
143414
+ const distM3 = distance3(lastPoint, path34[path34.length - 3]);
143415
+ const distM4 = distance3(lastPoint, path34[path34.length - 4]);
143416
+ const closerLastIdx = distM3 < distM4 ? path34.length - 3 : path34.length - 4;
143417
+ if (distM3 < distance3(lastPoint, path34[path34.length - 2]) || distM4 < distance3(lastPoint, path34[path34.length - 2])) {
143418
+ path34.splice(closerLastIdx + 1, path34.length - closerLastIdx - 2);
142973
143419
  }
142974
143420
  return {
142975
143421
  index: optimalPath2.index,
142976
- path: path33,
142977
- startsAt: path33[0] === C2 ? "C" : "D",
142978
- goesTo: path33[path33.length - 1] === C2 ? "C" : "D"
143422
+ path: path34,
143423
+ startsAt: path34[0] === C2 ? "C" : "D",
143424
+ goesTo: path34[path34.length - 1] === C2 ? "C" : "D"
142979
143425
  };
142980
143426
  };
142981
143427
  const optimalPath = findOptimalPath();
@@ -144395,9 +144841,9 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
144395
144841
  let closestIntersection = null;
144396
144842
  let intersectedSegmentZ = null;
144397
144843
  const checkIntersectionsWithPathMap = (pathMap) => {
144398
- for (const path33 of pathMap.values()) {
144399
- for (let i = 0;i < path33.length - 1; i++) {
144400
- const segment2 = [path33[i], path33[i + 1]];
144844
+ for (const path34 of pathMap.values()) {
144845
+ for (let i = 0;i < path34.length - 1; i++) {
144846
+ const segment2 = [path34[i], path34[i + 1]];
144401
144847
  if (segment2[0].x === segment2[1].x && segment2[0].y === segment2[1].y) {
144402
144848
  continue;
144403
144849
  }
@@ -144527,11 +144973,11 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
144527
144973
  });
144528
144974
  }
144529
144975
  const drawPath = (pathMap, labelPrefix) => {
144530
- for (const [connectionName, path33] of pathMap.entries()) {
144976
+ for (const [connectionName, path34] of pathMap.entries()) {
144531
144977
  const color = colorMap[connectionName] ?? "black";
144532
- for (let i = 0;i < path33.length - 1; i++) {
144533
- const p12 = path33[i];
144534
- const p2 = path33[i + 1];
144978
+ for (let i = 0;i < path34.length - 1; i++) {
144979
+ const p12 = path34[i];
144980
+ const p2 = path34[i + 1];
144535
144981
  if (p12.x === p2.x && p12.y === p2.y && p12.z !== p2.z) {
144536
144982
  graphics.circles.push({
144537
144983
  center: { x: p12.x, y: p12.y },
@@ -145129,10 +145575,10 @@ function detectMultiConnectionClosedFacesWithoutVias(polyLines, bounds) {
145129
145575
  const allSegments = [];
145130
145576
  const viaPoints = /* @__PURE__ */ new Map;
145131
145577
  for (const polyLine of polyLines) {
145132
- const path33 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
145133
- for (let i = 0;i < path33.length - 1; i++) {
145134
- const p12 = path33[i];
145135
- const p2 = path33[i + 1];
145578
+ const path34 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
145579
+ for (let i = 0;i < path34.length - 1; i++) {
145580
+ const p12 = path34[i];
145581
+ const p2 = path34[i + 1];
145136
145582
  const layer = p12.z2;
145137
145583
  allSegments.push({
145138
145584
  start: { x: p12.x, y: p12.y },
@@ -145150,7 +145596,7 @@ function detectMultiConnectionClosedFacesWithoutVias(polyLines, bounds) {
145150
145596
  }
145151
145597
  }
145152
145598
  }
145153
- const lastPoint = path33[path33.length - 1];
145599
+ const lastPoint = path34[path34.length - 1];
145154
145600
  if (lastPoint.z1 !== lastPoint.z2) {
145155
145601
  const key = pointKey2(lastPoint);
145156
145602
  if (!viaPoints.has(key)) {
@@ -145449,14 +145895,14 @@ var MultiHeadPolyLineIntraNodeSolver = class extends BaseSolver {
145449
145895
  const polyLineVias = [];
145450
145896
  for (let i = 0;i < polyLines.length; i++) {
145451
145897
  const polyLine = polyLines[i];
145452
- const path33 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
145898
+ const path34 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
145453
145899
  const segmentsByLayer = new Map(this.availableZ.map((z852) => [z852, []]));
145454
- for (let i22 = 0;i22 < path33.length - 1; i22++) {
145455
- const segment2 = [path33[i22], path33[i22 + 1]];
145900
+ for (let i22 = 0;i22 < path34.length - 1; i22++) {
145901
+ const segment2 = [path34[i22], path34[i22 + 1]];
145456
145902
  segmentsByLayer.get(segment2[0].z2).push(segment2);
145457
145903
  }
145458
145904
  polyLineSegmentsByLayer.push(segmentsByLayer);
145459
- polyLineVias.push(path33.filter((p) => p.z1 !== p.z2));
145905
+ polyLineVias.push(path34.filter((p) => p.z1 !== p.z2));
145460
145906
  }
145461
145907
  for (let i = 0;i < polyLines.length; i++) {
145462
145908
  const path1SegmentsByLayer = polyLineSegmentsByLayer[i];
@@ -146885,7 +147331,7 @@ var HighDensitySolver = class extends BaseSolver {
146885
147331
  if (this.failedSolvers.length > 0) {
146886
147332
  this.solved = false;
146887
147333
  this.failed = true;
146888
- this.error = `Failed to solve ${this.failedSolvers.length} nodes, ${this.failedSolvers.slice(0, 5).map((fs32) => fs32.nodeWithPortPoints.capacityMeshNodeId)}. err0: ${this.failedSolvers[0].error}.`;
147334
+ this.error = `Failed to solve ${this.failedSolvers.length} nodes, ${this.failedSolvers.slice(0, 5).map((fs33) => fs33.nodeWithPortPoints.capacityMeshNodeId)}. err0: ${this.failedSolvers[0].error}.`;
146889
147335
  return;
146890
147336
  }
146891
147337
  this.solved = true;
@@ -149666,13 +150112,13 @@ var CapacityPathingSolver = class extends BaseSolver {
149666
150112
  return this.getDistanceBetweenNodes(node, endGoal);
149667
150113
  }
149668
150114
  getBacktrackedPath(candidate) {
149669
- const path33 = [];
150115
+ const path34 = [];
149670
150116
  let currentCandidate = candidate;
149671
150117
  while (currentCandidate) {
149672
- path33.push(currentCandidate.node);
150118
+ path34.push(currentCandidate.node);
149673
150119
  currentCandidate = currentCandidate.prevCandidate;
149674
150120
  }
149675
- return path33;
150121
+ return path34;
149676
150122
  }
149677
150123
  getNeighboringNodes(node) {
149678
150124
  return this.nodeEdgeMap.get(node.capacityMeshNodeId).flatMap((edge) => edge.nodeIds.filter((n3) => n3 !== node.capacityMeshNodeId)).map((n3) => this.nodeMap.get(n3));
@@ -149680,12 +150126,12 @@ var CapacityPathingSolver = class extends BaseSolver {
149680
150126
  getCapacityPaths() {
149681
150127
  const capacityPaths = [];
149682
150128
  for (const connection of this.connectionsWithNodes) {
149683
- const path33 = connection.path;
149684
- if (path33) {
150129
+ const path34 = connection.path;
150130
+ if (path34) {
149685
150131
  capacityPaths.push({
149686
150132
  capacityPathId: connection.connection.name,
149687
150133
  connectionName: connection.connection.name,
149688
- nodeIds: path33.map((node) => node.capacityMeshNodeId)
150134
+ nodeIds: path34.map((node) => node.capacityMeshNodeId)
149689
150135
  });
149690
150136
  }
149691
150137
  }
@@ -150370,10 +150816,10 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
150370
150816
  return this.getDistanceBetweenNodes(node, endGoal) + this.getNodeCapacityPenalty(node);
150371
150817
  }
150372
150818
  getBacktrackedPath(candidate) {
150373
- const path33 = [];
150819
+ const path34 = [];
150374
150820
  let currentCandidate = candidate;
150375
150821
  while (currentCandidate) {
150376
- path33.push(currentCandidate.node);
150822
+ path34.push(currentCandidate.node);
150377
150823
  if (this.nodeMap.has(currentCandidate.node.capacityMeshNodeId)) {
150378
150824
  currentCandidate = currentCandidate.prevCandidate;
150379
150825
  } else {
@@ -150381,7 +150827,7 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
150381
150827
  break;
150382
150828
  }
150383
150829
  }
150384
- return path33.reverse();
150830
+ return path34.reverse();
150385
150831
  }
150386
150832
  getNeighboringNodes(node) {
150387
150833
  if (!this.nodeMap.has(node.capacityMeshNodeId))
@@ -150396,8 +150842,8 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
150396
150842
  doesNodeHaveCapacityForTrace(node, prevNode) {
150397
150843
  return true;
150398
150844
  }
150399
- reduceCapacityAlongPath(path33) {
150400
- for (const pathNode of path33) {
150845
+ reduceCapacityAlongPath(path34) {
150846
+ for (const pathNode of path34) {
150401
150847
  if (this.usedNodeCapacityMap.has(pathNode.capacityMeshNodeId)) {
150402
150848
  const nodeId = pathNode.capacityMeshNodeId;
150403
150849
  const nodeInSection = this.nodeMap.get(nodeId);
@@ -150526,9 +150972,9 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
150526
150972
  this.queuedNodes = null;
150527
150973
  }
150528
150974
  _handleGoalReached(currentCandidate, currentTerminal, endNode) {
150529
- const path33 = this.getBacktrackedPath(currentCandidate);
150530
- currentTerminal.path = path33;
150531
- this.reduceCapacityAlongPath(path33);
150975
+ const path34 = this.getBacktrackedPath(currentCandidate);
150976
+ currentTerminal.path = path34;
150977
+ this.reduceCapacityAlongPath(path34);
150532
150978
  this.currentConnectionIndex++;
150533
150979
  this.candidates = null;
150534
150980
  this.visitedNodes = null;
@@ -150577,10 +151023,10 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
150577
151023
  const connectionColor = this.colorMap[connectionName] ?? "purple";
150578
151024
  topCandidates.forEach((candidate, index) => {
150579
151025
  const opacity = 0.8 * (1 - index / 5);
150580
- const path33 = this.getBacktrackedPath(candidate);
150581
- if (path33.length > 0) {
151026
+ const path34 = this.getBacktrackedPath(candidate);
151027
+ if (path34.length > 0) {
150582
151028
  baseGraphics.lines.push({
150583
- points: path33.map(({ center: { x, y } }) => ({ x, y })),
151029
+ points: path34.map(({ center: { x, y } }) => ({ x, y })),
150584
151030
  strokeColor: safeTransparentize(connectionColor, 1 - opacity),
150585
151031
  strokeWidth: 0.05
150586
151032
  });
@@ -151269,12 +151715,12 @@ var CapacityPathingMultiSectionSolver = class extends BaseSolver {
151269
151715
  getCapacityPaths() {
151270
151716
  const capacityPaths = [];
151271
151717
  for (const connection of this.connectionsWithNodes) {
151272
- const path33 = connection.path;
151273
- if (path33) {
151718
+ const path34 = connection.path;
151719
+ if (path34) {
151274
151720
  capacityPaths.push({
151275
151721
  capacityPathId: connection.connection.name,
151276
151722
  connectionName: connection.connection.name,
151277
- nodeIds: path33.map((node) => node.capacityMeshNodeId)
151723
+ nodeIds: path34.map((node) => node.capacityMeshNodeId)
151278
151724
  });
151279
151725
  }
151280
151726
  }
@@ -152295,22 +152741,22 @@ var SingleSimplifiedPathSolver5 = class extends SingleSimplifiedPathSolver {
152295
152741
  return null;
152296
152742
  }
152297
152743
  const possiblePaths = calculate45DegreePaths({ x: start.x, y: start.y }, { x: end.x, y: end.y });
152298
- for (const path33 of possiblePaths) {
152299
- const fullPath = path33.map((p) => ({ x: p.x, y: p.y, z: start.z }));
152744
+ for (const path34 of possiblePaths) {
152745
+ const fullPath = path34.map((p) => ({ x: p.x, y: p.y, z: start.z }));
152300
152746
  if (this.isValidPath(fullPath)) {
152301
152747
  return fullPath;
152302
152748
  }
152303
152749
  }
152304
152750
  return null;
152305
152751
  }
152306
- addPathToResult(path33) {
152307
- if (path33.length === 0)
152752
+ addPathToResult(path34) {
152753
+ if (path34.length === 0)
152308
152754
  return;
152309
- for (let i = 0;i < path33.length; i++) {
152310
- if (i === 0 && this.newRoute.length > 0 && this.arePointsEqual(this.newRoute[this.newRoute.length - 1], path33[i])) {
152755
+ for (let i = 0;i < path34.length; i++) {
152756
+ if (i === 0 && this.newRoute.length > 0 && this.arePointsEqual(this.newRoute[this.newRoute.length - 1], path34[i])) {
152311
152757
  continue;
152312
152758
  }
152313
- this.newRoute.push(path33[i]);
152759
+ this.newRoute.push(path34[i]);
152314
152760
  }
152315
152761
  this.currentStepSize = this.maxStepSize;
152316
152762
  }
@@ -179717,7 +180163,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
179717
180163
  for (let i = 0;i < portsWithPosition.length - 1; i++) {
179718
180164
  const start = portsWithPosition[i];
179719
180165
  const end = portsWithPosition[i + 1];
179720
- const path33 = calculateElbow({
180166
+ const path34 = calculateElbow({
179721
180167
  x: start.position.x,
179722
180168
  y: start.position.y,
179723
180169
  facingDirection: convertFacingDirectionToElbowDirection(start.facingDirection)
@@ -179726,8 +180172,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
179726
180172
  y: end.position.y,
179727
180173
  facingDirection: convertFacingDirectionToElbowDirection(end.facingDirection)
179728
180174
  });
179729
- for (let j4 = 0;j4 < path33.length - 1; j4++) {
179730
- elbowEdges.push({ from: path33[j4], to: path33[j4 + 1] });
180175
+ for (let j4 = 0;j4 < path34.length - 1; j4++) {
180176
+ elbowEdges.push({ from: path34[j4], to: path34[j4 + 1] });
179731
180177
  }
179732
180178
  }
179733
180179
  const doesSegmentIntersectRect = (edge, rect) => {
@@ -185915,8 +186361,8 @@ react/cjs/react-jsx-runtime.development.js:
185915
186361
  */
185916
186362
 
185917
186363
  // lib/import/import-component-from-jlcpcb.ts
185918
- import fs32 from "node:fs/promises";
185919
- import path33 from "node:path";
186364
+ import fs33 from "node:fs/promises";
186365
+ import path34 from "node:path";
185920
186366
  var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd()) => {
185921
186367
  const component = await fetchEasyEDAComponent(jlcpcbPartNumber);
185922
186368
  const tsx = await convertRawEasyToTsx(component);
@@ -185924,10 +186370,10 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
185924
186370
  if (!fileName) {
185925
186371
  throw new Error("Could not determine file name of converted component");
185926
186372
  }
185927
- const importsDir = path33.join(projectDir, "imports");
185928
- await fs32.mkdir(importsDir, { recursive: true });
185929
- const filePath = path33.join(importsDir, `${fileName}.tsx`);
185930
- await fs32.writeFile(filePath, tsx);
186373
+ const importsDir = path34.join(projectDir, "imports");
186374
+ await fs33.mkdir(importsDir, { recursive: true });
186375
+ const filePath = path34.join(importsDir, `${fileName}.tsx`);
186376
+ await fs33.writeFile(filePath, tsx);
185931
186377
  return { filePath };
185932
186378
  };
185933
186379
 
@@ -187292,12 +187738,12 @@ var registerRemove = (program3) => {
187292
187738
  };
187293
187739
 
187294
187740
  // cli/build/register.ts
187295
- import path44 from "node:path";
187296
- import fs43 from "node:fs";
187741
+ import path45 from "node:path";
187742
+ import fs44 from "node:fs";
187297
187743
 
187298
187744
  // cli/build/build-file.ts
187299
- import path34 from "node:path";
187300
- import fs33 from "node:fs";
187745
+ import path35 from "node:path";
187746
+ import fs34 from "node:fs";
187301
187747
 
187302
187748
  // lib/shared/circuit-json-diagnostics.ts
187303
187749
  function analyzeCircuitJson(circuitJson) {
@@ -187359,9 +187805,9 @@ var buildFile = async (input, output, projectDir, options) => {
187359
187805
  filePath: input,
187360
187806
  platformConfig: completePlatformConfig
187361
187807
  });
187362
- fs33.mkdirSync(path34.dirname(output), { recursive: true });
187363
- fs33.writeFileSync(output, JSON.stringify(result.circuitJson, null, 2));
187364
- console.log(`Circuit JSON written to ${path34.relative(projectDir, output)}`);
187808
+ fs34.mkdirSync(path35.dirname(output), { recursive: true });
187809
+ fs34.writeFileSync(output, JSON.stringify(result.circuitJson, null, 2));
187810
+ console.log(`Circuit JSON written to ${path35.relative(projectDir, output)}`);
187365
187811
  const { errors, warnings } = analyzeCircuitJson(result.circuitJson);
187366
187812
  if (!options?.ignoreWarnings) {
187367
187813
  for (const warn of warnings) {
@@ -187400,7 +187846,7 @@ var logTsxExtensionHint = (error, entryFilePath) => {
187400
187846
  const isAggregateError = error instanceof AggregateError || String(error).includes("AggregateError");
187401
187847
  if (!isTsEntry || !isAggregateError)
187402
187848
  return;
187403
- const entryFileName = path34.basename(entryFilePath);
187849
+ const entryFileName = path35.basename(entryFilePath);
187404
187850
  console.error([
187405
187851
  "",
187406
187852
  `It looks like "${entryFileName}" is a ".ts" file. tscircuit component files must use the ".tsx" extension.`,
@@ -187415,7 +187861,7 @@ var logTypeReexportHint = (error, entryFilePath) => {
187415
187861
  if (!match)
187416
187862
  return;
187417
187863
  const [, exportName, fromSpecifier] = match;
187418
- const entryFileName = path34.basename(entryFilePath);
187864
+ const entryFileName = path35.basename(entryFilePath);
187419
187865
  console.error([
187420
187866
  "",
187421
187867
  `It looks like "${entryFileName}" re-exports the type-only symbol "${exportName}" from "${fromSpecifier}" without the "type" modifier.`,
@@ -187431,12 +187877,12 @@ var logTypeReexportHint = (error, entryFilePath) => {
187431
187877
  import { execSync as execSync3 } from "node:child_process";
187432
187878
 
187433
187879
  // lib/shared/install-project-dependencies.ts
187434
- import fs35 from "node:fs";
187435
- import path36 from "node:path";
187880
+ import fs36 from "node:fs";
187881
+ import path37 from "node:path";
187436
187882
 
187437
187883
  // lib/shared/collect-tsci-dependencies.ts
187438
- import fs34 from "node:fs";
187439
- import path35 from "node:path";
187884
+ import fs35 from "node:fs";
187885
+ import path36 from "node:path";
187440
187886
  var DEFAULT_PATTERNS = ["**/*.{ts,tsx,js,jsx}"];
187441
187887
  var DEFAULT_IGNORES = [
187442
187888
  "**/node_modules/**",
@@ -187451,7 +187897,7 @@ function collectTsciDependencies({
187451
187897
  patterns = DEFAULT_PATTERNS,
187452
187898
  ignore = DEFAULT_IGNORES
187453
187899
  } = {}) {
187454
- const searchRoot = path35.resolve(cwd);
187900
+ const searchRoot = path36.resolve(cwd);
187455
187901
  const files = globbySync(patterns, {
187456
187902
  cwd: searchRoot,
187457
187903
  absolute: true,
@@ -187461,7 +187907,7 @@ function collectTsciDependencies({
187461
187907
  const dependencies2 = new Set;
187462
187908
  for (const filePath of files) {
187463
187909
  try {
187464
- const fileContents = fs34.readFileSync(filePath, "utf-8");
187910
+ const fileContents = fs35.readFileSync(filePath, "utf-8");
187465
187911
  let match;
187466
187912
  while (true) {
187467
187913
  match = IMPORT_PATTERN.exec(fileContents);
@@ -187478,26 +187924,26 @@ function collectTsciDependencies({
187478
187924
  async function installProjectDependencies({
187479
187925
  cwd = process.cwd()
187480
187926
  } = {}) {
187481
- const projectRoot = path36.resolve(cwd);
187482
- const packageJsonPath = path36.join(projectRoot, "package.json");
187483
- const npmrcPath = path36.join(projectRoot, ".npmrc");
187927
+ const projectRoot = path37.resolve(cwd);
187928
+ const packageJsonPath = path37.join(projectRoot, "package.json");
187929
+ const npmrcPath = path37.join(projectRoot, ".npmrc");
187484
187930
  const packageManager = getPackageManager();
187485
- if (!fs35.existsSync(projectRoot)) {
187931
+ if (!fs36.existsSync(projectRoot)) {
187486
187932
  throw new Error(`Directory not found: ${projectRoot}`);
187487
187933
  }
187488
187934
  let packageJsonCreated = false;
187489
- if (!fs35.existsSync(packageJsonPath)) {
187935
+ if (!fs36.existsSync(packageJsonPath)) {
187490
187936
  console.log("No package.json found. Generating a new one.");
187491
187937
  generatePackageJson(projectRoot);
187492
187938
  packageJsonCreated = true;
187493
187939
  } else {
187494
187940
  console.log("Found existing package.json.");
187495
187941
  }
187496
- if (!fs35.existsSync(npmrcPath)) {
187942
+ if (!fs36.existsSync(npmrcPath)) {
187497
187943
  console.log("Creating .npmrc with tscircuit registry configuration.");
187498
- fs35.writeFileSync(npmrcPath, "@tsci:registry=https://npm.tscircuit.com");
187944
+ fs36.writeFileSync(npmrcPath, "@tsci:registry=https://npm.tscircuit.com");
187499
187945
  }
187500
- const packageJson = JSON.parse(fs35.readFileSync(packageJsonPath, "utf-8"));
187946
+ const packageJson = JSON.parse(fs36.readFileSync(packageJsonPath, "utf-8"));
187501
187947
  if (packageJsonCreated) {
187502
187948
  const tsciDependencies = collectTsciDependencies({ cwd: projectRoot });
187503
187949
  if (tsciDependencies.length > 0) {
@@ -187512,7 +187958,7 @@ async function installProjectDependencies({
187512
187958
  console.log("No @tsci dependencies detected in circuit files.");
187513
187959
  }
187514
187960
  }
187515
- fs35.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
187961
+ fs36.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
187516
187962
  `);
187517
187963
  console.log(`Installing dependencies using ${kleur_default.bold(packageManager.name)}...`);
187518
187964
  try {
@@ -187563,20 +188009,20 @@ var applyCiBuildOptions = async ({
187563
188009
  };
187564
188010
 
187565
188011
  // cli/build/get-build-entrypoints.ts
187566
- import fs36 from "node:fs";
187567
- import path37 from "node:path";
188012
+ import fs37 from "node:fs";
188013
+ import path38 from "node:path";
187568
188014
  var isSubPath2 = (maybeChild, maybeParent) => {
187569
- const relative10 = path37.relative(maybeParent, maybeChild);
187570
- return relative10 === "" || !relative10.startsWith("..") && !path37.isAbsolute(relative10);
188015
+ const relative10 = path38.relative(maybeParent, maybeChild);
188016
+ return relative10 === "" || !relative10.startsWith("..") && !path38.isAbsolute(relative10);
187571
188017
  };
187572
188018
  var findProjectRoot = (startDir) => {
187573
188019
  let currentDir = startDir;
187574
- while (currentDir !== path37.dirname(currentDir)) {
187575
- const packageJsonPath = path37.join(currentDir, "package.json");
187576
- if (fs36.existsSync(packageJsonPath)) {
188020
+ while (currentDir !== path38.dirname(currentDir)) {
188021
+ const packageJsonPath = path38.join(currentDir, "package.json");
188022
+ if (fs37.existsSync(packageJsonPath)) {
187577
188023
  return currentDir;
187578
188024
  }
187579
- currentDir = path37.dirname(currentDir);
188025
+ currentDir = path38.dirname(currentDir);
187580
188026
  }
187581
188027
  return startDir;
187582
188028
  };
@@ -187585,11 +188031,11 @@ async function getBuildEntrypoints({
187585
188031
  rootDir = process.cwd(),
187586
188032
  includeBoardFiles = true
187587
188033
  }) {
187588
- const resolvedRoot = path37.resolve(rootDir);
188034
+ const resolvedRoot = path38.resolve(rootDir);
187589
188035
  const includeBoardFilePatterns = includeBoardFiles ? getBoardFilePatterns(resolvedRoot) : [];
187590
188036
  const buildFromProjectDir = async () => {
187591
188037
  const projectConfig = loadProjectConfig(resolvedRoot);
187592
- const resolvedPreviewComponentPath = projectConfig?.previewComponentPath ? path37.resolve(resolvedRoot, projectConfig.previewComponentPath) : undefined;
188038
+ const resolvedPreviewComponentPath = projectConfig?.previewComponentPath ? path38.resolve(resolvedRoot, projectConfig.previewComponentPath) : undefined;
187593
188039
  if (includeBoardFiles) {
187594
188040
  const files = findBoardFiles({ projectDir: resolvedRoot });
187595
188041
  if (files.length > 0) {
@@ -187624,10 +188070,10 @@ async function getBuildEntrypoints({
187624
188070
  };
187625
188071
  };
187626
188072
  if (fileOrDir) {
187627
- const resolved = path37.resolve(resolvedRoot, fileOrDir);
187628
- if (fs36.existsSync(resolved) && fs36.statSync(resolved).isDirectory()) {
188073
+ const resolved = path38.resolve(resolvedRoot, fileOrDir);
188074
+ if (fs37.existsSync(resolved) && fs37.statSync(resolved).isDirectory()) {
187629
188075
  const projectConfig2 = loadProjectConfig(resolvedRoot);
187630
- const resolvedPreviewComponentPath2 = projectConfig2?.previewComponentPath ? path37.resolve(resolvedRoot, projectConfig2.previewComponentPath) : undefined;
188076
+ const resolvedPreviewComponentPath2 = projectConfig2?.previewComponentPath ? path38.resolve(resolvedRoot, projectConfig2.previewComponentPath) : undefined;
187631
188077
  if (includeBoardFiles) {
187632
188078
  const circuitFiles = findBoardFiles({
187633
188079
  projectDir: resolvedRoot,
@@ -187659,10 +188105,10 @@ async function getBuildEntrypoints({
187659
188105
  circuitFiles: mainEntrypoint ? [mainEntrypoint] : []
187660
188106
  };
187661
188107
  }
187662
- const fileDir = path37.dirname(resolved);
188108
+ const fileDir = path38.dirname(resolved);
187663
188109
  const projectDir = findProjectRoot(fileDir);
187664
188110
  const projectConfig = loadProjectConfig(projectDir);
187665
- const resolvedPreviewComponentPath = projectConfig?.previewComponentPath ? path37.resolve(projectDir, projectConfig.previewComponentPath) : undefined;
188111
+ const resolvedPreviewComponentPath = projectConfig?.previewComponentPath ? path38.resolve(projectDir, projectConfig.previewComponentPath) : undefined;
187666
188112
  return {
187667
188113
  projectDir,
187668
188114
  previewComponentPath: resolvedPreviewComponentPath,
@@ -187704,8 +188150,8 @@ ${scriptBlock} <script src="https://cdn.tailwindcss.com"></script>
187704
188150
  };
187705
188151
 
187706
188152
  // cli/build/build-preview-images.ts
187707
- import fs37 from "node:fs";
187708
- import path38 from "node:path";
188153
+ import fs38 from "node:fs";
188154
+ import path39 from "node:path";
187709
188155
  import {
187710
188156
  convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg2,
187711
188157
  convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg2
@@ -187714,7 +188160,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer } from "poppygl";
187714
188160
  import { convertCircuitJsonToGltf as convertCircuitJsonToGltf2 } from "circuit-json-to-gltf";
187715
188161
 
187716
188162
  // cli/build/convert-model-urls-to-file-urls.ts
187717
- import { pathToFileURL as pathToFileURL2 } from "node:url";
188163
+ import { pathToFileURL as pathToFileURL3 } from "node:url";
187718
188164
  var convertModelUrlsToFileUrls = (circuitJson) => {
187719
188165
  const modelUrlKeys = [
187720
188166
  "model_glb_url",
@@ -187734,7 +188180,7 @@ var convertModelUrlsToFileUrls = (circuitJson) => {
187734
188180
  const value = updated[key];
187735
188181
  if (typeof value === "string" && value.length > 0) {
187736
188182
  if (!value.match(/^[a-zA-Z]+:\/\//) && (value.startsWith("/") || value.match(/^[a-zA-Z]:\\/))) {
187737
- updated[key] = pathToFileURL2(value).href;
188183
+ updated[key] = pathToFileURL3(value).href;
187738
188184
  }
187739
188185
  }
187740
188186
  }
@@ -187781,21 +188227,21 @@ var generatePreviewAssets = async ({
187781
188227
  outputDir,
187782
188228
  distDir
187783
188229
  }) => {
187784
- const prefixRelative = path38.relative(distDir, outputDir) || ".";
188230
+ const prefixRelative = path39.relative(distDir, outputDir) || ".";
187785
188231
  const prefix = prefixRelative === "." ? "" : `[${prefixRelative}] `;
187786
188232
  let circuitJson;
187787
188233
  try {
187788
- const circuitJsonRaw = fs37.readFileSync(build.outputPath, "utf-8");
188234
+ const circuitJsonRaw = fs38.readFileSync(build.outputPath, "utf-8");
187789
188235
  circuitJson = JSON.parse(circuitJsonRaw);
187790
188236
  } catch (error) {
187791
188237
  console.error(`${prefix}Failed to read circuit JSON:`, error);
187792
188238
  return;
187793
188239
  }
187794
- fs37.mkdirSync(outputDir, { recursive: true });
188240
+ fs38.mkdirSync(outputDir, { recursive: true });
187795
188241
  try {
187796
188242
  console.log(`${prefix}Generating PCB SVG...`);
187797
188243
  const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson);
187798
- fs37.writeFileSync(path38.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
188244
+ fs38.writeFileSync(path39.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
187799
188245
  console.log(`${prefix}Written pcb.svg`);
187800
188246
  } catch (error) {
187801
188247
  console.error(`${prefix}Failed to generate PCB SVG:`, error);
@@ -187803,7 +188249,7 @@ var generatePreviewAssets = async ({
187803
188249
  try {
187804
188250
  console.log(`${prefix}Generating schematic SVG...`);
187805
188251
  const schematicSvg = convertCircuitJsonToSchematicSvg2(circuitJson);
187806
- fs37.writeFileSync(path38.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
188252
+ fs38.writeFileSync(path39.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
187807
188253
  console.log(`${prefix}Written schematic.svg`);
187808
188254
  } catch (error) {
187809
188255
  console.error(`${prefix}Failed to generate schematic SVG:`, error);
@@ -187820,7 +188266,7 @@ var generatePreviewAssets = async ({
187820
188266
  camPos: [10, 10, 10],
187821
188267
  lookAt: [0, 0, 0]
187822
188268
  });
187823
- fs37.writeFileSync(path38.join(outputDir, "3d.png"), Buffer.from(normalizeToUint8Array(pngBuffer)));
188269
+ fs38.writeFileSync(path39.join(outputDir, "3d.png"), Buffer.from(normalizeToUint8Array(pngBuffer)));
187824
188270
  console.log(`${prefix}Written 3d.png`);
187825
188271
  } catch (error) {
187826
188272
  console.error(`${prefix}Failed to generate 3D PNG:`, error);
@@ -187835,14 +188281,14 @@ var buildPreviewImages = async ({
187835
188281
  }) => {
187836
188282
  const successfulBuilds = builtFiles.filter((file) => file.ok);
187837
188283
  const previewEntrypoint = previewComponentPath || mainEntrypoint;
187838
- const resolvedPreviewEntrypoint = previewEntrypoint ? path38.resolve(previewEntrypoint) : undefined;
188284
+ const resolvedPreviewEntrypoint = previewEntrypoint ? path39.resolve(previewEntrypoint) : undefined;
187839
188285
  if (allImages) {
187840
188286
  if (successfulBuilds.length === 0) {
187841
188287
  console.warn("No successful build output available for preview image generation.");
187842
188288
  return;
187843
188289
  }
187844
188290
  for (const build of successfulBuilds) {
187845
- const outputDir = path38.dirname(build.outputPath);
188291
+ const outputDir = path39.dirname(build.outputPath);
187846
188292
  await generatePreviewAssets({
187847
188293
  build,
187848
188294
  outputDir,
@@ -187853,7 +188299,7 @@ var buildPreviewImages = async ({
187853
188299
  }
187854
188300
  const previewBuild = (() => {
187855
188301
  if (resolvedPreviewEntrypoint) {
187856
- const match = successfulBuilds.find((built) => path38.resolve(built.sourcePath) === resolvedPreviewEntrypoint);
188302
+ const match = successfulBuilds.find((built) => path39.resolve(built.sourcePath) === resolvedPreviewEntrypoint);
187857
188303
  if (match)
187858
188304
  return match;
187859
188305
  }
@@ -187871,8 +188317,8 @@ var buildPreviewImages = async ({
187871
188317
  };
187872
188318
 
187873
188319
  // cli/build/build-preview-gltf.ts
187874
- import fs38 from "node:fs";
187875
- import path39 from "node:path";
188320
+ import fs39 from "node:fs";
188321
+ import path40 from "node:path";
187876
188322
  import { convertCircuitJsonToGltf as convertCircuitJsonToGltf3 } from "circuit-json-to-gltf";
187877
188323
  var buildPreviewGltf = async ({
187878
188324
  builtFiles,
@@ -187882,10 +188328,10 @@ var buildPreviewGltf = async ({
187882
188328
  }) => {
187883
188329
  const successfulBuilds = builtFiles.filter((file) => file.ok);
187884
188330
  const previewEntrypoint = previewComponentPath || mainEntrypoint;
187885
- const resolvedPreviewEntrypoint = previewEntrypoint ? path39.resolve(previewEntrypoint) : undefined;
188331
+ const resolvedPreviewEntrypoint = previewEntrypoint ? path40.resolve(previewEntrypoint) : undefined;
187886
188332
  const previewBuild = (() => {
187887
188333
  if (resolvedPreviewEntrypoint) {
187888
- const match = successfulBuilds.find((built) => path39.resolve(built.sourcePath) === resolvedPreviewEntrypoint);
188334
+ const match = successfulBuilds.find((built) => path40.resolve(built.sourcePath) === resolvedPreviewEntrypoint);
187889
188335
  if (match)
187890
188336
  return match;
187891
188337
  }
@@ -187897,16 +188343,16 @@ var buildPreviewGltf = async ({
187897
188343
  }
187898
188344
  let circuitJson;
187899
188345
  try {
187900
- const circuitJsonRaw = fs38.readFileSync(previewBuild.outputPath, "utf-8");
188346
+ const circuitJsonRaw = fs39.readFileSync(previewBuild.outputPath, "utf-8");
187901
188347
  circuitJson = JSON.parse(circuitJsonRaw);
187902
188348
  } catch (error) {
187903
188349
  console.error("Failed to read circuit JSON:", error);
187904
188350
  return;
187905
188351
  }
187906
188352
  const sourcePath = previewBuild.sourcePath;
187907
- const sourceBasename = path39.basename(sourcePath);
188353
+ const sourceBasename = path40.basename(sourcePath);
187908
188354
  const gltfFilename = sourceBasename.replace(/(\.(board|circuit))?\.tsx?$/, ".gltf");
187909
- const outputPath = path39.join(distDir, gltfFilename);
188355
+ const outputPath = path40.join(distDir, gltfFilename);
187910
188356
  try {
187911
188357
  console.log("Converting circuit to GLTF...");
187912
188358
  const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
@@ -187914,7 +188360,7 @@ var buildPreviewGltf = async ({
187914
188360
  format: "gltf"
187915
188361
  });
187916
188362
  const gltfContent = JSON.stringify(gltfData, null, 2);
187917
- fs38.writeFileSync(outputPath, gltfContent, "utf-8");
188363
+ fs39.writeFileSync(outputPath, gltfContent, "utf-8");
187918
188364
  console.log(`Written ${gltfFilename}`);
187919
188365
  } catch (error) {
187920
188366
  console.error("Failed to generate GLTF:", error);
@@ -187922,8 +188368,8 @@ var buildPreviewGltf = async ({
187922
188368
  };
187923
188369
 
187924
188370
  // cli/build/generate-kicad-project.ts
187925
- import fs39 from "node:fs";
187926
- import path40 from "node:path";
188371
+ import fs40 from "node:fs";
188372
+ import path41 from "node:path";
187927
188373
  var createKicadProContent = ({
187928
188374
  projectName,
187929
188375
  schematicFileName,
@@ -187963,10 +188409,10 @@ var generateKicadProject = async ({
187963
188409
  boardFileName
187964
188410
  });
187965
188411
  if (writeFiles) {
187966
- fs39.mkdirSync(outputDir, { recursive: true });
187967
- fs39.writeFileSync(path40.join(outputDir, schematicFileName), schContent);
187968
- fs39.writeFileSync(path40.join(outputDir, boardFileName), pcbContent);
187969
- fs39.writeFileSync(path40.join(outputDir, projectFileName), proContent);
188412
+ fs40.mkdirSync(outputDir, { recursive: true });
188413
+ fs40.writeFileSync(path41.join(outputDir, schematicFileName), schContent);
188414
+ fs40.writeFileSync(path41.join(outputDir, boardFileName), pcbContent);
188415
+ fs40.writeFileSync(path41.join(outputDir, projectFileName), proContent);
187970
188416
  }
187971
188417
  return {
187972
188418
  pcbContent,
@@ -187978,8 +188424,8 @@ var generateKicadProject = async ({
187978
188424
  };
187979
188425
 
187980
188426
  // cli/build/transpile/index.ts
187981
- import path42 from "node:path";
187982
- import fs41 from "node:fs";
188427
+ import path43 from "node:path";
188428
+ import fs42 from "node:fs";
187983
188429
  import { rollup } from "rollup";
187984
188430
  import typescript from "@rollup/plugin-typescript";
187985
188431
  import resolve11 from "@rollup/plugin-node-resolve";
@@ -187988,11 +188434,11 @@ import json from "@rollup/plugin-json";
187988
188434
  import dts from "rollup-plugin-dts";
187989
188435
 
187990
188436
  // cli/build/transpile/static-asset-plugin.ts
187991
- import fs40 from "node:fs";
187992
- import path41 from "node:path";
188437
+ import fs41 from "node:fs";
188438
+ import path42 from "node:path";
187993
188439
  import { createHash } from "node:crypto";
187994
188440
  function normalizePathSeparators(filePath) {
187995
- return filePath.split(path41.sep).join("/");
188441
+ return filePath.split(path42.sep).join("/");
187996
188442
  }
187997
188443
  var STATIC_ASSET_EXTENSIONS = new Set([
187998
188444
  ".glb",
@@ -188023,24 +188469,24 @@ var createStaticAssetPlugin = ({
188023
188469
  return {
188024
188470
  name: "tsci-static-assets",
188025
188471
  resolveId(source, importer) {
188026
- const ext = path41.extname(source).toLowerCase();
188472
+ const ext = path42.extname(source).toLowerCase();
188027
188473
  if (!STATIC_ASSET_EXTENSIONS.has(ext))
188028
188474
  return null;
188029
- if (path41.isAbsolute(source)) {
188030
- return fs40.existsSync(source) ? { id: normalizePathSeparators(source), external: true } : null;
188475
+ if (path42.isAbsolute(source)) {
188476
+ return fs41.existsSync(source) ? { id: normalizePathSeparators(source), external: true } : null;
188031
188477
  }
188032
188478
  if (importer) {
188033
- const importerNative = importer.split("/").join(path41.sep);
188034
- const resolvedFromImporter = path41.resolve(path41.dirname(importerNative), source);
188035
- if (fs40.existsSync(resolvedFromImporter)) {
188479
+ const importerNative = importer.split("/").join(path42.sep);
188480
+ const resolvedFromImporter = path42.resolve(path42.dirname(importerNative), source);
188481
+ if (fs41.existsSync(resolvedFromImporter)) {
188036
188482
  return {
188037
188483
  id: normalizePathSeparators(resolvedFromImporter),
188038
188484
  external: true
188039
188485
  };
188040
188486
  }
188041
188487
  }
188042
- const resolvedFromProject = path41.resolve(resolvedBaseUrl, source);
188043
- if (fs40.existsSync(resolvedFromProject)) {
188488
+ const resolvedFromProject = path42.resolve(resolvedBaseUrl, source);
188489
+ if (fs41.existsSync(resolvedFromProject)) {
188044
188490
  return {
188045
188491
  id: normalizePathSeparators(resolvedFromProject),
188046
188492
  external: true
@@ -188053,8 +188499,8 @@ var createStaticAssetPlugin = ({
188053
188499
  const wildcard = isWildcard ? source.slice(patternPrefix.length) : "";
188054
188500
  for (const target of targets) {
188055
188501
  const targetPath = isWildcard ? target.replace("*", wildcard) : target;
188056
- const resolvedTarget = path41.resolve(resolvedBaseUrl, targetPath);
188057
- if (fs40.existsSync(resolvedTarget)) {
188502
+ const resolvedTarget = path42.resolve(resolvedBaseUrl, targetPath);
188503
+ if (fs41.existsSync(resolvedTarget)) {
188058
188504
  return {
188059
188505
  id: normalizePathSeparators(resolvedTarget),
188060
188506
  external: true
@@ -188080,18 +188526,18 @@ var createStaticAssetPlugin = ({
188080
188526
  if (chunk.type !== "chunk")
188081
188527
  continue;
188082
188528
  for (const importedId of chunk.imports) {
188083
- const ext = path41.extname(importedId).toLowerCase();
188529
+ const ext = path42.extname(importedId).toLowerCase();
188084
188530
  if (!STATIC_ASSET_EXTENSIONS.has(ext))
188085
188531
  continue;
188086
188532
  if (!copiedAssets.has(importedId)) {
188087
- const assetDir = path41.join(outputDir, "assets");
188088
- fs40.mkdirSync(assetDir, { recursive: true });
188089
- const nativePath = importedId.split("/").join(path41.sep);
188090
- const fileBuffer = fs40.readFileSync(nativePath);
188533
+ const assetDir = path42.join(outputDir, "assets");
188534
+ fs41.mkdirSync(assetDir, { recursive: true });
188535
+ const nativePath = importedId.split("/").join(path42.sep);
188536
+ const fileBuffer = fs41.readFileSync(nativePath);
188091
188537
  const hash = createHash("sha1").update(fileBuffer).digest("hex").slice(0, 8);
188092
- const fileName = `${path41.basename(importedId, ext)}-${hash}${ext}`;
188093
- const outputFilePath = path41.join(assetDir, fileName);
188094
- fs40.writeFileSync(outputFilePath, fileBuffer);
188538
+ const fileName = `${path42.basename(importedId, ext)}-${hash}${ext}`;
188539
+ const outputFilePath = path42.join(assetDir, fileName);
188540
+ fs41.writeFileSync(outputFilePath, fileBuffer);
188095
188541
  copiedAssets.set(importedId, `./assets/${fileName}`);
188096
188542
  assetIdToOutputPath.set(importedId, `./assets/${fileName}`);
188097
188543
  }
@@ -188113,17 +188559,17 @@ function escapeRegExp(string) {
188113
188559
 
188114
188560
  // cli/build/transpile/index.ts
188115
188561
  var createExternalFunction = (projectDir, tsconfigPath) => (id2) => {
188116
- if (id2.startsWith(".") || id2.startsWith("/") || path42.isAbsolute(id2)) {
188562
+ if (id2.startsWith(".") || id2.startsWith("/") || path43.isAbsolute(id2)) {
188117
188563
  return false;
188118
188564
  }
188119
188565
  let baseUrl = projectDir;
188120
188566
  let pathMappings = {};
188121
- if (tsconfigPath && fs41.existsSync(tsconfigPath)) {
188567
+ if (tsconfigPath && fs42.existsSync(tsconfigPath)) {
188122
188568
  try {
188123
- const tsconfigContent = fs41.readFileSync(tsconfigPath, "utf-8");
188569
+ const tsconfigContent = fs42.readFileSync(tsconfigPath, "utf-8");
188124
188570
  const tsconfig = JSON.parse(tsconfigContent);
188125
188571
  if (tsconfig.compilerOptions?.baseUrl) {
188126
- baseUrl = path42.resolve(path42.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
188572
+ baseUrl = path43.resolve(path43.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
188127
188573
  }
188128
188574
  if (tsconfig.compilerOptions?.paths) {
188129
188575
  pathMappings = tsconfig.compilerOptions.paths;
@@ -188137,17 +188583,17 @@ var createExternalFunction = (projectDir, tsconfigPath) => (id2) => {
188137
188583
  }
188138
188584
  }
188139
188585
  const potentialPaths = [
188140
- path42.join(baseUrl, id2),
188141
- path42.join(baseUrl, `${id2}.ts`),
188142
- path42.join(baseUrl, `${id2}.tsx`),
188143
- path42.join(baseUrl, `${id2}.js`),
188144
- path42.join(baseUrl, `${id2}.jsx`),
188145
- path42.join(baseUrl, id2, "index.ts"),
188146
- path42.join(baseUrl, id2, "index.tsx"),
188147
- path42.join(baseUrl, id2, "index.js"),
188148
- path42.join(baseUrl, id2, "index.jsx")
188586
+ path43.join(baseUrl, id2),
188587
+ path43.join(baseUrl, `${id2}.ts`),
188588
+ path43.join(baseUrl, `${id2}.tsx`),
188589
+ path43.join(baseUrl, `${id2}.js`),
188590
+ path43.join(baseUrl, `${id2}.jsx`),
188591
+ path43.join(baseUrl, id2, "index.ts"),
188592
+ path43.join(baseUrl, id2, "index.tsx"),
188593
+ path43.join(baseUrl, id2, "index.js"),
188594
+ path43.join(baseUrl, id2, "index.jsx")
188149
188595
  ];
188150
- if (potentialPaths.some((p) => fs41.existsSync(p))) {
188596
+ if (potentialPaths.some((p) => fs42.existsSync(p))) {
188151
188597
  return false;
188152
188598
  }
188153
188599
  return true;
@@ -188158,17 +188604,17 @@ var transpileFile = async ({
188158
188604
  projectDir
188159
188605
  }) => {
188160
188606
  try {
188161
- fs41.mkdirSync(outputDir, { recursive: true });
188162
- const tsconfigPath = path42.join(projectDir, "tsconfig.json");
188163
- const hasTsConfig = fs41.existsSync(tsconfigPath);
188607
+ fs42.mkdirSync(outputDir, { recursive: true });
188608
+ const tsconfigPath = path43.join(projectDir, "tsconfig.json");
188609
+ const hasTsConfig = fs42.existsSync(tsconfigPath);
188164
188610
  let tsconfigBaseUrl = projectDir;
188165
188611
  let tsconfigPathMappings;
188166
188612
  if (hasTsConfig) {
188167
188613
  try {
188168
- const tsconfigContent = fs41.readFileSync(tsconfigPath, "utf-8");
188614
+ const tsconfigContent = fs42.readFileSync(tsconfigPath, "utf-8");
188169
188615
  const tsconfig = JSON.parse(tsconfigContent);
188170
188616
  if (tsconfig.compilerOptions?.baseUrl) {
188171
- tsconfigBaseUrl = path42.resolve(path42.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
188617
+ tsconfigBaseUrl = path43.resolve(path43.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
188172
188618
  }
188173
188619
  if (tsconfig.compilerOptions?.paths) {
188174
188620
  tsconfigPathMappings = tsconfig.compilerOptions.paths;
@@ -188223,27 +188669,27 @@ var transpileFile = async ({
188223
188669
  external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
188224
188670
  plugins: getPlugins()
188225
188671
  });
188226
- const esmOutputPath = path42.join(outputDir, "index.js");
188672
+ const esmOutputPath = path43.join(outputDir, "index.js");
188227
188673
  await esmBundle.write({
188228
188674
  file: esmOutputPath,
188229
188675
  format: "es",
188230
188676
  sourcemap: false
188231
188677
  });
188232
- console.log(`ESM bundle written to ${path42.relative(projectDir, esmOutputPath)}`);
188678
+ console.log(`ESM bundle written to ${path43.relative(projectDir, esmOutputPath)}`);
188233
188679
  console.log("Building CommonJS bundle...");
188234
188680
  const cjsBundle = await rollup({
188235
188681
  input,
188236
188682
  external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
188237
188683
  plugins: getPlugins()
188238
188684
  });
188239
- const cjsOutputPath = path42.join(outputDir, "index.cjs");
188685
+ const cjsOutputPath = path43.join(outputDir, "index.cjs");
188240
188686
  console.log("Writing CJS bundle to:", cjsOutputPath);
188241
188687
  await cjsBundle.write({
188242
188688
  file: cjsOutputPath,
188243
188689
  format: "cjs",
188244
188690
  sourcemap: false
188245
188691
  });
188246
- console.log(`CommonJS bundle written to ${path42.relative(projectDir, cjsOutputPath)}`);
188692
+ console.log(`CommonJS bundle written to ${path43.relative(projectDir, cjsOutputPath)}`);
188247
188693
  console.log("Generating type declarations...");
188248
188694
  const dtsBundle = await rollup({
188249
188695
  input,
@@ -188268,9 +188714,9 @@ var transpileFile = async ({
188268
188714
  dtsContent = dtsContent.replace(/import \* as [\w_]+ from ['"]react\/jsx-runtime['"];?\s*\n?/g, "");
188269
188715
  dtsContent = dtsContent.replace(/[\w_]+\.JSX\.Element/g, "any");
188270
188716
  dtsContent = dtsContent.replace(/export\s*{\s*};\s*$/gm, "").trim();
188271
- const dtsOutputPath = path42.join(outputDir, "index.d.ts");
188272
- fs41.writeFileSync(dtsOutputPath, dtsContent);
188273
- console.log(`Type declarations written to ${path42.relative(projectDir, dtsOutputPath)}`);
188717
+ const dtsOutputPath = path43.join(outputDir, "index.d.ts");
188718
+ fs42.writeFileSync(dtsOutputPath, dtsContent);
188719
+ console.log(`Type declarations written to ${path43.relative(projectDir, dtsOutputPath)}`);
188274
188720
  console.log(kleur_default.green("Transpilation complete!"));
188275
188721
  return true;
188276
188722
  } catch (err) {
@@ -188283,17 +188729,17 @@ var transpileFile = async ({
188283
188729
  };
188284
188730
 
188285
188731
  // cli/utils/validate-main-in-dist.ts
188286
- import fs42 from "node:fs";
188287
- import path43 from "node:path";
188732
+ import fs43 from "node:fs";
188733
+ import path44 from "node:path";
188288
188734
  var validateMainInDist = (projectDir, distDir) => {
188289
- const packageJsonPath = path43.join(projectDir, "package.json");
188290
- if (!fs42.existsSync(packageJsonPath))
188735
+ const packageJsonPath = path44.join(projectDir, "package.json");
188736
+ if (!fs43.existsSync(packageJsonPath))
188291
188737
  return;
188292
- const packageJson = JSON.parse(fs42.readFileSync(packageJsonPath, "utf-8"));
188738
+ const packageJson = JSON.parse(fs43.readFileSync(packageJsonPath, "utf-8"));
188293
188739
  if (typeof packageJson.main !== "string")
188294
188740
  return;
188295
- const resolvedMainPath = path43.resolve(projectDir, packageJson.main);
188296
- const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path43.sep}`);
188741
+ const resolvedMainPath = path44.resolve(projectDir, packageJson.main);
188742
+ const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path44.sep}`);
188297
188743
  if (!isMainInDist) {
188298
188744
  console.warn('When using transpilation, your package\'s "main" field should point inside the `dist/*` directory, usually to "dist/index.js"');
188299
188745
  }
@@ -188346,8 +188792,8 @@ var registerBuild = (program3) => {
188346
188792
  }
188347
188793
  return config;
188348
188794
  })();
188349
- const distDir = path44.join(projectDir, "dist");
188350
- fs43.mkdirSync(distDir, { recursive: true });
188795
+ const distDir = path45.join(projectDir, "dist");
188796
+ fs44.mkdirSync(distDir, { recursive: true });
188351
188797
  console.log(`Building ${circuitFiles.length} file(s)...`);
188352
188798
  let hasErrors = false;
188353
188799
  const staticFileReferences = [];
@@ -188355,10 +188801,10 @@ var registerBuild = (program3) => {
188355
188801
  const kicadProjects = [];
188356
188802
  const shouldGenerateKicad = resolvedOptions?.kicad || resolvedOptions?.kicadFootprintLibrary;
188357
188803
  for (const filePath of circuitFiles) {
188358
- const relative10 = path44.relative(projectDir, filePath);
188804
+ const relative10 = path45.relative(projectDir, filePath);
188359
188805
  console.log(`Building ${relative10}...`);
188360
188806
  const outputDirName = relative10.replace(/(\.board|\.circuit)?\.tsx$/, "");
188361
- const outputPath = path44.join(distDir, outputDirName, "circuit.json");
188807
+ const outputPath = path45.join(distDir, outputDirName, "circuit.json");
188362
188808
  const buildOutcome = await buildFile(filePath, outputPath, projectDir, {
188363
188809
  ignoreErrors: resolvedOptions?.ignoreErrors,
188364
188810
  ignoreWarnings: resolvedOptions?.ignoreWarnings,
@@ -188372,17 +188818,17 @@ var registerBuild = (program3) => {
188372
188818
  if (!buildOutcome.ok) {
188373
188819
  hasErrors = true;
188374
188820
  } else if (resolvedOptions?.site) {
188375
- const normalizedSourcePath = relative10.split(path44.sep).join("/");
188376
- const relativeOutputPath = path44.join(outputDirName, "circuit.json");
188377
- const normalizedOutputPath = relativeOutputPath.split(path44.sep).join("/");
188821
+ const normalizedSourcePath = relative10.split(path45.sep).join("/");
188822
+ const relativeOutputPath = path45.join(outputDirName, "circuit.json");
188823
+ const normalizedOutputPath = relativeOutputPath.split(path45.sep).join("/");
188378
188824
  staticFileReferences.push({
188379
188825
  filePath: normalizedSourcePath,
188380
188826
  fileStaticAssetUrl: `./${normalizedOutputPath}`
188381
188827
  });
188382
188828
  }
188383
188829
  if (buildOutcome.ok && shouldGenerateKicad && buildOutcome.circuitJson) {
188384
- const projectOutputDir = path44.join(distDir, outputDirName, "kicad");
188385
- const projectName = path44.basename(outputDirName);
188830
+ const projectOutputDir = path45.join(distDir, outputDirName, "kicad");
188831
+ const projectName = path45.basename(outputDirName);
188386
188832
  const project = await generateKicadProject({
188387
188833
  circuitJson: buildOutcome.circuitJson,
188388
188834
  outputDir: projectOutputDir,
@@ -188445,13 +188891,13 @@ var registerBuild = (program3) => {
188445
188891
  if (resolvedOptions?.useCdnJavascript) {
188446
188892
  standaloneScriptSrc = await getLatestTscircuitCdnUrl();
188447
188893
  } else {
188448
- fs43.writeFileSync(path44.join(distDir, "standalone.min.js"), standalone_min_default);
188894
+ fs44.writeFileSync(path45.join(distDir, "standalone.min.js"), standalone_min_default);
188449
188895
  }
188450
188896
  const indexHtml = getStaticIndexHtmlFile({
188451
188897
  files: staticFileReferences,
188452
188898
  standaloneScriptSrc
188453
188899
  });
188454
- fs43.writeFileSync(path44.join(distDir, "index.html"), indexHtml);
188900
+ fs44.writeFileSync(path45.join(distDir, "index.html"), indexHtml);
188455
188901
  }
188456
188902
  const successCount = builtFiles.filter((f) => f.ok).length;
188457
188903
  const failCount = builtFiles.length - successCount;
@@ -188469,7 +188915,7 @@ var registerBuild = (program3) => {
188469
188915
  if (enabledOpts.length > 0) {
188470
188916
  console.log(` Options ${kleur_default.cyan(enabledOpts.join(", "))}`);
188471
188917
  }
188472
- console.log(` Output ${kleur_default.dim(path44.relative(process.cwd(), distDir) || "dist")}`);
188918
+ console.log(` Output ${kleur_default.dim(path45.relative(process.cwd(), distDir) || "dist")}`);
188473
188919
  console.log(hasErrors ? kleur_default.yellow(`
188474
188920
  ⚠ Build completed with errors`) : kleur_default.green(`
188475
188921
  ✓ Done`));
@@ -188483,8 +188929,8 @@ var registerBuild = (program3) => {
188483
188929
  };
188484
188930
 
188485
188931
  // lib/shared/snapshot-project.ts
188486
- import fs45 from "node:fs";
188487
- import path45 from "node:path";
188932
+ import fs46 from "node:fs";
188933
+ import path46 from "node:path";
188488
188934
  import looksSame2 from "looks-same";
188489
188935
  import {
188490
188936
  convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
@@ -188495,7 +188941,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
188495
188941
 
188496
188942
  // lib/shared/compare-images.ts
188497
188943
  import looksSame from "looks-same";
188498
- import fs44 from "node:fs/promises";
188944
+ import fs45 from "node:fs/promises";
188499
188945
  var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
188500
188946
  const { equal: equal2 } = await looksSame(buffer1, buffer2, {
188501
188947
  strict: false,
@@ -188511,7 +188957,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
188511
188957
  tolerance: 2
188512
188958
  });
188513
188959
  } else {
188514
- await fs44.writeFile(diffPath, buffer2);
188960
+ await fs45.writeFile(diffPath, buffer2);
188515
188961
  }
188516
188962
  }
188517
188963
  return { equal: equal2 };
@@ -188536,7 +188982,7 @@ var snapshotProject = async ({
188536
188982
  ...DEFAULT_IGNORED_PATTERNS,
188537
188983
  ...ignored.map(normalizeIgnorePattern)
188538
188984
  ];
188539
- const resolvedPaths = filePaths.map((f) => path45.resolve(projectDir, f));
188985
+ const resolvedPaths = filePaths.map((f) => path46.resolve(projectDir, f));
188540
188986
  const boardFiles = findBoardFiles({
188541
188987
  projectDir,
188542
188988
  ignore,
@@ -188550,7 +188996,7 @@ var snapshotProject = async ({
188550
188996
  const mismatches = [];
188551
188997
  let didUpdate = false;
188552
188998
  for (const file of boardFiles) {
188553
- const relativeFilePath = path45.relative(projectDir, file);
188999
+ const relativeFilePath = path46.relative(projectDir, file);
188554
189000
  let circuitJson;
188555
189001
  let pcbSvg;
188556
189002
  let schSvg;
@@ -188605,17 +189051,17 @@ var snapshotProject = async ({
188605
189051
  } catch (error) {
188606
189052
  const errorMessage = error instanceof Error ? error.message : String(error);
188607
189053
  if (errorMessage.includes("No pcb_board found in circuit JSON")) {
188608
- const fileDir = path45.dirname(file);
188609
- const relativeDir = path45.relative(projectDir, fileDir);
188610
- const snapDir2 = snapshotsDirName ? path45.join(projectDir, snapshotsDirName, relativeDir) : path45.join(fileDir, "__snapshots__");
188611
- const base2 = path45.basename(file).replace(/\.tsx$/, "");
188612
- const snap3dPath = path45.join(snapDir2, `${base2}-3d.snap.png`);
188613
- const existing3dSnapshot = fs45.existsSync(snap3dPath);
189054
+ const fileDir = path46.dirname(file);
189055
+ const relativeDir = path46.relative(projectDir, fileDir);
189056
+ const snapDir2 = snapshotsDirName ? path46.join(projectDir, snapshotsDirName, relativeDir) : path46.join(fileDir, "__snapshots__");
189057
+ const base2 = path46.basename(file).replace(/\.tsx$/, "");
189058
+ const snap3dPath = path46.join(snapDir2, `${base2}-3d.snap.png`);
189059
+ const existing3dSnapshot = fs46.existsSync(snap3dPath);
188614
189060
  if (existing3dSnapshot) {
188615
189061
  onError(kleur_default.red(`
188616
189062
  ❌ Failed to generate 3D snapshot for ${relativeFilePath}:
188617
189063
  `) + kleur_default.red(` No pcb_board found in circuit JSON
188618
- `) + kleur_default.red(` Existing snapshot: ${path45.relative(projectDir, snap3dPath)}
189064
+ `) + kleur_default.red(` Existing snapshot: ${path46.relative(projectDir, snap3dPath)}
188619
189065
  `));
188620
189066
  return onExit2(1);
188621
189067
  } else {
@@ -188631,9 +189077,9 @@ var snapshotProject = async ({
188631
189077
  }
188632
189078
  }
188633
189079
  }
188634
- const snapDir = snapshotsDirName ? path45.join(projectDir, snapshotsDirName, path45.relative(projectDir, path45.dirname(file))) : path45.join(path45.dirname(file), "__snapshots__");
188635
- fs45.mkdirSync(snapDir, { recursive: true });
188636
- const base = path45.basename(file).replace(/\.tsx$/, "");
189080
+ const snapDir = snapshotsDirName ? path46.join(projectDir, snapshotsDirName, path46.relative(projectDir, path46.dirname(file))) : path46.join(path46.dirname(file), "__snapshots__");
189081
+ fs46.mkdirSync(snapDir, { recursive: true });
189082
+ const base = path46.basename(file).replace(/\.tsx$/, "");
188637
189083
  const snapshots = [];
188638
189084
  if (pcbOnly || !schematicOnly) {
188639
189085
  snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
@@ -188651,31 +189097,31 @@ var snapshotProject = async ({
188651
189097
  for (const snapshot of snapshots) {
188652
189098
  const { type } = snapshot;
188653
189099
  const is3d = type === "3d";
188654
- const snapPath = path45.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
188655
- const existing = fs45.existsSync(snapPath);
189100
+ const snapPath = path46.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
189101
+ const existing = fs46.existsSync(snapPath);
188656
189102
  const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
188657
189103
  const newContentForFile = snapshot.content;
188658
189104
  if (!existing) {
188659
- fs45.writeFileSync(snapPath, newContentForFile);
188660
- console.log("✅", kleur_default.gray(path45.relative(projectDir, snapPath)));
189105
+ fs46.writeFileSync(snapPath, newContentForFile);
189106
+ console.log("✅", kleur_default.gray(path46.relative(projectDir, snapPath)));
188661
189107
  didUpdate = true;
188662
189108
  continue;
188663
189109
  }
188664
- const oldContentBuffer = fs45.readFileSync(snapPath);
189110
+ const oldContentBuffer = fs46.readFileSync(snapPath);
188665
189111
  const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
188666
189112
  const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
188667
189113
  if (update) {
188668
189114
  if (!forceUpdate && equal2) {
188669
- console.log("✅", kleur_default.gray(path45.relative(projectDir, snapPath)));
189115
+ console.log("✅", kleur_default.gray(path46.relative(projectDir, snapPath)));
188670
189116
  } else {
188671
- fs45.writeFileSync(snapPath, newContentForFile);
188672
- console.log("✅", kleur_default.gray(path45.relative(projectDir, snapPath)));
189117
+ fs46.writeFileSync(snapPath, newContentForFile);
189118
+ console.log("✅", kleur_default.gray(path46.relative(projectDir, snapPath)));
188673
189119
  didUpdate = true;
188674
189120
  }
188675
189121
  } else if (!equal2) {
188676
189122
  mismatches.push(`${snapPath} (diff: ${diffPath})`);
188677
189123
  } else {
188678
- console.log("✅", kleur_default.gray(path45.relative(projectDir, snapPath)));
189124
+ console.log("✅", kleur_default.gray(path46.relative(projectDir, snapPath)));
188679
189125
  }
188680
189126
  }
188681
189127
  }
@@ -188714,22 +189160,22 @@ var registerSnapshot = (program3) => {
188714
189160
  };
188715
189161
 
188716
189162
  // lib/shared/setup-github-actions.ts
188717
- import fs46 from "node:fs";
188718
- import path46 from "node:path";
189163
+ import fs47 from "node:fs";
189164
+ import path47 from "node:path";
188719
189165
  var setupGithubActions = (projectDir = process.cwd()) => {
188720
189166
  const findGitRoot = (startDir) => {
188721
- let dir = path46.resolve(startDir);
188722
- while (dir !== path46.parse(dir).root) {
188723
- if (fs46.existsSync(path46.join(dir, ".git"))) {
189167
+ let dir = path47.resolve(startDir);
189168
+ while (dir !== path47.parse(dir).root) {
189169
+ if (fs47.existsSync(path47.join(dir, ".git"))) {
188724
189170
  return dir;
188725
189171
  }
188726
- dir = path46.dirname(dir);
189172
+ dir = path47.dirname(dir);
188727
189173
  }
188728
189174
  return null;
188729
189175
  };
188730
189176
  const gitRoot = findGitRoot(projectDir) ?? projectDir;
188731
- const workflowsDir = path46.join(gitRoot, ".github", "workflows");
188732
- fs46.mkdirSync(workflowsDir, { recursive: true });
189177
+ const workflowsDir = path47.join(gitRoot, ".github", "workflows");
189178
+ fs47.mkdirSync(workflowsDir, { recursive: true });
188733
189179
  const buildWorkflow = `name: tscircuit Build
188734
189180
 
188735
189181
  on:
@@ -188768,8 +189214,8 @@ jobs:
188768
189214
  - run: bun install
188769
189215
  - run: bunx tsci snapshot
188770
189216
  `;
188771
- writeFileIfNotExists(path46.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
188772
- writeFileIfNotExists(path46.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
189217
+ writeFileIfNotExists(path47.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
189218
+ writeFileIfNotExists(path47.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
188773
189219
  };
188774
189220
 
188775
189221
  // cli/setup/register.ts
@@ -188807,8 +189253,8 @@ function registerAuthSetupNpmrc(program3) {
188807
189253
  }
188808
189254
 
188809
189255
  // cli/convert/register.ts
188810
- import fs47 from "node:fs/promises";
188811
- import path47 from "node:path";
189256
+ import fs48 from "node:fs/promises";
189257
+ import path48 from "node:path";
188812
189258
  import { parseKicadModToCircuitJson } from "kicad-component-converter";
188813
189259
 
188814
189260
  // node_modules/@tscircuit/mm/dist/index.js
@@ -188928,15 +189374,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
188928
189374
  var registerConvert = (program3) => {
188929
189375
  program3.command("convert").description("Convert a .kicad_mod footprint to a tscircuit component").argument("<file>", "Path to the .kicad_mod file").option("-o, --output <path>", "Output TSX file path").option("-n, --name <component>", "Component name for export").action(async (file, options) => {
188930
189376
  try {
188931
- const inputPath = path47.resolve(file);
188932
- const modContent = await fs47.readFile(inputPath, "utf-8");
189377
+ const inputPath = path48.resolve(file);
189378
+ const modContent = await fs48.readFile(inputPath, "utf-8");
188933
189379
  const circuitJson = await parseKicadModToCircuitJson(modContent);
188934
- const componentName = options.name ?? path47.basename(inputPath, ".kicad_mod");
189380
+ const componentName = options.name ?? path48.basename(inputPath, ".kicad_mod");
188935
189381
  const tsx = convertCircuitJsonToTscircuit(circuitJson, {
188936
189382
  componentName
188937
189383
  });
188938
- const outputPath = options.output ? path47.resolve(options.output) : path47.join(path47.dirname(inputPath), `${componentName}.tsx`);
188939
- await fs47.writeFile(outputPath, tsx);
189384
+ const outputPath = options.output ? path48.resolve(options.output) : path48.join(path48.dirname(inputPath), `${componentName}.tsx`);
189385
+ await fs48.writeFile(outputPath, tsx);
188940
189386
  console.log(kleur_default.green(`Converted ${outputPath}`));
188941
189387
  } catch (error) {
188942
189388
  console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
@@ -189052,7 +189498,7 @@ var registerInstall = (program3) => {
189052
189498
  };
189053
189499
 
189054
189500
  // cli/transpile/register.ts
189055
- import path48 from "node:path";
189501
+ import path49 from "node:path";
189056
189502
  var registerTranspile = (program3) => {
189057
189503
  program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
189058
189504
  try {
@@ -189060,7 +189506,7 @@ var registerTranspile = (program3) => {
189060
189506
  fileOrDir: file,
189061
189507
  includeBoardFiles: false
189062
189508
  });
189063
- const distDir = path48.join(projectDir, "dist");
189509
+ const distDir = path49.join(projectDir, "dist");
189064
189510
  validateMainInDist(projectDir, distDir);
189065
189511
  console.log("Transpiling entry file...");
189066
189512
  const entryFile = mainEntrypoint || circuitFiles[0];