diff --git a/_includes/kicanvas-include.html b/_includes/kicanvas-include.html
new file mode 100644
index 0000000..ff5a50d
--- /dev/null
+++ b/_includes/kicanvas-include.html
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/_layouts/documentation.html b/_layouts/documentation.html
index bef8f6d..37b91a4 100644
--- a/_layouts/documentation.html
+++ b/_layouts/documentation.html
@@ -3,6 +3,7 @@
---
{% include model-viewer-include.html %}
+ {% include kicanvas-include.html %}
diff --git a/assets/js/kicanvas.js b/assets/js/kicanvas.js
new file mode 100644
index 0000000..5b622f1
--- /dev/null
+++ b/assets/js/kicanvas.js
@@ -0,0 +1,1929 @@
+var ps=Object.defineProperty;var on=Object.getOwnPropertyDescriptor;var l=(s,t)=>ps(s,"name",{value:t,configurable:!0});var P=(s,t,e,r)=>{for(var i=r>1?void 0:r?on(t,e):t,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(t,e,i):o(i))||i);return r&&i&&ps(t,e,i),i};function ue(s){window.setTimeout(()=>{s()},0)}l(ue,"later");var Me=class{static{l(this,"DeferredPromise")}#e;#t;#r;#i;#s;constructor(){this.#e=new Promise((t,e)=>{this.#t=t,this.#r=e})}get rejected(){return this.#i===1}get resolved(){return this.#i===0}get settled(){return!!this.#i}get value(){return this.#s}then(t,e){return this.#e.then(t,e)}resolve(t){this.#i=0,this.#s=t,this.#t(t)}reject(t){this.#i=1,this.#s=t,this.#r(t)}},fe=class extends Me{static{l(this,"Barrier")}get isOpen(){return this.resolved&&this.value===!0}open(){this.resolve(!0)}};function hs(s){return s instanceof URL&&(s=s.pathname),s.split("/").slice(0,-1).join("/")}l(hs,"dirname");function Xe(s){return s instanceof URL&&(s=s.pathname),s.split("/").at(-1)}l(Xe,"basename");function D3(s){return s.split(".").at(-1)??""}l(D3,"extension");function Gt(s){let t,e;s instanceof File?(t=URL.createObjectURL(s),e=s.name):(t=s.href,e=Xe(t));let r=document.createElement("a");r.href=t,r.download=e,r.target="_blank",console.log(r),r.click(),s instanceof File&&URL.revokeObjectURL(t)}l(Gt,"initiate_download");var it=class{static{l(this,"VirtualFileSystem")}*list_matches(t){for(let e of this.list())e.match(t)&&(yield e)}*list_ext(t){t.startsWith(".")||(t=`.${t}`);for(let e of this.list())e.endsWith(t)&&(yield e)}},st=class extends it{constructor(e,r=null){super();this.urls=new Map;this.resolver=r??this.#e;for(let i of e)this.#t(i)}static{l(this,"FetchFileSystem")}#e(e){return new URL(e,window.location.toString())}#t(e){if(typeof e=="string"){let r=this.urls.get(e);if(r)return r;{let i=this.resolver(e),n=Xe(i);return this.urls.set(n,i),i}}return e}*list(){yield*this.urls.keys()}async has(e){return Promise.resolve(this.urls.has(e))}async get(e){let r=this.#t(e);if(!r)throw new Error(`File ${e} not found!`);let i=new Request(r,{method:"GET"}),n=await fetch(i);if(!n.ok)throw new Error(`Unable to load ${r}: ${n.status} ${n.statusText}`);let o=await n.blob();return new File([o],e)}async download(e){Gt(await this.get(e))}},Y2=class s extends it{constructor(e){super();this.items=e}static{l(this,"DragAndDropFileSystem")}static async fromDataTransfer(e){let r=[];for(let i=0;i
{i.readEntries(c=>{for(let u of c)u.isFile&&r.push(u);n(!0)},o)})}return new s(r)}*list(){for(let e of this.items)yield e.name}async has(e){for(let r of this.items)if(r.name==e)return!0;return!1}async get(e){let r=null;for(let i of this.items)if(i.name==e){r=i;break}if(r==null)throw new Error(`File ${e} not found!`);return await new Promise((i,n)=>{r.file(i,n)})}async download(e){Gt(await this.get(e))}};var K2=class{static{l(this,"DropTarget")}constructor(t,e){t.addEventListener("dragenter",r=>{r.preventDefault()},!1),t.addEventListener("dragover",r=>{r.dataTransfer&&(r.preventDefault(),r.dataTransfer.dropEffect="move")},!1),t.addEventListener("drop",async r=>{r.stopPropagation(),r.preventDefault();let i=r.dataTransfer;if(!i)return;let n=await Y2.fromDataTransfer(i);e(n)},!1)}};var H2=class s extends Event{constructor(e,r){super(s.type,{bubbles:!0,cancelable:!0,composed:!0});this.context_name=e;this._callback=r}static{l(this,"ContextRequestEvent")}static{this.type="context-request"}callback(e){this.stopPropagation(),this._callback(e)}};async function ds(s,t){return new Promise(e=>{s.dispatchEvent(new H2(t,r=>{e(r)}))})}l(ds,"requestContext");function ms(s,t,e){s.addEventListener(H2.type,r=>{let i=r;i.context_name==t&&i.callback(e)})}l(ms,"provideContext");async function an(s,t){return(await ds(s,t))()}l(an,"requestLazyContext");async function ln(s,t,e){ms(s,t,e)}l(ln,"provideLazyContext");function bs(s){return class extends s{static{l(this,"WithContext")}constructor(...e){super(...e)}async requestContext(e){return await ds(this,e)}provideContext(e,r){ms(this,e,r)}async requestLazyContext(e){return await an(this,e)}provideLazyContext(e,r){ln(this,e,r)}}}l(bs,"WithContext");function B3(s){return s===null||typeof s!="object"&&typeof s!="function"}l(B3,"is_primitive");function G(s){return typeof s=="string"}l(G,"is_string");function le(s){return typeof s=="number"&&!isNaN(s)}l(le,"is_number");function Et(s){return Array.isArray(s)||typeof s?.[Symbol.iterator]=="function"}l(Et,"is_iterable");function $3(s){return Array.isArray(s)}l($3,"is_array");function _s(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)&&!(s instanceof RegExp)&&!(s instanceof Date)}l(_s,"is_object");var Ms=new Map,Ne=class{constructor(t){this.css_string=t}static{l(this,"CSS")}get stylesheet(){let t=Ms.get(this.css_string);return t==null&&(t=new CSSStyleSheet,t.replaceSync(this.css_string),Ms.set(this.css_string,t)),t}};function T(s,...t){let e="";for(let r=0;re instanceof CSSStyleSheet?e:e.stylesheet))}l(fs,"adopt_styles");function G2(s){return $3(s)?s:[s]}l(G2,"as_array");function Ns(s){return $3(s)?s:Et(s)?Array.from(s):[s]}l(Ns,"iterable_as_array");var cn=new Intl.Collator(void 0,{numeric:!0});function pe(s,t){return s.slice().sort((e,r)=>cn.compare(t(e),t(r)))}l(pe,"sorted_by_numeric_strings");var nt=class{constructor(){this._disposables=new Set;this._is_disposed=!1}static{l(this,"Disposables")}add(t){if(this._is_disposed)throw new Error("Tried to add item to a DisposableStack that's already been disposed");return this._disposables.add(t),t}disposeAndRemove(t){t&&(t.dispose(),this._disposables.delete(t))}get isDisposed(){return this._is_disposed}dispose(){if(this._is_disposed){console.trace("dispose() called on an already disposed resource");return}for(let t of this._disposables.values())t.dispose();this._disposables.clear(),this._is_disposed=!0}};function Rn(s){return typeof HTMLElement=="object"&&s instanceof HTMLElement}l(Rn,"is_HTMLElement");function _(s,...t){let e=document.createElement("template");e.innerHTML=un(s,t);let r=e.content;return r=document.importNode(r,!0),pn(r,t),r.childElementCount==1?r.firstElementChild:r}l(_,"html");var j3=class{constructor(t){this.text=t}static{l(this,"Literal")}},z3=/\$\$:(\d+):\$\$/g;function un(s,t){let e=[];for(let i=0;i or
+ ${this.canvas}`}};P([L({type:Boolean})],Le.prototype,"loaded",2),P([L({type:String})],Le.prototype,"theme",2),P([L({type:Boolean})],Le.prototype,"disableinteraction",2);var xi=class extends Le{static{l(this,"KCBoardViewerElement")}update_theme(){this.viewer.theme=this.themeObject.board}make_viewer(){return new x3(this.canvas,!this.disableinteraction,this.themeObject.board)}};window.customElements.define("kc-board-viewer",xi);var xt=class extends N{static{l(this,"KCBoardFootprintsPanelElement")}connectedCallback(){(async()=>(this.viewer=await this.requestLazyContext("viewer"),await this.viewer.loaded,this.sort_footprints(),super.connectedCallback()))()}sort_footprints(){this.sorted_footprints=pe(this.viewer.board.footprints,e=>e.reference||"REF")}initialContentCallback(){this.addEventListener("kc-ui-menu:select",e=>{let r=e.detail;r.name&&this.viewer.select(r.name)}),this.addDisposable(this.viewer.addEventListener(D.type,()=>{this.menu.selected=this.viewer.selected?.context.uuid??null})),this.search_input_elm.addEventListener("input",e=>{this.item_filter_elem.filter_text=this.search_input_elm.value??null})}render(){return _`
+
+
+
+
+
+
+ ${this.render_list()}
+
+
+
+
+ `}render_list(){let e=[],r=[];for(let i of this.sorted_footprints){let n=i.reference||"REF",o=i.value||"VAL",c=`${i.library_link} ${i.descr} ${i.layer} ${n} ${o} ${i.tags}`,u=_`
+ ${n} ${o}
+ `;i.layer=="F.Cu"?e.push(u):r.push(u)}return _`Front
+ ${e}
+ Back
+ ${r}`}};P([Q("kc-ui-menu",!0)],xt.prototype,"menu",2),P([Q("kc-ui-text-filter-input",!0)],xt.prototype,"search_input_elm",2),P([Q("kc-ui-filtered-list",!0)],xt.prototype,"item_filter_elem",2);window.customElements.define("kc-board-footprints-panel",xt);var Qi=class extends N{static{l(this,"KCBoardInfoPanelElement")}connectedCallback(){(async()=>(this.viewer=await this.requestLazyContext("viewer"),await this.viewer.loaded,super.connectedCallback()))()}render(){let e=this.viewer.drawing_sheet,r=this.viewer.board,i=r.edge_cuts_bbox,n=l(u=>_` `,"header"),o=l((u,p,m="")=>_`
+ ${p} ${m}
+ `,"entry"),c=Object.entries(r.title_block?.comment||{}).map(([u,p])=>o(`Comment ${u}`,p));return _`
+
+
+
+
+ ${n("Page properties")}
+ ${o("Size",e.paper?.size)}
+ ${o("Width",e.width,"mm")}
+ ${o("Height",e.height,"mm")}
+ ${n("Board properties")}
+ ${o("KiCAD version",r.version)}
+ ${o("Generator",r.generator)}
+ ${o("Thickness",r.general?.thickness??1.6,"mm")}
+ ${o("Title",r.title_block?.title)}
+ ${o("Date",r.title_block?.date)}
+ ${o("Revision",r.title_block?.rev)}
+ ${o("Company",r.title_block?.company)}
+ ${c}
+ ${o("Dimensions",`${i.w.toFixed(1)} x
+ ${i.h.toFixed(1)} mm`)}
+ ${o("Footprints",r.footprints.length)}
+ ${o("Nets",r.nets.length)}
+ ${o("Track segments",r.segments.length)}
+ ${o("Vias",r.vias.length)}
+ ${o("Zones",r.zones.length)}
+ ${o("Pad to mask clearance",r.setup?.pad_to_mask_clearance??0,"mm")}
+ ${o("Soldermask min width",r.setup?.solder_mask_min_width??0,"mm")}
+ ${o("Pad to paste clearance",r.setup?.pad_to_paste_clearance??0,"mm")}
+ ${o("Pad to paste clearance ratio",r.setup?.pad_to_paste_clearance_ratio??0)}
+ ${o("Grid origin",`${r.setup?.grid_origin?.x??0}, ${r.setup?.grid_origin?.y??0}`)}
+
+
+
+ `}};window.customElements.define("kc-board-info-panel",Qi);var x2=class extends N{static{l(this,"KCBoardLayersPanelElement")}static{this.styles=[...N.styles,T`
+ :host {
+ display: block;
+ height: 100%;
+ overflow-y: auto;
+ overflow-x: hidden;
+ user-select: none;
+ }
+
+ kc-ui-panel-title button {
+ all: unset;
+ flex-shrink: 0;
+ margin-left: 1em;
+ color: white;
+ border: 0 none;
+ background: transparent;
+ padding: 0 0.25em 0 0.25em;
+ margin-right: -0.25em;
+ display: flex;
+ align-items: center;
+ }
+ `]}get items(){return Array.from(this.panel_body.querySelectorAll("kc-board-layer-control")??[])}connectedCallback(){(async()=>(this.viewer=await this.requestLazyContext("viewer"),await this.viewer.loaded,super.connectedCallback()))()}initialContentCallback(){this.panel_body.addEventListener(Q2.select_event,e=>{let r=e.detail;for(let n of this.items)n.layer_highlighted=!1;let i=this.viewer.layers.by_name(r.layer_name);i.highlighted?this.viewer.layers.highlight(null):(this.viewer.layers.highlight(i),i.visible=!0,r.layer_visible=!0,r.layer_highlighted=!0),this.viewer.draw()}),this.panel_body.addEventListener(Q2.visibility_event,e=>{let r=e.detail,i=this.viewer.layers.by_name(r.layer_name);i.visible=!i.visible,r.layer_visible=i.visible,this.presets_menu.deselect(),this.viewer.draw()}),this.renderRoot.querySelector("button")?.addEventListener("click",e=>{e.stopPropagation();let r=this.viewer.layers.in_ui_order();if(this.items.some(i=>i.layer_visible))for(let i of r)i.visible=!1;else for(let i of r)i.visible=!0;this.viewer.draw(),this.presets_menu.deselect(),this.update_item_states()}),this.presets_menu.addEventListener("kc-ui-menu:select",e=>{let r=e.detail,i=this.viewer.layers.in_ui_order();switch(r.name){case"all":for(let n of i)n.visible=!0;break;case"front":for(let n of i)n.visible=n.name.startsWith("F.")||n.name=="Edge.Cuts";break;case"back":for(let n of i)n.visible=n.name.startsWith("B.")||n.name=="Edge.Cuts";break;case"copper":for(let n of i)n.visible=n.name.includes(".Cu")||n.name=="Edge.Cuts";break;case"outer-copper":for(let n of i)n.visible=n.name=="F.Cu"||n.name=="B.Cu"||n.name=="Edge.Cuts";break;case"inner-copper":for(let n of i)n.visible=n.name.includes(".Cu")&&!(n.name=="F.Cu"||n.name=="B.Cu")||n.name=="Edge.Cuts";break;case"drawings":for(let n of i)n.visible=!n.name.includes(".Cu")&&!n.name.includes(".Mask")&&!n.name.includes(".Paste")&&!n.name.includes(".Adhes")}this.viewer.draw(),this.update_item_states()})}update_item_states(){for(let e of this.items){let r=this.viewer.layers.by_name(e.layer_name);e.layer_visible=r?.visible??!1,e.layer_highlighted=r?.highlighted??!1}}render(){let e=this.viewer.layers,r=[];for(let i of e.in_ui_order()){let n=i.visible?"":void 0,o=i.color.to_css();r.push(_` `)}return _`
+
+
+
+ visibility
+
+
+
+ ${r}
+ Presets
+
+ All
+ Front
+ Back
+ Copper
+
+ Outer copper
+
+
+ Inner copper
+
+
+ Drawings
+
+
+
+
+ `}};P([Q("kc-ui-panel-body",!0)],x2.prototype,"panel_body",2),P([Q("#presets",!0)],x2.prototype,"presets_menu",2);var Ie=class Ie extends N{static{l(this,"KCBoardLayerControlElement")}static{this.styles=[...N.styles,T`
+ :host {
+ box-sizing: border-box;
+ padding: 0.1em 0.8em 0.1em 0.4em;
+ color: white;
+ text-align: left;
+ display: flex;
+ flex-direction: row;
+ width: 100%;
+ align-items: center;
+ }
+
+ button {
+ all: unset;
+ cursor: pointer;
+ flex-shrink: 0;
+ margin-left: 1em;
+ color: white;
+ border: 0 none;
+ background: transparent;
+ padding: 0 0.25em 0 0.25em;
+ margin-right: -0.25em;
+ display: flex;
+ align-items: center;
+ }
+
+ .color {
+ flex-shrink: 0;
+ display: block;
+ width: 1em;
+ height: 1em;
+ margin-right: 0.5em;
+ }
+
+ .name {
+ display: block;
+ flex-grow: 1;
+ }
+
+ .for-hidden {
+ color: #888;
+ }
+
+ :host {
+ background: var(--list-item-disabled-bg);
+ color: var(--list-item-disabled-fg);
+ }
+
+ :host(:hover) {
+ background: var(--list-item-hover-bg);
+ color: var(--list-item-hover-fg);
+ }
+
+ :host(:hover) button {
+ color: var(--list-item-bg);
+ }
+
+ :host(:hover) button:hover {
+ color: var(--list-item-fg);
+ }
+
+ :host([layer-visible]) {
+ background: var(--list-item-bg);
+ color: var(--list-item-fg);
+ }
+
+ :host([layer-highlighted]) {
+ background: var(--list-item-active-bg);
+ color: var(--list-item-active-fg);
+ }
+
+ :host([layer-highlighted]:hover) button {
+ color: var(--list-item-fg);
+ }
+
+ :host kc-ui-icon.for-visible,
+ :host([layer-visible]) kc-ui-icon.for-hidden {
+ display: none;
+ }
+
+ :host kc-ui-icon.for-hidden,
+ :host([layer-visible]) kc-ui-icon.for-visible {
+ display: revert;
+ }
+ `]}static{this.select_event="kicanvas:layer-control:select"}static{this.visibility_event="kicanvas:layer-control:visibility"}initialContentCallback(){super.initialContentCallback(),this.renderRoot.addEventListener("click",e=>{e.stopPropagation();let r=e.target?.closest("button"),i;r?i=Ie.visibility_event:i=Ie.select_event,this.dispatchEvent(new CustomEvent(i,{detail:this,bubbles:!0}))})}render(){return _`
+ ${this.layer_name}
+
+ visibility
+ visibility_off
+ `}};P([L({type:String})],Ie.prototype,"layer_name",2),P([L({type:String})],Ie.prototype,"layer_color",2),P([L({type:Boolean})],Ie.prototype,"layer_highlighted",2),P([L({type:Boolean})],Ie.prototype,"layer_visible",2);var Q2=Ie;window.customElements.define("kc-board-layer-control",Q2);window.customElements.define("kc-board-layers-panel",x2);var v2=class extends N{static{l(this,"KCBoardNetsPanelElement")}connectedCallback(){(async()=>(this.viewer=await this.requestLazyContext("viewer"),await this.viewer.loaded,super.connectedCallback()))()}initialContentCallback(){this.addEventListener("kc-ui-menu:select",e=>{let r=e.detail,i=parseInt(r?.name,10);i&&this.viewer.highlight_net(i)}),this.search_input_elm.addEventListener("input",e=>{this.item_filter_elem.filter_text=this.search_input_elm.value??null})}render(){let e=this.viewer.board,r=[];for(let i of e.nets)r.push(_`
+ ${i.number}
+ ${i.name}
+ `);return _`
+
+
+
+
+
+ ${r}
+
+
+
+ `}};P([Q("kc-ui-text-filter-input",!0)],v2.prototype,"search_input_elm",2),P([Q("kc-ui-filtered-list",!0)],v2.prototype,"item_filter_elem",2);window.customElements.define("kc-board-nets-panel",v2);var vi=class extends N{static{l(this,"KCBoardObjectsPanelElement")}connectedCallback(){(async()=>(this.viewer=await this.requestLazyContext("viewer"),await this.viewer.loaded,super.connectedCallback(),this.setup_events()))()}setup_events(){he(this.renderRoot,"kc-ui-range","kc-ui-range:input",e=>{let r=e.target,i=r.valueAsNumber;switch(r.name){case"tracks":this.viewer.track_opacity=i;break;case"vias":this.viewer.via_opacity=i;break;case"pads":this.viewer.pad_opacity=i;break;case"holes":this.viewer.pad_hole_opacity=i;break;case"zones":this.viewer.zone_opacity=i;break;case"grid":this.viewer.grid_opacity=i;break;case"page":this.viewer.page_opacity=i;break}})}render(){return _`
+
+
+
+
+
+ Tracks
+
+
+
+ Vias
+
+
+
+ Pads
+
+
+
+ Through holes
+
+
+
+ Zones
+
+
+
+ Grid
+
+
+
+ Page
+
+
+
+
+
+ `}};window.customElements.define("kc-board-objects-panel",vi);var wi=class extends N{static{l(this,"KCBoardPropertiesPanelElement")}connectedCallback(){(async()=>(this.viewer=await this.requestLazyContext("viewer"),await this.viewer.loaded,super.connectedCallback(),this.setup_events()))()}setup_events(){this.addDisposable(this.viewer.addEventListener(D.type,e=>{this.selected_item=e.detail.item,this.update()}))}render(){let e=l(o=>_`
+ `,"header"),r=l((o,c,u="")=>_`
+ ${c??""} ${u}
+ `,"entry"),i=l(o=>o?_`check `:_`close `,"checkbox"),n;if(!this.selected_item)n=e("No item selected");else{let o=this.selected_item,c=Object.entries(o.properties).map(([u,p])=>r(u,p));n=_`
+ ${e("Basic properties")}
+ ${r("X",o.at.position.x.toFixed(4),"mm")}
+ ${r("Y",o.at.position.y.toFixed(4),"mm")}
+ ${r("Orientation",o.at.rotation,"\xB0")}
+ ${r("Layer",o.layer)} ${e("Footprint properties")}
+ ${r("Reference",o.reference)}
+ ${r("Value",o.value)}
+ ${r("Type",o.attr.through_hole?"through hole":o.attr.smd?"smd":"unspecified")}
+ ${r("Pads",o.pads.length)}
+ ${r("Library link",o.library_link)}
+ ${r("Description",o.descr)}
+ ${r("Keywords",o.tags)} ${c}
+ ${e("Fabrication attributes")}
+ ${r("Not in schematic",i(o.attr.board_only))}
+ ${r("Exclude from position files",i(o.attr.exclude_from_pos_files))}
+ ${r("Exclude from BOM",i(o.attr.exclude_from_bom))}
+ ${e("Overrides")}
+ ${r("Exempt from courtyard requirement",i(o.attr.allow_missing_courtyard))}
+ ${r("Clearance",o.clearance??0,"mm")}
+ ${r("Solderpaste margin",o.solder_paste_margin??0,"mm")}
+ ${r("Solderpaste margin ratio",o.solder_paste_ratio??0)}
+ ${r("Zone connection",o.zone_connect??"inherited")}
+ `}return _`
+
+
+
+ ${n}
+
+
+ `}};window.customElements.define("kc-board-properties-panel",wi);var Yi=class extends Se{static{l(this,"KCBoardAppElement")}on_viewer_select(t,e){t&&t==e&&this.change_activity("properties")}can_load(t){return t.document instanceof ge}make_viewer_element(){return _` `}make_activities(){return[_`
+
+ `,_`
+
+ `,_`
+
+ `,_`
+
+ `,_`
+
+ `,_`
+
+ `]}};window.customElements.define("kc-board-app",Yi);var Q3=class extends Ke{constructor(e){super(e);this.#e=[];this.state=new P2}static{l(this,"Canvas2DRenderer")}#e;#t;async setup(){let e=this.canvas.getContext("2d",{alpha:!1,desynchronized:!0});if(e==null)throw new Error("Unable to create Canvas2d context");this.ctx2d=e,this.update_canvas_size()}dispose(){this.ctx2d=void 0;for(let e of this.#e)e.dispose()}update_canvas_size(){let e=window.devicePixelRatio,r=this.canvas.getBoundingClientRect(),i=Math.round(r.width*e),n=Math.round(r.height*e);(this.canvas.width!=i||this.canvas.height!=n)&&(this.canvas.width=i,this.canvas.height=n)}clear_canvas(){this.update_canvas_size(),this.ctx2d.setTransform(),this.ctx2d.scale(window.devicePixelRatio,window.devicePixelRatio),this.ctx2d.fillStyle=this.background_color.to_css(),this.ctx2d.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx2d.lineCap="round",this.ctx2d.lineJoin="round"}start_layer(e){this.#t=new Ki(this,e)}end_layer(){if(!this.#t)throw new Error("No active layer");return this.#e.push(this.#t),this.#t=null,this.#e.at(-1)}arc(e,r,i,n,o,c){super.prep_arc(e,r,i,n,o,c)}circle(e,r,i){let n=super.prep_circle(e,r,i);if(!n.color||n.color.is_transparent_black)return;let o=n.color.to_css(),c=new Path2D;c.arc(n.center.x,n.center.y,n.radius,0,Math.PI*2),this.#t.commands.push(new Qt(c,o,null,0))}line(e,r,i){let n=super.prep_line(e,r,i);if(!n.color||n.color.is_transparent_black)return;let o=n.color.to_css(),c=new Path2D,u=!1;for(let p of n.points)u?c.lineTo(p.x,p.y):(c.moveTo(p.x,p.y),u=!0);this.#t.commands.push(new Qt(c,null,o,n.width))}polygon(e,r){let i=super.prep_polygon(e,r);if(!i.color||i.color.is_transparent_black)return;let n=i.color.to_css(),o=new Path2D,c=!1;for(let u of i.points)c?o.lineTo(u.x,u.y):(o.moveTo(u.x,u.y),c=!0);o.closePath(),this.#t.commands.push(new Qt(o,n,null,0))}get layers(){let e=this.#e;return{*[Symbol.iterator](){for(let r of e)yield r}}}remove_layer(e){let r=this.#e.indexOf(e);r!=-1&&this.#e.splice(r,1)}},Qt=class{constructor(t,e,r,i){this.path=t;this.fill=e;this.stroke=r;this.stroke_width=i;this.path_count=1}static{l(this,"DrawCommand")}render(t){t.fillStyle=this.fill??"black",t.strokeStyle=this.stroke??"black",t.lineWidth=this.stroke_width,this.fill&&t.fill(this.path),this.stroke&&t.stroke(this.path)}},Ki=class extends He{constructor(e,r,i=[]){super(e,r);this.renderer=e;this.name=r;this.commands=i}static{l(this,"Canvas2dRenderLayer")}dispose(){this.clear()}clear(){this.commands=[]}push_path(e,r,i,n){let o=this.commands.at(-1);o&&(o.path_count<20,o.fill==r&&o.stroke==i&&o.stroke_width==n)?(o.path.addPath(e),o.path_count++):this.commands.push(new Qt(e,r,i,n))}render(e,r,i=1){let n=this.renderer.ctx2d;if(!n)throw new Error("No CanvasRenderingContext2D!");n.save(),n.globalCompositeOperation=this.composite_operation,n.globalAlpha=i;let o=U.from_DOMMatrix(n.getTransform());o.multiply_self(e),n.setTransform(o.to_DOMMatrix());for(let c of this.commands)c.render(n);n.globalCompositeOperation="source-over",n.globalAlpha=1,n.restore()}};var ke=(f=>(f.interactive=":Interactive",f.marks=":Marks",f.symbol_field=":Symbol:Field",f.label=":Label",f.junction=":Junction",f.wire=":Wire",f.symbol_foreground=":Symbol:Foreground",f.notes=":Notes",f.bitmap=":Bitmap",f.symbol_pin=":Symbol:Pin",f.symbol_background=":Symbol:Background",f[f.drawing_sheet=":DrawingSheet"]="drawing_sheet",f[f.grid=":Grid"]="grid",f))(ke||{}),vt=class extends Ut{constructor(e){super();this.theme=e;for(let r of Object.values(ke))this.add(new ae(this,r));this.by_name(":Interactive").visible=!1,this.by_name(":Interactive").interactive=!0,this.by_name(ke.drawing_sheet).color=this.theme.worksheet??h.white}static{l(this,"LayerSet")}*interactive_layers(){yield this.by_name(":Interactive")}};var v3=class extends Ee{static{l(this,"BaseSchematicPainter")}},K=class extends be{static{l(this,"SchematicItemPainter")}get theme(){return this.view_painter.theme}get is_dimmed(){return this.view_painter.current_symbol?.dnp??!1}dim_color(e){return e=e.desaturate(),e.mix(this.theme.background,.5)}dim_if_needed(e){return this.is_dimmed?this.dim_color(e):e}determine_stroke(e,r){let i=r.stroke?.width||this.gfx.state.stroke_width;if(i<0)return{width:0,color:null};if((r.stroke?.type??"none")=="none")return{width:0,color:null};let o=e.name==":Symbol:Foreground"?this.theme.component_outline:this.theme.note,c=this.dim_if_needed(r.stroke?.color??o);return{width:i,color:c}}determine_fill(e,r){let i=r.fill?.type??"none";if(i=="none"||i=="background"&&e.name!=":Symbol:Background")return null;let n;switch(i){case"background":n=this.theme.component_body;break;case"outline":n=this.theme.component_outline;break;case"color":n=r.fill.color;break}return this.dim_if_needed(n)}};var w2=class extends K{constructor(){super(...arguments);this.classes=[]}static{l(this,"LabelPainter")}layers_for(e){return[":Label"]}paint(e,r){if(r.effects.hide)return;let i=new Ot(r.shown_text);i.apply_at(r.at),i.apply_effects(r.effects),this.after_apply(r,i),r.at.rotation==0||r.at.rotation==180?i.text_angle.degrees=0:(r.at.rotation==90||r.at.rotation==270)&&(i.text_angle.degrees=90);let n=i.text_pos.add(this.get_schematic_text_offset(r,i));this.gfx.state.push(),this.gfx.state.stroke=this.color,this.gfx.state.fill=this.color,Y.default().draw(this.gfx,i.shown_text,n,i.attributes);let o=this.create_shape(r,i);o&&this.gfx.line(o,i.attributes.stroke_width/1e4),this.gfx.state.pop()}create_shape(e,r){return[]}get color(){return new h(1,0,1,1)}after_apply(e,r){}get_text_offset(e){return Math.round(A.text_offset_ratio*e.text_size.x)}get_box_expansion(e){return Math.round(A.label_size_ratio*e.text_size.y)}get_schematic_text_offset(e,r){let i=Math.round(this.get_text_offset(r)+r.get_effective_text_thickness());return r.text_angle.is_vertical?new d(-i,0):new d(0,-i)}},w3=class extends w2{constructor(){super(...arguments);this.classes=[d2]}static{l(this,"NetLabelPainter")}get color(){return this.theme.label_local}},Y3=class extends w2{constructor(){super(...arguments);this.classes=[m2]}static{l(this,"GlobalLabelPainter")}get color(){return this.theme.label_global}get_schematic_text_offset(e,r){let i=e,n=r.text_size.y,o=this.get_box_expansion(r),c=n*.0715;switch(["input","bidirectional","tri_state"].includes(i.shape)&&(o+=n*.75),o=Math.round(o),c=Math.round(c),e.at.rotation){case 0:return new d(o,c);case 90:return new d(c,-o);case 180:return new d(-o,c);case 270:return new d(c,o);default:throw new Error(`Unexpected label rotation ${e.at.rotation}`)}}create_shape(e,r){let i=e,n=r.text_pos,o=W.from_degrees(e.at.rotation+180),c=r.text_size.y,u=this.get_box_expansion(r),p=c/2+u,m=r.get_text_box().w+2*u,b=r.attributes.stroke_width,M=m+b+3,f=p+b+3,V=[new d(0,0),new d(0,-f),new d(-M,-f),new d(-M,0),new d(-M,f),new d(0,f),new d(0,0)],S=new d;switch(i.shape){case"input":S.x=-p,V[0].x+=p,V[6].x+=p;break;case"output":V[3].x-=p;break;case"bidirectional":case"tri_state":S.x=-p,V[0].x+=p,V[6].x+=p,V[3].x-=p;break;default:break}return V=V.map(y=>y.add(S).rotate(o).add(n).multiply(1/1e4)),V}},K3=class extends w2{constructor(){super(...arguments);this.classes=[De]}static{l(this,"HierarchicalLabelPainter")}get color(){return this.theme.label_hier}after_apply(e,r){r.v_align="center"}get_schematic_text_offset(e,r){let i=Math.round(this.get_text_offset(r)+r.text_width);switch(e.at.rotation){case 0:return new d(i,0);case 90:return new d(0,-i);case 180:return new d(-i,0);case 270:return new d(0,i);default:throw new Error(`Unexpected label rotation ${e.at.rotation}`)}}create_shape(e,r){let i=r.text_pos,n=W.from_degrees(e.at.rotation),o=r.text_width,c;switch(e.shape){case"output":c=[new d(0,o/2),new d(o/2,o/2),new d(o,0),new d(o/2,-o/2),new d(0,-o/2),new d(0,o/2)];break;case"input":c=[new d(o,o/2),new d(o/2,o/2),new d(0,0),new d(o/2,-o/2),new d(o,-o/2),new d(o,o/2)];break;case"bidirectional":case"tri_state":c=[new d(o/2,o/2),new d(o,0),new d(o/2,-o/2),new d(0,0),new d(o/2,o/2)];break;case"passive":default:c=[new d(0,o/2),new d(o,o/2),new d(o,-o/2),new d(0,-o/2),new d(0,o/2)];break}return c=c.map(u=>u.rotate(n).add(i).multiply(1/1e4)),c}};var H3=class s extends K{constructor(){super(...arguments);this.classes=[b2]}static{l(this,"PinPainter")}layers_for(e){return[":Symbol:Pin",":Symbol:Foreground",":Interactive"]}paint(e,r){if(r.definition.hide)return;let i={pin:r,def:r.definition,position:r.definition.at.position.copy(),orientation:so(r.definition.at.rotation)},n=this.view_painter.current_symbol_transform,o=this.dim_if_needed(this.theme.pin);s.apply_symbol_transformations(i,n),this.gfx.state.push(),this.gfx.state.matrix=U.identity(),this.gfx.state.stroke=o,(e.name==":Symbol:Pin"||e.name==":Interactive")&&this.draw_pin_shape(this.gfx,i),e.name==":Symbol:Foreground"&&this.draw_name_and_number(this.gfx,i),this.gfx.state.pop()}static apply_symbol_transformations(e,r){for(let n=0;n0?(y=p?void 0:wt.place_inside(M,S,u,r.orientation),v=m?void 0:wt.place_above(f,b,V,u,r.orientation)):(y=p?void 0:wt.place_above(f,b,S,u,r.orientation),v=m?void 0:wt.place_below(f,b,S,u,r.orientation)),y&&wt.draw(e,o,r.position,y,i.name.effects,e.state.stroke),v&&wt.draw(e,c,r.position,v,i.number.effects,e.state.stroke)}};function so(s){switch(s){case 0:return"right";case 90:return"up";case 180:return"left";case 270:return"down";default:throw new Error(`Unexpected pin angle ${s}`)}}l(so,"angle_to_orientation");var sn={stem(s,t,e){let r=new d,i=new d;switch(t){case"up":r.set(s.x,s.y-e),i.set(0,1);break;case"down":r.set(s.x,s.y+e),i.set(0,-1);break;case"left":r.set(s.x-e,s.y),i.set(1,0);break;case"right":r.set(s.x+e,s.y),i.set(-1,0);break}return{p0:r,dir:i}},draw(s,t,e,r,i,n){let o=A.pinsymbol_size,c=o*2,u=A.target_pin_radius;if(t=="no_connect"){s.line([i,r]),s.line([r.add(new d(-u,-u)),r.add(new d(u,u))]),s.line([r.add(new d(u,-u)),r.add(new d(-u,u))]);return}let p=l(()=>{n.y?s.line([i.add(new d(o,0)),i.add(new d(0,-n.y*o)),i.add(new d(-o,0))]):s.line([i.add(new d(0,o)),i.add(new d(-n.x*o,0)),i.add(new d(0,-o))])},"clock_notch"),m=l(()=>{n.y?s.line([i.add(new d(0,n.y).multiply(c)),i.add(new d(-1,n.y).multiply(c)),i]):s.line([i.add(new d(n.x,0).multiply(c)),i.add(new d(n.x,-1).multiply(c)),i])},"low_in_tri");switch(e){case"line":s.line([i,r]);return;case"inverted":s.arc(i.add(n.multiply(o)),o),s.line([i.add(n.multiply(c)),r]);return;case"inverted_clock":s.arc(i.add(n.multiply(o)),o),s.line([i.add(n.multiply(c)),r]),p();return;case"clock":s.line([i,r]),p();return;case"clock_low":case"edge_clock_high":s.line([i,r]),p(),m();break;case"input_low":s.line([i,r]),m();break;case"output_low":s.line([i,r]),n.y?s.line([i.sub(new d(c,0)),i.add(new d(0,n.y*c))]):s.line([i.sub(new d(0,c)),i.add(new d(n.x*c,0))]);break;case"non_logic":s.line([i,r]),s.line([i.sub(new d(n.x+n.y,n.y-n.x).multiply(o)),i.add(new d(n.x+n.y,n.y-n.x).multiply(o))]),s.line([i.sub(new d(n.x-n.y,n.y+n.x).multiply(o)),i.add(new d(n.x-n.y,n.y+n.x).multiply(o))]);break}}},wt={orient_label(s,t,e,r){switch(t){case"right":break;case"left":s.x*=-1,e=="left"&&(e="right");break;case"up":s=new d(s.y,-s.x);break;case"down":s=new d(s.y,s.x),e=="left"&&(e="right");break}return{offset:s,h_align:e,v_align:r,orientation:t}},place_inside(s,t,e,r){let i=new d(s-t/2+e,0);return this.orient_label(i,r,"left","center")},place_above(s,t,e,r,i){let n=new d(r/2,-(s+t/2+e/2));return this.orient_label(n,i,"center","bottom")},place_below(s,t,e,r,i){let n=new d(r/2,s+t/2+e/2);return this.orient_label(n,i,"center","top")},draw(s,t,e,r,i,n){let o=new $(t);switch(o.apply_effects(i),o.attributes.h_align=r.h_align,o.attributes.v_align=r.v_align,o.attributes.color=n,o.text_pos=e.add(r.offset).multiply(1e4),r.orientation){case"up":case"down":o.text_angle=W.from_degrees(90);break;case"left":case"right":o.text_angle=W.from_degrees(0);break}Y.default().draw(s,o.shown_text,o.text_pos,o.attributes)}};var Hi=class extends He{constructor(){super(...arguments);this.shapes=[]}static{l(this,"NullRenderLayer")}dispose(){this.clear()}clear(){this.shapes=[]}render(e){}},G3=class extends Ke{static{l(this,"NullRenderer")}#e;constructor(){super(null)}set background_color(t){}async setup(){}async dispose(){}update_canvas_size(){}clear_canvas(){}start_layer(t){this.#e=new Hi(this,t)}end_layer(){return this.#e}get layers(){return[]}circle(t,e,r){this.#e.shapes.push(super.prep_circle(t,e,r))}arc(t,e,r,i,n,o){this.#e.shapes.push(super.prep_arc(t,e,r,i,n,o))}line(t,e,r){this.#e.shapes.push(super.prep_line(t,e,r))}polygon(t,e){this.#e.shapes.push(super.prep_polygon(t,e))}remove_layer(t){}};var E3=class extends K{constructor(){super(...arguments);this.classes=[Vt]}static{l(this,"LibSymbolPainter")}layers_for(e){return[":Symbol:Background",":Symbol:Foreground",":Symbol:Field"]}paint(e,r,i=1){if(![":Symbol:Background",":Symbol:Foreground",":Interactive"].includes(e.name))return;let n=r.units.get(0);n&&this.#e(e,n,i);let o=this.view_painter.current_symbol,c=r.units.get(o?.unit||1);c&&this.#e(e,c,i)}#e(e,r,i=1){for(let n of r)if(!(n.style>0&&i!=n.style))for(let o of n.drawings)this.view_painter.paint_item(e,o)}},J3=class extends K{constructor(){super(...arguments);this.classes=[re]}static{l(this,"SchematicSymbolPainter")}layers_for(e){let r=[":Interactive",":Symbol:Foreground",":Symbol:Background",":Symbol:Field",":Symbol:Pin"];return e.dnp&&r.push(":Marks"),r}paint(e,r){if(e.name==":Interactive"&&r.lib_symbol.power)return;let i=no(r);this.view_painter.current_symbol=r,this.view_painter.current_symbol_transform=i,this.gfx.state.push(),this.gfx.state.matrix=U.translation(r.at.position.x,r.at.position.y),this.gfx.state.multiply(i.matrix);let n=r.convert??1;if(this.view_painter.paint_item(e,r.lib_symbol,n),this.gfx.state.pop(),[":Symbol:Pin",":Symbol:Foreground",":Interactive"].includes(e.name))for(let o of r.unit_pins)this.view_painter.paint_item(e,o);if(e.name==":Symbol:Field"||e.name==":Interactive")for(let[o,c]of r.properties)this.view_painter.paint_item(e,c);if(r.dnp&&e.name==":Marks"){let o=oo(this.theme,r),c=A.line_width*3,u=this.theme.erc_error;this.gfx.line([o.top_left,o.bottom_right],c,u),this.gfx.line([o.bottom_left,o.top_right],c,u)}this.view_painter.current_symbol=void 0}};function no(s){let t=new U([1,0,0,0,-1,0,0,0,1]),e=new U([0,-1,0,-1,0,0,0,0,1]),r=new U([-1,0,0,0,1,0,0,0,1]),i=new U([0,1,0,1,0,0,0,0,1]),n=0,o=t;if(s.at.rotation!=0)if(s.at.rotation==90)n=1,o=e;else if(s.at.rotation==180)n=2,o=r;else if(s.at.rotation==270)n=3,o=i;else throw new Error(`unexpected rotation ${s.at.rotation}`);if(s.mirror=="y"){let c=o.elements[0]*-1,u=o.elements[3]*-1,p=o.elements[1],m=o.elements[4];o.elements[0]=c,o.elements[1]=p,o.elements[3]=u,o.elements[4]=m}else if(s.mirror=="x"){let c=o.elements[0],u=o.elements[3],p=o.elements[1]*-1,m=o.elements[4]*-1;o.elements[0]=c,o.elements[1]=p,o.elements[3]=u,o.elements[4]=m}return{matrix:o,position:s.at.position,rotations:n,mirror_x:s.mirror=="x",mirror_y:s.mirror=="y"}}l(no,"get_symbol_transform");function oo(s,t){let e=new G3,r=new vt(s),i=new Yt(e,r,s),n=[":Symbol:Foreground",":Symbol:Background",":Symbol:Pin"],o=[];for(let c of n){let u=r.by_name(c);u.items.push(t),i.paint_layer(u),o.push(u.bbox)}return O.combine(o)}l(oo,"get_symbol_body_and_pins_bbox");var Gi=class extends K{constructor(){super(...arguments);this.classes=[ft]}static{l(this,"RectanglePainter")}layers_for(e){return[":Notes"]}paint(e,r){let i=[r.start,new d(r.end.x,r.start.y),r.end,new d(r.start.x,r.end.y),r.start];this.#t(e,r,i),this.#e(e,r,i)}#e(e,r,i){let{width:n,color:o}=this.determine_stroke(e,r);!n||!o||this.gfx.line(new F(i,r.stroke?.width||this.gfx.state.stroke_width,o))}#t(e,r,i){let n=this.determine_fill(e,r);n&&this.gfx.polygon(new I(i,n))}},Ei=class extends K{constructor(){super(...arguments);this.classes=[Mt]}static{l(this,"PolylinePainter")}layers_for(e){return[":Notes"]}paint(e,r){this.#t(e,r),this.#e(e,r)}#e(e,r){let{width:i,color:n}=this.determine_stroke(e,r);!i||!n||this.gfx.line(new F(r.pts,i,n))}#t(e,r){let i=this.determine_fill(e,r);i&&this.gfx.polygon(new I(r.pts,i))}},Ji=class extends K{constructor(){super(...arguments);this.classes=[a2]}static{l(this,"WirePainter")}layers_for(e){return[":Wire"]}paint(e,r){this.gfx.line(new F(r.pts,this.gfx.state.stroke_width,this.theme.wire))}},Ii=class extends K{constructor(){super(...arguments);this.classes=[l2]}static{l(this,"BusPainter")}layers_for(e){return[":Wire"]}paint(e,r){this.gfx.line(new F(r.pts,A.bus_width,this.theme.bus))}},ki=class extends K{constructor(){super(...arguments);this.classes=[c2]}static{l(this,"BusEntryPainter")}layers_for(e){return[":Junction"]}paint(e,r){this.gfx.line(new F([r.at.position,r.at.position.add(r.size)],A.wire_width,this.theme.wire))}},Ai=class extends K{constructor(){super(...arguments);this.classes=[p2]}static{l(this,"CirclePainter")}layers_for(e){return[":Notes"]}paint(e,r){this.#t(e,r),this.#e(e,r)}#e(e,r){let{width:i,color:n}=this.determine_stroke(e,r);!i||!n||this.gfx.arc(new Ye(r.center,r.radius,new W(0),new W(Math.PI*2),i,n))}#t(e,r){let i=this.determine_fill(e,r);i&&this.gfx.circle(new B(r.center,r.radius,i))}},Ci=class extends K{constructor(){super(...arguments);this.classes=[_t]}static{l(this,"ArcPainter")}layers_for(e){return[":Notes"]}paint(e,r){let i=z.from_three_points(r.start,r.mid,r.end,r.stroke?.width);this.#t(e,r,i),this.#e(e,r,i)}#e(e,r,i){let{width:n,color:o}=this.determine_stroke(e,r);!n||!o||this.gfx.arc(new Ye(i.center,i.radius,i.start_angle,i.end_angle,n,o))}#t(e,r,i){let n=this.determine_fill(e,r);n&&this.gfx.polygon(new I(i.to_polygon(),n))}},Di=class extends K{constructor(){super(...arguments);this.classes=[R2]}static{l(this,"JunctionPainter")}layers_for(e){return[":Junction"]}paint(e,r){let i=this.theme.junction;this.gfx.circle(new B(r.at.position,(r.diameter||1)/2,i))}},Bi=class extends K{constructor(){super(...arguments);this.classes=[u2]}static{l(this,"NoConnectPainter")}layers_for(e){return[":Junction"]}paint(e,r){let i=this.theme.no_connect,n=A.line_width,o=A.noconnect_size/2;this.gfx.state.push(),this.gfx.state.matrix.translate_self(r.at.position.x,r.at.position.y),this.gfx.line(new F([new d(-o,-o),new d(o,o)],n,i)),this.gfx.line(new F([new d(o,-o),new d(-o,o)],n,i)),this.gfx.state.pop()}},$i=class extends K{constructor(){super(...arguments);this.classes=[Nt]}static{l(this,"TextPainter")}layers_for(e){return[":Notes"]}paint(e,r){if(r.effects.hide||!r.text)return;let i=new Ot(r.shown_text);i.apply_at(r.at),i.apply_effects(r.effects);let n=r.effects.font.color;if(n.is_transparent_black){let o=this.theme.note;i.attributes.color=this.dim_if_needed(o)}else i.attributes.color=this.dim_if_needed(n);this.gfx.state.push(),Y.default().draw(this.gfx,i.shown_text,i.text_pos,i.attributes),this.gfx.state.pop()}},ji=class extends K{constructor(){super(...arguments);this.classes=[we]}static{l(this,"PropertyPainter")}layers_for(e){return[":Symbol:Field",":Interactive"]}paint(e,r){if(r.effects.hide||!r.text)return;let i=this.theme.fields;r.parent instanceof ne&&(i=this.theme.sheet_fields);let n=r.effects.font.color;if(n.is_transparent_black){switch(r.name){case"Reference":i=this.theme.reference;break;case"Value":i=this.theme.value;break;case"Sheet name":i=this.theme.sheet_name;break;case"Sheet file":i=this.theme.sheet_filename;break}i=this.dim_if_needed(i)}else i=this.dim_if_needed(n);let o=r.parent,u=this.view_painter.current_symbol_transform?.matrix??U.identity(),p=r.shown_text;r.name=="Reference"&&o.unit&&(p+=o.unit_suffix);let m=new P3(p,{position:o.at.position.multiply(1e4),transform:u,is_symbol:o instanceof re});m.apply_effects(r.effects),m.attributes.angle=W.from_degrees(r.at.rotation);let b=r.at.position.multiply(1e4).sub(m.parent.position);b=u.inverse().transform(b),b=b.add(m.parent.position),m.text_pos=b;let M=m.draw_rotation,f=m.bounding_box,V=f.center;m.attributes.angle=M,m.attributes.h_align="center",m.attributes.v_align="center",m.attributes.stroke_width=m.get_effective_text_thickness(A.line_width*1e4),m.attributes.color=i;let S=U.scaling(1e-4,1e-4).transform_all([f.top_left,f.top_right,f.bottom_right,f.bottom_left,f.top_left]);e.name==":Interactive"?this.gfx.line(new F(Array.from(S),.1,h.white)):(this.gfx.state.push(),Y.default().draw(this.gfx,m.shown_text,V,m.attributes),this.gfx.state.pop())}},zi=class extends K{constructor(){super(...arguments);this.classes=[h2]}static{l(this,"LibTextPainter")}layers_for(e){return[":Symbol:Foreground"]}paint(e,r){if(r.effects.hide||!r.text)return;let i=this.view_painter.current_symbol_transform,n=new g3(r.shown_text);n.apply_effects(r.effects),n.apply_at(r.at),n.apply_symbol_transformations(i),n.attributes.color=this.dim_if_needed(this.theme.component_outline);let o=n.world_pos;n.attributes.v_align="center",this.gfx.state.push(),this.gfx.state.matrix=U.identity(),Y.default().draw(this.gfx,n.shown_text,o,n.attributes),this.gfx.state.pop()}paint_debug(e){this.gfx.line(F.from_BBox(e.scale(1/1e4),.127,new h(0,0,1,1))),this.gfx.circle(new B(e.center.multiply(1/1e4),.2,new h(0,1,0,1)))}},qi=class extends K{constructor(){super(...arguments);this.classes=[ne]}static{l(this,"SchematicSheetPainter")}layers_for(e){return[":Interactive",":Label",":Symbol:Foreground",":Symbol:Background",":Symbol:Field"]}paint(e,r){let i=this.theme.sheet,n=this.theme.sheet_background,o=new O(r.at.position.x,r.at.position.y,r.size.x,r.size.y);if(e.name==":Interactive"&&this.gfx.polygon(I.from_BBox(o.grow(3),n)),e.name==":Symbol:Background"&&this.gfx.polygon(I.from_BBox(o,n)),e.name==":Symbol:Foreground"&&this.gfx.line(F.from_BBox(o,this.gfx.state.stroke_width,i)),e.name==":Symbol:Field")for(let c of r.properties.values())this.view_painter.paint_item(e,c);if(e.name==":Label")for(let c of r.pins){let u=new De;switch(u.at=c.at.copy(),u.effects=c.effects,u.text=c.name,u.shape=c.shape,u.at.rotation){case 0:u.at.rotation=180;break;case 180:u.at.rotation=0;break;case 90:u.at.rotation=270;break;case 270:u.at.rotation=90;break}c.shape=="input"?u.shape="output":c.shape=="output"&&(u.shape="input"),this.view_painter.paint_item(e,u)}}},Yt=class extends v3{constructor(e,r,i){super(e,r,i);this.painter_list=[new Gi(this,e),new Ei(this,e),new Ji(this,e),new Ii(this,e),new ki(this,e),new Ai(this,e),new Ci(this,e),new Di(this,e),new Bi(this,e),new $i(this,e),new zi(this,e),new H3(this,e),new E3(this,e),new ji(this,e),new J3(this,e),new w3(this,e),new Y3(this,e),new K3(this,e),new qi(this,e)]}static{l(this,"SchematicPainter")}};var I3=class extends Ft{static{l(this,"SchematicViewer")}get schematic(){return this.document}create_renderer(t){let e=new Q3(t);return e.state.fill=this.theme.note,e.state.stroke=this.theme.note,e.state.stroke_width=.1524,e}async load(t){if(t instanceof me)return await super.load(t);this.document=null;let e=t.document;return e.update_hierarchical_data(t.sheet_path),await super.load(e)}create_painter(){return new Yt(this.renderer,this.layers,this.theme)}create_layer_set(){return new vt(this.theme)}select(t){if(G(t)&&(t=this.schematic.find_symbol(t)??this.schematic.find_sheet(t)),t instanceof re||t instanceof ne){let e=this.layers.query_item_bboxes(t);t=Ct(e)??null}super.select(t)}};var es=class extends Le{static{l(this,"KCSchematicViewerElement")}update_theme(){this.viewer.theme=this.themeObject.schematic}make_viewer(){return new I3(this.canvas,!this.disableinteraction,this.themeObject.schematic)}};window.customElements.define("kc-schematic-viewer",es);var ts=class extends N{static{l(this,"KCSchematicInfoPanel")}connectedCallback(){(async()=>(this.viewer=await this.requestLazyContext("viewer"),await this.viewer.loaded,super.connectedCallback(),this.addDisposable(this.viewer.addEventListener(ie.type,e=>{this.update()}))))()}render(){let e=this.viewer.drawing_sheet,r=this.viewer.schematic,i=l(c=>_` `,"header"),n=l((c,u,p="")=>_`
+ ${u} ${p}
+ `,"entry"),o=Object.entries(r.title_block?.comment||{}).map(([c,u])=>n(`Comment ${c}`,u));return _`
+
+
+
+
+ ${i("Page properties")}
+ ${n("Size",e.paper?.size)}
+ ${n("Width",e.width,"mm")}
+ ${n("Height",e.height,"mm")}
+ ${i("Schematic properties")}
+ ${n("KiCAD version",r.version)}
+ ${n("Generator",r.generator)}
+ ${n("Title",r.title_block?.title)}
+ ${n("Date",r.title_block?.date)}
+ ${n("Revision",r.title_block?.rev)}
+ ${n("Company",r.title_block?.company)}
+ ${o}
+ ${n("Symbols",r.symbols.size)}
+ ${n("Unique symbols",r.lib_symbols?.symbols.length??0)}
+ ${n("Wires",r.wires.length)}
+ ${n("Buses",r.buses.length)}
+ ${n("Junctions",r.junctions.length)}
+ ${n("Net labels",r.net_labels.length)}
+ ${n("Global labels",r.global_labels.length)}
+ ${n("Hierarchical labels",r.hierarchical_labels.length)}
+ ${n("No connects",r.no_connects.length)}
+
+
+
+ `}};window.customElements.define("kc-schematic-info-panel",ts);var rs=class extends N{static{l(this,"KCSchematicPropertiesPanelElement")}connectedCallback(){(async()=>(this.viewer=await this.requestLazyContext("viewer"),await this.viewer.loaded,super.connectedCallback(),this.setup_events()))()}setup_events(){this.addDisposable(this.viewer.addEventListener(D.type,e=>{this.selected_item=e.detail.item,this.update()})),this.addDisposable(this.viewer.addEventListener(ie.type,e=>{this.selected_item=void 0,this.update()}))}render(){let e=l(c=>_` `,"header"),r=l((c,u,p="")=>_`
+ ${u??""} ${p}
+ `,"entry"),i=l(c=>c?_`check `:_`close `,"checkbox"),n,o=this.selected_item;if(!o)n=e("No item selected");else if(o instanceof re){let c=o.lib_symbol,u=Array.from(o.properties.values()).map(m=>r(m.name,m.text)),p=pe(o.unit_pins,m=>m.number).map(m=>r(m.number,m.definition.name.text));n=_`
+ ${e("Basic properties")}
+ ${r("X",o.at.position.x.toFixed(4),"mm")}
+ ${r("Y",o.at.position.y.toFixed(4),"mm")}
+ ${r("Orientation",o.at.rotation,"\xB0")}
+ ${r("Mirror",o.mirror=="x"?"Around X axis":o.mirror=="y"?"Around Y axis":"Not mirrored")}
+ ${e("Instance properties")}
+ ${r("Library link",o.lib_name??o.lib_id)}
+ ${o.unit?r("Unit",String.fromCharCode("A".charCodeAt(0)+o.unit-1)):""}
+ ${r("In BOM",i(o.in_bom))}
+ ${r("On board",i(o.in_bom))}
+ ${r("Populate",i(!o.dnp))} ${e("Fields")}
+ ${u} ${e("Symbol properties")}
+ ${r("Name",c.name)}
+ ${r("Description",c.description)}
+ ${r("Keywords",c.keywords)}
+ ${r("Power",i(c.power))}
+ ${r("Units",c.unit_count)}
+ ${r("Units are interchangeable",i(c.units_interchangable))}
+ ${e("Pins")} ${p}
+ `}else if(o instanceof ne){let c=Array.from(o.properties.values()).map(p=>r(p.name,p.text)),u=pe(o.pins,p=>p.name).map(p=>r(p.name,p.shape));n=_`
+ ${e("Basic properties")}
+ ${r("X",o.at.position.x.toFixed(4),"mm")}
+ ${r("Y",o.at.position.y.toFixed(4),"mm")}
+ ${e("Fields")} ${c} ${e("Pins")} ${u}
+ `}return _`
+
+
+
+ ${n}
+
+
+ `}};window.customElements.define("kc-schematic-properties-panel",rs);var Kt=class extends N{static{l(this,"KCSchematicSymbolsPanelElement")}connectedCallback(){(async()=>(this.viewer=await this.requestLazyContext("viewer"),await this.viewer.loaded,super.connectedCallback(),this.setup_initial_events()))()}setup_initial_events(){let e=!1;this.addEventListener("kc-ui-menu:select",r=>{if(e)return;let i=r.detail;i.name&&this.viewer.select(i.name)}),this.addDisposable(this.viewer.addEventListener(D.type,()=>{e=!0,this.menu.selected=this.viewer.selected?.context.uuid??null,e=!1})),this.addDisposable(this.viewer.addEventListener(ie.type,()=>{this.update()}))}renderedCallback(){this.search_input_elm.addEventListener("input",e=>{this.item_filter_elem.filter_text=this.search_input_elm.value??null})}render(){let e=this.viewer.schematic,r=[],i=[],n=[],o=pe(Array.from(e.symbols.values()),u=>u.reference);for(let u of o){let p=`${u.reference} ${u.value} ${u.id} ${u.lib_symbol.name}`,m=_`
+ ${u.reference}
+ ${u.value}
+ `;u.lib_symbol.power?i.push(m):r.push(m)}let c=pe(e.sheets,u=>u.sheetname??u.sheetfile??"");for(let u of c){let p=`${u.sheetname} ${u.sheetfile}`;n.push(_`
+ ${u.sheetname}
+ ${u.sheetfile}
+ `)}return _`
+
+
+
+
+
+
+ ${r}
+ ${i.length?_`Power symbols `:null}
+ ${i}
+ ${n.length?_`Sheets `:null}
+ ${n}
+
+
+
+
+ `}};P([Q("kc-ui-menu")],Kt.prototype,"menu",2),P([Q("kc-ui-text-filter-input",!0)],Kt.prototype,"search_input_elm",2),P([Q("kc-ui-filtered-list",!0)],Kt.prototype,"item_filter_elem",2);window.customElements.define("kc-schematic-symbols-panel",Kt);var is=class extends Se{static{l(this,"KCSchematicAppElement")}on_viewer_select(t,e){if(!(!t||t!=e)){if(t instanceof ne){this.project.set_active_page(`${t.sheetfile}:${t.path}/${t.uuid}`);return}this.change_activity("properties")}}can_load(t){return t.document instanceof me}make_viewer_element(){return _` `}make_activities(){return[_`
+
+ `,_`
+
+ `,_`
+
+ `]}};window.customElements.define("kc-schematic-app",is);var k3=`:host{font-size:var(--font-size, 16px);--transition-time-very-short: .1s;--transition-time-short: .2s;--transition-time-medium: .5s;--bg: #131218;--fg: #f8f8f0;--tooltip-bg: #8864cb;--tooltip-fg: #f8f8f0;--tooltip-border: 1px solid #131218;--scrollbar-bg: #131218;--scrollbar-fg: #ae81ff66;--scrollbar-active-fg: #ae81ff;--scrollbar-hover-bg: #ae81ffbb;--activity-bar-bg: #282634;--activity-bar-fg: #f8f8f0;--activity-bar-active-bg: #131218;--activity-bar-active-fg: #f8f8f0;--resizer-bg: #ae81ff;--resizer-active-bg: #ae81ffbb;--panel-bg: #131218;--panel-fg: #f8f8f0;--panel-border: 2px solid #282634;--panel-title-bg: #8077a8;--panel-title-fg: #f8f8f0;--panel-title-border: 1px solid #634e89;--panel-title-button-bg: transparent;--panel-title-button-fg: #dcc8ff;--panel-title-button-hover-bg: #ae81ff;--panel-title-button-hover-fg: inherit;--panel-title-button-disabled-bg: inherit;--panel-title-button-disabled-fg: #888;--panel-subtitle-bg: #634e89;--panel-subtitle-fg: var(--panel-fg);--dropdown-bg: #464258;--dropdown-fg: #f8f8f0;--button-bg: #81eeff;--button-fg: #131218;--button-hover-bg: #a3f3ff;--button-hover-fg: #131218;--button-focus-outline: 1px solid #ae81ff;--button-selected-bg: #ae81ff;--button-selected-fg: #131218;--button-disabled-bg: #131218;--button-disabled-fg: #888;--button-success-bg: #64cb96;--button-success-fg: #131218;--button-success-hover-bg: #81ffbe;--button-success-hover-fg: #131218;--button-danger-bg: #cb6488;--button-danger-fg: #131218;--button-danger-hover-bg: #ff81ad;--button-danger-hover-fg: #131218;--button-outline-bg: #282634;--button-outline-fg: #f8f8f0;--button-outline-hover-bg: #282634;--button-outline-hover-fg: #81eeff;--button-outline-disabled-bg: #131218;--button-outline-disabled-fg: #888;--button-toolbar-bg: #282634;--button-toolbar-fg: #f8f8f0;--button-toolbar-hover-bg: #282634;--button-toolbar-hover-fg: #81eeff;--button-toolbar-disabled-bg: #131218;--button-toolbar-disabled-fg: #888;--button-menu-bg: transparent;--button-menu-fg: #f8f8f0;--button-menu-hover-bg: transparent;--button-menu-hover-fg: #81eeff;--button-menu-disabled-bg: transparent;--button-menu-disabled-fg: #888;--input-bg: #131218;--input-fg: #f8f8f0;--input-border: 1px solid #8077a8;--input-accent: #ae81ff;--input-hover-shadow: 1px 1px 10px 5px rgba(0, 0, 0, .2);--input-focus-outline: 1px solid #ae81ff;--input-placeholder: #8077a8;--input-disabled-bg: #131218;--input-disabled-fg: #888;--input-range-bg: #8077a8;--input-range-fg: #f8f8f0;--input-range-hover-bg: #ae81ff;--input-range-disabled-bg: #131218;--input-range-hover-shadow: 1px 1px 10px 5px rgba(0, 0, 0, .2);--input-range-handle-shadow: 1px 1px 5px 5px rgba(180, 180, 180, .2);--list-item-bg: var(--panel-bg);--list-item-fg: var(--panel-fg);--list-item-active-bg: #634e89;--list-item-active-fg: var(--list-item-fg);--list-item-hover-bg: #64cb96;--list-item-hover-fg: var(--list-item-bg);--list-item-disabled-bg: var(--list-item-bg);--list-item-disabled-fg: #888;--grid-outline: #433e56}:host{--gradient-purple-green-light: linear-gradient( 190deg, hsl(261deg 27% 42%) 0%, hsl(243deg 27% 42%) 17%, hsl(224deg 27% 42%) 33%, hsl(205deg 27% 42%) 50%, hsl(187deg 27% 42%) 67%, hsl(168deg 27% 42%) 83%, hsl(149deg 27% 42%) 100% ) 0 0 fixed;--gradient-purple-blue-medium: linear-gradient( 190deg, hsl(261deg 28% 30%) 0%, hsl(248deg 30% 31%) 17%, hsl(235deg 32% 32%) 33%, hsl(222deg 34% 33%) 50%, hsl(209deg 35% 34%) 67%, hsl(197deg 37% 35%) 83%, hsl(183deg 38% 36%) 100% ) 0 0 fixed;--gradient-purple-blue-dark: linear-gradient(10deg, #111928, #1d162a) 0 0 fixed;--gradient-cyan-blue-light: linear-gradient( 190deg, hsl(183deg 63% 33%) 0%, hsl(189deg 69% 30%) 17%, hsl(194deg 74% 27%) 33%, hsl(199deg 79% 24%) 50%, hsl(203deg 85% 21%) 67%, hsl(209deg 89% 18%) 83%, hsl(214deg 95% 15%) 100% ) 0 0 fixed;--gradient-purple-green-highlight: linear-gradient( 190deg, hsl(261deg 27% 53%) 0%, hsl(243deg 27% 52%) 17%, hsl(224deg 27% 52%) 33%, hsl(205deg 27% 51%) 50%, hsl(186deg 27% 51%) 67%, hsl(168deg 27% 50%) 83%, hsl(149deg 27% 50%) 100% ) 0 0 fixed;--gradient-purple-red: linear-gradient(90deg, #8864cb, #cb6488) 0 0 fixed;--gradient-purple-red-highlight: linear-gradient(90deg, #b187ff, #ff80ac) 0 0 fixed;--scrollbar-bg: var(--gradient-purple-blue-dark);--scrollbar-fg: var(--gradient-purple-green-light);--scrollbar-hover-fg: var(--scrollbar-fg);--scrollbar-active-fg: var(--scrollbar-fg);--activity-bar-bg: var(--gradient-purple-green-light);--resizer-bg: var(--gradient-purple-blue-medium);--resizer-active-bg: var(--gradient-purple-green-highlight);--panel-bg: var(--gradient-purple-blue-dark);--panel-title-bg: var(--gradient-purple-green-light);--panel-subtitle-bg: var(--gradient-purple-blue-medium);--button-toolbar-bg: var(--gradient-purple-blue-dark);--button-toolbar-hover-bg: var(--gradient-purple-green-light);--button-toolbar-hover-fg: #f8f8f0;--button-toolbar-disabled-bg: var(--gradient-purple-blue-dark);--button-toolbar-alt-bg: var(--gradient-purple-green-light);--button-toolbar-alt-hover-bg: var(--gradient-purple-green-highlight);--button-toolbar-alt-hover-fg: #f8f8f0;--button-toolbar-alt-disabled-bg: var(--gradient-purple-blue-dark);--dropdown-bg: var(--gradient-purple-green-light);--dropdown-fg: #f8f8f0;--dropdown-hover-bg: var(--gradient-purple-green-highlight);--dropdown-hover-fg: #f8f8f0;--dropdown-active-bg: var(--gradient-purple-blue-dark);--dropdown-active-fg: #f8f8f0;--input-range-bg: var(--gradient-purple-green-light);--list-item-hover-bg: var(--gradient-purple-green-highlight);--list-item-active-bg: var(--gradient-cyan-blue-light);--focus-overlay-bg: var(--gradient-purple-green-light);--focus-overlay-opacity: .5;--focus-overlay-fg: #f8f8f0}::-webkit-scrollbar{position:absolute;width:6px;height:6px;margin-left:-6px;background:var(--scrollbar-bg)}::-webkit-scrollbar-thumb{position:absolute;background:var(--scrollbar-fg)}::-webkit-scrollbar-thumb:hover{background:var(--scrollbar-hover-fg)}::-webkit-scrollbar-thumb:active{background:var(--scrollbar-active-fg)}kc-ui-app{width:100%;height:100%;flex-grow:1;display:flex;flex-direction:row;overflow:hidden}label{display:block;width:100%;margin-top:.75em}input,select,textarea{all:unset;box-sizing:border-box;display:block;width:100%;max-width:100%;margin-top:.5em;font-family:inherit;border-radius:.25em;text-align:center;padding:.25em;background:var(--input-bg);color:var(--input-fg);transition:color var(--transition-time-medium) ease,box-shadow var(--transition-time-medium) ease,outline var(--transition-time-medium) ease,background var(--transition-time-medium) ease,border var(--transition-time-medium) ease}input:hover,select:hover,textarea:hover{z-index:10;box-shadow:var(--input-hover-shadow)}input:focus,select:focus,textarea:focus{z-index:10;box-shadow:none;outline:var(--input-focus-outline)}input:disabled,select:disabled,textarea:disabled{background:var(--input-disabled-bg);color:var(--input-disabled-fg)}input:disabled:hover,select:disabled:hover,textarea:disabled:hover{z-index:10;cursor:unset}input[type=color]::-webkit-color-swatch{border:1px solid transparent;border-radius:.25em}textarea{text-align:left;padding:.5em}
+`;var nn=`*,*:before,*:after{box-sizing:border-box}:host{box-sizing:border-box;margin:0;display:flex;position:relative;width:100%;height:100%;color:var(--fg)}:host([loaded]) section.overlay,:host([loading]) section.overlay{display:none}:host main{display:contents}section.overlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;display:flex;flex-direction:column;align-items:center;justify-content:center;background:var(--gradient-purple-blue-dark)}section.overlay h1{display:flex;margin:0 auto;align-items:center;justify-content:center;font-size:5em;font-weight:300;text-shadow:0 0 5px var(--gradient-purple-red)}section.overlay h1 img{width:1.5em}section.overlay p{text-align:center;font-size:1.5em;max-width:50%}section.overlay strong{background:var(--gradient-purple-red-highlight);-webkit-background-clip:text;-moz-background-clip:text;background-clip:text;color:transparent}section.overlay a{color:#81eeff}section.overlay a:hover{color:#a3f3ff}section.overlay input{font-size:1.5em;color:var(--fg);background:var(--gradient-purple-red);max-width:50%}section.overlay input::placeholder{color:var(--fg)}section.overlay p.note{color:var(--input-placeholder);font-size:1em}section.overlay p.github img{width:2em}kc-board-viewer,kc-schematic-viewer{width:100%;height:100%;flex:1}.split-horizontal{display:flex;flex-direction:column;height:100%;max-height:100%;overflow:hidden}.split-vertical{display:flex;flex-direction:row;width:100%;max-width:100%;height:100%;overflow:hidden}kc-board-app,kc-schematic-app{width:100%;height:100%;flex:1}
+`;Jt.sprites_url=Ss;var tt=class extends N{constructor(){super();this.project=new Wt;this.provideContext("project",this.project)}static{l(this,"KiCanvasShellElement")}static{this.styles=[...N.styles,new Ne(k3),new Ne(nn)]}#e;#t;initialContentCallback(){let r=new URLSearchParams(document.location.search).getAll("github");ue(async()=>{if(this.src){let i=new st([this.src]);await this.setup_project(i);return}if(r.length){let i=await N2.fromURLs(...r);await this.setup_project(i);return}new K2(this,async i=>{await this.setup_project(i)})}),this.link_input.addEventListener("input",async i=>{let n=this.link_input.value;if(!$e.parse_url(n))return;let o=await N2.fromURLs(n);await this.setup_project(o);let c=new URL(window.location.href);c.searchParams.set("github",n),window.history.pushState(null,"",c)})}async setup_project(e){this.loaded=!1,this.loading=!0;try{await this.project.load(e),this.project.set_active_page(this.project.first_page),this.loaded=!0}catch(r){console.error(r)}finally{this.loading=!1}}render(){return this.#e=_`
+
+ `,this.#t=_`
+
+ `,_`
+
+
+
+
+ KiCanvas
+
+
+ KiCanvas is an
+ interactive
+ ,
+ browser-based
+ viewer for KiCAD schematics and boards. You can learn
+ more from the
+ docs . It's in
+ alpha
+ so please
+
+ report any bugs !
+
+
+ or drag & drop your KiCAD files
+
+ KiCanvas is
+ free & open source
+ and supported by
+ community donations
+ with significant support from
+ PartsBox ,
+ Blues ,
+ Mithro ,
+ Jeremy Gordon ,
+ &
+ James Neal . KiCanvas runs entirely within your browser, so your
+ files don't ever leave your machine.
+
+
+
+
+
+
+
+ ${this.#e} ${this.#t}
+
+ `}};P([L({type:Boolean})],tt.prototype,"loading",2),P([L({type:Boolean})],tt.prototype,"loaded",2),P([L({type:String})],tt.prototype,"src",2),P([Q('input[name="link"]',!0)],tt.prototype,"link_input",2);window.customElements.define("kc-kicanvas-shell",tt);var _e=class extends N{constructor(){super();this.#e=new Wt;this.custom_resolver=null;this.provideContext("project",this.#e)}static{l(this,"KiCanvasEmbedElement")}static{this.styles=[...N.styles,new Ne(k3),T`
+ :host {
+ margin: 0;
+ display: flex;
+ position: relative;
+ width: 100%;
+ max-height: 100%;
+ aspect-ratio: 1.414;
+ background-color: aqua;
+ color: var(--fg);
+ font-family: "Nunito", ui-rounded, "Hiragino Maru Gothic ProN",
+ Quicksand, Comfortaa, Manjari, "Arial Rounded MT Bold",
+ Calibri, source-sans-pro, sans-serif;
+ contain: layout paint;
+ }
+
+ main {
+ display: contents;
+ }
+
+ kc-board-app,
+ kc-schematic-app {
+ width: 100%;
+ height: 100%;
+ flex: 1;
+ }
+ `]}#e;#t;#r;initialContentCallback(){this.#i(),ue(()=>{this.#s()})}async#i(){}async#s(){let e=[];this.src&&e.push(this.src);for(let i of this.querySelectorAll("kicanvas-source"))i.src&&e.push(i.src);if(e.length==0){console.warn("No valid sources specified");return}let r=new st(e,this.custom_resolver);await this.#n(r)}async#n(e){this.loaded=!1,this.loading=!0;try{await this.#e.load(e),this.loaded=!0,await this.update(),this.#e.set_active_page(this.#e.root_schematic_page)}finally{this.loading=!1}}render(){if(!this.loaded)return _``;this.#e.has_schematics&&!this.#t&&(this.#t=_`
+ `),this.#e.has_boards&&!this.#r&&(this.#r=_`
+ `);let e=(this.controls??"none")=="none"||this.controlslist?.includes("nooverlay")?null:_` `;return _`
+ ${this.#t} ${this.#r} ${e}
+ `}};P([L({type:String})],_e.prototype,"src",2),P([L({type:Boolean})],_e.prototype,"loading",2),P([L({type:Boolean})],_e.prototype,"loaded",2),P([L({type:String})],_e.prototype,"controls",2),P([L({type:String})],_e.prototype,"controlslist",2),P([L({type:String})],_e.prototype,"theme",2),P([L({type:String})],_e.prototype,"zoom",2);window.customElements.define("kicanvas-embed",_e);var A3=class extends Oe{constructor(){super();this.ariaHidden="true",this.hidden=!0,this.style.display="none"}static{l(this,"KiCanvasSourceElement")}};P([L({type:String})],A3.prototype,"src",2);window.customElements.define("kicanvas-source",A3);document.body.appendChild(_` `);