@tscircuit/schematic-viewer 2.0.77 → 2.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,200 +2,11 @@
2
2
  import {
3
3
  convertCircuitJsonToSchematicSvg
4
4
  } from "circuit-to-svg";
5
- import { su as su7 } from "@tscircuit/soup-util";
6
-
7
- // lib/hooks/useChangeSchematicComponentLocationsInSvg.ts
8
- import "@tscircuit/soup-util";
9
- import "transformation-matrix";
10
- import { useEffect, useRef } from "react";
11
-
12
- // lib/utils/get-component-offset-due-to-events.ts
13
- var getComponentOffsetDueToEvents = ({
14
- editEvents,
15
- schematic_component_id
16
- }) => {
17
- const editEventsForComponent = editEvents.filter(
18
- (event) => "schematic_component_id" in event && event.schematic_component_id === schematic_component_id
19
- ).filter(
20
- (event) => "edit_event_type" in event && event.edit_event_type === "edit_schematic_component_location"
21
- );
22
- const totalOffsetX = editEventsForComponent.reduce((acc, event) => {
23
- return acc + event.new_center.x - event.original_center.x;
24
- }, 0);
25
- const totalOffsetY = editEventsForComponent.reduce((acc, event) => {
26
- return acc + event.new_center.y - event.original_center.y;
27
- }, 0);
28
- return {
29
- x: totalOffsetX,
30
- y: totalOffsetY
31
- };
32
- };
33
-
34
- // lib/hooks/useChangeSchematicComponentLocationsInSvg.ts
35
- var useChangeSchematicComponentLocationsInSvg = ({
36
- svgDivRef,
37
- realToSvgProjection,
38
- svgToScreenProjection,
39
- activeEditEvent,
40
- editEvents
41
- }) => {
42
- const lastSvgContentRef = useRef(null);
43
- useEffect(() => {
44
- const svg = svgDivRef.current;
45
- if (!svg) return;
46
- const observer = new MutationObserver((mutations) => {
47
- const currentSvgContent = svg.innerHTML;
48
- if (currentSvgContent !== lastSvgContentRef.current) {
49
- lastSvgContentRef.current = currentSvgContent;
50
- applyTransforms();
51
- }
52
- });
53
- const applyTransforms = () => {
54
- const componentsThatHaveBeenMoved = /* @__PURE__ */ new Set();
55
- for (const event of editEvents) {
56
- if ("edit_event_type" in event && event.edit_event_type === "edit_schematic_component_location") {
57
- componentsThatHaveBeenMoved.add(event.schematic_component_id);
58
- }
59
- }
60
- if (activeEditEvent) {
61
- componentsThatHaveBeenMoved.add(activeEditEvent.schematic_component_id);
62
- }
63
- const allComponents = svg.querySelectorAll(
64
- '[data-circuit-json-type="schematic_component"]'
65
- );
66
- for (const component of Array.from(allComponents)) {
67
- const schematic_component_id = component.getAttribute(
68
- "data-schematic-component-id"
69
- );
70
- const offsetMm = getComponentOffsetDueToEvents({
71
- editEvents: [
72
- ...editEvents,
73
- ...activeEditEvent ? [activeEditEvent] : []
74
- ],
75
- schematic_component_id
76
- });
77
- const offsetPx = {
78
- x: offsetMm.x * realToSvgProjection.a,
79
- y: offsetMm.y * realToSvgProjection.d
80
- };
81
- const style = component.style;
82
- style.transform = `translate(${offsetPx.x}px, ${offsetPx.y}px)`;
83
- if (activeEditEvent?.schematic_component_id === schematic_component_id) {
84
- style.outline = "solid 2px rgba(255,0,0,0.5)";
85
- style.outlineOffset = "5px";
86
- } else if (style.outline) {
87
- style.outline = "";
88
- }
89
- }
90
- };
91
- observer.observe(svg, {
92
- childList: true,
93
- // Watch for changes to the child elements
94
- subtree: false,
95
- // Watch for changes in the entire subtree
96
- characterData: false
97
- // Watch for changes to text content
98
- });
99
- applyTransforms();
100
- return () => {
101
- observer.disconnect();
102
- };
103
- }, [svgDivRef, editEvents, activeEditEvent]);
104
- };
105
-
106
- // lib/hooks/useChangeSchematicTracesForMovedComponents.ts
107
- import { useEffect as useEffect2, useRef as useRef2 } from "react";
108
- import { su as su2 } from "@tscircuit/soup-util";
109
- var useChangeSchematicTracesForMovedComponents = ({
110
- svgDivRef,
111
- circuitJson,
112
- activeEditEvent,
113
- editEvents
114
- }) => {
115
- const lastSvgContentRef = useRef2(null);
116
- useEffect2(() => {
117
- const svg = svgDivRef.current;
118
- if (!svg) return;
119
- const updateTraceStyles = () => {
120
- const allTraces = svg.querySelectorAll(
121
- '[data-circuit-json-type="schematic_trace"] path'
122
- );
123
- for (const trace of Array.from(allTraces)) {
124
- trace.setAttribute("stroke-dasharray", "0");
125
- trace.style.animation = "";
126
- }
127
- for (const editEvent of [
128
- ...editEvents,
129
- ...activeEditEvent ? [activeEditEvent] : []
130
- ]) {
131
- if ("schematic_component_id" in editEvent && editEvent.edit_event_type === "edit_schematic_component_location") {
132
- const sch_component = su2(circuitJson).schematic_component.get(
133
- editEvent.schematic_component_id
134
- );
135
- if (!sch_component) return;
136
- const src_ports = su2(circuitJson).source_port.list({
137
- source_component_id: sch_component.source_component_id
138
- });
139
- const src_port_ids = new Set(src_ports.map((sp) => sp.source_port_id));
140
- const src_traces = su2(circuitJson).source_trace.list().filter(
141
- (st) => st.connected_source_port_ids?.some(
142
- (spi) => src_port_ids.has(spi)
143
- )
144
- );
145
- const src_trace_ids = new Set(
146
- src_traces.map((st) => st.source_trace_id)
147
- );
148
- const schematic_traces = su2(circuitJson).schematic_trace.list().filter((st) => src_trace_ids.has(st.source_trace_id));
149
- schematic_traces.forEach((trace) => {
150
- const traceElements = svg.querySelectorAll(
151
- `[data-schematic-trace-id="${trace.schematic_trace_id}"] path`
152
- );
153
- for (const traceElement of Array.from(traceElements)) {
154
- if (traceElement.getAttribute("class")?.includes("invisible"))
155
- continue;
156
- traceElement.setAttribute("stroke-dasharray", "20,20");
157
- traceElement.style.animation = "dash-animation 350ms linear infinite, pulse-animation 900ms linear infinite";
158
- if (!svg.querySelector("style#dash-animation")) {
159
- const style = document.createElement("style");
160
- style.id = "dash-animation";
161
- style.textContent = `
162
- @keyframes dash-animation {
163
- to {
164
- stroke-dashoffset: -40;
165
- }
166
- }
167
- @keyframes pulse-animation {
168
- 0% { opacity: 0.6; }
169
- 50% { opacity: 0.2; }
170
- 100% { opacity: 0.6; }
171
- }
172
- `;
173
- svg.appendChild(style);
174
- }
175
- }
176
- });
177
- }
178
- }
179
- };
180
- updateTraceStyles();
181
- const observer = new MutationObserver(updateTraceStyles);
182
- observer.observe(svg, {
183
- childList: true,
184
- // Watch for changes to the child elements
185
- subtree: false,
186
- // Watch for changes in the entire subtree
187
- characterData: false
188
- // Watch for changes to text content
189
- });
190
- return () => {
191
- observer.disconnect();
192
- };
193
- }, [svgDivRef, activeEditEvent, circuitJson, editEvents]);
194
- };
5
+ import { su as su4 } from "@tscircuit/soup-util";
195
6
 
196
7
  // lib/hooks/useSchematicGroupsOverlay.ts
