@tscircuit/cli 0.1.954 → 0.1.955

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/main.js CHANGED
@@ -74389,7 +74389,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
74389
74389
  import { execSync as execSync2 } from "node:child_process";
74390
74390
  var import_semver2 = __toESM2(require_semver2(), 1);
74391
74391
  // package.json
74392
- var version = "0.1.953";
74392
+ var version = "0.1.954";
74393
74393
  var package_default = {
74394
74394
  name: "@tscircuit/cli",
74395
74395
  main: "dist/cli/main.js",
@@ -74418,7 +74418,7 @@ var package_default = {
74418
74418
  "@types/semver": "^7.5.8",
74419
74419
  "bun-match-svg": "^0.0.12",
74420
74420
  chokidar: "4.0.1",
74421
- "circuit-json-to-kicad": "^0.0.71",
74421
+ "circuit-json-to-kicad": "^0.0.76",
74422
74422
  "circuit-json-to-readable-netlist": "^0.0.13",
74423
74423
  "circuit-json-to-spice": "^0.0.10",
74424
74424
  "circuit-json-to-tscircuit": "^0.0.9",
@@ -76290,63 +76290,79 @@ __export2(exports_dist, {
76290
76290
  });
76291
76291
  import { KicadSch } from "kicadts";
76292
76292
  import { cju } from "@tscircuit/circuit-json-util";
76293
- import { compose, translate, scale } from "transformation-matrix";
76293
+ import { compose as compose2, translate as translate2, scale } from "transformation-matrix";
76294
76294
  import { Paper, Uuid } from "kicadts";
76295
76295
  import {
76296
76296
  EmbeddedFonts,
76297
76297
  LibSymbols,
76298
- Pts,
76299
- SchematicSymbol,
76300
- Stroke,
76298
+ SchematicSymbol as SchematicSymbol4,
76299
+ SymbolPinNames,
76300
+ SymbolPinNumbers
76301
+ } from "kicadts";
76302
+ import { symbols as symbols2 } from "schematic-symbols";
76303
+ import { symbols } from "schematic-symbols";
76304
+ import { SchematicSymbol } from "kicadts";
76305
+ import {
76306
+ compose,
76307
+ scale as createScaleMatrix,
76308
+ translate
76309
+ } from "transformation-matrix";
76310
+ import { Pts, Stroke, SymbolPolyline, SymbolPolylineFill, Xy } from "kicadts";
76311
+ import { applyToPoint } from "transformation-matrix";
76312
+ import {
76313
+ Stroke as Stroke2,
76301
76314
  SymbolCircle,
76302
76315
  SymbolCircleCenter,
76303
76316
  SymbolCircleFill,
76304
- SymbolCircleRadius,
76317
+ SymbolCircleRadius
76318
+ } from "kicadts";
76319
+ import { applyToPoint as applyToPoint2 } from "transformation-matrix";
76320
+ import { SymbolText, TextEffects, TextEffectsFont } from "kicadts";
76321
+ import { applyToPoint as applyToPoint3 } from "transformation-matrix";
76322
+ import { SymbolProperty } from "kicadts";
76323
+ import { TextEffects as TextEffects2, TextEffectsFont as TextEffectsFont2 } from "kicadts";
76324
+ import {
76325
+ SchematicSymbol as SchematicSymbol3,
76305
76326
  SymbolPin,
76306
76327
  SymbolPinName,
76307
- SymbolPinNames,
76308
76328
  SymbolPinNumber,
76309
- SymbolPinNumbers,
76310
- SymbolPolyline,
76311
- SymbolPolylineFill,
76312
- SymbolProperty,
76313
- TextEffects,
76314
- TextEffectsFont,
76315
- Xy
76329
+ TextEffects as TextEffects3,
76330
+ TextEffectsFont as TextEffectsFont3
76316
76331
  } from "kicadts";
76317
- import { symbols as symbols2 } from "schematic-symbols";
76318
- import { symbols } from "schematic-symbols";
76319
- import { applyToPoint, scale as createScaleMatrix } from "transformation-matrix";
76332
+ import { applyToPoint as applyToPoint4, scale as createScaleMatrix2 } from "transformation-matrix";
76320
76333
  import {
76321
- SchematicSymbol as SchematicSymbol2,
76334
+ SchematicSymbol as SchematicSymbol5,
76322
76335
  SymbolLibId,
76323
76336
  SymbolProperty as SymbolProperty2,
76324
76337
  SymbolPin as SymbolPin2,
76325
76338
  SymbolInstances,
76326
76339
  SymbolInstancesProject,
76327
76340
  SymbolInstancePath,
76328
- TextEffects as TextEffects2,
76329
- TextEffectsFont as TextEffectsFont2,
76330
- TextEffectsJustify
76341
+ TextEffects as TextEffects4,
76342
+ TextEffectsFont as TextEffectsFont4,
76343
+ TextEffectsJustify,
76344
+ EmbeddedFonts as EmbeddedFonts2,
76345
+ SymbolPinNames as SymbolPinNames2,
76346
+ SymbolPinNumbers as SymbolPinNumbers2
76331
76347
  } from "kicadts";
76332
- import { applyToPoint as applyToPoint2 } from "transformation-matrix";
76348
+ import { applyToPoint as applyToPoint5 } from "transformation-matrix";
76333
76349
  import { symbols as symbols3 } from "schematic-symbols";
76334
76350
  import {
76335
- SchematicSymbol as SchematicSymbol3,
76351
+ SchematicSymbol as SchematicSymbol6,
76336
76352
  SymbolLibId as SymbolLibId2,
76337
76353
  SymbolProperty as SymbolProperty3,
76338
76354
  SymbolPin as SymbolPin3,
76339
76355
  SymbolInstances as SymbolInstances2,
76340
76356
  SymbolInstancesProject as SymbolInstancesProject2,
76341
76357
  SymbolInstancePath as SymbolInstancePath2,
76342
- TextEffects as TextEffects3,
76343
- TextEffectsFont as TextEffectsFont3,
76358
+ TextEffects as TextEffects5,
76359
+ TextEffectsFont as TextEffectsFont5,
76344
76360
  TextEffectsJustify as TextEffectsJustify2,
76345
76361
  GlobalLabel
76346
76362
  } from "kicadts";
76347
- import { applyToPoint as applyToPoint3 } from "transformation-matrix";
76348
- import { Wire, Pts as Pts2, Xy as Xy2, Stroke as Stroke2, Junction } from "kicadts";
76349
- import { applyToPoint as applyToPoint4 } from "transformation-matrix";
76363
+ import { applyToPoint as applyToPoint6 } from "transformation-matrix";
76364
+ import { Wire, Pts as Pts2, Xy as Xy2, Stroke as Stroke3, Junction } from "kicadts";
76365
+ import { applyToPoint as applyToPoint7 } from "transformation-matrix";
76350
76366
  import {
76351
76367
  SheetInstances,
76352
76368
  SheetInstancesRootPath,
@@ -76355,7 +76371,7 @@ import {
76355
76371
  } from "kicadts";
76356
76372
  import { KicadPcb } from "kicadts";
76357
76373
  import { cju as cju2 } from "@tscircuit/circuit-json-util";
76358
- import { compose as compose3, translate as translate3, scale as scale3 } from "transformation-matrix";
76374
+ import { compose as compose4, translate as translate4, scale as scale3 } from "transformation-matrix";
76359
76375
  import {
76360
76376
  Paper as Paper2,
76361
76377
  PcbLayers,
@@ -76364,20 +76380,28 @@ import {
76364
76380
  Setup
76365
76381
  } from "kicadts";
76366
76382
  import { PcbNet } from "kicadts";
76367
- import { Footprint } from "kicadts";
76368
- import { applyToPoint as applyToPoint10 } from "transformation-matrix";
76369
- import { FpCircle, Stroke as Stroke3 } from "kicadts";
76370
- import { FpCircle as FpCircle2, Stroke as Stroke4 } from "kicadts";
76371
- import { FpRect, Stroke as Stroke5 } from "kicadts";
76372
- import { FpRect as FpRect2, Stroke as Stroke6 } from "kicadts";
76373
- import { FpRect as FpRect3, Stroke as Stroke7 } from "kicadts";
76374
- import { FpPoly, Pts as Pts3, Xy as Xy3, Stroke as Stroke8 } from "kicadts";
76383
+ import { Footprint as Footprint2 } from "kicadts";
76384
+ import { applyToPoint as applyToPoint13 } from "transformation-matrix";
76385
+ import {
76386
+ Property,
76387
+ TextEffects as TextEffects6,
76388
+ TextEffectsFont as TextEffectsFont6,
76389
+ EmbeddedFonts as EmbeddedFonts4,
76390
+ FootprintModel,
76391
+ FootprintAttr
76392
+ } from "kicadts";
76393
+ import { FpCircle, Stroke as Stroke4 } from "kicadts";
76394
+ import { FpCircle as FpCircle2, Stroke as Stroke5 } from "kicadts";
76395
+ import { FpRect, Stroke as Stroke6 } from "kicadts";
76396
+ import { FpRect as FpRect2, Stroke as Stroke7 } from "kicadts";
76397
+ import { FpRect as FpRect3, Stroke as Stroke8 } from "kicadts";
76398
+ import { FpPoly, Pts as Pts3, Xy as Xy3, Stroke as Stroke9 } from "kicadts";
76375
76399
  import"kicadts";
76376
- import { FpText, TextEffects as TextEffects4, TextEffectsFont as TextEffectsFont4 } from "kicadts";
76377
- import { applyToPoint as applyToPoint5, rotate, identity } from "transformation-matrix";
76378
- import { FpText as FpText3, TextEffects as TextEffects5, TextEffectsFont as TextEffectsFont5 } from "kicadts";
76379
- import { applyToPoint as applyToPoint6, rotate as rotate2, identity as identity2 } from "transformation-matrix";
76380
- import { FootprintModel } from "kicadts";
76400
+ import { FpText, TextEffects as TextEffects7, TextEffectsFont as TextEffectsFont7 } from "kicadts";
76401
+ import { applyToPoint as applyToPoint8, rotate, identity } from "transformation-matrix";
76402
+ import { FpText as FpText3, TextEffects as TextEffects8, TextEffectsFont as TextEffectsFont8 } from "kicadts";
76403
+ import { applyToPoint as applyToPoint9, rotate as rotate2, identity as identity2 } from "transformation-matrix";
76404
+ import { FootprintModel as FootprintModel2 } from "kicadts";
76381
76405
  import {
76382
76406
  FootprintPad,
76383
76407
  PadPrimitives,
@@ -76388,69 +76412,69 @@ import {
76388
76412
  PadNet
76389
76413
  } from "kicadts";
76390
76414
  import {
76391
- applyToPoint as applyToPoint7,
76392
- compose as compose2,
76393
- translate as translate2,
76415
+ applyToPoint as applyToPoint10,
76416
+ compose as compose3,
76417
+ translate as translate3,
76394
76418
  scale as scale2,
76395
76419
  rotate as rotate3
76396
76420
  } from "transformation-matrix";
76397
76421
  import { FootprintPad as FootprintPad2, PadDrill, PadNet as PadNet2 } from "kicadts";
76398
- import { applyToPoint as applyToPoint8, rotate as rotate4, identity as identity3 } from "transformation-matrix";
76422
+ import { applyToPoint as applyToPoint11, rotate as rotate4, identity as identity3 } from "transformation-matrix";
76399
76423
  import { FootprintPad as FootprintPad3, PadDrill as PadDrill2 } from "kicadts";
76400
- import { applyToPoint as applyToPoint9, rotate as rotate5, identity as identity4 } from "transformation-matrix";
76424
+ import { applyToPoint as applyToPoint12, rotate as rotate5, identity as identity4 } from "transformation-matrix";
76401
76425
  import { Segment, SegmentNet } from "kicadts";
76402
- import { applyToPoint as applyToPoint11 } from "transformation-matrix";
76426
+ import { applyToPoint as applyToPoint14 } from "transformation-matrix";
76403
76427
  import { Via, ViaNet } from "kicadts";
76404
- import { applyToPoint as applyToPoint12 } from "transformation-matrix";
76428
+ import { applyToPoint as applyToPoint15 } from "transformation-matrix";
76405
76429
  import { GrLine } from "kicadts";
76406
76430
  import {
76407
76431
  At,
76408
76432
  GrText,
76409
- TextEffects as TextEffects6,
76410
- TextEffectsFont as TextEffectsFont6,
76433
+ TextEffects as TextEffects9,
76434
+ TextEffectsFont as TextEffectsFont9,
76411
76435
  TextEffectsJustify as TextEffectsJustify3
76412
76436
  } from "kicadts";
76413
- import { applyToPoint as applyToPoint13 } from "transformation-matrix";
76414
- import { applyToPoint as applyToPoint15 } from "transformation-matrix";
76437
+ import { applyToPoint as applyToPoint16 } from "transformation-matrix";
76438
+ import { applyToPoint as applyToPoint18 } from "transformation-matrix";
76415
76439
  import {
76416
76440
  GrText as GrText2,
76417
- TextEffects as TextEffects7,
76418
- TextEffectsFont as TextEffectsFont7,
76441
+ TextEffects as TextEffects10,
76442
+ TextEffectsFont as TextEffectsFont10,
76419
76443
  TextEffectsJustify as TextEffectsJustify4,
76420
76444
  At as At2
76421
76445
  } from "kicadts";
76422
- import { applyToPoint as applyToPoint14 } from "transformation-matrix";
76446
+ import { applyToPoint as applyToPoint17 } from "transformation-matrix";
76423
76447
  import { cju as cju3 } from "@tscircuit/circuit-json-util";
76424
76448
  import { cju as cju4 } from "@tscircuit/circuit-json-util";
76425
76449
  import { parseKicadSexpr, KicadSch as KicadSch2 } from "kicadts";
76426
76450
  import {
76427
76451
  parseKicadSexpr as parseKicadSexpr2,
76428
76452
  KicadPcb as KicadPcb2,
76429
- FootprintModel as FootprintModel2,
76453
+ FootprintModel as FootprintModel3,
76430
76454
  At as At3,
76431
- EmbeddedFonts as EmbeddedFonts4,
76432
- FootprintAttr,
76433
- Property,
76434
- TextEffects as TextEffects8,
76435
- TextEffectsFont as TextEffectsFont8
76455
+ EmbeddedFonts as EmbeddedFonts5,
76456
+ FootprintAttr as FootprintAttr2,
76457
+ Property as Property2,
76458
+ TextEffects as TextEffects11,
76459
+ TextEffectsFont as TextEffectsFont11
76436
76460
  } from "kicadts";
76437
76461
  import { KicadSymbolLib } from "kicadts";
76438
76462
  import { parseKicadMod } from "kicadts";
76439
76463
  import {
76440
76464
  parseKicadSexpr as parseKicadSexpr3,
76441
- Footprint as Footprint3,
76442
- Property as Property2,
76443
- TextEffects as TextEffects9,
76444
- TextEffectsFont as TextEffectsFont9
76465
+ Footprint as Footprint4,
76466
+ Property as Property3,
76467
+ TextEffects as TextEffects12,
76468
+ TextEffectsFont as TextEffectsFont12
76445
76469
  } from "kicadts";
76446
76470
  import { parseKicadMod as parseKicadMod2 } from "kicadts";
76447
76471
  import {
76448
- EmbeddedFonts as EmbeddedFonts5,
76449
- SymbolPinNames as SymbolPinNames2,
76450
- SymbolPinNumbers as SymbolPinNumbers2,
76472
+ EmbeddedFonts as EmbeddedFonts6,
76473
+ SymbolPinNames as SymbolPinNames3,
76474
+ SymbolPinNumbers as SymbolPinNumbers3,
76451
76475
  SymbolProperty as SymbolProperty4,
76452
- TextEffects as TextEffects10,
76453
- TextEffectsFont as TextEffectsFont10,
76476
+ TextEffects as TextEffects13,
76477
+ TextEffectsFont as TextEffectsFont13,
76454
76478
  TextEffectsJustify as TextEffectsJustify5
76455
76479
  } from "kicadts";
76456
76480
  import { KicadSymbolLib as KicadSymbolLib2 } from "kicadts";
@@ -76599,6 +76623,427 @@ function getLibraryId(sourceComp, schematicComp, cadComponent, schematicSymbolNa
76599
76623
  const refPrefix = getReferencePrefixForComponent(sourceComp);
76600
76624
  return `Device:${refPrefix}_${ergonomicName}`;
76601
76625
  }
76626
+ function buildSymbolDataFromSchematicPrimitives(params2) {
76627
+ const {
76628
+ circuitJson,
76629
+ schematicSymbolId,
76630
+ schematicSymbol,
76631
+ schematicComponentId
76632
+ } = params2;
76633
+ const circles = circuitJson.filter((el) => el.type === "schematic_circle" && el.schematic_symbol_id === schematicSymbolId);
76634
+ const symbolLines = circuitJson.filter((el) => el.type === "schematic_line" && el.schematic_symbol_id === schematicSymbolId);
76635
+ const schLines = schematicComponentId ? circuitJson.filter((el) => el.type === "schematic_line" && el.schematic_component_id === schematicComponentId && !el.schematic_symbol_id) : [];
76636
+ const lines = [...symbolLines, ...schLines];
76637
+ const paths = circuitJson.filter((el) => el.type === "schematic_path" && el.schematic_symbol_id === schematicSymbolId);
76638
+ const texts = circuitJson.filter((el) => el.type === "schematic_text" && el.schematic_symbol_id === schematicSymbolId);
76639
+ let ports = circuitJson.filter((el) => el.type === "schematic_port" && ("schematic_symbol_id" in el) && el.schematic_symbol_id === schematicSymbolId);
76640
+ if (ports.length === 0 && schematicComponentId) {
76641
+ ports = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_component_id === schematicComponentId && el.display_pin_label !== undefined);
76642
+ if (ports.length === 0) {
76643
+ const allPorts = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_component_id === schematicComponentId);
76644
+ const seenPinNumbers = /* @__PURE__ */ new Set;
76645
+ ports = allPorts.filter((port) => {
76646
+ const pinNum = port.pin_number;
76647
+ if (pinNum !== undefined) {
76648
+ if (seenPinNumbers.has(pinNum)) {
76649
+ return false;
76650
+ }
76651
+ seenPinNumbers.add(pinNum);
76652
+ }
76653
+ return true;
76654
+ });
76655
+ }
76656
+ }
76657
+ const primitives2 = [];
76658
+ for (const circle of circles) {
76659
+ primitives2.push({
76660
+ type: "circle",
76661
+ x: circle.center?.x ?? 0,
76662
+ y: circle.center?.y ?? 0,
76663
+ radius: circle.radius ?? 0.5,
76664
+ fill: circle.is_filled ?? false,
76665
+ fillColor: circle.fill_color
76666
+ });
76667
+ }
76668
+ for (const line of lines) {
76669
+ primitives2.push({
76670
+ type: "path",
76671
+ points: [
76672
+ { x: line.x1 ?? 0, y: line.y1 ?? 0 },
76673
+ { x: line.x2 ?? 0, y: line.y2 ?? 0 }
76674
+ ]
76675
+ });
76676
+ }
76677
+ for (const path14 of paths) {
76678
+ if (path14.points && path14.points.length > 0) {
76679
+ primitives2.push({
76680
+ type: "path",
76681
+ points: path14.points,
76682
+ fill: path14.is_filled ?? false,
76683
+ fillColor: path14.fill_color
76684
+ });
76685
+ }
76686
+ }
76687
+ const symbolTexts = texts.map((text) => ({
76688
+ text: text.text ?? "",
76689
+ x: text.position?.x ?? 0,
76690
+ y: text.position?.y ?? 0,
76691
+ fontSize: text.font_size ?? 0.2,
76692
+ anchor: text.anchor ?? "center"
76693
+ }));
76694
+ const symbolPorts = ports.map((port, index) => ({
76695
+ x: port.center?.x ?? 0,
76696
+ y: port.center?.y ?? 0,
76697
+ labels: [port.display_pin_label || `${port.pin_number || index + 1}`],
76698
+ pinNumber: port.pin_number || index + 1,
76699
+ facingDirection: port.facing_direction
76700
+ }));
76701
+ symbolPorts.sort((a, b) => a.pinNumber - b.pinNumber);
76702
+ return {
76703
+ center: schematicSymbol.center || { x: 0, y: 0 },
76704
+ size: schematicSymbol.size || { width: 1, height: 1 },
76705
+ primitives: primitives2,
76706
+ texts: symbolTexts,
76707
+ ports: symbolPorts
76708
+ };
76709
+ }
76710
+ function createPolylineFromPoints({
76711
+ points,
76712
+ transform,
76713
+ fillType
76714
+ }) {
76715
+ const polyline = new SymbolPolyline;
76716
+ const xyPoints = points.map((p) => {
76717
+ const transformed = applyToPoint(transform, p);
76718
+ return new Xy(transformed.x, transformed.y);
76719
+ });
76720
+ const pts = new Pts(xyPoints);
76721
+ polyline.points = pts;
76722
+ const stroke = new Stroke;
76723
+ stroke.width = 0.254;
76724
+ stroke.type = "default";
76725
+ polyline.stroke = stroke;
76726
+ const fill = new SymbolPolylineFill;
76727
+ fill.type = fillType;
76728
+ polyline.fill = fill;
76729
+ return polyline;
76730
+ }
76731
+ function createCircleFromPrimitive({
76732
+ primitive,
76733
+ transform,
76734
+ scale: scale4
76735
+ }) {
76736
+ const circle = new SymbolCircle;
76737
+ const scaledPos = applyToPoint2(transform, {
76738
+ x: primitive.x,
76739
+ y: primitive.y
76740
+ });
76741
+ const c = circle;
76742
+ c._sxCenter = new SymbolCircleCenter(scaledPos.x, scaledPos.y);
76743
+ c._sxRadius = new SymbolCircleRadius(primitive.radius * scale4);
76744
+ const stroke = new Stroke2;
76745
+ stroke.width = 0.254;
76746
+ stroke.type = "default";
76747
+ c._sxStroke = stroke;
76748
+ const fill = new SymbolCircleFill;
76749
+ fill.type = primitive.fill ? "background" : "none";
76750
+ c._sxFill = fill;
76751
+ return circle;
76752
+ }
76753
+ function createTextFromPrimitive({
76754
+ schText,
76755
+ transform,
76756
+ scale: scale4
76757
+ }) {
76758
+ const symbolText = new SymbolText;
76759
+ const scaledPos = applyToPoint3(transform, { x: schText.x, y: schText.y });
76760
+ symbolText.value = schText.text;
76761
+ symbolText.at = [scaledPos.x, scaledPos.y, 0];
76762
+ const scaledFontSize = schText.fontSize * scale4;
76763
+ const font = new TextEffectsFont;
76764
+ font.size = { height: scaledFontSize, width: scaledFontSize };
76765
+ symbolText.effects = new TextEffects({ font });
76766
+ return symbolText;
76767
+ }
76768
+ function createDrawingSubsymbol({
76769
+ libId,
76770
+ symbolData,
76771
+ isChip,
76772
+ c2kMatSchScale
76773
+ }) {
76774
+ const drawingSymbol = new SchematicSymbol({
76775
+ libraryId: `${libId.split(":")[1]}_0_1`
76776
+ });
76777
+ const GRID_ALIGNED_SCALE = 15.24;
76778
+ const symbolScale = isChip ? c2kMatSchScale : GRID_ALIGNED_SCALE;
76779
+ const cx = symbolData.center?.x ?? 0;
76780
+ const cy = symbolData.center?.y ?? 0;
76781
+ const transform = compose(createScaleMatrix(symbolScale, symbolScale), translate(-cx, -cy));
76782
+ for (const primitive of symbolData.primitives || []) {
76783
+ if (primitive.type === "path" && primitive.points) {
76784
+ const fillType = isChip || primitive.fill ? "background" : "none";
76785
+ const polyline = createPolylineFromPoints({
76786
+ points: primitive.points,
76787
+ transform,
76788
+ fillType
76789
+ });
76790
+ drawingSymbol.polylines.push(polyline);
76791
+ } else if (primitive.type === "circle") {
76792
+ const circle = createCircleFromPrimitive({
76793
+ primitive,
76794
+ transform,
76795
+ scale: symbolScale
76796
+ });
76797
+ drawingSymbol.circles.push(circle);
76798
+ }
76799
+ }
76800
+ const textsArray = Array.isArray(symbolData.texts) ? symbolData.texts : [];
76801
+ for (const schText of textsArray) {
76802
+ const symbolText = createTextFromPrimitive({
76803
+ schText,
76804
+ transform,
76805
+ scale: symbolScale
76806
+ });
76807
+ drawingSymbol.texts.push(symbolText);
76808
+ }
76809
+ return drawingSymbol;
76810
+ }
76811
+ function createGenericChipSymbolData(schematicComp, db) {
76812
+ 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));
76813
+ const width = schematicComp.size?.width || 1.5;
76814
+ const height = schematicComp.size?.height || 1;
76815
+ const boxPath = {
76816
+ type: "path",
76817
+ points: [
76818
+ { x: -width / 2, y: -height / 2 },
76819
+ { x: width / 2, y: -height / 2 },
76820
+ { x: width / 2, y: height / 2 },
76821
+ { x: -width / 2, y: height / 2 },
76822
+ { x: -width / 2, y: -height / 2 }
76823
+ ]
76824
+ };
76825
+ const ports = schematicPorts.map((port) => {
76826
+ const portX = port.center.x - schematicComp.center.x;
76827
+ const portY = port.center.y - schematicComp.center.y;
76828
+ return {
76829
+ x: portX,
76830
+ y: portY,
76831
+ labels: [port.display_pin_label || `${port.pin_number || 1}`],
76832
+ pinNumber: port.pin_number || 1
76833
+ };
76834
+ });
76835
+ return {
76836
+ center: { x: 0, y: 0 },
76837
+ primitives: [boxPath],
76838
+ ports,
76839
+ size: { width, height }
76840
+ };
76841
+ }
76842
+ function createTextEffects(size, hide) {
76843
+ const font = new TextEffectsFont2;
76844
+ font.size = { height: size, width: size };
76845
+ return new TextEffects2({
76846
+ font,
76847
+ hiddenText: hide
76848
+ });
76849
+ }
76850
+ function addSymbolProperties({
76851
+ symbol,
76852
+ libId,
76853
+ description,
76854
+ keywords,
76855
+ fpFilters,
76856
+ footprintRef = "",
76857
+ referencePrefix
76858
+ }) {
76859
+ const refPrefix = referencePrefix || libId.split(":")[1]?.[0] || "U";
76860
+ const properties = [
76861
+ {
76862
+ key: "Reference",
76863
+ value: refPrefix,
76864
+ id: 0,
76865
+ at: [2.032, 0, 90],
76866
+ hide: false
76867
+ },
76868
+ { key: "Value", value: refPrefix, id: 1, at: [0, 0, 90], hide: false },
76869
+ {
76870
+ key: "Footprint",
76871
+ value: footprintRef,
76872
+ id: 2,
76873
+ at: [-1.778, 0, 90],
76874
+ hide: true
76875
+ },
76876
+ {
76877
+ key: "Datasheet",
76878
+ value: "~",
76879
+ id: 3,
76880
+ at: [0, 0, 0],
76881
+ hide: true
76882
+ },
76883
+ {
76884
+ key: "Description",
76885
+ value: description,
76886
+ id: 4,
76887
+ at: [0, 0, 0],
76888
+ hide: true
76889
+ },
76890
+ {
76891
+ key: "ki_keywords",
76892
+ value: keywords,
76893
+ id: 5,
76894
+ at: [0, 0, 0],
76895
+ hide: true
76896
+ },
76897
+ {
76898
+ key: "ki_fp_filters",
76899
+ value: fpFilters,
76900
+ id: 6,
76901
+ at: [0, 0, 0],
76902
+ hide: true
76903
+ }
76904
+ ];
76905
+ for (const prop of properties) {
76906
+ symbol.properties.push(new SymbolProperty({
76907
+ key: prop.key,
76908
+ value: prop.value,
76909
+ id: prop.id,
76910
+ at: prop.at,
76911
+ effects: createTextEffects(1.27, prop.hide)
76912
+ }));
76913
+ }
76914
+ }
76915
+ function calculatePinPosition({
76916
+ port,
76917
+ center,
76918
+ size,
76919
+ isChip,
76920
+ portIndex,
76921
+ schematicComponent,
76922
+ schematicPorts,
76923
+ c2kMatSchScale
76924
+ }) {
76925
+ const GRID_ALIGNED_SCALE = 15.24;
76926
+ const symbolScale = isChip ? c2kMatSchScale : GRID_ALIGNED_SCALE;
76927
+ let portX = port.x ?? 0;
76928
+ let portY = port.y ?? 0;
76929
+ let usingCircuitJsonPort = false;
76930
+ if (isChip && portIndex !== undefined && schematicComponent) {
76931
+ const sortedPorts = schematicPorts.filter((p) => p.schematic_component_id === schematicComponent.schematic_component_id).sort((a, b) => (a.pin_number || 0) - (b.pin_number || 0));
76932
+ if (sortedPorts[portIndex]) {
76933
+ const schPort = sortedPorts[portIndex];
76934
+ portX = schPort.center.x - schematicComponent.center.x;
76935
+ portY = schPort.center.y - schematicComponent.center.y;
76936
+ usingCircuitJsonPort = true;
76937
+ }
76938
+ }
76939
+ let dx;
76940
+ let dy;
76941
+ if (usingCircuitJsonPort) {
76942
+ dx = portX;
76943
+ dy = portY;
76944
+ } else {
76945
+ const cx = center?.x ?? 0;
76946
+ const cy = center?.y ?? 0;
76947
+ dx = portX - cx;
76948
+ dy = portY - cy;
76949
+ }
76950
+ const scaleMatrix = createScaleMatrix2(symbolScale, symbolScale);
76951
+ const scaled = applyToPoint4(scaleMatrix, { x: dx, y: dy });
76952
+ let isHorizontalPin;
76953
+ if (isChip && size) {
76954
+ const halfWidth = size.width / 2;
76955
+ const halfHeight = size.height / 2;
76956
+ const normalizedDx = Math.abs(dx) / halfWidth;
76957
+ const normalizedDy = Math.abs(dy) / halfHeight;
76958
+ isHorizontalPin = normalizedDx > normalizedDy;
76959
+ } else {
76960
+ isHorizontalPin = Math.abs(dx) > Math.abs(dy);
76961
+ }
76962
+ let x = scaled.x;
76963
+ let y = scaled.y;
76964
+ const CHIP_PIN_LENGTH = 6;
76965
+ if (isChip && size) {
76966
+ const halfWidth = size.width / 2 * symbolScale;
76967
+ const halfHeight = size.height / 2 * symbolScale;
76968
+ if (isHorizontalPin) {
76969
+ x = dx > 0 ? halfWidth : -halfWidth;
76970
+ y = dy * symbolScale;
76971
+ } else {
76972
+ x = dx * symbolScale;
76973
+ y = dy > 0 ? halfHeight : -halfHeight;
76974
+ }
76975
+ }
76976
+ let angle = 0;
76977
+ if (isHorizontalPin) {
76978
+ if (dx > 0) {
76979
+ angle = 180;
76980
+ if (isChip)
76981
+ x = x + CHIP_PIN_LENGTH;
76982
+ } else {
76983
+ angle = 0;
76984
+ if (isChip)
76985
+ x = x - CHIP_PIN_LENGTH;
76986
+ }
76987
+ } else {
76988
+ if (dy > 0) {
76989
+ angle = 270;
76990
+ if (isChip)
76991
+ y = y + CHIP_PIN_LENGTH;
76992
+ } else {
76993
+ angle = 90;
76994
+ if (isChip)
76995
+ y = y - CHIP_PIN_LENGTH;
76996
+ }
76997
+ }
76998
+ return { x, y, angle };
76999
+ }
77000
+ function createPinSubsymbol({
77001
+ libId,
77002
+ symbolData,
77003
+ isChip,
77004
+ schematicComponent,
77005
+ schematicPorts,
77006
+ c2kMatSchScale
77007
+ }) {
77008
+ const pinSymbol = new SchematicSymbol3({
77009
+ libraryId: `${libId.split(":")[1]}_1_1`
77010
+ });
77011
+ const CHIP_PIN_LENGTH = 6;
77012
+ const CUSTOM_SYMBOL_PIN_LENGTH = 2.54;
77013
+ for (let i = 0;i < (symbolData.ports?.length || 0); i++) {
77014
+ const port = symbolData.ports[i];
77015
+ const pin = new SymbolPin;
77016
+ pin.pinElectricalType = "passive";
77017
+ pin.pinGraphicStyle = "line";
77018
+ const { x, y, angle } = calculatePinPosition({
77019
+ port,
77020
+ center: symbolData.center,
77021
+ size: symbolData.size,
77022
+ isChip,
77023
+ portIndex: i,
77024
+ schematicComponent,
77025
+ schematicPorts,
77026
+ c2kMatSchScale
77027
+ });
77028
+ pin.at = [x, y, angle];
77029
+ pin.length = isChip ? CHIP_PIN_LENGTH : CUSTOM_SYMBOL_PIN_LENGTH;
77030
+ const nameFont = new TextEffectsFont3;
77031
+ nameFont.size = { height: 1.27, width: 1.27 };
77032
+ const nameEffects = new TextEffects3({ font: nameFont });
77033
+ const pinName = port.labels?.[0] || "~";
77034
+ pin._sxName = new SymbolPinName({ value: pinName, effects: nameEffects });
77035
+ const numFont = new TextEffectsFont3;
77036
+ numFont.size = { height: 1.27, width: 1.27 };
77037
+ const numEffects = new TextEffects3({ font: numFont });
77038
+ const pinNum = port.pinNumber?.toString() || `${i + 1}`;
77039
+ pin._sxNumber = new SymbolPinNumber({
77040
+ value: pinNum,
77041
+ effects: numEffects
77042
+ });
77043
+ pinSymbol.pins.push(pin);
77044
+ }
77045
+ return pinSymbol;
77046
+ }
76602
77047
  var AddLibrarySymbolsStage = class extends ConverterStage {
76603
77048
  processedSymbolNames = /* @__PURE__ */ new Set;
76604
77049
  _step() {
@@ -76696,7 +77141,12 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
76696
77141
  return null;
76697
77142
  }
76698
77143
  this.processedSymbolNames.add(libId);
76699
- const symbolData = this.buildSymbolDataFromSchematicPrimitives(schematicSymbolId, schematicSymbol, schematicComponent.schematic_component_id);
77144
+ const symbolData = buildSymbolDataFromSchematicPrimitives({
77145
+ circuitJson: this.ctx.circuitJson,
77146
+ schematicSymbolId,
77147
+ schematicSymbol,
77148
+ schematicComponentId: schematicComponent.schematic_component_id
77149
+ });
76700
77150
  const footprintName = getKicadCompatibleComponentName(sourceComp, cadComponent);
76701
77151
  return this.createLibrarySymbol({
76702
77152
  libId,
@@ -76710,74 +77160,6 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
76710
77160
  referencePrefix: getReferencePrefixForComponent(sourceComp)
76711
77161
  });
76712
77162
  }
76713
- buildSymbolDataFromSchematicPrimitives(schematicSymbolId, schematicSymbol, schematicComponentId) {
76714
- const { circuitJson } = this.ctx;
76715
- const circles = circuitJson.filter((el) => el.type === "schematic_circle" && el.schematic_symbol_id === schematicSymbolId);
76716
- const lines = circuitJson.filter((el) => el.type === "schematic_line" && el.schematic_symbol_id === schematicSymbolId);
76717
- const paths = circuitJson.filter((el) => el.type === "schematic_path" && el.schematic_symbol_id === schematicSymbolId);
76718
- let ports = circuitJson.filter((el) => el.type === "schematic_port" && ("schematic_symbol_id" in el) && el.schematic_symbol_id === schematicSymbolId);
76719
- if (ports.length === 0 && schematicComponentId) {
76720
- ports = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_component_id === schematicComponentId && el.display_pin_label !== undefined);
76721
- if (ports.length === 0) {
76722
- const allPorts = circuitJson.filter((el) => el.type === "schematic_port" && el.schematic_component_id === schematicComponentId);
76723
- const seenPinNumbers = /* @__PURE__ */ new Set;
76724
- ports = allPorts.filter((port) => {
76725
- const pinNum = port.pin_number;
76726
- if (pinNum !== undefined) {
76727
- if (seenPinNumbers.has(pinNum)) {
76728
- return false;
76729
- }
76730
- seenPinNumbers.add(pinNum);
76731
- }
76732
- return true;
76733
- });
76734
- }
76735
- }
76736
- const primitives2 = [];
76737
- for (const circle of circles) {
76738
- primitives2.push({
76739
- type: "circle",
76740
- x: circle.center?.x ?? 0,
76741
- y: circle.center?.y ?? 0,
76742
- radius: circle.radius ?? 0.5,
76743
- fill: circle.is_filled ?? false,
76744
- fillColor: circle.fill_color
76745
- });
76746
- }
76747
- for (const line of lines) {
76748
- primitives2.push({
76749
- type: "path",
76750
- points: [
76751
- { x: line.x1 ?? 0, y: line.y1 ?? 0 },
76752
- { x: line.x2 ?? 0, y: line.y2 ?? 0 }
76753
- ]
76754
- });
76755
- }
76756
- for (const path14 of paths) {
76757
- if (path14.points && path14.points.length > 0) {
76758
- primitives2.push({
76759
- type: "path",
76760
- points: path14.points,
76761
- fill: path14.is_filled ?? false,
76762
- fillColor: path14.fill_color
76763
- });
76764
- }
76765
- }
76766
- const symbolPorts = ports.map((port, index) => ({
76767
- x: port.center?.x ?? 0,
76768
- y: port.center?.y ?? 0,
76769
- labels: [port.display_pin_label || `${port.pin_number || index + 1}`],
76770
- pinNumber: port.pin_number || index + 1,
76771
- facingDirection: port.facing_direction
76772
- }));
76773
- symbolPorts.sort((a, b) => a.pinNumber - b.pinNumber);
76774
- return {
76775
- center: schematicSymbol.center || { x: 0, y: 0 },
76776
- size: schematicSymbol.size || { width: 1, height: 1 },
76777
- primitives: primitives2,
76778
- ports: symbolPorts
76779
- };
76780
- }
76781
77163
  createLibrarySymbolForNetLabel({
76782
77164
  netLabel,
76783
77165
  isPower,
@@ -76803,41 +77185,10 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
76803
77185
  }
76804
77186
  getSymbolData(symbolName, schematicComponent) {
76805
77187
  if (symbolName.startsWith("generic_chip_")) {
76806
- return this.createGenericChipSymbolData(schematicComponent, this.ctx.db);
77188
+ return createGenericChipSymbolData(schematicComponent, this.ctx.db);
76807
77189
  }
76808
77190
  return symbols2[symbolName] || null;
76809
77191
  }
76810
- createGenericChipSymbolData(schematicComp, db) {
76811
- 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));
76812
- const width = schematicComp.size?.width || 1.5;
76813
- const height = schematicComp.size?.height || 1;
76814
- const boxPath = {
76815
- type: "path",
76816
- points: [
76817
- { x: -width / 2, y: -height / 2 },
76818
- { x: width / 2, y: -height / 2 },
76819
- { x: width / 2, y: height / 2 },
76820
- { x: -width / 2, y: height / 2 },
76821
- { x: -width / 2, y: -height / 2 }
76822
- ]
76823
- };
76824
- const ports = schematicPorts.map((port) => {
76825
- const portX = port.center.x - schematicComp.center.x;
76826
- const portY = port.center.y - schematicComp.center.y;
76827
- return {
76828
- x: portX,
76829
- y: portY,
76830
- labels: [port.display_pin_label || `${port.pin_number || 1}`],
76831
- pinNumber: port.pin_number || 1
76832
- };
76833
- });
76834
- return {
76835
- center: { x: 0, y: 0 },
76836
- primitives: [boxPath],
76837
- ports,
76838
- size: { width, height }
76839
- };
76840
- }
76841
77192
  createLibrarySymbol({
76842
77193
  libId,
76843
77194
  symbolData,
@@ -76849,7 +77200,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
76849
77200
  footprintRef = "",
76850
77201
  referencePrefix
76851
77202
  }) {
76852
- const symbol = new SchematicSymbol({
77203
+ const symbol = new SchematicSymbol4({
76853
77204
  libraryId: libId,
76854
77205
  excludeFromSim: false,
76855
77206
  inBom: true,
@@ -76861,7 +77212,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
76861
77212
  const pinNames = new SymbolPinNames;
76862
77213
  pinNames.offset = isChip ? 1.27 : 0;
76863
77214
  symbol._sxPinNames = pinNames;
76864
- this.addSymbolProperties({
77215
+ addSymbolProperties({
76865
77216
  symbol,
76866
77217
  libId,
76867
77218
  description,
@@ -76870,87 +77221,25 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
76870
77221
  footprintRef,
76871
77222
  referencePrefix
76872
77223
  });
76873
- const drawingSymbol = this.createDrawingSubsymbol({
77224
+ const drawingSymbol = createDrawingSubsymbol({
76874
77225
  libId,
76875
77226
  symbolData,
76876
- isChip
77227
+ isChip,
77228
+ c2kMatSchScale: this.ctx.c2kMatSch?.a ?? 15
76877
77229
  });
76878
77230
  symbol.subSymbols.push(drawingSymbol);
76879
- const pinSymbol = this.createPinSubsymbol({
77231
+ const pinSymbol = createPinSubsymbol({
76880
77232
  libId,
76881
77233
  symbolData,
76882
77234
  isChip,
76883
- schematicComponent
77235
+ schematicComponent,
77236
+ schematicPorts: this.ctx.db.schematic_port.list(),
77237
+ c2kMatSchScale: this.ctx.c2kMatSch?.a ?? 15
76884
77238
  });
76885
77239
  symbol.subSymbols.push(pinSymbol);
76886
77240
  symbol._sxEmbeddedFonts = new EmbeddedFonts(false);
76887
77241
  return symbol;
76888
77242
  }
76889
- addSymbolProperties({
76890
- symbol,
76891
- libId,
76892
- description,
76893
- keywords,
76894
- fpFilters,
76895
- footprintRef = "",
76896
- referencePrefix
76897
- }) {
76898
- const refPrefix = referencePrefix || libId.split(":")[1]?.[0] || "U";
76899
- const properties = [
76900
- {
76901
- key: "Reference",
76902
- value: refPrefix,
76903
- id: 0,
76904
- at: [2.032, 0, 90],
76905
- hide: false
76906
- },
76907
- { key: "Value", value: refPrefix, id: 1, at: [0, 0, 90], hide: false },
76908
- {
76909
- key: "Footprint",
76910
- value: footprintRef,
76911
- id: 2,
76912
- at: [-1.778, 0, 90],
76913
- hide: true
76914
- },
76915
- {
76916
- key: "Datasheet",
76917
- value: "~",
76918
- id: 3,
76919
- at: [0, 0, 0],
76920
- hide: true
76921
- },
76922
- {
76923
- key: "Description",
76924
- value: description,
76925
- id: 4,
76926
- at: [0, 0, 0],
76927
- hide: true
76928
- },
76929
- {
76930
- key: "ki_keywords",
76931
- value: keywords,
76932
- id: 5,
76933
- at: [0, 0, 0],
76934
- hide: true
76935
- },
76936
- {
76937
- key: "ki_fp_filters",
76938
- value: fpFilters,
76939
- id: 6,
76940
- at: [0, 0, 0],
76941
- hide: true
76942
- }
76943
- ];
76944
- for (const prop of properties) {
76945
- symbol.properties.push(new SymbolProperty({
76946
- key: prop.key,
76947
- value: prop.value,
76948
- id: prop.id,
76949
- at: prop.at,
76950
- effects: this.createTextEffects(1.27, prop.hide)
76951
- }));
76952
- }
76953
- }
76954
77243
  getDescription(sourceComp) {
76955
77244
  if (sourceComp?.ftype === "simple_resistor")
76956
77245
  return "Resistor";
@@ -76981,213 +77270,6 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
76981
77270
  return "*";
76982
77271
  return "*";
76983
77272
  }
76984
- createDrawingSubsymbol({
76985
- libId,
76986
- symbolData,
76987
- isChip
76988
- }) {
76989
- const drawingSymbol = new SchematicSymbol({
76990
- libraryId: `${libId.split(":")[1]}_0_1`
76991
- });
76992
- const GRID_ALIGNED_SCALE = 15.24;
76993
- const standardScale = this.ctx.c2kMatSch?.a || 15;
76994
- const symbolScale = isChip ? standardScale : GRID_ALIGNED_SCALE;
76995
- for (const primitive of symbolData.primitives || []) {
76996
- if (primitive.type === "path" && primitive.points) {
76997
- const fillType = isChip || primitive.fill ? "background" : "none";
76998
- const polyline = this.createPolylineFromPoints({
76999
- points: primitive.points,
77000
- scale: symbolScale,
77001
- center: symbolData.center,
77002
- fillType
77003
- });
77004
- drawingSymbol.polylines.push(polyline);
77005
- } else if (primitive.type === "circle") {
77006
- const circle = this.createCircleFromPrimitive({
77007
- primitive,
77008
- scale: symbolScale,
77009
- center: symbolData.center
77010
- });
77011
- drawingSymbol.circles.push(circle);
77012
- }
77013
- }
77014
- return drawingSymbol;
77015
- }
77016
- createPolylineFromPoints({
77017
- points,
77018
- scale: scale4,
77019
- center,
77020
- fillType
77021
- }) {
77022
- const polyline = new SymbolPolyline;
77023
- const cx = center?.x ?? 0;
77024
- const cy = center?.y ?? 0;
77025
- const scaleMatrix = createScaleMatrix(scale4, scale4);
77026
- const xyPoints = points.map((p) => {
77027
- const translated = applyToPoint(scaleMatrix, { x: p.x - cx, y: p.y - cy });
77028
- return new Xy(translated.x, translated.y);
77029
- });
77030
- const pts = new Pts(xyPoints);
77031
- polyline.points = pts;
77032
- const stroke = new Stroke;
77033
- stroke.width = 0.254;
77034
- stroke.type = "default";
77035
- polyline.stroke = stroke;
77036
- const fill = new SymbolPolylineFill;
77037
- fill.type = fillType;
77038
- polyline.fill = fill;
77039
- return polyline;
77040
- }
77041
- createCircleFromPrimitive({
77042
- primitive,
77043
- scale: scale4,
77044
- center
77045
- }) {
77046
- const circle = new SymbolCircle;
77047
- const cx = center?.x ?? 0;
77048
- const cy = center?.y ?? 0;
77049
- const scaleMatrix = createScaleMatrix(scale4, scale4);
77050
- const scaledPos = applyToPoint(scaleMatrix, {
77051
- x: primitive.x - cx,
77052
- y: primitive.y - cy
77053
- });
77054
- const c = circle;
77055
- c._sxCenter = new SymbolCircleCenter(scaledPos.x, scaledPos.y);
77056
- c._sxRadius = new SymbolCircleRadius(primitive.radius * scale4);
77057
- const stroke = new Stroke;
77058
- stroke.width = 0.254;
77059
- stroke.type = "default";
77060
- c._sxStroke = stroke;
77061
- const fill = new SymbolCircleFill;
77062
- fill.type = primitive.fill ? "background" : "none";
77063
- c._sxFill = fill;
77064
- return circle;
77065
- }
77066
- createPinSubsymbol({
77067
- libId,
77068
- symbolData,
77069
- isChip,
77070
- schematicComponent
77071
- }) {
77072
- const pinSymbol = new SchematicSymbol({
77073
- libraryId: `${libId.split(":")[1]}_1_1`
77074
- });
77075
- for (let i = 0;i < (symbolData.ports?.length || 0); i++) {
77076
- const port = symbolData.ports[i];
77077
- const pin = new SymbolPin;
77078
- pin.pinElectricalType = "passive";
77079
- pin.pinGraphicStyle = "line";
77080
- const { x, y, angle } = this.calculatePinPosition(port, symbolData.center, symbolData.size, isChip, i, schematicComponent);
77081
- pin.at = [x, y, angle];
77082
- const CHIP_PIN_LENGTH = 6;
77083
- const CUSTOM_SYMBOL_PIN_LENGTH = 2.54;
77084
- pin.length = isChip ? CHIP_PIN_LENGTH : CUSTOM_SYMBOL_PIN_LENGTH;
77085
- const nameFont = new TextEffectsFont;
77086
- nameFont.size = { height: 1.27, width: 1.27 };
77087
- const nameEffects = new TextEffects({ font: nameFont });
77088
- const pinName = port.labels?.[0] || "~";
77089
- pin._sxName = new SymbolPinName({ value: pinName, effects: nameEffects });
77090
- const numFont = new TextEffectsFont;
77091
- numFont.size = { height: 1.27, width: 1.27 };
77092
- const numEffects = new TextEffects({ font: numFont });
77093
- const pinNum = port.pinNumber?.toString() || `${i + 1}`;
77094
- pin._sxNumber = new SymbolPinNumber({
77095
- value: pinNum,
77096
- effects: numEffects
77097
- });
77098
- pinSymbol.pins.push(pin);
77099
- }
77100
- return pinSymbol;
77101
- }
77102
- calculatePinPosition(port, center, size, isChip, portIndex, schematicComponent) {
77103
- const GRID_ALIGNED_SCALE = 15.24;
77104
- const standardScale = this.ctx.c2kMatSch?.a || 15;
77105
- const symbolScale = isChip ? standardScale : GRID_ALIGNED_SCALE;
77106
- let portX = port.x ?? 0;
77107
- let portY = port.y ?? 0;
77108
- let usingCircuitJsonPort = false;
77109
- if (isChip && portIndex !== undefined && schematicComponent) {
77110
- const schematicPorts = this.ctx.db.schematic_port.list().filter((p) => p.schematic_component_id === schematicComponent.schematic_component_id).sort((a, b) => (a.pin_number || 0) - (b.pin_number || 0));
77111
- if (schematicPorts[portIndex]) {
77112
- const schPort = schematicPorts[portIndex];
77113
- portX = schPort.center.x - schematicComponent.center.x;
77114
- portY = schPort.center.y - schematicComponent.center.y;
77115
- usingCircuitJsonPort = true;
77116
- }
77117
- }
77118
- let dx;
77119
- let dy;
77120
- if (usingCircuitJsonPort) {
77121
- dx = portX;
77122
- dy = portY;
77123
- } else {
77124
- const cx = center?.x ?? 0;
77125
- const cy = center?.y ?? 0;
77126
- dx = portX - cx;
77127
- dy = portY - cy;
77128
- }
77129
- const scaleMatrix = createScaleMatrix(symbolScale, symbolScale);
77130
- const scaled = applyToPoint(scaleMatrix, { x: dx, y: dy });
77131
- let isHorizontalPin;
77132
- if (isChip && size) {
77133
- const halfWidth = size.width / 2;
77134
- const halfHeight = size.height / 2;
77135
- const normalizedDx = Math.abs(dx) / halfWidth;
77136
- const normalizedDy = Math.abs(dy) / halfHeight;
77137
- isHorizontalPin = normalizedDx > normalizedDy;
77138
- } else {
77139
- isHorizontalPin = Math.abs(dx) > Math.abs(dy);
77140
- }
77141
- let x = scaled.x;
77142
- let y = scaled.y;
77143
- const CHIP_PIN_LENGTH = 6;
77144
- if (isChip && size) {
77145
- const halfWidth = size.width / 2 * symbolScale;
77146
- const halfHeight = size.height / 2 * symbolScale;
77147
- if (isHorizontalPin) {
77148
- x = dx > 0 ? halfWidth : -halfWidth;
77149
- y = dy * symbolScale;
77150
- } else {
77151
- x = dx * symbolScale;
77152
- y = dy > 0 ? halfHeight : -halfHeight;
77153
- }
77154
- }
77155
- let angle = 0;
77156
- if (isHorizontalPin) {
77157
- if (dx > 0) {
77158
- angle = 180;
77159
- if (isChip) {
77160
- x = x + CHIP_PIN_LENGTH;
77161
- }
77162
- } else {
77163
- angle = 0;
77164
- if (isChip) {
77165
- x = x - CHIP_PIN_LENGTH;
77166
- }
77167
- }
77168
- } else {
77169
- if (dy > 0) {
77170
- angle = 270;
77171
- if (isChip) {
77172
- y = y + CHIP_PIN_LENGTH;
77173
- }
77174
- } else {
77175
- angle = 90;
77176
- if (isChip) {
77177
- y = y - CHIP_PIN_LENGTH;
77178
- }
77179
- }
77180
- }
77181
- return { x, y, angle };
77182
- }
77183
- createTextEffects(size, hide) {
77184
- const font = new TextEffectsFont;
77185
- font.size = { height: size, width: size };
77186
- return new TextEffects({
77187
- font,
77188
- hiddenText: hide
77189
- });
77190
- }
77191
77273
  getOutput() {
77192
77274
  if (!this.ctx.kicadSch) {
77193
77275
  throw new Error("kicadSch is not initialized");
@@ -77210,12 +77292,12 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
77210
77292
  continue;
77211
77293
  if (!this.ctx.c2kMatSch)
77212
77294
  continue;
77213
- const { x, y } = applyToPoint2(this.ctx.c2kMatSch, {
77295
+ const { x, y } = applyToPoint5(this.ctx.c2kMatSch, {
77214
77296
  x: schematicComponent.center.x,
77215
77297
  y: schematicComponent.center.y
77216
77298
  });
77217
77299
  const uuid = crypto.randomUUID();
77218
- const symbol = new SchematicSymbol2({
77300
+ const symbol = new SchematicSymbol5({
77219
77301
  at: [x, y, 0],
77220
77302
  unit: 1,
77221
77303
  excludeFromSim: false,
@@ -77252,43 +77334,108 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
77252
77334
  symbol._sxLibId = symLibId;
77253
77335
  const { reference, value, description } = this.getComponentMetadata(sourceComponent);
77254
77336
  const { refTextPos, valTextPos } = this.getTextPositions(schematicComponent, { x, y });
77337
+ let symbolMetadata;
77338
+ if (schematicSymbolId) {
77339
+ const schSymEl = this.ctx.circuitJson.find((el) => el.type === "schematic_symbol" && el.schematic_symbol_id === schematicSymbolId);
77340
+ if (schSymEl && schSymEl.type === "schematic_symbol") {
77341
+ symbolMetadata = schSymEl.metadata?.kicad_symbol;
77342
+ }
77343
+ }
77344
+ const refMeta = symbolMetadata?.properties?.Reference;
77255
77345
  const referenceProperty = new SymbolProperty2({
77256
77346
  key: "Reference",
77257
- value: reference,
77347
+ value: refMeta?.value ?? reference,
77258
77348
  id: 0,
77259
77349
  at: [refTextPos.x, refTextPos.y, 0],
77260
- effects: this.createTextEffects(1.27, false)
77350
+ effects: this.createTextEffects(Number(refMeta?.effects?.font?.size?.x ?? 1.27), refMeta?.effects?.hide ?? false)
77261
77351
  });
77262
77352
  const hideValue = sourceComponent.ftype === "simple_chip";
77353
+ const valMeta = symbolMetadata?.properties?.Value;
77263
77354
  const valueProperty = new SymbolProperty2({
77264
77355
  key: "Value",
77265
- value,
77356
+ value: valMeta?.value ?? value,
77266
77357
  id: 1,
77267
77358
  at: [valTextPos.x, valTextPos.y, 0],
77268
- effects: this.createTextEffects(1.27, hideValue)
77359
+ effects: this.createTextEffects(Number(valMeta?.effects?.font?.size?.x ?? 1.27), valMeta?.effects?.hide ?? hideValue)
77269
77360
  });
77361
+ const fpMeta = symbolMetadata?.properties?.Footprint;
77270
77362
  const footprintProperty = new SymbolProperty2({
77271
77363
  key: "Footprint",
77272
- value: "",
77364
+ value: fpMeta?.value ?? "",
77273
77365
  id: 2,
77274
77366
  at: [x - 1.778, y, 90],
77275
- effects: this.createTextEffects(1.27, true)
77367
+ effects: this.createTextEffects(1.27, fpMeta?.effects?.hide ?? true)
77276
77368
  });
77369
+ const dsMeta = symbolMetadata?.properties?.Datasheet;
77277
77370
  const datasheetProperty = new SymbolProperty2({
77278
77371
  key: "Datasheet",
77279
- value: "~",
77372
+ value: dsMeta?.value ?? "~",
77280
77373
  id: 3,
77281
77374
  at: [x, y, 0],
77282
- effects: this.createTextEffects(1.27, true)
77375
+ effects: this.createTextEffects(1.27, dsMeta?.effects?.hide ?? true)
77283
77376
  });
77377
+ const descMeta = symbolMetadata?.properties?.Description;
77284
77378
  const descriptionProperty = new SymbolProperty2({
77285
77379
  key: "Description",
77286
- value: description,
77380
+ value: descMeta?.value ?? description,
77287
77381
  id: 4,
77288
77382
  at: [x, y, 0],
77289
- effects: this.createTextEffects(1.27, true)
77383
+ effects: this.createTextEffects(1.27, descMeta?.effects?.hide ?? true)
77290
77384
  });
77291
77385
  symbol.properties.push(referenceProperty, valueProperty, footprintProperty, datasheetProperty, descriptionProperty);
77386
+ const kwMeta = symbolMetadata?.properties?.ki_keywords;
77387
+ if (kwMeta?.value) {
77388
+ const keywordsProperty = new SymbolProperty2({
77389
+ key: "ki_keywords",
77390
+ value: kwMeta.value,
77391
+ id: 5,
77392
+ at: [x, y, 0],
77393
+ effects: this.createTextEffects(1.27, kwMeta.effects?.hide ?? true)
77394
+ });
77395
+ symbol.properties.push(keywordsProperty);
77396
+ }
77397
+ const fpFilterMeta = symbolMetadata?.properties?.ki_fp_filters;
77398
+ if (fpFilterMeta?.value) {
77399
+ const fpFiltersProperty = new SymbolProperty2({
77400
+ key: "ki_fp_filters",
77401
+ value: fpFilterMeta.value,
77402
+ id: 6,
77403
+ at: [x, y, 0],
77404
+ effects: this.createTextEffects(1.27, fpFilterMeta.effects?.hide ?? true)
77405
+ });
77406
+ symbol.properties.push(fpFiltersProperty);
77407
+ }
77408
+ if (symbolMetadata) {
77409
+ if (symbolMetadata.inBom !== undefined) {
77410
+ symbol.inBom = symbolMetadata.inBom;
77411
+ }
77412
+ if (symbolMetadata.onBoard !== undefined) {
77413
+ symbol.onBoard = symbolMetadata.onBoard;
77414
+ }
77415
+ if (symbolMetadata.excludeFromSim !== undefined) {
77416
+ symbol.excludeFromSim = symbolMetadata.excludeFromSim;
77417
+ }
77418
+ if (symbolMetadata.pinNames) {
77419
+ const pinNames = new SymbolPinNames2;
77420
+ if (symbolMetadata.pinNames.offset !== undefined) {
77421
+ pinNames.offset = Number(symbolMetadata.pinNames.offset);
77422
+ }
77423
+ if (symbolMetadata.pinNames.hide !== undefined) {
77424
+ pinNames.hide = symbolMetadata.pinNames.hide;
77425
+ }
77426
+ symbol.pinNames = pinNames;
77427
+ }
77428
+ if (symbolMetadata.pinNumbers) {
77429
+ const pinNumbers = new SymbolPinNumbers2;
77430
+ if (symbolMetadata.pinNumbers.hide !== undefined) {
77431
+ pinNumbers.hide = symbolMetadata.pinNumbers.hide;
77432
+ }
77433
+ symbol.pinNumbers = pinNumbers;
77434
+ }
77435
+ if (symbolMetadata.embeddedFonts !== undefined) {
77436
+ symbol._sxEmbeddedFonts = new EmbeddedFonts2(symbolMetadata.embeddedFonts);
77437
+ }
77438
+ }
77292
77439
  let schematicPorts = db.schematic_port.list().filter((p) => p.schematic_component_id === schematicComponent.schematic_component_id);
77293
77440
  if (schematicSymbolId) {
77294
77441
  const customSymbolPorts = schematicPorts.filter((p) => p.display_pin_label);
@@ -77325,7 +77472,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
77325
77472
  const schematicTexts = this.ctx.db.schematic_text?.list?.()?.filter((t) => t.schematic_component_id === schematicComponent.schematic_component_id) || [];
77326
77473
  const refText = schematicTexts.find((t) => t.text && t.text.length > 0);
77327
77474
  if (refText && this.ctx.c2kMatSch) {
77328
- const refTextPos2 = applyToPoint2(this.ctx.c2kMatSch, {
77475
+ const refTextPos2 = applyToPoint5(this.ctx.c2kMatSch, {
77329
77476
  x: refText.position.x,
77330
77477
  y: refText.position.y
77331
77478
  });
@@ -77354,11 +77501,11 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
77354
77501
  const symbolCenter = symbol.center || { x: 0, y: 0 };
77355
77502
  const isVertical = symbolName.includes("_down") || symbolName.includes("_up");
77356
77503
  const horizontalTextOffset = isVertical ? 0.15 : 0;
77357
- const refTextPos = refTextPrimitive && this.ctx.c2kMatSch ? applyToPoint2(this.ctx.c2kMatSch, {
77504
+ const refTextPos = refTextPrimitive && this.ctx.c2kMatSch ? applyToPoint5(this.ctx.c2kMatSch, {
77358
77505
  x: schematicComponent.center.x + (refTextPrimitive.x - symbolCenter.x) + horizontalTextOffset,
77359
77506
  y: schematicComponent.center.y + (refTextPrimitive.y - symbolCenter.y)
77360
77507
  }) : { x: symbolKicadPos.x, y: symbolKicadPos.y - 6 };
77361
- const valTextPos = valTextPrimitive && this.ctx.c2kMatSch ? applyToPoint2(this.ctx.c2kMatSch, {
77508
+ const valTextPos = valTextPrimitive && this.ctx.c2kMatSch ? applyToPoint5(this.ctx.c2kMatSch, {
77362
77509
  x: schematicComponent.center.x + (valTextPrimitive.x - symbolCenter.x) + horizontalTextOffset,
77363
77510
  y: schematicComponent.center.y + (valTextPrimitive.y - symbolCenter.y)
77364
77511
  }) : { x: symbolKicadPos.x, y: symbolKicadPos.y + 6 };
@@ -77430,10 +77577,10 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
77430
77577
  };
77431
77578
  }
77432
77579
  createTextEffects(size, hide = false, justify) {
77433
- const font = new TextEffectsFont2;
77580
+ const font = new TextEffectsFont4;
77434
77581
  font.size = { height: size, width: size };
77435
77582
  const justifyObj = justify ? new TextEffectsJustify({ horizontal: justify }) : undefined;
77436
- const effects = new TextEffects2({
77583
+ const effects = new TextEffects4({
77437
77584
  font,
77438
77585
  hiddenText: hide,
77439
77586
  justify: justifyObj
@@ -77491,12 +77638,12 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
77491
77638
  createSymbolFromNetLabel(netLabel, labelText, symbolName) {
77492
77639
  if (!this.ctx.c2kMatSch)
77493
77640
  return null;
77494
- const { x, y } = applyToPoint3(this.ctx.c2kMatSch, {
77641
+ const { x, y } = applyToPoint6(this.ctx.c2kMatSch, {
77495
77642
  x: netLabel.anchor_position?.x ?? netLabel.center?.x ?? 0,
77496
77643
  y: netLabel.anchor_position?.y ?? netLabel.center?.y ?? 0
77497
77644
  });
77498
77645
  const uuid = crypto.randomUUID();
77499
- const symbol = new SchematicSymbol3({
77646
+ const symbol = new SchematicSymbol6({
77500
77647
  at: [x, y, 0],
77501
77648
  unit: 1,
77502
77649
  excludeFromSim: false,
@@ -77566,7 +77713,7 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
77566
77713
  createGlobalLabel(netLabel, labelText) {
77567
77714
  if (!this.ctx.c2kMatSch || !this.ctx.kicadSch)
77568
77715
  return null;
77569
- const { x, y } = applyToPoint3(this.ctx.c2kMatSch, {
77716
+ const { x, y } = applyToPoint6(this.ctx.c2kMatSch, {
77570
77717
  x: netLabel.anchor_position?.x ?? netLabel.center?.x ?? 0,
77571
77718
  y: netLabel.anchor_position?.y ?? netLabel.center?.y ?? 0
77572
77719
  });
@@ -77599,9 +77746,9 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
77599
77746
  return globalLabel;
77600
77747
  }
77601
77748
  createTextEffects(size, hide = false) {
77602
- const font = new TextEffectsFont3;
77749
+ const font = new TextEffectsFont5;
77603
77750
  font.size = { height: size, width: size };
77604
- return new TextEffects3({
77751
+ return new TextEffects5({
77605
77752
  font,
77606
77753
  hiddenText: hide
77607
77754
  });
@@ -77645,11 +77792,11 @@ var AddSchematicTracesStage = class extends ConverterStage {
77645
77792
  if (!this.ctx.c2kMatSch) {
77646
77793
  throw new Error("Schematic transformation matrix not initialized in context");
77647
77794
  }
77648
- const from = applyToPoint4(this.ctx.c2kMatSch, {
77795
+ const from = applyToPoint7(this.ctx.c2kMatSch, {
77649
77796
  x: edge.from.x,
77650
77797
  y: edge.from.y
77651
77798
  });
77652
- const to = applyToPoint4(this.ctx.c2kMatSch, {
77799
+ const to = applyToPoint7(this.ctx.c2kMatSch, {
77653
77800
  x: edge.to.x,
77654
77801
  y: edge.to.y
77655
77802
  });
@@ -77659,7 +77806,7 @@ var AddSchematicTracesStage = class extends ConverterStage {
77659
77806
  const y2 = to.y;
77660
77807
  const pts = new Pts2([new Xy2(x1, y1), new Xy2(x2, y2)]);
77661
77808
  wire.points = pts;
77662
- const stroke = new Stroke2;
77809
+ const stroke = new Stroke3;
77663
77810
  stroke.width = 0;
77664
77811
  stroke.type = "default";
77665
77812
  wire.stroke = stroke;
@@ -77670,7 +77817,7 @@ var AddSchematicTracesStage = class extends ConverterStage {
77670
77817
  if (!this.ctx.c2kMatSch) {
77671
77818
  throw new Error("Schematic transformation matrix not initialized in context");
77672
77819
  }
77673
- const { x, y } = applyToPoint4(this.ctx.c2kMatSch, {
77820
+ const { x, y } = applyToPoint7(this.ctx.c2kMatSch, {
77674
77821
  x: junction.x,
77675
77822
  y: junction.y
77676
77823
  });
@@ -77792,7 +77939,7 @@ var CircuitJsonToKicadSchConverter = class {
77792
77939
  generatorVersion: "0.0.1"
77793
77940
  }),
77794
77941
  schematicPaperSize: paperSize,
77795
- c2kMatSch: compose(translate(KICAD_CENTER_X, KICAD_CENTER_Y), scale(CIRCUIT_JSON_SCALE_FACTOR, -CIRCUIT_JSON_SCALE_FACTOR), translate(-center.x, -center.y))
77942
+ c2kMatSch: compose2(translate2(KICAD_CENTER_X, KICAD_CENTER_Y), scale(CIRCUIT_JSON_SCALE_FACTOR, -CIRCUIT_JSON_SCALE_FACTOR), translate2(-center.x, -center.y))
77796
77943
  };
77797
77944
  this.pipeline = [
77798
77945
  new InitializeSchematicStage(circuitJson, this.ctx),
@@ -77938,6 +78085,137 @@ function generateDeterministicUuid(data) {
77938
78085
  const hash = simpleHash(data);
77939
78086
  return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-${hash.slice(12, 16)}-${hash.slice(16, 20)}-${hash.slice(20, 32)}`;
77940
78087
  }
78088
+ function createTextEffects2(metadataEffects) {
78089
+ const font = new TextEffectsFont6;
78090
+ if (metadataEffects?.font?.size) {
78091
+ font.size = {
78092
+ width: Number(metadataEffects.font.size.x),
78093
+ height: Number(metadataEffects.font.size.y)
78094
+ };
78095
+ } else {
78096
+ font.size = { width: 1.27, height: 1.27 };
78097
+ }
78098
+ if (metadataEffects?.font?.thickness !== undefined) {
78099
+ font.thickness = Number(metadataEffects.font.thickness);
78100
+ } else {
78101
+ font.thickness = 0.15;
78102
+ }
78103
+ return new TextEffects6({ font });
78104
+ }
78105
+ function applyMetadataToFootprint(footprint, metadata, componentName) {
78106
+ if (metadata.properties) {
78107
+ const newProperties = [];
78108
+ const refMeta = metadata.properties.Reference;
78109
+ newProperties.push(new Property({
78110
+ key: "Reference",
78111
+ value: refMeta?.value ?? componentName,
78112
+ position: refMeta?.at ? [
78113
+ Number(refMeta.at.x),
78114
+ Number(refMeta.at.y),
78115
+ Number(refMeta.at.rotation ?? 0)
78116
+ ] : [0, -3, 0],
78117
+ layer: refMeta?.layer ?? "F.SilkS",
78118
+ uuid: generateDeterministicUuid(`${componentName}-property-Reference`),
78119
+ effects: createTextEffects2(refMeta?.effects),
78120
+ hidden: refMeta?.hide
78121
+ }));
78122
+ const valMeta = metadata.properties.Value;
78123
+ const valueText = valMeta?.value ?? metadata.footprintName ?? "";
78124
+ newProperties.push(new Property({
78125
+ key: "Value",
78126
+ value: valueText,
78127
+ position: valMeta?.at ? [
78128
+ Number(valMeta.at.x),
78129
+ Number(valMeta.at.y),
78130
+ Number(valMeta.at.rotation ?? 0)
78131
+ ] : [0, 3, 0],
78132
+ layer: valMeta?.layer ?? "F.Fab",
78133
+ uuid: generateDeterministicUuid(`${componentName}-property-Value`),
78134
+ effects: createTextEffects2(valMeta?.effects),
78135
+ hidden: valMeta?.hide
78136
+ }));
78137
+ const dsMeta = metadata.properties.Datasheet;
78138
+ newProperties.push(new Property({
78139
+ key: "Datasheet",
78140
+ value: dsMeta?.value ?? "",
78141
+ position: dsMeta?.at ? [
78142
+ Number(dsMeta.at.x),
78143
+ Number(dsMeta.at.y),
78144
+ Number(dsMeta.at.rotation ?? 0)
78145
+ ] : [0, 0, 0],
78146
+ layer: dsMeta?.layer ?? "F.Fab",
78147
+ uuid: generateDeterministicUuid(`${componentName}-property-Datasheet`),
78148
+ effects: createTextEffects2(dsMeta?.effects),
78149
+ hidden: dsMeta?.hide ?? true
78150
+ }));
78151
+ const descMeta = metadata.properties.Description;
78152
+ newProperties.push(new Property({
78153
+ key: "Description",
78154
+ value: descMeta?.value ?? "",
78155
+ position: descMeta?.at ? [
78156
+ Number(descMeta.at.x),
78157
+ Number(descMeta.at.y),
78158
+ Number(descMeta.at.rotation ?? 0)
78159
+ ] : [0, 0, 0],
78160
+ layer: descMeta?.layer ?? "F.Fab",
78161
+ uuid: generateDeterministicUuid(`${componentName}-property-Description`),
78162
+ effects: createTextEffects2(descMeta?.effects),
78163
+ hidden: descMeta?.hide ?? true
78164
+ }));
78165
+ footprint.properties = newProperties;
78166
+ }
78167
+ if (metadata.attributes) {
78168
+ if (!footprint.attr) {
78169
+ footprint.attr = new FootprintAttr;
78170
+ }
78171
+ if (metadata.attributes.through_hole) {
78172
+ footprint.attr.type = "through_hole";
78173
+ } else if (metadata.attributes.smd) {
78174
+ footprint.attr.type = "smd";
78175
+ }
78176
+ if (metadata.attributes.exclude_from_pos_files !== undefined) {
78177
+ footprint.attr.excludeFromPosFiles = metadata.attributes.exclude_from_pos_files;
78178
+ }
78179
+ if (metadata.attributes.exclude_from_bom !== undefined) {
78180
+ footprint.attr.excludeFromBom = metadata.attributes.exclude_from_bom;
78181
+ }
78182
+ }
78183
+ if (metadata.footprintName) {
78184
+ footprint.libraryLink = metadata.footprintName;
78185
+ }
78186
+ if (metadata.layer) {
78187
+ footprint.layer = metadata.layer;
78188
+ }
78189
+ if (metadata.embeddedFonts !== undefined) {
78190
+ footprint.embeddedFonts = new EmbeddedFonts4(metadata.embeddedFonts);
78191
+ }
78192
+ if (metadata.model) {
78193
+ const model = new FootprintModel(metadata.model.path);
78194
+ if (metadata.model.offset) {
78195
+ model.offset = {
78196
+ x: Number(metadata.model.offset.x),
78197
+ y: Number(metadata.model.offset.y),
78198
+ z: Number(metadata.model.offset.z)
78199
+ };
78200
+ }
78201
+ if (metadata.model.scale) {
78202
+ model.scale = {
78203
+ x: Number(metadata.model.scale.x),
78204
+ y: Number(metadata.model.scale.y),
78205
+ z: Number(metadata.model.scale.z)
78206
+ };
78207
+ }
78208
+ if (metadata.model.rotate) {
78209
+ model.rotate = {
78210
+ x: Number(metadata.model.rotate.x),
78211
+ y: Number(metadata.model.rotate.y),
78212
+ z: Number(metadata.model.rotate.z)
78213
+ };
78214
+ }
78215
+ const existingModels = footprint.models || [];
78216
+ footprint.models = [model, ...existingModels];
78217
+ }
78218
+ }
77941
78219
  function convertSilkscreenCircles(silkscreenCircles, componentCenter) {
77942
78220
  const fpCircles = [];
77943
78221
  for (const circle of silkscreenCircles) {
@@ -77952,7 +78230,7 @@ function convertSilkscreenCircles(silkscreenCircles, componentCenter) {
77952
78230
  center: { x: relX, y: relY },
77953
78231
  end: { x: relX + circle.radius, y: relY },
77954
78232
  layer: kicadLayer,
77955
- stroke: new Stroke3,
78233
+ stroke: new Stroke4,
77956
78234
  fill: false
77957
78235
  });
77958
78236
  if (fpCircle.stroke) {
@@ -77977,7 +78255,7 @@ function convertCourtyardCircles(courtyardCircles, componentCenter) {
77977
78255
  center: { x: relX, y: relY },
77978
78256
  end: { x: relX + circle.radius, y: relY },
77979
78257
  layer: kicadLayer,
77980
- stroke: new Stroke4,
78258
+ stroke: new Stroke5,
77981
78259
  fill: false
77982
78260
  });
77983
78261
  if (fpCircle.stroke) {
@@ -78004,7 +78282,7 @@ function convertFabricationNoteRects(fabRects, componentCenter) {
78004
78282
  start: { x: relX - halfW, y: relY - halfH },
78005
78283
  end: { x: relX + halfW, y: relY + halfH },
78006
78284
  layer: kicadLayer,
78007
- stroke: new Stroke5,
78285
+ stroke: new Stroke6,
78008
78286
  fill: false
78009
78287
  });
78010
78288
  if (fpRect.stroke) {
@@ -78027,7 +78305,7 @@ function convertNoteRects(noteRects, componentCenter) {
78027
78305
  start: { x: relX - halfW, y: relY - halfH },
78028
78306
  end: { x: relX + halfW, y: relY + halfH },
78029
78307
  layer: kicadLayer,
78030
- stroke: new Stroke6,
78308
+ stroke: new Stroke7,
78031
78309
  fill: false
78032
78310
  });
78033
78311
  if (fpRect.stroke) {
@@ -78054,7 +78332,7 @@ function convertCourtyardRects(courtyardRects, componentCenter) {
78054
78332
  start: { x: relX - halfW, y: relY - halfH },
78055
78333
  end: { x: relX + halfW, y: relY + halfH },
78056
78334
  layer: kicadLayer,
78057
- stroke: new Stroke7,
78335
+ stroke: new Stroke8,
78058
78336
  fill: false
78059
78337
  });
78060
78338
  if (fpRect.stroke) {
@@ -78084,7 +78362,7 @@ function convertCourtyardOutlines(courtyardOutlines, componentCenter) {
78084
78362
  fpPoly.points = new Pts3(xyPoints);
78085
78363
  fpPoly.layer = kicadLayer;
78086
78364
  fpPoly.fill = false;
78087
- const stroke = new Stroke8;
78365
+ const stroke = new Stroke9;
78088
78366
  stroke.width = 0.05;
78089
78367
  stroke.type = "default";
78090
78368
  fpPoly.stroke = stroke;
@@ -78103,7 +78381,7 @@ function createFpTextFromCircuitJson({
78103
78381
  const relativeX = textElement.anchor_position.x - componentCenter.x;
78104
78382
  const relativeY = -(textElement.anchor_position.y - componentCenter.y);
78105
78383
  const rotationMatrix = componentRotation !== 0 ? rotate(componentRotation * Math.PI / 180) : identity();
78106
- const rotatedPos = applyToPoint5(rotationMatrix, {
78384
+ const rotatedPos = applyToPoint8(rotationMatrix, {
78107
78385
  x: relativeX,
78108
78386
  y: relativeY
78109
78387
  });
@@ -78117,9 +78395,9 @@ function createFpTextFromCircuitJson({
78117
78395
  };
78118
78396
  const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
78119
78397
  const fontSize = (textElement.font_size || 1) / 1.5;
78120
- const font = new TextEffectsFont4;
78398
+ const font = new TextEffectsFont7;
78121
78399
  font.size = { width: fontSize, height: fontSize };
78122
- const textEffects = new TextEffects4({
78400
+ const textEffects = new TextEffects7({
78123
78401
  font
78124
78402
  });
78125
78403
  const rotation = textElement.ccw_rotation || 0;
@@ -78158,11 +78436,11 @@ function convertNoteTexts(noteTexts, componentCenter, componentRotation) {
78158
78436
  const relX = textElement.anchor_position.x - componentCenter.x;
78159
78437
  const relY = -(textElement.anchor_position.y - componentCenter.y);
78160
78438
  const rotationMatrix = componentRotation !== 0 ? rotate2(componentRotation * Math.PI / 180) : identity2();
78161
- const rotatedPos = applyToPoint6(rotationMatrix, { x: relX, y: relY });
78439
+ const rotatedPos = applyToPoint9(rotationMatrix, { x: relX, y: relY });
78162
78440
  const fontSize = textElement.font_size || 1;
78163
- const font = new TextEffectsFont5;
78441
+ const font = new TextEffectsFont8;
78164
78442
  font.size = { width: fontSize, height: fontSize };
78165
- const textEffects = new TextEffects5({ font });
78443
+ const textEffects = new TextEffects8({ font });
78166
78444
  const fpText = new FpText3({
78167
78445
  type: "user",
78168
78446
  text: textElement.text,
@@ -78179,7 +78457,7 @@ function create3DModelsFromCadComponent(cadComponent, componentCenter) {
78179
78457
  const modelUrl = cadComponent.model_step_url || cadComponent.model_wrl_url;
78180
78458
  if (!modelUrl)
78181
78459
  return models;
78182
- const model = new FootprintModel(modelUrl);
78460
+ const model = new FootprintModel2(modelUrl);
78183
78461
  if (cadComponent.position) {
78184
78462
  model.offset = {
78185
78463
  x: (cadComponent.position.x || 0) - componentCenter.x,
@@ -78221,8 +78499,8 @@ function createSmdPadFromCircuitJson({
78221
78499
  } else {
78222
78500
  throw new Error("Pad must have either x/y coordinates or points array");
78223
78501
  }
78224
- const cj2kicadMatrix = compose2(componentRotation !== 0 ? rotate3(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale2(1, -1), translate2(-componentCenter.x, -componentCenter.y));
78225
- const rotatedPos = applyToPoint7(cj2kicadMatrix, {
78502
+ const cj2kicadMatrix = compose3(componentRotation !== 0 ? rotate3(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale2(1, -1), translate3(-componentCenter.x, -componentCenter.y));
78503
+ const rotatedPos = applyToPoint10(cj2kicadMatrix, {
78226
78504
  x: padX,
78227
78505
  y: padY
78228
78506
  });
@@ -78243,9 +78521,9 @@ function createSmdPadFromCircuitJson({
78243
78521
  ];
78244
78522
  } else if (pcbPad.shape === "polygon" && "points" in pcbPad) {
78245
78523
  const points = pcbPad.points;
78246
- const pointTransformMatrix = compose2(scale2(1, -1), translate2(-padX, -padY));
78524
+ const pointTransformMatrix = compose3(scale2(1, -1), translate3(-padX, -padY));
78247
78525
  const relativePoints = points.map((p) => {
78248
- const transformed = applyToPoint7(pointTransformMatrix, { x: p.x, y: p.y });
78526
+ const transformed = applyToPoint10(pointTransformMatrix, { x: p.x, y: p.y });
78249
78527
  return new Xy4(transformed.x, transformed.y);
78250
78528
  });
78251
78529
  const grPoly = new PadPrimitiveGrPoly;
@@ -78322,7 +78600,7 @@ function createThruHolePadFromCircuitJson({
78322
78600
  const relativeX = platedHole.x - componentCenter.x;
78323
78601
  const relativeY = -(platedHole.y - componentCenter.y);
78324
78602
  const rotationMatrix = componentRotation !== 0 ? rotate4(componentRotation * Math.PI / 180) : identity3();
78325
- const rotatedPos = applyToPoint8(rotationMatrix, {
78603
+ const rotatedPos = applyToPoint11(rotationMatrix, {
78326
78604
  x: relativeX,
78327
78605
  y: relativeY
78328
78606
  });
@@ -78338,7 +78616,7 @@ function createThruHolePadFromCircuitJson({
78338
78616
  y: platedHole.hole_offset_y ?? 0
78339
78617
  };
78340
78618
  if (rawOffset.x !== 0 || rawOffset.y !== 0) {
78341
- const rotatedOffset = applyToPoint8(rotationMatrix, {
78619
+ const rotatedOffset = applyToPoint11(rotationMatrix, {
78342
78620
  x: -rawOffset.x,
78343
78621
  y: rawOffset.y
78344
78622
  });
@@ -78452,7 +78730,7 @@ function createNpthPadFromCircuitJson({
78452
78730
  const relativeX = pcbHole.x - componentCenter.x;
78453
78731
  const relativeY = -(pcbHole.y - componentCenter.y);
78454
78732
  const rotationMatrix = componentRotation !== 0 ? rotate5(componentRotation * Math.PI / 180) : identity4();
78455
- const rotatedPos = applyToPoint9(rotationMatrix, {
78733
+ const rotatedPos = applyToPoint12(rotationMatrix, {
78456
78734
  x: relativeX,
78457
78735
  y: relativeY
78458
78736
  });
@@ -78552,12 +78830,12 @@ var AddFootprintsStage = class extends ConverterStage {
78552
78830
  const sourceComponent = component.source_component_id ? this.ctx.db.source_component.get(component.source_component_id) : null;
78553
78831
  const cadComponent = this.getCadComponentForPcbComponent(component.pcb_component_id);
78554
78832
  const footprintName = sourceComponent ? getKicadCompatibleComponentName(sourceComponent, cadComponent) : "Unknown";
78555
- const transformedPos = applyToPoint10(c2kMatPcb, {
78833
+ const transformedPos = applyToPoint13(c2kMatPcb, {
78556
78834
  x: component.center.x,
78557
78835
  y: component.center.y
78558
78836
  });
78559
78837
  const footprintData = `footprint:${component.pcb_component_id}:${transformedPos.x},${transformedPos.y}`;
78560
- const footprint = new Footprint({
78838
+ const footprint = new Footprint2({
78561
78839
  libraryLink: `tscircuit:${footprintName}`,
78562
78840
  layer: "F.Cu",
78563
78841
  at: [transformedPos.x, transformedPos.y, component.rotation || 0],
@@ -78606,6 +78884,10 @@ var AddFootprintsStage = class extends ConverterStage {
78606
78884
  footprint.models = models;
78607
78885
  }
78608
78886
  }
78887
+ const footprintMetadata = component.metadata?.kicad_footprint;
78888
+ if (footprintMetadata && sourceComponent?.name) {
78889
+ applyMetadataToFootprint(footprint, footprintMetadata, sourceComponent.name);
78890
+ }
78609
78891
  const footprints = kicadPcb.footprints;
78610
78892
  footprints.push(footprint);
78611
78893
  kicadPcb.footprints = footprints;
@@ -78666,11 +78948,11 @@ var AddTracesStage = class extends ConverterStage {
78666
78948
  for (let i = 0;i < trace.route.length - 1; i++) {
78667
78949
  const startPoint = trace.route[i];
78668
78950
  const endPoint = trace.route[i + 1];
78669
- const transformedStart = applyToPoint11(c2kMatPcb, {
78951
+ const transformedStart = applyToPoint14(c2kMatPcb, {
78670
78952
  x: startPoint.x,
78671
78953
  y: startPoint.y
78672
78954
  });
78673
- const transformedEnd = applyToPoint11(c2kMatPcb, {
78955
+ const transformedEnd = applyToPoint14(c2kMatPcb, {
78674
78956
  x: endPoint.x,
78675
78957
  y: endPoint.y
78676
78958
  });
@@ -78749,7 +79031,7 @@ var AddViasStage = class extends ConverterStage {
78749
79031
  return;
78750
79032
  }
78751
79033
  const via = this.pcbVias[this.viasProcessed];
78752
- const transformedPos = applyToPoint12(c2kMatPcb, {
79034
+ const transformedPos = applyToPoint15(c2kMatPcb, {
78753
79035
  x: via.x,
78754
79036
  y: via.y
78755
79037
  });
@@ -78818,7 +79100,7 @@ function createFabricationNoteTextFromCircuitJson({
78818
79100
  if (!textElement.text || !textElement.anchor_position) {
78819
79101
  return null;
78820
79102
  }
78821
- const transformedPos = applyToPoint13(c2kMatPcb, {
79103
+ const transformedPos = applyToPoint16(c2kMatPcb, {
78822
79104
  x: textElement.anchor_position.x,
78823
79105
  y: textElement.anchor_position.y
78824
79106
  });
@@ -78828,7 +79110,7 @@ function createFabricationNoteTextFromCircuitJson({
78828
79110
  };
78829
79111
  const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.Fab";
78830
79112
  const fontSize = (textElement.font_size || 1) / 1.5;
78831
- const font = new TextEffectsFont6;
79113
+ const font = new TextEffectsFont9;
78832
79114
  font.size = { width: fontSize, height: fontSize };
78833
79115
  const justify = new TextEffectsJustify3;
78834
79116
  const anchorAlignment = textElement.anchor_alignment || "center";
@@ -78852,7 +79134,7 @@ function createFabricationNoteTextFromCircuitJson({
78852
79134
  case "center":
78853
79135
  break;
78854
79136
  }
78855
- const textEffects = new TextEffects6({
79137
+ const textEffects = new TextEffects9({
78856
79138
  font
78857
79139
  });
78858
79140
  if (anchorAlignment !== "center") {
@@ -78874,7 +79156,7 @@ function createGrTextFromCircuitJson({
78874
79156
  if (!textElement.text || !textElement.anchor_position) {
78875
79157
  return null;
78876
79158
  }
78877
- const transformedPos = applyToPoint14(c2kMatPcb, {
79159
+ const transformedPos = applyToPoint17(c2kMatPcb, {
78878
79160
  x: textElement.anchor_position.x,
78879
79161
  y: textElement.anchor_position.y
78880
79162
  });
@@ -78884,7 +79166,7 @@ function createGrTextFromCircuitJson({
78884
79166
  };
78885
79167
  const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
78886
79168
  const fontSize = (textElement.font_size || 1) / 1.5;
78887
- const font = new TextEffectsFont7;
79169
+ const font = new TextEffectsFont10;
78888
79170
  font.size = { width: fontSize, height: fontSize };
78889
79171
  const justify = new TextEffectsJustify4;
78890
79172
  const anchorAlignment = textElement.anchor_alignment || "center";
@@ -78908,7 +79190,7 @@ function createGrTextFromCircuitJson({
78908
79190
  case "center":
78909
79191
  break;
78910
79192
  }
78911
- const textEffects = new TextEffects7({
79193
+ const textEffects = new TextEffects10({
78912
79194
  font
78913
79195
  });
78914
79196
  if (anchorAlignment !== "center") {
@@ -78942,11 +79224,11 @@ var AddGraphicsStage = class extends ConverterStage {
78942
79224
  const endPoint = path14.route[i + 1];
78943
79225
  if (!startPoint || !endPoint)
78944
79226
  continue;
78945
- const transformedStart = applyToPoint15(c2kMatPcb, {
79227
+ const transformedStart = applyToPoint18(c2kMatPcb, {
78946
79228
  x: startPoint.x,
78947
79229
  y: startPoint.y
78948
79230
  });
78949
- const transformedEnd = applyToPoint15(c2kMatPcb, {
79231
+ const transformedEnd = applyToPoint18(c2kMatPcb, {
78950
79232
  x: endPoint.x,
78951
79233
  y: endPoint.y
78952
79234
  });
@@ -79010,7 +79292,7 @@ var AddGraphicsStage = class extends ConverterStage {
79010
79292
  { x: board.center.x - halfWidth, y: board.center.y + halfHeight }
79011
79293
  ];
79012
79294
  }
79013
- const transformedCorners = corners.map((corner) => applyToPoint15(c2kMatPcb, corner));
79295
+ const transformedCorners = corners.map((corner) => applyToPoint18(c2kMatPcb, corner));
79014
79296
  for (let i = 0;i < transformedCorners.length; i++) {
79015
79297
  const start = transformedCorners[i];
79016
79298
  const end = transformedCorners[(i + 1) % transformedCorners.length];
@@ -79052,7 +79334,7 @@ var CircuitJsonToKicadPcbConverter = class {
79052
79334
  generator: "circuit-json-to-kicad",
79053
79335
  generatorVersion: "0.0.1"
79054
79336
  }),
79055
- c2kMatPcb: compose3(translate3(KICAD_PCB_CENTER_X, KICAD_PCB_CENTER_Y), scale3(CIRCUIT_JSON_TO_MM_SCALE, -CIRCUIT_JSON_TO_MM_SCALE))
79337
+ c2kMatPcb: compose4(translate4(KICAD_PCB_CENTER_X, KICAD_PCB_CENTER_Y), scale3(CIRCUIT_JSON_TO_MM_SCALE, -CIRCUIT_JSON_TO_MM_SCALE))
79056
79338
  };
79057
79339
  this.pipeline = [
79058
79340
  new InitializePcbStage(circuitJson, this.ctx),
@@ -79287,6 +79569,10 @@ var ExtractFootprintsStage = class extends ConverterStage {
79287
79569
  if (sourceComp) {
79288
79570
  const footprintName = getKicadCompatibleComponentName(sourceComp, cadComponent);
79289
79571
  customNames.add(footprintName);
79572
+ const pcbComp = this.ctx.circuitJson.find((el) => el.type === "pcb_component" && el.source_component_id === cadComponent.source_component_id);
79573
+ if (pcbComp && pcbComp.type === "pcb_component" && pcbComp.metadata?.kicad_footprint?.footprintName) {
79574
+ customNames.add(pcbComp.metadata.kicad_footprint.footprintName);
79575
+ }
79290
79576
  }
79291
79577
  }
79292
79578
  }
@@ -79348,10 +79634,10 @@ var ExtractFootprintsStage = class extends ConverterStage {
79348
79634
  footprint.tags = "";
79349
79635
  }
79350
79636
  if (!footprint.embeddedFonts) {
79351
- footprint.embeddedFonts = new EmbeddedFonts4(false);
79637
+ footprint.embeddedFonts = new EmbeddedFonts5(false);
79352
79638
  }
79353
79639
  if (!footprint.attr) {
79354
- const attr = new FootprintAttr;
79640
+ const attr = new FootprintAttr2;
79355
79641
  const padTypes = (footprint.fpPads ?? []).map((pad) => pad.padType);
79356
79642
  if (padTypes.some((padType) => padType.includes("thru_hole"))) {
79357
79643
  attr.type = "through_hole";
@@ -79364,10 +79650,10 @@ var ExtractFootprintsStage = class extends ConverterStage {
79364
79650
  footprint.path = undefined;
79365
79651
  footprint.sheetfile = undefined;
79366
79652
  footprint.sheetname = undefined;
79367
- const defaultFont = new TextEffectsFont8;
79653
+ const defaultFont = new TextEffectsFont11;
79368
79654
  defaultFont.size = { width: 1.27, height: 1.27 };
79369
79655
  defaultFont.thickness = 0.15;
79370
- const defaultEffects = new TextEffects8({ font: defaultFont });
79656
+ const defaultEffects = new TextEffects11({ font: defaultFont });
79371
79657
  const fpPads = footprint.fpPads ?? [];
79372
79658
  let minY = 0;
79373
79659
  let maxY = 0;
@@ -79386,7 +79672,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
79386
79672
  const refY = minY - 0.5;
79387
79673
  const valY = maxY + 0.5;
79388
79674
  footprint.properties = [
79389
- new Property({
79675
+ new Property2({
79390
79676
  key: "Reference",
79391
79677
  value: "REF**",
79392
79678
  position: [0, refY, 0],
@@ -79394,7 +79680,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
79394
79680
  uuid: generateDeterministicUuid(`${footprintName}-property-Reference`),
79395
79681
  effects: defaultEffects
79396
79682
  }),
79397
- new Property({
79683
+ new Property2({
79398
79684
  key: "Value",
79399
79685
  value: "Val**",
79400
79686
  position: [0, valY, 0],
@@ -79402,7 +79688,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
79402
79688
  uuid: generateDeterministicUuid(`${footprintName}-property-Value`),
79403
79689
  effects: defaultEffects
79404
79690
  }),
79405
- new Property({
79691
+ new Property2({
79406
79692
  key: "Datasheet",
79407
79693
  value: "",
79408
79694
  position: [0, 0, 0],
@@ -79411,7 +79697,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
79411
79697
  uuid: generateDeterministicUuid(`${footprintName}-property-Datasheet`),
79412
79698
  effects: defaultEffects
79413
79699
  }),
79414
- new Property({
79700
+ new Property2({
79415
79701
  key: "Description",
79416
79702
  value: "",
79417
79703
  position: [0, 0, 0],
@@ -79447,7 +79733,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
79447
79733
  if (model.path) {
79448
79734
  const modelFilename = getBasename(model.path);
79449
79735
  const newPath = `../../3dmodels/${fpLibraryName}.3dshapes/${modelFilename}`;
79450
- const newModel = new FootprintModel2(newPath);
79736
+ const newModel = new FootprintModel3(newPath);
79451
79737
  if (model.offset)
79452
79738
  newModel.offset = model.offset;
79453
79739
  if (model.scale)
@@ -79639,8 +79925,8 @@ function renameKicadFootprint(params2) {
79639
79925
  model3dSourcePaths: kicadFootprint.model3dSourcePaths
79640
79926
  };
79641
79927
  }
79642
- function createTextEffects(metadataEffects) {
79643
- const font = new TextEffectsFont9;
79928
+ function createTextEffects3(metadataEffects) {
79929
+ const font = new TextEffectsFont12;
79644
79930
  if (metadataEffects?.font?.size) {
79645
79931
  font.size = {
79646
79932
  width: Number(metadataEffects.font.size.x),
@@ -79654,12 +79940,12 @@ function createTextEffects(metadataEffects) {
79654
79940
  } else {
79655
79941
  font.thickness = 0.15;
79656
79942
  }
79657
- return new TextEffects9({ font });
79943
+ return new TextEffects12({ font });
79658
79944
  }
79659
79945
  function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
79660
79946
  try {
79661
79947
  const parsed = parseKicadSexpr3(kicadModString);
79662
- const footprint = parsed.find((node) => node instanceof Footprint3);
79948
+ const footprint = parsed.find((node) => node instanceof Footprint4);
79663
79949
  if (!footprint) {
79664
79950
  return kicadModString;
79665
79951
  }
@@ -79676,7 +79962,7 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
79676
79962
  if (metadata.properties) {
79677
79963
  const newProperties = [];
79678
79964
  const refMeta = metadata.properties.Reference;
79679
- newProperties.push(new Property2({
79965
+ newProperties.push(new Property3({
79680
79966
  key: "Reference",
79681
79967
  value: refMeta?.value ?? "REF**",
79682
79968
  position: refMeta?.at ? [
@@ -79686,11 +79972,11 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
79686
79972
  ] : [0, 0, 0],
79687
79973
  layer: refMeta?.layer ?? "F.SilkS",
79688
79974
  uuid: refMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Reference`),
79689
- effects: createTextEffects(refMeta?.effects),
79975
+ effects: createTextEffects3(refMeta?.effects),
79690
79976
  hidden: refMeta?.hide
79691
79977
  }));
79692
79978
  const valMeta = metadata.properties.Value;
79693
- newProperties.push(new Property2({
79979
+ newProperties.push(new Property3({
79694
79980
  key: "Value",
79695
79981
  value: valMeta?.value ?? footprintName,
79696
79982
  position: valMeta?.at ? [
@@ -79700,11 +79986,11 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
79700
79986
  ] : [0, 0, 0],
79701
79987
  layer: valMeta?.layer ?? "F.Fab",
79702
79988
  uuid: valMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Value`),
79703
- effects: createTextEffects(valMeta?.effects),
79989
+ effects: createTextEffects3(valMeta?.effects),
79704
79990
  hidden: valMeta?.hide
79705
79991
  }));
79706
79992
  const dsMeta = metadata.properties.Datasheet;
79707
- newProperties.push(new Property2({
79993
+ newProperties.push(new Property3({
79708
79994
  key: "Datasheet",
79709
79995
  value: dsMeta?.value ?? "",
79710
79996
  position: dsMeta?.at ? [
@@ -79714,11 +80000,11 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
79714
80000
  ] : [0, 0, 0],
79715
80001
  layer: dsMeta?.layer ?? "F.Fab",
79716
80002
  uuid: dsMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Datasheet`),
79717
- effects: createTextEffects(dsMeta?.effects),
80003
+ effects: createTextEffects3(dsMeta?.effects),
79718
80004
  hidden: dsMeta?.hide ?? true
79719
80005
  }));
79720
80006
  const descMeta = metadata.properties.Description;
79721
- newProperties.push(new Property2({
80007
+ newProperties.push(new Property3({
79722
80008
  key: "Description",
79723
80009
  value: descMeta?.value ?? "",
79724
80010
  position: descMeta?.at ? [
@@ -79728,7 +80014,7 @@ function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
79728
80014
  ] : [0, 0, 0],
79729
80015
  layer: descMeta?.layer ?? "F.Fab",
79730
80016
  uuid: descMeta?.uuid ?? generateDeterministicUuid(`${footprintName}-property-Description`),
79731
- effects: createTextEffects(descMeta?.effects),
80017
+ effects: createTextEffects3(descMeta?.effects),
79732
80018
  hidden: descMeta?.hide ?? true
79733
80019
  }));
79734
80020
  footprint.properties = newProperties;
@@ -79767,7 +80053,9 @@ function classifyFootprintsForComponent({
79767
80053
  }) {
79768
80054
  const { tscircuitComponentName, kicadFootprints } = extractedKicadComponent;
79769
80055
  let hasAddedUserFootprint = false;
79770
- const metadata = ctx.footprintMetadataMap.get(tscircuitComponentName);
80056
+ const builtComponent = ctx.builtTscircuitComponents.find((c) => c.tscircuitComponentName === tscircuitComponentName);
80057
+ const pcbComponent = builtComponent?.circuitJson.find((el) => el.type === "pcb_component");
80058
+ const metadata = pcbComponent?.metadata?.kicad_footprint;
79771
80059
  for (const kicadFootprint of kicadFootprints) {
79772
80060
  if (kicadFootprint.isBuiltin) {
79773
80061
  addBuiltinFootprint({ ctx, kicadFootprint });
@@ -79891,16 +80179,16 @@ var toNumber = (value, fallback) => {
79891
80179
  return fallback;
79892
80180
  return parsed;
79893
80181
  };
79894
- var createTextEffects2 = (effectsMeta, fallback) => {
80182
+ var createTextEffects4 = (effectsMeta, fallback) => {
79895
80183
  if (!effectsMeta)
79896
80184
  return fallback;
79897
- const effects = new TextEffects10({
80185
+ const effects = new TextEffects13({
79898
80186
  font: fallback?.font,
79899
80187
  justify: fallback?.justify,
79900
80188
  hiddenText: fallback?.hiddenText ?? false
79901
80189
  });
79902
80190
  if (!effects.font) {
79903
- const defaultFont = new TextEffectsFont10;
80191
+ const defaultFont = new TextEffectsFont13;
79904
80192
  defaultFont.size = { width: DEFAULT_TEXT_SIZE, height: DEFAULT_TEXT_SIZE };
79905
80193
  effects.font = defaultFont;
79906
80194
  }
@@ -79955,7 +80243,7 @@ var applySymbolProperty = (symbol, key, propertyMeta) => {
79955
80243
  toNumber(propertyMeta.at.y, 0),
79956
80244
  toNumber(propertyMeta.at.rotation, 0)
79957
80245
  ] : existingProperty?.at;
79958
- const nextEffects = createTextEffects2(propertyMeta.effects, existingProperty?.effects);
80246
+ const nextEffects = createTextEffects4(propertyMeta.effects, existingProperty?.effects);
79959
80247
  if (existingProperty) {
79960
80248
  existingProperty.value = propertyMeta.value;
79961
80249
  if (nextId !== undefined) {
@@ -79989,15 +80277,15 @@ function applyKicadSymbolMetadata(kicadSymbol, metadata) {
79989
80277
  symbol.onBoard = metadata.onBoard;
79990
80278
  }
79991
80279
  if (metadata.embeddedFonts !== undefined) {
79992
- symbol._sxEmbeddedFonts = new EmbeddedFonts5(metadata.embeddedFonts);
80280
+ symbol._sxEmbeddedFonts = new EmbeddedFonts6(metadata.embeddedFonts);
79993
80281
  }
79994
80282
  if (metadata.pinNumbers?.hide !== undefined) {
79995
- const pinNumbers = symbol.pinNumbers ?? new SymbolPinNumbers2;
80283
+ const pinNumbers = symbol.pinNumbers ?? new SymbolPinNumbers3;
79996
80284
  pinNumbers.hide = metadata.pinNumbers.hide;
79997
80285
  symbol.pinNumbers = pinNumbers;
79998
80286
  }
79999
80287
  if (metadata.pinNames) {
80000
- const pinNames = symbol.pinNames ?? new SymbolPinNames2;
80288
+ const pinNames = symbol.pinNames ?? new SymbolPinNames3;
80001
80289
  if (metadata.pinNames.offset !== undefined) {
80002
80290
  pinNames.offset = toNumber(metadata.pinNames.offset, pinNames.offset);
80003
80291
  }
@@ -80032,7 +80320,9 @@ function classifySymbolsForComponent({
80032
80320
  const { tscircuitComponentName, kicadSymbols } = extractedKicadComponent;
80033
80321
  const hasCustomFootprint = componentHasCustomFootprint(extractedKicadComponent);
80034
80322
  let hasAddedUserSymbol = false;
80035
- const metadata = ctx.symbolMetadataMap.get(tscircuitComponentName);
80323
+ const builtComponent = ctx.builtTscircuitComponents.find((c) => c.tscircuitComponentName === tscircuitComponentName);
80324
+ const schematicSymbol = builtComponent?.circuitJson.find((el) => el.type === "schematic_symbol");
80325
+ const metadata = schematicSymbol?.metadata?.kicad_symbol;
80036
80326
  for (const kicadSymbol of kicadSymbols) {
80037
80327
  if (!kicadSymbol.isBuiltin) {
80038
80328
  const symbolName = kicadSymbol.symbolName;
@@ -80183,8 +80473,6 @@ var KicadLibraryConverter = class {
80183
80473
  this.ctx = createKicadLibraryConverterContext({
80184
80474
  kicadLibraryName: options.kicadLibraryName ?? "tscircuit_library",
80185
80475
  includeBuiltins: options.includeBuiltins ?? true,
80186
- getComponentKicadMetadata: options.getComponentKicadMetadata,
80187
- getComponentKicadSymbolMetadata: options.getComponentKicadSymbolMetadata,
80188
80476
  isPcm: options.isPcm ?? false,
80189
80477
  kicadPcmPackageId: options.kicadPcmPackageId
80190
80478
  });
@@ -80212,18 +80500,6 @@ var KicadLibraryConverter = class {
80212
80500
  if (resolved)
80213
80501
  componentPath = resolved;
80214
80502
  }
80215
- if (this.ctx.getComponentKicadMetadata) {
80216
- const metadata = await this.ctx.getComponentKicadMetadata(componentPath, exportName);
80217
- if (metadata) {
80218
- this.ctx.footprintMetadataMap.set(exportName, metadata);
80219
- }
80220
- }
80221
- if (this.ctx.getComponentKicadSymbolMetadata) {
80222
- const symbolMetadata = await this.ctx.getComponentKicadSymbolMetadata(componentPath, exportName);
80223
- if (symbolMetadata) {
80224
- this.ctx.symbolMetadataMap.set(exportName, symbolMetadata);
80225
- }
80226
- }
80227
80503
  const circuitJson = await this.options.buildFileToCircuitJson(componentPath, exportName);
80228
80504
  if (circuitJson && (!Array.isArray(circuitJson) || circuitJson.length > 0)) {
80229
80505
  builtTscircuitComponents.push({
@@ -80240,18 +80516,6 @@ var KicadLibraryConverter = class {
80240
80516
  componentPath = resolved;
80241
80517
  }
80242
80518
  const componentName = deriveComponentNameFromPath(componentPath);
80243
- if (this.ctx.getComponentKicadMetadata) {
80244
- const metadata = await this.ctx.getComponentKicadMetadata(componentPath, "default");
80245
- if (metadata) {
80246
- this.ctx.footprintMetadataMap.set(componentName, metadata);
80247
- }
80248
- }
80249
- if (this.ctx.getComponentKicadSymbolMetadata) {
80250
- const symbolMetadata = await this.ctx.getComponentKicadSymbolMetadata(componentPath, "default");
80251
- if (symbolMetadata) {
80252
- this.ctx.symbolMetadataMap.set(componentName, symbolMetadata);
80253
- }
80254
- }
80255
80519
  const circuitJson = await this.options.buildFileToCircuitJson(componentPath, "default");
80256
80520
  if (circuitJson && (!Array.isArray(circuitJson) || circuitJson.length > 0)) {
80257
80521
  builtTscircuitComponents.push({
@@ -80297,12 +80561,8 @@ function createKicadLibraryConverterContext(params2) {
80297
80561
  return {
80298
80562
  kicadLibraryName: params2.kicadLibraryName,
80299
80563
  includeBuiltins: params2.includeBuiltins,
80300
- getComponentKicadMetadata: params2.getComponentKicadMetadata,
80301
- getComponentKicadSymbolMetadata: params2.getComponentKicadSymbolMetadata,
80302
80564
  isPcm: params2.isPcm,
80303
80565
  kicadPcmPackageId: params2.kicadPcmPackageId,
80304
- footprintMetadataMap: /* @__PURE__ */ new Map,
80305
- symbolMetadataMap: /* @__PURE__ */ new Map,
80306
80566
  builtTscircuitComponents: [],
80307
80567
  extractedKicadComponents: [],
80308
80568
  userKicadFootprints: [],
@@ -80347,144 +80607,6 @@ async function importFromUserLand(moduleName) {
80347
80607
  return import(moduleName);
80348
80608
  }
80349
80609
 
80350
- // lib/shared/extract-kicad-footprint-metadata.ts
80351
- function extractKicadFootprintMetadata(Component, options = {}) {
80352
- const { maxIterations = 100, debug = false } = options;
80353
- let reactElm;
80354
- try {
80355
- reactElm = Component({});
80356
- } catch (e) {
80357
- if (debug) {
80358
- console.log(`[extractKicadFootprintMetadata] Failed to call root component:`, e);
80359
- }
80360
- return {};
80361
- }
80362
- if (!reactElm) {
80363
- return {};
80364
- }
80365
- const queue = [reactElm];
80366
- let iterations = 0;
80367
- while (queue.length > 0) {
80368
- iterations++;
80369
- if (iterations > maxIterations) {
80370
- if (debug) {
80371
- console.log(`[extractKicadFootprintMetadata] Max iterations (${maxIterations}) reached`);
80372
- }
80373
- break;
80374
- }
80375
- const elm = queue.shift();
80376
- if (!elm)
80377
- continue;
80378
- if (typeof elm.type === "function") {
80379
- try {
80380
- let childElm = null;
80381
- try {
80382
- childElm = elm.type(elm.props || {});
80383
- } catch {
80384
- childElm = elm.type();
80385
- }
80386
- if (childElm) {
80387
- queue.push(childElm);
80388
- }
80389
- } catch (e) {
80390
- if (debug) {
80391
- console.log(`[extractKicadFootprintMetadata] Failed to call functional component:`, e);
80392
- }
80393
- }
80394
- }
80395
- if (elm?.props?.kicadFootprintMetadata) {
80396
- return elm.props.kicadFootprintMetadata;
80397
- }
80398
- if (elm?.props) {
80399
- const children = elm.props.children;
80400
- if (Array.isArray(children)) {
80401
- for (const child of children) {
80402
- if (child && typeof child === "object") {
80403
- queue.push(child);
80404
- }
80405
- }
80406
- } else if (children && typeof children === "object") {
80407
- queue.push(children);
80408
- }
80409
- for (const [key, value] of Object.entries(elm.props)) {
80410
- if (key !== "children" && value && typeof value === "object" && "type" in value && "props" in value) {
80411
- queue.push(value);
80412
- }
80413
- }
80414
- }
80415
- }
80416
- return {};
80417
- }
80418
-
80419
- // lib/shared/extract-kicad-symbol-metadata.ts
80420
- function extractKicadSymbolMetadata(Component, options = {}) {
80421
- const { maxIterations = 100, debug = false } = options;
80422
- let reactElm;
80423
- try {
80424
- reactElm = Component({});
80425
- } catch (e) {
80426
- if (debug) {
80427
- console.log(`[extractKicadSymbolMetadata] Failed to call root component:`, e);
80428
- }
80429
- return {};
80430
- }
80431
- if (!reactElm) {
80432
- return {};
80433
- }
80434
- const queue = [reactElm];
80435
- let iterations = 0;
80436
- while (queue.length > 0) {
80437
- iterations++;
80438
- if (iterations > maxIterations) {
80439
- if (debug) {
80440
- console.log(`[extractKicadSymbolMetadata] Max iterations (${maxIterations}) reached`);
80441
- }
80442
- break;
80443
- }
80444
- const elm = queue.shift();
80445
- if (!elm)
80446
- continue;
80447
- if (typeof elm.type === "function") {
80448
- try {
80449
- let childElm = null;
80450
- try {
80451
- childElm = elm.type(elm.props || {});
80452
- } catch {
80453
- childElm = elm.type();
80454
- }
80455
- if (childElm) {
80456
- queue.push(childElm);
80457
- }
80458
- } catch (e) {
80459
- if (debug) {
80460
- console.log(`[extractKicadSymbolMetadata] Failed to call functional component:`, e);
80461
- }
80462
- }
80463
- }
80464
- if (elm?.props?.kicadSymbolMetadata) {
80465
- return elm.props.kicadSymbolMetadata;
80466
- }
80467
- if (elm?.props) {
80468
- const children = elm.props.children;
80469
- if (Array.isArray(children)) {
80470
- for (const child of children) {
80471
- if (child && typeof child === "object") {
80472
- queue.push(child);
80473
- }
80474
- }
80475
- } else if (children && typeof children === "object") {
80476
- queue.push(children);
80477
- }
80478
- for (const [key, value] of Object.entries(elm.props)) {
80479
- if (key !== "children" && value && typeof value === "object" && "type" in value && "props" in value) {
80480
- queue.push(value);
80481
- }
80482
- }
80483
- }
80484
- }
80485
- return {};
80486
- }
80487
-
80488
80610
  // lib/shared/convert-to-kicad-library.tsx
80489
80611
  import { jsxDEV } from "react/jsx-dev-runtime";
80490
80612
  async function convertToKicadLibrary({
@@ -80525,30 +80647,6 @@ async function convertToKicadLibrary({
80525
80647
  const module2 = await import(pathToFileURL(filePath2).href);
80526
80648
  return Object.keys(module2);
80527
80649
  },
80528
- getComponentKicadMetadata: async (filePath2, componentName) => {
80529
- try {
80530
- const module2 = await import(pathToFileURL(filePath2).href);
80531
- const Component = module2[componentName];
80532
- if (!Component || typeof Component !== "function") {
80533
- return null;
80534
- }
80535
- return extractKicadFootprintMetadata(Component);
80536
- } catch (error) {
80537
- return null;
80538
- }
80539
- },
80540
- getComponentKicadSymbolMetadata: async (filePath2, componentName) => {
80541
- try {
80542
- const module2 = await import(pathToFileURL(filePath2).href);
80543
- const Component = module2[componentName];
80544
- if (!Component || typeof Component !== "function") {
80545
- return null;
80546
- }
80547
- return extractKicadSymbolMetadata(Component);
80548
- } catch (error) {
80549
- return null;
80550
- }
80551
- },
80552
80650
  includeBuiltins: true,
80553
80651
  isPcm,
80554
80652
  kicadPcmPackageId
@@ -85436,7 +85534,7 @@ import {
85436
85534
  } from "circuit-to-svg";
85437
85535
 
85438
85536
  // node_modules/dsn-converter/dist/index.js
85439
- import { applyToPoint as applyToPoint16, scale as scale4 } from "transformation-matrix";
85537
+ import { applyToPoint as applyToPoint19, scale as scale4 } from "transformation-matrix";
85440
85538
  import { su as su4 } from "@tscircuit/soup-util";
85441
85539
  import { su as su22 } from "@tscircuit/soup-util";
85442
85540
  import Debug3 from "debug";
@@ -85604,7 +85702,7 @@ function processComponentsAndPads(componentGroups, circuitElements, pcb) {
85604
85702
  const sourceComponent = su4(circuitElements).source_component.list().find((e) => e.source_component_id === pcbComponent?.source_component_id);
85605
85703
  const footprintName = getFootprintName(sourceComponent, pcbComponent);
85606
85704
  const componentName = sourceComponent?.name || "Unknown";
85607
- const circuitSpaceCoordinates = applyToPoint16(transformMmToUm, pcbComponent.center);
85705
+ const circuitSpaceCoordinates = applyToPoint19(transformMmToUm, pcbComponent.center);
85608
85706
  if (!componentsByFootprint.has(footprintName)) {
85609
85707
  componentsByFootprint.set(footprintName, []);
85610
85708
  }
@@ -95689,7 +95787,7 @@ var any_circuit_element = external_exports.union([
95689
95787
  var any_soup_element = any_circuit_element;
95690
95788
  expectTypesMatch(true);
95691
95789
  expectStringUnionsMatch(true);
95692
- function applyToPoint18(matrix, point2) {
95790
+ function applyToPoint21(matrix, point2) {
95693
95791
  return Array.isArray(point2) ? [
95694
95792
  matrix.a * point2[0] + matrix.c * point2[1] + matrix.e,
95695
95793
  matrix.b * point2[0] + matrix.d * point2[1] + matrix.f
@@ -95698,7 +95796,7 @@ function applyToPoint18(matrix, point2) {
95698
95796
  y: matrix.b * point2.x + matrix.d * point2.y + matrix.f
95699
95797
  };
95700
95798
  }
95701
- function translate4(tx2, ty2 = 0) {
95799
+ function translate5(tx2, ty2 = 0) {
95702
95800
  return {
95703
95801
  a: 1,
95704
95802
  c: 0,
@@ -95734,7 +95832,7 @@ function transform(...matrices) {
95734
95832
  }
95735
95833
  }
95736
95834
  }
95737
- function compose4(...matrices) {
95835
+ function compose5(...matrices) {
95738
95836
  return transform(...matrices);
95739
95837
  }
95740
95838
  function isUndefined2(val) {
@@ -95756,9 +95854,9 @@ function rotate6(angle, cx2, cy2) {
95756
95854
  return rotationMatrix;
95757
95855
  }
95758
95856
  return transform([
95759
- translate4(cx2, cy2),
95857
+ translate5(cx2, cy2),
95760
95858
  rotationMatrix,
95761
- translate4(-cx2, -cy2)
95859
+ translate5(-cx2, -cy2)
95762
95860
  ]);
95763
95861
  }
95764
95862
  function rotateDEG(angle, cx2 = undefined, cy2 = undefined) {
@@ -95779,9 +95877,9 @@ function scale6(sx2, sy2 = undefined, cx2 = undefined, cy2 = undefined) {
95779
95877
  return scaleMatrix;
95780
95878
  }
95781
95879
  return transform([
95782
- translate4(cx2, cy2),
95880
+ translate5(cx2, cy2),
95783
95881
  scaleMatrix,
95784
- translate4(-cx2, -cy2)
95882
+ translate5(-cx2, -cy2)
95785
95883
  ]);
95786
95884
  }
95787
95885
  function identity5() {
@@ -95925,12 +96023,12 @@ peg$SyntaxError.buildMessage = function(expected, found) {
95925
96023
  function decomposeTSR(matrix, flipX = false, flipY2 = false) {
95926
96024
  if (flipX) {
95927
96025
  if (flipY2) {
95928
- matrix = compose4(matrix, scale6(-1, -1));
96026
+ matrix = compose5(matrix, scale6(-1, -1));
95929
96027
  } else {
95930
- matrix = compose4(matrix, scale6(1, -1));
96028
+ matrix = compose5(matrix, scale6(1, -1));
95931
96029
  }
95932
96030
  } else if (flipY2) {
95933
- matrix = compose4(matrix, scale6(-1, 1));
96031
+ matrix = compose5(matrix, scale6(-1, 1));
95934
96032
  }
95935
96033
  const a = matrix.a;
95936
96034
  const b = matrix.b;
@@ -96658,25 +96756,25 @@ var oppositeSide = (sideOrDir) => {
96658
96756
  };
96659
96757
  var transformSchematicElement = (elm, matrix) => {
96660
96758
  if (elm.type === "schematic_component") {
96661
- elm.center = applyToPoint18(matrix, elm.center);
96759
+ elm.center = applyToPoint21(matrix, elm.center);
96662
96760
  } else if (elm.type === "schematic_port") {
96663
- elm.center = applyToPoint18(matrix, elm.center);
96761
+ elm.center = applyToPoint21(matrix, elm.center);
96664
96762
  if (elm.facing_direction) {
96665
96763
  elm.facing_direction = rotateDirection(elm.facing_direction, -(Math.atan2(matrix.b, matrix.a) / Math.PI) * 2);
96666
96764
  }
96667
96765
  } else if (elm.type === "schematic_text") {
96668
- elm.position = applyToPoint18(matrix, elm.position);
96766
+ elm.position = applyToPoint21(matrix, elm.position);
96669
96767
  } else if (elm.type === "schematic_trace") {
96670
96768
  const anyElm = elm;
96671
96769
  anyElm.route = (anyElm.route ?? []).map((rp2) => {
96672
- const tp2 = applyToPoint18(matrix, rp2);
96770
+ const tp2 = applyToPoint21(matrix, rp2);
96673
96771
  rp2.x = tp2.x;
96674
96772
  rp2.y = tp2.y;
96675
96773
  return rp2;
96676
96774
  });
96677
96775
  if (Array.isArray(anyElm.junctions)) {
96678
96776
  anyElm.junctions = anyElm.junctions.map((j2) => {
96679
- const tp2 = applyToPoint18(matrix, j2);
96777
+ const tp2 = applyToPoint21(matrix, j2);
96680
96778
  j2.x = tp2.x;
96681
96779
  j2.y = tp2.y;
96682
96780
  return j2;
@@ -96684,18 +96782,18 @@ var transformSchematicElement = (elm, matrix) => {
96684
96782
  }
96685
96783
  if (Array.isArray(anyElm.edges)) {
96686
96784
  anyElm.edges = anyElm.edges.map((e3) => {
96687
- e3.from = applyToPoint18(matrix, e3.from);
96688
- e3.to = applyToPoint18(matrix, e3.to);
96785
+ e3.from = applyToPoint21(matrix, e3.from);
96786
+ e3.to = applyToPoint21(matrix, e3.to);
96689
96787
  return e3;
96690
96788
  });
96691
96789
  }
96692
96790
  } else if (elm.type === "schematic_box") {
96693
- const { x, y } = applyToPoint18(matrix, { x: elm.x, y: elm.y });
96791
+ const { x, y } = applyToPoint21(matrix, { x: elm.x, y: elm.y });
96694
96792
  elm.x = x;
96695
96793
  elm.y = y;
96696
96794
  } else if (elm.type === "schematic_line") {
96697
- const { x: x12, y: y12 } = applyToPoint18(matrix, { x: elm.x1, y: elm.y1 });
96698
- const { x: x22, y: y22 } = applyToPoint18(matrix, { x: elm.x2, y: elm.y2 });
96795
+ const { x: x12, y: y12 } = applyToPoint21(matrix, { x: elm.x1, y: elm.y1 });
96796
+ const { x: x22, y: y22 } = applyToPoint21(matrix, { x: elm.x2, y: elm.y2 });
96699
96797
  elm.x1 = x12;
96700
96798
  elm.y1 = y12;
96701
96799
  elm.x2 = x22;
@@ -96710,20 +96808,20 @@ var transformPCBElement = (elm, matrix) => {
96710
96808
  const tsr = decomposeTSR(matrix);
96711
96809
  const flipPadWidthHeight = Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1;
96712
96810
  if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
96713
- const { x, y } = applyToPoint18(matrix, {
96811
+ const { x, y } = applyToPoint21(matrix, {
96714
96812
  x: Number(elm.x),
96715
96813
  y: Number(elm.y)
96716
96814
  });
96717
96815
  elm.x = x;
96718
96816
  elm.y = y;
96719
96817
  } else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
96720
- elm.center = applyToPoint18(matrix, elm.center);
96818
+ elm.center = applyToPoint21(matrix, elm.center);
96721
96819
  } else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text") {
96722
- elm.anchor_position = applyToPoint18(matrix, elm.anchor_position);
96820
+ elm.anchor_position = applyToPoint21(matrix, elm.anchor_position);
96723
96821
  } else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect") {
96724
- elm.center = applyToPoint18(matrix, elm.center);
96822
+ elm.center = applyToPoint21(matrix, elm.center);
96725
96823
  } else if (elm.type === "pcb_component") {
96726
- elm.center = applyToPoint18(matrix, elm.center);
96824
+ elm.center = applyToPoint21(matrix, elm.center);
96727
96825
  elm.rotation = elm.rotation + tsr.rotation.angle / Math.PI * 180;
96728
96826
  elm.rotation = elm.rotation % 360;
96729
96827
  if (flipPadWidthHeight) {
@@ -96731,7 +96829,7 @@ var transformPCBElement = (elm, matrix) => {
96731
96829
  }
96732
96830
  } else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path") {
96733
96831
  elm.route = elm.route.map((rp2) => {
96734
- const tp2 = applyToPoint18(matrix, rp2);
96832
+ const tp2 = applyToPoint21(matrix, rp2);
96735
96833
  rp2.x = tp2.x;
96736
96834
  rp2.y = tp2.y;
96737
96835
  return rp2;
@@ -96739,14 +96837,14 @@ var transformPCBElement = (elm, matrix) => {
96739
96837
  } else if (elm.type === "pcb_silkscreen_line") {
96740
96838
  const p12 = { x: elm.x1, y: elm.y1 };
96741
96839
  const p22 = { x: elm.x2, y: elm.y2 };
96742
- const p1t = applyToPoint18(matrix, p12);
96743
- const p2t = applyToPoint18(matrix, p22);
96840
+ const p1t = applyToPoint21(matrix, p12);
96841
+ const p2t = applyToPoint21(matrix, p22);
96744
96842
  elm.x1 = p1t.x;
96745
96843
  elm.y1 = p1t.y;
96746
96844
  elm.x2 = p2t.x;
96747
96845
  elm.y2 = p2t.y;
96748
96846
  } else if (elm.type === "cad_component") {
96749
- const newPos = applyToPoint18(matrix, {
96847
+ const newPos = applyToPoint21(matrix, {
96750
96848
  x: elm.position.x,
96751
96849
  y: elm.position.y
96752
96850
  });
@@ -97143,7 +97241,7 @@ var repositionPcbComponentTo = (circuitJson, pcb_component_id, newCenter) => {
97143
97241
  return true;
97144
97242
  return false;
97145
97243
  });
97146
- const matrix = translate4(dx2, dy2);
97244
+ const matrix = translate5(dx2, dy2);
97147
97245
  transformPCBElements(elementsToMove, matrix);
97148
97246
  };
97149
97247
  var findAllDescendantGroupIds = (circuitJson, parentGroupId) => {
@@ -97184,7 +97282,7 @@ var repositionPcbGroupTo = (circuitJson, source_group_id, newCenter) => {
97184
97282
  const { center: currentCenter } = findBoundsAndCenter(pcbElements);
97185
97283
  const dx2 = newCenter.x - currentCenter.x;
97186
97284
  const dy2 = newCenter.y - currentCenter.y;
97187
- const matrix = translate4(dx2, dy2);
97285
+ const matrix = translate5(dx2, dy2);
97188
97286
  transformPCBElements(pcbElements, matrix);
97189
97287
  };
97190
97288
  var repositionSchematicComponentTo = (circuitJson, schematic_component_id, newCenter) => {
@@ -97215,7 +97313,7 @@ var repositionSchematicComponentTo = (circuitJson, schematic_component_id, newCe
97215
97313
  return true;
97216
97314
  return false;
97217
97315
  });
97218
- const matrix = translate4(dx2, dy2);
97316
+ const matrix = translate5(dx2, dy2);
97219
97317
  transformSchematicElements(elementsToMove, matrix);
97220
97318
  };
97221
97319
  var findAllDescendantGroupIds2 = (circuitJson, parentGroupId) => {
@@ -97261,7 +97359,7 @@ var repositionSchematicGroupTo = (circuitJson, source_group_id, newCenter) => {
97261
97359
  const { center: currentCenter } = findBoundsAndCenter(schematicElements);
97262
97360
  const dx2 = newCenter.x - currentCenter.x;
97263
97361
  const dy2 = newCenter.y - currentCenter.y;
97264
- const matrix = translate4(dx2, dy2);
97362
+ const matrix = translate5(dx2, dy2);
97265
97363
  transformSchematicElements(schematicElements, matrix);
97266
97364
  };
97267
97365
  var getCircuitJsonTree = (circuitJson, opts) => {
@@ -155997,7 +156095,7 @@ function rectanglePolygon({
155997
156095
  if (rotationDeg) {
155998
156096
  const matrix2 = rotateDEG(rotationDeg, cx2, cy2);
155999
156097
  const rotatedCorners = corners.map((pt22) => {
156000
- const p22 = applyToPoint18(matrix2, { x: pt22.x, y: pt22.y });
156098
+ const p22 = applyToPoint21(matrix2, { x: pt22.x, y: pt22.y });
156001
156099
  return new Point$3(p22.x, p22.y);
156002
156100
  });
156003
156101
  poly = new Polygon$1(rotatedCorners);
@@ -156062,7 +156160,7 @@ function computeOverlapDistance(compPoly, boardPoly, componentCenter, componentW
156062
156160
  }
156063
156161
  const matrix2 = rotateDEG(rotationDeg, componentCenter.x, componentCenter.y);
156064
156162
  const rotatePoint3 = (pt22) => {
156065
- const p22 = applyToPoint18(matrix2, pt22);
156163
+ const p22 = applyToPoint21(matrix2, pt22);
156066
156164
  return new Point$3(p22.x, p22.y);
156067
156165
  };
156068
156166
  const rotatedPoints = corners.concat(midpoints).map(rotatePoint3);
@@ -156474,7 +156572,7 @@ __export32(components_exports, {
156474
156572
  FabricationNotePath: () => FabricationNotePath,
156475
156573
  FabricationNoteRect: () => FabricationNoteRect,
156476
156574
  FabricationNoteText: () => FabricationNoteText,
156477
- Footprint: () => Footprint2,
156575
+ Footprint: () => Footprint,
156478
156576
  Fuse: () => Fuse2,
156479
156577
  Group: () => Group6,
156480
156578
  Hole: () => Hole,
@@ -157071,25 +157169,25 @@ var PrimitiveComponent2 = class extends Renderable {
157071
157169
  computePcbPropsTransform() {
157072
157170
  const { _parsedProps: props } = this;
157073
157171
  const rotation5 = this._getPcbRotationBeforeLayout() ?? 0;
157074
- const matrix2 = compose4(translate4(props.pcbX ?? 0, props.pcbY ?? 0), rotate6(rotation5 * Math.PI / 180));
157172
+ const matrix2 = compose5(translate5(props.pcbX ?? 0, props.pcbY ?? 0), rotate6(rotation5 * Math.PI / 180));
157075
157173
  return matrix2;
157076
157174
  }
157077
157175
  _computePcbGlobalTransformBeforeLayout() {
157078
157176
  const manualPlacement = this.getSubcircuit()._getPcbManualPlacementForComponent(this);
157079
157177
  if (manualPlacement && this.props.pcbX === undefined && this.props.pcbY === undefined) {
157080
157178
  const rotation5 = this._getPcbRotationBeforeLayout() ?? 0;
157081
- return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), compose4(translate4(manualPlacement.x, manualPlacement.y), rotate6(rotation5 * Math.PI / 180)));
157179
+ return compose5(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), compose5(translate5(manualPlacement.x, manualPlacement.y), rotate6(rotation5 * Math.PI / 180)));
157082
157180
  }
157083
157181
  if (this.isPcbPrimitive) {
157084
157182
  const primitiveContainer = this.getPrimitiveContainer();
157085
157183
  if (primitiveContainer) {
157086
157184
  const isFlipped = primitiveContainer._parsedProps.layer === "bottom";
157087
157185
  if (isFlipped) {
157088
- return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), flipY(), this.computePcbPropsTransform());
157186
+ return compose5(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), flipY(), this.computePcbPropsTransform());
157089
157187
  }
157090
157188
  }
157091
157189
  }
157092
- return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), this.computePcbPropsTransform());
157190
+ return compose5(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), this.computePcbPropsTransform());
157093
157191
  }
157094
157192
  getPrimitiveContainer() {
157095
157193
  if (this.isPrimitiveContainer)
@@ -157130,13 +157228,13 @@ var PrimitiveComponent2 = class extends Renderable {
157130
157228
  }
157131
157229
  computeSchematicPropsTransform() {
157132
157230
  const { _parsedProps: props } = this;
157133
- return compose4(translate4(props.schX ?? 0, props.schY ?? 0));
157231
+ return compose5(translate5(props.schX ?? 0, props.schY ?? 0));
157134
157232
  }
157135
157233
  computeSchematicGlobalTransform() {
157136
157234
  const manualPlacementTransform = this._getSchematicGlobalManualPlacementTransform(this);
157137
157235
  if (manualPlacementTransform)
157138
157236
  return manualPlacementTransform;
157139
- return compose4(this.parent?.computeSchematicGlobalTransform?.() ?? identity5(), this.computeSchematicPropsTransform());
157237
+ return compose5(this.parent?.computeSchematicGlobalTransform?.() ?? identity5(), this.computeSchematicPropsTransform());
157140
157238
  }
157141
157239
  _getSchematicSymbolName() {
157142
157240
  const { _parsedProps: props } = this;
@@ -157222,7 +157320,7 @@ var PrimitiveComponent2 = class extends Renderable {
157222
157320
  return null;
157223
157321
  for (const position2 of placementConfigPositions) {
157224
157322
  if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
157225
- const center2 = applyToPoint18(this._computePcbGlobalTransformBeforeLayout(), position2.center);
157323
+ const center2 = applyToPoint21(this._computePcbGlobalTransformBeforeLayout(), position2.center);
157226
157324
  return center2;
157227
157325
  }
157228
157326
  }
@@ -157239,7 +157337,7 @@ var PrimitiveComponent2 = class extends Renderable {
157239
157337
  return null;
157240
157338
  for (const position2 of placementConfigPositions) {
157241
157339
  if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
157242
- const center2 = applyToPoint18(this.computeSchematicGlobalTransform(), position2.center);
157340
+ const center2 = applyToPoint21(this.computeSchematicGlobalTransform(), position2.center);
157243
157341
  return center2;
157244
157342
  }
157245
157343
  }
@@ -157252,20 +157350,20 @@ var PrimitiveComponent2 = class extends Renderable {
157252
157350
  for (const position2 of manualEdits.schematic_placements ?? []) {
157253
157351
  if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
157254
157352
  if (position2.relative_to === "group_center") {
157255
- return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), translate4(position2.center.x, position2.center.y));
157353
+ return compose5(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity5(), translate5(position2.center.x, position2.center.y));
157256
157354
  }
157257
157355
  }
157258
157356
  }
157259
157357
  return null;
157260
157358
  }
157261
157359
  _getGlobalPcbPositionBeforeLayout() {
157262
- return applyToPoint18(this._computePcbGlobalTransformBeforeLayout(), {
157360
+ return applyToPoint21(this._computePcbGlobalTransformBeforeLayout(), {
157263
157361
  x: 0,
157264
157362
  y: 0
157265
157363
  });
157266
157364
  }
157267
157365
  _getGlobalSchematicPositionBeforeLayout() {
157268
- return applyToPoint18(this.computeSchematicGlobalTransform(), { x: 0, y: 0 });
157366
+ return applyToPoint21(this.computeSchematicGlobalTransform(), { x: 0, y: 0 });
157269
157367
  }
157270
157368
  get root() {
157271
157369
  return this.parent?.root ?? null;
@@ -158180,7 +158278,7 @@ var SmtPad = class extends PrimitiveComponent2 {
158180
158278
  });
158181
158279
  } else if (props.shape === "polygon") {
158182
158280
  const transformedPoints = props.points.map((point5) => {
158183
- const transformed = applyToPoint18(globalTransform, {
158281
+ const transformed = applyToPoint21(globalTransform, {
158184
158282
  x: distance.parse(point5.x),
158185
158283
  y: distance.parse(point5.y)
158186
158284
  });
@@ -158357,7 +158455,7 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
158357
158455
  pcb_component_id,
158358
158456
  layer,
158359
158457
  route: props.route.map((p22) => {
158360
- const transformedPosition = applyToPoint18(transform2, {
158458
+ const transformedPosition = applyToPoint21(transform2, {
158361
158459
  x: p22.x,
158362
158460
  y: p22.y
158363
158461
  });
@@ -158440,7 +158538,7 @@ var PcbTrace = class extends PrimitiveComponent2 {
158440
158538
  const parentTransform = this._computePcbGlobalTransformBeforeLayout();
158441
158539
  const transformedRoute = props.route.map((point5) => {
158442
158540
  const { x: x22, y: y22, ...restOfPoint } = point5;
158443
- const transformedPoint = applyToPoint18(parentTransform, { x: x22, y: y22 });
158541
+ const transformedPoint = applyToPoint21(parentTransform, { x: x22, y: y22 });
158444
158542
  if (point5.route_type === "wire" && point5.layer) {
158445
158543
  return {
158446
158544
  ...transformedPoint,
@@ -158946,7 +159044,7 @@ var Cutout = class extends PrimitiveComponent2 {
158946
159044
  inserted_pcb_cutout = db.pcb_cutout.insert(circleData);
158947
159045
  } else if (props.shape === "polygon") {
158948
159046
  const transform2 = this._computePcbGlobalTransformBeforeLayout();
158949
- const transformedPoints = props.points.map((p22) => applyToPoint18(transform2, p22));
159047
+ const transformedPoints = props.points.map((p22) => applyToPoint21(transform2, p22));
158950
159048
  const polygonData = {
158951
159049
  shape: "polygon",
158952
159050
  points: transformedPoints,
@@ -159646,8 +159744,8 @@ var Port = class extends PrimitiveComponent2 {
159646
159744
  throw new Error(`Couldn't find schematicSymbolPortDef for port ${this.getString()}, searched internally connected ports and none had a schematicSymbolPortDef. Why are we trying to get the schematic position of this port?`);
159647
159745
  }
159648
159746
  }
159649
- const transform2 = compose4(parentNormalComponent.computeSchematicGlobalTransform(), translate4(-symbol.center.x, -symbol.center.y));
159650
- return applyToPoint18(transform2, schematicSymbolPortDef);
159747
+ const transform2 = compose5(parentNormalComponent.computeSchematicGlobalTransform(), translate5(-symbol.center.x, -symbol.center.y));
159748
+ return applyToPoint21(transform2, schematicSymbolPortDef);
159651
159749
  }
159652
159750
  const parentBoxDim = parentNormalComponent?._getSchematicBoxDimensions();
159653
159751
  if (parentBoxDim && this.props.pinNumber !== undefined) {
@@ -159655,7 +159753,7 @@ var Port = class extends PrimitiveComponent2 {
159655
159753
  if (!localPortPosition) {
159656
159754
  throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);
159657
159755
  }
159658
- return applyToPoint18(parentNormalComponent.computeSchematicGlobalTransform(), localPortPosition);
159756
+ return applyToPoint21(parentNormalComponent.computeSchematicGlobalTransform(), localPortPosition);
159659
159757
  }
159660
159758
  throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`);
159661
159759
  }
@@ -160276,7 +160374,7 @@ var getAllDimensionsForSchematicBox = (params2) => {
160276
160374
  };
160277
160375
  };
160278
160376
  var debug222 = (0, import_debug82.default)("tscircuit:core:footprint");
160279
- var Footprint2 = class extends PrimitiveComponent2 {
160377
+ var Footprint = class extends PrimitiveComponent2 {
160280
160378
  get config() {
160281
160379
  return {
160282
160380
  componentName: "Footprint",
@@ -162284,7 +162382,7 @@ function Trace_doInitialPcbManualTraceRender(trace) {
162284
162382
  coordinates = { x: pt22.x, y: pt22.y };
162285
162383
  isGlobalPosition = false;
162286
162384
  }
162287
- const finalCoordinates = isGlobalPosition ? coordinates : applyToPoint18(transform2, coordinates);
162385
+ const finalCoordinates = isGlobalPosition ? coordinates : applyToPoint21(transform2, coordinates);
162288
162386
  route.push({
162289
162387
  route_type: "wire",
162290
162388
  x: finalCoordinates.x,
@@ -164473,7 +164571,7 @@ var TraceHint = class extends PrimitiveComponent2 {
164473
164571
  return [];
164474
164572
  const globalTransform = this._computePcbGlobalTransformBeforeLayout();
164475
164573
  return offsets.map((offset) => ({
164476
- ...applyToPoint18(globalTransform, offset),
164574
+ ...applyToPoint21(globalTransform, offset),
164477
164575
  via: offset.via,
164478
164576
  to_layer: offset.to_layer,
164479
164577
  trace_width: offset.trace_width
@@ -166357,7 +166455,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
166357
166455
  if (!member)
166358
166456
  continue;
166359
166457
  const originalCenter2 = member.center;
166360
- const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x + rotatedRel.x, center2.y + rotatedRel.y), rotate6(angleRad), translate4(-originalCenter2.x, -originalCenter2.y));
166458
+ const transformMatrix2 = compose5(group._computePcbGlobalTransformBeforeLayout(), translate5(center2.x + rotatedRel.x, center2.y + rotatedRel.y), rotate6(angleRad), translate5(-originalCenter2.x, -originalCenter2.y));
166361
166459
  const related = db.toArray().filter((elm) => ("pcb_component_id" in elm) && elm.pcb_component_id === memberId);
166362
166460
  transformPCBElements(related, transformMatrix2);
166363
166461
  updateCadRotation({
@@ -166379,7 +166477,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
166379
166477
  }
166380
166478
  const originalCenter2 = pcbComponent.center;
166381
166479
  const rotationDegrees2 = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
166382
- const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y), rotate6(rotationDegrees2 * Math.PI / 180), translate4(-originalCenter2.x, -originalCenter2.y));
166480
+ const transformMatrix2 = compose5(group._computePcbGlobalTransformBeforeLayout(), translate5(center2.x, center2.y), rotate6(rotationDegrees2 * Math.PI / 180), translate5(-originalCenter2.x, -originalCenter2.y));
166383
166481
  const related = db.toArray().filter((elm) => ("pcb_component_id" in elm) && elm.pcb_component_id === componentId);
166384
166482
  transformPCBElements(related, transformMatrix2);
166385
166483
  updateCadRotation({
@@ -166395,7 +166493,7 @@ var applyPackOutput = (group, packOutput, clusterMap) => {
166395
166493
  continue;
166396
166494
  const originalCenter = pcbGroup.center;
166397
166495
  const rotationDegrees = ccwRotationDegrees ?? ccwRotationOffset ?? 0;
166398
- const transformMatrix = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y), rotate6(rotationDegrees * Math.PI / 180), translate4(-originalCenter.x, -originalCenter.y));
166496
+ const transformMatrix = compose5(group._computePcbGlobalTransformBeforeLayout(), translate5(center2.x, center2.y), rotate6(rotationDegrees * Math.PI / 180), translate5(-originalCenter.x, -originalCenter.y));
166399
166497
  const relatedElements = db.toArray().filter((elm) => {
166400
166498
  if ("source_group_id" in elm && elm.source_group_id) {
166401
166499
  if (elm.source_group_id === componentId) {
@@ -169783,7 +169881,7 @@ var FabricationNotePath = class extends PrimitiveComponent2 {
169783
169881
  layer,
169784
169882
  color: props.color,
169785
169883
  route: props.route.map((p22) => {
169786
- const transformedPosition = applyToPoint18(transform2, {
169884
+ const transformedPosition = applyToPoint21(transform2, {
169787
169885
  x: p22.x,
169788
169886
  y: p22.y
169789
169887
  });
@@ -169844,13 +169942,13 @@ var FabricationNoteDimension = class extends PrimitiveComponent2 {
169844
169942
  const target = this.getSubcircuit().selectOne(input);
169845
169943
  if (!target) {
169846
169944
  this.renderError(`FabricationNoteDimension could not find selector "${input}"`);
169847
- return applyToPoint18(transform2, { x: 0, y: 0 });
169945
+ return applyToPoint21(transform2, { x: 0, y: 0 });
169848
169946
  }
169849
169947
  return target._getGlobalPcbPositionBeforeLayout();
169850
169948
  }
169851
169949
  const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
169852
169950
  const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
169853
- return applyToPoint18(transform2, { x: numericX, y: numericY });
169951
+ return applyToPoint21(transform2, { x: numericX, y: numericY });
169854
169952
  }
169855
169953
  doInitialPcbPrimitiveRender() {
169856
169954
  if (this.root?.pcbDisabled)
@@ -169930,8 +170028,8 @@ var PcbNoteLine = class extends PrimitiveComponent2 {
169930
170028
  const subcircuit = this.getSubcircuit();
169931
170029
  const group = this.getGroup();
169932
170030
  const transform2 = this._computePcbGlobalTransformBeforeLayout();
169933
- const start = applyToPoint18(transform2, { x: props.x1, y: props.y1 });
169934
- const end = applyToPoint18(transform2, { x: props.x2, y: props.y2 });
170031
+ const start = applyToPoint21(transform2, { x: props.x1, y: props.y1 });
170032
+ const end = applyToPoint21(transform2, { x: props.x2, y: props.y2 });
169935
170033
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
169936
170034
  const pcb_note_line2 = db.pcb_note_line.insert({
169937
170035
  pcb_component_id,
@@ -169970,7 +170068,7 @@ var PcbNoteRect = class extends PrimitiveComponent2 {
169970
170068
  const { db } = this.root;
169971
170069
  const { _parsedProps: props } = this;
169972
170070
  const transform2 = this._computePcbGlobalTransformBeforeLayout();
169973
- const center2 = applyToPoint18(transform2, { x: 0, y: 0 });
170071
+ const center2 = applyToPoint21(transform2, { x: 0, y: 0 });
169974
170072
  const subcircuit = this.getSubcircuit();
169975
170073
  const group = this.getGroup();
169976
170074
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
@@ -170012,7 +170110,7 @@ var PcbNoteText = class extends PrimitiveComponent2 {
170012
170110
  const { db } = this.root;
170013
170111
  const { _parsedProps: props } = this;
170014
170112
  const transform2 = this._computePcbGlobalTransformBeforeLayout();
170015
- const anchorPosition = applyToPoint18(transform2, { x: 0, y: 0 });
170113
+ const anchorPosition = applyToPoint21(transform2, { x: 0, y: 0 });
170016
170114
  const subcircuit = this.getSubcircuit();
170017
170115
  const group = this.getGroup();
170018
170116
  const pcb_component_id = this.parent?.pcb_component_id ?? this.getPrimitiveContainer()?.pcb_component_id ?? undefined;
@@ -170060,7 +170158,7 @@ var PcbNotePath = class extends PrimitiveComponent2 {
170060
170158
  const { x: x22, y: y22, ...rest } = point5;
170061
170159
  const numericX = typeof x22 === "string" ? parseFloat(x22) : x22;
170062
170160
  const numericY = typeof y22 === "string" ? parseFloat(y22) : y22;
170063
- const transformed = applyToPoint18(transform2, { x: numericX, y: numericY });
170161
+ const transformed = applyToPoint21(transform2, { x: numericX, y: numericY });
170064
170162
  return { ...rest, x: transformed.x, y: transformed.y };
170065
170163
  });
170066
170164
  const pcb_note_path2 = db.pcb_note_path.insert({
@@ -170100,13 +170198,13 @@ var PcbNoteDimension = class extends PrimitiveComponent2 {
170100
170198
  const target = this.getSubcircuit().selectOne(`.${input}`);
170101
170199
  if (!target) {
170102
170200
  this.renderError(`PcbNoteDimension could not find selector "${input}"`);
170103
- return applyToPoint18(transform2, { x: 0, y: 0 });
170201
+ return applyToPoint21(transform2, { x: 0, y: 0 });
170104
170202
  }
170105
170203
  return target._getGlobalPcbPositionBeforeLayout();
170106
170204
  }
170107
170205
  const numericX = typeof input.x === "string" ? parseFloat(input.x) : input.x;
170108
170206
  const numericY = typeof input.y === "string" ? parseFloat(input.y) : input.y;
170109
- return applyToPoint18(transform2, { x: numericX, y: numericY });
170207
+ return applyToPoint21(transform2, { x: numericX, y: numericY });
170110
170208
  }
170111
170209
  doInitialPcbPrimitiveRender() {
170112
170210
  if (this.root?.pcbDisabled)
@@ -170512,8 +170610,8 @@ var NetLabel = class extends PrimitiveComponent2 {
170512
170610
  const connectedPorts = this._getConnectedPorts();
170513
170611
  if (connectedPorts.length > 0) {
170514
170612
  const portPos = connectedPorts[0]._getGlobalSchematicPositionBeforeLayout();
170515
- const parentCenter = applyToPoint18(this.parent?.computeSchematicGlobalTransform?.() ?? identity5(), { x: 0, y: 0 });
170516
- return translate4(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
170613
+ const parentCenter = applyToPoint21(this.parent?.computeSchematicGlobalTransform?.() ?? identity5(), { x: 0, y: 0 });
170614
+ return translate5(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
170517
170615
  }
170518
170616
  }
170519
170617
  return super.computeSchematicPropsTransform();
@@ -172647,28 +172745,28 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
172647
172745
  const elementsForBounds = circuitElements.filter((e22) => e22.type !== "pcb_component" && e22.type !== "cad_component");
172648
172746
  const bounds = findBoundsAndCenter(elementsForBounds);
172649
172747
  if (Number.isFinite(bounds.center.x) && Number.isFinite(bounds.center.y)) {
172650
- const matrix2 = compose4(translate4(-bounds.center.x, bounds.center.y), scale6(1, -1));
172748
+ const matrix2 = compose5(translate5(-bounds.center.x, bounds.center.y), scale6(1, -1));
172651
172749
  const elementsForTransform = circuitElements.filter((e22) => !(e22.type === "pcb_smtpad" && e22.shape === "polygon") && e22.type !== "cad_component");
172652
172750
  transformPCBElements(elementsForTransform, matrix2);
172653
172751
  for (const e22 of circuitElements) {
172654
172752
  if (e22.type === "pcb_cutout") {
172655
172753
  if (e22.shape === "polygon") {
172656
- e22.points = e22.points.map((p22) => applyToPoint18(matrix2, p22));
172754
+ e22.points = e22.points.map((p22) => applyToPoint21(matrix2, p22));
172657
172755
  } else if (e22.shape === "circle" || e22.shape === "rect") {
172658
- e22.center = applyToPoint18(matrix2, e22.center);
172756
+ e22.center = applyToPoint21(matrix2, e22.center);
172659
172757
  } else if ("route" in e22) {
172660
172758
  const cutoutPath = e22;
172661
- cutoutPath.route = cutoutPath.route.map((p22) => applyToPoint18(matrix2, p22));
172759
+ cutoutPath.route = cutoutPath.route.map((p22) => applyToPoint21(matrix2, p22));
172662
172760
  }
172663
172761
  } else if (e22.type === "pcb_smtpad" && e22.shape === "polygon") {
172664
- e22.points = e22.points.map((p22) => applyToPoint18(matrix2, p22));
172762
+ e22.points = e22.points.map((p22) => applyToPoint21(matrix2, p22));
172665
172763
  }
172666
172764
  }
172667
172765
  const cad = circuitElements.find((e22) => e22.type === "cad_component");
172668
172766
  if (cad) {
172669
172767
  if (!cad.rotation)
172670
172768
  cad.rotation = { x: 0, y: 0, z: 0 };
172671
- const p22 = applyToPoint18(matrix2, { x: cad.position.x, y: cad.position.y });
172769
+ const p22 = applyToPoint21(matrix2, { x: cad.position.x, y: cad.position.y });
172672
172770
  cad.position.x = p22.x;
172673
172771
  cad.position.y = p22.y;
172674
172772
  const side = pcb_component2.layer ?? "top";