@tscircuit/runframe 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.github/workflows/bun-formatcheck.yml +26 -0
  2. package/.github/workflows/bun-pver-release.yml +25 -0
  3. package/.github/workflows/bun-typecheck.yml +26 -0
  4. package/LICENSE +21 -0
  5. package/README.md +40 -0
  6. package/biome.json +57 -0
  7. package/bun.lockb +0 -0
  8. package/cosmos.config.json +3 -0
  9. package/cosmos.decorator.tsx +3 -0
  10. package/dist/assets/index-CNL2S1zq.js +36 -0
  11. package/dist/assets/index-DDl5GwFA.js +21609 -0
  12. package/dist/assets/vision_bundle-CPRQl8Yc.js +15 -0
  13. package/dist/index.html +13 -0
  14. package/dist/standalone.js +46887 -0
  15. package/examples/resistor.fixture.tsx +12 -0
  16. package/examples/runframe-with-api-1.fixture.tsx +41 -0
  17. package/examples/runframe1-basic.fixture.tsx +19 -0
  18. package/index.html +13 -0
  19. package/lib/components/BomTable.tsx +69 -0
  20. package/lib/components/CircuitJsonPreview.tsx +348 -0
  21. package/lib/components/CircuitJsonTableViewer/CircuitJsonTableViewer.tsx +315 -0
  22. package/lib/components/CircuitJsonTableViewer/ClickableText.tsx +20 -0
  23. package/lib/components/CircuitJsonTableViewer/HeaderCell.tsx +26 -0
  24. package/lib/components/CircuitJsonTableViewer/Modal.tsx +38 -0
  25. package/lib/components/ErrorFallback.tsx +25 -0
  26. package/lib/components/ErrorTabContent.tsx +86 -0
  27. package/lib/components/PcbViewerWithContainerHeight.tsx +47 -0
  28. package/lib/components/PreviewEmptyState.tsx +14 -0
  29. package/lib/components/RunFrame.tsx +68 -0
  30. package/lib/components/RunFrameWithApi/index.tsx +41 -0
  31. package/lib/components/RunFrameWithApi/standalone.tsx +6 -0
  32. package/lib/components/RunFrameWithApi/store.ts +122 -0
  33. package/lib/components/RunFrameWithApi/types.ts +43 -0
  34. package/lib/components/ui/button.tsx +57 -0
  35. package/lib/components/ui/dropdown-menu.tsx +203 -0
  36. package/lib/components/ui/tabs.tsx +53 -0
  37. package/lib/dev/render-to-circuit-json.ts +7 -0
  38. package/lib/hooks/use-styles.ts +17 -0
  39. package/lib/preview.ts +1 -0
  40. package/lib/runner.ts +2 -0
  41. package/lib/utils/index.ts +6 -0
  42. package/lib/utils/pcbManualEditEventHandler.ts +156 -0
  43. package/package.json +52 -0
  44. package/postcss.config.js +8 -0
  45. package/renovate.json +15 -0
  46. package/scripts/build-css.ts +26 -0
  47. package/src/main.tsx +13 -0
  48. package/tailwind.config.js +3 -0
  49. package/tsconfig.json +43 -0
  50. package/vite.config.ts +43 -0