197
- import { useEffect as useEffect3 } from "react";
198
- import { su as su3 } from "@tscircuit/soup-util";
8
+ import { useEffect } from "react";
9
+ import { su } from "@tscircuit/soup-util";
199
10
  var GROUP_COLORS = [
200
11
  "#8B0000",
201
12
  // Dark Red
@@ -220,7 +31,7 @@ var GROUP_COLORS = [
220
31
  ];
221
32
  var useSchematicGroupsOverlay = (options) => {
222
33
  const { svgDivRef, circuitJson, circuitJsonKey, showGroups } = options;
223
- useEffect3(() => {
34
+ useEffect(() => {
224
35
  if (svgDivRef.current) {
225
36
  const existingOverlays = svgDivRef.current.querySelectorAll(
226
37
  ".schematic-group-overlay"
@@ -239,8 +50,8 @@ var useSchematicGroupsOverlay = (options) => {
239
50
  const existingOverlays = svg.querySelectorAll(".schematic-group-overlay");
240
51
  existingOverlays.forEach((overlay) => overlay.remove());
241
52
  try {
242
- const sourceGroups = su3(circuitJson).source_group?.list().filter((x) => !!!x.is_subcircuit) || [];
243
- const schematicComponents = su3(circuitJson).schematic_component?.list() || [];
53
+ const sourceGroups = su(circuitJson).source_group?.list().filter((x) => !!!x.is_subcircuit) || [];
54
+ const schematicComponents = su(circuitJson).schematic_component?.list() || [];
244
55
  const sourceGroupHierarchy = /* @__PURE__ */ new Map();
245
56
  sourceGroups.forEach((group) => {
246
57
  const groupWithParent = group;
@@ -278,7 +89,7 @@ var useSchematicGroupsOverlay = (options) => {
278
89
  if (hasMeaningfulGroups) {
279
90
  const groupMap = /* @__PURE__ */ new Map();
280
91
  for (const comp of schematicComponents) {
281
- const sourceComp = su3(circuitJson).source_component.get(
92
+ const sourceComp = su(circuitJson).source_component.get(
282
93
  comp.source_component_id
283
94
  );
284
95
  if (sourceComp?.source_group_id) {
@@ -462,8 +273,8 @@ function calculateGroupBounds(components, svg) {
462
273
  }
463
274
 
464
275
  // lib/hooks/useSchematicNetHover.ts
465
- import { su as su4 } from "@tscircuit/soup-util";
466
- import { useEffect as useEffect4 } from "react";
276
+ import { su as su2 } from "@tscircuit/soup-util";
277
+ import { useEffect as useEffect2 } from "react";
467
278
  var FADED_CLASS = "sch-net-faded";
468
279
  var TRACE_SELECTOR = "g.trace[data-subcircuit-connectivity-map-key], g.trace-overlays[data-subcircuit-connectivity-map-key]";
469
280
  var NET_LABEL_SELECTOR = "[data-schematic-net-label-id]";
@@ -473,7 +284,7 @@ var useSchematicNetHover = ({
473
284
  circuitJsonKey,
474
285
  enabled
475
286
  }) => {
476
- useEffect4(() => {
287
+ useEffect2(() => {
477
288
  const svgDiv = svgDivRef.current;
478
289
  if (!enabled || !svgDiv) return;
479
290
  const { componentIdToKeys, netLabelIdToKey } = buildNetRegistry(circuitJson);
@@ -549,7 +360,7 @@ var useSchematicNetHover = ({
549
360
  }, [svgDivRef, circuitJsonKey, enabled]);
550
361
  };
551
362
  function buildNetRegistry(circuitJson) {
552
- const cju = su4(circuitJson);
363
+ const cju = su2(circuitJson);
553
364
  const srcCompToSchComp = /* @__PURE__ */ new Map();
554
365
  for (const c of cju.schematic_component.list()) {
555
366
  if (c.source_component_id) {
@@ -586,23 +397,18 @@ var debug = Debug("schematic-viewer");
586
397
  var enableDebug = () => {
587
398
  Debug.enable("schematic-viewer*");
588
399
  };
589
- var debug_default = debug;
590
400
 
591
401
  // lib/components/SchematicViewer.tsx
592
- import { useCallback as useCallback6, useEffect as useEffect11, useMemo as useMemo4, useRef as useRef8, useState as useState6 } from "react";
593
- import {
594
- fromString,
595
- identity,
596
- toString as transformToString
597
- } from "transformation-matrix";
402
+ import { useCallback as useCallback5, useEffect as useEffect8, useMemo as useMemo4, useRef as useRef5, useState as useState5 } from "react";
403
+ import { toString as transformToString } from "transformation-matrix";
598
404
  import { useMouseMatrixTransform } from "use-mouse-matrix-transform";
599
405
 
600
406
  // lib/hooks/use-resize-handling.ts
601
- import { useEffect as useEffect5, useState } from "react";
407
+ import { useEffect as useEffect3, useState } from "react";
602
408
  var useResizeHandling = (containerRef) => {
603
409
  const [containerWidth, setContainerWidth] = useState(0);
604
410
  const [containerHeight, setContainerHeight] = useState(0);
605
- useEffect5(() => {
411
+ useEffect3(() => {
606
412
  if (!containerRef.current) return;
607
413
  const updateDimensions = () => {
608
414
  const rect = containerRef.current?.getBoundingClientRect();
@@ -621,192 +427,13 @@ var useResizeHandling = (containerRef) => {
621
427
  return { containerWidth, containerHeight };
622
428
  };
623
429
 
624
- // lib/hooks/useComponentDragging.ts
625
- import { su as su5 } from "@tscircuit/soup-util";
626
- import { useCallback, useEffect as useEffect6, useRef as useRef3, useState as useState2 } from "react";
627
- import { compose as compose2 } from "transformation-matrix";
628
- var debug2 = debug_default.extend("useComponentDragging");
629
- var useComponentDragging = ({
630
- onEditEvent,
631
- editEvents = [],
632
- circuitJson,
633
- cancelDrag,
634
- svgToScreenProjection,
635
- realToSvgProjection,
636
- enabled = false,
637
- snapToGrid = false
638
- }) => {
639
- const [activeEditEvent, setActiveEditEvent] = useState2(null);
640
- const realToScreenProjection = compose2(
641
- realToSvgProjection,
642
- svgToScreenProjection
643
- );
644
- const dragStartPosRef = useRef3(null);
645
- const activeEditEventRef = useRef3(null);
646
- const componentPositionsRef = useRef3(
647
- /* @__PURE__ */ new Map()
648
- );
649
- useEffect6(() => {
650
- editEvents.forEach((event) => {
651
- if ("edit_event_type" in event && event.edit_event_type === "edit_schematic_component_location" && !event.in_progress) {
652
- componentPositionsRef.current.set(event.schematic_component_id, {
653
- ...event.new_center
654
- });
655
- }
656
- });
657
- }, [editEvents]);
658
- const startDrag = useCallback(
659
- (clientX, clientY, target) => {
660
- if (!enabled) return false;
661
- const componentGroup = target.closest(
662
- '[data-circuit-json-type="schematic_component"]'
663
- );
664
- if (!componentGroup) return false;
665
- const schematic_component_id = componentGroup.getAttribute(
666
- "data-schematic-component-id"
667
- );
668
- if (!schematic_component_id) return false;
669
- if (cancelDrag) cancelDrag();
670
- const schematic_component = su5(circuitJson).schematic_component.get(
671
- schematic_component_id
672
- );
673
- if (!schematic_component) return false;
674
- dragStartPosRef.current = { x: clientX, y: clientY };
675
- let current_position;
676
- const trackedPosition = componentPositionsRef.current.get(
677
- schematic_component_id
678
- );
679
- if (trackedPosition) {
680
- current_position = { ...trackedPosition };
681
- } else {
682
- const editEventOffset = getComponentOffsetDueToEvents({
683
- editEvents,
684
- schematic_component_id
685
- });
686
- current_position = {
687
- x: schematic_component.center.x + editEventOffset.x,
688
- y: schematic_component.center.y + editEventOffset.y
689
- };
690
- componentPositionsRef.current.set(schematic_component_id, {
691
- ...current_position
692
- });
693
- }
694
- const newEditEvent = {
695
- edit_event_id: Math.random().toString(36).substr(2, 9),
696
- edit_event_type: "edit_schematic_component_location",
697
- schematic_component_id,
698
- original_center: current_position,
699
- new_center: { ...current_position },
700
- in_progress: true,
701
- created_at: Date.now(),
702
- _element: componentGroup
703
- };
704
- activeEditEventRef.current = newEditEvent;
705
- setActiveEditEvent(newEditEvent);
706
- return true;
707
- },
708
- [cancelDrag, enabled, circuitJson, editEvents]
709
- );
710
- const handleMouseDown = useCallback(
711
- (e) => {
712
- startDrag(e.clientX, e.clientY, e.target);
713
- },
714
- [startDrag]
715
- );
716
- const handleTouchStart = useCallback(
717
- (e) => {
718
- if (e.touches.length !== 1) return;
719
- const touch = e.touches[0];
720
- if (startDrag(touch.clientX, touch.clientY, e.target)) {
721
- e.preventDefault();
722
- }
723
- },
724
- [startDrag]
725
- );
726
- const updateDragPosition = useCallback(
727
- (clientX, clientY) => {
728
- if (!activeEditEventRef.current || !dragStartPosRef.current) return;
729
- const screenDelta = {
730
- x: clientX - dragStartPosRef.current.x,
731
- y: clientY - dragStartPosRef.current.y
732
- };
733
- const mmDelta = {
734
- x: screenDelta.x / realToScreenProjection.a,
735
- y: screenDelta.y / realToScreenProjection.d
736
- };
737
- let newCenter = {
738
- x: activeEditEventRef.current.original_center.x + mmDelta.x,
739
- y: activeEditEventRef.current.original_center.y + mmDelta.y
740
- };
741
- if (snapToGrid) {
742
- const snap = (v) => Math.round(v * 10) / 10;
743
- newCenter = { x: snap(newCenter.x), y: snap(newCenter.y) };
744
- }
745
- const newEditEvent = {
746
- ...activeEditEventRef.current,
747
- new_center: newCenter
748
- };
749
- activeEditEventRef.current = newEditEvent;
750
- setActiveEditEvent(newEditEvent);
751
- },
752
- [realToScreenProjection, snapToGrid]
753
- );
754
- const handleMouseMove = useCallback(
755
- (e) => updateDragPosition(e.clientX, e.clientY),
756
- [updateDragPosition]
757
- );
758
- const handleTouchMove = useCallback(
759
- (e) => {
760
- if (e.touches.length !== 1 || !activeEditEventRef.current) return;
761
- e.preventDefault();
762
- const touch = e.touches[0];
763
- updateDragPosition(touch.clientX, touch.clientY);
764
- },
765
- [updateDragPosition]
766
- );
767
- const endDrag = useCallback(() => {
768
- if (!activeEditEventRef.current) return;
769
- const finalEvent = {
770
- ...activeEditEventRef.current,
771
- in_progress: false
772
- };
773
- componentPositionsRef.current.set(finalEvent.schematic_component_id, {
774
- ...finalEvent.new_center
775
- });
776
- debug2("endDrag calling onEditEvent with new edit event", {
777
- newEditEvent: finalEvent
778
- });
779
- if (onEditEvent) onEditEvent(finalEvent);
780
- activeEditEventRef.current = null;
781
- dragStartPosRef.current = null;
782
- setActiveEditEvent(null);
783
- }, [onEditEvent]);
784
- const handleMouseUp = useCallback(() => endDrag(), [endDrag]);
785
- const handleTouchEnd = useCallback(() => endDrag(), [endDrag]);
786
- useEffect6(() => {
787
- window.addEventListener("mousemove", handleMouseMove);
788
- window.addEventListener("mouseup", handleMouseUp);
789
- window.addEventListener("touchmove", handleTouchMove, { passive: false });
790
- window.addEventListener("touchend", handleTouchEnd);
791
- return () => {
792
- window.removeEventListener("mousemove", handleMouseMove);
793
- window.removeEventListener("mouseup", handleMouseUp);
794
- window.removeEventListener("touchmove", handleTouchMove);
795
- window.removeEventListener("touchend", handleTouchEnd);
796
- };
797
- }, [handleMouseMove, handleMouseUp, handleTouchMove, handleTouchEnd]);
798
- return {
799
- handleMouseDown,
800
- handleTouchStart,
801
- isDragging: !!activeEditEventRef.current,
802
- activeEditEvent
803
- };
804
- };
430
+ // lib/components/ViewMenu.tsx
431
+ import { useMemo } from "react";
432
+ import { su as su3 } from "@tscircuit/soup-util";
433
+ import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
805
434
 
806
435
  // lib/utils/z-index-map.ts
807
436
  var zIndexMap = {
808
- schematicEditIcon: 50,
809
- schematicGridIcon: 49,
810
437
  viewMenuIcon: 48,
811
438
  viewMenu: 55,
812
439
  viewMenuBackdrop: 54,
@@ -815,112 +442,10 @@ var zIndexMap = {
815
442
  schematicPortHoverOutline: 48
816
443
  };
817
444
 
818
- // lib/components/EditIcon.tsx
819
- import { jsx, jsxs } from "react/jsx-runtime";
820
- var EditIcon = ({
821
- onClick,
822
- active
823
- }) => {
824
- const handleInteraction = (e) => {
825
- e.preventDefault();
826
- onClick();
827
- };
828
- return /* @__PURE__ */ jsx(
829
- "div",
830
- {
831
- onClick: handleInteraction,
832
- onTouchEnd: handleInteraction,
833
- title: active ? "Disable edit mode" : "Enable edit mode",
834
- style: {
835
- position: "absolute",
836
- top: "16px",
837
- right: "64px",
838
- backgroundColor: active ? "#4CAF50" : "#fff",
839
- color: active ? "#fff" : "#000",
840
- padding: "8px",
841
- borderRadius: "4px",
842
- cursor: "pointer",
843
- boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
844
- display: "flex",
845
- alignItems: "center",
846
- gap: "4px",
847
- zIndex: zIndexMap.schematicEditIcon
848
- },
849
- children: /* @__PURE__ */ jsxs(
850
- "svg",
851
- {
852
- width: "16",
853
- height: "16",
854
- viewBox: "0 0 24 24",
855
- fill: "none",
856
- stroke: "currentColor",
857
- strokeWidth: "2",
858
- children: [
859
- /* @__PURE__ */ jsx("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }),
860
- /* @__PURE__ */ jsx("path", { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" })
861
- ]
862
- }
863
- )
864
- }
865
- );
866
- };
867
-
868
- // lib/components/GridIcon.tsx
869
- import { jsx as jsx2 } from "react/jsx-runtime";
870
- var GridIcon = ({
871
- onClick,
872
- active
873
- }) => {
874
- const handleInteraction = (e) => {
875
- e.preventDefault();
876
- onClick();
877
- };
878
- return /* @__PURE__ */ jsx2(
879
- "div",
880
- {
881
- onClick: handleInteraction,
882
- onTouchEnd: handleInteraction,
883
- title: active ? "Hide grid" : "Show grid",
884
- style: {
885
- position: "absolute",
886
- top: "56px",
887
- right: "64px",
888
- backgroundColor: active ? "#4CAF50" : "#fff",
889
- color: active ? "#fff" : "#000",
890
- padding: "8px",
891
- borderRadius: "4px",
892
- cursor: "pointer",
893
- boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
894
- display: "flex",
895
- alignItems: "center",
896
- gap: "4px",
897
- zIndex: zIndexMap.schematicGridIcon
898
- },
899
- children: /* @__PURE__ */ jsx2(
900
- "svg",
901
- {
902
- width: "16",
903
- height: "16",
904
- viewBox: "0 0 24 24",
905
- fill: "none",
906
- stroke: "currentColor",
907
- strokeWidth: "2",
908
- children: /* @__PURE__ */ jsx2("path", { d: "M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z" })
909
- }
910
- )
911
- }
912
- );
913
- };
914
-
915
- // lib/components/ViewMenu.tsx
916
- import { useMemo } from "react";
917
- import { su as su6 } from "@tscircuit/soup-util";
918
- import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
919
-
920
445
  // package.json
921
446
  var package_default = {
922
447
  name: "@tscircuit/schematic-viewer",
923
- version: "2.0.76",
448
+ version: "2.0.77",
924
449
  main: "dist/index.js",
925
450
  type: "module",
926
451
  scripts: {
@@ -966,12 +491,12 @@ var package_default = {
966
491
  };
967
492
 
968
493
  // lib/components/ViewMenuIcon.tsx
969
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
494
+ import { jsx, jsxs } from "react/jsx-runtime";
970
495
  var ViewMenuIcon = ({
971
496
  active = false,
972
497
  ...props
973
498
  }) => {
974
- return /* @__PURE__ */ jsx3(
499
+ return /* @__PURE__ */ jsx(
975
500
  "button",
976
501
  {
977
502
  type: "button",
@@ -994,7 +519,7 @@ var ViewMenuIcon = ({
994
519
  gap: "4px",
995
520
  zIndex: zIndexMap.viewMenuIcon
996
521
  },
997
- children: /* @__PURE__ */ jsxs2(
522
+ children: /* @__PURE__ */ jsxs(
998
523
  "svg",
999
524
  {
1000
525
  width: "16",
@@ -1004,9 +529,9 @@ var ViewMenuIcon = ({
1004
529
  stroke: "currentColor",
1005
530
  strokeWidth: "2",
1006
531
  children: [
1007
- /* @__PURE__ */ jsx3("circle", { cx: "12", cy: "12", r: "1" }),
1008
- /* @__PURE__ */ jsx3("circle", { cx: "12", cy: "5", r: "1" }),
1009
- /* @__PURE__ */ jsx3("circle", { cx: "12", cy: "19", r: "1" })
532
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "1" }),
533
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "5", r: "1" }),
534
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "19", r: "1" })
1010
535
  ]
1011
536
  }
1012
537
  )
@@ -1015,7 +540,7 @@ var ViewMenuIcon = ({
1015
540
  };
1016
541
 
1017
542
  // lib/components/ViewMenu.tsx
1018
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
543
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1019
544
  var FONT_FAMILY = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
1020
545
  var contentStyles = {
1021
546
  backgroundColor: "#ffffff",
@@ -1062,7 +587,7 @@ var HIGHLIGHT_CSS = `
1062
587
  .sv-vm-item:hover:not([data-disabled]) { background-color: #f1f3f5; }
1063
588
  .sv-vm-item[data-disabled] { opacity: 0.45; cursor: not-allowed; }
1064
589
  `;
1065
- var CheckIcon = () => /* @__PURE__ */ jsx4(
590
+ var CheckIcon = () => /* @__PURE__ */ jsx2(
1066
591
  "svg",
1067
592
  {
1068
593
  width: "14",
@@ -1074,7 +599,7 @@ var CheckIcon = () => /* @__PURE__ */ jsx4(
1074
599
  strokeLinecap: "round",
1075
600
  strokeLinejoin: "round",
1076
601
  "aria-hidden": "true",
1077
- children: /* @__PURE__ */ jsx4("path", { d: "M20 6 9 17l-5-5" })
602
+ children: /* @__PURE__ */ jsx2("path", { d: "M20 6 9 17l-5-5" })
1078
603
  }
1079
604
  );
1080
605
  var ViewMenu = ({
@@ -1090,13 +615,13 @@ var ViewMenu = ({
1090
615
  const hasGroups = useMemo(() => {
1091
616
  if (!circuitJson || circuitJson.length === 0) return false;
1092
617
  try {
1093
- const sourceGroups = su6(circuitJson).source_group?.list() || [];
618
+ const sourceGroups = su3(circuitJson).source_group?.list() || [];
1094
619
  if (sourceGroups.length > 0) return true;
1095
- const schematicComponents = su6(circuitJson).schematic_component?.list() || [];
620
+ const schematicComponents = su3(circuitJson).schematic_component?.list() || [];
1096
621
  if (schematicComponents.length > 1) {
1097
622
  const componentTypes = /* @__PURE__ */ new Set();
1098
623
  for (const comp of schematicComponents) {
1099
- const sourceComp = su6(circuitJson).source_component.get(
624
+ const sourceComp = su3(circuitJson).source_component.get(
1100
625
  comp.source_component_id
1101
626
  );
1102
627
  if (sourceComp?.ftype) {
@@ -1111,9 +636,9 @@ var ViewMenu = ({
1111
636
  return false;
1112
637
  }
1113
638
  }, [circuitJsonKey]);
1114
- return /* @__PURE__ */ jsxs3(DropdownMenu.Root, { open, onOpenChange, modal: false, children: [
1115
- /* @__PURE__ */ jsx4(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsx4(ViewMenuIcon, { active: open }) }),
1116
- /* @__PURE__ */ jsx4(DropdownMenu.Portal, { children: /* @__PURE__ */ jsxs3(
639
+ return /* @__PURE__ */ jsxs2(DropdownMenu.Root, { open, onOpenChange, modal: false, children: [
640
+ /* @__PURE__ */ jsx2(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsx2(ViewMenuIcon, { active: open }) }),
641
+ /* @__PURE__ */ jsx2(DropdownMenu.Portal, { children: /* @__PURE__ */ jsxs2(
1117
642
  DropdownMenu.Content,
1118
643
  {
1119
644
  style: contentStyles,
@@ -1122,8 +647,8 @@ var ViewMenu = ({
1122
647
  sideOffset: 8,
1123
648
  collisionPadding: 10,
1124
649
  children: [
1125
- /* @__PURE__ */ jsx4("style", { children: HIGHLIGHT_CSS }),
1126
- /* @__PURE__ */ jsxs3(
650
+ /* @__PURE__ */ jsx2("style", { children: HIGHLIGHT_CSS }),
651
+ /* @__PURE__ */ jsxs2(
1127
652
  DropdownMenu.Item,
1128
653
  {
1129
654
  className: "sv-vm-item",
@@ -1135,12 +660,12 @@ var ViewMenu = ({
1135
660
  if (hasGroups) onToggleGroups(!showGroups);
1136
661
  },
1137
662
  children: [
1138
- /* @__PURE__ */ jsx4("span", { style: iconSlotStyles, children: showGroups && /* @__PURE__ */ jsx4(CheckIcon, {}) }),
1139
- /* @__PURE__ */ jsx4("span", { children: "View Schematic Groups" })
663
+ /* @__PURE__ */ jsx2("span", { style: iconSlotStyles, children: showGroups && /* @__PURE__ */ jsx2(CheckIcon, {}) }),
664
+ /* @__PURE__ */ jsx2("span", { children: "View Schematic Groups" })
1140
665
  ]
1141
666
  }
1142
667
  ),
1143
- /* @__PURE__ */ jsxs3(
668
+ /* @__PURE__ */ jsxs2(
1144
669
  DropdownMenu.Item,
1145
670
  {
1146
671
  className: "sv-vm-item",
@@ -1148,13 +673,13 @@ var ViewMenu = ({
1148
673
  onSelect: (e) => e.preventDefault(),
1149
674
  onPointerUp: () => onToggleGrid(!showGrid),
1150
675
  children: [
1151
- /* @__PURE__ */ jsx4("span", { style: iconSlotStyles, children: showGrid && /* @__PURE__ */ jsx4(CheckIcon, {}) }),
1152
- /* @__PURE__ */ jsx4("span", { children: "Show Grid" })
676
+ /* @__PURE__ */ jsx2("span", { style: iconSlotStyles, children: showGrid && /* @__PURE__ */ jsx2(CheckIcon, {}) }),
677
+ /* @__PURE__ */ jsx2("span", { children: "Show Grid" })
1153
678
  ]
1154
679
  }
1155
680
  ),
1156
- /* @__PURE__ */ jsx4(DropdownMenu.Separator, { style: separatorStyles }),
1157
- /* @__PURE__ */ jsxs3(
681
+ /* @__PURE__ */ jsx2(DropdownMenu.Separator, { style: separatorStyles }),
682
+ /* @__PURE__ */ jsxs2(
1158
683
  "div",
1159
684
  {
1160
685
  style: {
@@ -1177,7 +702,7 @@ var ViewMenu = ({
1177
702
  };
1178
703
 
1179
704
  // lib/hooks/useLocalStorage.ts
1180
- import { useCallback as useCallback2 } from "react";
705
+ import { useCallback } from "react";
1181
706
  var STORAGE_KEYS = {
1182
707
  IS_SHOWING_SCHEMATIC_GROUPS: "schematic_viewer_show_groups",
1183
708
  SELECTED_SCHEMATIC_SHEET: "schematic_viewer_selected_sheet"
@@ -1217,13 +742,13 @@ var setStoredString = (key, value) => {
1217
742
  // lib/components/MouseTracker.tsx
1218
743
  import {
1219
744
  createContext,
1220
- useCallback as useCallback3,
745
+ useCallback as useCallback2,
1221
746
  useContext,
1222
- useEffect as useEffect7,
747
+ useEffect as useEffect4,
1223
748
  useMemo as useMemo2,
1224
- useRef as useRef4
749
+ useRef
1225
750
  } from "react";
1226
- import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
751
+ import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
1227
752
  var MouseTrackerContext = createContext(null);
1228
753
  var DRAG_THRESHOLD_PX = 5;
1229
754
  var boundsAreEqual = (a, b) => {
@@ -1234,24 +759,24 @@ var boundsAreEqual = (a, b) => {
1234
759
  var MouseTracker = ({ children }) => {
1235
760
  const existingContext = useContext(MouseTrackerContext);
1236
761
  if (existingContext) {
1237
- return /* @__PURE__ */ jsx5(Fragment, { children });
762
+ return /* @__PURE__ */ jsx3(Fragment, { children });
1238
763
  }
1239
- return /* @__PURE__ */ jsx5(MouseTrackerProvider, { children });
764
+ return /* @__PURE__ */ jsx3(MouseTrackerProvider, { children });
1240
765
  };
1241
766
  var MouseTrackerProvider = ({ children }) => {
1242
- const storeRef = useRef4({
767
+ const storeRef = useRef({
1243
768
  pointer: null,
1244
769
  boundingBoxes: /* @__PURE__ */ new Map(),
1245
770
  hoveringIds: /* @__PURE__ */ new Set(),
1246
771
  subscribers: /* @__PURE__ */ new Set(),
1247
772
  mouseDownPosition: null
1248
773
  });
1249
- const notifySubscribers = useCallback3(() => {
774
+ const notifySubscribers = useCallback2(() => {
1250
775
  for (const callback of storeRef.current.subscribers) {
1251
776
  callback();
1252
777
  }
1253
778
  }, []);
1254
- const updateHovering = useCallback3(() => {
779
+ const updateHovering = useCallback2(() => {
1255
780
  const pointer = storeRef.current.pointer;
1256
781
  const newHovering = /* @__PURE__ */ new Set();
1257
782
  if (pointer) {
@@ -1270,14 +795,14 @@ var MouseTrackerProvider = ({ children }) => {
1270
795
  storeRef.current.hoveringIds = newHovering;
1271
796
  notifySubscribers();
1272
797
  }, [notifySubscribers]);
1273
- const registerBoundingBox = useCallback3(
798
+ const registerBoundingBox = useCallback2(
1274
799
  (id, registration) => {
1275
800
  storeRef.current.boundingBoxes.set(id, registration);
1276
801
  updateHovering();
1277
802
  },
1278
803
  [updateHovering]
1279
804
  );
1280
- const updateBoundingBox = useCallback3(
805
+ const updateBoundingBox = useCallback2(
1281
806
  (id, registration) => {
1282
807
  const existing = storeRef.current.boundingBoxes.get(id);
1283
808
  if (existing && boundsAreEqual(existing.bounds, registration.bounds) && existing.onClick === registration.onClick) {
@@ -1288,7 +813,7 @@ var MouseTrackerProvider = ({ children }) => {
1288
813
  },
1289
814
  [updateHovering]
1290
815
  );
1291
- const unregisterBoundingBox = useCallback3(
816
+ const unregisterBoundingBox = useCallback2(
1292
817
  (id) => {
1293
818
  const removed = storeRef.current.boundingBoxes.delete(id);
1294
819
  if (removed) {
@@ -1297,16 +822,16 @@ var MouseTrackerProvider = ({ children }) => {
1297
822
  },
1298
823
  [updateHovering]
1299
824
  );
1300
- const subscribe = useCallback3((listener) => {
825
+ const subscribe = useCallback2((listener) => {
1301
826
  storeRef.current.subscribers.add(listener);
1302
827
  return () => {
1303
828
  storeRef.current.subscribers.delete(listener);
1304
829
  };
1305
830
  }, []);
1306
- const isHovering = useCallback3((id) => {
831
+ const isHovering = useCallback2((id) => {
1307
832
  return storeRef.current.hoveringIds.has(id);
1308
833
  }, []);
1309
- useEffect7(() => {
834
+ useEffect4(() => {
1310
835
  const handlePointerPosition = (event) => {
1311
836
  const { clientX, clientY } = event;
1312
837
  const pointer = storeRef.current.pointer;
@@ -1390,19 +915,19 @@ var MouseTrackerProvider = ({ children }) => {
1390
915
  isHovering
1391
916
  ]
1392
917
  );
1393
- return /* @__PURE__ */ jsx5(MouseTrackerContext.Provider, { value, children });
918
+ return /* @__PURE__ */ jsx3(MouseTrackerContext.Provider, { value, children });
1394
919
  };
1395
920
 
1396
921
  // lib/components/SchematicComponentMouseTarget.tsx
1397
- import { useCallback as useCallback4, useEffect as useEffect9, useRef as useRef6, useState as useState3 } from "react";
922
+ import { useCallback as useCallback3, useEffect as useEffect6, useRef as useRef3, useState as useState2 } from "react";
1398
923
 
1399
924
  // lib/hooks/useMouseEventsOverBoundingBox.ts
1400
925
  import {
1401
926
  useContext as useContext2,
1402
- useEffect as useEffect8,
927
+ useEffect as useEffect5,
1403
928
  useId,
1404
929
  useMemo as useMemo3,
1405
- useRef as useRef5,
930
+ useRef as useRef2,
1406
931
  useSyncExternalStore
1407
932
  } from "react";
1408
933
  var useMouseEventsOverBoundingBox = (options) => {
@@ -1413,7 +938,7 @@ var useMouseEventsOverBoundingBox = (options) => {
1413
938
  );
1414
939
  }
1415
940
  const id = useId();
1416
- const latestOptionsRef = useRef5(options);
941
+ const latestOptionsRef = useRef2(options);
1417
942
  latestOptionsRef.current = options;
1418
943
  const handleClick = useMemo3(
1419
944
  () => (event) => {
@@ -1421,7 +946,7 @@ var useMouseEventsOverBoundingBox = (options) => {
1421
946
  },
1422
947
  []
1423
948
  );
1424
- useEffect8(() => {
949
+ useEffect5(() => {
1425
950
  context.registerBoundingBox(id, {
1426
951
  bounds: latestOptionsRef.current.bounds,
1427
952
  onClick: latestOptionsRef.current.onClick ? handleClick : void 0
@@ -1430,7 +955,7 @@ var useMouseEventsOverBoundingBox = (options) => {
1430
955
  context.unregisterBoundingBox(id);
1431
956
  };
1432
957
  }, [context, handleClick, id]);
1433
- useEffect8(() => {
958
+ useEffect5(() => {
1434
959
  context.updateBoundingBox(id, {
1435
960
  bounds: latestOptionsRef.current.bounds,
1436
961
  onClick: latestOptionsRef.current.onClick ? handleClick : void 0
@@ -1454,7 +979,7 @@ var useMouseEventsOverBoundingBox = (options) => {
1454
979
  };
1455
980
 
1456
981
  // lib/components/SchematicComponentMouseTarget.tsx
1457
- import { jsx as jsx6 } from "react/jsx-runtime";
982
+ import { jsx as jsx4 } from "react/jsx-runtime";
1458
983
  var areMeasurementsEqual = (a, b) => {
1459
984
  if (!a && !b) return true;
1460
985
  if (!a || !b) return false;
@@ -1469,9 +994,9 @@ var SchematicComponentMouseTarget = ({
1469
994
  showOutline,
1470
995
  circuitJsonKey
1471
996
  }) => {
1472
- const [measurement, setMeasurement] = useState3(null);
1473
- const frameRef = useRef6(null);
1474
- const measure = useCallback4(() => {
997
+ const [measurement, setMeasurement] = useState2(null);
998
+ const frameRef = useRef3(null);
999
+ const measure = useCallback3(() => {
1475
1000
  frameRef.current = null;
1476
1001
  const svgDiv = svgDivRef.current;
1477
1002
  const container = containerRef.current;
@@ -1506,14 +1031,14 @@ var SchematicComponentMouseTarget = ({
1506
1031
  (prev) => areMeasurementsEqual(prev, nextMeasurement) ? prev : nextMeasurement
1507
1032
  );
1508
1033
  }, [componentId, containerRef, svgDivRef]);
1509
- const scheduleMeasure = useCallback4(() => {
1034
+ const scheduleMeasure = useCallback3(() => {
1510
1035
  if (frameRef.current !== null) return;
1511
1036
  frameRef.current = window.requestAnimationFrame(measure);
1512
1037
  }, [measure]);
1513
- useEffect9(() => {
1038
+ useEffect6(() => {
1514
1039
  scheduleMeasure();
1515
1040
  }, [scheduleMeasure, circuitJsonKey]);
1516
- useEffect9(() => {
1041
+ useEffect6(() => {
1517
1042
  scheduleMeasure();
1518
1043
  const svgDiv = svgDivRef.current;
1519
1044
  const container = containerRef.current;
@@ -1545,7 +1070,7 @@ var SchematicComponentMouseTarget = ({
1545
1070
  }
1546
1071
  };
1547
1072
  }, [scheduleMeasure, svgDivRef, containerRef]);
1548
- const handleClick = useCallback4(
1073
+ const handleClick = useCallback3(
1549
1074
  (event) => {
1550
1075
  if (onComponentClick) {
1551
1076
  onComponentClick(componentId, event);
@@ -1558,7 +1083,7 @@ var SchematicComponentMouseTarget = ({
1558
1083
  bounds,
1559
1084
  onClick: onComponentClick ? handleClick : void 0
1560
1085
  });
1561
- useEffect9(() => {
1086
+ useEffect6(() => {
1562
1087
  if (onHoverChange) {
1563
1088
  onHoverChange(componentId, hovering);
1564
1089
  }
@@ -1567,7 +1092,7 @@ var SchematicComponentMouseTarget = ({
1567
1092
  return null;
1568
1093
  }
1569
1094
  const rect = measurement.rect;
1570
- return /* @__PURE__ */ jsx6(
1095
+ return /* @__PURE__ */ jsx4(
1571
1096
  "div",
1572
1097
  {
1573
1098
  style: {
@@ -1585,8 +1110,8 @@ var SchematicComponentMouseTarget = ({
1585
1110
  };
1586
1111
 
1587
1112
  // lib/components/SchematicPortMouseTarget.tsx
1588
- import { useCallback as useCallback5, useEffect as useEffect10, useRef as useRef7, useState as useState4 } from "react";
1589
- import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1113
+ import { useCallback as useCallback4, useEffect as useEffect7, useRef as useRef4, useState as useState3 } from "react";
1114
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1590
1115
  var areMeasurementsEqual2 = (a, b) => {
1591
1116
  if (!a && !b) return true;
1592
1117
  if (!a || !b) return false;
@@ -1602,9 +1127,9 @@ var SchematicPortMouseTarget = ({
1602
1127
  showOutline,
1603
1128
  circuitJsonKey
1604
1129
  }) => {
1605
- const [measurement, setMeasurement] = useState4(null);
1606
- const frameRef = useRef7(null);
1607
- const measure = useCallback5(() => {
1130
+ const [measurement, setMeasurement] = useState3(null);
1131
+ const frameRef = useRef4(null);
1132
+ const measure = useCallback4(() => {
1608
1133
  frameRef.current = null;
1609
1134
  const svgDiv = svgDivRef.current;
1610
1135
  const container = containerRef.current;
@@ -1640,14 +1165,14 @@ var SchematicPortMouseTarget = ({
1640
1165
  (prev) => areMeasurementsEqual2(prev, nextMeasurement) ? prev : nextMeasurement
1641
1166
  );
1642
1167
  }, [portId, containerRef, svgDivRef]);
1643
- const scheduleMeasure = useCallback5(() => {
1168
+ const scheduleMeasure = useCallback4(() => {
1644
1169
  if (frameRef.current !== null) return;
1645
1170
  frameRef.current = window.requestAnimationFrame(measure);
1646
1171
  }, [measure]);
1647
- useEffect10(() => {
1172
+ useEffect7(() => {
1648
1173
  scheduleMeasure();
1649
1174
  }, [scheduleMeasure, circuitJsonKey]);
1650
- useEffect10(() => {
1175
+ useEffect7(() => {
1651
1176
  scheduleMeasure();
1652
1177
  const svgDiv = svgDivRef.current;
1653
1178
  const container = containerRef.current;
@@ -1679,7 +1204,7 @@ var SchematicPortMouseTarget = ({
1679
1204
  }
1680
1205
  };
1681
1206
  }, [scheduleMeasure, svgDivRef, containerRef]);
1682
- const handleClick = useCallback5(
1207
+ const handleClick = useCallback4(
1683
1208
  (event) => {
1684
1209
  if (onPortClick) {
1685
1210
  onPortClick(portId, event);
@@ -1692,7 +1217,7 @@ var SchematicPortMouseTarget = ({
1692
1217
  bounds,
1693
1218
  onClick: onPortClick ? handleClick : void 0
1694
1219
  });
1695
- useEffect10(() => {
1220
+ useEffect7(() => {
1696
1221
  if (onHoverChange) {
1697
1222
  onHoverChange(portId, hovering);
1698
1223
  }
@@ -1701,8 +1226,8 @@ var SchematicPortMouseTarget = ({
1701
1226
  return null;
1702
1227
  }
1703
1228
  const rect = measurement.rect;
1704
- return /* @__PURE__ */ jsxs4(Fragment2, { children: [
1705
- /* @__PURE__ */ jsx7(
1229
+ return /* @__PURE__ */ jsxs3(Fragment2, { children: [
1230
+ /* @__PURE__ */ jsx5(
1706
1231
  "div",
1707
1232
  {
1708
1233
  style: {
@@ -1720,7 +1245,7 @@ var SchematicPortMouseTarget = ({
1720
1245
  }
1721
1246
  }
1722
1247
  ),
1723
- hovering && portLabel && /* @__PURE__ */ jsx7(
1248
+ hovering && portLabel && /* @__PURE__ */ jsx5(
1724
1249
  "div",
1725
1250
  {
1726
1251
  style: {
@@ -1745,9 +1270,9 @@ var SchematicPortMouseTarget = ({
1745
1270
  };
1746
1271
 
1747
1272
  // lib/components/SchematicSheetSelector.tsx
1748
- import { useState as useState5 } from "react";
1273
+ import { useState as useState4 } from "react";
1749
1274
  import * as DropdownMenu2 from "@radix-ui/react-dropdown-menu";
1750
- import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1275
+ import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
1751
1276
  var FONT_FAMILY2 = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
1752
1277
  var contentStyles2 = {
1753
1278
  backgroundColor: "#ffffff",
@@ -1797,7 +1322,7 @@ var MENU_CSS = `
1797
1322
  .sv-sheet-chevron { transition: transform 0.2s ease; }
1798
1323
  [data-state="open"] > .sv-sheet-chevron { transform: rotate(180deg); }
1799
1324
  `;
1800
- var CheckIcon2 = () => /* @__PURE__ */ jsx8(
1325
+ var CheckIcon2 = () => /* @__PURE__ */ jsx6(
1801
1326
  "svg",
1802
1327
  {
1803
1328
  width: "14",
@@ -1809,10 +1334,10 @@ var CheckIcon2 = () => /* @__PURE__ */ jsx8(
1809
1334
  strokeLinecap: "round",
1810
1335
  strokeLinejoin: "round",
1811
1336
  "aria-hidden": "true",
1812
- children: /* @__PURE__ */ jsx8("path", { d: "M20 6 9 17l-5-5" })
1337
+ children: /* @__PURE__ */ jsx6("path", { d: "M20 6 9 17l-5-5" })
1813
1338
  }
1814
1339
  );
1815
- var ChevronDownIcon = ({ className }) => /* @__PURE__ */ jsx8(
1340
+ var ChevronDownIcon = ({ className }) => /* @__PURE__ */ jsx6(
1816
1341
  "svg",
1817
1342
  {
1818
1343
  className,
@@ -1826,7 +1351,7 @@ var ChevronDownIcon = ({ className }) => /* @__PURE__ */ jsx8(
1826
1351
  strokeLinejoin: "round",
1827
1352
  style: { opacity: 0.6, flexShrink: 0 },
1828
1353
  "aria-hidden": "true",
1829
- children: /* @__PURE__ */ jsx8("path", { d: "m6 9 6 6 6-6" })
1354
+ children: /* @__PURE__ */ jsx6("path", { d: "m6 9 6 6 6-6" })
1830
1355
  }
1831
1356
  );
1832
1357
  var SchematicSheetSelector = ({
@@ -1834,16 +1359,16 @@ var SchematicSheetSelector = ({
1834
1359
  selectedSheetId,
1835
1360
  onSelectSheet
1836
1361
  }) => {
1837
- const [open, setOpen] = useState5(false);
1362
+ const [open, setOpen] = useState4(false);
1838
1363
  if (sheets.length <= 1) return null;
1839
1364
  const selectedSheet = sheets.find(
1840
1365
  (s) => s.schematic_sheet_id === selectedSheetId
1841
1366
  );
1842
1367
  const selectedLabel = selectedSheet?.name ?? "Select sheet";
1843
- return /* @__PURE__ */ jsxs5(Fragment3, { children: [
1844
- /* @__PURE__ */ jsx8("style", { children: MENU_CSS }),
1845
- /* @__PURE__ */ jsxs5(DropdownMenu2.Root, { open, onOpenChange: setOpen, modal: false, children: [
1846
- /* @__PURE__ */ jsx8(DropdownMenu2.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs5(
1368
+ return /* @__PURE__ */ jsxs4(Fragment3, { children: [
1369
+ /* @__PURE__ */ jsx6("style", { children: MENU_CSS }),
1370
+ /* @__PURE__ */ jsxs4(DropdownMenu2.Root, { open, onOpenChange: setOpen, modal: false, children: [
1371
+ /* @__PURE__ */ jsx6(DropdownMenu2.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs4(
1847
1372
  "button",
1848
1373
  {
1849
1374
  type: "button",
@@ -1870,13 +1395,13 @@ var SchematicSheetSelector = ({
1870
1395
  zIndex: zIndexMap.viewMenuIcon
1871
1396
  },
1872
1397
  children: [
1873
- /* @__PURE__ */ jsx8("span", { style: { color: "#888888", flexShrink: 0 }, children: "Sheet:" }),
1874
- /* @__PURE__ */ jsx8("span", { style: { ...ellipsisStyles, minWidth: 0 }, children: selectedLabel }),
1875
- /* @__PURE__ */ jsx8(ChevronDownIcon, { className: "sv-sheet-chevron" })
1398
+ /* @__PURE__ */ jsx6("span", { style: { color: "#888888", flexShrink: 0 }, children: "Sheet:" }),
1399
+ /* @__PURE__ */ jsx6("span", { style: { ...ellipsisStyles, minWidth: 0 }, children: selectedLabel }),
1400
+ /* @__PURE__ */ jsx6(ChevronDownIcon, { className: "sv-sheet-chevron" })
1876
1401
  ]
1877
1402
  }
1878
1403
  ) }),
1879
- /* @__PURE__ */ jsx8(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsx8(
1404
+ /* @__PURE__ */ jsx6(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsx6(
1880
1405
  DropdownMenu2.Content,
1881
1406
  {
1882
1407
  style: contentStyles2,
@@ -1886,7 +1411,7 @@ var SchematicSheetSelector = ({
1886
1411
  collisionPadding: 10,
1887
1412
  children: sheets.map((sheet) => {
1888
1413
  const selected = sheet.schematic_sheet_id === selectedSheetId;
1889
- return /* @__PURE__ */ jsxs5(
1414
+ return /* @__PURE__ */ jsxs4(
1890
1415
  DropdownMenu2.Item,
1891
1416
  {
1892
1417
  className: "sv-sheet-item",
@@ -1898,8 +1423,8 @@ var SchematicSheetSelector = ({
1898
1423
  setOpen(false);
1899
1424
  },
1900
1425
  children: [
1901
- /* @__PURE__ */ jsx8("span", { style: iconSlotStyles2, children: selected && /* @__PURE__ */ jsx8(CheckIcon2, {}) }),
1902
- /* @__PURE__ */ jsx8("span", { style: { ...ellipsisStyles, minWidth: 0 }, children: sheet.name })
1426
+ /* @__PURE__ */ jsx6("span", { style: iconSlotStyles2, children: selected && /* @__PURE__ */ jsx6(CheckIcon2, {}) }),
1427
+ /* @__PURE__ */ jsx6("span", { style: { ...ellipsisStyles, minWidth: 0 }, children: sheet.name })
1903
1428
  ]
1904
1429
  },
1905
1430
  sheet.schematic_sheet_id
@@ -1912,16 +1437,12 @@ var SchematicSheetSelector = ({
1912
1437
  };
1913
1438
 
1914
1439
  // lib/components/SchematicViewer.tsx
1915
- import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1440
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1916
1441
  var SchematicViewer = ({
1917
1442
  circuitJson,
1918
1443
  containerStyle,
1919
- editEvents: unappliedEditEvents = [],
1920
- onEditEvent,
1921
- defaultEditMode = false,
1922
1444
  debugGrid = false,
1923
- editingEnabled = false,
1924
- debug: debug3 = false,
1445
+ debug: debug2 = false,
1925
1446
  clickToInteractEnabled = false,
1926
1447
  colorOverrides,
1927
1448
  disableGroups = false,
@@ -1933,7 +1454,7 @@ var SchematicViewer = ({
1933
1454
  css,
1934
1455
  className
1935
1456
  }) => {
1936
- if (debug3) {
1457
+ if (debug2) {
1937
1458
  enableDebug();
1938
1459
  }
1939
1460
  const getCircuitHash = (circuitJson2) => {
@@ -1953,7 +1474,7 @@ var SchematicViewer = ({
1953
1474
  }, [circuitJsonKey]);
1954
1475
  const hasMultipleSheets = schematicSheets.length > 1;
1955
1476
  const defaultSheetId = schematicSheets[0]?.schematic_sheet_id;
1956
- const [selectedSheetId, setSelectedSheetId] = useState6(
1477
+ const [selectedSheetId, setSelectedSheetId] = useState5(
1957
1478
  () => {
1958
1479
  const stored = getStoredString(STORAGE_KEYS.SELECTED_SCHEMATIC_SHEET);
1959
1480
  if (stored && schematicSheets.some((s) => s.schematic_sheet_id === stored)) {
@@ -1962,14 +1483,14 @@ var SchematicViewer = ({
1962
1483
  return defaultSheetId;
1963
1484
  }
1964
1485
  );
1965
- useEffect11(() => {
1486
+ useEffect8(() => {
1966
1487
  const stillExists = selectedSheetId !== void 0 && schematicSheets.some((s) => s.schematic_sheet_id === selectedSheetId);
1967
1488
  if (!stillExists) {
1968
1489
  setSelectedSheetId(defaultSheetId);
1969
1490
  }
1970
1491
  }, [circuitJsonKey]);
1971
1492
  const activeSheetId = hasMultipleSheets ? selectedSheetId ?? defaultSheetId : void 0;
1972
- const handleSelectSheet = useCallback6(
1493
+ const handleSelectSheet = useCallback5(
1973
1494
  (sheetId) => {
1974
1495
  setSelectedSheetId(sheetId);
1975
1496
  setStoredString(STORAGE_KEYS.SELECTED_SCHEMATIC_SHEET, sheetId);
@@ -1977,21 +1498,19 @@ var SchematicViewer = ({
1977
1498
  },
1978
1499
  [onSchematicSheetChange]
1979
1500
  );
1980
- const [editModeEnabled, setEditModeEnabled] = useState6(defaultEditMode);
1981
- const [snapToGrid, setSnapToGrid] = useState6(true);
1982
- const [showGridInternal, setShowGridInternal] = useState6(false);
1501
+ const [showGridInternal, setShowGridInternal] = useState5(false);
1983
1502
  const showGrid = debugGrid || showGridInternal;
1984
- const [isInteractionEnabled, setIsInteractionEnabled] = useState6(
1503
+ const [isInteractionEnabled, setIsInteractionEnabled] = useState5(
1985
1504
  !clickToInteractEnabled
1986
1505
  );
1987
- const [showViewMenu, setShowViewMenu] = useState6(false);
1988
- const [showSchematicGroups, setShowSchematicGroups] = useState6(() => {
1506
+ const [showViewMenu, setShowViewMenu] = useState5(false);
1507
+ const [showSchematicGroups, setShowSchematicGroups] = useState5(() => {
1989
1508
  if (disableGroups) return false;
1990
1509
  return getStoredBoolean("schematic_viewer_show_groups", false);
1991
1510
  });
1992
- const [isHoveringClickableComponent, setIsHoveringClickableComponent] = useState6(false);
1993
- const hoveringComponentsRef = useRef8(/* @__PURE__ */ new Set());
1994
- const handleComponentHoverChange = useCallback6(
1511
+ const [isHoveringClickableComponent, setIsHoveringClickableComponent] = useState5(false);
1512
+ const hoveringComponentsRef = useRef5(/* @__PURE__ */ new Set());
1513
+ const handleComponentHoverChange = useCallback5(
1995
1514
  (componentId, isHovering) => {
1996
1515
  if (isHovering) {
1997
1516
  hoveringComponentsRef.current.add(componentId);
@@ -2002,9 +1521,9 @@ var SchematicViewer = ({
2002
1521
  },
2003
1522
  []
2004
1523
  );
2005
- const [isHoveringClickablePort, setIsHoveringClickablePort] = useState6(false);
2006
- const hoveringPortsRef = useRef8(/* @__PURE__ */ new Set());
2007
- const handlePortHoverChange = useCallback6(
1524
+ const [isHoveringClickablePort, setIsHoveringClickablePort] = useState5(false);
1525
+ const hoveringPortsRef = useRef5(/* @__PURE__ */ new Set());
1526
+ const handlePortHoverChange = useCallback5(
2008
1527
  (portId, isHovering) => {
2009
1528
  if (isHovering) {
2010
1529
  hoveringPortsRef.current.add(portId);
@@ -2015,11 +1534,11 @@ var SchematicViewer = ({
2015
1534
  },
2016
1535
  []
2017
1536
  );
2018
- const svgDivRef = useRef8(null);
2019
- const touchStartRef = useRef8(null);
1537
+ const svgDivRef = useRef5(null);
1538
+ const touchStartRef = useRef5(null);
2020
1539
  const schematicComponentIds = useMemo4(() => {
2021
1540
  try {
2022
- const components = su7(circuitJson).schematic_component?.list() ?? [];
1541
+ const components = su4(circuitJson).schematic_component?.list() ?? [];
2023
1542
  return components.filter(
2024
1543
  (component) => !activeSheetId || component.schematic_sheet_id === activeSheetId
2025
1544
  ).map((component) => component.schematic_component_id);
@@ -2031,12 +1550,12 @@ var SchematicViewer = ({
2031
1550
  const schematicPortsInfo = useMemo4(() => {
2032
1551
  if (!showSchematicPorts) return [];
2033
1552
  try {
2034
- const ports = (su7(circuitJson).schematic_port?.list() ?? []).filter(
1553
+ const ports = (su4(circuitJson).schematic_port?.list() ?? []).filter(
2035
1554
  (port) => !activeSheetId || port.schematic_sheet_id === activeSheetId
2036
1555
  );
2037
1556
  return ports.map((port) => {
2038
- const sourcePort = su7(circuitJson).source_port.get(port.source_port_id);
2039
- const sourceComponent = sourcePort?.source_component_id ? su7(circuitJson).source_component.get(sourcePort.source_component_id) : null;
1557
+ const sourcePort = su4(circuitJson).source_port.get(port.source_port_id);
1558
+ const sourceComponent = sourcePort?.source_component_id ? su4(circuitJson).source_component.get(sourcePort.source_component_id) : null;
2040
1559
  const componentName = sourceComponent?.name ?? "?";
2041
1560
  const pinLabel = port.display_pin_label ?? sourcePort?.pin_number ?? sourcePort?.name ?? "?";
2042
1561
  return {
@@ -2068,21 +1587,7 @@ var SchematicViewer = ({
2068
1587
  }
2069
1588
  touchStartRef.current = null;
2070
1589
  };
2071
- const [internalEditEvents, setInternalEditEvents] = useState6([]);
2072
- const circuitJsonRef = useRef8(circuitJson);
2073
- useEffect11(() => {
2074
- const circuitHash = getCircuitHash(circuitJson);
2075
- const circuitHashRef = getCircuitHash(circuitJsonRef.current);
2076
- if (circuitHash !== circuitHashRef) {
2077
- setInternalEditEvents([]);
2078
- circuitJsonRef.current = circuitJson;
2079
- }
2080
- }, [circuitJson]);
2081
- const {
2082
- ref: containerRef,
2083
- cancelDrag,
2084
- transform: svgToScreenProjection
2085
- } = useMouseMatrixTransform({
1590
+ const { ref: containerRef } = useMouseMatrixTransform({
2086
1591
  onSetTransform(transform) {
2087
1592
  if (!svgDivRef.current) return;
2088
1593
  svgDivRef.current.style.transform = transformToString(transform);
@@ -2120,55 +1625,6 @@ var SchematicViewer = ({
2120
1625
  );
2121
1626
  return match?.[1] ?? "transparent";
2122
1627
  }, [svgString]);
2123
- const realToSvgProjection = useMemo4(() => {
2124
- if (!svgString) return identity();
2125
- const transformString = svgString.match(
2126
- /data-real-to-screen-transform="([^"]+)"/
2127
- )?.[1];
2128
- try {
2129
- return fromString(transformString);
2130
- } catch (e) {
2131
- console.error(e);
2132
- return identity();
2133
- }
2134
- }, [svgString]);
2135
- const handleEditEvent = (event) => {
2136
- setInternalEditEvents((prev) => [...prev, event]);
2137
- if (onEditEvent) {
2138
- onEditEvent(event);
2139
- }
2140
- };
2141
- const editEventsWithUnappliedEditEvents = useMemo4(() => {
2142
- return [...unappliedEditEvents, ...internalEditEvents];
2143
- }, [unappliedEditEvents, internalEditEvents]);
2144
- const {
2145
- handleMouseDown,
2146
- handleTouchStart: handleComponentTouchStart,
2147
- isDragging,
2148
- activeEditEvent
2149
- } = useComponentDragging({
2150
- onEditEvent: handleEditEvent,
2151
- cancelDrag,
2152
- realToSvgProjection,
2153
- svgToScreenProjection,
2154
- circuitJson,
2155
- editEvents: editEventsWithUnappliedEditEvents,
2156
- enabled: editModeEnabled && isInteractionEnabled,
2157
- snapToGrid
2158
- });
2159
- useChangeSchematicComponentLocationsInSvg({
2160
- svgDivRef,
2161
- editEvents: editEventsWithUnappliedEditEvents,
2162
- realToSvgProjection,
2163
- svgToScreenProjection,
2164
- activeEditEvent
2165
- });
2166
- useChangeSchematicTracesForMovedComponents({
2167
- svgDivRef,
2168
- circuitJson,
2169
- activeEditEvent,
2170
- editEvents: editEventsWithUnappliedEditEvents
2171
- });
2172
1628
  useSchematicGroupsOverlay({
2173
1629
  svgDivRef,
2174
1630
  circuitJson,
@@ -2181,12 +1637,8 @@ var SchematicViewer = ({
2181
1637
  circuitJsonKey: `${circuitJsonKey}_${activeSheetId ?? ""}`,
2182
1638
  enabled: netHoverHighlightEnabled
2183
1639
  });
2184
- const handleComponentTouchStartRef = useRef8(handleComponentTouchStart);
2185
- useEffect11(() => {
2186
- handleComponentTouchStartRef.current = handleComponentTouchStart;
2187
- }, [handleComponentTouchStart]);
2188
1640
  const svgDiv = useMemo4(
2189
- () => /* @__PURE__ */ jsx9(
1641
+ () => /* @__PURE__ */ jsx7(
2190
1642
  "div",
2191
1643
  {
2192
1644
  ref: svgDivRef,
@@ -2195,22 +1647,17 @@ var SchematicViewer = ({
2195
1647
  transformOrigin: "0 0"
2196
1648
  },
2197
1649
  className: onSchematicComponentClicked ? "schematic-component-clickable" : void 0,
2198
- onTouchStart: (e) => {
2199
- if (editModeEnabled && isInteractionEnabled) {
2200
- handleComponentTouchStartRef.current(e);
2201
- }
2202
- },
2203
1650
  dangerouslySetInnerHTML: { __html: svgString }
2204
1651
  }
2205
1652
  ),
2206
- [svgString, isInteractionEnabled, clickToInteractEnabled, editModeEnabled]
1653
+ [svgString, isInteractionEnabled, clickToInteractEnabled]
2207
1654
  );
2208
- return /* @__PURE__ */ jsxs6(MouseTracker, { children: [
2209
- netHoverHighlightEnabled && /* @__PURE__ */ jsx9("style", { children: `.sch-net-faded { opacity: 0.35; }
1655
+ return /* @__PURE__ */ jsxs5(MouseTracker, { children: [
1656
+ netHoverHighlightEnabled && /* @__PURE__ */ jsx7("style", { children: `.sch-net-faded { opacity: 0.35; }
2210
1657
  svg :is(g.trace, g.trace-overlays, g[data-schematic-component-id], [data-schematic-net-label-id]) { transition: opacity 0.12s ease-in-out; }` }),
2211
- onSchematicComponentClicked && /* @__PURE__ */ jsx9("style", { children: `.schematic-component-clickable [data-schematic-component-id]:hover { cursor: pointer !important; }` }),
2212
- onSchematicPortClicked && /* @__PURE__ */ jsx9("style", { children: `[data-schematic-port-id]:hover { cursor: pointer !important; }` }),
2213
- /* @__PURE__ */ jsxs6(
1658
+ onSchematicComponentClicked && /* @__PURE__ */ jsx7("style", { children: `.schematic-component-clickable [data-schematic-component-id]:hover { cursor: pointer !important; }` }),
1659
+ onSchematicPortClicked && /* @__PURE__ */ jsx7("style", { children: `[data-schematic-port-id]:hover { cursor: pointer !important; }` }),
1660
+ /* @__PURE__ */ jsxs5(
2214
1661
  "div",
2215
1662
  {
2216
1663
  ref: containerRef,
@@ -2218,18 +1665,10 @@ var SchematicViewer = ({
2218
1665
  position: "relative",
2219
1666
  backgroundColor: containerBackgroundColor,
2220
1667
  overflow: "hidden",
2221
- cursor: isDragging ? "grabbing" : clickToInteractEnabled && !isInteractionEnabled ? "pointer" : isHoveringClickableComponent && onSchematicComponentClicked ? "pointer" : isHoveringClickablePort && onSchematicPortClicked ? "pointer" : "grab",
1668
+ cursor: clickToInteractEnabled && !isInteractionEnabled ? "pointer" : isHoveringClickableComponent && onSchematicComponentClicked ? "pointer" : isHoveringClickablePort && onSchematicPortClicked ? "pointer" : "grab",
2222
1669
  minHeight: "300px",
2223
1670
  ...containerStyle
2224
1671
  },
2225
- onMouseDown: (e) => {
2226
- if (clickToInteractEnabled && !isInteractionEnabled) {
2227
- e.preventDefault();
2228
- e.stopPropagation();
2229
- return;
2230
- }
2231
- handleMouseDown(e);
2232
- },
2233
1672
  onMouseDownCapture: (e) => {
2234
1673
  if (clickToInteractEnabled && !isInteractionEnabled) {
2235
1674
  e.preventDefault();
@@ -2240,7 +1679,7 @@ var SchematicViewer = ({
2240
1679
  onTouchStart: handleTouchStart,
2241
1680
  onTouchEnd: handleTouchEnd,
2242
1681
  children: [
2243
- !isInteractionEnabled && clickToInteractEnabled && /* @__PURE__ */ jsx9(
1682
+ !isInteractionEnabled && clickToInteractEnabled && /* @__PURE__ */ jsx7(
2244
1683
  "div",
2245
1684
  {
2246
1685
  onClick: (e) => {
@@ -2259,7 +1698,7 @@ var SchematicViewer = ({
2259
1698
  pointerEvents: "all",
2260
1699
  touchAction: "pan-x pan-y pinch-zoom"
2261
1700
  },
2262
- children: /* @__PURE__ */ jsx9(
1701
+ children: /* @__PURE__ */ jsx7(
2263
1702
  "div",
2264
1703
  {
2265
1704
  style: {
@@ -2276,21 +1715,7 @@ var SchematicViewer = ({
2276
1715
  )
2277
1716
  }
2278
1717
  ),
2279
- editingEnabled && /* @__PURE__ */ jsx9(
2280
- EditIcon,
2281
- {
2282
- active: editModeEnabled,
2283
- onClick: () => setEditModeEnabled(!editModeEnabled)
2284
- }
2285
- ),
2286
- editingEnabled && editModeEnabled && /* @__PURE__ */ jsx9(
2287
- GridIcon,
2288
- {
2289
- active: snapToGrid,
2290
- onClick: () => setSnapToGrid(!snapToGrid)
2291
- }
2292
- ),
2293
- /* @__PURE__ */ jsx9(
1718
+ /* @__PURE__ */ jsx7(
2294
1719
  ViewMenu,
2295
1720
  {
2296
1721
  circuitJson,
@@ -2308,7 +1733,7 @@ var SchematicViewer = ({
2308
1733
  onToggleGrid: setShowGridInternal
2309
1734
  }
2310
1735
  ),
2311
- /* @__PURE__ */ jsx9(
1736
+ /* @__PURE__ */ jsx7(
2312
1737
  SchematicSheetSelector,
2313
1738
  {
2314
1739
  sheets: schematicSheets,
@@ -2316,7 +1741,7 @@ var SchematicViewer = ({
2316
1741
  onSelectSheet: handleSelectSheet
2317
1742
  }
2318
1743
  ),
2319
- onSchematicComponentClicked && schematicComponentIds.map((componentId) => /* @__PURE__ */ jsx9(
1744
+ onSchematicComponentClicked && schematicComponentIds.map((componentId) => /* @__PURE__ */ jsx7(
2320
1745
  SchematicComponentMouseTarget,
2321
1746
  {
2322
1747
  componentId,
@@ -2335,7 +1760,7 @@ var SchematicViewer = ({
2335
1760
  componentId
2336
1761
  )),
2337
1762
  svgDiv,
2338
- showSchematicPorts && schematicPortsInfo.map(({ portId, label }) => /* @__PURE__ */ jsx9(
1763
+ showSchematicPorts && schematicPortsInfo.map(({ portId, label }) => /* @__PURE__ */ jsx7(
2339
1764
  SchematicPortMouseTarget,
2340
1765
  {
2341
1766
  portId,
@@ -2365,7 +1790,7 @@ import {
2365
1790
  convertCircuitJsonToSchematicSimulationSvg,
2366
1791
  convertCircuitJsonToSimulationGraphSvg
2367
1792
  } from "circuit-to-svg";
2368
- import { useEffect as useEffect12, useMemo as useMemo5, useRef as useRef9, useState as useState8 } from "react";
1793
+ import { useEffect as useEffect9, useMemo as useMemo5, useRef as useRef6, useState as useState7 } from "react";
2369
1794
  import { toString as transformToString2 } from "transformation-matrix";
2370
1795
  import { useMouseMatrixTransform as useMouseMatrixTransform2 } from "use-mouse-matrix-transform";
2371
1796
 
@@ -2383,8 +1808,8 @@ var getAnalogSimulationBackgroundColor = (simulationSvg, colorOverrides) => getR
2383
1808
 
2384
1809
  // lib/components/AnalogSimulationSelector.tsx
2385
1810
  import * as DropdownMenu3 from "@radix-ui/react-dropdown-menu";
2386
- import { useState as useState7 } from "react";
2387
- import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
1811
+ import { useState as useState6 } from "react";
1812
+ import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
2388
1813
  var FONT_FAMILY3 = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
2389
1814
  var contentStyles3 = {
2390
1815
  backgroundColor: "#ffffff",
@@ -2434,7 +1859,7 @@ var MENU_CSS2 = `
2434
1859
  .sv-simulation-chevron { transition: transform 0.2s ease; }
2435
1860
  [data-state="open"] > .sv-simulation-chevron { transform: rotate(180deg); }
2436
1861
  `;
2437
- var CheckIcon3 = () => /* @__PURE__ */ jsx10(
1862
+ var CheckIcon3 = () => /* @__PURE__ */ jsx8(
2438
1863
  "svg",
2439
1864
  {
2440
1865
  width: "14",
@@ -2446,10 +1871,10 @@ var CheckIcon3 = () => /* @__PURE__ */ jsx10(
2446
1871
  strokeLinecap: "round",
2447
1872
  strokeLinejoin: "round",
2448
1873
  "aria-hidden": "true",
2449
- children: /* @__PURE__ */ jsx10("path", { d: "M20 6 9 17l-5-5" })
1874
+ children: /* @__PURE__ */ jsx8("path", { d: "M20 6 9 17l-5-5" })
2450
1875
  }
2451
1876
  );
2452
- var ChevronDownIcon2 = ({ className }) => /* @__PURE__ */ jsx10(
1877
+ var ChevronDownIcon2 = ({ className }) => /* @__PURE__ */ jsx8(
2453
1878
  "svg",
2454
1879
  {
2455
1880
  className,
@@ -2463,7 +1888,7 @@ var ChevronDownIcon2 = ({ className }) => /* @__PURE__ */ jsx10(
2463
1888
  strokeLinejoin: "round",
2464
1889
  style: { opacity: 0.6, flexShrink: 0 },
2465
1890
  "aria-hidden": "true",
2466
- children: /* @__PURE__ */ jsx10("path", { d: "m6 9 6 6 6-6" })
1891
+ children: /* @__PURE__ */ jsx8("path", { d: "m6 9 6 6 6-6" })
2467
1892
  }
2468
1893
  );
2469
1894
  var getSimulationLabels = (simulations) => {
@@ -2482,17 +1907,17 @@ var AnalogSimulationSelector = ({
2482
1907
  selectedSimulationExperimentId,
2483
1908
  onSelectSimulation
2484
1909
  }) => {
2485
- const [open, setOpen] = useState7(false);
1910
+ const [open, setOpen] = useState6(false);
2486
1911
  if (simulations.length <= 1) return null;
2487
1912
  const simulationLabels = getSimulationLabels(simulations);
2488
1913
  const selectedSimulation = simulationLabels.find(
2489
1914
  ({ simulation }) => simulation.simulation_experiment_id === selectedSimulationExperimentId
2490
1915
  );
2491
1916
  const selectedLabel = selectedSimulation?.label ?? "Select simulation";
2492
- return /* @__PURE__ */ jsxs7(Fragment4, { children: [
2493
- /* @__PURE__ */ jsx10("style", { children: MENU_CSS2 }),
2494
- /* @__PURE__ */ jsxs7(DropdownMenu3.Root, { open, onOpenChange: setOpen, modal: false, children: [
2495
- /* @__PURE__ */ jsx10(DropdownMenu3.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs7(
1917
+ return /* @__PURE__ */ jsxs6(Fragment4, { children: [
1918
+ /* @__PURE__ */ jsx8("style", { children: MENU_CSS2 }),
1919
+ /* @__PURE__ */ jsxs6(DropdownMenu3.Root, { open, onOpenChange: setOpen, modal: false, children: [
1920
+ /* @__PURE__ */ jsx8(DropdownMenu3.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs6(
2496
1921
  "button",
2497
1922
  {
2498
1923
  type: "button",
@@ -2519,13 +1944,13 @@ var AnalogSimulationSelector = ({
2519
1944
  zIndex: zIndexMap.viewMenuIcon
2520
1945
  },
2521
1946
  children: [
2522
- /* @__PURE__ */ jsx10("span", { style: { color: "#888888", flexShrink: 0 }, children: "Simulation:" }),
2523
- /* @__PURE__ */ jsx10("span", { style: { ...ellipsisStyles2, minWidth: 0 }, children: selectedLabel }),
2524
- /* @__PURE__ */ jsx10(ChevronDownIcon2, { className: "sv-simulation-chevron" })
1947
+ /* @__PURE__ */ jsx8("span", { style: { color: "#888888", flexShrink: 0 }, children: "Simulation:" }),
1948
+ /* @__PURE__ */ jsx8("span", { style: { ...ellipsisStyles2, minWidth: 0 }, children: selectedLabel }),
1949
+ /* @__PURE__ */ jsx8(ChevronDownIcon2, { className: "sv-simulation-chevron" })
2525
1950
  ]
2526
1951
  }
2527
1952
  ) }),
2528
- /* @__PURE__ */ jsx10(DropdownMenu3.Portal, { children: /* @__PURE__ */ jsx10(
1953
+ /* @__PURE__ */ jsx8(DropdownMenu3.Portal, { children: /* @__PURE__ */ jsx8(
2529
1954
  DropdownMenu3.Content,
2530
1955
  {
2531
1956
  style: contentStyles3,
@@ -2535,7 +1960,7 @@ var AnalogSimulationSelector = ({
2535
1960
  collisionPadding: 10,
2536
1961
  children: simulationLabels.map(({ simulation, label }) => {
2537
1962
  const selected = simulation.simulation_experiment_id === selectedSimulationExperimentId;
2538
- return /* @__PURE__ */ jsxs7(
1963
+ return /* @__PURE__ */ jsxs6(
2539
1964
  DropdownMenu3.Item,
2540
1965
  {
2541
1966
  className: "sv-simulation-item",
@@ -2547,8 +1972,8 @@ var AnalogSimulationSelector = ({
2547
1972
  setOpen(false);
2548
1973
  },
2549
1974
  children: [
2550
- /* @__PURE__ */ jsx10("span", { style: iconSlotStyles3, children: selected && /* @__PURE__ */ jsx10(CheckIcon3, {}) }),
2551
- /* @__PURE__ */ jsx10("span", { style: { ...ellipsisStyles2, minWidth: 0 }, children: label })
1975
+ /* @__PURE__ */ jsx8("span", { style: iconSlotStyles3, children: selected && /* @__PURE__ */ jsx8(CheckIcon3, {}) }),
1976
+ /* @__PURE__ */ jsx8("span", { style: { ...ellipsisStyles2, minWidth: 0 }, children: label })
2552
1977
  ]
2553
1978
  },
2554
1979
  simulation.simulation_experiment_id
@@ -2561,7 +1986,7 @@ var AnalogSimulationSelector = ({
2561
1986
  };
2562
1987
 
2563
1988
  // lib/components/AnalogSimulationViewer.tsx
2564
- import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
1989
+ import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
2565
1990
  var DEFAULT_RENDER_WIDTH = 1200;
2566
1991
  var DEFAULT_COMBINED_RENDER_ASPECT_RATIO = 1;
2567
1992
  var DEFAULT_GRAPH_ONLY_RENDER_ASPECT_RATIO = 2;
@@ -2576,16 +2001,16 @@ var AnalogSimulationViewer = ({
2576
2001
  onSimulationChange,
2577
2002
  acSweepView = "magnitude"
2578
2003
  }) => {
2579
- const [circuitJson, setCircuitJson] = useState8(null);
2580
- const [isLoading, setIsLoading] = useState8(true);
2581
- const [error, setError] = useState8(null);
2582
- const [svgObjectUrl, setSvgObjectUrl] = useState8(null);
2583
- const containerRef = useRef9(null);
2584
- const imgRef = useRef9(null);
2004
+ const [circuitJson, setCircuitJson] = useState7(null);
2005
+ const [isLoading, setIsLoading] = useState7(true);
2006
+ const [error, setError] = useState7(null);
2007
+ const [svgObjectUrl, setSvgObjectUrl] = useState7(null);
2008
+ const containerRef = useRef6(null);
2009
+ const imgRef = useRef6(null);
2585
2010
  const { containerWidth } = useResizeHandling(
2586
2011
  containerRef
2587
2012
  );
2588
- const [isDragging, setIsDragging] = useState8(false);
2013
+ const [isDragging, setIsDragging] = useState7(false);
2589
2014
  const {
2590
2015
  ref: transformRef,
2591
2016
  cancelDrag: _cancelDrag,
@@ -2601,7 +2026,7 @@ var AnalogSimulationViewer = ({
2601
2026
  const renderAspectRatio = width && height ? width / height : defaultRenderAspectRatio;
2602
2027
  const effectiveWidth = width || (height ? height * renderAspectRatio : containerWidth) || DEFAULT_RENDER_WIDTH;
2603
2028
  const effectiveHeight = height || effectiveWidth / renderAspectRatio;
2604
- useEffect12(() => {
2029
+ useEffect9(() => {
2605
2030
  setIsLoading(true);
2606
2031
  setError(null);
2607
2032
  setCircuitJson(inputCircuitJson);
@@ -2613,11 +2038,11 @@ var AnalogSimulationViewer = ({
2613
2038
  (element) => element.type === "simulation_experiment"
2614
2039
  );
2615
2040
  }, [circuitJson]);
2616
- const [selectedSimulationExperimentId, setSelectedSimulationExperimentId] = useState8(null);
2041
+ const [selectedSimulationExperimentId, setSelectedSimulationExperimentId] = useState7(null);
2617
2042
  const simulationExperimentId = (selectedSimulationExperimentId && simulationExperiments.some(
2618
2043
  (simulation) => simulation.simulation_experiment_id === selectedSimulationExperimentId
2619
2044
  ) ? selectedSimulationExperimentId : simulationExperiments[0]?.simulation_experiment_id) ?? null;
2620
- useEffect12(() => {
2045
+ useEffect9(() => {
2621
2046
  if (simulationExperimentId !== selectedSimulationExperimentId) {
2622
2047
  setSelectedSimulationExperimentId(simulationExperimentId);
2623
2048
  }
@@ -2654,7 +2079,7 @@ var AnalogSimulationViewer = ({
2654
2079
  simulationExperimentId,
2655
2080
  acSweepView
2656
2081
  ]);
2657
- useEffect12(() => {
2082
+ useEffect9(() => {
2658
2083
  if (!simulationSvg) {
2659
2084
  setSvgObjectUrl(null);
2660
2085
  return;
@@ -2680,7 +2105,7 @@ var AnalogSimulationViewer = ({
2680
2105
  const handleTouchStart = (_e) => {
2681
2106
  setIsDragging(true);
2682
2107
  };
2683
- useEffect12(() => {
2108
+ useEffect9(() => {
2684
2109
  const handleMouseUp = () => {
2685
2110
  setIsDragging(false);
2686
2111
  };
@@ -2695,7 +2120,7 @@ var AnalogSimulationViewer = ({
2695
2120
  };
2696
2121
  }, []);
2697
2122
  if (isLoading) {
2698
- return /* @__PURE__ */ jsx11(
2123
+ return /* @__PURE__ */ jsx9(
2699
2124
  "div",
2700
2125
  {
2701
2126
  style: {
@@ -2715,7 +2140,7 @@ var AnalogSimulationViewer = ({
2715
2140
  );
2716
2141
  }
2717
2142
  if (error) {
2718
- return /* @__PURE__ */ jsx11(
2143
+ return /* @__PURE__ */ jsx9(
2719
2144
  "div",
2720
2145
  {
2721
2146
  style: {
@@ -2730,15 +2155,15 @@ var AnalogSimulationViewer = ({
2730
2155
  ...containerStyle
2731
2156
  },
2732
2157
  className,
2733
- children: /* @__PURE__ */ jsxs8("div", { style: { textAlign: "center", padding: "20px" }, children: [
2734
- /* @__PURE__ */ jsx11("div", { style: { fontWeight: "bold", marginBottom: "8px" }, children: "Circuit Conversion Error" }),
2735
- /* @__PURE__ */ jsx11("div", { style: { fontSize: "14px" }, children: error })
2158
+ children: /* @__PURE__ */ jsxs7("div", { style: { textAlign: "center", padding: "20px" }, children: [
2159
+ /* @__PURE__ */ jsx9("div", { style: { fontWeight: "bold", marginBottom: "8px" }, children: "Circuit Conversion Error" }),
2160
+ /* @__PURE__ */ jsx9("div", { style: { fontSize: "14px" }, children: error })
2736
2161
  ] })
2737
2162
  }
2738
2163
  );
2739
2164
  }
2740
2165
  if (!simulationSvg) {
2741
- return /* @__PURE__ */ jsxs8(
2166
+ return /* @__PURE__ */ jsxs7(
2742
2167
  "div",
2743
2168
  {
2744
2169
  style: {
@@ -2754,11 +2179,11 @@ var AnalogSimulationViewer = ({
2754
2179
  },
2755
2180
  className,
2756
2181
  children: [
2757
- /* @__PURE__ */ jsx11("div", { style: { fontSize: "16px", color: "#475569", fontWeight: 500 }, children: "No Simulation Found" }),
2758
- /* @__PURE__ */ jsxs8("div", { style: { fontSize: "14px", color: "#64748b" }, children: [
2182
+ /* @__PURE__ */ jsx9("div", { style: { fontSize: "16px", color: "#475569", fontWeight: 500 }, children: "No Simulation Found" }),
2183
+ /* @__PURE__ */ jsxs7("div", { style: { fontSize: "14px", color: "#64748b" }, children: [
2759
2184
  "Use",
2760
2185
  " ",
2761
- /* @__PURE__ */ jsx11(
2186
+ /* @__PURE__ */ jsx9(
2762
2187
  "code",
2763
2188
  {
2764
2189
  style: {
@@ -2778,7 +2203,7 @@ var AnalogSimulationViewer = ({
2778
2203
  }
2779
2204
  );
2780
2205
  }
2781
- return /* @__PURE__ */ jsxs8(
2206
+ return /* @__PURE__ */ jsxs7(
2782
2207
  "div",
2783
2208
  {
2784
2209
  ref: (node) => {
@@ -2797,7 +2222,7 @@ var AnalogSimulationViewer = ({
2797
2222
  onMouseDown: handleMouseDown,
2798
2223
  onTouchStart: handleTouchStart,
2799
2224
  children: [
2800
- /* @__PURE__ */ jsx11(
2225
+ /* @__PURE__ */ jsx9(
2801
2226
  AnalogSimulationSelector,
2802
2227
  {
2803
2228
  simulations: simulationExperiments,
@@ -2805,7 +2230,7 @@ var AnalogSimulationViewer = ({
2805
2230
  onSelectSimulation: handleSelectSimulation
2806
2231
  }
2807
2232
  ),
2808
- svgObjectUrl ? /* @__PURE__ */ jsx11(
2233
+ svgObjectUrl ? /* @__PURE__ */ jsx9(
2809
2234
  "img",
2810
2235
  {
2811
2236
  ref: imgRef,
@@ -2819,7 +2244,7 @@ var AnalogSimulationViewer = ({
2819
2244
  objectFit: "contain"
2820
2245
  }
2821
2246
  }
2822
- ) : /* @__PURE__ */ jsx11(
2247
+ ) : /* @__PURE__ */ jsx9(
2823
2248
  "div",
2824
2249
  {
2825
2250
  style: {