@tscircuit/core 0.0.645 → 0.0.647

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,8 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
2
  var __export = (target, all) => {
4
3
  for (var name in all)
5
4
  __defProp(target, name, { get: all[name], enumerable: true });
6
5
  };
7
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
6
 
9
7
  // lib/components/index.ts
10
8
  var components_exports = {};
@@ -23,7 +21,7 @@ __export(components_exports, {
23
21
  FabricationNoteText: () => FabricationNoteText,
24
22
  Footprint: () => Footprint,
25
23
  Fuse: () => Fuse,
26
- Group: () => Group,
24
+ Group: () => Group6,
27
25
  Hole: () => Hole,
28
26
  Inductor: () => Inductor,
29
27
  Jumper: () => Jumper,
@@ -125,18 +123,18 @@ var orderedRenderPhases = [
125
123
  ];
126
124
  var globalRenderCounter = 0;
127
125
  var Renderable = class {
126
+ renderPhaseStates;
127
+ shouldBeRemoved = false;
128
+ children;
129
+ /** PCB-only SMTPads, PlatedHoles, Holes, Silkscreen elements etc. */
130
+ isPcbPrimitive = false;
131
+ /** Schematic-only, lines, boxes, indicators etc. */
132
+ isSchematicPrimitive = false;
133
+ _renderId;
134
+ _currentRenderPhase = null;
135
+ _asyncEffects = [];
136
+ parent = null;
128
137
  constructor(props) {
129
- __publicField(this, "renderPhaseStates");
130
- __publicField(this, "shouldBeRemoved", false);
131
- __publicField(this, "children");
132
- /** PCB-only SMTPads, PlatedHoles, Holes, Silkscreen elements etc. */
133
- __publicField(this, "isPcbPrimitive", false);
134
- /** Schematic-only, lines, boxes, indicators etc. */
135
- __publicField(this, "isSchematicPrimitive", false);
136
- __publicField(this, "_renderId");
137
- __publicField(this, "_currentRenderPhase", null);
138
- __publicField(this, "_asyncEffects", []);
139
- __publicField(this, "parent", null);
140
138
  this._renderId = `${globalRenderCounter++}`;
141
139
  this.children = [];
142
140
  this.renderPhaseStates = {};
@@ -540,58 +538,17 @@ var cssSelectOptionsInsideSubcircuit = {
540
538
  cacheResults: true
541
539
  };
542
540
  var PrimitiveComponent2 = class extends Renderable {
543
- constructor(props) {
544
- super(props);
545
- __publicField(this, "parent", null);
546
- __publicField(this, "children");
547
- __publicField(this, "childrenPendingRemoval");
548
- __publicField(this, "props");
549
- __publicField(this, "_parsedProps");
550
- __publicField(this, "externallyAddedAliases");
551
- /**
552
- * A primitive container is a component that contains one or more ports and
553
- * primitive components that are designed to interact.
554
- *
555
- * For example a resistor contains ports and smtpads that interact, so the
556
- * resistor is a primitive container. Inside a primitive container, the ports
557
- * and pads are likely to reference each other and look for eachother during
558
- * the port matching phase.
559
- *
560
- */
561
- __publicField(this, "isPrimitiveContainer", false);
562
- __publicField(this, "canHaveTextChildren", false);
563
- __publicField(this, "source_group_id", null);
564
- __publicField(this, "source_component_id", null);
565
- __publicField(this, "schematic_component_id", null);
566
- __publicField(this, "pcb_component_id", null);
567
- __publicField(this, "cad_component_id", null);
568
- __publicField(this, "fallbackUnassignedName");
569
- __publicField(this, "_cachedSelectAllQueries", /* @__PURE__ */ new Map());
570
- __publicField(this, "_cachedSelectOneQueries", /* @__PURE__ */ new Map());
571
- this.children = [];
572
- this.childrenPendingRemoval = [];
573
- this.props = props ?? {};
574
- this.externallyAddedAliases = [];
575
- const zodProps = "partial" in this.config.zodProps ? this.config.zodProps.partial({
576
- name: true
577
- }) : this.config.zodProps;
578
- const parsePropsResult = zodProps.safeParse(props ?? {});
579
- if (parsePropsResult.success) {
580
- this._parsedProps = parsePropsResult.data;
581
- } else {
582
- throw new InvalidProps(
583
- this.lowercaseComponentName,
584
- this.props,
585
- parsePropsResult.error.format()
586
- );
587
- }
588
- }
541
+ parent = null;
542
+ children;
543
+ childrenPendingRemoval;
589
544
  get config() {
590
545
  return {
591
546
  componentName: "",
592
547
  zodProps: z.object({}).passthrough()
593
548
  };
594
549
  }
550
+ props;
551
+ _parsedProps;
595
552
  get componentName() {
596
553
  return this.config.componentName;
597
554
  }
@@ -611,6 +568,7 @@ var PrimitiveComponent2 = class extends Renderable {
611
568
  get lowercaseComponentName() {
612
569
  return this.componentName.toLowerCase();
613
570
  }
571
+ externallyAddedAliases;
614
572
  /**
615
573
  * An subcircuit is self-contained. All the selectors inside
616
574
  * a subcircuit are relative to the subcircuit group. You can have multiple
@@ -626,6 +584,44 @@ var PrimitiveComponent2 = class extends Renderable {
626
584
  get name() {
627
585
  return this._parsedProps.name ?? this.fallbackUnassignedName;
628
586
  }
587
+ /**
588
+ * A primitive container is a component that contains one or more ports and
589
+ * primitive components that are designed to interact.
590
+ *
591
+ * For example a resistor contains ports and smtpads that interact, so the
592
+ * resistor is a primitive container. Inside a primitive container, the ports
593
+ * and pads are likely to reference each other and look for eachother during
594
+ * the port matching phase.
595
+ *
596
+ */
597
+ isPrimitiveContainer = false;
598
+ canHaveTextChildren = false;
599
+ source_group_id = null;
600
+ source_component_id = null;
601
+ schematic_component_id = null;
602
+ pcb_component_id = null;
603
+ cad_component_id = null;
604
+ fallbackUnassignedName;
605
+ constructor(props) {
606
+ super(props);
607
+ this.children = [];
608
+ this.childrenPendingRemoval = [];
609
+ this.props = props ?? {};
610
+ this.externallyAddedAliases = [];
611
+ const zodProps = "partial" in this.config.zodProps ? this.config.zodProps.partial({
612
+ name: true
613
+ }) : this.config.zodProps;
614
+ const parsePropsResult = zodProps.safeParse(props ?? {});
615
+ if (parsePropsResult.success) {
616
+ this._parsedProps = parsePropsResult.data;
617
+ } else {
618
+ throw new InvalidProps(
619
+ this.lowercaseComponentName,
620
+ this.props,
621
+ parsePropsResult.error.format()
622
+ );
623
+ }
624
+ }
629
625
  setProps(props) {
630
626
  const newProps = this.config.zodProps.parse({
631
627
  ...this.props,
@@ -1033,6 +1029,7 @@ var PrimitiveComponent2 = class extends Renderable {
1033
1029
  }
1034
1030
  }
1035
1031
  }
1032
+ _cachedSelectAllQueries = /* @__PURE__ */ new Map();
1036
1033
  selectAll(selectorRaw) {
1037
1034
  if (this._cachedSelectAllQueries.has(selectorRaw)) {
1038
1035
  return this._cachedSelectAllQueries.get(
@@ -1054,6 +1051,7 @@ var PrimitiveComponent2 = class extends Renderable {
1054
1051
  this._cachedSelectAllQueries.set(selectorRaw, result2);
1055
1052
  return result2;
1056
1053
  }
1054
+ _cachedSelectOneQueries = /* @__PURE__ */ new Map();
1057
1055
  selectOne(selectorRaw, options) {
1058
1056
  if (this._cachedSelectOneQueries.has(selectorRaw)) {
1059
1057
  return this._cachedSelectOneQueries.get(selectorRaw);
@@ -1073,11 +1071,11 @@ var PrimitiveComponent2 = class extends Renderable {
1073
1071
  (n) => n.lowercaseComponentName === options.type
1074
1072
  );
1075
1073
  }
1076
- result ?? (result = selectOne(
1074
+ result ??= selectOne(
1077
1075
  selector,
1078
1076
  this,
1079
1077
  cssSelectOptionsInsideSubcircuit
1080
- ));
1078
+ );
1081
1079
  if (result) {
1082
1080
  this._cachedSelectOneQueries.set(selectorRaw, result);
1083
1081
  return result;
@@ -1503,10 +1501,7 @@ var netProps = z4.object({
1503
1501
  )
1504
1502
  });
1505
1503
  var Net = class extends PrimitiveComponent2 {
1506
- constructor() {
1507
- super(...arguments);
1508
- __publicField(this, "source_net_id");
1509
- }
1504
+ source_net_id;
1510
1505
  get config() {
1511
1506
  return {
1512
1507
  componentName: "Net",
@@ -1711,12 +1706,9 @@ var createNetsFromProps = (component, props) => {
1711
1706
  import { smtPadProps } from "@tscircuit/props";
1712
1707
  import { decomposeTSR } from "transformation-matrix";
1713
1708
  var SmtPad = class extends PrimitiveComponent2 {
1714
- constructor() {
1715
- super(...arguments);
1716
- __publicField(this, "pcb_smtpad_id", null);
1717
- __publicField(this, "matchedPort", null);
1718
- __publicField(this, "isPcbPrimitive", true);
1719
- }
1709
+ pcb_smtpad_id = null;
1710
+ matchedPort = null;
1711
+ isPcbPrimitive = true;
1720
1712
  get config() {
1721
1713
  return {
1722
1714
  componentName: "SmtPad",
@@ -1974,11 +1966,8 @@ var SmtPad = class extends PrimitiveComponent2 {
1974
1966
  import { silkscreenPathProps } from "@tscircuit/props";
1975
1967
  import { applyToPoint as applyToPoint2 } from "transformation-matrix";
1976
1968
  var SilkscreenPath = class extends PrimitiveComponent2 {
1977
- constructor() {
1978
- super(...arguments);
1979
- __publicField(this, "pcb_silkscreen_path_id", null);
1980
- __publicField(this, "isPcbPrimitive", true);
1981
- }
1969
+ pcb_silkscreen_path_id = null;
1970
+ isPcbPrimitive = true;
1982
1971
  get config() {
1983
1972
  return {
1984
1973
  componentName: "SilkscreenPath",
@@ -2073,11 +2062,8 @@ var pcbTraceProps = z5.object({
2073
2062
  source_trace_id: z5.string().optional()
2074
2063
  });
2075
2064
  var PcbTrace = class extends PrimitiveComponent2 {
2076
- constructor() {
2077
- super(...arguments);
2078
- __publicField(this, "pcb_trace_id", null);
2079
- __publicField(this, "isPcbPrimitive", true);
2080
- }
2065
+ pcb_trace_id = null;
2066
+ isPcbPrimitive = true;
2081
2067
  get config() {
2082
2068
  return {
2083
2069
  componentName: "PcbTrace",
@@ -2144,12 +2130,9 @@ var PcbTrace = class extends PrimitiveComponent2 {
2144
2130
  // lib/components/primitive-components/PlatedHole.ts
2145
2131
  import { platedHoleProps } from "@tscircuit/props";
2146
2132
  var PlatedHole = class extends PrimitiveComponent2 {
2147
- constructor() {
2148
- super(...arguments);
2149
- __publicField(this, "pcb_plated_hole_id", null);
2150
- __publicField(this, "matchedPort", null);
2151
- __publicField(this, "isPcbPrimitive", true);
2152
- }
2133
+ pcb_plated_hole_id = null;
2134
+ matchedPort = null;
2135
+ isPcbPrimitive = true;
2153
2136
  get config() {
2154
2137
  return {
2155
2138
  componentName: "PlatedHole",
@@ -2372,11 +2355,8 @@ var PlatedHole = class extends PrimitiveComponent2 {
2372
2355
  import { pcbKeepoutProps } from "@tscircuit/props";
2373
2356
  import { decomposeTSR as decomposeTSR2 } from "transformation-matrix";
2374
2357
  var Keepout = class extends PrimitiveComponent2 {
2375
- constructor() {
2376
- super(...arguments);
2377
- __publicField(this, "pcb_keepout_id", null);
2378
- __publicField(this, "isPcbPrimitive", true);
2379
- }
2358
+ pcb_keepout_id = null;
2359
+ isPcbPrimitive = true;
2380
2360
  get config() {
2381
2361
  return {
2382
2362
  componentName: "Keepout",
@@ -2430,11 +2410,8 @@ var Keepout = class extends PrimitiveComponent2 {
2430
2410
  // lib/components/primitive-components/Hole.ts
2431
2411
  import { holeProps } from "@tscircuit/props";
2432
2412
  var Hole = class extends PrimitiveComponent2 {
2433
- constructor() {
2434
- super(...arguments);
2435
- __publicField(this, "pcb_hole_id", null);
2436
- __publicField(this, "isPcbPrimitive", true);
2437
- }
2413
+ pcb_hole_id = null;
2414
+ isPcbPrimitive = true;
2438
2415
  get config() {
2439
2416
  return {
2440
2417
  componentName: "Hole",
@@ -2490,10 +2467,7 @@ var Hole = class extends PrimitiveComponent2 {
2490
2467
  // lib/components/primitive-components/SilkscreenText.ts
2491
2468
  import { silkscreenTextProps } from "@tscircuit/props";
2492
2469
  var SilkscreenText = class extends PrimitiveComponent2 {
2493
- constructor() {
2494
- super(...arguments);
2495
- __publicField(this, "isPcbPrimitive", true);
2496
- }
2470
+ isPcbPrimitive = true;
2497
2471
  get config() {
2498
2472
  return {
2499
2473
  componentName: "SilkscreenText",
@@ -2543,11 +2517,8 @@ var SilkscreenText = class extends PrimitiveComponent2 {
2543
2517
  import { applyToPoint as applyToPoint4 } from "transformation-matrix";
2544
2518
  import { cutoutProps } from "@tscircuit/props";
2545
2519
  var Cutout = class extends PrimitiveComponent2 {
2546
- constructor() {
2547
- super(...arguments);
2548
- __publicField(this, "pcb_cutout_id", null);
2549
- __publicField(this, "isPcbPrimitive", true);
2550
- }
2520
+ pcb_cutout_id = null;
2521
+ isPcbPrimitive = true;
2551
2522
  get config() {
2552
2523
  return {
2553
2524
  componentName: "Cutout",
@@ -3010,6 +2981,19 @@ var portProps = z6.object({
3010
2981
  aliases: z6.array(z6.string()).optional()
3011
2982
  });
3012
2983
  var Port = class extends PrimitiveComponent2 {
2984
+ source_port_id = null;
2985
+ pcb_port_id = null;
2986
+ schematic_port_id = null;
2987
+ schematicSymbolPortDef = null;
2988
+ matchedComponents;
2989
+ facingDirection = null;
2990
+ originDescription = null;
2991
+ get config() {
2992
+ return {
2993
+ componentName: "Port",
2994
+ zodProps: portProps
2995
+ };
2996
+ }
3013
2997
  constructor(props, opts = {}) {
3014
2998
  if (!props.name && props.pinNumber !== void 0)
3015
2999
  props.name = `pin${props.pinNumber}`;
@@ -3017,24 +3001,11 @@ var Port = class extends PrimitiveComponent2 {
3017
3001
  throw new Error("Port must have a name or a pinNumber");
3018
3002
  }
3019
3003
  super(props);
3020
- __publicField(this, "source_port_id", null);
3021
- __publicField(this, "pcb_port_id", null);
3022
- __publicField(this, "schematic_port_id", null);
3023
- __publicField(this, "schematicSymbolPortDef", null);
3024
- __publicField(this, "matchedComponents");
3025
- __publicField(this, "facingDirection", null);
3026
- __publicField(this, "originDescription", null);
3027
3004
  if (opts.originDescription) {
3028
3005
  this.originDescription = opts.originDescription;
3029
3006
  }
3030
3007
  this.matchedComponents = [];
3031
3008
  }
3032
- get config() {
3033
- return {
3034
- componentName: "Port",
3035
- zodProps: portProps
3036
- };
3037
- }
3038
3009
  _getGlobalPcbPositionBeforeLayout() {
3039
3010
  const matchedPcbElm = this.matchedComponents.find((c) => c.isPcbPrimitive);
3040
3011
  const parentComponent = this.parent;
@@ -3904,8 +3875,8 @@ import "circuit-json-to-connectivity-map";
3904
3875
 
3905
3876
  // lib/utils/autorouting/DirectLineRouter.ts
3906
3877
  var DirectLineRouter = class {
3878
+ input;
3907
3879
  constructor({ input }) {
3908
- __publicField(this, "input");
3909
3880
  this.input = input;
3910
3881
  }
3911
3882
  solveAndMapToTraces() {
@@ -4197,7 +4168,7 @@ var getMaxLengthFromConnectedCapacitors = (ports, { db }) => {
4197
4168
  return sourceComponent.max_decoupling_trace_length;
4198
4169
  }
4199
4170
  return null;
4200
- }).filter((length6) => length6 !== null);
4171
+ }).filter((length7) => length7 !== null);
4201
4172
  if (capacitorMaxLengths.length === 0) return void 0;
4202
4173
  return Math.min(...capacitorMaxLengths);
4203
4174
  };
@@ -5071,7 +5042,7 @@ var convertFacingDirectionToElbowDirection = (facingDirection) => {
5071
5042
  };
5072
5043
 
5073
5044
  // lib/errors/AutorouterError.ts
5074
- import packageJson from "@tscircuit/capacity-autorouter/package.json";
5045
+ import packageJson from "@tscircuit/capacity-autorouter/package.json" with { type: "json" };
5075
5046
  var autorouterVersion = packageJson.version ?? "unknown";
5076
5047
  var AutorouterError = class extends Error {
5077
5048
  constructor(message) {
@@ -5091,6 +5062,7 @@ var TraceConnectionError = class extends Error {
5091
5062
 
5092
5063
  // lib/components/primitive-components/Trace/Trace_doInitialSchematicTraceRender.ts
5093
5064
  var Trace_doInitialSchematicTraceRender = (trace) => {
5065
+ if (trace.root?._featureMspSchematicTraceRouting) return;
5094
5066
  if (trace._couldNotFindPort) return;
5095
5067
  if (trace.root?.schematicDisabled) return;
5096
5068
  const { db } = trace.root;
@@ -5972,15 +5944,15 @@ function Trace__findConnectedPorts(trace) {
5972
5944
 
5973
5945
  // lib/components/primitive-components/Trace/Trace.ts
5974
5946
  var Trace3 = class extends PrimitiveComponent2 {
5947
+ source_trace_id = null;
5948
+ pcb_trace_id = null;
5949
+ schematic_trace_id = null;
5950
+ _portsRoutedOnPcb;
5951
+ subcircuit_connectivity_map_key = null;
5952
+ _traceConnectionHash = null;
5953
+ _couldNotFindPort;
5975
5954
  constructor(props) {
5976
5955
  super(props);
5977
- __publicField(this, "source_trace_id", null);
5978
- __publicField(this, "pcb_trace_id", null);
5979
- __publicField(this, "schematic_trace_id", null);
5980
- __publicField(this, "_portsRoutedOnPcb");
5981
- __publicField(this, "subcircuit_connectivity_map_key", null);
5982
- __publicField(this, "_traceConnectionHash", null);
5983
- __publicField(this, "_couldNotFindPort");
5984
5956
  this._portsRoutedOnPcb = [];
5985
5957
  }
5986
5958
  get config() {
@@ -6200,17 +6172,12 @@ var rotation3 = z8.object({
6200
6172
  z: rotation
6201
6173
  });
6202
6174
  var NormalComponent = class extends PrimitiveComponent2 {
6203
- constructor(props) {
6204
- super(props);
6205
- __publicField(this, "reactSubtrees", []);
6206
- __publicField(this, "_impliedFootprint");
6207
- __publicField(this, "isPrimitiveContainer", true);
6208
- __publicField(this, "_asyncSupplierPartNumbers");
6209
- __publicField(this, "pcb_missing_footprint_error_id");
6210
- __publicField(this, "_hasStartedFootprintUrlLoad", false);
6211
- this._addChildrenFromStringFootprint();
6212
- this.initPorts();
6213
- }
6175
+ reactSubtrees = [];
6176
+ _impliedFootprint;
6177
+ isPrimitiveContainer = true;
6178
+ _asyncSupplierPartNumbers;
6179
+ pcb_missing_footprint_error_id;
6180
+ _hasStartedFootprintUrlLoad = false;
6214
6181
  /**
6215
6182
  * Override this property for component defaults
6216
6183
  */
@@ -6225,6 +6192,11 @@ var NormalComponent = class extends PrimitiveComponent2 {
6225
6192
  )
6226
6193
  );
6227
6194
  }
6195
+ constructor(props) {
6196
+ super(props);
6197
+ this._addChildrenFromStringFootprint();
6198
+ this.initPorts();
6199
+ }
6228
6200
  /**
6229
6201
  * Override this method for better control over the auto-discovery of ports.
6230
6202
  *
@@ -6415,7 +6387,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
6415
6387
  _addChildrenFromStringFootprint() {
6416
6388
  const { pcbRotation, pinLabels, pcbPinLabels } = this.props;
6417
6389
  let { footprint } = this.props;
6418
- footprint ?? (footprint = this._getImpliedFootprintString?.());
6390
+ footprint ??= this._getImpliedFootprintString?.();
6419
6391
  if (!footprint) return;
6420
6392
  if (typeof footprint === "string") {
6421
6393
  if (this._isFootprintUrl(footprint)) return;
@@ -6671,7 +6643,7 @@ var NormalComponent = class extends PrimitiveComponent2 {
6671
6643
  }
6672
6644
  doInitialPcbFootprintStringRender() {
6673
6645
  let { footprint } = this.props;
6674
- footprint ?? (footprint = this._getImpliedFootprintString?.());
6646
+ footprint ??= this._getImpliedFootprintString?.();
6675
6647
  if (!footprint) return;
6676
6648
  const { pcbRotation, pinLabels, pcbPinLabels } = this.props;
6677
6649
  if (typeof footprint === "string" && this._isFootprintUrl(footprint)) {
@@ -7072,18 +7044,18 @@ import {
7072
7044
  // lib/utils/autorouting/CapacityMeshAutorouter.ts
7073
7045
  import { CapacityMeshSolver } from "@tscircuit/capacity-autorouter";
7074
7046
  var CapacityMeshAutorouter = class {
7047
+ input;
7048
+ isRouting = false;
7049
+ solver;
7050
+ eventHandlers = {
7051
+ complete: [],
7052
+ error: [],
7053
+ progress: []
7054
+ };
7055
+ cycleCount = 0;
7056
+ stepDelay;
7057
+ timeoutId;
7075
7058
  constructor(input, options = {}) {
7076
- __publicField(this, "input");
7077
- __publicField(this, "isRouting", false);
7078
- __publicField(this, "solver");
7079
- __publicField(this, "eventHandlers", {
7080
- complete: [],
7081
- error: [],
7082
- progress: []
7083
- });
7084
- __publicField(this, "cycleCount", 0);
7085
- __publicField(this, "stepDelay");
7086
- __publicField(this, "timeoutId");
7087
7059
  this.input = input;
7088
7060
  const { capacityDepth, targetMinCapacity, stepDelay = 0 } = options;
7089
7061
  this.solver = new CapacityMeshSolver(input, {
@@ -7219,17 +7191,14 @@ var CapacityMeshAutorouter = class {
7219
7191
 
7220
7192
  // lib/components/primitive-components/Group/Group.ts
7221
7193
  import "circuit-json";
7222
- import Debug8 from "debug";
7194
+ import Debug9 from "debug";
7223
7195
  import "zod";
7224
7196
 
7225
7197
  // lib/components/primitive-components/TraceHint.ts
7226
7198
  import { traceHintProps } from "@tscircuit/props";
7227
7199
  import { applyToPoint as applyToPoint6 } from "transformation-matrix";
7228
7200
  var TraceHint = class extends PrimitiveComponent2 {
7229
- constructor() {
7230
- super(...arguments);
7231
- __publicField(this, "matchedPort", null);
7232
- }
7201
+ matchedPort = null;
7233
7202
  get config() {
7234
7203
  return {
7235
7204
  componentName: "TraceHint",
@@ -7743,7 +7712,7 @@ var getSimpleRouteJsonFromCircuitJson = ({
7743
7712
  if (!conn) continue;
7744
7713
  if (![...tracePortIds].every((pid) => pointIdToConn.get(pid) === conn))
7745
7714
  continue;
7746
- conn.externallyConnectedPointIds ?? (conn.externallyConnectedPointIds = []);
7715
+ conn.externallyConnectedPointIds ??= [];
7747
7716
  conn.externallyConnectedPointIds.push([...tracePortIds]);
7748
7717
  }
7749
7718
  return {
@@ -8024,7 +7993,7 @@ function convertTreeToInputProblem(tree, db, group) {
8024
7993
  netMap: {},
8025
7994
  pinStrongConnMap: {},
8026
7995
  netConnMap: {},
8027
- chipGap: 0.4,
7996
+ chipGap: 0.6,
8028
7997
  partitionGap: 1.2
8029
7998
  };
8030
7999
  debug5(
@@ -9501,16 +9470,770 @@ var Group_doInitialPcbLayoutFlex = (group) => {
9501
9470
 
9502
9471
  // lib/components/primitive-components/Group/Group.ts
9503
9472
  import { convertSrjToGraphicsObject } from "@tscircuit/capacity-autorouter";
9504
- var Group = class extends NormalComponent {
9505
- constructor() {
9506
- super(...arguments);
9507
- __publicField(this, "pcb_group_id", null);
9508
- __publicField(this, "schematic_group_id", null);
9509
- __publicField(this, "subcircuit_id", null);
9510
- __publicField(this, "_hasStartedAsyncAutorouting", false);
9511
- __publicField(this, "_asyncAutoroutingResult", null);
9512
- __publicField(this, "unnamedElementCounter", {});
9473
+
9474
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts
9475
+ import { SchematicTracePipelineSolver as SchematicTracePipelineSolver4 } from "@tscircuit/schematic-trace-solver";
9476
+ import Debug8 from "debug";
9477
+
9478
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/createSchematicTraceSolverInputProblem.ts
9479
+ import "@tscircuit/schematic-trace-solver";
9480
+ function createSchematicTraceSolverInputProblem(group) {
9481
+ const { db } = group.root;
9482
+ const sckToSourceNet = /* @__PURE__ */ new Map();
9483
+ const sckToUserNetId = /* @__PURE__ */ new Map();
9484
+ const allScks = /* @__PURE__ */ new Set();
9485
+ const traces = group.selectAll("trace");
9486
+ const displayLabelTraces = traces.filter(
9487
+ (t) => t._parsedProps?.schDisplayLabel
9488
+ );
9489
+ const displayLabelSourceTraceIds = new Set(
9490
+ displayLabelTraces.map((t) => t.source_trace_id).filter((id) => Boolean(id))
9491
+ );
9492
+ const childGroups = group.selectAll("group");
9493
+ const allSchematicGroupIds = [
9494
+ group.schematic_group_id,
9495
+ ...childGroups.map((a) => a.schematic_group_id)
9496
+ ];
9497
+ const schematicComponents = db.schematic_component.list().filter((a) => allSchematicGroupIds.includes(a.schematic_group_id));
9498
+ const chips = [];
9499
+ const pinIdToSchematicPortId = /* @__PURE__ */ new Map();
9500
+ const schematicPortIdToPinId = /* @__PURE__ */ new Map();
9501
+ for (const schematicComponent of schematicComponents) {
9502
+ const chipId = schematicComponent.schematic_component_id;
9503
+ const pins = [];
9504
+ const sourceComponent = db.source_component.getWhere({
9505
+ source_component_id: schematicComponent.source_component_id
9506
+ });
9507
+ const schematicPorts = db.schematic_port.list({
9508
+ schematic_component_id: schematicComponent.schematic_component_id
9509
+ });
9510
+ for (const schematicPort of schematicPorts) {
9511
+ const pinId = `${sourceComponent?.name ?? schematicComponent.schematic_component_id}.${schematicPort.pin_number}`;
9512
+ pinIdToSchematicPortId.set(pinId, schematicPort.schematic_port_id);
9513
+ schematicPortIdToPinId.set(schematicPort.schematic_port_id, pinId);
9514
+ }
9515
+ for (const schematicPort of schematicPorts) {
9516
+ const pinId = schematicPortIdToPinId.get(schematicPort.schematic_port_id);
9517
+ pins.push({
9518
+ pinId,
9519
+ x: schematicPort.center.x,
9520
+ y: schematicPort.center.y
9521
+ });
9522
+ }
9523
+ chips.push({
9524
+ chipId,
9525
+ center: schematicComponent.center,
9526
+ width: schematicComponent.size.width,
9527
+ height: schematicComponent.size.height,
9528
+ pins
9529
+ });
9530
+ }
9531
+ const allSourceAndSchematicPortIdsInScope = /* @__PURE__ */ new Set();
9532
+ const schPortIdToSourcePortId = /* @__PURE__ */ new Map();
9533
+ const sourcePortIdToSchPortId = /* @__PURE__ */ new Map();
9534
+ const userNetIdToSck = /* @__PURE__ */ new Map();
9535
+ for (const sc of schematicComponents) {
9536
+ const ports = db.schematic_port.list({
9537
+ schematic_component_id: sc.schematic_component_id
9538
+ });
9539
+ for (const sp of ports) {
9540
+ allSourceAndSchematicPortIdsInScope.add(sp.schematic_port_id);
9541
+ if (sp.source_port_id) {
9542
+ schPortIdToSourcePortId.set(sp.schematic_port_id, sp.source_port_id);
9543
+ sourcePortIdToSchPortId.set(sp.source_port_id, sp.schematic_port_id);
9544
+ }
9545
+ }
9546
+ }
9547
+ const allowedSubcircuitIds = /* @__PURE__ */ new Set();
9548
+ if (group.subcircuit_id) allowedSubcircuitIds.add(group.subcircuit_id);
9549
+ for (const cg of childGroups) {
9550
+ if (cg.subcircuit_id) allowedSubcircuitIds.add(cg.subcircuit_id);
9551
+ }
9552
+ const directConnections = [];
9553
+ const pairKeyToSourceTraceId = /* @__PURE__ */ new Map();
9554
+ for (const st of db.source_trace.list()) {
9555
+ if (displayLabelSourceTraceIds.has(st.source_trace_id)) continue;
9556
+ if (st.subcircuit_id && !allowedSubcircuitIds.has(st.subcircuit_id)) {
9557
+ continue;
9558
+ }
9559
+ const connected = (st.connected_source_port_ids ?? []).map((srcId) => sourcePortIdToSchPortId.get(srcId)).filter(
9560
+ (sourcePortId) => Boolean(sourcePortId) && allSourceAndSchematicPortIdsInScope.has(sourcePortId)
9561
+ );
9562
+ if (connected.length >= 2) {
9563
+ const [a, b] = connected.slice(0, 2);
9564
+ const pairKey = [a, b].sort().join("::");
9565
+ if (!pairKeyToSourceTraceId.has(pairKey)) {
9566
+ pairKeyToSourceTraceId.set(pairKey, st.source_trace_id);
9567
+ const userNetId = st.display_name ?? st.source_trace_id;
9568
+ if (st.subcircuit_connectivity_map_key) {
9569
+ allScks.add(st.subcircuit_connectivity_map_key);
9570
+ userNetIdToSck.set(userNetId, st.subcircuit_connectivity_map_key);
9571
+ sckToUserNetId.set(st.subcircuit_connectivity_map_key, userNetId);
9572
+ }
9573
+ directConnections.push({
9574
+ pinIds: [a, b].map((id) => schematicPortIdToPinId.get(id)),
9575
+ netId: userNetId
9576
+ });
9577
+ }
9578
+ }
9579
+ }
9580
+ const netConnections = [];
9581
+ for (const net of db.source_net.list().filter((n) => allowedSubcircuitIds.has(n.subcircuit_id))) {
9582
+ if (net.subcircuit_connectivity_map_key) {
9583
+ allScks.add(net.subcircuit_connectivity_map_key);
9584
+ sckToSourceNet.set(net.subcircuit_connectivity_map_key, net);
9585
+ }
9586
+ }
9587
+ const sckToPinIds = /* @__PURE__ */ new Map();
9588
+ for (const [schId, srcPortId] of schPortIdToSourcePortId) {
9589
+ const sp = db.source_port.get(srcPortId);
9590
+ if (!sp?.subcircuit_connectivity_map_key) continue;
9591
+ const sck = sp.subcircuit_connectivity_map_key;
9592
+ allScks.add(sck);
9593
+ if (!sckToPinIds.has(sck)) sckToPinIds.set(sck, []);
9594
+ sckToPinIds.get(sck).push(schId);
9595
+ }
9596
+ for (const [subcircuitConnectivityKey, schematicPortIds] of sckToPinIds) {
9597
+ const sourceNet = sckToSourceNet.get(subcircuitConnectivityKey);
9598
+ if (sourceNet && schematicPortIds.length >= 2) {
9599
+ const userNetId = String(
9600
+ sourceNet.name || sourceNet.source_net_id || subcircuitConnectivityKey
9601
+ );
9602
+ userNetIdToSck.set(userNetId, subcircuitConnectivityKey);
9603
+ sckToUserNetId.set(subcircuitConnectivityKey, userNetId);
9604
+ netConnections.push({
9605
+ netId: userNetId,
9606
+ pinIds: schematicPortIds.map(
9607
+ (portId) => schematicPortIdToPinId.get(portId)
9608
+ )
9609
+ });
9610
+ }
9611
+ }
9612
+ const availableNetLabelOrientations = (() => {
9613
+ const netToAllowedOrientations = {};
9614
+ const presentNetIds = new Set(netConnections.map((nc) => nc.netId));
9615
+ for (const net of db.source_net.list().filter(
9616
+ (n) => !n.subcircuit_id || allowedSubcircuitIds.has(n.subcircuit_id)
9617
+ )) {
9618
+ if (!net.name) continue;
9619
+ if (!presentNetIds.has(net.name)) continue;
9620
+ if (net.name === "GND") {
9621
+ netToAllowedOrientations[net.name] = ["y-"];
9622
+ } else if (/^V/.test(net.name)) {
9623
+ netToAllowedOrientations[net.name] = ["y+"];
9624
+ }
9625
+ }
9626
+ return netToAllowedOrientations;
9627
+ })();
9628
+ const inputProblem = {
9629
+ chips,
9630
+ directConnections,
9631
+ netConnections,
9632
+ availableNetLabelOrientations,
9633
+ maxMspPairDistance: 2
9634
+ };
9635
+ return {
9636
+ inputProblem,
9637
+ pinIdToSchematicPortId,
9638
+ pairKeyToSourceTraceId,
9639
+ sckToSourceNet,
9640
+ sckToUserNetId,
9641
+ userNetIdToSck,
9642
+ allSourceAndSchematicPortIdsInScope,
9643
+ schPortIdToSourcePortId,
9644
+ displayLabelTraces,
9645
+ allScks
9646
+ };
9647
+ }
9648
+
9649
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts
9650
+ import "@tscircuit/schematic-trace-solver";
9651
+
9652
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-crossings.ts
9653
+ var TOL = 1e-6;
9654
+ function isHorizontalEdge(edge) {
9655
+ const dx = Math.abs(edge.to.x - edge.from.x);
9656
+ const dy = Math.abs(edge.to.y - edge.from.y);
9657
+ return dx >= dy;
9658
+ }
9659
+ function length6(a, b) {
9660
+ return Math.hypot(b.x - a.x, b.y - a.y);
9661
+ }
9662
+ function pointAt(a, b, t) {
9663
+ return { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };
9664
+ }
9665
+ function paramAlong(a, b, p) {
9666
+ const L = length6(a, b);
9667
+ if (L < TOL) return 0;
9668
+ const t = ((p.x - a.x) * (b.x - a.x) + (p.y - a.y) * (b.y - a.y)) / ((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y));
9669
+ return Math.max(0, Math.min(1, t)) * L;
9670
+ }
9671
+ function cross(ax, ay, bx, by) {
9672
+ return ax * by - ay * bx;
9673
+ }
9674
+ function segmentIntersection(p1, p2, q1, q2) {
9675
+ const r = { x: p2.x - p1.x, y: p2.y - p1.y };
9676
+ const s = { x: q2.x - q1.x, y: q2.y - q1.y };
9677
+ const rxs = cross(r.x, r.y, s.x, s.y);
9678
+ const q_p = { x: q1.x - p1.x, y: q1.y - p1.y };
9679
+ const q_pxr = cross(q_p.x, q_p.y, r.x, r.y);
9680
+ if (Math.abs(rxs) < TOL && Math.abs(q_pxr) < TOL) {
9681
+ return null;
9682
+ }
9683
+ if (Math.abs(rxs) < TOL && Math.abs(q_pxr) >= TOL) {
9684
+ return null;
9685
+ }
9686
+ const t = cross(q_p.x, q_p.y, s.x, s.y) / rxs;
9687
+ const u = cross(q_p.x, q_p.y, r.x, r.y) / rxs;
9688
+ if (t < -TOL || t > 1 + TOL || u < -TOL || u > 1 + TOL) return null;
9689
+ const pt = { x: p1.x + t * r.x, y: p1.y + t * r.y };
9690
+ return pt;
9691
+ }
9692
+ function mergeIntervals(intervals, tol = TOL) {
9693
+ if (intervals.length === 0) return intervals;
9694
+ intervals.sort((a, b) => a.start - b.start);
9695
+ const merged = [];
9696
+ let cur = { ...intervals[0] };
9697
+ for (let i = 1; i < intervals.length; i++) {
9698
+ const nxt = intervals[i];
9699
+ if (nxt.start <= cur.end + tol) {
9700
+ cur.end = Math.max(cur.end, nxt.end);
9701
+ } else {
9702
+ merged.push(cur);
9703
+ cur = { ...nxt };
9704
+ }
9705
+ }
9706
+ merged.push(cur);
9707
+ return merged;
9708
+ }
9709
+ function splitEdgeByCrossings(edge, crossingDistances, crossLen) {
9710
+ const L = length6(edge.from, edge.to);
9711
+ if (L < TOL || crossingDistances.length === 0) return [edge];
9712
+ const half = crossLen / 2;
9713
+ const rawIntervals = crossingDistances.map((d) => ({
9714
+ start: Math.max(0, d - half),
9715
+ end: Math.min(L, d + half)
9716
+ })).filter((iv) => iv.end - iv.start > TOL);
9717
+ const intervals = mergeIntervals(rawIntervals);
9718
+ const result = [];
9719
+ let cursor = 0;
9720
+ const dir = { x: edge.to.x - edge.from.x, y: edge.to.y - edge.from.y };
9721
+ const addSeg = (d0, d1, isCrossing) => {
9722
+ if (d1 - d0 <= TOL) return;
9723
+ const t0 = d0 / L;
9724
+ const t1 = d1 / L;
9725
+ result.push({
9726
+ from: pointAt(edge.from, edge.to, t0),
9727
+ to: pointAt(edge.from, edge.to, t1),
9728
+ ...isCrossing ? { is_crossing: true } : {}
9729
+ });
9730
+ };
9731
+ for (const iv of intervals) {
9732
+ if (iv.start - cursor > TOL) {
9733
+ addSeg(cursor, iv.start, false);
9734
+ }
9735
+ addSeg(iv.start, iv.end, true);
9736
+ cursor = iv.end;
9737
+ }
9738
+ if (L - cursor > TOL) {
9739
+ addSeg(cursor, L, false);
9740
+ }
9741
+ return result.length > 0 ? result : [edge];
9742
+ }
9743
+ function computeCrossings(traces, opts = {}) {
9744
+ const crossLen = opts.crossSegmentLength ?? 0.075;
9745
+ const tol = opts.tolerance ?? TOL;
9746
+ const crossingsByEdge = /* @__PURE__ */ new Map();
9747
+ const keyOf = (ref) => `${ref.traceIdx}:${ref.edgeIdx}`;
9748
+ const getEdge = (ref) => traces[ref.traceIdx].edges[ref.edgeIdx];
9749
+ for (let ti = 0; ti < traces.length; ti++) {
9750
+ const A = traces[ti];
9751
+ for (let ei = 0; ei < A.edges.length; ei++) {
9752
+ const eA = A.edges[ei];
9753
+ for (let tj = ti; tj < traces.length; tj++) {
9754
+ const B = traces[tj];
9755
+ for (let ej = tj === ti ? ei + 1 : 0; ej < B.edges.length; ej++) {
9756
+ const eB = B.edges[ej];
9757
+ const P = segmentIntersection(eA.from, eA.to, eB.from, eB.to);
9758
+ if (!P) continue;
9759
+ const LA = length6(eA.from, eA.to);
9760
+ const LB = length6(eB.from, eB.to);
9761
+ if (LA < tol || LB < tol) continue;
9762
+ const dA = paramAlong(eA.from, eA.to, P);
9763
+ const dB = paramAlong(eB.from, eB.to, P);
9764
+ const nearEndpointA = dA <= tol || Math.abs(LA - dA) <= tol || Number.isNaN(dA);
9765
+ const nearEndpointB = dB <= tol || Math.abs(LB - dB) <= tol || Number.isNaN(dB);
9766
+ if (!nearEndpointA && !nearEndpointB) {
9767
+ const aIsHorizontal = isHorizontalEdge(eA);
9768
+ const bIsHorizontal = isHorizontalEdge(eB);
9769
+ let assignToA;
9770
+ if (aIsHorizontal !== bIsHorizontal) {
9771
+ assignToA = aIsHorizontal;
9772
+ } else {
9773
+ const ax = Math.abs(eA.to.x - eA.from.x);
9774
+ const ay = Math.abs(eA.to.y - eA.from.y);
9775
+ const bx = Math.abs(eB.to.x - eB.from.x);
9776
+ const by = Math.abs(eB.to.y - eB.from.y);
9777
+ const aScore = ax - ay;
9778
+ const bScore = bx - by;
9779
+ assignToA = aScore === bScore ? true : aScore > bScore;
9780
+ }
9781
+ const chosenKey = keyOf({
9782
+ traceIdx: assignToA ? ti : tj,
9783
+ edgeIdx: assignToA ? ei : ej
9784
+ });
9785
+ const chosenList = crossingsByEdge.get(chosenKey) ?? [];
9786
+ chosenList.push(assignToA ? dA : dB);
9787
+ crossingsByEdge.set(chosenKey, chosenList);
9788
+ }
9789
+ }
9790
+ }
9791
+ }
9792
+ }
9793
+ const out = traces.map((t) => ({ id: t.id, edges: [] }));
9794
+ for (let ti = 0; ti < traces.length; ti++) {
9795
+ const trace = traces[ti];
9796
+ for (let ei = 0; ei < trace.edges.length; ei++) {
9797
+ const eRefKey = keyOf({ traceIdx: ti, edgeIdx: ei });
9798
+ const splittingDistances = crossingsByEdge.get(eRefKey) ?? [];
9799
+ if (splittingDistances.length === 0) {
9800
+ out[ti].edges.push(trace.edges[ei]);
9801
+ continue;
9802
+ }
9803
+ const uniqueSorted = Array.from(
9804
+ new Set(splittingDistances.map((d) => Number(d.toFixed(6))))
9805
+ ).sort((a, b) => a - b);
9806
+ const split = splitEdgeByCrossings(
9807
+ trace.edges[ei],
9808
+ uniqueSorted,
9809
+ crossLen
9810
+ );
9811
+ out[ti].edges.push(...split);
9812
+ }
9813
+ }
9814
+ return out;
9815
+ }
9816
+
9817
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts
9818
+ var TOL2 = 1e-6;
9819
+ function nearlyEqual(a, b, tol = TOL2) {
9820
+ return Math.abs(a - b) <= tol;
9821
+ }
9822
+ function pointEq(a, b, tol = TOL2) {
9823
+ return nearlyEqual(a.x, b.x, tol) && nearlyEqual(a.y, b.y, tol);
9824
+ }
9825
+ function onSegment(p, a, b, tol = TOL2) {
9826
+ const minX = Math.min(a.x, b.x) - tol;
9827
+ const maxX = Math.max(a.x, b.x) + tol;
9828
+ const minY = Math.min(a.y, b.y) - tol;
9829
+ const maxY = Math.max(a.y, b.y) + tol;
9830
+ if (p.x < minX || p.x > maxX || p.y < minY || p.y > maxY) return false;
9831
+ const area = Math.abs((b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x));
9832
+ return area <= tol;
9833
+ }
9834
+ function dedupePoints(points, tol = TOL2) {
9835
+ const map = /* @__PURE__ */ new Map();
9836
+ for (const p of points) {
9837
+ const key = `${p.x.toFixed(6)},${p.y.toFixed(6)}`;
9838
+ if (!map.has(key)) map.set(key, p);
9839
+ }
9840
+ return Array.from(map.values());
9841
+ }
9842
+ function edgeVec(e) {
9843
+ return { x: e.to.x - e.from.x, y: e.to.y - e.from.y };
9844
+ }
9845
+ function isParallel(e1, e2, tol = TOL2) {
9846
+ const v1 = edgeVec(e1);
9847
+ const v2 = edgeVec(e2);
9848
+ const L1 = Math.hypot(v1.x, v1.y);
9849
+ const L2 = Math.hypot(v2.x, v2.y);
9850
+ if (L1 < tol || L2 < tol) return true;
9851
+ const cross2 = v1.x * v2.y - v1.y * v2.x;
9852
+ return Math.abs(cross2) <= tol * L1 * L2;
9853
+ }
9854
+ function incidentEdgesAtPoint(trace, p, tol = TOL2) {
9855
+ return trace.edges.filter(
9856
+ (e) => pointEq(e.from, p, tol) || pointEq(e.to, p, tol)
9857
+ );
9858
+ }
9859
+ function nearestEndpointOnTrace(trace, p, tol = TOL2) {
9860
+ for (const e of trace.edges) {
9861
+ if (pointEq(e.from, p, tol)) return e.from;
9862
+ if (pointEq(e.to, p, tol)) return e.to;
9863
+ }
9864
+ return null;
9865
+ }
9866
+ function edgeDirectionFromPoint(e, p, tol = TOL2) {
9867
+ const other = pointEq(e.from, p, tol) || nearlyEqual(e.from.x, p.x, tol) && nearlyEqual(e.from.y, p.y, tol) ? e.to : e.from;
9868
+ const dx = other.x - p.x;
9869
+ const dy = other.y - p.y;
9870
+ if (Math.abs(dx) < tol && Math.abs(dy) < tol) return null;
9871
+ if (Math.abs(dx) >= Math.abs(dy)) {
9872
+ return dx >= 0 ? "right" : "left";
9873
+ }
9874
+ return dy >= 0 ? "up" : "down";
9875
+ }
9876
+ function getCornerOrientationAtPoint(trace, p, tol = TOL2) {
9877
+ const incident = incidentEdgesAtPoint(trace, p, tol);
9878
+ if (incident.length < 2) return null;
9879
+ const dirs = incident.map((e) => edgeDirectionFromPoint(e, p, tol));
9880
+ const hasUp = dirs.includes("up");
9881
+ const hasDown = dirs.includes("down");
9882
+ const hasLeft = dirs.includes("left");
9883
+ const hasRight = dirs.includes("right");
9884
+ const vertical = hasUp ? "up" : hasDown ? "down" : null;
9885
+ const horizontal = hasRight ? "right" : hasLeft ? "left" : null;
9886
+ if (vertical && horizontal) {
9887
+ return `${vertical}-${horizontal}`;
9888
+ }
9889
+ return null;
9890
+ }
9891
+ function computeJunctions(traces, opts = {}) {
9892
+ const tol = opts.tolerance ?? TOL2;
9893
+ const result = {};
9894
+ for (const t of traces) result[t.id] = [];
9895
+ const endpointsByTrace = traces.map((t) => {
9896
+ const pts = [];
9897
+ for (const e of t.edges) {
9898
+ pts.push(e.from, e.to);
9899
+ }
9900
+ return dedupePoints(pts, tol);
9901
+ });
9902
+ for (let i = 0; i < traces.length; i++) {
9903
+ const A = traces[i];
9904
+ const AEnds = endpointsByTrace[i];
9905
+ for (let j = i + 1; j < traces.length; j++) {
9906
+ const B = traces[j];
9907
+ const BEnds = endpointsByTrace[j];
9908
+ for (const pa of AEnds) {
9909
+ for (const pb of BEnds) {
9910
+ if (pointEq(pa, pb, tol)) {
9911
+ const aEdgesAtP = incidentEdgesAtPoint(A, pa, tol);
9912
+ const bEdgesAtP = incidentEdgesAtPoint(B, pb, tol);
9913
+ const hasCorner = aEdgesAtP.some(
9914
+ (eA) => bEdgesAtP.some((eB) => !isParallel(eA, eB, tol))
9915
+ );
9916
+ const aCorner = getCornerOrientationAtPoint(A, pa, tol);
9917
+ const bCorner = getCornerOrientationAtPoint(B, pb, tol);
9918
+ const sameCornerOrientation = aCorner !== null && bCorner !== null && aCorner === bCorner;
9919
+ if (hasCorner && !sameCornerOrientation) {
9920
+ result[A.id].push(pa);
9921
+ if (A.id !== B.id) result[B.id].push(pb);
9922
+ }
9923
+ }
9924
+ }
9925
+ }
9926
+ for (const pa of AEnds) {
9927
+ for (const eB of B.edges) {
9928
+ if (onSegment(pa, eB.from, eB.to, tol)) {
9929
+ const aEdgesAtP = incidentEdgesAtPoint(A, pa, tol);
9930
+ const hasCorner = aEdgesAtP.some((eA) => !isParallel(eA, eB, tol));
9931
+ const aCorner = getCornerOrientationAtPoint(A, pa, tol);
9932
+ const bEndpointNearPa = nearestEndpointOnTrace(B, pa, tol * 1e3);
9933
+ const bCorner = bEndpointNearPa ? getCornerOrientationAtPoint(B, bEndpointNearPa, tol) : null;
9934
+ const sameCornerOrientation = aCorner !== null && bCorner !== null && aCorner === bCorner;
9935
+ if (hasCorner && !sameCornerOrientation) {
9936
+ result[A.id].push(pa);
9937
+ if (A.id !== B.id) result[B.id].push(pa);
9938
+ }
9939
+ }
9940
+ }
9941
+ }
9942
+ for (const pb of BEnds) {
9943
+ for (const eA of A.edges) {
9944
+ if (onSegment(pb, eA.from, eA.to, tol)) {
9945
+ const bEdgesAtP = incidentEdgesAtPoint(B, pb, tol);
9946
+ const hasCorner = bEdgesAtP.some((eB) => !isParallel(eA, eB, tol));
9947
+ const bCorner = getCornerOrientationAtPoint(B, pb, tol);
9948
+ const aEndpointNearPb = nearestEndpointOnTrace(A, pb, tol * 1e3);
9949
+ const aCorner = aEndpointNearPb ? getCornerOrientationAtPoint(A, aEndpointNearPb, tol) : null;
9950
+ const sameCornerOrientation = aCorner !== null && bCorner !== null && aCorner === bCorner;
9951
+ if (hasCorner && !sameCornerOrientation) {
9952
+ result[B.id].push(pb);
9953
+ if (A.id !== B.id) result[A.id].push(pb);
9954
+ }
9955
+ }
9956
+ }
9957
+ }
9958
+ }
9513
9959
  }
9960
+ for (const id of Object.keys(result)) {
9961
+ result[id] = dedupePoints(result[id], tol);
9962
+ }
9963
+ return result;
9964
+ }
9965
+
9966
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts
9967
+ function applyTracesFromSolverOutput(args) {
9968
+ const { group, solver, pinIdToSchematicPortId, pairKeyToSourceTraceId } = args;
9969
+ const { db } = group.root;
9970
+ const correctedMap = solver.traceOverlapShiftSolver?.correctedTraceMap;
9971
+ const pendingTraces = [];
9972
+ for (const solved of Object.values(correctedMap ?? {})) {
9973
+ const points = solved?.tracePath;
9974
+ if (!Array.isArray(points) || points.length < 2) continue;
9975
+ const edges = [];
9976
+ for (let i = 0; i < points.length - 1; i++) {
9977
+ edges.push({
9978
+ from: { x: points[i].x, y: points[i].y },
9979
+ to: { x: points[i + 1].x, y: points[i + 1].y }
9980
+ });
9981
+ }
9982
+ let source_trace_id = null;
9983
+ if (Array.isArray(solved?.pins) && solved.pins.length === 2) {
9984
+ const pA = pinIdToSchematicPortId.get(solved.pins[0]?.pinId);
9985
+ const pB = pinIdToSchematicPortId.get(solved.pins[1]?.pinId);
9986
+ if (pA && pB) {
9987
+ const pairKey = [pA, pB].sort().join("::");
9988
+ source_trace_id = pairKeyToSourceTraceId.get(pairKey) || `solver_${solved.mspPairId || pairKey}`;
9989
+ for (const schPid of [pA, pB]) {
9990
+ const existing = db.schematic_port.get(schPid);
9991
+ if (existing) db.schematic_port.update(schPid, { is_connected: true });
9992
+ }
9993
+ }
9994
+ }
9995
+ if (!source_trace_id) {
9996
+ source_trace_id = `solver_${solved?.mspPairId}`;
9997
+ }
9998
+ pendingTraces.push({
9999
+ id: source_trace_id,
10000
+ edges
10001
+ });
10002
+ }
10003
+ const withCrossings = computeCrossings(
10004
+ pendingTraces.map((t) => ({ id: t.id, edges: t.edges }))
10005
+ );
10006
+ const junctionsById = computeJunctions(withCrossings);
10007
+ for (const t of withCrossings) {
10008
+ db.schematic_trace.insert({
10009
+ source_trace_id: t.id,
10010
+ edges: t.edges,
10011
+ junctions: junctionsById[t.id] ?? []
10012
+ });
10013
+ }
10014
+ }
10015
+
10016
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyNetLabelPlacements.ts
10017
+ import "@tscircuit/schematic-trace-solver";
10018
+
10019
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/oppositeSide.ts
10020
+ var oppositeSide = (input) => {
10021
+ switch (input) {
10022
+ case "x+":
10023
+ return "left";
10024
+ case "x-":
10025
+ return "right";
10026
+ case "y+":
10027
+ return "bottom";
10028
+ case "y-":
10029
+ return "top";
10030
+ case "left":
10031
+ return "right";
10032
+ case "top":
10033
+ return "bottom";
10034
+ case "right":
10035
+ return "left";
10036
+ case "bottom":
10037
+ return "top";
10038
+ }
10039
+ };
10040
+
10041
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyNetLabelPlacements.ts
10042
+ function applyNetLabelPlacements(args) {
10043
+ const {
10044
+ group,
10045
+ solver,
10046
+ sckToSourceNet,
10047
+ allScks,
10048
+ allSourceAndSchematicPortIdsInScope,
10049
+ schPortIdToSourcePortId,
10050
+ userNetIdToSck
10051
+ } = args;
10052
+ const { db } = group.root;
10053
+ const netLabelPlacements = solver.netLabelPlacementSolver?.netLabelPlacements ?? [];
10054
+ const globalConnMap = solver.mspConnectionPairSolver.globalConnMap;
10055
+ for (const placement of netLabelPlacements) {
10056
+ const placementUserNetId = globalConnMap.getIdsConnectedToNet(placement.globalConnNetId).find((id) => userNetIdToSck.get(id));
10057
+ const placementSck = userNetIdToSck.get(placementUserNetId);
10058
+ const anchor_position = placement.anchorPoint;
10059
+ const orientation = placement.orientation;
10060
+ const anchor_side = oppositeSide(orientation);
10061
+ const sourceNet = placementSck ? sckToSourceNet.get(placementSck) : void 0;
10062
+ if (!sourceNet) {
10063
+ continue;
10064
+ }
10065
+ const text = sourceNet.name;
10066
+ const hasExistingLabelForNet = db.schematic_net_label.list().some((nl) => {
10067
+ if (sourceNet?.source_net_id && nl.source_net_id) {
10068
+ return nl.source_net_id === sourceNet.source_net_id;
10069
+ }
10070
+ return nl.text === text;
10071
+ });
10072
+ if (hasExistingLabelForNet) continue;
10073
+ const center = placement.center ?? computeSchematicNetLabelCenter({
10074
+ anchor_position,
10075
+ anchor_side,
10076
+ text
10077
+ });
10078
+ db.schematic_net_label.insert({
10079
+ text,
10080
+ anchor_position,
10081
+ center,
10082
+ anchor_side,
10083
+ ...sourceNet?.source_net_id ? { source_net_id: sourceNet.source_net_id } : {}
10084
+ });
10085
+ }
10086
+ }
10087
+
10088
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/insertNetLabelsForTracesExcludedFromRouting.ts
10089
+ import "@tscircuit/schematic-trace-solver";
10090
+ function insertNetLabelsForTracesExcludedFromRouting(args) {
10091
+ const { group, displayLabelTraces } = args;
10092
+ const { db } = group.root;
10093
+ for (const trace of displayLabelTraces) {
10094
+ const label = trace._parsedProps?.schDisplayLabel;
10095
+ if (!label) continue;
10096
+ try {
10097
+ const res = trace._findConnectedPorts?.();
10098
+ if (!res?.allPortsFound || !res.ports || res.ports.length < 1) continue;
10099
+ const ports = res.ports.slice(0, 2);
10100
+ for (const port of ports) {
10101
+ const anchor_position = port._getGlobalSchematicPositionAfterLayout();
10102
+ const side = getEnteringEdgeFromDirection(port.facingDirection || "right") || "right";
10103
+ const center = computeSchematicNetLabelCenter({
10104
+ anchor_position,
10105
+ anchor_side: side,
10106
+ text: label
10107
+ });
10108
+ db.schematic_net_label.insert({
10109
+ text: label,
10110
+ anchor_position,
10111
+ center,
10112
+ anchor_side: side,
10113
+ ...trace.source_trace_id ? { source_trace_id: trace.source_trace_id } : {}
10114
+ });
10115
+ }
10116
+ } catch {
10117
+ }
10118
+ }
10119
+ }
10120
+
10121
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/insertNetLabelsForPortsMissingTrace.ts
10122
+ var insertNetLabelsForPortsMissingTrace = ({
10123
+ allSourceAndSchematicPortIdsInScope,
10124
+ group,
10125
+ schPortIdToSourcePortId,
10126
+ sckToSourceNet: connKeyToNet
10127
+ }) => {
10128
+ const { db } = group.root;
10129
+ for (const schOrSrcPortId of Array.from(
10130
+ allSourceAndSchematicPortIdsInScope
10131
+ )) {
10132
+ const sp = db.schematic_port.get(schOrSrcPortId);
10133
+ if (!sp) continue;
10134
+ if (sp.is_connected) continue;
10135
+ const srcPortId = schPortIdToSourcePortId.get(schOrSrcPortId);
10136
+ if (!srcPortId) continue;
10137
+ const sourcePort = db.source_port.get(srcPortId);
10138
+ const key = sourcePort?.subcircuit_connectivity_map_key;
10139
+ if (!key) continue;
10140
+ const sourceNet = connKeyToNet.get(key);
10141
+ if (!sourceNet) {
10142
+ continue;
10143
+ }
10144
+ const hasLabelForNet = db.schematic_net_label.list().some((nl) => {
10145
+ if (sourceNet.source_net_id && nl.source_net_id) {
10146
+ return nl.source_net_id === sourceNet.source_net_id;
10147
+ }
10148
+ return nl.text === (sourceNet.name || key);
10149
+ });
10150
+ if (hasLabelForNet) continue;
10151
+ const existingAtPort = db.schematic_net_label.list().some((nl) => {
10152
+ const samePos = Math.abs(nl.anchor_position.x - sp.center.x) < 1e-6 && Math.abs(nl.anchor_position.y - sp.center.y) < 1e-6;
10153
+ if (!samePos) return false;
10154
+ if (sourceNet.source_net_id && nl.source_net_id) {
10155
+ return nl.source_net_id === sourceNet.source_net_id;
10156
+ }
10157
+ return nl.text === (sourceNet.name || key);
10158
+ });
10159
+ if (existingAtPort) continue;
10160
+ const text = sourceNet.name || sourceNet.source_net_id || key;
10161
+ const side = getEnteringEdgeFromDirection(sp.facing_direction || "right") || "right";
10162
+ const center = computeSchematicNetLabelCenter({
10163
+ anchor_position: sp.center,
10164
+ anchor_side: side,
10165
+ text
10166
+ });
10167
+ db.schematic_net_label.insert({
10168
+ text,
10169
+ anchor_position: sp.center,
10170
+ center,
10171
+ anchor_side: side,
10172
+ ...sourceNet.source_net_id ? { source_net_id: sourceNet.source_net_id } : {}
10173
+ });
10174
+ }
10175
+ };
10176
+
10177
+ // lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts
10178
+ var debug7 = Debug8("Group_doInitialSchematicTraceRender");
10179
+ var Group_doInitialSchematicTraceRender = (group) => {
10180
+ if (!group.root?._featureMspSchematicTraceRouting) return;
10181
+ if (!group.isSubcircuit) return;
10182
+ if (group.root?.schematicDisabled) return;
10183
+ const {
10184
+ inputProblem,
10185
+ pinIdToSchematicPortId,
10186
+ pairKeyToSourceTraceId,
10187
+ sckToSourceNet,
10188
+ allSourceAndSchematicPortIdsInScope,
10189
+ schPortIdToSourcePortId,
10190
+ displayLabelTraces,
10191
+ allScks,
10192
+ userNetIdToSck
10193
+ } = createSchematicTraceSolverInputProblem(group);
10194
+ if (debug7.enabled) {
10195
+ globalThis.debugOutputs?.add(
10196
+ "group-trace-render-input-problem",
10197
+ JSON.stringify(inputProblem, null, 2)
10198
+ );
10199
+ }
10200
+ const solver = new SchematicTracePipelineSolver4(inputProblem);
10201
+ solver.solve();
10202
+ applyTracesFromSolverOutput({
10203
+ group,
10204
+ solver,
10205
+ pinIdToSchematicPortId,
10206
+ pairKeyToSourceTraceId
10207
+ });
10208
+ applyNetLabelPlacements({
10209
+ group,
10210
+ solver,
10211
+ sckToSourceNet,
10212
+ allSourceAndSchematicPortIdsInScope,
10213
+ schPortIdToSourcePortId,
10214
+ allScks,
10215
+ userNetIdToSck
10216
+ });
10217
+ insertNetLabelsForPortsMissingTrace({
10218
+ group,
10219
+ allSourceAndSchematicPortIdsInScope,
10220
+ schPortIdToSourcePortId,
10221
+ sckToSourceNet
10222
+ });
10223
+ insertNetLabelsForTracesExcludedFromRouting({
10224
+ group,
10225
+ solver,
10226
+ displayLabelTraces
10227
+ });
10228
+ };
10229
+
10230
+ // lib/components/primitive-components/Group/Group.ts
10231
+ var Group6 = class extends NormalComponent {
10232
+ pcb_group_id = null;
10233
+ schematic_group_id = null;
10234
+ subcircuit_id = null;
10235
+ _hasStartedAsyncAutorouting = false;
10236
+ _asyncAutoroutingResult = null;
9514
10237
  get config() {
9515
10238
  return {
9516
10239
  zodProps: groupProps,
@@ -9607,9 +10330,9 @@ var Group = class extends NormalComponent {
9607
10330
  });
9608
10331
  }
9609
10332
  }
10333
+ unnamedElementCounter = {};
9610
10334
  getNextAvailableName(elm) {
9611
- var _a, _b;
9612
- (_a = this.unnamedElementCounter)[_b = elm.lowercaseComponentName] ?? (_a[_b] = 1);
10335
+ this.unnamedElementCounter[elm.lowercaseComponentName] ??= 1;
9613
10336
  return `unnamed_${elm.lowercaseComponentName}${this.unnamedElementCounter[elm.lowercaseComponentName]++}`;
9614
10337
  }
9615
10338
  _resolvePcbPadding() {
@@ -9669,20 +10392,20 @@ var Group = class extends NormalComponent {
9669
10392
  return false;
9670
10393
  }
9671
10394
  _hasTracesToRoute() {
9672
- const debug7 = Debug8("tscircuit:core:_hasTracesToRoute");
10395
+ const debug8 = Debug9("tscircuit:core:_hasTracesToRoute");
9673
10396
  const traces = this.selectAll("trace");
9674
- debug7(`[${this.getString()}] has ${traces.length} traces to route`);
10397
+ debug8(`[${this.getString()}] has ${traces.length} traces to route`);
9675
10398
  return traces.length > 0;
9676
10399
  }
9677
10400
  async _runEffectMakeHttpAutoroutingRequest() {
9678
10401
  const { db } = this.root;
9679
- const debug7 = Debug8("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
10402
+ const debug8 = Debug9("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
9680
10403
  const props = this._parsedProps;
9681
10404
  const autorouterConfig = this._getAutorouterConfig();
9682
10405
  const serverUrl = autorouterConfig.serverUrl;
9683
10406
  const serverMode = autorouterConfig.serverMode;
9684
10407
  const fetchWithDebug = (url, options) => {
9685
- debug7("fetching", url);
10408
+ debug8("fetching", url);
9686
10409
  if (options.headers) {
9687
10410
  options.headers["Tscircuit-Core-Version"] = this.root?.getCoreVersion();
9688
10411
  }
@@ -9798,15 +10521,15 @@ var Group = class extends NormalComponent {
9798
10521
  async _runLocalAutorouting() {
9799
10522
  const { db } = this.root;
9800
10523
  const props = this._parsedProps;
9801
- const debug7 = Debug8("tscircuit:core:_runLocalAutorouting");
9802
- debug7(`[${this.getString()}] starting local autorouting`);
10524
+ const debug8 = Debug9("tscircuit:core:_runLocalAutorouting");
10525
+ debug8(`[${this.getString()}] starting local autorouting`);
9803
10526
  const autorouterConfig = this._getAutorouterConfig();
9804
10527
  const { simpleRouteJson } = getSimpleRouteJsonFromCircuitJson({
9805
10528
  db,
9806
10529
  minTraceWidth: this.props.autorouter?.minTraceWidth ?? 0.15,
9807
10530
  subcircuit_id: this.subcircuit_id
9808
10531
  });
9809
- if (debug7.enabled) {
10532
+ if (debug8.enabled) {
9810
10533
  const graphicsObject = convertSrjToGraphicsObject(
9811
10534
  simpleRouteJson
9812
10535
  );
@@ -9831,11 +10554,11 @@ var Group = class extends NormalComponent {
9831
10554
  const routingPromise = new Promise(
9832
10555
  (resolve, reject) => {
9833
10556
  autorouter.on("complete", (event) => {
9834
- debug7(`[${this.getString()}] local autorouting complete`);
10557
+ debug8(`[${this.getString()}] local autorouting complete`);
9835
10558
  resolve(event.traces);
9836
10559
  });
9837
10560
  autorouter.on("error", (event) => {
9838
- debug7(
10561
+ debug8(
9839
10562
  `[${this.getString()}] local autorouting error: ${event.error.message}`
9840
10563
  );
9841
10564
  reject(event.error);
@@ -9892,30 +10615,33 @@ var Group = class extends NormalComponent {
9892
10615
  }
9893
10616
  }
9894
10617
  doInitialPcbTraceRender() {
9895
- const debug7 = Debug8("tscircuit:core:doInitialPcbTraceRender");
10618
+ const debug8 = Debug9("tscircuit:core:doInitialPcbTraceRender");
9896
10619
  if (!this.isSubcircuit) return;
9897
10620
  if (this.root?.pcbDisabled) return;
9898
10621
  if (this.getInheritedProperty("routingDisabled")) return;
9899
10622
  if (this._shouldUseTraceByTraceRouting()) return;
9900
10623
  if (!this._areChildSubcircuitsRouted()) {
9901
- debug7(
10624
+ debug8(
9902
10625
  `[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`
9903
10626
  );
9904
10627
  return;
9905
10628
  }
9906
- debug7(
10629
+ debug8(
9907
10630
  `[${this.getString()}] no child subcircuits to wait for, initiating async routing`
9908
10631
  );
9909
10632
  if (!this._hasTracesToRoute()) return;
9910
10633
  this._startAsyncAutorouting();
9911
10634
  }
10635
+ doInitialSchematicTraceRender() {
10636
+ Group_doInitialSchematicTraceRender(this);
10637
+ }
9912
10638
  updatePcbTraceRender() {
9913
- const debug7 = Debug8("tscircuit:core:updatePcbTraceRender");
9914
- debug7(`[${this.getString()}] updating...`);
10639
+ const debug8 = Debug9("tscircuit:core:updatePcbTraceRender");
10640
+ debug8(`[${this.getString()}] updating...`);
9915
10641
  if (!this.isSubcircuit) return;
9916
10642
  if (this._shouldRouteAsync() && this._hasTracesToRoute() && !this._hasStartedAsyncAutorouting) {
9917
10643
  if (this._areChildSubcircuitsRouted()) {
9918
- debug7(
10644
+ debug8(
9919
10645
  `[${this.getString()}] child subcircuits are now routed, starting async autorouting`
9920
10646
  );
9921
10647
  this._startAsyncAutorouting();
@@ -9926,14 +10652,14 @@ var Group = class extends NormalComponent {
9926
10652
  if (this._shouldUseTraceByTraceRouting()) return;
9927
10653
  const { db } = this.root;
9928
10654
  if (this._asyncAutoroutingResult.output_simple_route_json) {
9929
- debug7(
10655
+ debug8(
9930
10656
  `[${this.getString()}] updating PCB traces from simple route json (${this._asyncAutoroutingResult.output_simple_route_json.traces?.length} traces)`
9931
10657
  );
9932
10658
  this._updatePcbTraceRenderFromSimpleRouteJson();
9933
10659
  return;
9934
10660
  }
9935
10661
  if (this._asyncAutoroutingResult.output_pcb_traces) {
9936
- debug7(
10662
+ debug8(
9937
10663
  `[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`
9938
10664
  );
9939
10665
  this._updatePcbTraceRenderFromPcbTraces();
@@ -10237,13 +10963,10 @@ import {
10237
10963
  checkEachPcbPortConnectedToPcbTraces,
10238
10964
  checkEachPcbTraceNonOverlapping
10239
10965
  } from "@tscircuit/checks";
10240
- var Board = class extends Group {
10241
- constructor() {
10242
- super(...arguments);
10243
- __publicField(this, "pcb_board_id", null);
10244
- __publicField(this, "_drcChecksComplete", false);
10245
- __publicField(this, "_connectedSchematicPortPairs", /* @__PURE__ */ new Set());
10246
- }
10966
+ var Board = class extends Group6 {
10967
+ pcb_board_id = null;
10968
+ _drcChecksComplete = false;
10969
+ _connectedSchematicPortPairs = /* @__PURE__ */ new Set();
10247
10970
  get isSubcircuit() {
10248
10971
  return true;
10249
10972
  }
@@ -10525,10 +11248,7 @@ var Capacitor = class extends NormalComponent {
10525
11248
  // lib/components/normal-components/Chip.ts
10526
11249
  import { chipProps } from "@tscircuit/props";
10527
11250
  var Chip = class extends NormalComponent {
10528
- constructor() {
10529
- super(...arguments);
10530
- __publicField(this, "schematicBoxDimensions", null);
10531
- }
11251
+ schematicBoxDimensions = null;
10532
11252
  get config() {
10533
11253
  return {
10534
11254
  componentName: "Chip",
@@ -10671,13 +11391,6 @@ var Chip = class extends NormalComponent {
10671
11391
  // lib/components/normal-components/Diode.ts
10672
11392
  import { diodeProps } from "@tscircuit/props";
10673
11393
  var Diode = class extends NormalComponent {
10674
- constructor() {
10675
- super(...arguments);
10676
- __publicField(this, "pos", this.portMap.pin1);
10677
- __publicField(this, "anode", this.portMap.pin1);
10678
- __publicField(this, "neg", this.portMap.pin2);
10679
- __publicField(this, "cathode", this.portMap.pin2);
10680
- }
10681
11394
  // @ts-ignore
10682
11395
  get config() {
10683
11396
  const symbolMap = {
@@ -10715,6 +11428,10 @@ var Diode = class extends NormalComponent {
10715
11428
  });
10716
11429
  this.source_component_id = source_component.source_component_id;
10717
11430
  }
11431
+ pos = this.portMap.pin1;
11432
+ anode = this.portMap.pin1;
11433
+ neg = this.portMap.pin2;
11434
+ cathode = this.portMap.pin2;
10718
11435
  };
10719
11436
 
10720
11437
  // lib/components/normal-components/Fuse.ts
@@ -10756,10 +11473,7 @@ var Fuse = class extends NormalComponent {
10756
11473
  // lib/components/normal-components/Jumper.ts
10757
11474
  import { jumperProps } from "@tscircuit/props";
10758
11475
  var Jumper = class extends NormalComponent {
10759
- constructor() {
10760
- super(...arguments);
10761
- __publicField(this, "schematicDimensions", null);
10762
- }
11476
+ schematicDimensions = null;
10763
11477
  get config() {
10764
11478
  return {
10765
11479
  schematicSymbolName: void 0,
@@ -10858,10 +11572,7 @@ var Jumper = class extends NormalComponent {
10858
11572
  // lib/components/normal-components/SolderJumper.ts
10859
11573
  import { solderjumperProps } from "@tscircuit/props";
10860
11574
  var SolderJumper = class extends NormalComponent {
10861
- constructor() {
10862
- super(...arguments);
10863
- __publicField(this, "schematicDimensions", null);
10864
- }
11575
+ schematicDimensions = null;
10865
11576
  _getPinNumberFromBridgedPinName(pinName) {
10866
11577
  const port = this.selectOne(`port.${pinName}`, {
10867
11578
  type: "port"
@@ -11015,13 +11726,6 @@ var SolderJumper = class extends NormalComponent {
11015
11726
  // lib/components/normal-components/Led.ts
11016
11727
  import { ledProps } from "@tscircuit/props";
11017
11728
  var Led = class extends NormalComponent {
11018
- constructor() {
11019
- super(...arguments);
11020
- __publicField(this, "pos", this.portMap.pin1);
11021
- __publicField(this, "anode", this.portMap.pin1);
11022
- __publicField(this, "neg", this.portMap.pin2);
11023
- __publicField(this, "cathode", this.portMap.pin2);
11024
- }
11025
11729
  get config() {
11026
11730
  const symbolMap = {
11027
11731
  laser: "laser_diode"
@@ -11061,18 +11765,15 @@ var Led = class extends NormalComponent {
11061
11765
  });
11062
11766
  this.source_component_id = source_component.source_component_id;
11063
11767
  }
11768
+ pos = this.portMap.pin1;
11769
+ anode = this.portMap.pin1;
11770
+ neg = this.portMap.pin2;
11771
+ cathode = this.portMap.pin2;
11064
11772
  };
11065
11773
 
11066
11774
  // lib/components/normal-components/PowerSource.ts
11067
11775
  import { powerSourceProps } from "@tscircuit/props";
11068
11776
  var PowerSource = class extends NormalComponent {
11069
- constructor() {
11070
- super(...arguments);
11071
- __publicField(this, "pos", this.portMap.pin1);
11072
- __publicField(this, "positive", this.portMap.pin1);
11073
- __publicField(this, "neg", this.portMap.pin2);
11074
- __publicField(this, "negative", this.portMap.pin2);
11075
- }
11076
11777
  // @ts-ignore
11077
11778
  get config() {
11078
11779
  return {
@@ -11103,6 +11804,10 @@ var PowerSource = class extends NormalComponent {
11103
11804
  });
11104
11805
  this.source_component_id = source_component.source_component_id;
11105
11806
  }
11807
+ pos = this.portMap.pin1;
11808
+ positive = this.portMap.pin1;
11809
+ neg = this.portMap.pin2;
11810
+ negative = this.portMap.pin2;
11106
11811
  };
11107
11812
 
11108
11813
  // lib/components/normal-components/VoltageSource.ts
@@ -11119,11 +11824,6 @@ var voltageSourceProps = commonComponentProps.extend({
11119
11824
  phase: rotation2.optional()
11120
11825
  });
11121
11826
  var VoltageSource = class extends NormalComponent {
11122
- constructor() {
11123
- super(...arguments);
11124
- __publicField(this, "terminal1", this.portMap.terminal1);
11125
- __publicField(this, "terminal2", this.portMap.terminal2);
11126
- }
11127
11827
  get config() {
11128
11828
  return {
11129
11829
  componentName: "VoltageSource",
@@ -11184,6 +11884,8 @@ var VoltageSource = class extends NormalComponent {
11184
11884
  phase: props.phase
11185
11885
  });
11186
11886
  }
11887
+ terminal1 = this.portMap.terminal1;
11888
+ terminal2 = this.portMap.terminal2;
11187
11889
  };
11188
11890
 
11189
11891
  // lib/components/normal-components/Resistor.ts
@@ -11333,10 +12035,7 @@ var Constraint2 = class extends PrimitiveComponent2 {
11333
12035
  import { fabricationNotePathProps } from "@tscircuit/props";
11334
12036
  import { applyToPoint as applyToPoint7 } from "transformation-matrix";
11335
12037
  var FabricationNotePath = class extends PrimitiveComponent2 {
11336
- constructor() {
11337
- super(...arguments);
11338
- __publicField(this, "fabrication_note_path_id", null);
11339
- }
12038
+ fabrication_note_path_id = null;
11340
12039
  get config() {
11341
12040
  return {
11342
12041
  componentName: "FabricationNotePath",
@@ -11413,7 +12112,7 @@ var FabricationNoteText = class extends PrimitiveComponent2 {
11413
12112
 
11414
12113
  // lib/components/primitive-components/Group/Subcircuit.ts
11415
12114
  import "@tscircuit/props";
11416
- var Subcircuit = class extends Group {
12115
+ var Subcircuit = class extends Group6 {
11417
12116
  constructor(props) {
11418
12117
  super({
11419
12118
  ...props,
@@ -11424,7 +12123,7 @@ var Subcircuit = class extends Group {
11424
12123
 
11425
12124
  // lib/components/primitive-components/Breakout/Breakout.ts
11426
12125
  import "@tscircuit/props";
11427
- var Breakout = class extends Group {
12126
+ var Breakout = class extends Group6 {
11428
12127
  constructor(props) {
11429
12128
  super({
11430
12129
  ...props,
@@ -11457,13 +12156,10 @@ var Breakout = class extends Group {
11457
12156
  // lib/components/primitive-components/BreakoutPoint.ts
11458
12157
  import { breakoutPointProps } from "@tscircuit/props";
11459
12158
  var BreakoutPoint = class extends PrimitiveComponent2 {
11460
- constructor() {
11461
- super(...arguments);
11462
- __publicField(this, "pcb_breakout_point_id", null);
11463
- __publicField(this, "matchedPort", null);
11464
- __publicField(this, "matchedNet", null);
11465
- __publicField(this, "isPcbPrimitive", true);
11466
- }
12159
+ pcb_breakout_point_id = null;
12160
+ matchedPort = null;
12161
+ matchedNet = null;
12162
+ isPcbPrimitive = true;
11467
12163
  get config() {
11468
12164
  return {
11469
12165
  componentName: "BreakoutPoint",
@@ -11542,11 +12238,9 @@ import {
11542
12238
  identity as identity4,
11543
12239
  translate as translate6
11544
12240
  } from "transformation-matrix";
12241
+ import { calculateElbow as calculateElbow2 } from "calculate-elbow";
11545
12242
  var NetLabel = class extends PrimitiveComponent2 {
11546
- constructor() {
11547
- super(...arguments);
11548
- __publicField(this, "source_net_label_id");
11549
- }
12243
+ source_net_label_id;
11550
12244
  get config() {
11551
12245
  return {
11552
12246
  componentName: "NetLabel",
@@ -11657,16 +12351,87 @@ var NetLabel = class extends PrimitiveComponent2 {
11657
12351
  );
11658
12352
  }
11659
12353
  }
12354
+ doInitialSchematicTraceRender() {
12355
+ if (!this.root?._featureMspSchematicTraceRouting) return;
12356
+ if (this.root?.schematicDisabled) return;
12357
+ const { db } = this.root;
12358
+ const connectsTo = this._resolveConnectsTo();
12359
+ if (!connectsTo || connectsTo.length === 0) return;
12360
+ const anchorPos = this._getGlobalSchematicPositionBeforeLayout();
12361
+ const anchorSide = this._getAnchorSide();
12362
+ const sideToAxisDir = {
12363
+ left: "x-",
12364
+ right: "x+",
12365
+ top: "y+",
12366
+ bottom: "y-"
12367
+ };
12368
+ const anchorFacing = sideToAxisDir[anchorSide];
12369
+ const net = this.getSubcircuit().selectOne(
12370
+ `net.${this._getNetName()}`
12371
+ );
12372
+ for (const connection of connectsTo) {
12373
+ const port = this.getSubcircuit().selectOne(connection, {
12374
+ type: "port"
12375
+ });
12376
+ if (!port || !port.schematic_port_id) continue;
12377
+ let existingTraceForThisConnection = false;
12378
+ if (net?.source_net_id) {
12379
+ const candidateSourceTrace = db.source_trace.list().find(
12380
+ (st) => st.connected_source_net_ids?.includes(net.source_net_id) && st.connected_source_port_ids?.includes(port.source_port_id ?? "")
12381
+ );
12382
+ if (candidateSourceTrace) {
12383
+ existingTraceForThisConnection = db.schematic_trace.list().some(
12384
+ (t) => t.source_trace_id === candidateSourceTrace.source_trace_id
12385
+ );
12386
+ }
12387
+ if (existingTraceForThisConnection) continue;
12388
+ }
12389
+ const portPos = port._getGlobalSchematicPositionAfterLayout();
12390
+ const portFacing = convertFacingDirectionToElbowDirection(
12391
+ port.facingDirection ?? "right"
12392
+ ) ?? "x+";
12393
+ const path = calculateElbow2(
12394
+ {
12395
+ x: portPos.x,
12396
+ y: portPos.y,
12397
+ facingDirection: portFacing
12398
+ },
12399
+ {
12400
+ x: anchorPos.x,
12401
+ y: anchorPos.y,
12402
+ facingDirection: anchorFacing
12403
+ }
12404
+ );
12405
+ if (!Array.isArray(path) || path.length < 2) continue;
12406
+ const edges = [];
12407
+ for (let i = 0; i < path.length - 1; i++) {
12408
+ edges.push({
12409
+ from: { x: path[i].x, y: path[i].y },
12410
+ to: { x: path[i + 1].x, y: path[i + 1].y }
12411
+ });
12412
+ }
12413
+ let source_trace_id;
12414
+ if (net?.source_net_id && port.source_port_id) {
12415
+ const st = db.source_trace.list().find(
12416
+ (s) => s.connected_source_net_ids?.includes(net.source_net_id) && s.connected_source_port_ids?.includes(port.source_port_id)
12417
+ );
12418
+ source_trace_id = st?.source_trace_id;
12419
+ }
12420
+ db.schematic_trace.insert({
12421
+ source_trace_id,
12422
+ edges,
12423
+ junctions: []
12424
+ });
12425
+ db.schematic_port.update(port.schematic_port_id, { is_connected: true });
12426
+ }
12427
+ }
11660
12428
  };
11661
12429
 
11662
12430
  // lib/components/primitive-components/SilkscreenCircle.ts
11663
12431
  import { silkscreenCircleProps } from "@tscircuit/props";
11664
12432
  var SilkscreenCircle = class extends PrimitiveComponent2 {
11665
- constructor() {
11666
- super(...arguments);
11667
- __publicField(this, "pcb_silkscreen_circle_id", null);
11668
- __publicField(this, "isPcbPrimitive", true);
11669
- }
12433
+ pcb_silkscreen_circle_id = null;
12434
+ isPcbPrimitive = true;
11670
12435
  get config() {
11671
12436
  return {
11672
12437
  componentName: "SilkscreenCircle",
@@ -11711,11 +12476,8 @@ var SilkscreenCircle = class extends PrimitiveComponent2 {
11711
12476
  // lib/components/primitive-components/SilkscreenRect.ts
11712
12477
  import { silkscreenRectProps } from "@tscircuit/props";
11713
12478
  var SilkscreenRect = class extends PrimitiveComponent2 {
11714
- constructor() {
11715
- super(...arguments);
11716
- __publicField(this, "pcb_silkscreen_rect_id", null);
11717
- __publicField(this, "isPcbPrimitive", true);
11718
- }
12479
+ pcb_silkscreen_rect_id = null;
12480
+ isPcbPrimitive = true;
11719
12481
  get config() {
11720
12482
  return {
11721
12483
  componentName: "SilkscreenRect",
@@ -11759,11 +12521,8 @@ var SilkscreenRect = class extends PrimitiveComponent2 {
11759
12521
  // lib/components/primitive-components/SilkscreenLine.ts
11760
12522
  import { silkscreenLineProps } from "@tscircuit/props";
11761
12523
  var SilkscreenLine = class extends PrimitiveComponent2 {
11762
- constructor() {
11763
- super(...arguments);
11764
- __publicField(this, "pcb_silkscreen_line_id", null);
11765
- __publicField(this, "isPcbPrimitive", true);
11766
- }
12524
+ pcb_silkscreen_line_id = null;
12525
+ isPcbPrimitive = true;
11767
12526
  get config() {
11768
12527
  return {
11769
12528
  componentName: "SilkscreenLine",
@@ -11807,12 +12566,9 @@ var SilkscreenLine = class extends PrimitiveComponent2 {
11807
12566
  // lib/components/primitive-components/Via.ts
11808
12567
  import { viaProps } from "@tscircuit/props";
11809
12568
  var Via = class extends PrimitiveComponent2 {
11810
- constructor() {
11811
- super(...arguments);
11812
- __publicField(this, "pcb_via_id", null);
11813
- __publicField(this, "matchedPort", null);
11814
- __publicField(this, "isPcbPrimitive", true);
11815
- }
12569
+ pcb_via_id = null;
12570
+ matchedPort = null;
12571
+ isPcbPrimitive = true;
11816
12572
  get config() {
11817
12573
  return {
11818
12574
  componentName: "Via",
@@ -12234,12 +12990,6 @@ var Crystal = class extends NormalComponent {
12234
12990
  // lib/components/normal-components/Transistor.ts
12235
12991
  import { transistorProps } from "@tscircuit/props";
12236
12992
  var Transistor = class extends NormalComponent {
12237
- constructor() {
12238
- super(...arguments);
12239
- __publicField(this, "emitter", this.portMap.pin1);
12240
- __publicField(this, "collector", this.portMap.pin2);
12241
- __publicField(this, "base", this.portMap.pin3);
12242
- }
12243
12993
  get config() {
12244
12994
  const baseSymbolName = this.props.type === "npn" ? "npn_bipolar_transistor" : "pnp_bipolar_transistor";
12245
12995
  return {
@@ -12265,6 +13015,9 @@ var Transistor = class extends NormalComponent {
12265
13015
  additionalAliases: pinAliases
12266
13016
  });
12267
13017
  }
13018
+ emitter = this.portMap.pin1;
13019
+ collector = this.portMap.pin2;
13020
+ base = this.portMap.pin3;
12268
13021
  doInitialCreateNetsFromProps() {
12269
13022
  this._createNetsFromProps([...this._getNetsFromConnectionsProp()]);
12270
13023
  }
@@ -12380,17 +13133,17 @@ var TestPoint = class extends NormalComponent {
12380
13133
  if (!footprintVariant && holeDiameter) {
12381
13134
  footprintVariant = "through_hole";
12382
13135
  }
12383
- footprintVariant ?? (footprintVariant = "through_hole");
12384
- padShape ?? (padShape = "circle");
13136
+ footprintVariant ??= "through_hole";
13137
+ padShape ??= "circle";
12385
13138
  if (footprintVariant === "pad") {
12386
13139
  if (padShape === "circle") {
12387
- padDiameter ?? (padDiameter = TESTPOINT_DEFAULTS.SMT_CIRCLE_DIAMETER);
13140
+ padDiameter ??= TESTPOINT_DEFAULTS.SMT_CIRCLE_DIAMETER;
12388
13141
  } else if (padShape === "rect") {
12389
- width ?? (width = TESTPOINT_DEFAULTS.SMT_RECT_SIZE);
12390
- height ?? (height = width);
13142
+ width ??= TESTPOINT_DEFAULTS.SMT_RECT_SIZE;
13143
+ height ??= width;
12391
13144
  }
12392
13145
  } else if (footprintVariant === "through_hole") {
12393
- holeDiameter ?? (holeDiameter = TESTPOINT_DEFAULTS.HOLE_DIAMETER);
13146
+ holeDiameter ??= TESTPOINT_DEFAULTS.HOLE_DIAMETER;
12394
13147
  }
12395
13148
  return {
12396
13149
  padShape,
@@ -12455,10 +13208,7 @@ var TestPoint = class extends NormalComponent {
12455
13208
  // lib/components/primitive-components/SchematicText.ts
12456
13209
  import { schematicTextProps } from "@tscircuit/props";
12457
13210
  var SchematicText = class extends PrimitiveComponent2 {
12458
- constructor() {
12459
- super(...arguments);
12460
- __publicField(this, "isSchematicPrimitive", true);
12461
- }
13211
+ isSchematicPrimitive = true;
12462
13212
  get config() {
12463
13213
  return {
12464
13214
  componentName: "SchematicText",
@@ -12562,10 +13312,7 @@ function getTitleAnchorAndPosition({
12562
13312
 
12563
13313
  // lib/components/primitive-components/SchematicBox.ts
12564
13314
  var SchematicBox = class extends PrimitiveComponent2 {
12565
- constructor() {
12566
- super(...arguments);
12567
- __publicField(this, "isSchematicPrimitive", true);
12568
- }
13315
+ isSchematicPrimitive = true;
12569
13316
  get config() {
12570
13317
  return {
12571
13318
  componentName: "SchematicBox",
@@ -12686,11 +13433,8 @@ var SchematicBox = class extends PrimitiveComponent2 {
12686
13433
  // lib/components/primitive-components/SchematicTable.ts
12687
13434
  import { schematicTableProps } from "@tscircuit/props";
12688
13435
  var SchematicTable = class extends PrimitiveComponent2 {
12689
- constructor() {
12690
- super(...arguments);
12691
- __publicField(this, "isSchematicPrimitive", true);
12692
- __publicField(this, "schematic_table_id", null);
12693
- }
13436
+ isSchematicPrimitive = true;
13437
+ schematic_table_id = null;
12694
13438
  get config() {
12695
13439
  return {
12696
13440
  componentName: "SchematicTable",
@@ -12818,10 +13562,7 @@ var SchematicTable = class extends PrimitiveComponent2 {
12818
13562
  // lib/components/primitive-components/SchematicRow.ts
12819
13563
  import { schematicRowProps } from "@tscircuit/props";
12820
13564
  var SchematicRow = class extends PrimitiveComponent2 {
12821
- constructor() {
12822
- super(...arguments);
12823
- __publicField(this, "isSchematicPrimitive", true);
12824
- }
13565
+ isSchematicPrimitive = true;
12825
13566
  get config() {
12826
13567
  return {
12827
13568
  componentName: "SchematicRow",
@@ -12833,11 +13574,8 @@ var SchematicRow = class extends PrimitiveComponent2 {
12833
13574
  // lib/components/primitive-components/SchematicCell.ts
12834
13575
  import { schematicCellProps } from "@tscircuit/props";
12835
13576
  var SchematicCell = class extends PrimitiveComponent2 {
12836
- constructor() {
12837
- super(...arguments);
12838
- __publicField(this, "isSchematicPrimitive", true);
12839
- __publicField(this, "canHaveTextChildren", true);
12840
- }
13577
+ isSchematicPrimitive = true;
13578
+ canHaveTextChildren = true;
12841
13579
  get config() {
12842
13580
  return {
12843
13581
  componentName: "SchematicCell",
@@ -12855,7 +13593,7 @@ import { identity as identity5 } from "transformation-matrix";
12855
13593
  var package_default = {
12856
13594
  name: "@tscircuit/core",
12857
13595
  type: "module",
12858
- version: "0.0.644",
13596
+ version: "0.0.646",
12859
13597
  types: "dist/index.d.ts",
12860
13598
  main: "dist/index.js",
12861
13599
  module: "dist/index.js",
@@ -12885,8 +13623,8 @@ var package_default = {
12885
13623
  devDependencies: {
12886
13624
  "@biomejs/biome": "^1.8.3",
12887
13625
  "@tscircuit/capacity-autorouter": "^0.0.100",
12888
- "@tscircuit/circuit-json-util": "^0.0.65",
12889
13626
  "@tscircuit/checks": "^0.0.71",
13627
+ "@tscircuit/circuit-json-util": "^0.0.65",
12890
13628
  "@tscircuit/footprinter": "^0.0.208",
12891
13629
  "@tscircuit/import-snippet": "^0.0.4",
12892
13630
  "@tscircuit/infgrid-ijump-astar": "^0.0.33",
@@ -12898,6 +13636,7 @@ var package_default = {
12898
13636
  "@tscircuit/schematic-autolayout": "^0.0.6",
12899
13637
  "@tscircuit/schematic-corpus": "^0.0.110",
12900
13638
  "@tscircuit/schematic-match-adapt": "^0.0.16",
13639
+ "@tscircuit/schematic-trace-solver": "^0.0.12",
12901
13640
  "@tscircuit/simple-3d-svg": "^0.0.38",
12902
13641
  "@types/bun": "^1.2.16",
12903
13642
  "@types/debug": "^4.1.12",
@@ -12914,6 +13653,7 @@ var package_default = {
12914
13653
  "circuit-json-to-simple-3d": "^0.0.6",
12915
13654
  "circuit-to-svg": "^0.0.174",
12916
13655
  concurrently: "^9.1.2",
13656
+ "connectivity-map": "^1.0.0",
12917
13657
  debug: "^4.3.6",
12918
13658
  "graphics-debug": "^0.0.60",
12919
13659
  howfat: "^0.3.8",
@@ -12962,33 +13702,33 @@ var package_default = {
12962
13702
 
12963
13703
  // lib/RootCircuit.ts
12964
13704
  var RootCircuit = class {
13705
+ firstChild = null;
13706
+ children;
13707
+ db;
13708
+ root = null;
13709
+ isRoot = true;
13710
+ schematicDisabled = false;
13711
+ pcbDisabled = false;
13712
+ pcbRoutingDisabled = false;
13713
+ _featureMspSchematicTraceRouting = false;
13714
+ /**
13715
+ * The RootCircuit name is usually set by the platform, it's not required but
13716
+ * if supplied can identify the circuit in certain effects, e.g. it is passed
13717
+ * as the display_name parameter for autorouting effects.
13718
+ */
13719
+ name;
13720
+ platform;
13721
+ /**
13722
+ * Optional URL pointing to where this project is hosted or documented.
13723
+ * When provided it is stored in the source_project_metadata.project_url field
13724
+ * of the generated Circuit JSON.
13725
+ */
13726
+ projectUrl;
13727
+ _hasRenderedAtleastOnce = false;
12965
13728
  constructor({
12966
13729
  platform,
12967
13730
  projectUrl
12968
13731
  } = {}) {
12969
- __publicField(this, "firstChild", null);
12970
- __publicField(this, "children");
12971
- __publicField(this, "db");
12972
- __publicField(this, "root", null);
12973
- __publicField(this, "isRoot", true);
12974
- __publicField(this, "schematicDisabled", false);
12975
- __publicField(this, "pcbDisabled", false);
12976
- __publicField(this, "pcbRoutingDisabled", false);
12977
- /**
12978
- * The RootCircuit name is usually set by the platform, it's not required but
12979
- * if supplied can identify the circuit in certain effects, e.g. it is passed
12980
- * as the display_name parameter for autorouting effects.
12981
- */
12982
- __publicField(this, "name");
12983
- __publicField(this, "platform");
12984
- /**
12985
- * Optional URL pointing to where this project is hosted or documented.
12986
- * When provided it is stored in the source_project_metadata.project_url field
12987
- * of the generated Circuit JSON.
12988
- */
12989
- __publicField(this, "projectUrl");
12990
- __publicField(this, "_hasRenderedAtleastOnce", false);
12991
- __publicField(this, "_eventListeners", {});
12992
13732
  this.children = [];
12993
13733
  this.db = su5([]);
12994
13734
  this.root = this;
@@ -13024,7 +13764,7 @@ var RootCircuit = class {
13024
13764
  this.firstChild = this.children[0];
13025
13765
  return;
13026
13766
  }
13027
- const group = new Group({ subcircuit: true });
13767
+ const group = new Group6({ subcircuit: true });
13028
13768
  group.parent = this;
13029
13769
  group.addAll(this.children);
13030
13770
  this.children = [group];
@@ -13110,6 +13850,7 @@ var RootCircuit = class {
13110
13850
  this._guessRootComponent();
13111
13851
  return this.firstChild?.selectOne(selector, opts) ?? null;
13112
13852
  }
13853
+ _eventListeners = {};
13113
13854
  emit(event, ...args) {
13114
13855
  if (!this._eventListeners[event]) return;
13115
13856
  for (const listener of this._eventListeners[event]) {
@@ -13363,7 +14104,7 @@ export {
13363
14104
  FabricationNoteText,
13364
14105
  Footprint,
13365
14106
  Fuse,
13366
- Group,
14107
+ Group6 as Group,
13367
14108
  Hole,
13368
14109
  Inductor,
13369
14110
  Jumper,