@@ -0,0 +1,26 @@
1
+ # Created using @tscircuit/plop (npm install -g @tscircuit/plop)
2
+ name: Format Check
3
+
4
+ on:
5
+ push:
6
+ branches: [main]
7
+ pull_request:
8
+ branches: [main]
9
+
10
+ jobs:
11
+ format-check:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v3
16
+
17
+ - name: Setup bun
18
+ uses: oven-sh/setup-bun@v1
19
+ with:
20
+ bun-version: latest
21
+
22
+ - name: Install dependencies
23
+ run: bun install
24
+
25
+ - name: Run format check
26
+ run: bun run format:check
@@ -0,0 +1,25 @@
1
+ # Created using @tscircuit/plop (npm install -g @tscircuit/plop)
2
+ name: Publish to npm
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+ - name: Setup bun
13
+ uses: oven-sh/setup-bun@v1
14
+ with:
15
+ bun-version: latest
16
+ - uses: actions/setup-node@v3
17
+ with:
18
+ node-version: 20
19
+ registry-url: https://registry.npmjs.org/
20
+ - run: npm install -g pver
21
+ - run: bun install --frozen-lockfile
22
+ - run: bun run build
23
+ - run: pver release
24
+ env:
25
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,26 @@
1
+ # Created using @tscircuit/plop (npm install -g @tscircuit/plop)
2
+ name: Type Check
3
+
4
+ on:
5
+ push:
6
+ branches: [main]
7
+ pull_request:
8
+ branches: [main]
9
+
10
+ jobs:
11
+ type-check:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v3
16
+
17
+ - name: Setup bun
18
+ uses: oven-sh/setup-bun@v1
19
+ with:
20
+ bun-version: latest
21
+
22
+ - name: Install dependencies
23
+ run: bun i
24
+
25
+ - name: Run type check
26
+ run: bunx tsc --noEmit
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 tscircuit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @tscircuit/runframe
2
+
3
+ [tscircuit](https://github.com/tscircuit/tscircuit) ⋅ [View Examples](https://runframe.vercel.app)
4
+
5
+ A React component that runs tscircuit inside a webworker and shows you the PCB,
6
+ Schematic, 3D and other previews.
7
+
8
+ - Automatically imports other snippets and libraries if imported
9
+ - Runs inside webworker (doesn't block the main thread)
10
+ - Converts typescript to javascript using babel
11
+
12
+ ## Usage
13
+
14
+ ```tsx
15
+ import { RunFrame } from "@tscircuit/runframe"
16
+
17
+ const App = () => (
18
+ <RunFrame
19
+ fsMap={{
20
+ "main.tsx": `
21
+ circuit.add(
22
+ <resistor resistance="1k" />
23
+ )
24
+ `,
25
+ }}
26
+ entrypoint="main.tsx"
27
+
28
+ // Listen to events
29
+ onCircuitJsonChange={(circuitJson) => void}
30
+ onRenderingFinished={({ circuitJson }) => void}
31
+ onRenderEvent={(event) => void}
32
+ onError={(error) => void}
33
+ />
34
+ )
35
+ ```
36
+
37
+ > Note: You should have tailwind installed in the parent project, this library
38
+ > works without installing tailwind but without the "css reset" things will look
39
+ > a bit off (e.g. you might see serif fonts), create an issue if that's
40
+ > cumbersome because we removed it to save 5kb
package/biome.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
3
+ "organizeImports": {
4
+ "enabled": true
5
+ },
6
+ "formatter": {
7
+ "enabled": true,
8
+ "indentStyle": "space"
9
+ },
10
+ "files": {
11
+ "ignore": ["cosmos-export", "dist", "package.json"]
12
+ },
13
+ "javascript": {
14
+ "formatter": {
15
+ "jsxQuoteStyle": "double",
16
+ "quoteProperties": "asNeeded",
17
+ "trailingCommas": "all",
18
+ "semicolons": "asNeeded",
19
+ "arrowParentheses": "always",
20
+ "bracketSpacing": true,
21
+ "bracketSameLine": false
22
+ }
23
+ },
24
+ "linter": {
25
+ "enabled": true,
26
+ "rules": {
27
+ "recommended": true,
28
+ "suspicious": {
29
+ "noExplicitAny": "off",
30
+ "noArrayIndexKey": "off"
31
+ },
32
+ "complexity": {
33
+ "noForEach": "info"
34
+ },
35
+ "correctness": {
36
+ "useExhaustiveDependencies": "off"
37
+ },
38
+ "a11y": {
39
+ "useKeyWithClickEvents": "off"
40
+ },
41
+ "style": {
42
+ "noUselessElse": "off",
43
+ "noNonNullAssertion": "off",
44
+ "useNumberNamespace": "off",
45
+ "noUnusedTemplateLiteral": "off",
46
+ "useFilenamingConvention": {
47
+ "level": "error",
48
+ "options": {
49
+ "strictCase": true,
50
+ "requireAscii": true,
51
+ "filenameCases": ["kebab-case", "export"]
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
package/bun.lockb ADDED
Binary file
@@ -0,0 +1,3 @@
1
+ {
2
+ "plugins": ["react-cosmos-plugin-vite"]
3
+ }
@@ -0,0 +1,3 @@
1
+ export default ({ children }: { children: React.ReactNode }) => {
2
+ return <div style={{ width: "100vw", height: "100vh" }}>{children}</div>
3
+ }
@@ -0,0 +1,36 @@
1
+ import{S as at,a as ht,c as w,s as B,t as A,b as it,d as b,f as lt,r as T,e as rt,g as st}from"./index-DDl5GwFA.js";var q=(t,e={})=>{let n=t._internal_store;if(!n){n={counts:{}},t._internal_store=n;for(const s of t){const o=s.type,a=s[`${o}_id`];if(!a)continue;const c=Number.parseInt(a.split("_").pop());Number.isNaN(c)||(n.counts[o]=Math.max(n.counts[o]??0,c))}}return new Proxy({},{get:(s,o)=>o==="toArray"?()=>t:{get:a=>t.find(c=>c.type===o&&c[`${o}_id`]===a),getUsing:a=>{const c=Object.keys(a);if(c.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const i=c[0],r=i.replace("_id",""),l=t.find(g=>g.type===r&&g[i]===a[i]);return l?t.find(g=>g.type===o&&g[`${o}_id`]===l[`${o}_id`]):null},getWhere:a=>{const c=Object.keys(a);return t.find(i=>i.type===o&&c.every(r=>i[r]===a[r]))},list:a=>{const c=a?Object.keys(a):[];return t.filter(i=>i.type===o&&c.every(r=>i[r]===a[r]))},insert:a=>{var r;(r=n.counts)[o]??(r[o]=-1),n.counts[o]++;const c=n.counts[o],i={type:o,[`${o}_id`]:`${o}_${c}`,...a};return e.validateInserts&&(at[o]??ht).parse(i),t.push(i),i},delete:a=>{const c=t.find(i=>i[`${o}_id`]===a);c&&t.splice(t.indexOf(c),1)},update:(a,c)=>{const i=t.find(r=>r.type===o&&r[`${o}_id`]===a);if(i)return Object.assign(i,c),i},select:a=>{if(o==="source_component")return t.find(c=>c.type==="source_component"&&c.name===a.replace(/\./g,""));if(o==="pcb_port"||o==="source_port"||o==="schematic_port"){const[c,i]=a.replace(/\./g,"").split(/[\s\>]+/),r=t.find(g=>g.type==="source_component"&&g.name===c);if(!r)return null;const l=t.find(g=>g.type==="source_port"&&g.source_component_id===r.source_component_id&&(g.name===i||(g.port_hints??[]).includes(i)));if(!l)return null;if(o==="source_port")return l;if(o==="pcb_port")return t.find(g=>g.type==="pcb_port"&&g.source_port_id===l.source_port_id);if(o==="schematic_port")return t.find(g=>g.type==="schematic_port"&&g.source_port_id===l.source_port_id)}}}})};q.unparsed=q;var H=q;function gt(t,e,n,h){if(!h)return[];const{pcb_port_ids:s}=t,o=n.find(g=>g.type==="pcb_port"&&g.pcb_port_id===(s==null?void 0:s[0])),a=n.find(g=>g.type==="pcb_port"&&g.pcb_port_id===(s==null?void 0:s[1]));if(!o||!a)return[];const c=b(e,{x:o.x,y:o.y}),i=b(e,{x:a.x,y:a.y}),r={x:(c.x+i.x)/2,y:(c.y+i.y)/2};return isNaN(c.x)||isNaN(c.y)||isNaN(i.x)||isNaN(i.y)||isNaN(r.x)||isNaN(r.y)?[]:[{name:"line",type:"element",attributes:{x1:c.x.toString(),y1:c.y.toString(),x2:r.x.toString(),y2:r.y.toString(),stroke:"red","stroke-width":"1.5","stroke-dasharray":"2,2"},children:[],value:""},{name:"line",type:"element",attributes:{x1:r.x.toString(),y1:r.y.toString(),x2:i.x.toString(),y2:i.y.toString(),stroke:"red","stroke-width":"1.5","stroke-dasharray":"2,2"},children:[],value:""},{name:"rect",type:"element",attributes:{x:(r.x-5).toString(),y:(r.y-5).toString(),width:"10",height:"10",fill:"red",transform:`rotate(45 ${r.x} ${r.y})`},children:[],value:""},{name:"text",type:"element",attributes:{x:r.x.toString(),y:(r.y-15).toString(),fill:"red","font-family":"sans-serif","font-size":"12","text-anchor":"middle"},children:[{type:"text",value:t.message||"Pcb Trace Error",name:"",attributes:{},children:[]}],value:""}]}function dt(t,e){if(!t.route||!Array.isArray(t.route))return[];const n=t.route[0],h=t.route[t.route.length-1],s=n.x===h.x&&n.y===h.y,o=t.route.slice(0,s?-1:void 0).map((a,c)=>{const[i,r]=b(e,[a.x,a.y]);return c===0?`M ${i} ${r}`:`L ${i} ${r}`}).join(" ")+(s?" Z":"");return[{name:"path",type:"element",attributes:{class:"pcb-fabrication-note-path",stroke:t.color||"rgba(255,255,255,0.5)",fill:"none",d:o,"stroke-width":(t.stroke_width*Math.abs(e.a)).toString(),"data-pcb-component-id":t.pcb_component_id,"data-pcb-fabrication-note-path-id":t.pcb_fabrication_note_path_id},value:"",children:[]}]}function bt(t,e){const{anchor_position:n,anchor_alignment:h,text:s,font_size:o=1,layer:a="top",color:c}=t;if(!n||typeof n.x!="number"||typeof n.y!="number")return console.error("Invalid anchor_position:",n),[];const[i,r]=b(e,[n.x,n.y]),l=o*Math.abs(e.a),g=w(A(i,r),T(Math.PI/180));return[{name:"text",type:"element",attributes:{x:"0",y:"0","font-family":"Arial, sans-serif","font-size":l.toString(),"text-anchor":"middle","dominant-baseline":"central",transform:rt(g),class:"pcb-fabrication-note-text",fill:c||"rgba(255,255,255,0.5)"},children:[{type:"text",value:s,name:"",attributes:{},children:[]}],value:""}]}function mt(t,e){const[n,h]=b(e,[t.x,t.y]);if(t.shape==="pill"){const s=t.outer_width*Math.abs(e.a),o=t.outer_height*Math.abs(e.a),a=t.hole_width*Math.abs(e.a),c=t.hole_height*Math.abs(e.a),i=s/2,r=a/2,l=o-s;return[{name:"g",type:"element",children:[{name:"path",type:"element",attributes:{class:"pcb-hole-outer",d:`M${n-i},${h-l/2} v${l} a${i},${i} 0 0 0 ${s},0 v-${l} a${i},${i} 0 0 0 -${s},0 z`},value:"",children:[]},{name:"path",type:"element",attributes:{class:"pcb-hole-inner",d:`M${n-r},${h-(c-a)/2} v${c-a} a${r},${r} 0 0 0 ${a},0 v-${c-a} a${r},${r} 0 0 0 -${a},0 z`},value:"",children:[]}],value:"",attributes:{}}]}if(t.shape==="circle"){const s=t.outer_diameter*Math.abs(e.a),o=t.outer_diameter*Math.abs(e.a),a=t.hole_diameter*Math.abs(e.a),c=t.hole_diameter*Math.abs(e.a),i=Math.min(s,o)/2,r=Math.min(a,c)/2;return[{name:"g",type:"element",children:[{name:"circle",type:"element",attributes:{class:"pcb-hole-outer",cx:n.toString(),cy:h.toString(),r:i.toString()},value:"",children:[]},{name:"circle",type:"element",attributes:{class:"pcb-hole-inner",cx:n.toString(),cy:h.toString(),r:r.toString()},value:"",children:[]}],value:"",attributes:{}}]}return[]}function ut(t,e){if(!t.route||!Array.isArray(t.route))return[];let n=t.route.map((o,a)=>{const[c,i]=b(e,[o.x,o.y]);return a===0?`M ${c} ${i}`:`L ${c} ${i}`}).join(" ");const h=t.route[0],s=t.route[t.route.length-1];return h&&s&&h.x===s.x&&h.y===s.y&&(n+=" Z"),[{name:"path",type:"element",attributes:{class:`pcb-silkscreen pcb-silkscreen-${t.layer}`,d:n,"stroke-width":(t.stroke_width*Math.abs(e.a)).toString(),"data-pcb-component-id":t.pcb_component_id,"data-pcb-silkscreen-path-id":t.pcb_silkscreen_path_id},value:"",children:[]}]}function ft(t,e){const{anchor_position:n,text:h,font_size:s=1,layer:o="top"}=t;if(!n||typeof n.x!="number"||typeof n.y!="number")return console.error("Invalid anchor_position:",n),[];const[a,c]=b(e,[n.x,n.y]),i=s*Math.abs(e.a),r=w(A(a,c),T(Math.PI/180));return[{name:"text",type:"element",attributes:{x:"0",y:"0","font-family":"Arial, sans-serif","font-size":i.toString(),"text-anchor":"middle","dominant-baseline":"central",transform:rt(r),class:`pcb-silkscreen-text pcb-silkscreen-${o}`,"data-pcb-silkscreen-text-id":t.pcb_component_id},children:[{type:"text",value:h,name:"",attributes:{},children:[]}],value:""}]}function pt(t){const e=[];for(let n=0;n<t.length-1;n++)e.push([t[n],t[n+1]]);return e}var ct={top:"rgb(200, 52, 52)",bottom:"rgb(77, 127, 196)"};function K(t){return ct[t]??"white"}function yt(t,e){if(!t.route||!Array.isArray(t.route)||t.route.length<2)return[];const n=pt(t.route),h=[];for(const[s,o]of n){const a=b(e,[s.x,s.y]),c=b(e,[o.x,o.y]),i="layer"in s?s.layer:"layer"in o?o.layer:null;if(!i)continue;const r=ct[i]??"white",l="width"in s?s.width:"width"in o?o.width:null;h.push({name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-trace",stroke:r,d:`M ${a[0]} ${a[1]} L ${c[0]} ${c[1]}`,"stroke-width":l?(l*Math.abs(e.a)).toString():"0.3","stroke-linecap":"round","stroke-linejoin":"round","shape-rendering":"crispEdges"}})}return h}function xt(t,e){const[n,h]=b(e,[t.x,t.y]);if(t.shape==="rect"||t.shape==="rotated_rect"){const s=t.width*Math.abs(e.a),o=t.height*Math.abs(e.d);return t.shape==="rotated_rect"&&t.ccw_rotation?[{name:"rect",type:"element",attributes:{class:"pcb-pad",fill:K(t.layer),x:(-s/2).toString(),y:(-o/2).toString(),width:s.toString(),height:o.toString(),transform:`translate(${n} ${h}) rotate(${-t.ccw_rotation})`}}]:[{name:"rect",type:"element",attributes:{class:"pcb-pad",fill:K(t.layer),x:(n-s/2).toString(),y:(h-o/2).toString(),width:s.toString(),height:o.toString()}}]}return[]}function _t(t,e){const{width:n,height:h,center:s,outline:o}=t;let a;if(o&&Array.isArray(o)&&o.length>=3)a=o.map((c,i)=>{const[r,l]=b(e,[c.x,c.y]);return i===0?`M ${r} ${l}`:`L ${r} ${l}`}).join(" ");else{const c=n/2,i=h/2,r=b(e,[s.x-c,s.y-i]),l=b(e,[s.x+c,s.y-i]),g=b(e,[s.x+c,s.y+i]),p=b(e,[s.x-c,s.y+i]);a=`M ${r[0]} ${r[1]} L ${l[0]} ${l[1]} L ${g[0]} ${g[1]} L ${p[0]} ${p[1]}`}return a+=" Z",[{name:"path",type:"element",value:"",children:[],attributes:{class:"pcb-board",d:a,stroke:"rgba(255, 255, 255, 0.5)","stroke-width":(.1*Math.abs(e.a)).toString()}}]}function St(t,e){const[n,h]=b(e,[t.x,t.y]),s=t.outer_diameter*Math.abs(e.a),o=t.outer_diameter*Math.abs(e.a),a=t.hole_diameter*Math.abs(e.a),c=t.hole_diameter*Math.abs(e.a),i=Math.min(s,o)/2,r=Math.min(a,c)/2;return{name:"g",type:"element",children:[{name:"circle",type:"element",attributes:{class:"pcb-hole-outer",cx:n.toString(),cy:h.toString(),r:i.toString()}},{name:"circle",type:"element",attributes:{class:"pcb-hole-inner",cx:n.toString(),cy:h.toString(),r:r.toString()}}]}}var C="#FF26E2";function vt(t,e){const[n,h]=b(e,[t.x,t.y]);if(t.hole_shape==="circle"||t.hole_shape==="square"){const s=t.hole_diameter*Math.abs(e.a),o=s/2;return t.hole_shape==="circle"?[{name:"circle",type:"element",attributes:{class:"pcb-hole",cx:n.toString(),cy:h.toString(),r:o.toString(),fill:C},children:[],value:""}]:[{name:"rect",type:"element",attributes:{class:"pcb-hole",x:(n-o).toString(),y:(h-o).toString(),width:s.toString(),height:s.toString(),fill:C},children:[],value:""}]}if(t.hole_shape==="oval"){const s=t.hole_width*Math.abs(e.a),o=t.hole_height*Math.abs(e.a),a=s/2,c=o/2;return[{name:"ellipse",type:"element",attributes:{class:"pcb-hole",cx:n.toString(),cy:h.toString(),rx:a.toString(),ry:c.toString(),fill:C},children:[],value:""}]}return[]}var tt=["pcb_trace_error","pcb_plated_hole","pcb_fabrication_note_text","pcb_fabrication_note_path","pcb_silkscreen_text","pcb_silkscreen_path","pcb_via","pcb_trace","pcb_smtpad","pcb_component","pcb_board"];function wt(t,e){let n=Number.POSITIVE_INFINITY,h=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(const d of t)d.type==="pcb_board"?d.outline&&Array.isArray(d.outline)&&d.outline.length>=3?E(d.outline):"center"in d&&"width"in d&&"height"in d&&O(d.center,d.width,d.height):"x"in d&&"y"in d?O({x:d.x,y:d.y},0,0):"route"in d&&j(d.route);const a=1,c=s-n+2*a,i=o-h+2*a,r=(e==null?void 0:e.width)??800,l=(e==null?void 0:e.height)??600,g=[];for(const d of t)"route"in d&&d.route!==void 0&&g.push(d.route);const p=r/c,x=l/i,_=Math.min(p,x),v=(r-c*_)/2,M=(l-i*_)/2,k=w(A(v-n*_+a*_,l-M+h*_-a*_),B(_,-_)),I=t.sort((d,y)=>(tt.indexOf(y.type)??9999)-(tt.indexOf(d.type)??9999)).flatMap(d=>Mt(d,k,t,e==null?void 0:e.shouldDrawErrors));for(const d of t)if("stroke_width"in d){String(_*d.stroke_width);break}const u={name:"svg",type:"element",attributes:{xmlns:"http://www.w3.org/2000/svg",width:r.toString(),height:l.toString()},value:"",children:[{name:"style",type:"element",children:[{type:"text",value:`
2
+ .boundary { fill: #000; }
3
+ .pcb-board { fill: none; }
4
+ .pcb-trace { fill: none; }
5
+ .pcb-hole-outer { fill: rgb(200, 52, 52); }
6
+ .pcb-hole-inner { fill: rgb(255, 38, 226); }
7
+ .pcb-pad { }
8
+ .pcb-boundary { fill: none; stroke: #fff; stroke-width: 0.3; }
9
+ .pcb-silkscreen { fill: none; }
10
+ .pcb-silkscreen-top { stroke: #f2eda1; }
11
+ .pcb-silkscreen-bottom { stroke: #f2eda1; }
12
+ .pcb-silkscreen-text { fill: #f2eda1; }
13
+ `}]},{name:"rect",type:"element",attributes:{class:"boundary",x:"0",y:"0",width:r.toString(),height:l.toString()}},kt(k,n,h,s,o),...I].filter(d=>d!==null)};try{return it(u)}catch(d){throw console.error("Error stringifying SVG object:",d),d}function O(d,y,F){const X=y/2,R=F/2;n=Math.min(n,d.x-X),h=Math.min(h,d.y-R),s=Math.max(s,d.x+X),o=Math.max(o,d.y+R)}function E(d){for(const y of d)n=Math.min(n,y.x),h=Math.min(h,y.y),s=Math.max(s,y.x),o=Math.max(o,y.y)}function j(d){for(const y of d)n=Math.min(n,y.x),h=Math.min(h,y.y),s=Math.max(s,y.x),o=Math.max(o,y.y)}}function Mt(t,e,n,h){switch(t.type){case"pcb_trace_error":return gt(t,e,n,h).filter(Boolean);case"pcb_component":return[$t(t,e)].filter(Boolean);case"pcb_trace":return yt(t,e);case"pcb_plated_hole":return mt(t,e).filter(Boolean);case"pcb_hole":return vt(t,e);case"pcb_smtpad":return xt(t,e);case"pcb_silkscreen_text":return ft(t,e);case"pcb_fabrication_note_path":return dt(t,e);case"pcb_fabrication_note_text":return bt(t,e);case"pcb_silkscreen_path":return ut(t,e);case"pcb_board":return _t(t,e);case"pcb_via":return St(t,e);default:return[]}}function $t(t,e){const{center:n,width:h,height:s,rotation:o=0}=t,[a,c]=b(e,[n.x,n.y]),i=h*Math.abs(e.a),r=s*Math.abs(e.d);return{name:"g",type:"element",attributes:{transform:`translate(${a}, ${c}) rotate(${-o}) scale(1, -1)`},children:[{name:"rect",type:"element",attributes:{class:"pcb-component",x:(-i/2).toString(),y:(-r/2).toString(),width:i.toString(),height:r.toString()}},{name:"rect",type:"element",attributes:{class:"pcb-component-outline",x:(-i/2).toString(),y:(-r/2).toString(),width:i.toString(),height:r.toString()}}]}}function kt(t,e,n,h,s){const[o,a]=b(t,[e,n]),[c,i]=b(t,[h,s]),r=Math.abs(c-o),l=Math.abs(i-a),g=Math.min(o,c),p=Math.min(a,i);return{name:"rect",type:"element",value:"",children:[],attributes:{class:"pcb-boundary",x:g.toString(),y:p.toString(),width:r.toString(),height:l.toString()}}}var ee=wt,f={"3d_viewer":{background_bottom:"rgb(102, 102, 128)",background_top:"rgb(204, 204, 230)",board:"rgb(51, 43, 23)",copper:"rgb(179, 156, 0)",silkscreen_bottom:"rgb(230, 230, 230)",silkscreen_top:"rgb(230, 230, 230)",soldermask:"rgb(20, 51, 36)",solderpaste:"rgb(128, 128, 128)"},board:{anchor:"rgb(255, 38, 226)",aux_items:"rgb(255, 255, 255)",b_adhes:"rgb(0, 0, 132)",b_crtyd:"rgb(255, 38, 226)",b_fab:"rgb(88, 93, 132)",b_mask:"rgba(2, 255, 238, 0.400)",b_paste:"rgb(0, 194, 194)",b_silks:"rgb(232, 178, 167)",background:"rgb(0, 16, 35)",cmts_user:"rgb(89, 148, 220)",copper:{b:"rgb(77, 127, 196)",f:"rgb(200, 52, 52)",in1:"rgb(127, 200, 127)",in10:"rgb(237, 124, 51)",in11:"rgb(91, 195, 235)",in12:"rgb(247, 111, 142)",in13:"rgb(167, 165, 198)",in14:"rgb(40, 204, 217)",in15:"rgb(232, 178, 167)",in16:"rgb(242, 237, 161)",in17:"rgb(237, 124, 51)",in18:"rgb(91, 195, 235)",in19:"rgb(247, 111, 142)",in2:"rgb(206, 125, 44)",in20:"rgb(167, 165, 198)",in21:"rgb(40, 204, 217)",in22:"rgb(232, 178, 167)",in23:"rgb(242, 237, 161)",in24:"rgb(237, 124, 51)",in25:"rgb(91, 195, 235)",in26:"rgb(247, 111, 142)",in27:"rgb(167, 165, 198)",in28:"rgb(40, 204, 217)",in29:"rgb(232, 178, 167)",in3:"rgb(79, 203, 203)",in30:"rgb(242, 237, 161)",in4:"rgb(219, 98, 139)",in5:"rgb(167, 165, 198)",in6:"rgb(40, 204, 217)",in7:"rgb(232, 178, 167)",in8:"rgb(242, 237, 161)",in9:"rgb(141, 203, 129)"},cursor:"rgb(255, 255, 255)",drc:"rgb(194, 194, 194)",drc_error:"rgba(215, 91, 107, 0.800)",drc_exclusion:"rgb(255, 255, 255)",drc_warning:"rgba(255, 208, 66, 0.902)",dwgs_user:"rgb(194, 194, 194)",eco1_user:"rgb(180, 219, 210)",eco2_user:"rgb(216, 200, 82)",edge_cuts:"rgb(208, 210, 205)",f_adhes:"rgb(132, 0, 132)",f_crtyd:"rgb(255, 0, 245)",f_fab:"rgb(175, 175, 175)",f_mask:"rgba(216, 100, 255, 0.400)",f_paste:"rgba(180, 160, 154, 0.902)",f_silks:"rgb(242, 237, 161)",footprint_text_back:"rgb(0, 0, 132)",footprint_text_front:"rgb(194, 194, 194)",footprint_text_invisible:"rgb(132, 132, 132)",grid:"rgb(132, 132, 132)",grid_axes:"rgb(194, 194, 194)",margin:"rgb(255, 38, 226)",microvia:"rgb(0, 132, 132)",no_connect:"rgb(0, 0, 132)",pad_back:"rgb(77, 127, 196)",pad_front:"rgb(200, 52, 52)",pad_plated_hole:"rgb(194, 194, 0)",pad_through_hole:"rgb(227, 183, 46)",plated_hole:"rgb(26, 196, 210)",ratsnest:"rgba(245, 255, 213, 0.702)",select_overlay:"rgb(4, 255, 67)",through_via:"rgb(236, 236, 236)",user_1:"rgb(194, 194, 194)",user_2:"rgb(89, 148, 220)",user_3:"rgb(180, 219, 210)",user_4:"rgb(216, 200, 82)",user_5:"rgb(194, 194, 194)",user_6:"rgb(89, 148, 220)",user_7:"rgb(180, 219, 210)",user_8:"rgb(216, 200, 82)",user_9:"rgb(232, 178, 167)",via_blind_buried:"rgb(187, 151, 38)",via_hole:"rgb(227, 183, 46)",via_micro:"rgb(0, 132, 132)",via_through:"rgb(236, 236, 236)",worksheet:"rgb(200, 114, 171)"},gerbview:{axes:"rgb(0, 0, 132)",background:"rgb(0, 0, 0)",dcodes:"rgb(255, 255, 255)",grid:"rgb(132, 132, 132)",layers:["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)","rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)"],negative_objects:"rgb(132, 132, 132)",worksheet:"rgb(0, 0, 132)"},meta:{filename:"kicad_2020",name:"KiCad 2020",version:2},palette:["rgb(132, 0, 0)","rgb(194, 194, 0)","rgb(194, 0, 194)","rgb(194, 0, 0)","rgb(0, 132, 132)","rgb(0, 132, 0)","rgb(0, 0, 132)","rgb(132, 132, 132)","rgb(132, 0, 132)","rgb(194, 194, 194)","rgb(132, 0, 132)","rgb(132, 0, 0)","rgb(132, 132, 0)","rgb(194, 194, 194)","rgb(0, 0, 132)","rgb(0, 132, 0)"],schematic:{aux_items:"rgb(46, 46, 46)",background:"rgb(245, 241, 237)",brightened:"rgb(255, 0, 255)",bus:"rgb(0, 0, 132)",bus_junction:"rgb(0, 0, 132)",component_body:"rgb(255, 255, 194)",component_outline:"rgb(132, 0, 0)",cursor:"rgb(15, 15, 15)",erc_error:"rgba(230, 9, 13, 0.800)",erc_warning:"rgba(209, 146, 0, 0.800)",fields:"rgb(132, 0, 132)",grid:"rgb(181, 181, 181)",grid_axes:"rgb(0, 0, 132)",hidden:"rgb(194, 194, 194)",junction:"rgb(0, 150, 0)",label_global:"rgb(132, 0, 0)",label_hier:"rgb(114, 86, 0)",label_local:"rgb(15, 15, 15)",net_name:"rgb(132, 132, 132)",no_connect:"rgb(0, 0, 132)",note:"rgb(0, 0, 194)",override_item_colors:!1,pin:"rgb(132, 0, 0)",pin_name:"rgb(0, 100, 100)",pin_number:"rgb(169, 0, 0)",reference:"rgb(0, 100, 100)",shadow:"rgba(102, 179, 255, 0.800)",sheet:"rgb(132, 0, 0)",sheet_background:"rgba(253, 255, 231, 0.000)",sheet_fields:"rgb(132, 0, 132)",sheet_filename:"rgb(114, 86, 0)",sheet_label:"rgb(0, 100, 100)",sheet_name:"rgb(0, 100, 100)",value:"rgb(0, 100, 100)",wire:"rgb(0, 150, 0)",wire_crossing:"rgb(30, 180, 30)",worksheet:"rgb(132, 0, 0)"}};function Pt(t){const{minX:e,minY:n,maxX:h,maxY:s}=t.bounds,o=t.cellSize??1,a=t.labelCells??!1,c=[],i=(r,l)=>{const[g,p]=b(t.transform,[r,l]);return{x:g,y:p}};for(let r=Math.floor(e);r<=Math.ceil(h);r+=o){const l=i(r,n),g=i(r,s);c.push({name:"line",type:"element",attributes:{x1:l.x.toString(),y1:l.y.toString(),x2:g.x.toString(),y2:g.y.toString(),stroke:f.schematic.grid,"stroke-width":(.01*Math.abs(t.transform.a)).toString(),"stroke-opacity":"0.5"}})}for(let r=Math.floor(n);r<=Math.ceil(s);r+=o){const l=i(e,r),g=i(h,r);c.push({name:"line",type:"element",attributes:{x1:l.x.toString(),y1:l.y.toString(),x2:g.x.toString(),y2:g.y.toString(),stroke:f.schematic.grid,"stroke-width":(.01*Math.abs(t.transform.a)).toString(),"stroke-opacity":"0.5"}})}if(a){const r=(l,g)=>o<=.1?`${l.toFixed(1)},${g.toFixed(1)}`:`${l},${g}`;for(let l=Math.floor(e);l<=Math.ceil(h);l+=o)for(let g=Math.floor(n);g<=Math.ceil(s);g+=o){const p=i(l,g);c.push({name:"text",type:"element",attributes:{x:(p.x-2.5).toString(),y:(p.y-5).toString(),fill:f.schematic.grid,"font-size":(o/5*Math.abs(t.transform.a)).toString(),"fill-opacity":"0.5","text-anchor":"middle","dominant-baseline":"middle","font-family":"sans-serif"},children:[{type:"text",value:r(l,g),name:"",attributes:{},children:[]}]})}}return{name:"g",value:"",type:"element",attributes:{class:"grid"},children:c}}function It(t){const{points:e,transform:n}=t,h=[];for(const s of e){const[o,a]=b(n,[s.x-.1,s.y-.1]),[c,i]=b(n,[s.x+.1,s.y+.1]),[r,l]=b(n,[s.x-.1,s.y+.1]),[g,p]=b(n,[s.x+.1,s.y-.1]);h.push({name:"path",type:"element",attributes:{d:`M${o},${a} L${c},${i} M${r},${l} L${g},${p}`,stroke:f.schematic.grid,"stroke-width":(.02*Math.abs(n.a)).toString(),"stroke-opacity":"0.7"}});const[x,_]=b(n,[s.x+.15,s.y-.15]);h.push({name:"text",type:"element",attributes:{x:x.toString(),y:_.toString(),fill:f.schematic.grid,"font-size":(.1*Math.abs(n.a)).toString(),"fill-opacity":"0.7","text-anchor":"start","font-family":"sans-serif","dominant-baseline":"middle"},children:[{type:"text",value:s.label||`(${s.x},${s.y})`,name:"",attributes:{},children:[]}]})}return{name:"g",value:"",type:"element",attributes:{class:"labeled-points"},children:h}}function Ft(t,e=.5){let n=Number.POSITIVE_INFINITY,h=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;const a=.2;for(const i of t)if(i.type==="schematic_component")c(i.center,i.size,i.rotation||0);else if(i.type==="schematic_port")c(i.center,{width:a,height:a},0);else if(i.type==="schematic_debug_object")i.shape==="rect"?c(i.center,i.size,0):i.shape==="line"&&(c(i.start,{width:.1,height:.1},0),c(i.end,{width:.1,height:.1},0));else if(i.type==="schematic_net_label")c(i.center,{width:1,height:1},0);else if(i.type==="schematic_trace")for(const r of i.edges)c(r.from,{width:.1,height:.1},0),c(r.to,{width:.1,height:.1},0);else i.type==="schematic_text"?c(i.position,{width:.1,height:.1},0):i.type==="schematic_voltage_probe"&&c(i.position,{width:.2,height:.4},0);return n-=e,h-=e,s+=e,o+=e,{minX:n,minY:h,maxX:s,maxY:o};function c(i,r,l){const g=[{x:-r.width/2,y:-r.height/2},{x:r.width/2,y:-r.height/2},{x:r.width/2,y:r.height/2},{x:-r.width/2,y:r.height/2}];for(const p of g){const x=p.x*Math.cos(l)-p.y*Math.sin(l)+i.x,_=p.x*Math.sin(l)+p.y*Math.cos(l)+i.y;n=Math.min(n,x),h=Math.min(h,_),s=Math.max(s,x),o=Math.max(o,_)}}}var P=t=>Math.abs(t.a)*.02,Ot=(t,e)=>{const n=t<0?t+2*Math.PI:t,h=e<0?e+2*Math.PI:e;let s=Math.abs(n-h);return s>Math.PI&&(s=2*Math.PI-s),s},Yt=({schPorts:t,symbol:e,schComponent:n})=>{const h=t.map(c=>{const i=c.center.x-n.center.x,r=c.center.y-n.center.y;return{port:c,angle:Math.atan2(r,i)}}),s=e.ports.map(c=>{const i=c.x-e.center.x,r=c.y-e.center.y;return{port:c,angle:Math.atan2(r,i)}});h.sort((c,i)=>c.angle-i.angle),s.sort((c,i)=>c.angle-i.angle);const o=[],a=new Set;for(const c of h){let i=null;for(const r of s){if(a.has(r.port))continue;const l=Ot(c.angle,r.angle);(i===null||l<i.angleDiff)&&(i={symbolPort:r.port,angleDiff:l})}i&&i.angleDiff<Math.PI/4&&(o.push({schPort:c.port,symbolPort:i.symbolPort}),a.add(i.symbolPort))}return o};function Et(t,e,n,h){const s=e.x-t.x,o=e.y-t.y,a=Math.sqrt((n.x-t.x)**2+(n.y-t.y)**2),i=Math.sqrt((h.x-e.x)**2+(h.y-e.y)**2)/a,r=A(s,o),l=B(i,i);return w(r,l)}var J=t=>t==="error"?.05:t==="pin_number"?.15:.18,Y=(t,e)=>Math.abs(t.a)*J(e),U=({text:t,realCenter:e,realToScreenTransform:n})=>{const h=b(n,e);return{type:"element",name:"text",value:"",attributes:{x:h.x.toString(),y:h.y.toString(),fill:"red","text-anchor":"middle","dominant-baseline":"middle","font-family":"sans-serif","font-size":`${Y(n,"error")}px`},children:[{type:"text",value:t,name:"",attributes:{},children:[]}]}},jt={top_left:"start",top_right:"end",middle_left:"start",middle_right:"end",bottom_left:"start",bottom_right:"end",center:"middle",middle_top:"middle",middle_bottom:"middle"},Xt={top_left:"auto",top_right:"auto",bottom_left:"hanging",bottom_right:"hanging",center:"auto",middle_left:"middle",middle_right:"middle",middle_top:"auto",middle_bottom:"hanging"},At=({component:t,transform:e,circuitJson:n})=>{var E,j;const h=[],s=st[t.symbol_name];if(!s)return[U({text:`Symbol not found: ${t.symbol_name}`,realCenter:t.center,realToScreenTransform:e})];const o=H(n).schematic_port.list({schematic_component_id:t.schematic_component_id}),a=H(n).source_component.get(t.source_component_id),c=Yt({schPorts:o,symbol:s,schComponent:t});if(!c[0])return[U({text:`Could not match ports for symbol ${t.symbol_name}`,realCenter:t.center,realToScreenTransform:e})];const i=Et(((E=c[1])==null?void 0:E.symbolPort)??s.center,((j=c[1])==null?void 0:j.schPort.center)??t.center,c[0].symbolPort,c[0].schPort.center),r=s.primitives.filter(d=>d.type==="path"),l=s.primitives.filter(d=>d.type==="text");s.primitives.filter(d=>d.type==="circle");const g=s.primitives.filter(d=>d.type==="box"),p={minX:Math.min(...r.flatMap(d=>d.points.map(y=>y.x))),maxX:Math.max(...r.flatMap(d=>d.points.map(y=>y.x))),minY:Math.min(...r.flatMap(d=>d.points.map(y=>y.y))),maxY:Math.max(...r.flatMap(d=>d.points.map(y=>y.y)))},[x,_]=b(w(e,i),[p.minX,p.minY]),[v,M]=b(w(e,i),[p.maxX,p.maxY]),k=Math.abs(M-_),I=Math.min(_,M),u=Math.abs(v-x),O=Math.min(x,v);h.push({name:"rect",type:"element",value:"",attributes:{class:"component-overlay",x:O.toString(),y:I.toString(),width:u.toString(),height:k.toString(),fill:"transparent"},children:[]});for(const d of r){const{points:y,color:F,closed:X,fill:R}=d;h.push({type:"element",name:"path",attributes:{d:y.map((m,S)=>{const[$,W]=b(w(e,i),[m.x,m.y]);return`${S===0?"M":"L"} ${$} ${W}`}).join(" ")+(X?" Z":""),stroke:f.schematic.component_outline,fill:"none","stroke-width":`${P(e)}px`},value:"",children:[]})}for(const d of l){const y=b(w(e,i),d);let F="";d.text==="{REF}"?F=(a==null?void 0:a.name)??"":d.text==="{VAL}"&&(F=t.symbol_display_value??""),h.push({name:"text",type:"element",attributes:{x:y.x.toString(),y:y.y.toString(),"dominant-baseline":Xt[d.anchor],"text-anchor":jt[d.anchor],"font-family":"sans-serif","font-size":`${Y(e,"reference_designator")}px`},value:"",children:[{type:"text",value:F,name:"",attributes:{},children:[]}]})}for(const d of g){const y=b(w(e,i),d),F=w(e,i).a;h.push({name:"rect",type:"element",attributes:{x:y.x.toString(),y:y.y.toString(),width:(d.width*F).toString(),height:(d.height*F).toString(),fill:"red"},value:"",children:[]})}for(const d of s.ports){const y=b(w(e,i),d);h.push({type:"element",name:"circle",attributes:{cx:y.x.toString(),cy:y.y.toString(),r:`${Math.abs(e.a)*.02}px`,"stroke-width":`${P(e)}px`,fill:"none",stroke:f.schematic.component_outline},value:"",children:[]})}return h},z=.02,Rt=({schPort:t,schComponent:e,transform:n,circuitJson:h})=>{const s=[];H(h).source_port.get(t.source_port_id);const o={x:t.center.x,y:t.center.y},a=t.distance_from_component_edge??.4;switch(t.side_of_component){case"left":o.x+=a;break;case"right":o.x-=a;break;case"top":o.y-=a;break;case"bottom":o.y+=a;break}const c=b(n,t.center),i=b(n,o),r={...t.center};switch(t.side_of_component){case"left":r.x+=z;break;case"right":r.x-=z;break;case"top":r.y-=z;break;case"bottom":r.y+=z;break}const l=b(n,r);return s.push({name:"line",type:"element",attributes:{class:"component-pin",x1:l.x.toString(),y1:l.y.toString(),x2:i.x.toString(),y2:i.y.toString(),"stroke-width":`${P(n)}px`},value:"",children:[]}),s.push({name:"circle",type:"element",attributes:{class:"component-pin",cx:c.x.toString(),cy:c.y.toString(),r:(Math.abs(n.a)*z).toString(),"stroke-width":`${P(n)}px`},value:"",children:[]}),s},V=t=>{switch(t){case"top":return{x:0,y:-1};case"bottom":return{x:0,y:1};case"left":return{x:1,y:0};case"right":return{x:-1,y:0}}throw new Error(`Invalid side: ${t}`)},Wt=t=>{var l;const e=[],{schPort:n,schComponent:h,transform:s,circuitJson:o}=t,a={x:n.center.x,y:n.center.y};if(!n.side_of_component)return[];const c=V(n.side_of_component),i=n.distance_from_component_edge??.4;a.x+=c.x*i/2,a.y+=c.y*i/2,n.side_of_component==="top"||n.side_of_component==="bottom"?a.x-=.02:a.y+=.02;const r=b(s,a);return e.push({name:"text",type:"element",attributes:{class:"pin-number",x:r.x.toString(),y:r.y.toString(),style:"font-family: sans-serif;",fill:f.schematic.pin_number,"text-anchor":"middle","dominant-baseline":"auto","font-size":`${Y(s,"pin_number")}px`,transform:n.side_of_component==="top"||n.side_of_component==="bottom"?`rotate(-90 ${r.x} ${r.y})`:""},children:[{type:"text",value:((l=n.pin_number)==null?void 0:l.toString())||"",name:"",attributes:{},children:[]}],value:""}),e},et=.1,zt=t=>{var g;const e=[],{schPort:n,schComponent:h,transform:s,circuitJson:o}=t,a={x:n.center.x,y:n.center.y};if(!n.side_of_component)return[];const c=V(n.side_of_component),i=n.distance_from_component_edge??.4;a.x+=c.x*(i+et),a.y+=c.y*(i+et);const r=b(s,a),l=n.display_pin_label??((g=h.port_labels)==null?void 0:g[`${n.pin_number}`]);return l?(e.push({name:"text",type:"element",attributes:{class:"pin-number",x:r.x.toString(),y:r.y.toString(),style:"font-family: sans-serif;",fill:f.schematic.pin_number,"text-anchor":n.side_of_component==="left"||n.side_of_component==="bottom"?"start":"end","dominant-baseline":"middle","font-size":`${Y(s,"pin_number")}px`,transform:n.side_of_component==="top"||n.side_of_component==="bottom"?`rotate(-90 ${r.x} ${r.y})`:""},children:[{type:"text",value:l||"",name:"",attributes:{},children:[]}],value:""}),e):[]},Dt=t=>{const e=[];return e.push(...Rt(t)),e.push(...Wt(t)),e.push(...zt(t)),e},Nt=({component:t,transform:e,circuitJson:n})=>{const h=[],s=b(e,{x:t.center.x-t.size.width/2,y:t.center.y+t.size.height/2}),o=b(e,{x:t.center.x+t.size.width/2,y:t.center.y-t.size.height/2}),a=o.x-s.x,c=o.y-s.y;h.push({name:"rect",type:"element",value:"",attributes:{class:"component chip",x:s.x.toString(),y:s.y.toString(),width:a.toString(),height:c.toString(),"stroke-width":`${P(e)}px`,fill:f.schematic.component_body,stroke:f.schematic.component_outline},children:[]}),h.push({name:"rect",type:"element",value:"",attributes:{class:"component-overlay",x:s.x.toString(),y:s.y.toString(),width:a.toString(),height:c.toString(),fill:"transparent"},children:[]});const i=H(n).schematic_port.list({schematic_component_id:t.schematic_component_id});for(const r of i)h.push(...Dt({schPort:r,schComponent:t,transform:e,circuitJson:n}));return h};function Ht(t){const{component:e}=t,n=e.symbol_name?At(t):Nt(t);return[{type:"element",name:"g",attributes:{"data-circuit-json-type":"schematic_component","data-schematic-component-id":e.schematic_component_id},children:n,value:""}]}function Bt(t,e){const[n,h]=b(e,[t.position.x,t.position.y]),s=Math.abs(e.a)*.6,o=Math.abs(e.a)*.28,a=n+s*Math.cos(-50*Math.PI/180),c=h+s*Math.sin(-50*Math.PI/180),i=n,r=h;return[{name:"path",type:"element",attributes:{d:[`M ${a},${c}`,`L ${i},${r}`,`M ${i},${r}`,`L ${i-o*Math.cos(100*Math.PI/180)},${r-o*Math.sin(100*Math.PI/180)}`,`L ${i-o*Math.cos(160*Math.PI/180)},${r-o*Math.sin(160*Math.PI/180)}`,"Z"].join(" "),stroke:f.schematic.reference,fill:f.schematic.reference,"stroke-width":`${P(e)}px`},value:"",children:[]},{type:"element",name:"text",value:"",attributes:{x:(a+8-(a-a)).toString(),y:(c-10+(c-c)).toString(),fill:f.schematic.reference,"text-anchor":"middle","dominant-baseline":"middle","font-family":"sans-serif","font-size":`${Y(e,"reference_designator")}px`,"font-weight":"bold","data-schematic-voltage-probe-id":t.schematic_voltage_probe_id},children:[{type:"text",value:t.voltage?`${t.voltage}V`:"",name:"",attributes:{},children:[]}]}]}function Tt(t,e){if(t.shape==="rect"){let[n,h]=b(e,[t.center.x-t.size.width/2,t.center.y-t.size.height/2]),[s,o]=b(e,[t.center.x+t.size.width/2,t.center.y+t.size.height/2]);[h,o]=[Math.min(h,o),Math.max(h,o)];const a=Math.abs(s-n),c=Math.abs(o-h),[i,r]=b(e,[t.center.x,t.center.y]);return[{name:"rect",type:"element",value:"",attributes:{x:n.toString(),y:h.toString(),width:a.toString(),height:c.toString(),fill:"none",stroke:"red","stroke-width":(.02*Math.abs(e.a)).toString(),"stroke-dasharray":"5,5"},children:t.label?[{name:"text",type:"element",value:"",attributes:{x:i.toString(),y:(r-10).toString(),"text-anchor":"middle","font-size":(.2*Math.abs(e.a)).toString(),fill:"red"},children:[{type:"text",value:t.label,name:"",attributes:{},children:[]}]}]:[]}]}if(t.shape==="line"){const[n,h]=b(e,[t.start.x,t.start.y]),[s,o]=b(e,[t.end.x,t.end.y]),a=(n+s)/2,c=(h+o)/2;return[{name:"line",type:"element",value:"",attributes:{x1:n.toString(),y1:h.toString(),x2:s.toString(),y2:o.toString(),stroke:"red","stroke-width":(.02*Math.abs(e.a)).toString(),"stroke-dasharray":"5,5"},children:t.label?[{name:"text",type:"element",value:"",attributes:{x:a.toString(),y:(c-10).toString(),"text-anchor":"middle","font-size":(.2*Math.abs(e.a)).toString(),fill:"red"},children:[{type:"text",value:t.label,name:"",attributes:{},children:[]}]}]:[]}]}return[]}function Vt(t,e){var o;const n=t.edges;if(n.length===0)return[];const h=[];let s="";for(let a=0;a<n.length;a++){const c=n[a];if(c.is_crossing)continue;const[i,r]=b(e,[c.from.x,c.from.y]),[l,g]=b(e,[c.to.x,c.to.y]);a===0||(o=n[a-1])!=null&&o.is_crossing?s+=`M ${i} ${r} L ${l} ${g}`:s+=` L ${l} ${g}`}for(const a of n){if(!a.is_crossing)continue;const[c,i]=b(e,[a.from.x,a.from.y]),[r,l]=b(e,[a.to.x,a.to.y]),g=(c+r)/2,p=(i+l)/2,x=r-c,_=l-i,v=Math.sqrt(x*x+_*_),M=v*.7,k=-_/v*M,I=x/v*M,u=g+k,O=p-Math.abs(I);h.push({name:"path",type:"element",attributes:{class:"trace-crossing-outline",d:`M ${c} ${i} Q ${u} ${O} ${r} ${l}`,stroke:f.schematic.background,fill:"none","stroke-width":`${P(e)*1.5}px`,"stroke-linecap":"round"},value:"",children:[]}),h.push({name:"path",type:"element",attributes:{d:`M ${c} ${i} Q ${u} ${O} ${r} ${l}`,stroke:f.schematic.wire,fill:"none","stroke-width":`${P(e)}px`,"stroke-linecap":"round"},value:"",children:[]})}if(s&&(h.push({name:"path",type:"element",attributes:{d:s,class:"trace-invisible-hover-outline",stroke:f.schematic.wire,fill:"none","stroke-width":`${P(e)*8}px`,"stroke-linecap":"round",opacity:"0","stroke-linejoin":"round"},value:"",children:[]}),h.push({name:"path",type:"element",attributes:{d:s,stroke:f.schematic.wire,fill:"none","stroke-width":`${P(e)}px`,"stroke-linecap":"round","stroke-linejoin":"round"},value:"",children:[]})),t.junctions)for(const a of t.junctions){const[c,i]=b(e,[a.x,a.y]);h.push({name:"circle",type:"element",attributes:{cx:c.toString(),cy:i.toString(),r:(Math.abs(e.a)*.03).toString(),fill:f.schematic.junction},value:"",children:[]})}return[{name:"g",type:"element",value:"",attributes:{class:"trace"},children:h}]}var nt={0:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},1:{width:13,height:27,ascent:22,descent:5,left:-3,right:9},2:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},3:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},4:{width:13,height:27,ascent:22,descent:5,left:0,right:12},5:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},6:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},7:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},8:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},9:{width:13,height:27,ascent:22,descent:5,left:-1,right:12}," ":{width:7,height:27,ascent:22,descent:5,left:0,right:0},"!":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},'"':{width:9,height:27,ascent:22,descent:5,left:-1,right:7},"#":{width:13,height:27,ascent:22,descent:5,left:0,right:13},$:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},"%":{width:21,height:27,ascent:22,descent:5,left:-1,right:20},"&":{width:16,height:27,ascent:22,descent:5,left:-1,right:15},"'":{width:5,height:27,ascent:22,descent:5,left:-1,right:3},"(":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},")":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},"*":{width:9,height:27,ascent:22,descent:5,left:-1,right:8},"+":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},",":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},"-":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},".":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},"/":{width:7,height:27,ascent:22,descent:5,left:0,right:7},":":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},";":{width:7,height:27,ascent:22,descent:5,left:-2,right:5},"<":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},"=":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},">":{width:14,height:27,ascent:22,descent:5,left:-1,right:13},"?":{width:13,height:27,ascent:22,descent:5,left:-1,right:12},"@":{width:24,height:27,ascent:22,descent:5,left:-1,right:23},A:{width:16,height:27,ascent:22,descent:5,left:0,right:16},B:{width:16,height:27,ascent:22,descent:5,left:-2,right:15},C:{width:17,height:27,ascent:22,descent:5,left:-1,right:16},D:{width:17,height:27,ascent:22,descent:5,left:-2,right:16},E:{width:16,height:27,ascent:22,descent:5,left:-2,right:15},F:{width:15,height:27,ascent:22,descent:5,left:-2,right:14},G:{width:19,height:27,ascent:22,descent:5,left:-1,right:17},H:{width:17,height:27,ascent:22,descent:5,left:-2,right:15},I:{width:7,height:27,ascent:22,descent:5,left:-2,right:5},J:{width:12,height:27,ascent:22,descent:5,left:-1,right:10},K:{width:16,height:27,ascent:22,descent:5,left:-2,right:16},L:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},M:{width:20,height:27,ascent:22,descent:5,left:-2,right:18},N:{width:17,height:27,ascent:22,descent:5,left:-2,right:15},O:{width:19,height:27,ascent:22,descent:5,left:-1,right:18},P:{width:16,height:27,ascent:22,descent:5,left:-2,right:15},Q:{width:19,height:27,ascent:22,descent:5,left:-1,right:18},R:{width:17,height:27,ascent:22,descent:5,left:-2,right:17},S:{width:16,height:27,ascent:22,descent:5,left:-1,right:15},T:{width:15,height:27,ascent:22,descent:5,left:-1,right:14},U:{width:17,height:27,ascent:22,descent:5,left:-2,right:15},V:{width:16,height:27,ascent:22,descent:5,left:0,right:16},W:{width:23,height:27,ascent:22,descent:5,left:0,right:22},X:{width:16,height:27,ascent:22,descent:5,left:0,right:16},Y:{width:16,height:27,ascent:22,descent:5,left:0,right:16},Z:{width:15,height:27,ascent:22,descent:5,left:0,right:14},"[":{width:7,height:27,ascent:22,descent:5,left:-2,right:6},"\\":{width:7,height:27,ascent:22,descent:5,left:0,right:7},"]":{width:7,height:27,ascent:22,descent:5,left:0,right:5},"^":{width:11,height:27,ascent:22,descent:5,left:-1,right:11},_:{width:13,height:27,ascent:22,descent:5,left:0,right:14},"`":{width:8,height:27,ascent:22,descent:5,left:-1,right:5},a:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},b:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},c:{width:12,height:27,ascent:22,descent:5,left:-1,right:12},d:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},e:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},f:{width:7,height:27,ascent:22,descent:5,left:0,right:8},g:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},h:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},i:{width:5,height:27,ascent:22,descent:5,left:-2,right:4},j:{width:5,height:27,ascent:22,descent:5,left:1,right:4},k:{width:12,height:27,ascent:22,descent:5,left:-2,right:12},l:{width:5,height:27,ascent:22,descent:5,left:-2,right:4},m:{width:20,height:27,ascent:22,descent:5,left:-2,right:18},n:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},o:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},p:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},q:{width:13,height:27,ascent:22,descent:5,left:-1,right:12},r:{width:8,height:27,ascent:22,descent:5,left:-2,right:8},s:{width:12,height:27,ascent:22,descent:5,left:-1,right:11},t:{width:7,height:27,ascent:22,descent:5,left:0,right:6},u:{width:13,height:27,ascent:22,descent:5,left:-2,right:12},v:{width:12,height:27,ascent:22,descent:5,left:0,right:12},w:{width:17,height:27,ascent:22,descent:5,left:0,right:17},x:{width:12,height:27,ascent:22,descent:5,left:0,right:12},y:{width:12,height:27,ascent:22,descent:5,left:0,right:12},z:{width:12,height:27,ascent:22,descent:5,left:0,right:11},"{":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},"|":{width:6,height:27,ascent:22,descent:5,left:-2,right:4},"}":{width:8,height:27,ascent:22,descent:5,left:-1,right:7},"~":{width:14,height:27,ascent:22,descent:5,left:-1,right:13}},ot=t=>{if(!t)return 0;let e=0;for(const n of t){const h=nt[n];h?e+=h.width:e+=nt["?"].width}return e/27},D=.3,G=.3,Z=.06,Lt=(t,e)=>{if(!t.text)return[];const n=[],h=Y(e,"net_label"),s=J("net_label"),o=ot(t.text||""),a=b(e,t.center),c=V(t.anchor_side),i={...c};i.y*=-1;const r=o+D*2+Z*t.text.length+G,l=t.anchor_position?b(e,t.anchor_position):{x:a.x-i.x*r*h/2,y:a.y-i.y*r*h/2},g=t.anchor_position??{x:t.center.x-c.x*r*s/2,y:t.center.y-c.y*r*s/2},p={left:0,top:-90,bottom:90,right:180}[t.anchor_side],x=[{x:0,y:0},{x:D,y:.6},{x:D*2+G+Z*t.text.length+o,y:.6},{x:D*2+G+Z*t.text.length+o,y:-.6},{x:D,y:-.6}].map(I=>b(w(e,A(g.x,g.y),B(s),T(p/180*Math.PI)),I)),_=`
14
+ M ${x[0].x},${x[0].y}
15
+ L ${x[1].x},${x[1].y}
16
+ L ${x[2].x},${x[2].y}
17
+ L ${x[3].x},${x[3].y}
18
+ L ${x[4].x},${x[4].y}
19
+ Z
20
+ `;n.push({name:"path",type:"element",attributes:{class:"net-label",d:_,fill:"white",stroke:f.schematic.label_global,"stroke-width":`${P(e)}px`},value:"",children:[]});const v={x:l.x+i.x*h*.5,y:l.y+i.y*h*.5},M={left:"start",top:"start",bottom:"start",right:"end"}[t.anchor_side],k={left:"",right:"",top:`rotate(90 ${v.x} ${v.y})`,bottom:`rotate(-90 ${v.x} ${v.y})`}[t.anchor_side];return n.push({name:"text",type:"element",attributes:{class:"net-label-text",x:v.x.toString(),y:v.y.toString(),fill:f.schematic.label_global,"text-anchor":M,"dominant-baseline":"central","font-family":"sans-serif","font-variant-numeric":"tabular-nums","font-size":`${h}px`,transform:k},children:[{type:"text",value:t.text||"",name:"",attributes:{},children:[]}],value:""}),n},Ct=(t,e)=>{const n=b(e,t.position),h={center:"middle",left:"start",right:"end",top:"middle",bottom:"middle"},s={center:"middle",left:"middle",right:"middle",top:"hanging",bottom:"ideographic"};return{type:"element",name:"text",value:"",attributes:{x:n.x.toString(),y:n.y.toString(),fill:t.color??f.schematic.sheet_label,"text-anchor":h[t.anchor],"dominant-baseline":s[t.anchor],"font-family":"sans-serif","font-size":`${Y(e,"reference_designator")}px`,transform:`rotate(${t.rotation}, ${n.x}, ${n.y})`},children:[{type:"text",value:t.text,name:t.schematic_text_id,attributes:{},children:[]}]}},Gt={top_left:"start",top_right:"end",middle_left:"start",middle_right:"end",bottom_left:"start",bottom_right:"end",center:"middle",middle_top:"middle",middle_bottom:"middle"},Zt={top_left:"auto",top_right:"auto",bottom_left:"hanging",bottom_right:"hanging",center:"auto",middle_left:"middle",middle_right:"middle",middle_top:"auto",middle_bottom:"hanging"},qt=.3,Ut=.3,Jt=.06,Qt=(t,e)=>{if(!t.text)return[];const n=[],h=st.ground_horz;if(!h)return n.push(U({text:`Symbol not found: ${t.symbol_name}`,realCenter:t.center,realToScreenTransform:e})),n;const s=h.primitives.filter(m=>m.type==="path"),o=h.primitives.filter(m=>m.type==="text"),a=h.primitives.filter(m=>m.type==="circle"),c=h.primitives.filter(m=>m.type==="box"),i={minX:Math.min(...s.flatMap(m=>m.points.map(S=>S.x))),maxX:Math.max(...s.flatMap(m=>m.points.map(S=>S.x))),minY:Math.min(...s.flatMap(m=>m.points.map(S=>S.y))),maxY:Math.max(...s.flatMap(m=>m.points.map(S=>S.y)))},r=J("net_label"),g=ot(t.text||"")+qt*2+Jt*t.text.length+Ut,p=V(t.anchor_side),x=t.anchor_position??{x:t.center.x-p.x*g*r/2,y:t.center.y-p.y*g*r/2},_={left:0,top:-90,bottom:90,right:180}[t.anchor_side],v=T(_/180*Math.PI),M={minX:Math.min(...h.primitives.flatMap(m=>m.type==="path"?m.points.map(S=>S.x):[])),maxX:Math.max(...h.primitives.flatMap(m=>m.type==="path"?m.points.map(S=>S.x):[])),minY:Math.min(...h.primitives.flatMap(m=>m.type==="path"?m.points.map(S=>S.y):[])),maxY:Math.max(...h.primitives.flatMap(m=>m.type==="path"?m.points.map(S=>S.y):[]))},k={x:M.minX,y:(M.minY+M.maxY)/2},I=b(v,k),u=w(A(x.x-I.x,x.y-I.y),v,B(1)),[O,E]=b(w(e,u),[i.minX,i.minY]),[j,d]=b(w(e,u),[i.maxX,i.maxY]),y=Math.abs(d-E),F=Math.min(E,d),X=Math.abs(j-O),R=Math.min(O,j);n.push({name:"rect",type:"element",value:"",attributes:{class:"component-overlay",x:R.toString(),y:F.toString(),width:X.toString(),height:y.toString(),fill:"transparent"},children:[]});for(const m of s){const S=m.points.map(($,W)=>{const[L,N]=b(w(e,u),[$.x,$.y]);return`${W===0?"M":"L"} ${L} ${N}`}).join(" ");n.push({name:"path",type:"element",attributes:{d:S+(m.closed?" Z":""),stroke:f.schematic.component_outline,fill:"none","stroke-width":`${P(e)}px`},value:"",children:[]})}for(const m of o){const S=b(w(e,u),m);let $=m.text;$==="{REF}"?$=t.text||"":$==="{VAL}"&&($="");const W={0:{x:8,y:-10},"-90":{x:33,y:28},90:{x:-32.5,y:-38},180:{x:-8.5,y:-2}},L=_.toString(),N=W[L]||{x:0,y:0},Q={x:S.x+N.x,y:S.y+N.y};n.push({name:"text",type:"element",attributes:{x:Q.x.toString(),y:Q.y.toString(),fill:f.schematic.label_global,"font-family":"sans-serif","text-anchor":Gt[m.anchor],"dominant-baseline":Zt[m.anchor],"font-size":`${Y(e,"reference_designator")}px`},children:[{type:"text",value:$,name:"",attributes:{},children:[]}],value:""})}for(const m of c){const S=b(w(e,u),m),$=w(e,u).a;n.push({name:"rect",type:"element",attributes:{x:S.x.toString(),y:S.y.toString(),width:(m.width*$).toString(),height:(m.height*$).toString(),fill:"red"},value:"",children:[]})}for(const m of a){const S=b(w(e,u),m),$=w(e,u).a;n.push({name:"circle",type:"element",attributes:{cx:S.x.toString(),cy:S.y.toString(),r:(m.radius*$).toString(),fill:"none",stroke:f.schematic.component_outline,"stroke-width":`${P(e)}px`},value:"",children:[]})}return n};function Kt(t,e){const n=Ft(t),h=n.maxX-n.minX,s=n.maxY-n.minY,o=(e==null?void 0:e.width)??1200,a=(e==null?void 0:e.height)??600,c=h/s,i=o/a;let r;if(c>i){const u=o/c;r={x:0,y:(a-u)/2}}else{const u=a*c;r={x:(o-u)/2,y:0}}const l=lt([{x:n.minX,y:n.maxY},{x:n.maxX,y:n.maxY},{x:n.maxX,y:n.minY}],[{x:r.x,y:r.y},{x:o-r.x,y:r.y},{x:o-r.x,y:a-r.y}]),g=[];if(g.push({name:"rect",type:"element",attributes:{class:"boundary",x:"0",y:"0",width:o.toString(),height:a.toString()},children:[],value:""}),e!=null&&e.grid){const u=typeof e.grid=="object"?e.grid:{};g.push(Pt({bounds:n,transform:l,...u}))}const p=[],x=[],_=[],v=[],M=[],k=[];for(const u of t)u.type==="schematic_debug_object"?p.push(...Tt(u,l)):u.type==="schematic_component"?x.push(...Ht({component:u,transform:l,circuitJson:t})):u.type==="schematic_trace"?_.push(...Vt(u,l)):u.type==="schematic_net_label"?u.symbol_name?v.push(...Qt(u,l)):v.push(...Lt(u,l)):u.type==="schematic_text"?M.push(Ct(u,l)):u.type==="schematic_voltage_probe"&&k.push(...Bt(u,l));g.push(...p,...x,..._,...v,...M,...k),e!=null&&e.labeledPoints&&g.push(It({points:e.labeledPoints,transform:l}));const I={name:"svg",type:"element",attributes:{xmlns:"http://www.w3.org/2000/svg",width:o.toString(),height:a.toString(),style:`background-color: ${f.schematic.background}`},children:[{name:"style",type:"element",children:[{type:"text",value:`
21
+ .boundary { fill: ${f.schematic.background}; }
22
+ .schematic-boundary { fill: none; stroke: #fff; }
23
+ .component { fill: none; stroke: ${f.schematic.component_outline}; }
24
+ .chip { fill: ${f.schematic.component_body}; stroke: ${f.schematic.component_outline}; }
25
+ .component-pin { fill: none; stroke: ${f.schematic.component_outline}; }
26
+ .trace:hover {
27
+ filter: invert(1);
28
+ }
29
+ .trace:hover .trace-crossing-outline {
30
+ opacity: 0;
31
+ }
32
+ .text { font-family: sans-serif; fill: ${f.schematic.wire}; }
33
+ .pin-number { fill: ${f.schematic.pin_number}; }
34
+ .port-label { fill: ${f.schematic.reference}; }
35
+ .component-name { fill: ${f.schematic.reference}; }
36
+ `,name:"",attributes:{},children:[]}],value:"",attributes:{}},...g],value:""};return it(I)}var ne=Kt;export{ee as circuitJsonToPcbSvg,ne as circuitJsonToSchematicSvg,wt as convertCircuitJsonToPcbSvg,Kt as convertCircuitJsonToSchematicSvg};