tscircuit 0.0.841 → 0.0.842-libonly

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.
@@ -5564,7 +5564,7 @@ You passed in: '`+this.raw_options[o]+"'");return c},t.prototype._is_valid_selec
5564
5564
  `);break}}return s}}}),RFn=gh({"node_modules/pretty/index.js"(n,e){var t=EFn(),i=PFn(),r=Nht(),o={unformatted:["code","pre","em","strong","span"],indent_inner_html:!0,indent_char:" ",indent_size:2,sep:`
5565
5565
  `};e.exports=function(c,l){var u=r({},o,l);return c=t.html(c,u),u.ocd===!0?(u.newlines&&(u.sep=u.newlines),s(c,u)):c};function s(a,c){return i(a,c).replace(/^\s+/g,"").replace(/\s+$/g,`
5566
5566
  `).replace(/(\s*<!--)/g,`
5567
- $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function kht(n,e,t){if(!e||!t)return;let i=n.get(e);i||(i=new Set,n.set(e,i)),i.add(t);let r=n.get(t);r||(r=new Set,n.set(t,r)),r.add(e)}function IFn(n,e){if(!e.subcircuit_id&&!e.source_group_id)return[...n];const t=new Map;for(const s of n){const a=s[`${s.type}_id`];typeof a=="string"&&t.set(a,s)}const i=new Map;for(const s of n){const a=Object.entries(s);for(const[c,l]of a)if(c!=="parent_source_group_id"){if(c.endsWith("_id")&&typeof l=="string"){const u=t.get(l);kht(i,s,u)}else if(c.endsWith("_ids")&&Array.isArray(l)){for(const u of l)if(typeof u=="string"){const d=t.get(u);kht(i,s,d)}}}}const r=[],o=new Set;for(const s of n)(e.subcircuit_id&&s.subcircuit_id===e.subcircuit_id||e.source_group_id&&(s.source_group_id===e.source_group_id||Array.isArray(s.member_source_group_ids)&&s.member_source_group_ids.includes(e.source_group_id)))&&(r.push(s),o.add(s));for(;r.length>0;){const s=r.shift(),a=i.get(s);if(a)for(const c of a)o.has(c)||(o.add(c),r.push(c))}return n.filter(s=>o.has(s))}var eq=(n,e={})=>{const t=n;let i=t._internal_store;if(!i){i={counts:{},editCount:0},t._internal_store=i;for(const o of t){const s=o.type,a=o[`${s}_id`];if(!a)continue;const c=Number.parseInt(a.split("_").pop());Number.isNaN(c)||(i.counts[s]=Math.max(i.counts[s]??0,c))}}return new Proxy({},{get:(o,s)=>{if(s==="toArray")return()=>(t.editCount=i.editCount,t);if(s==="editCount")return i.editCount;if(s==="subtree")return c=>eq(IFn(t,c),e);const a=s;return{get:c=>t.find(l=>l.type===a&&l[`${a}_id`]===c),getUsing:c=>{const l=Object.keys(c);if(l.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const u=l[0],d=u.replace("_id",""),h=t.find(p=>p.type===d&&p[u]===c[u]);return h?t.find(p=>p.type===a&&p[`${a}_id`]===h[`${a}_id`]):null},getWhere:c=>{const l=Object.keys(c);return t.find(u=>u.type===a&&l.every(d=>u[d]===c[d]))},list:c=>{const l=c?Object.keys(c):[];return t.filter(u=>u.type===a&&l.every(d=>u[d]===c[d]))},insert:c=>{i.counts[a]??=-1,i.counts[a]++;const l=i.counts[a],u={type:a,[`${a}_id`]:`${a}_${l}`,...c};return e.validateInserts&&(Fdt[a]??zbe).parse(u),t.push(u),i.editCount++,u},delete:c=>{const l=t.find(u=>u[`${a}_id`]===c);l&&(t.splice(t.indexOf(l),1),i.editCount++)},update:(c,l)=>{const u=t.find(d=>d.type===a&&d[`${a}_id`]===c);return u?(Object.assign(u,l),i.editCount++,u):null},select:c=>{if(a==="source_component")return t.find(l=>l.type==="source_component"&&l.name===c.replace(/\./g,""));if(a==="pcb_port"||a==="source_port"||a==="schematic_port"){const[l,u]=c.replace(/\./g,"").split(/[\s\>]+/),d=t.find(p=>p.type==="source_component"&&p.name===l);if(!d)return null;const h=t.find(p=>p.type==="source_port"&&p.source_component_id===d.source_component_id&&(p.name===u||(p.port_hints??[]).includes(u)));if(!h)return null;if(a==="source_port")return h;if(a==="pcb_port")return t.find(p=>p.type==="pcb_port"&&p.source_port_id===h.source_port_id);if(a==="schematic_port")return t.find(p=>p.type==="schematic_port"&&p.source_port_id===h.source_port_id)}}}}})};eq.unparsed=eq;var fC=eq;function cve(n){const e=n.type;return`${e}:${n[`${e}_id`]}`}var Oht=(n,e={})=>{let t=n._internal_store_indexed;if(!t){t={counts:{},editCount:0,indexes:{}};for(const s of n){const a=s.type,c=s[`${a}_id`];if(!c)continue;const l=Number.parseInt(c.split("_").pop()||"");Number.isNaN(l)||(t.counts[a]=Math.max(t.counts[a]??0,l))}const r=e.indexConfig||{},o=t.indexes;if(r.byId&&(o.byId=new Map),r.byType&&(o.byType=new Map),r.byRelation&&(o.byRelation=new Map),r.bySubcircuit&&(o.bySubcircuit=new Map),r.byCustomField&&r.byCustomField.length>0){o.byCustomField=new Map;for(const s of r.byCustomField)o.byCustomField.set(s,new Map)}for(const s of n){if(r.byId){const a=cve(s);o.byId.set(a,s)}if(r.byType){const a=o.byType.get(s.type)||[];a.push(s),o.byType.set(s.type,a)}if(r.byRelation){const a=Object.entries(s);for(const[c,l]of a)if(c.endsWith("_id")&&c!==`${s.type}_id`&&typeof l=="string"){const u=o.byRelation.get(c)||new Map,d=u.get(l)||[];d.push(s),u.set(l,d),o.byRelation.set(c,u)}}if(r.bySubcircuit&&"subcircuit_id"in s){const a=s.subcircuit_id;if(a&&typeof a=="string"){const c=o.bySubcircuit.get(a)||[];c.push(s),o.bySubcircuit.set(a,c)}}if(r.byCustomField&&o.byCustomField){for(const a of r.byCustomField)if(a in s){const c=s[a];if(c!==void 0&&(typeof c=="string"||typeof c=="number")){const l=String(c),u=o.byCustomField.get(a),d=u.get(l)||[];d.push(s),u.set(l,d)}}}}n._internal_store_indexed=t}return new Proxy({},{get:(r,o)=>{if(o==="toArray")return()=>(n.editCount=t.editCount,n);if(o==="editCount")return t.editCount;const s=o;return{get:a=>{const c=e.indexConfig||{};return c.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${a}`)||null:c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(u=>u[`${s}_id`]===a)||null:n.find(l=>l.type===s&&l[`${s}_id`]===a)||null},getUsing:a=>{const c=e.indexConfig||{},l=Object.keys(a);if(l.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const u=l[0],d=u.replace("_id","");if(c.byRelation&&t.indexes.byRelation){const p=t.indexes.byRelation.get(u);if(p){const _=(p.get(a[u])||[]).find(x=>x.type===d);if(!_)return null;const g=_[`${s}_id`];return c.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${g}`)||null:c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(b=>b[`${s}_id`]===g)||null:n.find(x=>x.type===s&&x[`${s}_id`]===g)||null}}const h=n.find(p=>p.type===d&&p[u]===a[u]);return h&&n.find(p=>p.type===s&&p[`${s}_id`]===h[`${s}_id`])||null},getWhere:a=>{const c=e.indexConfig||{},l=Object.keys(a);if(l.length===1&&c.byCustomField&&t.indexes.byCustomField){const u=l[0],d=t.indexes.byCustomField.get(u);if(d){const h=String(a[u]);return(d.get(h)||[]).find(m=>m.type===s)||null}}if("subcircuit_id"in a&&c.bySubcircuit&&t.indexes.bySubcircuit){const u=a.subcircuit_id;return(t.indexes.bySubcircuit.get(u)||[]).find(h=>h.type===s&&l.every(p=>h[p]===a[p]))||null}return c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(d=>l.every(h=>d[h]===a[h]))||null:n.find(u=>u.type===s&&l.every(d=>u[d]===a[d]))||null},list:a=>{const c=e.indexConfig||{},l=a?Object.keys(a):[];if(l.length===0&&c.byType&&t.indexes.byType)return t.indexes.byType.get(s)||[];if(l.length===1&&l[0]==="subcircuit_id"&&c.bySubcircuit&&t.indexes.bySubcircuit){const d=a.subcircuit_id;return(t.indexes.bySubcircuit.get(d)||[]).filter(p=>p.type===s)}let u;return c.byType&&t.indexes.byType?u=t.indexes.byType.get(s)||[]:u=n.filter(d=>d.type===s),l.length>0?u.filter(d=>l.every(h=>d[h]===a[h])):u},insert:a=>{t.counts[s]??=-1,t.counts[s]++;const c=t.counts[s],l={type:s,[`${s}_id`]:`${s}_${c}`,...a};e.validateInserts&&(Fdt[s]??zbe).parse(l),n.push(l),t.editCount++;const u=e.indexConfig||{};if(u.byId&&t.indexes.byId){const d=cve(l);t.indexes.byId.set(d,l)}if(u.byType&&t.indexes.byType){const d=t.indexes.byType.get(s)||[];d.push(l),t.indexes.byType.set(s,d)}if(u.byRelation&&t.indexes.byRelation){const d=Object.entries(l);for(const[h,p]of d)if(h.endsWith("_id")&&h!==`${l.type}_id`&&typeof p=="string"){const m=t.indexes.byRelation.get(h)||new Map,_=m.get(p)||[];_.push(l),m.set(p,_),t.indexes.byRelation.set(h,m)}}if(u.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in l){const d=l.subcircuit_id;if(d&&typeof d=="string"){const h=t.indexes.bySubcircuit.get(d)||[];h.push(l),t.indexes.bySubcircuit.set(d,h)}}if(u.byCustomField&&t.indexes.byCustomField){for(const d of u.byCustomField)if(d in l){const h=l[d];if(h!==void 0&&(typeof h=="string"||typeof h=="number")){const p=String(h),m=t.indexes.byCustomField.get(d),_=m.get(p)||[];_.push(l),m.set(p,_)}}}return l},delete:a=>{const c=e.indexConfig||{};let l;if(c.byId&&t.indexes.byId?l=t.indexes.byId.get(`${s}:${a}`):c.byType&&t.indexes.byType?l=(t.indexes.byType.get(s)||[]).find(h=>h[`${s}_id`]===a):l=n.find(d=>d[`${s}_id`]===a),!l)return;const u=n.indexOf(l);if(u>=0&&(n.splice(u,1),t.editCount++),c.byId&&t.indexes.byId){const d=cve(l);t.indexes.byId.delete(d)}if(c.byType&&t.indexes.byType){const h=(t.indexes.byType.get(s)||[]).filter(p=>p[`${s}_id`]!==a);t.indexes.byType.set(s,h)}if(c.byRelation&&t.indexes.byRelation)for(const[d,h]of t.indexes.byRelation.entries())for(const[p,m]of h.entries()){const _=m.filter(g=>g!==l);_.length===0?h.delete(p):h.set(p,_)}if(c.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in l){const d=l.subcircuit_id;if(d){const p=(t.indexes.bySubcircuit.get(d)||[]).filter(m=>m!==l);p.length===0?t.indexes.bySubcircuit.delete(d):t.indexes.bySubcircuit.set(d,p)}}if(c.byCustomField&&t.indexes.byCustomField)for(const d of t.indexes.byCustomField.values())for(const[h,p]of d.entries()){const m=p.filter(_=>_!==l);m.length===0?d.delete(h):d.set(h,m)}},update:(a,c)=>{const l=e.indexConfig||{};let u;if(l.byId&&t.indexes.byId?u=t.indexes.byId.get(`${s}:${a}`):l.byType&&t.indexes.byType?u=(t.indexes.byType.get(s)||[]).find(h=>h[`${s}_id`]===a):u=n.find(d=>d.type===s&&d[`${s}_id`]===a),!u)return null;if(l.byRelation&&t.indexes.byRelation){const d=Object.entries(u);for(const[h,p]of d)if(h.endsWith("_id")&&h!==`${u.type}_id`&&typeof p=="string"&&h in c&&c[h]!==p){const m=t.indexes.byRelation.get(h);if(m){const g=(m.get(p)||[]).filter(x=>x!==u);g.length===0?m.delete(p):m.set(p,g)}}}if(l.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in u&&"subcircuit_id"in c){const d=u.subcircuit_id,h=c.subcircuit_id;if(d!==h){const m=(t.indexes.bySubcircuit.get(d)||[]).filter(_=>_!==u);m.length===0?t.indexes.bySubcircuit.delete(d):t.indexes.bySubcircuit.set(d,m)}}if(l.byCustomField&&t.indexes.byCustomField){for(const d of l.byCustomField)if(d in u&&d in c&&u[d]!==c[d]){const h=t.indexes.byCustomField.get(d);if(h){const p=String(u[d]),_=(h.get(p)||[]).filter(g=>g!==u);_.length===0?h.delete(p):h.set(p,_)}}}if(Object.assign(u,c),t.editCount++,l.byRelation&&t.indexes.byRelation){const d=Object.entries(u);for(const[h,p]of d)if(h.endsWith("_id")&&h!==`${u.type}_id`&&typeof p=="string"&&h in c){const m=t.indexes.byRelation.get(h)||new Map,_=m.get(p)||[];_.includes(u)||(_.push(u),m.set(p,_),t.indexes.byRelation.set(h,m))}}if(l.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in u&&"subcircuit_id"in c){const d=u.subcircuit_id;if(d&&typeof d=="string"){const h=t.indexes.bySubcircuit.get(d)||[];h.includes(u)||(h.push(u),t.indexes.bySubcircuit.set(d,h))}}if(l.byCustomField&&t.indexes.byCustomField){for(const d of l.byCustomField)if(d in u&&d in c){const h=u[d];if(h!==void 0&&(typeof h=="string"||typeof h=="number")){const p=String(h),m=t.indexes.byCustomField.get(d),_=m.get(p)||[];_.includes(u)||(_.push(u),m.set(p,_))}}}return u},select:a=>{if(s==="source_component")return n.find(c=>c.type==="source_component"&&c.name===a.replace(/\./g,""))||null;if(s==="pcb_port"||s==="source_port"||s==="schematic_port"){const[c,l]=a.replace(/\./g,"").split(/[\s\>]+/),u=n.find(h=>h.type==="source_component"&&h.name===c);if(!u)return null;const d=n.find(h=>h.type==="source_port"&&h.source_component_id===u.source_component_id&&(h.name===l||(h.port_hints??[]).includes(l)));if(!d)return null;if(s==="source_port")return d;if(s==="pcb_port")return n.find(h=>h.type==="pcb_port"&&h.source_port_id===d.source_port_id)||null;if(s==="schematic_port")return n.find(h=>h.type==="schematic_port"&&h.source_port_id===d.source_port_id)||null}return null}}}})};Oht.unparsed=Oht;var NFn=n=>{const e=n.type;return n[`${e}_id`]},kFn=n=>{let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const o of n){if(!o.type.startsWith("pcb_"))continue;let s,a,c,l;if("x"in o&&"y"in o&&(s=Number(o.x),a=Number(o.y)),"outer_diameter"in o&&(c=Number(o.outer_diameter),l=Number(o.outer_diameter)),"width"in o&&(c=Number(o.width)),"height"in o&&(l=Number(o.height)),"center"in o&&(s=o.center.x,a=o.center.y),s!==void 0&&a!==void 0)e=Math.min(e,s),t=Math.min(t,a),i=Math.max(i,s),r=Math.max(r,a),c!==void 0&&l!==void 0&&(e=Math.min(e,s-c/2),t=Math.min(t,a-l/2),i=Math.max(i,s+c/2),r=Math.max(r,a+l/2)),"radius"in o&&(e=Math.min(e,s-o.radius),t=Math.min(t,a-o.radius),i=Math.max(i,s+o.radius),r=Math.max(r,a+o.radius));else if(o.type==="pcb_trace")for(const u of o.route)e=Math.min(e,u.x),t=Math.min(t,u.y),i=Math.max(i,u.x),r=Math.max(r,u.y)}return{minX:e,minY:t,maxX:i,maxY:r}};function OFn(n){let e=0;if(n.length==0)return e;for(var t=0;t<n.length;t++){var i=n.charCodeAt(t);e=(e<<5)-e+i,e=e&e}return Math.abs(e)}var Lht=[["#69d2e7","#a7dbd8","#e0e4cc","#f38630","#fa6900"],["#fe4365","#fc9d9a","#f9cdad","#c8c8a9","#83af9b"],["#ecd078","#d95b43","#c02942","#542437","#53777a"],["#556270","#4ecdc4","#c7f464","#ff6b6b","#c44d58"],["#774f38","#e08e79","#f1d4af","#ece5ce","#c5e0dc"],["#e8ddcb","#cdb380","#036564","#033649","#031634"],["#490a3d","#bd1550","#e97f02","#f8ca00","#8a9b0f"],["#594f4f","#547980","#45ada8","#9de0ad","#e5fcc2"],["#00a0b0","#6a4a3c","#cc333f","#eb6841","#edc951"],["#e94e77","#d68189","#c6a49a","#c6e5d9","#f4ead5"],["#3fb8af","#7fc7af","#dad8a7","#ff9e9d","#ff3d7f"],["#d9ceb2","#948c75","#d5ded9","#7a6a53","#99b2b7"],["#ffffff","#cbe86b","#f2e9e1","#1c140d","#cbe86b"],["#efffcd","#dce9be","#555152","#2e2633","#99173c"],["#343838","#005f6b","#008c9e","#00b4cc","#00dffc"],["#413e4a","#73626e","#b38184","#f0b49e","#f7e4be"],["#ff4e50","#fc913a","#f9d423","#ede574","#e1f5c4"],["#99b898","#fecea8","#ff847c","#e84a5f","#2a363b"],["#655643","#80bca3","#f6f7bd","#e6ac27","#bf4d28"],["#00a8c6","#40c0cb","#f9f2e7","#aee239","#8fbe00"],["#351330","#424254","#64908a","#e8caa4","#cc2a41"],["#554236","#f77825","#d3ce3d","#f1efa5","#60b99a"],["#5d4157","#838689","#a8caba","#cad7b2","#ebe3aa"],["#8c2318","#5e8c6a","#88a65e","#bfb35a","#f2c45a"],["#fad089","#ff9c5b","#f5634a","#ed303c","#3b8183"],["#ff4242","#f4fad2","#d4ee5e","#e1edb9","#f0f2eb"],["#f8b195","#f67280","#c06c84","#6c5b7b","#355c7d"],["#d1e751","#ffffff","#000000","#4dbce9","#26ade4"],["#1b676b","#519548","#88c425","#bef202","#eafde6"],["#5e412f","#fcebb6","#78c0a8","#f07818","#f0a830"],["#bcbdac","#cfbe27","#f27435","#f02475","#3b2d38"],["#452632","#91204d","#e4844a","#e8bf56","#e2f7ce"],["#eee6ab","#c5bc8e","#696758","#45484b","#36393b"],["#f0d8a8","#3d1c00","#86b8b1","#f2d694","#fa2a00"],["#2a044a","#0b2e59","#0d6759","#7ab317","#a0c55f"],["#f04155","#ff823a","#f2f26f","#fff7bd","#95cfb7"],["#b9d7d9","#668284","#2a2829","#493736","#7b3b3b"],["#bbbb88","#ccc68d","#eedd99","#eec290","#eeaa88"],["#b3cc57","#ecf081","#ffbe40","#ef746f","#ab3e5b"],["#a3a948","#edb92e","#f85931","#ce1836","#009989"],["#300030","#480048","#601848","#c04848","#f07241"],["#67917a","#170409","#b8af03","#ccbf82","#e33258"],["#aab3ab","#c4cbb7","#ebefc9","#eee0b7","#e8caaf"],["#e8d5b7","#0e2430","#fc3a51","#f5b349","#e8d5b9"],["#ab526b","#bca297","#c5ceae","#f0e2a4","#f4ebc3"],["#607848","#789048","#c0d860","#f0f0d8","#604848"],["#b6d8c0","#c8d9bf","#dadabd","#ecdbbc","#fedcba"],["#a8e6ce","#dcedc2","#ffd3b5","#ffaaa6","#ff8c94"],["#3e4147","#fffedf","#dfba69","#5a2e2e","#2a2c31"],["#fc354c","#29221f","#13747d","#0abfbc","#fcf7c5"],["#cc0c39","#e6781e","#c8cf02","#f8fcc1","#1693a7"],["#1c2130","#028f76","#b3e099","#ffeaad","#d14334"],["#a7c5bd","#e5ddcb","#eb7b59","#cf4647","#524656"],["#dad6ca","#1bb0ce","#4f8699","#6a5e72","#563444"],["#5c323e","#a82743","#e15e32","#c0d23e","#e5f04c"],["#edebe6","#d6e1c7","#94c7b6","#403b33","#d3643b"],["#fdf1cc","#c6d6b8","#987f69","#e3ad40","#fcd036"],["#230f2b","#f21d41","#ebebbc","#bce3c5","#82b3ae"],["#b9d3b0","#81bda4","#b28774","#f88f79","#f6aa93"],["#3a111c","#574951","#83988e","#bcdea5","#e6f9bc"],["#5e3929","#cd8c52","#b7d1a3","#dee8be","#fcf7d3"],["#1c0113","#6b0103","#a30006","#c21a01","#f03c02"],["#000000","#9f111b","#b11623","#292c37","#cccccc"],["#382f32","#ffeaf2","#fcd9e5","#fbc5d8","#f1396d"],["#e3dfba","#c8d6bf","#93ccc6","#6cbdb5","#1a1f1e"],["#f6f6f6","#e8e8e8","#333333","#990100","#b90504"],["#1b325f","#9cc4e4","#e9f2f9","#3a89c9","#f26c4f"],["#a1dbb2","#fee5ad","#faca66","#f7a541","#f45d4c"],["#c1b398","#605951","#fbeec2","#61a6ab","#accec0"],["#5e9fa3","#dcd1b4","#fab87f","#f87e7b","#b05574"],["#951f2b","#f5f4d7","#e0dfb1","#a5a36c","#535233"],["#8dccad","#988864","#fea6a2","#f9d6ac","#ffe9af"],["#2d2d29","#215a6d","#3ca2a2","#92c7a3","#dfece6"],["#413d3d","#040004","#c8ff00","#fa023c","#4b000f"],["#eff3cd","#b2d5ba","#61ada0","#248f8d","#605063"],["#ffefd3","#fffee4","#d0ecea","#9fd6d2","#8b7a5e"],["#cfffdd","#b4dec1","#5c5863","#a85163","#ff1f4c"],["#9dc9ac","#fffec7","#f56218","#ff9d2e","#919167"],["#4e395d","#827085","#8ebe94","#ccfc8e","#dc5b3e"],["#a8a7a7","#cc527a","#e8175d","#474747","#363636"],["#f8edd1","#d88a8a","#474843","#9d9d93","#c5cfc6"],["#046d8b","#309292","#2fb8ac","#93a42a","#ecbe13"],["#f38a8a","#55443d","#a0cab5","#cde9ca","#f1edd0"],["#a70267","#f10c49","#fb6b41","#f6d86b","#339194"],["#ff003c","#ff8a00","#fabe28","#88c100","#00c176"],["#ffedbf","#f7803c","#f54828","#2e0d23","#f8e4c1"],["#4e4d4a","#353432","#94ba65","#2790b0","#2b4e72"],["#0ca5b0","#4e3f30","#fefeeb","#f8f4e4","#a5b3aa"],["#4d3b3b","#de6262","#ffb88c","#ffd0b3","#f5e0d3"],["#fffbb7","#a6f6af","#66b6ab","#5b7c8d","#4f2958"],["#edf6ee","#d1c089","#b3204d","#412e28","#151101"],["#9d7e79","#ccac95","#9a947c","#748b83","#5b756c"],["#fcfef5","#e9ffe1","#cdcfb7","#d6e6c3","#fafbe3"],["#9cddc8","#bfd8ad","#ddd9ab","#f7af63","#633d2e"],["#30261c","#403831","#36544f","#1f5f61","#0b8185"],["#aaff00","#ffaa00","#ff00aa","#aa00ff","#00aaff"],["#d1313d","#e5625c","#f9bf76","#8eb2c5","#615375"],["#ffe181","#eee9e5","#fad3b2","#ffba7f","#ff9c97"],["#73c8a9","#dee1b6","#e1b866","#bd5532","#373b44"],["#805841","#dcf7f3","#fffcdd","#ffd8d8","#f5a2a2"]],LFn=n=>{let{x:e,y:t,width:i,height:r}={...n,...n.size,...n.center,...n.position};if(n.x1!==void 0&&n.x2!==void 0&&n.y1!==void 0&&n.y2!==void 0&&(e=(n.x1+n.x2)/2,t=(n.y1+n.y2)/2,i=Math.abs(n.x1-n.x2),r=Math.abs(n.y1-n.y2)),n.points&&Array.isArray(n.points)&&n.points.length>0){const a=n.points.map(p=>p.x),c=n.points.map(p=>p.y),l=Math.min(...a),u=Math.max(...a),d=Math.min(...c),h=Math.max(...c);e=(l+u)/2,t=(d+h)/2,i=u-l,r=h-d}const o=n.text||n.name||n.source?.text||n.source?.name||"?",s=n;return e===void 0||t===void 0?null:(i===void 0&&"outer_diameter"in n&&(i=n.outer_diameter,r=n.outer_diameter),(i===void 0||r===void 0)&&(i=.1,r=.1),{x:e,y:t,width:i,height:r,title:o,content:s,bg_color:Lht[OFn(n.type||o)%Lht.length]?.[4]??"#f00"})},DFn=n=>!!n,zFn=n=>{const e=n.filter(l=>l.type.startsWith("pcb_")||l.type.startsWith("schematic_")).concat(n.filter(l=>l.type==="pcb_trace"||l.type==="schematic_trace").flatMap(l=>l.route)).map(l=>LFn(l)).filter(DFn);if(e.length===0)return{center:{x:0,y:0},width:0,height:0};let t=e[0].x-e[0].width/2,i=e[0].x+e[0].width/2,r=e[0].y-e[0].height/2,o=e[0].y+e[0].height/2;for(const l of e.slice(1))t=Math.min(t,l.x-l.width/2),i=Math.max(i,l.x+l.width/2),r=Math.min(r,l.y-l.height/2),o=Math.max(o,l.y+l.height/2);const s=i-t,a=o-r;return{center:{x:t+s/2,y:r+a/2},width:s,height:a}},eN={IS_SHOWING_PCB_GROUPS:"pcb_viewer_is_showing_pcb_groups",PCB_GROUP_VIEW_MODE:"pcb_viewer_group_view_mode",IS_SHOWING_COPPER_POURS:"pcb_viewer_is_showing_copper_pours"},Dht=(n,e)=>{if(typeof window>"u")return e;try{const t=localStorage.getItem(n);return t!==null?JSON.parse(t):e}catch{return e}},zht=(n,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(n,JSON.stringify(e))}catch{}},$Fn=(n,e)=>{if(typeof window>"u")return e;try{const t=localStorage.getItem(n);return t!==null?JSON.parse(t):e}catch{return e}},FFn=(n,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(n,JSON.stringify(e))}catch{}},UFn="named_only",BFn=(n={},e=!1)=>lze(t=>({selected_layer:"top",pcb_viewer_id:`pcb_viewer_${Math.random().toString().slice(2,10)}`,in_edit_mode:!1,in_move_footprint_mode:!1,in_draw_trace_mode:!1,is_moving_component:!1,is_drawing_trace:!1,is_mouse_over_container:!1,is_showing_multiple_traces_length:!1,is_showing_rats_nest:!1,is_showing_autorouting:!0,is_showing_drc_errors:!0,is_showing_copper_pours:Dht(eN.IS_SHOWING_COPPER_POURS,!0),is_showing_pcb_groups:e?!1:Dht(eN.IS_SHOWING_PCB_GROUPS,!0),pcb_group_view_mode:e?"all":$Fn(eN.PCB_GROUP_VIEW_MODE,UFn),hovered_error_id:null,...n,selectLayer:i=>t({selected_layer:i}),setEditMode:i=>t({in_edit_mode:i!=="off",in_move_footprint_mode:i==="move_footprint",in_draw_trace_mode:i==="draw_trace",is_moving_component:!1,is_drawing_trace:!1}),setIsShowingRatsNest:i=>t({is_showing_rats_nest:i}),setIsMovingComponent:i=>t({is_moving_component:i}),setIsDrawingTrace:i=>t({is_drawing_trace:i}),setIsMouseOverContainer:i=>t({is_mouse_over_container:i}),setIsShowingMultipleTracesLength:i=>t({is_showing_multiple_traces_length:i}),setIsShowingAutorouting:i=>t({is_showing_autorouting:i}),setIsShowingDrcErrors:i=>t({is_showing_drc_errors:i}),setIsShowingCopperPours:i=>{zht(eN.IS_SHOWING_COPPER_POURS,i),t({is_showing_copper_pours:i})},setIsShowingPcbGroups:i=>{e||(zht(eN.IS_SHOWING_PCB_GROUPS,i),t({is_showing_pcb_groups:i}))},setPcbGroupViewMode:i=>{e||(FFn(eN.PCB_GROUP_VIEW_MODE,i),t({pcb_group_view_mode:i}))},setHoveredErrorId:i=>t({hovered_error_id:i})})),iv=n=>{const e=ce.useContext($ht);return xze(e,n)},$ht=ce.createContext(null),jFn=({children:n,initialState:e,disablePcbGroups:t})=>{const i=ce.useMemo(()=>BFn(e,t),[t]);return re.jsx($ht.Provider,{value:i,children:n})},HFn=()=>{const n=iv(t=>t.pcb_viewer_id),e=(t,i)=>zf(t,{containerId:n,...i});return e.error=(t,i)=>zf.error(t,{containerId:n,...i}),e.promise=zf.promise,e},VFn=()=>{ce.useEffect(()=>{p$n()},[]);const n=iv(e=>e.pcb_viewer_id);return re.jsx(h$n,{position:"top-center",containerId:n})},GFn=function(){},Fht=typeof window<"u",YFn=Fht?ce.useLayoutEffect:ce.useEffect,qFn=YFn,Uht={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function XFn(){var n=ce.useState(null),e=n[0],t=n[1],i=ce.useState(Uht),r=i[0],o=i[1],s=ce.useMemo(function(){return new window.ResizeObserver(function(a){if(a[0]){var c=a[0].contentRect,l=c.x,u=c.y,d=c.width,h=c.height,p=c.top,m=c.left,_=c.bottom,g=c.right;o({x:l,y:u,width:d,height:h,top:p,left:m,bottom:_,right:g})}})},[]);return qFn(function(){if(e)return s.observe(e),function(){s.disconnect()}},[e]),[t,r]}var tq=Fht&&typeof window.ResizeObserver<"u"?XFn:function(){return[GFn,Uht]},Bht=({initialTransform:n,initialTouch1:e,initialTouch2:t,finalTouch1:i,finalTouch2:r})=>{if(!i||!r)return n;const o={x:(e.x+t.x)/2,y:(e.y+t.y)/2},s={x:(i.x+r.x)/2,y:(i.y+r.y)/2},a=Math.hypot(t.x-e.x,t.y-e.y),c=Math.hypot(r.x-i.x,r.y-i.y),l=a===0?1:c/a,u=s.x-o.x,d=s.y-o.y;return ko(Go(u,d),Go(o.x,o.y),jm(l,l),Go(-o.x,-o.y),n)},WFn=(n={})=>{const e=ce.useRef(null),[t,i]=ce.useState(0),r=n.canvasElm??e.current,[o,s]=ce.useState(n.initialTransform??Bh()),[a,c]=ce.useState(0),[l,u]=ce.useReducer(w=>w+1,0),d=ce.useCallback(w=>{n.onSetTransform&&n.onSetTransform(w),n.transform||s(w)},[n.onSetTransform,s]),h=ce.useCallback(w=>{d(w),u()},[d]),p=n.transform??o,m=ce.useCallback(()=>{i(Date.now())},[]),_=ce.useRef("none"),g=ce.useRef(null),x=ce.useRef(null);ce.useEffect(()=>{const w=n.canvasElm??e.current;if(w&&!r){c(a+1);return}if(!w){const J=setTimeout(()=>{c(a+1)},100);return()=>clearTimeout(J)}let E=n.transform??o,k={x:0,y:0},A={x:0,y:0},R=!1;const M=J=>({x:J.pageX-w.getBoundingClientRect().left-window.scrollX,y:J.pageY-w.getBoundingClientRect().top-window.scrollY});function I(J){n.enabled!==!1&&(n.shouldDrag&&!n.shouldDrag(J)||(k=M(J),!(Date.now()-t<100)&&(R=!0,J.preventDefault())))}function C(J){if(!R||n.enabled===!1||n.shouldDrag&&!n.shouldDrag(J))return;A=M(J);const le=ko(Go(A.x-k.x,A.y-k.y),E);d(le),E=le,R=!1}function U(J){if(M(J),!R||n.enabled===!1||n.shouldDrag&&!n.shouldDrag(J))return;A=M(J);const le=ko(Go(A.x-k.x,A.y-k.y),E);d(le)}function O(J){if(n.enabled===!1||n.shouldDrag&&!n.shouldDrag(J))return;const le=M(J),pe=ko(Go(le.x,le.y),jm(1-J.deltaY/1e3,1-J.deltaY/1e3),Go(-le.x,-le.y),E);d(pe),E=pe,J.preventDefault()}function H(J){if(!R||n.shouldDrag&&!n.shouldDrag(J))return;if(w){const pe=w.getBoundingClientRect();if(J.clientX>=pe.left+10&&J.clientX<=pe.right-10&&J.clientY>=pe.top+10&&J.clientY<=pe.bottom-10)return}R=!1,A=M(J);const le=ko(Go(A.x-k.x,A.y-k.y),E);d(le),E=le}function Y(J){if(J.preventDefault(),n.enabled!==!1){if(J.touches.length===1){_.current="drag";const le=J.touches[0];g.current={initialTransform:E,initialTouch:{x:le.clientX,y:le.clientY}}}else if(J.touches.length===2){_.current="pinch";const le=J.touches[0],pe=J.touches[1];x.current={initialTransform:E,initialTouch1:{x:le.clientX,y:le.clientY},initialTouch2:{x:pe.clientX,y:pe.clientY},finalTouch1:null,finalTouch2:null}}}}function X(J){if(J.preventDefault(),n.enabled!==!1){if(_.current==="drag"&&J.touches.length===1&&g.current){const le=J.touches[0],pe={x:le.clientX,y:le.clientY},ve=pe.x-g.current.initialTouch.x,oe=pe.y-g.current.initialTouch.y,ae=ko(Go(ve,oe),g.current.initialTransform);d(ae)}else if(_.current==="pinch"&&J.touches.length===2&&x.current){const le=J.touches[0],pe=J.touches[1];x.current.finalTouch1={x:le.clientX,y:le.clientY},x.current.finalTouch2={x:pe.clientX,y:pe.clientY};const ve=Bht(x.current);d(ve)}}}function K(J){J.preventDefault();const le=J.changedTouches[0];if(_.current==="drag"&&g.current&&le){const pe={x:le.clientX,y:le.clientY},ve=pe.x-g.current.initialTouch.x,oe=pe.y-g.current.initialTouch.y,ae=ko(Go(ve,oe),g.current.initialTransform);d(ae),E=ae}else if(_.current==="pinch"&&x.current){const pe=Bht(x.current);d(pe),E=pe}_.current="none",g.current=null,x.current=null}return w.addEventListener("mousedown",I),w.addEventListener("mouseup",C),window.addEventListener("mousemove",U),w.addEventListener("mouseout",H),w.addEventListener("wheel",O),w.addEventListener("touchstart",Y,{passive:!1}),w.addEventListener("touchmove",X,{passive:!1}),w.addEventListener("touchend",K,{passive:!1}),w.addEventListener("touchcancel",K,{passive:!1}),()=>{w.removeEventListener("mousedown",I),w.removeEventListener("mouseup",C),window.removeEventListener("mousemove",U),w.removeEventListener("mouseout",H),w.removeEventListener("wheel",O),w.removeEventListener("touchstart",Y),w.removeEventListener("touchmove",X),w.removeEventListener("touchend",K),w.removeEventListener("touchcancel",K)}},[r,a,l,t,n.enabled,n.shouldDrag]);const b=ce.useCallback(w=>Dt(p,w),[p]);return{ref:e,transform:p,applyTransformToPoint:b,setTransform:h,cancelDrag:m}},KFn=WFn;function ZFn(n){const e=new Map;let t=0;function i(r){for(const[,s]of e)if(s.has(r))return s;const o=new Set;return e.set(`connectivity_net${t++}`,o),o}for(const r of n){let o=null;for(const s of r){if(!o)o=i(s);else if(!o.has(s)){const a=i(s);if(a!==o){for(const c of a)o.add(c);e.delete(Array.from(e.entries()).find(([,c])=>c===a)[0])}}o.add(s)}}return Object.fromEntries(Array.from(e.entries()).map(([r,o])=>[r,Array.from(o)]))}var QFn=class{netMap;idToNetMap;constructor(e){this.netMap=e,this.idToNetMap={};for(const[t,i]of Object.entries(e))for(const r of i)this.idToNetMap[r]=t}addConnections(e){for(const t of e){const i=new Set;for(const o of t){const s=this.idToNetMap[o];s&&i.add(s)}let r;if(i.size===0)r=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[r]=[];else if(i.size===1)r=i.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{r=i.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const o of i)if(o!==r){this.netMap[r].push(...this.netMap[o]),this.netMap[o]=this.netMap[r];for(const s of this.netMap[r])this.idToNetMap[s]=r}}for(const o of t)this.netMap[r].includes(o)||this.netMap[r].push(o),this.idToNetMap[o]=r}}getIdsConnectedToNet(e){return this.netMap[e]||[]}getNetConnectedToId(e){return this.idToNetMap[e]}areIdsConnected(e,t){if(e===t)return!0;const i=this.getNetConnectedToId(e);if(!i)return!1;const r=this.getNetConnectedToId(t);return r?i===r||r===e||r===e:!1}areAllIdsConnected(e){const t=this.getNetConnectedToId(e[0]);for(const i of e){const r=this.getNetConnectedToId(i);if(r===void 0||r!==t)return!1}return!0}},jht=n=>{const e=[];for(const i of n)if(i.type==="source_trace")e.push([i.source_trace_id,...i.connected_source_port_ids??[],...i.connected_source_net_ids??[]].filter(Boolean));else if(i.type==="pcb_port"){const{pcb_port_id:r,source_port_id:o}=i;o&&r&&e.push([o,r])}else if(i.type==="pcb_smtpad"){const{pcb_smtpad_id:r,pcb_port_id:o}=i;o&&r&&e.push([r,o])}else if(i.type==="pcb_plated_hole"){const{pcb_plated_hole_id:r,pcb_port_id:o}=i;o&&r&&e.push([r,o])}else if(i.type==="pcb_trace"){const{pcb_trace_id:r,source_trace_id:o}=i,s=Array.isArray(i.route)?i.route.filter(a=>a&&a.route_type==="wire"):[];if(o&&r&&e.push([r,o]),Array.isArray(s)){const a=s.find(l=>l&&l.start_pcb_port_id)?.start_pcb_port_id,c=s.find(l=>l&&l.end_pcb_port_id)?.end_pcb_port_id;a&&r&&c&&e.push([a,r,c])}}else if(i.type==="pcb_via"){const{pcb_via_id:r,pcb_trace_id:o}=i;o&&r&&e.push([r,o])}else if(i.type==="source_component"&&i.internally_connected_source_port_ids)for(const r of i.internally_connected_source_port_ids)e.push(r);const t=ZFn(e);return new QFn(t)};function JFn({primitivesWithoutInteractionMetadata:n,drawingObjectIdsWithMouseOver:e,primitiveIdsInMousedOverNet:t}){const i=[];for(const r of n){const o={...r};r?.layer==="drill"?(o.is_in_highlighted_net=!1,o.is_mouse_over=!1):e.has(r._pcb_drawing_object_id)?o.is_mouse_over=!0:r._element&&("pcb_trace_id"in r._element&&t.includes(r._element.pcb_trace_id)||"pcb_port_id"in r._element&&t.includes(r._element.pcb_port_id))?o.is_in_highlighted_net=!0:(o.is_in_highlighted_net=!1,o.is_mouse_over=!1),i.push(o)}return i}function eUn(n,e){if(n.length<2)throw new Error("Stroke must have at least two points");const t=n.map(d=>Array.isArray(d)?{x:d[0],y:d[1]}:d),i=[],r=[];function o(d,h){const p=h.x-d.x,m=h.y-d.y,_=Math.sqrt(p*p+m*m);return{x:-m/_,y:p/_}}function s(d,h,p,m){const _=m/2,g={x:d.x+h.x*_*p,y:d.y+h.y*_*p};p>0?i.push(g):r.unshift(g)}const a=o(t[0],t[1]),c=t[0].trace_width??e;s(t[0],a,1,c),s(t[0],a,-1,c);for(let d=1;d<t.length-1;d++){const h=t[d-1],p=t[d],m=t[d+1],_=o(h,p),g=o(p,m),x=_.x+g.x,b=_.y+g.y,w=Math.sqrt(x*x+b*b),E=p.trace_width??e;if(w/2>2*(E/2))s(p,_,1,E),s(p,g,1,E),s(p,_,-1,E),s(p,g,-1,E);else{const A=1/w;s(p,{x:x*A,y:b*A},1,E),s(p,{x:x*A,y:b*A},-1,E)}}const l=o(t[t.length-2],t[t.length-1]),u=t[t.length-1].trace_width??e;return s(t[t.length-1],l,1,u),s(t[t.length-1],l,-1,u),[...i,...r]}var Uc=0,l_=n=>`${n}_${Uc++}`,lve=n=>(n??[]).map(e=>({x:di.parse(e.x),y:di.parse(e.y)})),tUn=(n,e)=>{const t="pcb_component_id"in n?e.find(s=>s.type==="pcb_component"&&s.pcb_component_id===n.pcb_component_id):void 0,i=t&&"source_component_id"in t?e.find(s=>s.type==="source_component"&&s.source_component_id===t.source_component_id):void 0,r="source_port_id"in n?n.source_port_id:"pcb_port_id"in n?fC(e).pcb_port.get(n.pcb_port_id)?.source_port_id:void 0,o=r?e.find(s=>s.type==="source_port"&&s.source_port_id===r):void 0;switch(n.type){case"pcb_panel":{const{width:s,height:a}=n;return[{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:0,y1:0,x2:s,y2:0,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:0,y1:a,x2:s,y2:a,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:0,y1:0,x2:0,y2:a,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:s,y1:0,x2:s,y2:a,width:1,zoomIndependent:!0,layer:"board",_element:n}]}case"pcb_board":{const{width:s,height:a,center:c,outline:l}=n;return l&&l.length>2?l.map((u,d,h)=>({_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:u.x,y1:u.y,x2:d===h.length-1?h[0].x:h[d+1].x,y2:d===h.length-1?h[0].y:h[d+1].y,width:1,zoomIndependent:!0,layer:"board",_element:n})):[{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y-a/2,x2:c.x+s/2,y2:c.y-a/2,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y+a/2,x2:c.x+s/2,y2:c.y+a/2,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y-a/2,x2:c.x-s/2,y2:c.y+a/2,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:c.x+s/2,y1:c.y-a/2,x2:c.x+s/2,y2:c.y+a/2,width:1,zoomIndependent:!0,layer:"board",_element:n}]}case"pcb_smtpad":{if(n.shape==="rect"||n.shape==="rotated_rect"){const{shape:s,x:a,y:c,width:l,height:u,layer:d,rect_border_radius:h}=n,p=n.corner_radius??h??0;return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:a,y:c,w:l,h:u,layer:d||"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:n.ccw_rotation,roundness:p}]}else if(n.shape==="circle"){const{x:s,y:a,radius:c,layer:l}=n;return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:c,layer:l||"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}]}else if(n.shape==="polygon"){const{layer:s,points:a}=n;return[{_pcb_drawing_object_id:`polygon_${Uc++}`,pcb_drawing_type:"polygon",points:lve(a),layer:s||"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}]}else if(n.shape==="pill"||n.shape==="rotated_pill"){const{x:s,y:a,width:c,height:l,layer:u}=n;return[{_pcb_drawing_object_id:`pill_${Uc++}`,pcb_drawing_type:"pill",x:s,y:a,w:c,h:l,layer:u||"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:n.ccw_rotation}]}return[]}case"pcb_hole":{if(n.hole_shape==="circle"||!n.hole_shape){const{x:s,y:a,hole_diameter:c}=n;return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:c/2,layer:"drill",_element:n,_parent_pcb_component:t,_parent_source_component:i}]}return[]}case"pcb_plated_hole":if(n.shape==="circle"){const{x:s,y:a,hole_diameter:c,outer_diameter:l}=n;return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:l/2,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o},{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:c/2,layer:"drill",_element:n}]}else if(n.shape==="oval"){const{x:s,y:a,outer_height:c,outer_width:l,hole_height:u,hole_width:d}=n;return[{_pcb_drawing_object_id:`oval_${Uc++}`,pcb_drawing_type:"oval",x:s,y:a,rX:l/2,rY:c/2,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o},{_pcb_drawing_object_id:`oval_${Uc++}`,_element:n,pcb_drawing_type:"oval",x:s,y:a,rX:d/2,rY:u/2,layer:"drill"}]}else if(n.shape==="pill"){const{x:s,y:a,outer_height:c,outer_width:l,hole_height:u,hole_width:d}=n;return[{_pcb_drawing_object_id:`pill_${Uc++}`,pcb_drawing_type:"pill",x:s,y:a,w:l,h:c,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:n.ccw_rotation},{_pcb_drawing_object_id:`pill_${Uc++}`,_element:n,pcb_drawing_type:"pill",x:s,y:a,w:d,h:u,layer:"drill",ccw_rotation:n.ccw_rotation}]}else if(n.shape==="circular_hole_with_rect_pad"){const{x:s,y:a,hole_diameter:c,rect_pad_width:l,rect_pad_height:u,rect_border_radius:d}=n,h=n.hole_offset_x??0,p=n.hole_offset_y??0;return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:s,y:a,w:l,h:u,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:d},{_pcb_drawing_object_id:`circle_${Uc++}`,_element:n,pcb_drawing_type:"circle",x:s+h,y:a+p,r:c/2,layer:"drill"}]}else if(n.shape==="pill_hole_with_rect_pad"){const{x:s,y:a,hole_width:c,hole_height:l,rect_pad_width:u,rect_pad_height:d,rect_border_radius:h}=n;return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:s,y:a,w:u,h:d,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:h},{_pcb_drawing_object_id:`pill_${Uc++}`,_element:n,pcb_drawing_type:"pill",x:s,y:a,w:c,h:l,layer:"drill"}]}else if(n.shape==="rotated_pill_hole_with_rect_pad"){const{x:s,y:a,hole_width:c,hole_height:l,hole_ccw_rotation:u,rect_pad_width:d,rect_pad_height:h,rect_ccw_rotation:p,rect_border_radius:m}=n;return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:s,y:a,w:d,h,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:p,roundness:m},{_pcb_drawing_object_id:`pill_${Uc++}`,_element:n,pcb_drawing_type:"pill",x:s,y:a,w:c,h:l,layer:"drill",ccw_rotation:u}]}else return[];case"pcb_keepout":{if(n.shape==="circle"){const{center:s,radius:a}=n;return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s.x,y:s.y,r:a,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,mesh_fill:!0}]}else if(n.shape==="rect"){const{center:s,width:a,height:c}=n;return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:s.x,y:s.y,w:a,h:c,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,mesh_fill:!0}]}break}case"pcb_trace":{const s=[];if(n.route_thickness_mode==="interpolated"){const l=n.route.map(h=>({x:h.x,y:h.y,trace_width:h.route_type==="wire"?h.width:.5})),u=eUn(l,.5),d=n.route[0].layer;return s.push({_pcb_drawing_object_id:`polygon_${Uc++}`,_element:n,pcb_drawing_type:"polygon",points:u,layer:d}),n.route.forEach(h=>{h.route_type==="via"&&s.push({_pcb_drawing_object_id:`circle_${Uc++}`,_element:n,pcb_drawing_type:"circle",x:h.x,y:h.y,r:h.outer_diameter/2,layer:h.from_layer})}),s}let a=null,c=null;for(const l of n.route)l.route_type==="wire"&&(a!==null&&c!==null&&s.push({_pcb_drawing_object_id:`line_${Uc++}`,_element:n,pcb_drawing_type:"line",x1:a,y1:c,x2:l.x,y2:l.y,width:l.width,squareCap:!1,layer:l.layer}),a=l.x,c=l.y);return s}case"pcb_via":{const{x:s,y:a,outer_diameter:c,hole_diameter:l,from_layer:u,to_layer:d}=n;return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:c/2,layer:u,_element:n,_parent_pcb_component:t,_parent_source_component:i},{_pcb_drawing_object_id:`circle_${Uc++}`,_element:n,pcb_drawing_type:"circle",x:s,y:a,r:l/2,layer:"drill",_parent_pcb_component:t,_parent_source_component:i},{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:c/2,layer:d,_element:n,_parent_pcb_component:t,_parent_source_component:i}]}case"pcb_silkscreen_rect":return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:n.center.x,y:n.center.y,w:n.width,h:n.height,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen",stroke_width:n.stroke_width,is_filled:n.is_filled,has_stroke:n.has_stroke,is_stroke_dashed:n.is_stroke_dashed,_element:n}];case"pcb_silkscreen_circle":return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:n.center.x,y:n.center.y,r:n.radius,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_oval":return[{_pcb_drawing_object_id:`oval_${Uc++}`,pcb_drawing_type:"oval",x:n.center.x,y:n.center.y,rX:n.radius_x/2,rY:n.radius_y/2,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_pill":return[{_pcb_drawing_object_id:`pill_${Uc++}`,pcb_drawing_type:"pill",x:n.center.x,y:n.center.y,w:n.width,h:n.height,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_line":return[{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,width:.1,squareCap:!1,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_fabrication_note_path":case"pcb_silkscreen_path":{const{pcb_component_id:s,route:a,type:c}=n;let l;return c==="pcb_silkscreen_path"?l=n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen":c==="pcb_fabrication_note_path"&&(l="top_fabrication"),a.slice(0,-1).map((u,d)=>{const h=a[d+1];return{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:u.x,y1:u.y,x2:h.x,y2:h.y,width:n.stroke_width??.1,squareCap:!1,layer:l,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}}).filter(Boolean)}case"pcb_silkscreen_text":return[{_pcb_drawing_object_id:`text_${Uc++}`,pcb_drawing_type:"text",x:n.anchor_position.x,y:n.anchor_position.y,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen",align:n.anchor_alignment??"center",text:n.text,size:n.font_size,ccw_rotation:n.ccw_rotation}];case"pcb_copper_pour":{const s=n;switch(s.shape){case"rect":{const{center:a,width:c,height:l,layer:u,rotation:d}=s;return[{_pcb_drawing_object_id:l_("pcb_copper_pour_rect"),pcb_drawing_type:"rect",x:a.x,y:a.y,w:c,h:l,layer:u,_element:n,ccw_rotation:d}]}case"polygon":{const{points:a,layer:c}=s;return[{_pcb_drawing_object_id:l_("pcb_copper_pour_polygon"),pcb_drawing_type:"polygon",points:lve(a),layer:c,_element:n}]}case"brep":{const{brep_shape:a,layer:c}=s;return[{_pcb_drawing_object_id:l_("pcb_copper_pour_brep"),pcb_drawing_type:"polygon_with_arcs",brep_shape:a,layer:c,_element:n}]}}return[]}case"pcb_fabrication_note_dimension":{const s=n,{from:a,to:c,text:l,font_size:u,arrow_size:d}=s,h=n.layer==="bottom"?"bottom_fabrication":"top_fabrication",p=[],m=typeof d=="number"&&!Number.isNaN(d)?d:1;p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:c.x,y2:c.y,width:.05,squareCap:!1,layer:h,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o});const _=c.x-a.x,g=c.y-a.y,x=Math.sqrt(_*_+g*g)||1,b=_/x,w=g/x,E=Math.PI/6,k=a.x+m*(b*Math.cos(E)-w*Math.sin(E)),A=a.y+m*(b*Math.sin(E)+w*Math.cos(E)),R=a.x+m*(b*Math.cos(-E)-w*Math.sin(-E)),M=a.y+m*(b*Math.sin(-E)+w*Math.cos(-E));p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:k,y2:A,width:.05,squareCap:!1,layer:h,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}),p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:R,y2:M,width:.05,squareCap:!1,layer:h,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o});const I=c.x-m*(b*Math.cos(E)-w*Math.sin(E)),C=c.y-m*(b*Math.sin(E)+w*Math.cos(E)),U=c.x-m*(b*Math.cos(-E)-w*Math.sin(-E)),O=c.y-m*(b*Math.sin(-E)+w*Math.cos(-E));return p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"line",x1:c.x,y1:c.y,x2:I,y2:C,width:.05,squareCap:!1,layer:h,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}),p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"line",x1:c.x,y1:c.y,x2:U,y2:O,width:.05,squareCap:!1,layer:h,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}),l&&p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"text",x:(a.x+c.x)/2,y:(a.y+c.y)/2,layer:h,align:"center",text:l,size:u,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}),p}case"pcb_fabrication_note_text":return[{_pcb_drawing_object_id:l_("text"),pcb_drawing_type:"text",x:n.anchor_position.x,y:n.anchor_position.y,layer:n.layer==="bottom"?"bottom_fabrication":"top_fabrication",size:n.font_size,align:n.anchor_alignment??"center",text:n.text}];case"pcb_cutout":{const s=n;switch(s.shape){case"rect":return[{_pcb_drawing_object_id:l_("pcb_cutout_rect"),pcb_drawing_type:"rect",x:s.center.x,y:s.center.y,w:s.width,h:s.height,layer:"drill",_element:n,_parent_pcb_component:t,_parent_source_component:i}];case"circle":return[{_pcb_drawing_object_id:l_("pcb_cutout_circle"),pcb_drawing_type:"circle",x:s.center.x,y:s.center.y,r:s.radius,layer:"drill",_element:n,_parent_pcb_component:t,_parent_source_component:i}];case"polygon":return[{_pcb_drawing_object_id:l_("pcb_cutout_polygon"),pcb_drawing_type:"polygon",points:lve(s.points),layer:"drill",_element:n,_parent_pcb_component:t,_parent_source_component:i}];default:return console.warn(`Unsupported pcb_cutout shape: ${s.shape}`),[]}}case"pcb_note_line":{const s=n;return[{_pcb_drawing_object_id:l_("pcb_note_line"),pcb_drawing_type:"line",x1:s.x1,y1:s.y1,x2:s.x2,y2:s.y2,width:s.stroke_width??.1,squareCap:!1,layer:"notes",color:s.color,_element:n,_parent_pcb_component:t,_parent_source_component:i}]}case"pcb_note_rect":{const s=n;return[{_pcb_drawing_object_id:l_("pcb_note_rect"),pcb_drawing_type:"rect",x:s.center.x,y:s.center.y,w:s.width,h:s.height,layer:"notes",stroke_width:s.stroke_width,is_filled:s.is_filled,has_stroke:s.has_stroke,is_stroke_dashed:s.is_stroke_dashed,color:s.color,_element:n,_parent_pcb_component:t,_parent_source_component:i}]}case"pcb_note_path":{const s=n,{route:a,stroke_width:c}=s;return a.slice(0,-1).map((l,u)=>{const d=a[u+1];return{_pcb_drawing_object_id:l_("pcb_note_path"),pcb_drawing_type:"line",x1:l.x,y1:l.y,x2:d.x,y2:d.y,width:c??.1,squareCap:!1,layer:"notes",color:s.color,_element:n,_parent_pcb_component:t,_parent_source_component:i}}).filter(Boolean)}case"pcb_note_text":{const s=n;return[{_pcb_drawing_object_id:l_("pcb_note_text"),pcb_drawing_type:"text",x:s.anchor_position.x,y:s.anchor_position.y,layer:"notes",align:s.anchor_alignment??"center",text:s.text||"",size:s.font_size,color:s.color,_element:n,_parent_pcb_component:t,_parent_source_component:i}]}case"pcb_note_dimension":{const s=n,{from:a,to:c,text:l,font_size:u,arrow_size:d}=s,h=[];h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:c.x,y2:c.y,width:.05,squareCap:!1,color:s.color,layer:"notes",_element:n,_parent_pcb_component:t,_parent_source_component:i});const p=c.x-a.x,m=c.y-a.y,_=Math.sqrt(p*p+m*m),g=p/_,x=m/_,b=Math.PI/6,w=a.x+d*(g*Math.cos(b)-x*Math.sin(b)),E=a.y+d*(g*Math.sin(b)+x*Math.cos(b)),k=a.x+d*(g*Math.cos(-b)-x*Math.sin(-b)),A=a.y+d*(g*Math.sin(-b)+x*Math.cos(-b));h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:w,y2:E,width:.05,squareCap:!1,layer:"notes",_element:n}),h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:k,y2:A,width:.05,squareCap:!1,layer:"notes",_element:n});const R=c.x-d*(g*Math.cos(b)-x*Math.sin(b)),M=c.y-d*(g*Math.sin(b)+x*Math.cos(b)),I=c.x-d*(g*Math.cos(-b)-x*Math.sin(-b)),C=c.y-d*(g*Math.sin(-b)+x*Math.cos(-b));return h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"line",x1:c.x,y1:c.y,x2:R,y2:M,width:.05,squareCap:!1,layer:"notes",_element:n}),h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"line",x1:c.x,y1:c.y,x2:I,y2:C,width:.05,squareCap:!1,layer:"notes",_element:n}),l&&h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"text",x:(a.x+c.x)/2,y:(a.y+c.y)/2,layer:"notes",align:"center",text:l,size:u,_element:n}),h}}return[]},Cy={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(242, 237, 161)",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)"}},bw=(n,e=1)=>{if(Math.abs(n.a)!==Math.abs(n.d))throw new Error("Cannot scale non-uniformly");return e*Math.abs(n.a)},u_={elementOverlay:30,dimensionOverlay:30,editTraceHintOverlay:30,errorOverlay:30,pcbGroupOverlay:25,ratsNestOverlay:20,toolbarOverlay:60,warnings:20,topLayer:10,clickToInteractOverlay:100},nq={red:"red",black:"black",green:"green",board:"rgb(255, 255, 255)",other:"#eee",top:Cy.board.copper.f,inner1:Cy.board.copper.in1,inner2:Cy.board.copper.in2,inner3:Cy.board.copper.in3,inner4:Cy.board.copper.in4,inner5:Cy.board.copper.in5,inner6:Cy.board.copper.in6,inner7:Cy.board.copper.in7,inner8:Cy.board.copper.in8,bottom:Cy.board.copper.b,drill:Cy.board.anchor,keepout:Cy.board.background,tkeepout:Cy.board.b_crtyd,tplace:Cy.board.b_silks,top_silkscreen:Cy.board.f_silks,bottom_silkscreen:Cy.board.b_silks,top_fabrication:Cy.board.f_fab,bottom_fabrication:Cy.board.b_fab,notes:Cy.board.user_2,...Cy.board},nUn=["inner6","inner5","inner4","inner3","inner2","inner1","bottom","bottom_silkscreen","top","top_silkscreen","board"],iUn=class{canvasLayerMap;ctxLayerMap;aperture;transform;foregroundLayer="top";lastPoint;constructor(n){this.canvasLayerMap=n,this.ctxLayerMap=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t.getContext("2d")])),this.transform=Bh(),this.transform.d*=-1,this.transform=ko(this.transform,Go(0,-500)),this.lastPoint={x:0,y:0},this.equip({})}clear(){for(const n of Object.values(this.ctxLayerMap))n.clearRect(0,0,n.canvas.width,n.canvas.height)}equip(n){this.aperture={fontSize:0,shape:"circle",mode:"add",size:0,color:"red",layer:"top",opacity:this.foregroundLayer===n.color?1:.5,...n}}drawMeshPattern(n,e,t,i,r,o=45){const s=this.getLayerCtx(),[a,c]=Dt(this.transform,[n,e]),[l,u]=Dt(this.transform,[n+t,e+i]),d=bw(this.transform,r);s.lineWidth=1,s.strokeStyle=this.aperture.color;const h=p=>{const m=Math.sin(p),_=Math.cos(p),g=Math.sqrt(Math.pow(l-a,2)+Math.pow(u-c,2));for(let x=-g;x<=g;x+=d)s.beginPath(),s.moveTo(a+x*_-g*m,c+x*m+g*_),s.lineTo(a+x*_+g*m,c+x*m-g*_),s.stroke()};h(o*Math.PI/180),h((o+90)*Math.PI/180)}rect({x:n,y:e,w:t,h:i,mesh_fill:r,is_filled:o=!0,has_stroke:s,is_stroke_dashed:a,stroke_width:c,roundness:l}){const[u,d]=Dt(this.transform,[n-t/2,e-i/2]),[h,p]=Dt(this.transform,[n+t/2,e+i/2]);this.applyAperture();const m=this.getLayerCtx(),_=l?bw(this.transform,l):0,g=s===void 0?o===!1:s;if(r)m.save(),m.beginPath(),_>0&&m.roundRect?m.roundRect(u,d,h-u,p-d,_):m.rect(u,d,h-u,p-d),m.clip(),this.drawMeshPattern(n-t/2,e-i/2,t,i,.15),m.restore(),_>0&&m.roundRect?(m.beginPath(),m.roundRect(u,d,h-u,p-d,_),m.stroke()):m.strokeRect(u,d,h-u,p-d);else if(o!==!1&&(_>0&&m.roundRect?(m.beginPath(),m.roundRect(u,d,h-u,p-d,_),m.fill()):m.fillRect(u,d,h-u,p-d)),g){const x=m.lineWidth;if(c!==void 0&&(m.lineWidth=bw(this.transform,c)),a){let b=[];const w=Math.abs(this.transform.a);if(w>0){const k=.1*w,A=k*1.3;k>.5&&(b=[k,A])}m.setLineDash(b)}_>0&&m.roundRect?(m.beginPath(),m.roundRect(u,d,h-u,p-d,_),m.stroke()):m.strokeRect(u,d,h-u,p-d),a&&m.setLineDash([]),c!==void 0&&(m.lineWidth=x)}}rotatedRect(n,e,t,i,r,o,s){const a=this.getLayerCtx();this.applyAperture();const[c,l]=Dt(this.transform,[n-t/2,e-i/2]),[u,d]=Dt(this.transform,[n+t/2,e+i/2]),h=o?bw(this.transform,o):0;a.save();const[p,m]=Dt(this.transform,[n,e]);a.translate(p,m);const _=360-r;r&&a.rotate(_*Math.PI/180),a.translate(-p,-m),s?(a.beginPath(),h>0&&a.roundRect?a.roundRect(c,l,u-c,d-l,h):a.rect(c,l,u-c,d-l),a.clip(),this.drawMeshPattern(n-t/2,e-i/2,t,i,.15),h>0&&a.roundRect?(a.beginPath(),a.roundRect(c,l,u-c,d-l,h),a.stroke()):a.strokeRect(c,l,u-c,d-l)):h>0&&a.roundRect?(a.beginPath(),a.roundRect(c,l,u-c,d-l,h),a.fill()):a.fillRect(c,l,u-c,d-l),a.restore()}rotatedPill(n,e,t,i,r){const o=this.getLayerCtx();this.applyAperture(),o.save();const[s,a]=Dt(this.transform,[n,e]);o.translate(s,a);const c=360-r;r&&o.rotate(c*Math.PI/180),o.translate(-s,-a),this.pill(n,e,t,i),o.restore()}circle(n,e,t,i){const r=bw(this.transform,t),[o,s]=Dt(this.transform,[n,e]);this.applyAperture();const a=this.getLayerCtx();i?(a.save(),a.beginPath(),a.arc(o,s,r,0,2*Math.PI),a.clip(),this.drawMeshPattern(n-t,e-t,t*2,t*2,.15),a.restore(),a.beginPath(),a.arc(o,s,r,0,2*Math.PI),a.stroke()):(a.beginPath(),a.arc(o,s,r,0,2*Math.PI),a.fill())}oval(n,e,t,i){const r=bw(this.transform,t),o=bw(this.transform,i),[s,a]=Dt(this.transform,[n,e]);this.applyAperture();const c=this.getLayerCtx();c.beginPath(),c.ellipse(s,a,r,o,0,0,2*Math.PI),c.fill(),c.closePath()}pill(n,e,t,i){const[r,o]=Dt(this.transform,[n-t/2,e+i/2]),s=bw(this.transform,t),a=bw(this.transform,i),c=Math.min(s,a)/2;this.applyAperture();const l=this.getLayerCtx();l.beginPath(),l.arc(r+c,o+c,c,Math.PI,Math.PI*1.5),l.arc(r+s-c,o+c,c,Math.PI*1.5,0),l.arc(r+s-c,o+a-c,c,0,Math.PI*.5),l.arc(r+c,o+a-c,c,Math.PI*.5,Math.PI),l.fill(),l.closePath()}polygon(n){if(n.length<3)return;this.applyAperture();const e=this.getLayerCtx(),t=n.map(r=>Dt(this.transform,[r.x,r.y]));e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let r=1;r<t.length;r++)e.lineTo(t[r][0],t[r][1]);e.closePath(),e.fill("evenodd");const i=bw(this.transform,this.aperture.size);i>0&&(e.lineWidth=i,e.stroke())}debugText(n,e,t){const[i,r]=Dt(this.transform,[e,t]);this.applyAperture();const o=this.getLayerCtx();o.font="10px sans-serif",o.fillText(n,i,r)}getLayerCtx(){const n=this.ctxLayerMap[this.aperture.layer];if(!n)throw new Error(`No context for layer "${this.aperture.layer}"`);return n}orderAndFadeLayers(){const{canvasLayerMap:n,foregroundLayer:e}=this,t=new Set([e,"drill","other","board",e==="top"?"top_silkscreen":e==="bottom"?"bottom_silkscreen":""]),i=e==="top"?"top_silkscreen":e==="bottom"?"bottom_silkscreen":void 0,r=[e,...i?[i]:[]],o=[...nUn.filter(s=>!r.includes(s)),e,"drill",...i?[i]:[]];o.forEach((s,a)=>{const c=n[s];c&&(c.style.zIndex=`${u_.topLayer-(o.length-a)}`,c.style.opacity=t.has(s)?"1":"0.5")})}applyAperture(){const{transform:n,aperture:e}=this;let{size:t,mode:i,color:r,fontSize:o,layer:s}=e;s in this.ctxLayerMap||(this.aperture.layer="other");const a=this.getLayerCtx();if(!a)throw new Error(`No context for layer "${this.foregroundLayer}"`);if(r||(r="undefined"),a.lineWidth=bw(n,t),a.lineCap="round",i==="add"){a.globalCompositeOperation="source-over";let c=nq[r.toLowerCase()];if(!c)try{c=iht(r).rgb().toString()}catch{console.warn(`Invalid color format: '${r}'`),c="white"}a.fillStyle=c,a.strokeStyle=c}else a.globalCompositeOperation="destination-out",a.fillStyle="rgba(0,0,0,1)",a.strokeStyle="rgba(0,0,0,1)";a.font=`${bw(F2(n),o)}px sans-serif`}moveTo(n,e){this.lastPoint={x:n,y:e}}lineTo(n,e){const[t,i]=Dt(this.transform,[n,e]),{size:r,shape:o,mode:s}=this.aperture,a=bw(this.transform,r);let{lastPoint:c}=this;const l=Dt(this.transform,c);this.applyAperture();const u=this.getLayerCtx();o==="square"&&u.fillRect(l.x-a/2,l.y-a/2,a,a),u.beginPath(),u.moveTo(l.x,l.y),u.lineTo(t,i),u.stroke(),u.closePath(),o==="square"&&u.fillRect(t-a/2,i-a/2,a,a),this.lastPoint={x:n,y:e}}polygonWithArcs(n){const e=this.getLayerCtx(),t=i=>{if(i.vertices.length===0)return;const r=i.vertices[0],o=Dt(this.transform,[r.x,r.y]);e.moveTo(o[0],o[1]);for(let s=0;s<i.vertices.length;s++){const a=i.vertices[s],c=i.vertices[(s+1)%i.vertices.length];if(a.bulge&&a.bulge!==0){const l=a.bulge,u=c.x-a.x,d=c.y-a.y,h=Math.sqrt(u*u+d*d);if(h<1e-9){const O=Dt(this.transform,[c.x,c.y]);e.lineTo(O[0],O[1]);continue}const p=4*Math.atan(l),m=Math.abs(h/(2*Math.sin(p/2))),_=(a.x+c.x)/2,g=(a.y+c.y)/2,x=u/h,w=-(d/h),E=x,k=Math.sqrt(Math.max(0,m*m-(h/2)**2)),A=_+k*w*Math.sign(l),R=g+k*E*Math.sign(l),M=Math.atan2(a.y-R,a.x-A);let I=Math.atan2(c.y-R,c.x-A);l>0&&I<M?I+=2*Math.PI:l<0&&I>M&&(I-=2*Math.PI);const C=Dt(this.transform,[A,R]),U=bw(this.transform,m);e.arc(C[0],C[1],U,-M,-I,l>0)}else{const l=Dt(this.transform,[c.x,c.y]);e.lineTo(l[0],l[1])}}e.closePath()};if(e.beginPath(),t(n.outer_ring),n.inner_rings)for(const i of n.inner_rings)t(i);e.fill("evenodd")}};function rUn(n){const{lines:e,anchorPoint:t,ccwRotation:i}=n;if(!i)return e;const r=i*Math.PI/180,o=B_(r),s=ko(Go(t.x,t.y),o,Go(-t.x,-t.y));return Dt(s,t),e.map(a=>({...a,x1:Dt(s,{x:a.x1,y:a.y1}).x,y1:Dt(s,{x:a.x1,y:a.y1}).y,x2:Dt(s,{x:a.x2,y:a.y2}).x,y2:Dt(s,{x:a.x2,y:a.y2}).y}))}var Hht=.6,Vht=.2,oUn=n=>{if(n.text.length===0)return 0;const e=n.size*.7,t=e*Hht,i=e*Vht;return n.text.length*t+(n.text.length-1)*i},sUn=n=>{const e=n.size*.7;if(e<=0||n.text.length===0)return[];const t=e/12,i=Math.max(0,e-t),r=t/2,o=e*Hht,s=Math.max(0,o-t),a=t/2,c=e*Vht,l=[];let u=n.x;for(let d=0;d<n.text.length;d++){const h=n.text[d],p=BY[h]??BY[h.toUpperCase()];if(!p){u+=o+c;continue}for(const{x1:m,y1:_,x2:g,y2:x}of p)l.push({_pcb_drawing_object_id:l_("line"),pcb_drawing_type:"line",x1:u+a+s*m,y1:n.y+r+i*_,x2:u+a+s*g,y2:n.y+r+i*x,width:t,layer:n.layer,unit:n.unit});u+=o+c}return l};function DT(n){const t=n.color??nq[n.layer];let i=iht(t);return n._element?.type==="pcb_copper_pour"&&(i=i.alpha(.7)),n.is_mouse_over||n.is_in_highlighted_net?i.lighten(.5).rgb().toString():i.rgb().toString()}var Ght=(n,e)=>{n.equip({size:e.zoomIndependent?e.width/n.transform.a:e.width,shape:e.squareCap?"square":"circle",color:DT(e),layer:e.layer}),n.moveTo(e.x1,e.y1),n.lineTo(e.x2,e.y2)},aUn=(n,e)=>{n.equip({fontSize:e.size,color:DT(e),layer:e.layer});let t={x:0,y:0};const i=oUn(e),r=e.size;switch(e.align){case"top_left":t.x=0,t.y=-r;break;case"top_center":t.x=-i/2,t.y=-r;break;case"top_right":t.x=-i,t.y=-r;break;case"center_left":t.x=0,t.y=-r/2;break;case"center":t.x=-i/2,t.y=-r/2;break;case"center_right":t.x=-i,t.y=-r/2;break;case"bottom_left":t.x=0,t.y=0;break;case"bottom_center":t.x=-i/2,t.y=0;break;case"bottom_right":t.x=-i,t.y=0;break;default:t.x=0,t.y=0;break}e.x??=0,e.y??=0;const o={x:e.x,y:e.y};let s=sUn({...e,x:e.x+t.x,y:e.y+t.y});if(e.layer==="bottom_silkscreen"&&(s=s.map(a=>({...a,x1:2*e.x-a.x1,x2:2*e.x-a.x2}))),e.ccw_rotation){const a={lines:s,anchorPoint:o,ccwRotation:e.ccw_rotation};s=rUn(a)}for(const a of s)Ght(n,a)},cUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer,size:e.stroke_width}),n.rect({x:e.x,y:e.y,w:e.w,h:e.h,mesh_fill:e.mesh_fill,is_filled:e.is_filled,has_stroke:e.has_stroke,is_stroke_dashed:e.is_stroke_dashed,stroke_width:e.stroke_width,roundness:e.roundness})},lUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.rotatedRect(e.x,e.y,e.w,e.h,e.ccw_rotation,e.roundness,e.mesh_fill)},uUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.rotatedPill(e.x,e.y,e.w,e.h,e.ccw_rotation)},dUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.circle(e.x,e.y,e.r,e.mesh_fill)},hUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.oval(e.x,e.y,e.rX,e.rY)},pUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.pill(e.x,e.y,e.w,e.h)},fUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.polygon(e.points)},mUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.polygonWithArcs(e.brep_shape)},_Un=(n,e)=>{switch(e.pcb_drawing_type){case"line":return Ght(n,e);case"text":return aUn(n,e);case"rect":return e.ccw_rotation?lUn(n,e):cUn(n,e);case"circle":return dUn(n,e);case"oval":return hUn(n,e);case"pill":return e.ccw_rotation?uUn(n,e):pUn(n,e);case"polygon":return fUn(n,e);case"polygon_with_arcs":return mUn(n,e)}},yUn=(n,e)=>{for(const t of e)_Un(n,t)},gUn=["board","bottom_silkscreen","bottom","top","top_silkscreen","inner1","inner2","inner3","inner4","inner5","inner6","drill","notes","other"],xUn=({primitives:n,transform:e,grid:t,width:i=500,height:r=500})=>{const o=ce.useRef({}),s=iv(a=>a.selected_layer);return ce.useEffect(()=>{if(!o.current||Object.keys(o.current).length===0)return;const a=new iUn(o.current);e&&(a.transform=e),a.clear(),a.foregroundLayer=s,yUn(a,n),a.orderAndFadeLayers()},[n,e,s]),re.jsxs("div",{style:{backgroundColor:"black",width:i,height:r,position:"relative"},children:[re.jsx(jbe.SuperGrid,{textColor:"rgba(0,255,0,0.8)",majorColor:"rgba(0,255,0,0.4)",minorColor:"rgba(0,255,0,0.2)",screenSpaceCellSize:200,width:i,height:r,transform:e,stringifyCoord:(a,c,l)=>`${jbe.toMMSI(a,l)}, ${jbe.toMMSI(c,l)}`}),gUn.map(a=>a.replace(/-/g,"")).map((a,c)=>re.jsx("canvas",{className:`pcb-layer-${a}`,ref:l=>{o.current??={},o.current[a]=l},style:{position:"absolute",zIndex:c,left:0,top:0,pointerEvents:"none"},width:i,height:r},a))]})},bUn=.6,vUn=1;Eht(fFn()),Eht(RFn());var iq=["rgba(239, 68, 68, 0.8)","rgba(249, 115, 22, 0.8)","rgba(245, 158, 11, 0.8)","rgba(234, 179, 8, 0.8)","rgba(132, 204, 22, 0.8)","rgba(34, 197, 94, 0.8)","rgba(16, 185, 129, 0.8)","rgba(20, 184, 166, 0.8)","rgba(6, 182, 212, 0.8)","rgba(14, 165, 233, 0.8)","rgba(59, 130, 246, 0.8)","rgba(99, 102, 241, 0.8)","rgba(139, 92, 246, 0.8)","rgba(168, 85, 247, 0.8)","rgba(217, 70, 239, 0.8)","rgba(236, 72, 153, 0.8)","rgba(249, 168, 212, 0.8)","rgba(161, 161, 170, 0.8)"];function Yht(n,e,t,i={}){const r=i.padding??40,o=i.yFlip??!1;let s;if("center"in n){const u=n.width/2,d=n.height/2;s={minX:n.center.x-u,maxX:n.center.x+u,minY:n.center.y-d,maxY:n.center.y+d}}else s=n;const a=s.maxX-s.minX||1,c=s.maxY-s.minY||1,l=Math.min((e-2*r)/a,(t-2*r)/c);return ko(Go(e/2,t/2),jm(l,o?-l:l),Go(-(s.minX+a/2),-(s.minY+c/2)))}function wUn(n){const e=[...n.points||[],...(n.lines||[]).flatMap(t=>t.points),...(n.rects||[]).flatMap(t=>{const i=t.width/2,r=t.height/2;return[{x:t.center.x-i,y:t.center.y-r},{x:t.center.x+i,y:t.center.y-r},{x:t.center.x-i,y:t.center.y+r},{x:t.center.x+i,y:t.center.y+r}]}),...(n.circles||[]).flatMap(t=>[{x:t.center.x-t.radius,y:t.center.y},{x:t.center.x+t.radius,y:t.center.y},{x:t.center.x,y:t.center.y-t.radius},{x:t.center.x,y:t.center.y+t.radius}]),...(n.texts||[]).flatMap(t=>{const i=t.fontSize??12,r=t.text.length*i*bUn,o=i*vUn,s=t.anchorSide??"center",a={top_left:{dx:0,dy:0},top_center:{dx:-r/2,dy:0},top_right:{dx:-r,dy:0},center_left:{dx:0,dy:-o/2},center:{dx:-r/2,dy:-o/2},center_right:{dx:-r,dy:-o/2},bottom_left:{dx:0,dy:-o},bottom_center:{dx:-r/2,dy:-o},bottom_right:{dx:-r,dy:-o}},{dx:c,dy:l}=a[s],u=t.x+c,d=t.y+l;return[{x:u,y:d},{x:u+r,y:d+o}]})];return e.length===0?{minX:-1,maxX:1,minY:-1,maxY:1}:e.reduce((t,i)=>({minX:Math.min(t.minX,i.x),maxX:Math.max(t.maxX,i.x),minY:Math.min(t.minY,i.y),maxY:Math.max(t.maxY,i.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0})}function SUn(n,e,t={}){const i=e instanceof HTMLCanvasElement?e.getContext("2d"):e;if(!i)throw new Error("Could not get 2D context from canvas");const r=e instanceof HTMLCanvasElement?e.width:e.canvas.width,o=e instanceof HTMLCanvasElement?e.height:e.canvas.height;let s;if(t.transform)s=t.transform;else if(t.viewbox)s=Yht(t.viewbox,r,o,{padding:t.padding,yFlip:t.yFlip});else{const a=wUn(n),c=n.coordinateSystem==="cartesian";s=Yht(a,r,o,{padding:t.padding??40,yFlip:c})}i.clearRect(0,0,r,o),i.save(),n.rects&&n.rects.length>0&&n.rects.forEach(a=>{const c=a.width/2,l=a.height/2,u=Dt(s,{x:a.center.x-c,y:a.center.y-l}),d=Dt(s,{x:a.center.x+c,y:a.center.y+l}),h=Math.abs(d.x-u.x),p=Math.abs(d.y-u.y);i.beginPath(),i.rect(Math.min(u.x,d.x),Math.min(u.y,d.y),h,p),a.fill&&(i.fillStyle=a.fill,i.fill()),a.stroke&&(i.strokeStyle=a.stroke,i.stroke())}),n.circles&&n.circles.length>0&&n.circles.forEach(a=>{const c=Dt(s,a.center),l=a.radius*Math.abs(s.a);i.beginPath(),i.arc(c.x,c.y,l,0,2*Math.PI),a.fill&&(i.fillStyle=a.fill,i.fill()),a.stroke&&(i.strokeStyle=a.stroke??"transparent",i.stroke())}),n.lines&&n.lines.length>0&&n.lines.forEach((a,c)=>{if(a.points.length===0)return;i.beginPath();const l=Dt(s,a.points[0]);i.moveTo(l.x,l.y);for(let u=1;u<a.points.length;u++){const d=Dt(s,a.points[u]);i.lineTo(d.x,d.y)}if(i.strokeStyle=a.strokeColor||iq[c%iq.length],a.strokeWidth?i.lineWidth=a.strokeWidth*s.a:i.lineWidth=2,i.lineCap="round",a.strokeDash)if(typeof a.strokeDash=="string"){let u;if(a.strokeDash.includes(","))u=a.strokeDash.split(",").map(d=>parseFloat(d.trim())).filter(d=>!Number.isNaN(d));else{const d=parseFloat(a.strokeDash.trim());u=Number.isNaN(d)?[]:[d]}i.setLineDash(u)}else i.setLineDash(a.strokeDash.map(u=>u*Math.abs(s.a)));else i.setLineDash([]);i.stroke()}),n.points&&n.points.length>0&&n.points.forEach((a,c)=>{const l=Dt(s,a);i.beginPath(),i.arc(l.x,l.y,3,0,2*Math.PI),i.fillStyle=a.color||iq[c%iq.length],i.fill(),a.label&&!t.disableLabels&&(i.fillStyle=a.color||"black",i.font="12px sans-serif",i.fillText(a.label,l.x+5,l.y-5))}),n.texts&&n.texts.length>0&&n.texts.forEach(a=>{const c=Dt(s,{x:a.x,y:a.y});i.fillStyle=a.color||"black",i.font=`${(a.fontSize??12)*Math.abs(s.a)}px sans-serif`;const l=a.anchorSide??"center",u={top_left:"left",center_left:"left",bottom_left:"left",top_center:"center",center:"center",bottom_center:"center",top_right:"right",center_right:"right",bottom_right:"right"},d={top_left:"top",top_center:"top",top_right:"top",center_left:"middle",center:"middle",center_right:"middle",bottom_left:"bottom",bottom_center:"bottom",bottom_right:"bottom"};i.textAlign=u[l],i.textBaseline=d[l],i.fillText(a.text,c.x,c.y)}),i.restore()}var EUn=({children:n,transform:e,debugGraphics:t})=>{const i=ce.useRef(null),[r,{width:o,height:s}]=tq(),a=iv(c=>c.is_showing_autorouting);return ce.useEffect(()=>{a&&i.current&&t&&o&&s&&(i.current.width=o,i.current.height=s,SUn(t,i.current,{transform:e,disableLabels:!0}))},[t,e,o,s,a]),a?re.jsxs("div",{ref:r,style:{position:"relative",width:"100%",height:"100%"},children:[n,re.jsx("canvas",{ref:i,style:{position:"absolute",top:0,left:0,opacity:.5,zIndex:100,width:"100%",height:"100%",pointerEvents:"none"}})]}):n},TUn=({children:n,transform:e=Bh(),elements:t=[]})=>{const[i,{width:r,height:o}]=tq(),s=ce.useRef(null);return ce.useEffect(()=>{const a=s.current;if(!a||!r||!o)return;a.width=r,a.height=o;const c=a.getContext("2d");if(!c)return;c.clearRect(0,0,r,o);const l=t.filter(d=>d.type==="pcb_component"),u=t.filter(d=>d.type==="pcb_manual_edit_conflict_warning");c.strokeStyle=Cy.board.drc_warning,c.lineWidth=2,u.forEach(d=>{const h=l.find(K=>K.pcb_component_id===d.pcb_component_id);if(!h)return;const{width:p,height:m,center:_}=h,g=Dt(e,_),x=p*Math.abs(e.a),b=m*Math.abs(e.d),w=.1*Math.abs(e.a),E=x+w*2,k=b+w*2,A=g.x-E/2,R=g.y-k/2;c.beginPath(),c.rect(A,R,E,k),c.stroke();const M="Manual Edit Conflict",I=4,C=Math.max(8,Math.min(12,10*Math.abs(e.a)));c.font=`${C}px sans-serif`;const O=c.measureText(M).width+I*2,H=C+I*2,Y=A+(E-O)/2,X=R+k+5;c.fillStyle="rgba(0, 0, 0, 0.7)",c.beginPath(),c.roundRect(Y,X,O,H,3),c.fill(),c.fillStyle=Cy.board.drc_warning,c.textAlign="center",c.textBaseline="middle",c.fillText(M,Y+O/2,X+H/2)})},[t,e,r,o]),re.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[n,re.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:u_.warnings}})]})},rq=(n,e,t)=>t(n,e),qht=(n,e,t,i,r)=>{const o=r*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=n-t,l=e-i,u=c*s-l*a,d=c*a+l*s;return{x:u+t,y:d+i}},U8=n=>{if(n.length===0)return null;let e=n[0].x,t=n[0].x,i=n[0].y,r=n[0].y;for(const o of n)e=rq(e,o.x,Math.min),t=rq(t,o.x,Math.max),i=rq(i,o.y,Math.min),r=rq(r,o.y,Math.max);return{minX:e,maxX:t,minY:i,maxY:r}},MUn=(n,e)=>({minX:Math.min(n.minX,e.minX),maxX:Math.max(n.maxX,e.maxX),minY:Math.min(n.minY,e.minY),maxY:Math.max(n.maxY,e.maxY)}),CUn=(n,e)=>n?MUn(n,e):e,AUn=n=>{switch(n.pcb_drawing_type){case"line":{const e=(n.width??0)/2,t=[{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}],i=U8(t);return i?{minX:i.minX-e,maxX:i.maxX+e,minY:i.minY-e,maxY:i.maxY+e}:null}case"rect":{const e=n.w/2,t=n.h/2,i=[{x:n.x-e,y:n.y-t},{x:n.x+e,y:n.y-t},{x:n.x+e,y:n.y+t},{x:n.x-e,y:n.y+t}],r=n.ccw_rotation??0,o=r===0?i:i.map(s=>qht(s.x,s.y,n.x,n.y,r));return U8(o)}case"circle":return{minX:n.x-n.r,maxX:n.x+n.r,minY:n.y-n.r,maxY:n.y+n.r};case"oval":return{minX:n.x-n.rX,maxX:n.x+n.rX,minY:n.y-n.rY,maxY:n.y+n.rY};case"pill":{const e=n.w/2,t=n.h/2,i=[{x:n.x-e,y:n.y-t},{x:n.x+e,y:n.y-t},{x:n.x+e,y:n.y+t},{x:n.x-e,y:n.y+t}],r=n.ccw_rotation??0,o=r===0?i:i.map(s=>qht(s.x,s.y,n.x,n.y,r));return U8(o)}case"polygon":return U8(n.points);case"polygon_with_arcs":{const e=n.brep_shape.outer_ring.vertices.map(t=>({x:t.x,y:t.y}));return U8(e)}case"text":{const e=n.size??0,t=n.text?n.text.length*e*.6:0,i=e;if(t===0&&i===0)return{minX:n.x,maxX:n.x,minY:n.y,maxY:n.y};const r=t/2,o=i/2;return{minX:n.x-r,maxX:n.x+r,minY:n.y-o,maxY:n.y+o}}default:return null}},PUn=16,G4=5,RUn=n=>{if(n.pcb_drawing_type==="text")return!0;const e=n._element;if(!e||typeof e!="object")return!1;const t=typeof e.type=="string"?e.type:void 0;return t?!!(t.startsWith("pcb_silkscreen_")||t.startsWith("pcb_note_")||t==="pcb_text"||t.startsWith("pcb_fabrication_note_")&&t!=="pcb_fabrication_note_rect"):!1},IUn=({children:n,transform:e,focusOnHover:t=!1,primitives:i=[]})=>{e||(e=Bh());const[r,o]=ce.useState(!1),[s,a]=ce.useState(!1),[c,l]=ce.useState(!1),[u,d]=ce.useState({start:null,end:null}),h=ce.useCallback(()=>{c&&(l(!1),window.dispatchEvent(new Event("disarm-dimension-tool")))},[c]),[p,m]=ce.useState({x:0,y:0}),[_,g]=ce.useState({x:0,y:0}),x=ce.useRef({x:0,y:0}),b=ce.useRef(null),E=b.current?.getBoundingClientRect(),k=ce.useMemo(()=>{const O=new Map;for(const H of i){if(!H._element||RUn(H))continue;const Y=AUn(H);if(!Y)continue;const X=O.get(H._element);O.set(H._element,CUn(X??void 0,Y))}return O},[i]),A=ce.useMemo(()=>{const O=[];return k.forEach((H,Y)=>{if(!H)return;const X=(H.minX+H.maxX)/2,K=(H.minY+H.maxY)/2,J={top_left:{x:H.minX,y:H.minY},top_center:{x:X,y:H.minY},top_right:{x:H.maxX,y:H.minY},center_left:{x:H.minX,y:K},center:{x:X,y:K},center_right:{x:H.maxX,y:K},bottom_left:{x:H.minX,y:H.maxY},bottom_center:{x:X,y:H.maxY},bottom_right:{x:H.maxX,y:H.maxY}};for(const[le,pe]of Object.entries(J))O.push({anchor:le,point:pe,element:Y})}),O},[k]),R=ce.useMemo(()=>A.map((O,H)=>({...O,id:`${H}-${O.anchor}`,screenPoint:Dt(e,O.point)})),[A,e]),M=ce.useCallback(O=>{if(R.length===0)return{point:O,id:null};const H=Dt(e,O);let Y=null;for(const X of R){const K=X.screenPoint.x-H.x,J=X.screenPoint.y-H.y,le=Math.hypot(K,J);le>PUn||(!Y||le<Y.distance)&&(Y={distance:le,id:X.id,point:X.point})}return Y?{point:Y.point,id:Y.id}:{point:O,id:null}},[R,e]);ce.useEffect(()=>{const O=b.current,H=J=>{if(J.key==="d"){const le=M({x:x.current.x,y:x.current.y});m({x:le.point.x,y:le.point.y}),g({x:le.point.x,y:le.point.y}),d({start:le.id,end:le.id}),r?(o(!1),a(!1),d({start:null,end:null})):(o(!0),a(!0)),h()}J.key==="Escape"&&(o(!1),a(!1),d({start:null,end:null}),h())},Y=()=>{l(!0)},X=()=>{O&&window.addEventListener("keydown",H)},K=()=>{O&&window.removeEventListener("keydown",H)};return window.addEventListener("arm-dimension-tool",Y),O&&(O.addEventListener("focus",X),O.addEventListener("blur",K),O.addEventListener("mouseenter",X),O.addEventListener("mouseleave",K)),()=>{window.removeEventListener("arm-dimension-tool",Y),h(),O&&(O.removeEventListener("focus",X),O.removeEventListener("blur",K),O.removeEventListener("mouseenter",X),O.removeEventListener("mouseleave",K))}},[b,r,h,M]);const I=Dt(e,p),C=Dt(e,_),U={left:Math.min(I.x,C.x),right:Math.max(I.x,C.x),top:Math.min(I.y,C.y),bottom:Math.max(I.y,C.y),flipX:I.x>C.x,flipY:I.y>C.y,width:0,height:0};return U.width=U.right-U.left,U.height=U.bottom-U.top,re.jsxs("div",{ref:b,tabIndex:0,style:{position:"relative"},onMouseEnter:()=>{t&&b.current&&b.current.focus()},onMouseLeave:()=>{b.current&&b.current.blur()},onMouseMove:O=>{const H=O.currentTarget.getBoundingClientRect(),Y=O.clientX-H.left,X=O.clientY-H.top,K=Dt(F2(e),{x:Y,y:X});if(x.current.x=K.x,x.current.y=K.y,s){const J=M(K);g({x:J.point.x,y:J.point.y}),d(le=>({...le,end:J.id}))}},onMouseDown:O=>{const H=O.currentTarget.getBoundingClientRect(),Y=O.clientX-H.left,X=O.clientY-H.top,K=Dt(F2(e),{x:Y,y:X});if(c&&!r){const J=M(K);m({x:J.point.x,y:J.point.y}),g({x:J.point.x,y:J.point.y}),d({start:J.id,end:J.id}),o(!0),a(!0),h()}else s?(a(!1),d(J=>({...J,end:null}))):r&&(o(!1),d({start:null,end:null}))},children:[n,r&&re.jsxs(re.Fragment,{children:[re.jsx("div",{style:{position:"absolute",left:U.left,width:U.width,textAlign:"center",top:I.y+2,color:"red",mixBlendMode:"difference",pointerEvents:"none",marginTop:U.flipY?0:-20,fontSize:12,fontFamily:"sans-serif",zIndex:u_.dimensionOverlay},children:Math.abs(p.x-_.x).toFixed(2)}),re.jsx("div",{style:{position:"absolute",left:C.x,height:U.height,display:"flex",flexDirection:"column",justifyContent:"center",top:U.top,color:"red",pointerEvents:"none",mixBlendMode:"difference",fontSize:12,fontFamily:"sans-serif",zIndex:u_.dimensionOverlay},children:re.jsx("div",{style:{marginLeft:U.flipX?"-100%":4,paddingRight:4},children:Math.abs(p.y-_.y).toFixed(2)})}),re.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:u_.dimensionOverlay},width:E.width,height:E.height,children:[re.jsx("defs",{children:re.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:re.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),re.jsx("line",{x1:I.x,y1:I.y,x2:C.x,y2:C.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),re.jsx("line",{x1:I.x,y1:I.y,x2:C.x,y2:I.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),re.jsx("line",{x1:C.x,y1:I.y,x2:C.x,y2:C.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),s&&R.map(O=>{const H=O.id===u.start||O.id===u.end,Y=G4/2;return re.jsxs("svg",{width:G4,height:G4,style:{position:"absolute",left:O.screenPoint.x-Y,top:O.screenPoint.y-Y,pointerEvents:"none",zIndex:u_.dimensionOverlay},children:[re.jsx("line",{x1:0,y1:0,x2:G4,y2:G4,stroke:H?"#66ccff":"white",strokeWidth:1}),re.jsx("line",{x1:G4,y1:0,x2:0,y2:G4,stroke:H?"#66ccff":"white",strokeWidth:1})]},O.id)}),re.jsxs("div",{style:{right:0,bottom:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4},children:["(",p.x.toFixed(2),",",p.y.toFixed(2),")",re.jsx("br",{}),"(",_.x.toFixed(2),",",_.y.toFixed(2),")",re.jsx("br",{}),"dist:"," ",Math.sqrt((_.x-p.x)**2+(_.y-p.y)**2).toFixed(2)]})]})]})},NUn=(n,e,t=0)=>{const i=n.width/2,r=n.height/2,o=n.center.x-i-t,s=n.center.x+i+t,a=n.center.y-r-t,c=n.center.y+r+t;return e.x>o&&e.x<s&&e.y>a&&e.y<c},kUn=({children:n,disabled:e,transform:t,soup:i,cancelPanDrag:r,onCreateEditEvent:o,onModifyEditEvent:s})=>{t||(t=Bh());const a=ce.useRef(null),[c,l]=ce.useState(null),[u,d]=ce.useState(null),h=c!==null;iv(g=>g.in_edit_mode);const p=iv(g=>g.in_move_footprint_mode),m=iv(g=>g.setIsMovingComponent),_=e||!p;return re.jsxs("div",{ref:a,style:{position:"relative",overflow:"hidden"},onMouseDown:g=>{if(_)return;const x=g.currentTarget.getBoundingClientRect(),b=g.clientX-x.left,w=g.clientY-x.top;if(Number.isNaN(b)||Number.isNaN(w))return;const E=Dt(F2(t),{x:b,y:w});let k=!1;for(const A of i)if(A.type==="pcb_component"&&NUn(A,E,10/t.a)){r(),l(A.pcb_component_id),k=!0;const R=Math.random().toString();d({dragStart:E,originalCenter:A.center,dragEnd:E,edit_event_id:R}),o({edit_event_id:R,edit_event_type:"edit_pcb_component_location",pcb_edit_event_type:"edit_component_location",pcb_component_id:A.pcb_component_id,original_center:A.center,new_center:A.center,in_progress:!0,created_at:Date.now()}),m(!0);break}if(k||l(null),k)return g.preventDefault(),!1},onMouseMove:g=>{if(!c||!u)return;const x=g.currentTarget.getBoundingClientRect(),b=g.clientX-x.left,w=g.clientY-x.top;if(Number.isNaN(b)||Number.isNaN(w))return;const E=Dt(F2(t),{x:b,y:w});d({...u,dragEnd:E}),s({edit_event_id:u.edit_event_id,new_center:{x:u.originalCenter.x+E.x-u.dragStart.x,y:u.originalCenter.y+E.y-u.dragStart.y}})},onMouseUp:g=>{c&&(l(null),m(!1),u&&(s({edit_event_id:u.edit_event_id,in_progress:!1}),d(null)))},children:[n,!_&&i.filter(g=>g.type==="pcb_component").map(g=>{if(!g?.center)return null;const x=Dt(t,g.center);return re.jsx("div",{style:{position:"absolute",pointerEvents:"none",left:x.x,top:x.y,width:g.width*t.a+20,height:g.height*t.a+20,transform:"translate(-50%, -50%)",background:h&&c===g.pcb_component_id?"rgba(255, 0, 0, 0.2)":""}},g.pcb_component_id)})]})},OUn=({hotkeys:n})=>(ce.useEffect(()=>{const e=t=>{n.forEach(i=>{t.key===i.key&&i.onUse()})};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[n]),re.jsx("div",{className:JI`
5567
+ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function kht(n,e,t){if(!e||!t)return;let i=n.get(e);i||(i=new Set,n.set(e,i)),i.add(t);let r=n.get(t);r||(r=new Set,n.set(t,r)),r.add(e)}function IFn(n,e){if(!e.subcircuit_id&&!e.source_group_id)return[...n];const t=new Map;for(const s of n){const a=s[`${s.type}_id`];typeof a=="string"&&t.set(a,s)}const i=new Map;for(const s of n){const a=Object.entries(s);for(const[c,l]of a)if(c!=="parent_source_group_id"){if(c.endsWith("_id")&&typeof l=="string"){const u=t.get(l);kht(i,s,u)}else if(c.endsWith("_ids")&&Array.isArray(l)){for(const u of l)if(typeof u=="string"){const d=t.get(u);kht(i,s,d)}}}}const r=[],o=new Set;for(const s of n)(e.subcircuit_id&&s.subcircuit_id===e.subcircuit_id||e.source_group_id&&(s.source_group_id===e.source_group_id||Array.isArray(s.member_source_group_ids)&&s.member_source_group_ids.includes(e.source_group_id)))&&(r.push(s),o.add(s));for(;r.length>0;){const s=r.shift(),a=i.get(s);if(a)for(const c of a)o.has(c)||(o.add(c),r.push(c))}return n.filter(s=>o.has(s))}var eq=(n,e={})=>{const t=n;let i=t._internal_store;if(!i){i={counts:{},editCount:0},t._internal_store=i;for(const o of t){const s=o.type,a=o[`${s}_id`];if(!a)continue;const c=Number.parseInt(a.split("_").pop());Number.isNaN(c)||(i.counts[s]=Math.max(i.counts[s]??0,c))}}return new Proxy({},{get:(o,s)=>{if(s==="toArray")return()=>(t.editCount=i.editCount,t);if(s==="editCount")return i.editCount;if(s==="subtree")return c=>eq(IFn(t,c),e);const a=s;return{get:c=>t.find(l=>l.type===a&&l[`${a}_id`]===c),getUsing:c=>{const l=Object.keys(c);if(l.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const u=l[0],d=u.replace("_id",""),h=t.find(p=>p.type===d&&p[u]===c[u]);return h?t.find(p=>p.type===a&&p[`${a}_id`]===h[`${a}_id`]):null},getWhere:c=>{const l=Object.keys(c);return t.find(u=>u.type===a&&l.every(d=>u[d]===c[d]))},list:c=>{const l=c?Object.keys(c):[];return t.filter(u=>u.type===a&&l.every(d=>u[d]===c[d]))},insert:c=>{i.counts[a]??=-1,i.counts[a]++;const l=i.counts[a],u={type:a,[`${a}_id`]:`${a}_${l}`,...c};return e.validateInserts&&(Fdt[a]??zbe).parse(u),t.push(u),i.editCount++,u},delete:c=>{const l=t.find(u=>u[`${a}_id`]===c);l&&(t.splice(t.indexOf(l),1),i.editCount++)},update:(c,l)=>{const u=t.find(d=>d.type===a&&d[`${a}_id`]===c);return u?(Object.assign(u,l),i.editCount++,u):null},select:c=>{if(a==="source_component")return t.find(l=>l.type==="source_component"&&l.name===c.replace(/\./g,""));if(a==="pcb_port"||a==="source_port"||a==="schematic_port"){const[l,u]=c.replace(/\./g,"").split(/[\s\>]+/),d=t.find(p=>p.type==="source_component"&&p.name===l);if(!d)return null;const h=t.find(p=>p.type==="source_port"&&p.source_component_id===d.source_component_id&&(p.name===u||(p.port_hints??[]).includes(u)));if(!h)return null;if(a==="source_port")return h;if(a==="pcb_port")return t.find(p=>p.type==="pcb_port"&&p.source_port_id===h.source_port_id);if(a==="schematic_port")return t.find(p=>p.type==="schematic_port"&&p.source_port_id===h.source_port_id)}}}}})};eq.unparsed=eq;var fC=eq;function cve(n){const e=n.type;return`${e}:${n[`${e}_id`]}`}var Oht=(n,e={})=>{let t=n._internal_store_indexed;if(!t){t={counts:{},editCount:0,indexes:{}};for(const s of n){const a=s.type,c=s[`${a}_id`];if(!c)continue;const l=Number.parseInt(c.split("_").pop()||"");Number.isNaN(l)||(t.counts[a]=Math.max(t.counts[a]??0,l))}const r=e.indexConfig||{},o=t.indexes;if(r.byId&&(o.byId=new Map),r.byType&&(o.byType=new Map),r.byRelation&&(o.byRelation=new Map),r.bySubcircuit&&(o.bySubcircuit=new Map),r.byCustomField&&r.byCustomField.length>0){o.byCustomField=new Map;for(const s of r.byCustomField)o.byCustomField.set(s,new Map)}for(const s of n){if(r.byId){const a=cve(s);o.byId.set(a,s)}if(r.byType){const a=o.byType.get(s.type)||[];a.push(s),o.byType.set(s.type,a)}if(r.byRelation){const a=Object.entries(s);for(const[c,l]of a)if(c.endsWith("_id")&&c!==`${s.type}_id`&&typeof l=="string"){const u=o.byRelation.get(c)||new Map,d=u.get(l)||[];d.push(s),u.set(l,d),o.byRelation.set(c,u)}}if(r.bySubcircuit&&"subcircuit_id"in s){const a=s.subcircuit_id;if(a&&typeof a=="string"){const c=o.bySubcircuit.get(a)||[];c.push(s),o.bySubcircuit.set(a,c)}}if(r.byCustomField&&o.byCustomField){for(const a of r.byCustomField)if(a in s){const c=s[a];if(c!==void 0&&(typeof c=="string"||typeof c=="number")){const l=String(c),u=o.byCustomField.get(a),d=u.get(l)||[];d.push(s),u.set(l,d)}}}}n._internal_store_indexed=t}return new Proxy({},{get:(r,o)=>{if(o==="toArray")return()=>(n.editCount=t.editCount,n);if(o==="editCount")return t.editCount;const s=o;return{get:a=>{const c=e.indexConfig||{};return c.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${a}`)||null:c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(u=>u[`${s}_id`]===a)||null:n.find(l=>l.type===s&&l[`${s}_id`]===a)||null},getUsing:a=>{const c=e.indexConfig||{},l=Object.keys(a);if(l.length!==1)throw new Error("getUsing requires exactly one key, e.g. { pcb_component_id }");const u=l[0],d=u.replace("_id","");if(c.byRelation&&t.indexes.byRelation){const p=t.indexes.byRelation.get(u);if(p){const _=(p.get(a[u])||[]).find(x=>x.type===d);if(!_)return null;const g=_[`${s}_id`];return c.byId&&t.indexes.byId?t.indexes.byId.get(`${s}:${g}`)||null:c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(b=>b[`${s}_id`]===g)||null:n.find(x=>x.type===s&&x[`${s}_id`]===g)||null}}const h=n.find(p=>p.type===d&&p[u]===a[u]);return h&&n.find(p=>p.type===s&&p[`${s}_id`]===h[`${s}_id`])||null},getWhere:a=>{const c=e.indexConfig||{},l=Object.keys(a);if(l.length===1&&c.byCustomField&&t.indexes.byCustomField){const u=l[0],d=t.indexes.byCustomField.get(u);if(d){const h=String(a[u]);return(d.get(h)||[]).find(m=>m.type===s)||null}}if("subcircuit_id"in a&&c.bySubcircuit&&t.indexes.bySubcircuit){const u=a.subcircuit_id;return(t.indexes.bySubcircuit.get(u)||[]).find(h=>h.type===s&&l.every(p=>h[p]===a[p]))||null}return c.byType&&t.indexes.byType?(t.indexes.byType.get(s)||[]).find(d=>l.every(h=>d[h]===a[h]))||null:n.find(u=>u.type===s&&l.every(d=>u[d]===a[d]))||null},list:a=>{const c=e.indexConfig||{},l=a?Object.keys(a):[];if(l.length===0&&c.byType&&t.indexes.byType)return t.indexes.byType.get(s)||[];if(l.length===1&&l[0]==="subcircuit_id"&&c.bySubcircuit&&t.indexes.bySubcircuit){const d=a.subcircuit_id;return(t.indexes.bySubcircuit.get(d)||[]).filter(p=>p.type===s)}let u;return c.byType&&t.indexes.byType?u=t.indexes.byType.get(s)||[]:u=n.filter(d=>d.type===s),l.length>0?u.filter(d=>l.every(h=>d[h]===a[h])):u},insert:a=>{t.counts[s]??=-1,t.counts[s]++;const c=t.counts[s],l={type:s,[`${s}_id`]:`${s}_${c}`,...a};e.validateInserts&&(Fdt[s]??zbe).parse(l),n.push(l),t.editCount++;const u=e.indexConfig||{};if(u.byId&&t.indexes.byId){const d=cve(l);t.indexes.byId.set(d,l)}if(u.byType&&t.indexes.byType){const d=t.indexes.byType.get(s)||[];d.push(l),t.indexes.byType.set(s,d)}if(u.byRelation&&t.indexes.byRelation){const d=Object.entries(l);for(const[h,p]of d)if(h.endsWith("_id")&&h!==`${l.type}_id`&&typeof p=="string"){const m=t.indexes.byRelation.get(h)||new Map,_=m.get(p)||[];_.push(l),m.set(p,_),t.indexes.byRelation.set(h,m)}}if(u.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in l){const d=l.subcircuit_id;if(d&&typeof d=="string"){const h=t.indexes.bySubcircuit.get(d)||[];h.push(l),t.indexes.bySubcircuit.set(d,h)}}if(u.byCustomField&&t.indexes.byCustomField){for(const d of u.byCustomField)if(d in l){const h=l[d];if(h!==void 0&&(typeof h=="string"||typeof h=="number")){const p=String(h),m=t.indexes.byCustomField.get(d),_=m.get(p)||[];_.push(l),m.set(p,_)}}}return l},delete:a=>{const c=e.indexConfig||{};let l;if(c.byId&&t.indexes.byId?l=t.indexes.byId.get(`${s}:${a}`):c.byType&&t.indexes.byType?l=(t.indexes.byType.get(s)||[]).find(h=>h[`${s}_id`]===a):l=n.find(d=>d[`${s}_id`]===a),!l)return;const u=n.indexOf(l);if(u>=0&&(n.splice(u,1),t.editCount++),c.byId&&t.indexes.byId){const d=cve(l);t.indexes.byId.delete(d)}if(c.byType&&t.indexes.byType){const h=(t.indexes.byType.get(s)||[]).filter(p=>p[`${s}_id`]!==a);t.indexes.byType.set(s,h)}if(c.byRelation&&t.indexes.byRelation)for(const[d,h]of t.indexes.byRelation.entries())for(const[p,m]of h.entries()){const _=m.filter(g=>g!==l);_.length===0?h.delete(p):h.set(p,_)}if(c.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in l){const d=l.subcircuit_id;if(d){const p=(t.indexes.bySubcircuit.get(d)||[]).filter(m=>m!==l);p.length===0?t.indexes.bySubcircuit.delete(d):t.indexes.bySubcircuit.set(d,p)}}if(c.byCustomField&&t.indexes.byCustomField)for(const d of t.indexes.byCustomField.values())for(const[h,p]of d.entries()){const m=p.filter(_=>_!==l);m.length===0?d.delete(h):d.set(h,m)}},update:(a,c)=>{const l=e.indexConfig||{};let u;if(l.byId&&t.indexes.byId?u=t.indexes.byId.get(`${s}:${a}`):l.byType&&t.indexes.byType?u=(t.indexes.byType.get(s)||[]).find(h=>h[`${s}_id`]===a):u=n.find(d=>d.type===s&&d[`${s}_id`]===a),!u)return null;if(l.byRelation&&t.indexes.byRelation){const d=Object.entries(u);for(const[h,p]of d)if(h.endsWith("_id")&&h!==`${u.type}_id`&&typeof p=="string"&&h in c&&c[h]!==p){const m=t.indexes.byRelation.get(h);if(m){const g=(m.get(p)||[]).filter(x=>x!==u);g.length===0?m.delete(p):m.set(p,g)}}}if(l.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in u&&"subcircuit_id"in c){const d=u.subcircuit_id,h=c.subcircuit_id;if(d!==h){const m=(t.indexes.bySubcircuit.get(d)||[]).filter(_=>_!==u);m.length===0?t.indexes.bySubcircuit.delete(d):t.indexes.bySubcircuit.set(d,m)}}if(l.byCustomField&&t.indexes.byCustomField){for(const d of l.byCustomField)if(d in u&&d in c&&u[d]!==c[d]){const h=t.indexes.byCustomField.get(d);if(h){const p=String(u[d]),_=(h.get(p)||[]).filter(g=>g!==u);_.length===0?h.delete(p):h.set(p,_)}}}if(Object.assign(u,c),t.editCount++,l.byRelation&&t.indexes.byRelation){const d=Object.entries(u);for(const[h,p]of d)if(h.endsWith("_id")&&h!==`${u.type}_id`&&typeof p=="string"&&h in c){const m=t.indexes.byRelation.get(h)||new Map,_=m.get(p)||[];_.includes(u)||(_.push(u),m.set(p,_),t.indexes.byRelation.set(h,m))}}if(l.bySubcircuit&&t.indexes.bySubcircuit&&"subcircuit_id"in u&&"subcircuit_id"in c){const d=u.subcircuit_id;if(d&&typeof d=="string"){const h=t.indexes.bySubcircuit.get(d)||[];h.includes(u)||(h.push(u),t.indexes.bySubcircuit.set(d,h))}}if(l.byCustomField&&t.indexes.byCustomField){for(const d of l.byCustomField)if(d in u&&d in c){const h=u[d];if(h!==void 0&&(typeof h=="string"||typeof h=="number")){const p=String(h),m=t.indexes.byCustomField.get(d),_=m.get(p)||[];_.includes(u)||(_.push(u),m.set(p,_))}}}return u},select:a=>{if(s==="source_component")return n.find(c=>c.type==="source_component"&&c.name===a.replace(/\./g,""))||null;if(s==="pcb_port"||s==="source_port"||s==="schematic_port"){const[c,l]=a.replace(/\./g,"").split(/[\s\>]+/),u=n.find(h=>h.type==="source_component"&&h.name===c);if(!u)return null;const d=n.find(h=>h.type==="source_port"&&h.source_component_id===u.source_component_id&&(h.name===l||(h.port_hints??[]).includes(l)));if(!d)return null;if(s==="source_port")return d;if(s==="pcb_port")return n.find(h=>h.type==="pcb_port"&&h.source_port_id===d.source_port_id)||null;if(s==="schematic_port")return n.find(h=>h.type==="schematic_port"&&h.source_port_id===d.source_port_id)||null}return null}}}})};Oht.unparsed=Oht;var NFn=n=>{const e=n.type;return n[`${e}_id`]},kFn=n=>{let e=Number.POSITIVE_INFINITY,t=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const o of n){if(!o.type.startsWith("pcb_"))continue;let s,a,c,l;if("x"in o&&"y"in o&&(s=Number(o.x),a=Number(o.y)),"outer_diameter"in o&&(c=Number(o.outer_diameter),l=Number(o.outer_diameter)),"width"in o&&(c=Number(o.width)),"height"in o&&(l=Number(o.height)),"center"in o&&(s=o.center.x,a=o.center.y),s!==void 0&&a!==void 0)e=Math.min(e,s),t=Math.min(t,a),i=Math.max(i,s),r=Math.max(r,a),c!==void 0&&l!==void 0&&(e=Math.min(e,s-c/2),t=Math.min(t,a-l/2),i=Math.max(i,s+c/2),r=Math.max(r,a+l/2)),"radius"in o&&(e=Math.min(e,s-o.radius),t=Math.min(t,a-o.radius),i=Math.max(i,s+o.radius),r=Math.max(r,a+o.radius));else if(o.type==="pcb_trace")for(const u of o.route)e=Math.min(e,u.x),t=Math.min(t,u.y),i=Math.max(i,u.x),r=Math.max(r,u.y)}return{minX:e,minY:t,maxX:i,maxY:r}};function OFn(n){let e=0;if(n.length==0)return e;for(var t=0;t<n.length;t++){var i=n.charCodeAt(t);e=(e<<5)-e+i,e=e&e}return Math.abs(e)}var Lht=[["#69d2e7","#a7dbd8","#e0e4cc","#f38630","#fa6900"],["#fe4365","#fc9d9a","#f9cdad","#c8c8a9","#83af9b"],["#ecd078","#d95b43","#c02942","#542437","#53777a"],["#556270","#4ecdc4","#c7f464","#ff6b6b","#c44d58"],["#774f38","#e08e79","#f1d4af","#ece5ce","#c5e0dc"],["#e8ddcb","#cdb380","#036564","#033649","#031634"],["#490a3d","#bd1550","#e97f02","#f8ca00","#8a9b0f"],["#594f4f","#547980","#45ada8","#9de0ad","#e5fcc2"],["#00a0b0","#6a4a3c","#cc333f","#eb6841","#edc951"],["#e94e77","#d68189","#c6a49a","#c6e5d9","#f4ead5"],["#3fb8af","#7fc7af","#dad8a7","#ff9e9d","#ff3d7f"],["#d9ceb2","#948c75","#d5ded9","#7a6a53","#99b2b7"],["#ffffff","#cbe86b","#f2e9e1","#1c140d","#cbe86b"],["#efffcd","#dce9be","#555152","#2e2633","#99173c"],["#343838","#005f6b","#008c9e","#00b4cc","#00dffc"],["#413e4a","#73626e","#b38184","#f0b49e","#f7e4be"],["#ff4e50","#fc913a","#f9d423","#ede574","#e1f5c4"],["#99b898","#fecea8","#ff847c","#e84a5f","#2a363b"],["#655643","#80bca3","#f6f7bd","#e6ac27","#bf4d28"],["#00a8c6","#40c0cb","#f9f2e7","#aee239","#8fbe00"],["#351330","#424254","#64908a","#e8caa4","#cc2a41"],["#554236","#f77825","#d3ce3d","#f1efa5","#60b99a"],["#5d4157","#838689","#a8caba","#cad7b2","#ebe3aa"],["#8c2318","#5e8c6a","#88a65e","#bfb35a","#f2c45a"],["#fad089","#ff9c5b","#f5634a","#ed303c","#3b8183"],["#ff4242","#f4fad2","#d4ee5e","#e1edb9","#f0f2eb"],["#f8b195","#f67280","#c06c84","#6c5b7b","#355c7d"],["#d1e751","#ffffff","#000000","#4dbce9","#26ade4"],["#1b676b","#519548","#88c425","#bef202","#eafde6"],["#5e412f","#fcebb6","#78c0a8","#f07818","#f0a830"],["#bcbdac","#cfbe27","#f27435","#f02475","#3b2d38"],["#452632","#91204d","#e4844a","#e8bf56","#e2f7ce"],["#eee6ab","#c5bc8e","#696758","#45484b","#36393b"],["#f0d8a8","#3d1c00","#86b8b1","#f2d694","#fa2a00"],["#2a044a","#0b2e59","#0d6759","#7ab317","#a0c55f"],["#f04155","#ff823a","#f2f26f","#fff7bd","#95cfb7"],["#b9d7d9","#668284","#2a2829","#493736","#7b3b3b"],["#bbbb88","#ccc68d","#eedd99","#eec290","#eeaa88"],["#b3cc57","#ecf081","#ffbe40","#ef746f","#ab3e5b"],["#a3a948","#edb92e","#f85931","#ce1836","#009989"],["#300030","#480048","#601848","#c04848","#f07241"],["#67917a","#170409","#b8af03","#ccbf82","#e33258"],["#aab3ab","#c4cbb7","#ebefc9","#eee0b7","#e8caaf"],["#e8d5b7","#0e2430","#fc3a51","#f5b349","#e8d5b9"],["#ab526b","#bca297","#c5ceae","#f0e2a4","#f4ebc3"],["#607848","#789048","#c0d860","#f0f0d8","#604848"],["#b6d8c0","#c8d9bf","#dadabd","#ecdbbc","#fedcba"],["#a8e6ce","#dcedc2","#ffd3b5","#ffaaa6","#ff8c94"],["#3e4147","#fffedf","#dfba69","#5a2e2e","#2a2c31"],["#fc354c","#29221f","#13747d","#0abfbc","#fcf7c5"],["#cc0c39","#e6781e","#c8cf02","#f8fcc1","#1693a7"],["#1c2130","#028f76","#b3e099","#ffeaad","#d14334"],["#a7c5bd","#e5ddcb","#eb7b59","#cf4647","#524656"],["#dad6ca","#1bb0ce","#4f8699","#6a5e72","#563444"],["#5c323e","#a82743","#e15e32","#c0d23e","#e5f04c"],["#edebe6","#d6e1c7","#94c7b6","#403b33","#d3643b"],["#fdf1cc","#c6d6b8","#987f69","#e3ad40","#fcd036"],["#230f2b","#f21d41","#ebebbc","#bce3c5","#82b3ae"],["#b9d3b0","#81bda4","#b28774","#f88f79","#f6aa93"],["#3a111c","#574951","#83988e","#bcdea5","#e6f9bc"],["#5e3929","#cd8c52","#b7d1a3","#dee8be","#fcf7d3"],["#1c0113","#6b0103","#a30006","#c21a01","#f03c02"],["#000000","#9f111b","#b11623","#292c37","#cccccc"],["#382f32","#ffeaf2","#fcd9e5","#fbc5d8","#f1396d"],["#e3dfba","#c8d6bf","#93ccc6","#6cbdb5","#1a1f1e"],["#f6f6f6","#e8e8e8","#333333","#990100","#b90504"],["#1b325f","#9cc4e4","#e9f2f9","#3a89c9","#f26c4f"],["#a1dbb2","#fee5ad","#faca66","#f7a541","#f45d4c"],["#c1b398","#605951","#fbeec2","#61a6ab","#accec0"],["#5e9fa3","#dcd1b4","#fab87f","#f87e7b","#b05574"],["#951f2b","#f5f4d7","#e0dfb1","#a5a36c","#535233"],["#8dccad","#988864","#fea6a2","#f9d6ac","#ffe9af"],["#2d2d29","#215a6d","#3ca2a2","#92c7a3","#dfece6"],["#413d3d","#040004","#c8ff00","#fa023c","#4b000f"],["#eff3cd","#b2d5ba","#61ada0","#248f8d","#605063"],["#ffefd3","#fffee4","#d0ecea","#9fd6d2","#8b7a5e"],["#cfffdd","#b4dec1","#5c5863","#a85163","#ff1f4c"],["#9dc9ac","#fffec7","#f56218","#ff9d2e","#919167"],["#4e395d","#827085","#8ebe94","#ccfc8e","#dc5b3e"],["#a8a7a7","#cc527a","#e8175d","#474747","#363636"],["#f8edd1","#d88a8a","#474843","#9d9d93","#c5cfc6"],["#046d8b","#309292","#2fb8ac","#93a42a","#ecbe13"],["#f38a8a","#55443d","#a0cab5","#cde9ca","#f1edd0"],["#a70267","#f10c49","#fb6b41","#f6d86b","#339194"],["#ff003c","#ff8a00","#fabe28","#88c100","#00c176"],["#ffedbf","#f7803c","#f54828","#2e0d23","#f8e4c1"],["#4e4d4a","#353432","#94ba65","#2790b0","#2b4e72"],["#0ca5b0","#4e3f30","#fefeeb","#f8f4e4","#a5b3aa"],["#4d3b3b","#de6262","#ffb88c","#ffd0b3","#f5e0d3"],["#fffbb7","#a6f6af","#66b6ab","#5b7c8d","#4f2958"],["#edf6ee","#d1c089","#b3204d","#412e28","#151101"],["#9d7e79","#ccac95","#9a947c","#748b83","#5b756c"],["#fcfef5","#e9ffe1","#cdcfb7","#d6e6c3","#fafbe3"],["#9cddc8","#bfd8ad","#ddd9ab","#f7af63","#633d2e"],["#30261c","#403831","#36544f","#1f5f61","#0b8185"],["#aaff00","#ffaa00","#ff00aa","#aa00ff","#00aaff"],["#d1313d","#e5625c","#f9bf76","#8eb2c5","#615375"],["#ffe181","#eee9e5","#fad3b2","#ffba7f","#ff9c97"],["#73c8a9","#dee1b6","#e1b866","#bd5532","#373b44"],["#805841","#dcf7f3","#fffcdd","#ffd8d8","#f5a2a2"]],LFn=n=>{let{x:e,y:t,width:i,height:r}={...n,...n.size,...n.center,...n.position};if(n.x1!==void 0&&n.x2!==void 0&&n.y1!==void 0&&n.y2!==void 0&&(e=(n.x1+n.x2)/2,t=(n.y1+n.y2)/2,i=Math.abs(n.x1-n.x2),r=Math.abs(n.y1-n.y2)),n.points&&Array.isArray(n.points)&&n.points.length>0){const a=n.points.map(p=>p.x),c=n.points.map(p=>p.y),l=Math.min(...a),u=Math.max(...a),d=Math.min(...c),h=Math.max(...c);e=(l+u)/2,t=(d+h)/2,i=u-l,r=h-d}const o=n.text||n.name||n.source?.text||n.source?.name||"?",s=n;return e===void 0||t===void 0?null:(i===void 0&&"outer_diameter"in n&&(i=n.outer_diameter,r=n.outer_diameter),(i===void 0||r===void 0)&&(i=.1,r=.1),{x:e,y:t,width:i,height:r,title:o,content:s,bg_color:Lht[OFn(n.type||o)%Lht.length]?.[4]??"#f00"})},DFn=n=>!!n,zFn=n=>{const e=n.filter(l=>l.type.startsWith("pcb_")||l.type.startsWith("schematic_")).concat(n.filter(l=>l.type==="pcb_trace"||l.type==="schematic_trace").flatMap(l=>l.route)).map(l=>LFn(l)).filter(DFn);if(e.length===0)return{center:{x:0,y:0},width:0,height:0};let t=e[0].x-e[0].width/2,i=e[0].x+e[0].width/2,r=e[0].y-e[0].height/2,o=e[0].y+e[0].height/2;for(const l of e.slice(1))t=Math.min(t,l.x-l.width/2),i=Math.max(i,l.x+l.width/2),r=Math.min(r,l.y-l.height/2),o=Math.max(o,l.y+l.height/2);const s=i-t,a=o-r;return{center:{x:t+s/2,y:r+a/2},width:s,height:a}},eN={IS_SHOWING_PCB_GROUPS:"pcb_viewer_is_showing_pcb_groups",PCB_GROUP_VIEW_MODE:"pcb_viewer_group_view_mode",IS_SHOWING_COPPER_POURS:"pcb_viewer_is_showing_copper_pours"},Dht=(n,e)=>{if(typeof window>"u")return e;try{const t=localStorage.getItem(n);return t!==null?JSON.parse(t):e}catch{return e}},zht=(n,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(n,JSON.stringify(e))}catch{}},$Fn=(n,e)=>{if(typeof window>"u")return e;try{const t=localStorage.getItem(n);return t!==null?JSON.parse(t):e}catch{return e}},FFn=(n,e)=>{if(!(typeof window>"u"))try{localStorage.setItem(n,JSON.stringify(e))}catch{}},UFn="named_only",BFn=(n={},e=!1)=>lze(t=>({selected_layer:"top",pcb_viewer_id:`pcb_viewer_${Math.random().toString().slice(2,10)}`,in_edit_mode:!1,in_move_footprint_mode:!1,in_draw_trace_mode:!1,is_moving_component:!1,is_drawing_trace:!1,is_mouse_over_container:!1,is_showing_multiple_traces_length:!1,is_showing_rats_nest:!1,is_showing_autorouting:!0,is_showing_drc_errors:!0,is_showing_copper_pours:Dht(eN.IS_SHOWING_COPPER_POURS,!0),is_showing_pcb_groups:e?!1:Dht(eN.IS_SHOWING_PCB_GROUPS,!0),pcb_group_view_mode:e?"all":$Fn(eN.PCB_GROUP_VIEW_MODE,UFn),hovered_error_id:null,...n,selectLayer:i=>t({selected_layer:i}),setEditMode:i=>t({in_edit_mode:i!=="off",in_move_footprint_mode:i==="move_footprint",in_draw_trace_mode:i==="draw_trace",is_moving_component:!1,is_drawing_trace:!1}),setIsShowingRatsNest:i=>t({is_showing_rats_nest:i}),setIsMovingComponent:i=>t({is_moving_component:i}),setIsDrawingTrace:i=>t({is_drawing_trace:i}),setIsMouseOverContainer:i=>t({is_mouse_over_container:i}),setIsShowingMultipleTracesLength:i=>t({is_showing_multiple_traces_length:i}),setIsShowingAutorouting:i=>t({is_showing_autorouting:i}),setIsShowingDrcErrors:i=>t({is_showing_drc_errors:i}),setIsShowingCopperPours:i=>{zht(eN.IS_SHOWING_COPPER_POURS,i),t({is_showing_copper_pours:i})},setIsShowingPcbGroups:i=>{e||(zht(eN.IS_SHOWING_PCB_GROUPS,i),t({is_showing_pcb_groups:i}))},setPcbGroupViewMode:i=>{e||(FFn(eN.PCB_GROUP_VIEW_MODE,i),t({pcb_group_view_mode:i}))},setHoveredErrorId:i=>t({hovered_error_id:i})})),iv=n=>{const e=ce.useContext($ht);return xze(e,n)},$ht=ce.createContext(null),jFn=({children:n,initialState:e,disablePcbGroups:t})=>{const i=ce.useMemo(()=>BFn(e,t),[t]);return re.jsx($ht.Provider,{value:i,children:n})},HFn=()=>{const n=iv(t=>t.pcb_viewer_id),e=(t,i)=>zf(t,{containerId:n,...i});return e.error=(t,i)=>zf.error(t,{containerId:n,...i}),e.promise=zf.promise,e},VFn=()=>{ce.useEffect(()=>{p$n()},[]);const n=iv(e=>e.pcb_viewer_id);return re.jsx(h$n,{position:"top-center",containerId:n})},GFn=function(){},Fht=typeof window<"u",YFn=Fht?ce.useLayoutEffect:ce.useEffect,qFn=YFn,Uht={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function XFn(){var n=ce.useState(null),e=n[0],t=n[1],i=ce.useState(Uht),r=i[0],o=i[1],s=ce.useMemo(function(){return new window.ResizeObserver(function(a){if(a[0]){var c=a[0].contentRect,l=c.x,u=c.y,d=c.width,h=c.height,p=c.top,m=c.left,_=c.bottom,g=c.right;o({x:l,y:u,width:d,height:h,top:p,left:m,bottom:_,right:g})}})},[]);return qFn(function(){if(e)return s.observe(e),function(){s.disconnect()}},[e]),[t,r]}var tq=Fht&&typeof window.ResizeObserver<"u"?XFn:function(){return[GFn,Uht]},Bht=({initialTransform:n,initialTouch1:e,initialTouch2:t,finalTouch1:i,finalTouch2:r})=>{if(!i||!r)return n;const o={x:(e.x+t.x)/2,y:(e.y+t.y)/2},s={x:(i.x+r.x)/2,y:(i.y+r.y)/2},a=Math.hypot(t.x-e.x,t.y-e.y),c=Math.hypot(r.x-i.x,r.y-i.y),l=a===0?1:c/a,u=s.x-o.x,d=s.y-o.y;return ko(Go(u,d),Go(o.x,o.y),jm(l,l),Go(-o.x,-o.y),n)},WFn=(n={})=>{const e=ce.useRef(null),[t,i]=ce.useState(0),r=n.canvasElm??e.current,[o,s]=ce.useState(n.initialTransform??Bh()),[a,c]=ce.useState(0),[l,u]=ce.useReducer(w=>w+1,0),d=ce.useCallback(w=>{n.onSetTransform&&n.onSetTransform(w),n.transform||s(w)},[n.onSetTransform,s]),h=ce.useCallback(w=>{d(w),u()},[d]),p=n.transform??o,m=ce.useCallback(()=>{i(Date.now())},[]),_=ce.useRef("none"),g=ce.useRef(null),x=ce.useRef(null);ce.useEffect(()=>{const w=n.canvasElm??e.current;if(w&&!r){c(a+1);return}if(!w){const J=setTimeout(()=>{c(a+1)},100);return()=>clearTimeout(J)}let E=n.transform??o,k={x:0,y:0},A={x:0,y:0},R=!1;const M=J=>({x:J.pageX-w.getBoundingClientRect().left-window.scrollX,y:J.pageY-w.getBoundingClientRect().top-window.scrollY});function I(J){n.enabled!==!1&&(n.shouldDrag&&!n.shouldDrag(J)||(k=M(J),!(Date.now()-t<100)&&(R=!0,J.preventDefault())))}function C(J){if(!R||n.enabled===!1||n.shouldDrag&&!n.shouldDrag(J))return;A=M(J);const le=ko(Go(A.x-k.x,A.y-k.y),E);d(le),E=le,R=!1}function U(J){if(M(J),!R||n.enabled===!1||n.shouldDrag&&!n.shouldDrag(J))return;A=M(J);const le=ko(Go(A.x-k.x,A.y-k.y),E);d(le)}function O(J){if(n.enabled===!1||n.shouldDrag&&!n.shouldDrag(J))return;const le=M(J),pe=ko(Go(le.x,le.y),jm(1-J.deltaY/1e3,1-J.deltaY/1e3),Go(-le.x,-le.y),E);d(pe),E=pe,J.preventDefault()}function H(J){if(!R||n.shouldDrag&&!n.shouldDrag(J))return;if(w){const pe=w.getBoundingClientRect();if(J.clientX>=pe.left+10&&J.clientX<=pe.right-10&&J.clientY>=pe.top+10&&J.clientY<=pe.bottom-10)return}R=!1,A=M(J);const le=ko(Go(A.x-k.x,A.y-k.y),E);d(le),E=le}function Y(J){if(J.preventDefault(),n.enabled!==!1){if(J.touches.length===1){_.current="drag";const le=J.touches[0];g.current={initialTransform:E,initialTouch:{x:le.clientX,y:le.clientY}}}else if(J.touches.length===2){_.current="pinch";const le=J.touches[0],pe=J.touches[1];x.current={initialTransform:E,initialTouch1:{x:le.clientX,y:le.clientY},initialTouch2:{x:pe.clientX,y:pe.clientY},finalTouch1:null,finalTouch2:null}}}}function X(J){if(J.preventDefault(),n.enabled!==!1){if(_.current==="drag"&&J.touches.length===1&&g.current){const le=J.touches[0],pe={x:le.clientX,y:le.clientY},ve=pe.x-g.current.initialTouch.x,oe=pe.y-g.current.initialTouch.y,ae=ko(Go(ve,oe),g.current.initialTransform);d(ae)}else if(_.current==="pinch"&&J.touches.length===2&&x.current){const le=J.touches[0],pe=J.touches[1];x.current.finalTouch1={x:le.clientX,y:le.clientY},x.current.finalTouch2={x:pe.clientX,y:pe.clientY};const ve=Bht(x.current);d(ve)}}}function K(J){J.preventDefault();const le=J.changedTouches[0];if(_.current==="drag"&&g.current&&le){const pe={x:le.clientX,y:le.clientY},ve=pe.x-g.current.initialTouch.x,oe=pe.y-g.current.initialTouch.y,ae=ko(Go(ve,oe),g.current.initialTransform);d(ae),E=ae}else if(_.current==="pinch"&&x.current){const pe=Bht(x.current);d(pe),E=pe}_.current="none",g.current=null,x.current=null}return w.addEventListener("mousedown",I),w.addEventListener("mouseup",C),window.addEventListener("mousemove",U),w.addEventListener("mouseout",H),w.addEventListener("wheel",O),w.addEventListener("touchstart",Y,{passive:!1}),w.addEventListener("touchmove",X,{passive:!1}),w.addEventListener("touchend",K,{passive:!1}),w.addEventListener("touchcancel",K,{passive:!1}),()=>{w.removeEventListener("mousedown",I),w.removeEventListener("mouseup",C),window.removeEventListener("mousemove",U),w.removeEventListener("mouseout",H),w.removeEventListener("wheel",O),w.removeEventListener("touchstart",Y),w.removeEventListener("touchmove",X),w.removeEventListener("touchend",K),w.removeEventListener("touchcancel",K)}},[r,a,l,t,n.enabled,n.shouldDrag]);const b=ce.useCallback(w=>Dt(p,w),[p]);return{ref:e,transform:p,applyTransformToPoint:b,setTransform:h,cancelDrag:m}},KFn=WFn;function ZFn(n){const e=new Map;let t=0;function i(r){for(const[,s]of e)if(s.has(r))return s;const o=new Set;return e.set(`connectivity_net${t++}`,o),o}for(const r of n){let o=null;for(const s of r){if(!o)o=i(s);else if(!o.has(s)){const a=i(s);if(a!==o){for(const c of a)o.add(c);e.delete(Array.from(e.entries()).find(([,c])=>c===a)[0])}}o.add(s)}}return Object.fromEntries(Array.from(e.entries()).map(([r,o])=>[r,Array.from(o)]))}var QFn=class{netMap;idToNetMap;constructor(e){this.netMap=e,this.idToNetMap={};for(const[t,i]of Object.entries(e))for(const r of i)this.idToNetMap[r]=t}addConnections(e){for(const t of e){const i=new Set;for(const o of t){const s=this.idToNetMap[o];s&&i.add(s)}let r;if(i.size===0)r=`connectivity_net${Object.keys(this.netMap).length}`,this.netMap[r]=[];else if(i.size===1)r=i.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;else{r=i.values().next().value??`connectivity_net${Object.keys(this.netMap).length}`;for(const o of i)if(o!==r){this.netMap[r].push(...this.netMap[o]),this.netMap[o]=this.netMap[r];for(const s of this.netMap[r])this.idToNetMap[s]=r}}for(const o of t)this.netMap[r].includes(o)||this.netMap[r].push(o),this.idToNetMap[o]=r}}getIdsConnectedToNet(e){return this.netMap[e]||[]}getNetConnectedToId(e){return this.idToNetMap[e]}areIdsConnected(e,t){if(e===t)return!0;const i=this.getNetConnectedToId(e);if(!i)return!1;const r=this.getNetConnectedToId(t);return r?i===r||r===e||r===e:!1}areAllIdsConnected(e){const t=this.getNetConnectedToId(e[0]);for(const i of e){const r=this.getNetConnectedToId(i);if(r===void 0||r!==t)return!1}return!0}},jht=n=>{const e=[];for(const i of n)if(i.type==="source_trace")e.push([i.source_trace_id,...i.connected_source_port_ids??[],...i.connected_source_net_ids??[]].filter(Boolean));else if(i.type==="pcb_port"){const{pcb_port_id:r,source_port_id:o}=i;o&&r&&e.push([o,r])}else if(i.type==="pcb_smtpad"){const{pcb_smtpad_id:r,pcb_port_id:o}=i;o&&r&&e.push([r,o])}else if(i.type==="pcb_plated_hole"){const{pcb_plated_hole_id:r,pcb_port_id:o}=i;o&&r&&e.push([r,o])}else if(i.type==="pcb_trace"){const{pcb_trace_id:r,source_trace_id:o}=i,s=Array.isArray(i.route)?i.route.filter(a=>a&&a.route_type==="wire"):[];if(o&&r&&e.push([r,o]),Array.isArray(s)){const a=s.find(l=>l&&l.start_pcb_port_id)?.start_pcb_port_id,c=s.find(l=>l&&l.end_pcb_port_id)?.end_pcb_port_id;a&&r&&c&&e.push([a,r,c])}}else if(i.type==="pcb_via"){const{pcb_via_id:r,pcb_trace_id:o}=i;o&&r&&e.push([r,o])}else if(i.type==="source_component"&&i.internally_connected_source_port_ids)for(const r of i.internally_connected_source_port_ids)e.push(r);const t=ZFn(e);return new QFn(t)};function JFn({primitivesWithoutInteractionMetadata:n,drawingObjectIdsWithMouseOver:e,primitiveIdsInMousedOverNet:t}){const i=[];for(const r of n){const o={...r};r?.layer==="drill"?(o.is_in_highlighted_net=!1,o.is_mouse_over=!1):e.has(r._pcb_drawing_object_id)?o.is_mouse_over=!0:r._element&&("pcb_trace_id"in r._element&&t.includes(r._element.pcb_trace_id)||"pcb_port_id"in r._element&&t.includes(r._element.pcb_port_id))?o.is_in_highlighted_net=!0:(o.is_in_highlighted_net=!1,o.is_mouse_over=!1),i.push(o)}return i}function eUn(n,e){if(n.length<2)throw new Error("Stroke must have at least two points");const t=n.map(d=>Array.isArray(d)?{x:d[0],y:d[1]}:d),i=[],r=[];function o(d,h){const p=h.x-d.x,m=h.y-d.y,_=Math.sqrt(p*p+m*m);return{x:-m/_,y:p/_}}function s(d,h,p,m){const _=m/2,g={x:d.x+h.x*_*p,y:d.y+h.y*_*p};p>0?i.push(g):r.unshift(g)}const a=o(t[0],t[1]),c=t[0].trace_width??e;s(t[0],a,1,c),s(t[0],a,-1,c);for(let d=1;d<t.length-1;d++){const h=t[d-1],p=t[d],m=t[d+1],_=o(h,p),g=o(p,m),x=_.x+g.x,b=_.y+g.y,w=Math.sqrt(x*x+b*b),E=p.trace_width??e;if(w/2>2*(E/2))s(p,_,1,E),s(p,g,1,E),s(p,_,-1,E),s(p,g,-1,E);else{const A=1/w;s(p,{x:x*A,y:b*A},1,E),s(p,{x:x*A,y:b*A},-1,E)}}const l=o(t[t.length-2],t[t.length-1]),u=t[t.length-1].trace_width??e;return s(t[t.length-1],l,1,u),s(t[t.length-1],l,-1,u),[...i,...r]}var Uc=0,l_=n=>`${n}_${Uc++}`,lve=n=>(n??[]).map(e=>({x:di.parse(e.x),y:di.parse(e.y)})),tUn=(n,e)=>{const t="pcb_component_id"in n?e.find(s=>s.type==="pcb_component"&&s.pcb_component_id===n.pcb_component_id):void 0,i=t&&"source_component_id"in t?e.find(s=>s.type==="source_component"&&s.source_component_id===t.source_component_id):void 0,r="source_port_id"in n?n.source_port_id:"pcb_port_id"in n?fC(e).pcb_port.get(n.pcb_port_id)?.source_port_id:void 0,o=r?e.find(s=>s.type==="source_port"&&s.source_port_id===r):void 0;switch(n.type){case"pcb_panel":{const{width:s,height:a}=n;return[{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:0,y1:0,x2:s,y2:0,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:0,y1:a,x2:s,y2:a,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:0,y1:0,x2:0,y2:a,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:s,y1:0,x2:s,y2:a,width:1,zoomIndependent:!0,layer:"board",_element:n}]}case"pcb_board":{const{width:s,height:a,center:c,outline:l}=n;return l&&l.length>2?l.map((u,d,h)=>({_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:u.x,y1:u.y,x2:d===h.length-1?h[0].x:h[d+1].x,y2:d===h.length-1?h[0].y:h[d+1].y,width:1,zoomIndependent:!0,layer:"board",_element:n})):[{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y-a/2,x2:c.x+s/2,y2:c.y-a/2,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y+a/2,x2:c.x+s/2,y2:c.y+a/2,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:c.x-s/2,y1:c.y-a/2,x2:c.x-s/2,y2:c.y+a/2,width:1,zoomIndependent:!0,layer:"board",_element:n},{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:c.x+s/2,y1:c.y-a/2,x2:c.x+s/2,y2:c.y+a/2,width:1,zoomIndependent:!0,layer:"board",_element:n}]}case"pcb_smtpad":{if(n.shape==="rect"||n.shape==="rotated_rect"){const{shape:s,x:a,y:c,width:l,height:u,layer:d,rect_border_radius:h}=n,p=n.corner_radius??h??0;return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:a,y:c,w:l,h:u,layer:d||"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:n.ccw_rotation,roundness:p}]}else if(n.shape==="circle"){const{x:s,y:a,radius:c,layer:l}=n;return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:c,layer:l||"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}]}else if(n.shape==="polygon"){const{layer:s,points:a}=n;return[{_pcb_drawing_object_id:`polygon_${Uc++}`,pcb_drawing_type:"polygon",points:lve(a),layer:s||"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}]}else if(n.shape==="pill"||n.shape==="rotated_pill"){const{x:s,y:a,width:c,height:l,layer:u}=n;return[{_pcb_drawing_object_id:`pill_${Uc++}`,pcb_drawing_type:"pill",x:s,y:a,w:c,h:l,layer:u||"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:n.ccw_rotation}]}return[]}case"pcb_hole":{if(n.hole_shape==="circle"||!n.hole_shape){const{x:s,y:a,hole_diameter:c}=n;return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:c/2,layer:"drill",_element:n,_parent_pcb_component:t,_parent_source_component:i}]}return[]}case"pcb_plated_hole":if(n.shape==="circle"){const{x:s,y:a,hole_diameter:c,outer_diameter:l}=n;return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:l/2,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o},{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:c/2,layer:"drill",_element:n}]}else if(n.shape==="oval"){const{x:s,y:a,outer_height:c,outer_width:l,hole_height:u,hole_width:d}=n;return[{_pcb_drawing_object_id:`oval_${Uc++}`,pcb_drawing_type:"oval",x:s,y:a,rX:l/2,rY:c/2,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o},{_pcb_drawing_object_id:`oval_${Uc++}`,_element:n,pcb_drawing_type:"oval",x:s,y:a,rX:d/2,rY:u/2,layer:"drill"}]}else if(n.shape==="pill"){const{x:s,y:a,outer_height:c,outer_width:l,hole_height:u,hole_width:d}=n;return[{_pcb_drawing_object_id:`pill_${Uc++}`,pcb_drawing_type:"pill",x:s,y:a,w:l,h:c,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:n.ccw_rotation},{_pcb_drawing_object_id:`pill_${Uc++}`,_element:n,pcb_drawing_type:"pill",x:s,y:a,w:d,h:u,layer:"drill",ccw_rotation:n.ccw_rotation}]}else if(n.shape==="circular_hole_with_rect_pad"){const{x:s,y:a,hole_diameter:c,rect_pad_width:l,rect_pad_height:u,rect_border_radius:d}=n,h=n.hole_offset_x??0,p=n.hole_offset_y??0;return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:s,y:a,w:l,h:u,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:d},{_pcb_drawing_object_id:`circle_${Uc++}`,_element:n,pcb_drawing_type:"circle",x:s+h,y:a+p,r:c/2,layer:"drill"}]}else if(n.shape==="pill_hole_with_rect_pad"){const{x:s,y:a,hole_width:c,hole_height:l,rect_pad_width:u,rect_pad_height:d,rect_border_radius:h}=n;return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:s,y:a,w:u,h:d,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,roundness:h},{_pcb_drawing_object_id:`pill_${Uc++}`,_element:n,pcb_drawing_type:"pill",x:s,y:a,w:c,h:l,layer:"drill"}]}else if(n.shape==="rotated_pill_hole_with_rect_pad"){const{x:s,y:a,hole_width:c,hole_height:l,hole_ccw_rotation:u,rect_pad_width:d,rect_pad_height:h,rect_ccw_rotation:p,rect_border_radius:m}=n;return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:s,y:a,w:d,h,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o,ccw_rotation:p,roundness:m},{_pcb_drawing_object_id:`pill_${Uc++}`,_element:n,pcb_drawing_type:"pill",x:s,y:a,w:c,h:l,layer:"drill",ccw_rotation:u}]}else return[];case"pcb_keepout":{if(n.shape==="circle"){const{center:s,radius:a}=n;return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s.x,y:s.y,r:a,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,mesh_fill:!0}]}else if(n.shape==="rect"){const{center:s,width:a,height:c}=n;return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:s.x,y:s.y,w:a,h:c,layer:"top",_element:n,_parent_pcb_component:t,_parent_source_component:i,mesh_fill:!0}]}break}case"pcb_trace":{const s=[];if(n.route_thickness_mode==="interpolated"){const l=n.route.map(h=>({x:h.x,y:h.y,trace_width:h.route_type==="wire"?h.width:.5})),u=eUn(l,.5),d=n.route[0].layer;return s.push({_pcb_drawing_object_id:`polygon_${Uc++}`,_element:n,pcb_drawing_type:"polygon",points:u,layer:d}),n.route.forEach(h=>{h.route_type==="via"&&s.push({_pcb_drawing_object_id:`circle_${Uc++}`,_element:n,pcb_drawing_type:"circle",x:h.x,y:h.y,r:h.outer_diameter/2,layer:h.from_layer})}),s}let a=null,c=null;for(const l of n.route)l.route_type==="wire"&&(a!==null&&c!==null&&s.push({_pcb_drawing_object_id:`line_${Uc++}`,_element:n,pcb_drawing_type:"line",x1:a,y1:c,x2:l.x,y2:l.y,width:l.width,squareCap:!1,layer:l.layer}),a=l.x,c=l.y);return s}case"pcb_via":{const{x:s,y:a,outer_diameter:c,hole_diameter:l,from_layer:u,to_layer:d}=n;return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:c/2,layer:u,_element:n,_parent_pcb_component:t,_parent_source_component:i},{_pcb_drawing_object_id:`circle_${Uc++}`,_element:n,pcb_drawing_type:"circle",x:s,y:a,r:l/2,layer:"drill",_parent_pcb_component:t,_parent_source_component:i},{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:s,y:a,r:c/2,layer:d,_element:n,_parent_pcb_component:t,_parent_source_component:i}]}case"pcb_silkscreen_rect":return[{_pcb_drawing_object_id:`rect_${Uc++}`,pcb_drawing_type:"rect",x:n.center.x,y:n.center.y,w:n.width,h:n.height,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen",stroke_width:n.stroke_width,is_filled:n.is_filled,has_stroke:n.has_stroke,is_stroke_dashed:n.is_stroke_dashed,_element:n}];case"pcb_silkscreen_circle":return[{_pcb_drawing_object_id:`circle_${Uc++}`,pcb_drawing_type:"circle",x:n.center.x,y:n.center.y,r:n.radius,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_oval":return[{_pcb_drawing_object_id:`oval_${Uc++}`,pcb_drawing_type:"oval",x:n.center.x,y:n.center.y,rX:n.radius_x/2,rY:n.radius_y/2,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_pill":return[{_pcb_drawing_object_id:`pill_${Uc++}`,pcb_drawing_type:"pill",x:n.center.x,y:n.center.y,w:n.width,h:n.height,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_silkscreen_line":return[{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,width:.1,squareCap:!1,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen"}];case"pcb_fabrication_note_path":case"pcb_silkscreen_path":{const{pcb_component_id:s,route:a,type:c}=n;let l;return c==="pcb_silkscreen_path"?l=n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen":c==="pcb_fabrication_note_path"&&(l="top_fabrication"),a.slice(0,-1).map((u,d)=>{const h=a[d+1];return{_pcb_drawing_object_id:`line_${Uc++}`,pcb_drawing_type:"line",x1:u.x,y1:u.y,x2:h.x,y2:h.y,width:n.stroke_width??.1,squareCap:!1,layer:l,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}}).filter(Boolean)}case"pcb_silkscreen_text":return[{_pcb_drawing_object_id:`text_${Uc++}`,pcb_drawing_type:"text",x:n.anchor_position.x,y:n.anchor_position.y,layer:n.layer==="bottom"?"bottom_silkscreen":"top_silkscreen",align:n.anchor_alignment??"center",text:n.text,size:n.font_size,ccw_rotation:n.ccw_rotation}];case"pcb_copper_pour":{const s=n;switch(s.shape){case"rect":{const{center:a,width:c,height:l,layer:u,rotation:d}=s;return[{_pcb_drawing_object_id:l_("pcb_copper_pour_rect"),pcb_drawing_type:"rect",x:a.x,y:a.y,w:c,h:l,layer:u,_element:n,ccw_rotation:d}]}case"polygon":{const{points:a,layer:c}=s;return[{_pcb_drawing_object_id:l_("pcb_copper_pour_polygon"),pcb_drawing_type:"polygon",points:lve(a),layer:c,_element:n}]}case"brep":{const{brep_shape:a,layer:c}=s;return[{_pcb_drawing_object_id:l_("pcb_copper_pour_brep"),pcb_drawing_type:"polygon_with_arcs",brep_shape:a,layer:c,_element:n}]}}return[]}case"pcb_fabrication_note_dimension":{const s=n,{from:a,to:c,text:l,font_size:u,arrow_size:d}=s,h=n.layer==="bottom"?"bottom_fabrication":"top_fabrication",p=[],m=typeof d=="number"&&!Number.isNaN(d)?d:1;p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:c.x,y2:c.y,width:.05,squareCap:!1,layer:h,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o});const _=c.x-a.x,g=c.y-a.y,x=Math.sqrt(_*_+g*g)||1,b=_/x,w=g/x,E=Math.PI/6,k=a.x+m*(b*Math.cos(E)-w*Math.sin(E)),A=a.y+m*(b*Math.sin(E)+w*Math.cos(E)),R=a.x+m*(b*Math.cos(-E)-w*Math.sin(-E)),M=a.y+m*(b*Math.sin(-E)+w*Math.cos(-E));p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:k,y2:A,width:.05,squareCap:!1,layer:h,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}),p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:R,y2:M,width:.05,squareCap:!1,layer:h,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o});const I=c.x-m*(b*Math.cos(E)-w*Math.sin(E)),C=c.y-m*(b*Math.sin(E)+w*Math.cos(E)),U=c.x-m*(b*Math.cos(-E)-w*Math.sin(-E)),O=c.y-m*(b*Math.sin(-E)+w*Math.cos(-E));return p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"line",x1:c.x,y1:c.y,x2:I,y2:C,width:.05,squareCap:!1,layer:h,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}),p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"line",x1:c.x,y1:c.y,x2:U,y2:O,width:.05,squareCap:!1,layer:h,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}),l&&p.push({_pcb_drawing_object_id:l_("pcb_fabrication_note_dimension"),pcb_drawing_type:"text",x:(a.x+c.x)/2,y:(a.y+c.y)/2,layer:h,align:"center",text:l,size:u,_element:n,_parent_pcb_component:t,_parent_source_component:i,_source_port:o}),p}case"pcb_fabrication_note_text":return[{_pcb_drawing_object_id:l_("text"),pcb_drawing_type:"text",x:n.anchor_position.x,y:n.anchor_position.y,layer:n.layer==="bottom"?"bottom_fabrication":"top_fabrication",size:n.font_size,align:n.anchor_alignment??"center",text:n.text}];case"pcb_cutout":{const s=n;switch(s.shape){case"rect":return[{_pcb_drawing_object_id:l_("pcb_cutout_rect"),pcb_drawing_type:"rect",x:s.center.x,y:s.center.y,w:s.width,h:s.height,layer:"drill",_element:n,_parent_pcb_component:t,_parent_source_component:i}];case"circle":return[{_pcb_drawing_object_id:l_("pcb_cutout_circle"),pcb_drawing_type:"circle",x:s.center.x,y:s.center.y,r:s.radius,layer:"drill",_element:n,_parent_pcb_component:t,_parent_source_component:i}];case"polygon":return[{_pcb_drawing_object_id:l_("pcb_cutout_polygon"),pcb_drawing_type:"polygon",points:lve(s.points),layer:"drill",_element:n,_parent_pcb_component:t,_parent_source_component:i}];default:return console.warn(`Unsupported pcb_cutout shape: ${s.shape}`),[]}}case"pcb_note_line":{const s=n;return[{_pcb_drawing_object_id:l_("pcb_note_line"),pcb_drawing_type:"line",x1:s.x1,y1:s.y1,x2:s.x2,y2:s.y2,width:s.stroke_width??.1,squareCap:!1,layer:"notes",color:s.color,_element:n,_parent_pcb_component:t,_parent_source_component:i}]}case"pcb_note_rect":{const s=n;return[{_pcb_drawing_object_id:l_("pcb_note_rect"),pcb_drawing_type:"rect",x:s.center.x,y:s.center.y,w:s.width,h:s.height,layer:"notes",stroke_width:s.stroke_width,is_filled:s.is_filled,has_stroke:s.has_stroke,is_stroke_dashed:s.is_stroke_dashed,color:s.color,_element:n,_parent_pcb_component:t,_parent_source_component:i}]}case"pcb_note_path":{const s=n,{route:a,stroke_width:c}=s;return a.slice(0,-1).map((l,u)=>{const d=a[u+1];return{_pcb_drawing_object_id:l_("pcb_note_path"),pcb_drawing_type:"line",x1:l.x,y1:l.y,x2:d.x,y2:d.y,width:c??.1,squareCap:!1,layer:"notes",color:s.color,_element:n,_parent_pcb_component:t,_parent_source_component:i}}).filter(Boolean)}case"pcb_note_text":{const s=n;return[{_pcb_drawing_object_id:l_("pcb_note_text"),pcb_drawing_type:"text",x:s.anchor_position.x,y:s.anchor_position.y,layer:"notes",align:s.anchor_alignment??"center",text:s.text||"",size:s.font_size,color:s.color,_element:n,_parent_pcb_component:t,_parent_source_component:i}]}case"pcb_note_dimension":{const s=n,{from:a,to:c,text:l,font_size:u,arrow_size:d}=s,h=[];h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:c.x,y2:c.y,width:.05,squareCap:!1,color:s.color,layer:"notes",_element:n,_parent_pcb_component:t,_parent_source_component:i});const p=c.x-a.x,m=c.y-a.y,_=Math.sqrt(p*p+m*m),g=p/_,x=m/_,b=Math.PI/6,w=a.x+d*(g*Math.cos(b)-x*Math.sin(b)),E=a.y+d*(g*Math.sin(b)+x*Math.cos(b)),k=a.x+d*(g*Math.cos(-b)-x*Math.sin(-b)),A=a.y+d*(g*Math.sin(-b)+x*Math.cos(-b));h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:w,y2:E,width:.05,squareCap:!1,layer:"notes",_element:n}),h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"line",x1:a.x,y1:a.y,x2:k,y2:A,width:.05,squareCap:!1,layer:"notes",_element:n});const R=c.x-d*(g*Math.cos(b)-x*Math.sin(b)),M=c.y-d*(g*Math.sin(b)+x*Math.cos(b)),I=c.x-d*(g*Math.cos(-b)-x*Math.sin(-b)),C=c.y-d*(g*Math.sin(-b)+x*Math.cos(-b));return h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"line",x1:c.x,y1:c.y,x2:R,y2:M,width:.05,squareCap:!1,layer:"notes",_element:n}),h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"line",x1:c.x,y1:c.y,x2:I,y2:C,width:.05,squareCap:!1,layer:"notes",_element:n}),l&&h.push({_pcb_drawing_object_id:l_("pcb_note_dimension"),pcb_drawing_type:"text",x:(a.x+c.x)/2,y:(a.y+c.y)/2,layer:"notes",align:"center",text:l,size:u,_element:n}),h}}return[]},Cy={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(242, 237, 161)",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)"}},bw=(n,e=1)=>{if(Math.abs(n.a)!==Math.abs(n.d))throw new Error("Cannot scale non-uniformly");return e*Math.abs(n.a)},u_={elementOverlay:40,dimensionOverlay:40,editTraceHintOverlay:40,errorOverlay:40,pcbGroupOverlay:35,ratsNestOverlay:30,toolbarOverlay:70,warnings:30,topLayer:20,clickToInteractOverlay:100},nq={red:"red",black:"black",green:"green",board:"rgb(255, 255, 255)",other:"#eee",top:Cy.board.copper.f,inner1:Cy.board.copper.in1,inner2:Cy.board.copper.in2,inner3:Cy.board.copper.in3,inner4:Cy.board.copper.in4,inner5:Cy.board.copper.in5,inner6:Cy.board.copper.in6,inner7:Cy.board.copper.in7,inner8:Cy.board.copper.in8,bottom:Cy.board.copper.b,drill:Cy.board.anchor,keepout:Cy.board.background,tkeepout:Cy.board.b_crtyd,tplace:Cy.board.b_silks,top_silkscreen:Cy.board.f_silks,bottom_silkscreen:Cy.board.b_silks,top_fabrication:Cy.board.f_fab,bottom_fabrication:Cy.board.b_fab,notes:Cy.board.user_2,...Cy.board},nUn=["inner6","inner5","inner4","inner3","inner2","inner1","bottom","bottom_silkscreen","top","top_silkscreen","board"],iUn=class{canvasLayerMap;ctxLayerMap;aperture;transform;foregroundLayer="top";lastPoint;constructor(n){this.canvasLayerMap=n,this.ctxLayerMap=Object.fromEntries(Object.entries(n).map(([e,t])=>[e,t.getContext("2d")])),this.transform=Bh(),this.transform.d*=-1,this.transform=ko(this.transform,Go(0,-500)),this.lastPoint={x:0,y:0},this.equip({})}clear(){for(const n of Object.values(this.ctxLayerMap))n.clearRect(0,0,n.canvas.width,n.canvas.height)}equip(n){this.aperture={fontSize:0,shape:"circle",mode:"add",size:0,color:"red",layer:"top",opacity:this.foregroundLayer===n.color?1:.5,...n}}drawMeshPattern(n,e,t,i,r,o=45){const s=this.getLayerCtx(),[a,c]=Dt(this.transform,[n,e]),[l,u]=Dt(this.transform,[n+t,e+i]),d=bw(this.transform,r);s.lineWidth=1,s.strokeStyle=this.aperture.color;const h=p=>{const m=Math.sin(p),_=Math.cos(p),g=Math.sqrt(Math.pow(l-a,2)+Math.pow(u-c,2));for(let x=-g;x<=g;x+=d)s.beginPath(),s.moveTo(a+x*_-g*m,c+x*m+g*_),s.lineTo(a+x*_+g*m,c+x*m-g*_),s.stroke()};h(o*Math.PI/180),h((o+90)*Math.PI/180)}rect({x:n,y:e,w:t,h:i,mesh_fill:r,is_filled:o=!0,has_stroke:s,is_stroke_dashed:a,stroke_width:c,roundness:l}){const[u,d]=Dt(this.transform,[n-t/2,e-i/2]),[h,p]=Dt(this.transform,[n+t/2,e+i/2]);this.applyAperture();const m=this.getLayerCtx(),_=l?bw(this.transform,l):0,g=s===void 0?o===!1:s;if(r)m.save(),m.beginPath(),_>0&&m.roundRect?m.roundRect(u,d,h-u,p-d,_):m.rect(u,d,h-u,p-d),m.clip(),this.drawMeshPattern(n-t/2,e-i/2,t,i,.15),m.restore(),_>0&&m.roundRect?(m.beginPath(),m.roundRect(u,d,h-u,p-d,_),m.stroke()):m.strokeRect(u,d,h-u,p-d);else if(o!==!1&&(_>0&&m.roundRect?(m.beginPath(),m.roundRect(u,d,h-u,p-d,_),m.fill()):m.fillRect(u,d,h-u,p-d)),g){const x=m.lineWidth;if(c!==void 0&&(m.lineWidth=bw(this.transform,c)),a){let b=[];const w=Math.abs(this.transform.a);if(w>0){const k=.1*w,A=k*1.3;k>.5&&(b=[k,A])}m.setLineDash(b)}_>0&&m.roundRect?(m.beginPath(),m.roundRect(u,d,h-u,p-d,_),m.stroke()):m.strokeRect(u,d,h-u,p-d),a&&m.setLineDash([]),c!==void 0&&(m.lineWidth=x)}}rotatedRect(n,e,t,i,r,o,s){const a=this.getLayerCtx();this.applyAperture();const[c,l]=Dt(this.transform,[n-t/2,e-i/2]),[u,d]=Dt(this.transform,[n+t/2,e+i/2]),h=o?bw(this.transform,o):0;a.save();const[p,m]=Dt(this.transform,[n,e]);a.translate(p,m);const _=360-r;r&&a.rotate(_*Math.PI/180),a.translate(-p,-m),s?(a.beginPath(),h>0&&a.roundRect?a.roundRect(c,l,u-c,d-l,h):a.rect(c,l,u-c,d-l),a.clip(),this.drawMeshPattern(n-t/2,e-i/2,t,i,.15),h>0&&a.roundRect?(a.beginPath(),a.roundRect(c,l,u-c,d-l,h),a.stroke()):a.strokeRect(c,l,u-c,d-l)):h>0&&a.roundRect?(a.beginPath(),a.roundRect(c,l,u-c,d-l,h),a.fill()):a.fillRect(c,l,u-c,d-l),a.restore()}rotatedPill(n,e,t,i,r){const o=this.getLayerCtx();this.applyAperture(),o.save();const[s,a]=Dt(this.transform,[n,e]);o.translate(s,a);const c=360-r;r&&o.rotate(c*Math.PI/180),o.translate(-s,-a),this.pill(n,e,t,i),o.restore()}circle(n,e,t,i){const r=bw(this.transform,t),[o,s]=Dt(this.transform,[n,e]);this.applyAperture();const a=this.getLayerCtx();i?(a.save(),a.beginPath(),a.arc(o,s,r,0,2*Math.PI),a.clip(),this.drawMeshPattern(n-t,e-t,t*2,t*2,.15),a.restore(),a.beginPath(),a.arc(o,s,r,0,2*Math.PI),a.stroke()):(a.beginPath(),a.arc(o,s,r,0,2*Math.PI),a.fill())}oval(n,e,t,i){const r=bw(this.transform,t),o=bw(this.transform,i),[s,a]=Dt(this.transform,[n,e]);this.applyAperture();const c=this.getLayerCtx();c.beginPath(),c.ellipse(s,a,r,o,0,0,2*Math.PI),c.fill(),c.closePath()}pill(n,e,t,i){const[r,o]=Dt(this.transform,[n-t/2,e+i/2]),s=bw(this.transform,t),a=bw(this.transform,i),c=Math.min(s,a)/2;this.applyAperture();const l=this.getLayerCtx();l.beginPath(),l.arc(r+c,o+c,c,Math.PI,Math.PI*1.5),l.arc(r+s-c,o+c,c,Math.PI*1.5,0),l.arc(r+s-c,o+a-c,c,0,Math.PI*.5),l.arc(r+c,o+a-c,c,Math.PI*.5,Math.PI),l.fill(),l.closePath()}polygon(n){if(n.length<3)return;this.applyAperture();const e=this.getLayerCtx(),t=n.map(r=>Dt(this.transform,[r.x,r.y]));e.beginPath(),e.moveTo(t[0][0],t[0][1]);for(let r=1;r<t.length;r++)e.lineTo(t[r][0],t[r][1]);e.closePath(),e.fill("evenodd");const i=bw(this.transform,this.aperture.size);i>0&&(e.lineWidth=i,e.stroke())}debugText(n,e,t){const[i,r]=Dt(this.transform,[e,t]);this.applyAperture();const o=this.getLayerCtx();o.font="10px sans-serif",o.fillText(n,i,r)}getLayerCtx(){const n=this.ctxLayerMap[this.aperture.layer];if(!n)throw new Error(`No context for layer "${this.aperture.layer}"`);return n}orderAndFadeLayers(){const{canvasLayerMap:n,foregroundLayer:e}=this,t=new Set([e,"drill","other","board",e==="top"?"top_silkscreen":e==="bottom"?"bottom_silkscreen":""]),i=e==="top"?"top_silkscreen":e==="bottom"?"bottom_silkscreen":void 0,r=[e,...i?[i]:[]],o=[...nUn.filter(s=>!r.includes(s)),e,"drill",...i?[i]:[]];o.forEach((s,a)=>{const c=n[s];c&&(c.style.zIndex=`${u_.topLayer-(o.length-a)}`,c.style.opacity=t.has(s)?"1":"0.5")})}applyAperture(){const{transform:n,aperture:e}=this;let{size:t,mode:i,color:r,fontSize:o,layer:s}=e;s in this.ctxLayerMap||(this.aperture.layer="other");const a=this.getLayerCtx();if(!a)throw new Error(`No context for layer "${this.foregroundLayer}"`);if(r||(r="undefined"),a.lineWidth=bw(n,t),a.lineCap="round",i==="add"){a.globalCompositeOperation="source-over";let c=nq[r.toLowerCase()];if(!c)try{c=iht(r).rgb().toString()}catch{console.warn(`Invalid color format: '${r}'`),c="white"}a.fillStyle=c,a.strokeStyle=c}else a.globalCompositeOperation="destination-out",a.fillStyle="rgba(0,0,0,1)",a.strokeStyle="rgba(0,0,0,1)";a.font=`${bw(F2(n),o)}px sans-serif`}moveTo(n,e){this.lastPoint={x:n,y:e}}lineTo(n,e){const[t,i]=Dt(this.transform,[n,e]),{size:r,shape:o,mode:s}=this.aperture,a=bw(this.transform,r);let{lastPoint:c}=this;const l=Dt(this.transform,c);this.applyAperture();const u=this.getLayerCtx();o==="square"&&u.fillRect(l.x-a/2,l.y-a/2,a,a),u.beginPath(),u.moveTo(l.x,l.y),u.lineTo(t,i),u.stroke(),u.closePath(),o==="square"&&u.fillRect(t-a/2,i-a/2,a,a),this.lastPoint={x:n,y:e}}polygonWithArcs(n){const e=this.getLayerCtx(),t=i=>{if(i.vertices.length===0)return;const r=i.vertices[0],o=Dt(this.transform,[r.x,r.y]);e.moveTo(o[0],o[1]);for(let s=0;s<i.vertices.length;s++){const a=i.vertices[s],c=i.vertices[(s+1)%i.vertices.length];if(a.bulge&&a.bulge!==0){const l=a.bulge,u=c.x-a.x,d=c.y-a.y,h=Math.sqrt(u*u+d*d);if(h<1e-9){const O=Dt(this.transform,[c.x,c.y]);e.lineTo(O[0],O[1]);continue}const p=4*Math.atan(l),m=Math.abs(h/(2*Math.sin(p/2))),_=(a.x+c.x)/2,g=(a.y+c.y)/2,x=u/h,w=-(d/h),E=x,k=Math.sqrt(Math.max(0,m*m-(h/2)**2)),A=_+k*w*Math.sign(l),R=g+k*E*Math.sign(l),M=Math.atan2(a.y-R,a.x-A);let I=Math.atan2(c.y-R,c.x-A);l>0&&I<M?I+=2*Math.PI:l<0&&I>M&&(I-=2*Math.PI);const C=Dt(this.transform,[A,R]),U=bw(this.transform,m);e.arc(C[0],C[1],U,-M,-I,l>0)}else{const l=Dt(this.transform,[c.x,c.y]);e.lineTo(l[0],l[1])}}e.closePath()};if(e.beginPath(),t(n.outer_ring),n.inner_rings)for(const i of n.inner_rings)t(i);e.fill("evenodd")}};function rUn(n){const{lines:e,anchorPoint:t,ccwRotation:i}=n;if(!i)return e;const r=i*Math.PI/180,o=B_(r),s=ko(Go(t.x,t.y),o,Go(-t.x,-t.y));return Dt(s,t),e.map(a=>({...a,x1:Dt(s,{x:a.x1,y:a.y1}).x,y1:Dt(s,{x:a.x1,y:a.y1}).y,x2:Dt(s,{x:a.x2,y:a.y2}).x,y2:Dt(s,{x:a.x2,y:a.y2}).y}))}var Hht=.6,Vht=.2,oUn=n=>{if(n.text.length===0)return 0;const e=n.size*.7,t=e*Hht,i=e*Vht;return n.text.length*t+(n.text.length-1)*i},sUn=n=>{const e=n.size*.7;if(e<=0||n.text.length===0)return[];const t=e/12,i=Math.max(0,e-t),r=t/2,o=e*Hht,s=Math.max(0,o-t),a=t/2,c=e*Vht,l=[];let u=n.x;for(let d=0;d<n.text.length;d++){const h=n.text[d],p=BY[h]??BY[h.toUpperCase()];if(!p){u+=o+c;continue}for(const{x1:m,y1:_,x2:g,y2:x}of p)l.push({_pcb_drawing_object_id:l_("line"),pcb_drawing_type:"line",x1:u+a+s*m,y1:n.y+r+i*_,x2:u+a+s*g,y2:n.y+r+i*x,width:t,layer:n.layer,unit:n.unit});u+=o+c}return l};function DT(n){const t=n.color??nq[n.layer];let i=iht(t);return n._element?.type==="pcb_copper_pour"&&(i=i.alpha(.7)),n.is_mouse_over||n.is_in_highlighted_net?i.lighten(.5).rgb().toString():i.rgb().toString()}var Ght=(n,e)=>{n.equip({size:e.zoomIndependent?e.width/n.transform.a:e.width,shape:e.squareCap?"square":"circle",color:DT(e),layer:e.layer}),n.moveTo(e.x1,e.y1),n.lineTo(e.x2,e.y2)},aUn=(n,e)=>{n.equip({fontSize:e.size,color:DT(e),layer:e.layer});let t={x:0,y:0};const i=oUn(e),r=e.size;switch(e.align){case"top_left":t.x=0,t.y=-r;break;case"top_center":t.x=-i/2,t.y=-r;break;case"top_right":t.x=-i,t.y=-r;break;case"center_left":t.x=0,t.y=-r/2;break;case"center":t.x=-i/2,t.y=-r/2;break;case"center_right":t.x=-i,t.y=-r/2;break;case"bottom_left":t.x=0,t.y=0;break;case"bottom_center":t.x=-i/2,t.y=0;break;case"bottom_right":t.x=-i,t.y=0;break;default:t.x=0,t.y=0;break}e.x??=0,e.y??=0;const o={x:e.x,y:e.y};let s=sUn({...e,x:e.x+t.x,y:e.y+t.y});if(e.layer==="bottom_silkscreen"&&(s=s.map(a=>({...a,x1:2*e.x-a.x1,x2:2*e.x-a.x2}))),e.ccw_rotation){const a={lines:s,anchorPoint:o,ccwRotation:e.ccw_rotation};s=rUn(a)}for(const a of s)Ght(n,a)},cUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer,size:e.stroke_width}),n.rect({x:e.x,y:e.y,w:e.w,h:e.h,mesh_fill:e.mesh_fill,is_filled:e.is_filled,has_stroke:e.has_stroke,is_stroke_dashed:e.is_stroke_dashed,stroke_width:e.stroke_width,roundness:e.roundness})},lUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.rotatedRect(e.x,e.y,e.w,e.h,e.ccw_rotation,e.roundness,e.mesh_fill)},uUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.rotatedPill(e.x,e.y,e.w,e.h,e.ccw_rotation)},dUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.circle(e.x,e.y,e.r,e.mesh_fill)},hUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.oval(e.x,e.y,e.rX,e.rY)},pUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.pill(e.x,e.y,e.w,e.h)},fUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.polygon(e.points)},mUn=(n,e)=>{n.equip({color:DT(e),layer:e.layer}),n.polygonWithArcs(e.brep_shape)},_Un=(n,e)=>{switch(e.pcb_drawing_type){case"line":return Ght(n,e);case"text":return aUn(n,e);case"rect":return e.ccw_rotation?lUn(n,e):cUn(n,e);case"circle":return dUn(n,e);case"oval":return hUn(n,e);case"pill":return e.ccw_rotation?uUn(n,e):pUn(n,e);case"polygon":return fUn(n,e);case"polygon_with_arcs":return mUn(n,e)}},yUn=(n,e)=>{for(const t of e)_Un(n,t)},gUn=["board","bottom_silkscreen","bottom","top","top_silkscreen","inner1","inner2","inner3","inner4","inner5","inner6","drill","notes","other"],xUn=({primitives:n,transform:e,grid:t,width:i=500,height:r=500})=>{const o=ce.useRef({}),s=iv(a=>a.selected_layer);return ce.useEffect(()=>{if(!o.current||Object.keys(o.current).length===0)return;const a=new iUn(o.current);e&&(a.transform=e),a.clear(),a.foregroundLayer=s,yUn(a,n),a.orderAndFadeLayers()},[n,e,s]),re.jsxs("div",{style:{backgroundColor:"black",width:i,height:r,position:"relative"},children:[re.jsx(jbe.SuperGrid,{textColor:"rgba(0,255,0,0.8)",majorColor:"rgba(0,255,0,0.4)",minorColor:"rgba(0,255,0,0.2)",screenSpaceCellSize:200,width:i,height:r,transform:e,stringifyCoord:(a,c,l)=>`${jbe.toMMSI(a,l)}, ${jbe.toMMSI(c,l)}`}),gUn.map(a=>a.replace(/-/g,"")).map((a,c)=>re.jsx("canvas",{className:`pcb-layer-${a}`,ref:l=>{o.current??={},o.current[a]=l},style:{position:"absolute",zIndex:c,left:0,top:0,pointerEvents:"none"},width:i,height:r},a))]})},bUn=.6,vUn=1;Eht(fFn()),Eht(RFn());var iq=["rgba(239, 68, 68, 0.8)","rgba(249, 115, 22, 0.8)","rgba(245, 158, 11, 0.8)","rgba(234, 179, 8, 0.8)","rgba(132, 204, 22, 0.8)","rgba(34, 197, 94, 0.8)","rgba(16, 185, 129, 0.8)","rgba(20, 184, 166, 0.8)","rgba(6, 182, 212, 0.8)","rgba(14, 165, 233, 0.8)","rgba(59, 130, 246, 0.8)","rgba(99, 102, 241, 0.8)","rgba(139, 92, 246, 0.8)","rgba(168, 85, 247, 0.8)","rgba(217, 70, 239, 0.8)","rgba(236, 72, 153, 0.8)","rgba(249, 168, 212, 0.8)","rgba(161, 161, 170, 0.8)"];function Yht(n,e,t,i={}){const r=i.padding??40,o=i.yFlip??!1;let s;if("center"in n){const u=n.width/2,d=n.height/2;s={minX:n.center.x-u,maxX:n.center.x+u,minY:n.center.y-d,maxY:n.center.y+d}}else s=n;const a=s.maxX-s.minX||1,c=s.maxY-s.minY||1,l=Math.min((e-2*r)/a,(t-2*r)/c);return ko(Go(e/2,t/2),jm(l,o?-l:l),Go(-(s.minX+a/2),-(s.minY+c/2)))}function wUn(n){const e=[...n.points||[],...(n.lines||[]).flatMap(t=>t.points),...(n.rects||[]).flatMap(t=>{const i=t.width/2,r=t.height/2;return[{x:t.center.x-i,y:t.center.y-r},{x:t.center.x+i,y:t.center.y-r},{x:t.center.x-i,y:t.center.y+r},{x:t.center.x+i,y:t.center.y+r}]}),...(n.circles||[]).flatMap(t=>[{x:t.center.x-t.radius,y:t.center.y},{x:t.center.x+t.radius,y:t.center.y},{x:t.center.x,y:t.center.y-t.radius},{x:t.center.x,y:t.center.y+t.radius}]),...(n.texts||[]).flatMap(t=>{const i=t.fontSize??12,r=t.text.length*i*bUn,o=i*vUn,s=t.anchorSide??"center",a={top_left:{dx:0,dy:0},top_center:{dx:-r/2,dy:0},top_right:{dx:-r,dy:0},center_left:{dx:0,dy:-o/2},center:{dx:-r/2,dy:-o/2},center_right:{dx:-r,dy:-o/2},bottom_left:{dx:0,dy:-o},bottom_center:{dx:-r/2,dy:-o},bottom_right:{dx:-r,dy:-o}},{dx:c,dy:l}=a[s],u=t.x+c,d=t.y+l;return[{x:u,y:d},{x:u+r,y:d+o}]})];return e.length===0?{minX:-1,maxX:1,minY:-1,maxY:1}:e.reduce((t,i)=>({minX:Math.min(t.minX,i.x),maxX:Math.max(t.maxX,i.x),minY:Math.min(t.minY,i.y),maxY:Math.max(t.maxY,i.y)}),{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0})}function SUn(n,e,t={}){const i=e instanceof HTMLCanvasElement?e.getContext("2d"):e;if(!i)throw new Error("Could not get 2D context from canvas");const r=e instanceof HTMLCanvasElement?e.width:e.canvas.width,o=e instanceof HTMLCanvasElement?e.height:e.canvas.height;let s;if(t.transform)s=t.transform;else if(t.viewbox)s=Yht(t.viewbox,r,o,{padding:t.padding,yFlip:t.yFlip});else{const a=wUn(n),c=n.coordinateSystem==="cartesian";s=Yht(a,r,o,{padding:t.padding??40,yFlip:c})}i.clearRect(0,0,r,o),i.save(),n.rects&&n.rects.length>0&&n.rects.forEach(a=>{const c=a.width/2,l=a.height/2,u=Dt(s,{x:a.center.x-c,y:a.center.y-l}),d=Dt(s,{x:a.center.x+c,y:a.center.y+l}),h=Math.abs(d.x-u.x),p=Math.abs(d.y-u.y);i.beginPath(),i.rect(Math.min(u.x,d.x),Math.min(u.y,d.y),h,p),a.fill&&(i.fillStyle=a.fill,i.fill()),a.stroke&&(i.strokeStyle=a.stroke,i.stroke())}),n.circles&&n.circles.length>0&&n.circles.forEach(a=>{const c=Dt(s,a.center),l=a.radius*Math.abs(s.a);i.beginPath(),i.arc(c.x,c.y,l,0,2*Math.PI),a.fill&&(i.fillStyle=a.fill,i.fill()),a.stroke&&(i.strokeStyle=a.stroke??"transparent",i.stroke())}),n.lines&&n.lines.length>0&&n.lines.forEach((a,c)=>{if(a.points.length===0)return;i.beginPath();const l=Dt(s,a.points[0]);i.moveTo(l.x,l.y);for(let u=1;u<a.points.length;u++){const d=Dt(s,a.points[u]);i.lineTo(d.x,d.y)}if(i.strokeStyle=a.strokeColor||iq[c%iq.length],a.strokeWidth?i.lineWidth=a.strokeWidth*s.a:i.lineWidth=2,i.lineCap="round",a.strokeDash)if(typeof a.strokeDash=="string"){let u;if(a.strokeDash.includes(","))u=a.strokeDash.split(",").map(d=>parseFloat(d.trim())).filter(d=>!Number.isNaN(d));else{const d=parseFloat(a.strokeDash.trim());u=Number.isNaN(d)?[]:[d]}i.setLineDash(u)}else i.setLineDash(a.strokeDash.map(u=>u*Math.abs(s.a)));else i.setLineDash([]);i.stroke()}),n.points&&n.points.length>0&&n.points.forEach((a,c)=>{const l=Dt(s,a);i.beginPath(),i.arc(l.x,l.y,3,0,2*Math.PI),i.fillStyle=a.color||iq[c%iq.length],i.fill(),a.label&&!t.disableLabels&&(i.fillStyle=a.color||"black",i.font="12px sans-serif",i.fillText(a.label,l.x+5,l.y-5))}),n.texts&&n.texts.length>0&&n.texts.forEach(a=>{const c=Dt(s,{x:a.x,y:a.y});i.fillStyle=a.color||"black",i.font=`${(a.fontSize??12)*Math.abs(s.a)}px sans-serif`;const l=a.anchorSide??"center",u={top_left:"left",center_left:"left",bottom_left:"left",top_center:"center",center:"center",bottom_center:"center",top_right:"right",center_right:"right",bottom_right:"right"},d={top_left:"top",top_center:"top",top_right:"top",center_left:"middle",center:"middle",center_right:"middle",bottom_left:"bottom",bottom_center:"bottom",bottom_right:"bottom"};i.textAlign=u[l],i.textBaseline=d[l],i.fillText(a.text,c.x,c.y)}),i.restore()}var EUn=({children:n,transform:e,debugGraphics:t})=>{const i=ce.useRef(null),[r,{width:o,height:s}]=tq(),a=iv(c=>c.is_showing_autorouting);return ce.useEffect(()=>{a&&i.current&&t&&o&&s&&(i.current.width=o,i.current.height=s,SUn(t,i.current,{transform:e,disableLabels:!0}))},[t,e,o,s,a]),a?re.jsxs("div",{ref:r,style:{position:"relative",width:"100%",height:"100%"},children:[n,re.jsx("canvas",{ref:i,style:{position:"absolute",top:0,left:0,opacity:.5,zIndex:100,width:"100%",height:"100%",pointerEvents:"none"}})]}):n},TUn=({children:n,transform:e=Bh(),elements:t=[]})=>{const[i,{width:r,height:o}]=tq(),s=ce.useRef(null);return ce.useEffect(()=>{const a=s.current;if(!a||!r||!o)return;a.width=r,a.height=o;const c=a.getContext("2d");if(!c)return;c.clearRect(0,0,r,o);const l=t.filter(d=>d.type==="pcb_component"),u=t.filter(d=>d.type==="pcb_manual_edit_conflict_warning");c.strokeStyle=Cy.board.drc_warning,c.lineWidth=2,u.forEach(d=>{const h=l.find(K=>K.pcb_component_id===d.pcb_component_id);if(!h)return;const{width:p,height:m,center:_}=h,g=Dt(e,_),x=p*Math.abs(e.a),b=m*Math.abs(e.d),w=.1*Math.abs(e.a),E=x+w*2,k=b+w*2,A=g.x-E/2,R=g.y-k/2;c.beginPath(),c.rect(A,R,E,k),c.stroke();const M="Manual Edit Conflict",I=4,C=Math.max(8,Math.min(12,10*Math.abs(e.a)));c.font=`${C}px sans-serif`;const O=c.measureText(M).width+I*2,H=C+I*2,Y=A+(E-O)/2,X=R+k+5;c.fillStyle="rgba(0, 0, 0, 0.7)",c.beginPath(),c.roundRect(Y,X,O,H,3),c.fill(),c.fillStyle=Cy.board.drc_warning,c.textAlign="center",c.textBaseline="middle",c.fillText(M,Y+O/2,X+H/2)})},[t,e,r,o]),re.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[n,re.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:u_.warnings}})]})},rq=(n,e,t)=>t(n,e),qht=(n,e,t,i,r)=>{const o=r*Math.PI/180,s=Math.cos(o),a=Math.sin(o),c=n-t,l=e-i,u=c*s-l*a,d=c*a+l*s;return{x:u+t,y:d+i}},U8=n=>{if(n.length===0)return null;let e=n[0].x,t=n[0].x,i=n[0].y,r=n[0].y;for(const o of n)e=rq(e,o.x,Math.min),t=rq(t,o.x,Math.max),i=rq(i,o.y,Math.min),r=rq(r,o.y,Math.max);return{minX:e,maxX:t,minY:i,maxY:r}},MUn=(n,e)=>({minX:Math.min(n.minX,e.minX),maxX:Math.max(n.maxX,e.maxX),minY:Math.min(n.minY,e.minY),maxY:Math.max(n.maxY,e.maxY)}),CUn=(n,e)=>n?MUn(n,e):e,AUn=n=>{switch(n.pcb_drawing_type){case"line":{const e=(n.width??0)/2,t=[{x:n.x1,y:n.y1},{x:n.x2,y:n.y2}],i=U8(t);return i?{minX:i.minX-e,maxX:i.maxX+e,minY:i.minY-e,maxY:i.maxY+e}:null}case"rect":{const e=n.w/2,t=n.h/2,i=[{x:n.x-e,y:n.y-t},{x:n.x+e,y:n.y-t},{x:n.x+e,y:n.y+t},{x:n.x-e,y:n.y+t}],r=n.ccw_rotation??0,o=r===0?i:i.map(s=>qht(s.x,s.y,n.x,n.y,r));return U8(o)}case"circle":return{minX:n.x-n.r,maxX:n.x+n.r,minY:n.y-n.r,maxY:n.y+n.r};case"oval":return{minX:n.x-n.rX,maxX:n.x+n.rX,minY:n.y-n.rY,maxY:n.y+n.rY};case"pill":{const e=n.w/2,t=n.h/2,i=[{x:n.x-e,y:n.y-t},{x:n.x+e,y:n.y-t},{x:n.x+e,y:n.y+t},{x:n.x-e,y:n.y+t}],r=n.ccw_rotation??0,o=r===0?i:i.map(s=>qht(s.x,s.y,n.x,n.y,r));return U8(o)}case"polygon":return U8(n.points);case"polygon_with_arcs":{const e=n.brep_shape.outer_ring.vertices.map(t=>({x:t.x,y:t.y}));return U8(e)}case"text":{const e=n.size??0,t=n.text?n.text.length*e*.6:0,i=e;if(t===0&&i===0)return{minX:n.x,maxX:n.x,minY:n.y,maxY:n.y};const r=t/2,o=i/2;return{minX:n.x-r,maxX:n.x+r,minY:n.y-o,maxY:n.y+o}}default:return null}},PUn=16,G4=5,RUn=n=>{if(n.pcb_drawing_type==="text")return!0;const e=n._element;if(!e||typeof e!="object")return!1;const t=typeof e.type=="string"?e.type:void 0;return t?!!(t.startsWith("pcb_silkscreen_")||t.startsWith("pcb_note_")||t==="pcb_text"||t.startsWith("pcb_fabrication_note_")&&t!=="pcb_fabrication_note_rect"):!1},IUn=({children:n,transform:e,focusOnHover:t=!1,primitives:i=[]})=>{e||(e=Bh());const[r,o]=ce.useState(!1),[s,a]=ce.useState(!1),[c,l]=ce.useState(!1),[u,d]=ce.useState({start:null,end:null}),h=ce.useCallback(()=>{c&&(l(!1),window.dispatchEvent(new Event("disarm-dimension-tool")))},[c]),[p,m]=ce.useState({x:0,y:0}),[_,g]=ce.useState({x:0,y:0}),x=ce.useRef({x:0,y:0}),b=ce.useRef(null),E=b.current?.getBoundingClientRect(),k=ce.useMemo(()=>{const O=new Map;for(const H of i){if(!H._element||RUn(H))continue;const Y=AUn(H);if(!Y)continue;const X=O.get(H._element);O.set(H._element,CUn(X??void 0,Y))}return O},[i]),A=ce.useMemo(()=>{const O=[];return k.forEach((H,Y)=>{if(!H)return;const X=(H.minX+H.maxX)/2,K=(H.minY+H.maxY)/2,J={top_left:{x:H.minX,y:H.minY},top_center:{x:X,y:H.minY},top_right:{x:H.maxX,y:H.minY},center_left:{x:H.minX,y:K},center:{x:X,y:K},center_right:{x:H.maxX,y:K},bottom_left:{x:H.minX,y:H.maxY},bottom_center:{x:X,y:H.maxY},bottom_right:{x:H.maxX,y:H.maxY}};for(const[le,pe]of Object.entries(J))O.push({anchor:le,point:pe,element:Y})}),O},[k]),R=ce.useMemo(()=>A.map((O,H)=>({...O,id:`${H}-${O.anchor}`,screenPoint:Dt(e,O.point)})),[A,e]),M=ce.useCallback(O=>{if(R.length===0)return{point:O,id:null};const H=Dt(e,O);let Y=null;for(const X of R){const K=X.screenPoint.x-H.x,J=X.screenPoint.y-H.y,le=Math.hypot(K,J);le>PUn||(!Y||le<Y.distance)&&(Y={distance:le,id:X.id,point:X.point})}return Y?{point:Y.point,id:Y.id}:{point:O,id:null}},[R,e]);ce.useEffect(()=>{const O=b.current,H=J=>{if(J.key==="d"){const le=M({x:x.current.x,y:x.current.y});m({x:le.point.x,y:le.point.y}),g({x:le.point.x,y:le.point.y}),d({start:le.id,end:le.id}),r?(o(!1),a(!1),d({start:null,end:null})):(o(!0),a(!0)),h()}J.key==="Escape"&&(o(!1),a(!1),d({start:null,end:null}),h())},Y=()=>{l(!0)},X=()=>{O&&window.addEventListener("keydown",H)},K=()=>{O&&window.removeEventListener("keydown",H)};return window.addEventListener("arm-dimension-tool",Y),O&&(O.addEventListener("focus",X),O.addEventListener("blur",K),O.addEventListener("mouseenter",X),O.addEventListener("mouseleave",K)),()=>{window.removeEventListener("arm-dimension-tool",Y),h(),O&&(O.removeEventListener("focus",X),O.removeEventListener("blur",K),O.removeEventListener("mouseenter",X),O.removeEventListener("mouseleave",K))}},[b,r,h,M]);const I=Dt(e,p),C=Dt(e,_),U={left:Math.min(I.x,C.x),right:Math.max(I.x,C.x),top:Math.min(I.y,C.y),bottom:Math.max(I.y,C.y),flipX:I.x>C.x,flipY:I.y>C.y,width:0,height:0};return U.width=U.right-U.left,U.height=U.bottom-U.top,re.jsxs("div",{ref:b,tabIndex:0,style:{position:"relative"},onMouseEnter:()=>{t&&b.current&&b.current.focus()},onMouseLeave:()=>{b.current&&b.current.blur()},onMouseMove:O=>{const H=O.currentTarget.getBoundingClientRect(),Y=O.clientX-H.left,X=O.clientY-H.top,K=Dt(F2(e),{x:Y,y:X});if(x.current.x=K.x,x.current.y=K.y,s){const J=M(K);g({x:J.point.x,y:J.point.y}),d(le=>({...le,end:J.id}))}},onMouseDown:O=>{const H=O.currentTarget.getBoundingClientRect(),Y=O.clientX-H.left,X=O.clientY-H.top,K=Dt(F2(e),{x:Y,y:X});if(c&&!r){const J=M(K);m({x:J.point.x,y:J.point.y}),g({x:J.point.x,y:J.point.y}),d({start:J.id,end:J.id}),o(!0),a(!0),h()}else s?(a(!1),d(J=>({...J,end:null}))):r&&(o(!1),d({start:null,end:null}))},children:[n,r&&re.jsxs(re.Fragment,{children:[re.jsx("div",{style:{position:"absolute",left:U.left,width:U.width,textAlign:"center",top:I.y+2,color:"red",mixBlendMode:"difference",pointerEvents:"none",marginTop:U.flipY?0:-20,fontSize:12,fontFamily:"sans-serif",zIndex:u_.dimensionOverlay},children:Math.abs(p.x-_.x).toFixed(2)}),re.jsx("div",{style:{position:"absolute",left:C.x,height:U.height,display:"flex",flexDirection:"column",justifyContent:"center",top:U.top,color:"red",pointerEvents:"none",mixBlendMode:"difference",fontSize:12,fontFamily:"sans-serif",zIndex:u_.dimensionOverlay},children:re.jsx("div",{style:{marginLeft:U.flipX?"-100%":4,paddingRight:4},children:Math.abs(p.y-_.y).toFixed(2)})}),re.jsxs("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:u_.dimensionOverlay},width:E.width,height:E.height,children:[re.jsx("defs",{children:re.jsx("marker",{id:"head",orient:"auto",markerWidth:"3",markerHeight:"4",refX:"2",refY:"2",children:re.jsx("path",{d:"M0,0 V4 L2,2 Z",fill:"red"})})}),re.jsx("line",{x1:I.x,y1:I.y,x2:C.x,y2:C.y,markerEnd:"url(#head)",strokeWidth:1.5,fill:"none",stroke:"red"}),re.jsx("line",{x1:I.x,y1:I.y,x2:C.x,y2:I.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"}),re.jsx("line",{x1:C.x,y1:I.y,x2:C.x,y2:C.y,strokeWidth:1.5,fill:"none",strokeDasharray:"2,2",stroke:"red"})]}),s&&R.map(O=>{const H=O.id===u.start||O.id===u.end,Y=G4/2;return re.jsxs("svg",{width:G4,height:G4,style:{position:"absolute",left:O.screenPoint.x-Y,top:O.screenPoint.y-Y,pointerEvents:"none",zIndex:u_.dimensionOverlay},children:[re.jsx("line",{x1:0,y1:0,x2:G4,y2:G4,stroke:H?"#66ccff":"white",strokeWidth:1}),re.jsx("line",{x1:G4,y1:0,x2:0,y2:G4,stroke:H?"#66ccff":"white",strokeWidth:1})]},O.id)}),re.jsxs("div",{style:{right:0,bottom:0,position:"absolute",color:"red",fontFamily:"sans-serif",fontSize:12,margin:4},children:["(",p.x.toFixed(2),",",p.y.toFixed(2),")",re.jsx("br",{}),"(",_.x.toFixed(2),",",_.y.toFixed(2),")",re.jsx("br",{}),"dist:"," ",Math.sqrt((_.x-p.x)**2+(_.y-p.y)**2).toFixed(2)]})]})]})},NUn=(n,e,t=0)=>{const i=n.width/2,r=n.height/2,o=n.center.x-i-t,s=n.center.x+i+t,a=n.center.y-r-t,c=n.center.y+r+t;return e.x>o&&e.x<s&&e.y>a&&e.y<c},kUn=({children:n,disabled:e,transform:t,soup:i,cancelPanDrag:r,onCreateEditEvent:o,onModifyEditEvent:s})=>{t||(t=Bh());const a=ce.useRef(null),[c,l]=ce.useState(null),[u,d]=ce.useState(null),h=c!==null;iv(g=>g.in_edit_mode);const p=iv(g=>g.in_move_footprint_mode),m=iv(g=>g.setIsMovingComponent),_=e||!p;return re.jsxs("div",{ref:a,style:{position:"relative",overflow:"hidden"},onMouseDown:g=>{if(_)return;const x=g.currentTarget.getBoundingClientRect(),b=g.clientX-x.left,w=g.clientY-x.top;if(Number.isNaN(b)||Number.isNaN(w))return;const E=Dt(F2(t),{x:b,y:w});let k=!1;for(const A of i)if(A.type==="pcb_component"&&NUn(A,E,10/t.a)){r(),l(A.pcb_component_id),k=!0;const R=Math.random().toString();d({dragStart:E,originalCenter:A.center,dragEnd:E,edit_event_id:R}),o({edit_event_id:R,edit_event_type:"edit_pcb_component_location",pcb_edit_event_type:"edit_component_location",pcb_component_id:A.pcb_component_id,original_center:A.center,new_center:A.center,in_progress:!0,created_at:Date.now()}),m(!0);break}if(k||l(null),k)return g.preventDefault(),!1},onMouseMove:g=>{if(!c||!u)return;const x=g.currentTarget.getBoundingClientRect(),b=g.clientX-x.left,w=g.clientY-x.top;if(Number.isNaN(b)||Number.isNaN(w))return;const E=Dt(F2(t),{x:b,y:w});d({...u,dragEnd:E}),s({edit_event_id:u.edit_event_id,new_center:{x:u.originalCenter.x+E.x-u.dragStart.x,y:u.originalCenter.y+E.y-u.dragStart.y}})},onMouseUp:g=>{c&&(l(null),m(!1),u&&(s({edit_event_id:u.edit_event_id,in_progress:!1}),d(null)))},children:[n,!_&&i.filter(g=>g.type==="pcb_component").map(g=>{if(!g?.center)return null;const x=Dt(t,g.center);return re.jsx("div",{style:{position:"absolute",pointerEvents:"none",left:x.x,top:x.y,width:g.width*t.a+20,height:g.height*t.a+20,transform:"translate(-50%, -50%)",background:h&&c===g.pcb_component_id?"rgba(255, 0, 0, 0.2)":""}},g.pcb_component_id)})]})},OUn=({hotkeys:n})=>(ce.useEffect(()=>{const e=t=>{n.forEach(i=>{t.key===i.key&&i.onUse()})};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[n]),re.jsx("div",{className:JI`
5568
5568
  display: flex;
5569
5569
  flex-direction: column;
5570
5570
  font-family: sans-serif;
@@ -5603,7 +5603,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function kht(n,e,t){if(!e||!t)retu
5603
5603
  transition: opacity 0.2s;
5604
5604
  margin-bottom: 10px;
5605
5605
  color: red;
5606
- `,UUn=({children:n,transform:e=Bh(),elements:t})=>{const i=ce.useRef(null),{isShowingDRCErrors:r,hoveredErrorId:o}=iv(l=>({isShowingDRCErrors:l.is_showing_drc_errors,hoveredErrorId:l.hovered_error_id}));if(!t)return re.jsx("div",{style:{position:"relative"},ref:i,children:n});const s=t.filter(l=>l.type==="pcb_trace_error"),a=t.filter(l=>l.type==="pcb_trace_error"&&l.message?.includes("Multiple components found with name")),c=new Map;return t.forEach(l=>{l.type==="pcb_port"&&c.set(l.pcb_port_id,l)}),re.jsxs("div",{style:{position:"relative"},ref:i,children:[n,s.map((l,u)=>{const{pcb_port_ids:d,pcb_trace_id:h}=l,p=d?.[0]?c.get(d[0]):void 0,m=d?.[1]?c.get(d[1]):void 0,_=t?fC(t).pcb_trace.get(h):void 0,g=l.pcb_trace_error_id||`error_${u}_${l.error_type}_${l.message?.slice(0,20)}`,x=o===g;if(p&&m){const b=Dt(e,{x:p.x,y:p.y}),w=Dt(e,{x:m.x,y:m.y}),E=!(isNaN(b.x)||isNaN(b.y)||isNaN(w.x)||isNaN(w.y)),k={x:(b.x+w.x)/2,y:(b.y+w.y)/2};if(isNaN(k.x)||isNaN(k.y))return null;const A=uve(k,i);return re.jsxs(ce.Fragment,{children:[re.jsx($Un,{screenPort1:b,screenPort2:w,errorCenter:k,canLineBeDrawn:E,isHighlighted:x}),re.jsx("div",{style:{position:"absolute",left:k.x-15,top:k.y-15,width:30,height:30,zIndex:u_.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:R=>{const M=R.currentTarget.nextElementSibling;if(M){const I=M.querySelector(".error-message");I&&(I.style.opacity="1")}},onMouseLeave:R=>{if(!x){const M=R.currentTarget.nextElementSibling;if(M){const I=M.querySelector(".error-message");I&&(I.style.opacity="0")}}}}),re.jsx("div",{style:{position:"absolute",zIndex:x?200:100,left:A.left,top:A.top,color:x?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||x?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:A.transform},children:re.jsx("div",{className:`error-message ${dve}`,style:{opacity:x?1:0,border:`1px solid ${x?"#ff4444":"red"}`},children:l.message})})]},g)}if(_?.route&&(r||x)){const b=_.route.map(A=>Dt(e,{x:A.x,y:A.y}));if(b.some(A=>isNaN(A.x)||isNaN(A.y)))return null;const w=Math.floor(b.length/2),E=b[w],k=uve(E,i);return re.jsxs(ce.Fragment,{children:[re.jsx(FUn,{points:b,errorCenter:E,isHighlighted:x}),re.jsx("div",{style:{position:"absolute",left:E.x-15,top:E.y-15,width:30,height:30,zIndex:u_.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:A=>{const R=A.currentTarget.nextElementSibling;if(R){const M=R.querySelector(".error-message");M&&(M.style.opacity="1")}},onMouseLeave:A=>{if(!x){const R=A.currentTarget.nextElementSibling;if(R){const M=R.querySelector(".error-message");M&&(M.style.opacity="0")}}}}),re.jsx("div",{style:{position:"absolute",zIndex:x?u_.errorOverlay+10:u_.errorOverlay+1,left:k.left,top:k.top,color:x?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:k.transform},children:re.jsx("div",{className:`error-message ${dve}`,style:{opacity:x?1:0,border:`1px solid ${x?"#ff4444":"red"}`},children:l.message})})]},g)}return null}),a.map((l,u)=>{const d=l.component_name||l.message?.match(/name "([^"]+)"/)?.[1];if(!d)return null;const h=t?.filter(_=>_.type==="source_component"&&_.name===d||_.type==="pcb_component"&&t?.find(g=>g.type==="source_component"&&g.source_component_id===_.source_component_id&&g.name===d))||[],p=l.pcb_trace_error_id||`error_${u}_${l.error_type}_${l.message?.slice(0,20)}`,m=o===p;return!m&&!r?null:h.map((_,g)=>{let x={x:0,y:0};if(_.type==="pcb_component")x=_.center||{x:0,y:0};else if(_.type==="source_component"){const I=t?.find(C=>C.type==="pcb_component"&&C.source_component_id===_.source_component_id);I&&I.type==="pcb_component"&&(x=I.center||{x:0,y:0})}const b=Dt(e,x);if(isNaN(b.x)||isNaN(b.y))return null;const w=Math.abs(e.a),R=Math.max(8,Math.min(30,.5*w)),M=uve(b,i);return re.jsxs(ce.Fragment,{children:[re.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:u_.errorOverlay},width:"100%",height:"100%",children:m?re.jsx("polygon",{points:`${b.x},${b.y-R*1.25} ${b.x+R},${b.y} ${b.x},${b.y+R*1.25} ${b.x-R},${b.y}`,fill:"#ff4444"}):re.jsx("circle",{cx:b.x,cy:b.y,r:R,fill:"none",stroke:m?"#ff4444":"red",strokeWidth:m?Math.max(2,R*.15):Math.max(1,R*.1),opacity:1})}),re.jsx("div",{style:{position:"absolute",left:b.x-(R+10),top:b.y-(R+10),width:(R+10)*2,height:(R+10)*2,zIndex:u_.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:I=>{const C=I.currentTarget.nextElementSibling;if(C){const U=C.querySelector(".error-message");U&&(U.style.opacity="1")}},onMouseLeave:I=>{if(!m){const C=I.currentTarget.nextElementSibling;if(C){const U=C.querySelector(".error-message");U&&(U.style.opacity="0")}}}}),re.jsx("div",{style:{position:"absolute",zIndex:m?u_.errorOverlay+20:u_.errorOverlay+10,left:M.left,top:M.top,color:m?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||m?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:M.transform},children:re.jsx("div",{className:`error-message ${dve}`,style:{opacity:m?1:0,border:`1px solid ${m?"#ff4444":"red"}`},children:l.message})})]},`${p}_${g}`)})})]})};function BUn({primitiveElement:n,elements:e}){let t=n.trace_length?`${n.trace_length.toFixed(3)}`:"";const i=fC(e).source_trace.get(n?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const r=n.trace_length&&i?.max_length&&n.trace_length>i.max_length;return{text:t,isOverLength:r}}function jUn(n){const{primitives:e,is_showing_multiple_traces_length:t,elements:i}=n,r=e.filter(c=>c._element.type==="pcb_trace"),o=i.filter(c=>c.type==="source_trace"),s=e.filter(c=>c._element.type!=="pcb_trace"),a=r.filter(c=>o.some(l=>c._element.type==="pcb_trace"&&c._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0));if(!t)return[...s,...a];if(r.length>1){const c=r.reduce((l,u)=>{const d=l._element.trace_length;return u._element.trace_length<d?u:l},r[0]);return[...s,c]}return e}var HUn={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},VUn=n=>{const{_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:r}=n;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((e.port_hints??[]).concat(r?.port_hints??[]))).filter(c=>!/^[0-9]+$/.test(c)).filter(c=>!c.includes("unnamed_")).sort((c,l)=>l.localeCompare(c)),a=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?a?o.push(...s.map(c=>`${a}.${c}`)):o.push(...s):a&&o.push(a),o.join(", ")}default:return""}},GUn={top:"red",bottom:"aqua"},YUn=({primitive:n,mousePos:e,elements:t})=>{const[i,r]=ce.useState(!1),o=n._element;ce.useEffect(()=>{setTimeout(()=>{r(!0)},100)},[]);const[s,a,c,l]=[n.screen_x,n.screen_y,n.screen_w,n.screen_h],u=n.same_space_index??0,d=26,h=GUn[n?._element?.layer]??"red";let p=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?p=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in n||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in n)&&(p=o.ccw_rotation??0),o.type==="pcb_trace"){const g=BUn({primitiveElement:o,elements:t});if(!g)return null;const x=e.y-35;return re.jsx("div",{style:{zIndex:u_.elementOverlay,position:"absolute",left:e.x,top:x,color:h,pointerEvents:"none",transform:"translateX(-50%)"},children:re.jsx("div",{style:{backgroundColor:"#f2efcc",color:g.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:g.text})})}const m=VUn(n);return m.trim().length===0?null:re.jsx("div",{style:{zIndex:u_.elementOverlay,position:"absolute",left:s-c/2-8,top:a-l/2-8,width:c+16,height:l+16,color:h,transform:`rotate(${-p}deg)`,transformOrigin:"center center"},children:re.jsx("div",{style:{width:i?`calc(100% + ${d*2*u}px)`:"100%",height:i?`calc(100% + ${d*2*u}px)`:"100%",marginLeft:i?`${-d*u}px`:0,marginTop:i?`${-d*u}px`:0,border:`1px solid ${h}`,opacity:i||u===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:re.jsx("div",{style:{position:"absolute",bottom:l+20+d*u,marginRight:i?`${-d*u}px`:0,marginBottom:i?0:-d*u,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${p}deg)`,minWidth:"45px",textAlign:"center"},children:m})})})},qUn=({highlightedPrimitives:n,mousePos:e,elements:t})=>{const[i,r]=iv(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),o=n.some(a=>a._element.type==="pcb_smtpad")&&n.some(a=>a._element.type==="pcb_trace");let s=n;return o&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=jUn({primitives:s,is_showing_multiple_traces_length:r,elements:t}),re.jsx("div",{style:HUn,children:!i&&s.map((a,c)=>re.jsx(YUn,{primitive:a,mousePos:e,elements:t},c))})};function XUn(n,e){return n.size!==e.size?!1:Array.from(n).every(t=>e.has(t))}function WUn(n,e,t){const i=(t.x-e.x)**2+(t.y-e.y)**2;if(i===0)return Xht(n,e);let r=((n.x-e.x)*(t.x-e.x)+(n.y-e.y)*(t.y-e.y))/i;r=Math.max(0,Math.min(1,r));const o={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};return Xht(n,o)}function Xht(n,e){const t=n.x-e.x,i=n.y-e.y;return Math.sqrt(t*t+i*i)}var oq=n=>{if(n.length===0)return null;let e=n[0].x,t=n[0].y,i=n[0].x,r=n[0].y;for(const o of n)o.x<e&&(e=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>r&&(r=o.y);return{center:{x:(e+i)/2,y:(t+r)/2},width:i-e,height:r-t}},Wht=(n,e)=>{if(e.length<3)return!1;let t=!1;for(let i=0,r=e.length-1;i<e.length;r=i++){const o=e[i].x,s=e[i].y,a=e[r].x,c=e[r].y;s>n.y!=c>n.y&&n.x<(a-o)*(n.y-s)/(c-s||Number.EPSILON)+o&&(t=!t)}return t},KUn=(n,e,t)=>{const i=[];for(const r of n){if(!r._element)continue;if("x1"in r&&r._element?.type==="pcb_trace"){const a=WUn({x:e.x,y:e.y},{x:r.x1,y:r.y1},{x:r.x2,y:r.y2}),c=r.width||.5,l=Math.max(c*25,2)/t.a;a<l&&i.push(r);continue}if(r.pcb_drawing_type==="polygon"){const a=r.points.map(l=>({x:di.parse(l.x),y:di.parse(l.y)})),c=oq(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;Wht(e,a)&&i.push(r);continue}if(r.pcb_drawing_type==="polygon_with_arcs"){const a=r.brep_shape.outer_ring.vertices.map(l=>({x:di.parse(l.x),y:di.parse(l.y)})),c=oq(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;Wht(e,a)&&i.push(r);continue}if(!("x"in r&&"y"in r))continue;let o=0,s=0;if("w"in r&&"h"in r)o=r.w,s=r.h;else if("r"in r)o=r.r*2,s=r.r*2;else continue;Math.abs(r.x-e.x)<o/2&&Math.abs(r.y-e.y)<s/2&&i.push(r)}return i},ZUn=({elements:n,children:e,transform:t,primitives:i,onMouseHoverOverPrimitives:r})=>{const[o,s]=ce.useState([]),[a,c]=ce.useState({x:0,y:0}),l=ce.useMemo(()=>{const d=[];for(const h of o){if(h._element?.type==="pcb_via"||h._element?.type==="pcb_component"||h?.layer==="drill")continue;let p=null,m=0,_=0;if(h.pcb_drawing_type==="polygon"){const w=oq(h.points);if(!w)continue;p=w.center,m=w.width,_=w.height}else if(h.pcb_drawing_type==="polygon_with_arcs"){const w=h.brep_shape.outer_ring.vertices.map(k=>({x:k.x,y:k.y})),E=oq(w);if(!E)continue;p=E.center,m=E.width,_=E.height}else"x"in h&&"y"in h&&(p={x:h.x,y:h.y},m="w"in h?h.w:"r"in h?h.r*2:0,_="h"in h?h.h:"r"in h?h.r*2:0);if(!p)continue;const g=Dt(t,p),x={w:m*t.a,h:_*t.a},b=d.filter(w=>g.x===w.screen_x&&g.y===w.screen_y&&x.w===w.screen_w&&x.h===w.screen_h).length;d.push({...h,x:p.x,y:p.y,w:m,h:_,screen_x:g.x,screen_y:g.y,screen_w:x.w,screen_h:x.h,same_space_index:b})}return d},[o,t]),u=(d,h,p,m)=>{c({x:d,y:h});const _=Dt(F2(p),{x:d,y:h}),g=KUn(m,_,p);XUn(new Set(g.map(x=>x._pcb_drawing_object_id)),new Set(o.map(x=>x._pcb_drawing_object_id)))||(s(g),r(g))};return re.jsxs("div",{style:{position:"relative"},onMouseMove:d=>{if(t){const h=d.currentTarget.getBoundingClientRect(),p=d.clientX-h.left,m=d.clientY-h.top;u(p,m,t,i)}},onTouchStart:d=>{if(t){const h=d.touches[0],p=d.currentTarget.getBoundingClientRect(),m=h.clientX-p.left,_=h.clientY-p.top;u(m,_,t,i)}},children:[e,re.jsx(qUn,{elements:n,mousePos:a,highlightedPrimitives:l})]})},Kht=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],QUn=({children:n,transform:e=Bh(),elements:t=[]})=>{const[i,{width:r,height:o}]=tq(),s=ce.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:c}=iv(l=>({is_showing_pcb_groups:l.is_showing_pcb_groups,pcb_group_view_mode:l.pcb_group_view_mode}));return ce.useEffect(()=>{const l=s.current;if(!l||!r||!o)return;l.width=r,l.height=o;const u=l.getContext("2d");if(!u||(u.clearRect(0,0,r,o),!a))return;const d=t.filter(w=>w.type==="pcb_group"),h=t.filter(w=>w.type==="pcb_component"),p=t.filter(w=>w.type==="source_group"),m=new Map(p.map(w=>[w.source_group_id,w])),_=d.filter(w=>{if(c==="all")return!0;if(!w.source_group_id)return!1;const E=m.get(w.source_group_id);return E?E.was_automatically_named!==!0:!1}),g=new Map;p.forEach(w=>{const E=w;if(E.parent_source_group_id){const k=g.get(E.parent_source_group_id)||[];k.push(w.source_group_id),g.set(E.parent_source_group_id,k)}});const x=w=>{const E=[],k=g.get(w)||[];for(const A of k)E.push(A),E.push(...x(A));return E},b=w=>{const E=p.find(k=>k.source_group_id===w);return E?.parent_source_group_id?1+b(E.parent_source_group_id):0};_.forEach((w,E)=>{let k=h.filter(Qe=>Qe.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const Qe=x(w.source_group_id),Xe=d.filter(Ge=>Ge.source_group_id&&Qe.includes(Ge.source_group_id));for(const Ge of Xe){const et=h.filter(De=>De.pcb_group_id===Ge.pcb_group_id);k=[...k,...et]}}if(k.length===0)return;let A=1/0,R=1/0,M=-1/0,I=-1/0;if(k.forEach(Qe=>{if(Qe.center&&typeof Qe.width=="number"&&typeof Qe.height=="number"){const Xe=Qe.center.x-Qe.width/2,Ge=Qe.center.x+Qe.width/2,et=Qe.center.y+Qe.height/2,De=Qe.center.y-Qe.height/2;A=Math.min(A,Xe),M=Math.max(M,Ge),R=Math.min(R,De),I=Math.max(I,et)}}),A===1/0||M===-1/0)return;const C=w.source_group_id?b(w.source_group_id):0,U=w.source_group_id?x(w.source_group_id).length>0:!1,Y=1+(U?.5:0);A-=Y,M+=Y,R-=Y,I+=Y;const X=Dt(e,{x:A,y:I}),K=Dt(e,{x:M,y:I}),J=Dt(e,{x:A,y:R}),le=Dt(e,{x:M,y:R}),pe=Kht[E%Kht.length];u.strokeStyle=pe,u.lineWidth=2;const ve=Math.max(4,Math.min(12,8*Math.abs(e.a))),oe=Math.max(2,Math.min(6,4*Math.abs(e.a))),de=ve*(U?1.3:1),Te=oe;u.setLineDash([de,Te]),u.beginPath(),u.moveTo(X.x,X.y),u.lineTo(K.x,K.y),u.lineTo(le.x,le.y),u.lineTo(J.x,J.y),u.closePath(),u.stroke();const Me=Math.max(8,Math.min(12,10*Math.abs(e.a))),Oe=C==0||C==1?0:C*.11,$e=Me*(1-Oe),Re=4,se=w.name||`Group ${E+1}`;u.font=`${$e}px sans-serif`,u.setLineDash([]);const xe=u.measureText(se).width+Re*2,Ve=$e+Re*2,tt=X.x-5,ct=X.y-5,Ce=3;if(u.fillStyle="rgba(0, 0, 0, 0.8)",u.beginPath(),u.roundRect(tt,ct-Ve,xe,Ve,Ce),u.fill(),u.fillStyle=pe,u.textAlign="left",u.textBaseline="middle",u.fillText(se,tt+Re,ct-Ve/2),w.anchor_position){const Qe=w.anchor_position,Xe=A,Ge=M,et=I,De=R;let ke={x:Qe.x,y:Qe.y};const qe=Math.abs(Qe.x-Xe),Le=Math.abs(Qe.x-Ge),We=Math.abs(Qe.y-et),nt=Math.abs(Qe.y-De),mt=Math.min(qe,Le,We,nt);mt===qe?ke={x:Xe,y:Qe.y}:mt===Le?ke={x:Ge,y:Qe.y}:mt===We?ke={x:Qe.x,y:et}:ke={x:Qe.x,y:De};const bt=Dt(e,ke);u.strokeStyle="white",u.lineWidth=1.5,u.setLineDash([]);const _t=Math.max(4,Math.min(8,6*Math.abs(e.a)));u.beginPath(),u.moveTo(bt.x-_t,bt.y),u.lineTo(bt.x+_t,bt.y),u.stroke(),u.beginPath(),u.moveTo(bt.x,bt.y-_t),u.lineTo(bt.x,bt.y+_t),u.stroke()}})},[t,e,r,o,a,c]),re.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[n,re.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:u_.pcbGroupOverlay,display:a?"block":"none"}})]})},JUn=({transform:n,soup:e,children:t})=>{const i=iv(a=>a.is_showing_rats_nest),{netMap:r,idToNetMap:o}=ce.useMemo(()=>jht(e||[]),[e]),s=ce.useMemo(()=>{if(!e||!i)return[];const a=h=>{const p=fC(e)[h.replace(/_\d+$/,"")].get(h);return p&&"x"in p&&"y"in p?{x:p.x,y:p.y}:null},c=(h,p)=>{const m=r[p]||[];let _=null,g=1/0;return m.forEach(x=>{const b=a(x);if(b){const w=Math.sqrt((h.x-b.x)**2+(h.y-b.y)**2);w<g&&w>0&&(g=w,_=b)}}),_},l=fC(e).pcb_port.list(),u=fC(e).source_trace.list(),d=[];return l.forEach((h,p)=>{const m=o[h.pcb_port_id];let _=!1;for(const b of u)b.connected_source_port_ids.includes(h.source_port_id)&&b.connected_source_net_ids.length>0&&(_=!0);if(!m)return;const g={x:h.x,y:h.y},x=c(g,m);x&&d.push({key:`${h.pcb_port_id}-${p}`,startPoint:g,endPoint:x,isInNet:_})}),d},[e,r,o,i]);return!e||!i?t:(n||(n=Bh()),re.jsxs("div",{style:{position:"relative"},children:[t,re.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:u_.ratsNestOverlay},children:s.map(({key:a,startPoint:c,endPoint:l,isInNet:u})=>{const d=Dt(n,c),h=Dt(n,l);return re.jsx("line",{x1:d.x,y1:d.y,x2:h.x,y2:h.y,stroke:"white",strokeWidth:"1",strokeDasharray:u?"6,6":void 0},a)})})]}))},eBn={version:"1.11.246"},mC=(n,e)=>{const t=iv(i=>i.is_mouse_over_container);ce.useEffect(()=>{if(!n||typeof e!="function")return;const i=r=>{const o=n.split("+"),s=o.includes("ctrl"),a=o.includes("shift"),c=o.includes("alt"),l=o.includes("meta"),u=o[o.length-1];t&&(!s||r.ctrlKey)&&(!a||r.shiftKey)&&(!c||r.altKey)&&(!l||r.metaKey)&&r.key.toLowerCase()===u.toLowerCase()&&(r.preventDefault(),e())};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[n,e])},tBn=()=>{const[n,e]=ce.useState(!1);return ce.useEffect(()=>{const t=()=>{e(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),n},nBn=({name:n,selected:e,onClick:t})=>re.jsxs("div",{className:JI`
5606
+ `,UUn=({children:n,transform:e=Bh(),elements:t})=>{const i=ce.useRef(null),{isShowingDRCErrors:r,hoveredErrorId:o}=iv(l=>({isShowingDRCErrors:l.is_showing_drc_errors,hoveredErrorId:l.hovered_error_id}));if(!t)return re.jsx("div",{style:{position:"relative"},ref:i,children:n});const s=t.filter(l=>l.type==="pcb_trace_error"),a=t.filter(l=>l.type==="pcb_trace_error"&&l.message?.includes("Multiple components found with name")),c=new Map;return t.forEach(l=>{l.type==="pcb_port"&&c.set(l.pcb_port_id,l)}),re.jsxs("div",{style:{position:"relative"},ref:i,children:[n,s.map((l,u)=>{const{pcb_port_ids:d,pcb_trace_id:h}=l,p=d?.[0]?c.get(d[0]):void 0,m=d?.[1]?c.get(d[1]):void 0,_=t?fC(t).pcb_trace.get(h):void 0,g=l.pcb_trace_error_id||`error_${u}_${l.error_type}_${l.message?.slice(0,20)}`,x=o===g;if(p&&m){const b=Dt(e,{x:p.x,y:p.y}),w=Dt(e,{x:m.x,y:m.y}),E=!(isNaN(b.x)||isNaN(b.y)||isNaN(w.x)||isNaN(w.y)),k={x:(b.x+w.x)/2,y:(b.y+w.y)/2};if(isNaN(k.x)||isNaN(k.y))return null;const A=uve(k,i);return re.jsxs(ce.Fragment,{children:[re.jsx($Un,{screenPort1:b,screenPort2:w,errorCenter:k,canLineBeDrawn:E,isHighlighted:x}),re.jsx("div",{style:{position:"absolute",left:k.x-15,top:k.y-15,width:30,height:30,zIndex:u_.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:R=>{const M=R.currentTarget.nextElementSibling;if(M){const I=M.querySelector(".error-message");I&&(I.style.opacity="1")}},onMouseLeave:R=>{if(!x){const M=R.currentTarget.nextElementSibling;if(M){const I=M.querySelector(".error-message");I&&(I.style.opacity="0")}}}}),re.jsx("div",{style:{position:"absolute",zIndex:x?200:100,left:A.left,top:A.top,color:x?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||x?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:A.transform},children:re.jsx("div",{className:`error-message ${dve}`,style:{opacity:x?1:0,border:`1px solid ${x?"#ff4444":"red"}`},children:l.message})})]},g)}if(_?.route&&(r||x)){const b=_.route.map(A=>Dt(e,{x:A.x,y:A.y}));if(b.some(A=>isNaN(A.x)||isNaN(A.y)))return null;const w=Math.floor(b.length/2),E=b[w],k=uve(E,i);return re.jsxs(ce.Fragment,{children:[re.jsx(FUn,{points:b,errorCenter:E,isHighlighted:x}),re.jsx("div",{style:{position:"absolute",left:E.x-15,top:E.y-15,width:30,height:30,zIndex:u_.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:A=>{const R=A.currentTarget.nextElementSibling;if(R){const M=R.querySelector(".error-message");M&&(M.style.opacity="1")}},onMouseLeave:A=>{if(!x){const R=A.currentTarget.nextElementSibling;if(R){const M=R.querySelector(".error-message");M&&(M.style.opacity="0")}}}}),re.jsx("div",{style:{position:"absolute",zIndex:x?u_.errorOverlay+10:u_.errorOverlay+1,left:k.left,top:k.top,color:x?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:"flex",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:k.transform},children:re.jsx("div",{className:`error-message ${dve}`,style:{opacity:x?1:0,border:`1px solid ${x?"#ff4444":"red"}`},children:l.message})})]},g)}return null}),a.map((l,u)=>{const d=l.component_name||l.message?.match(/name "([^"]+)"/)?.[1];if(!d)return null;const h=t?.filter(_=>_.type==="source_component"&&_.name===d||_.type==="pcb_component"&&t?.find(g=>g.type==="source_component"&&g.source_component_id===_.source_component_id&&g.name===d))||[],p=l.pcb_trace_error_id||`error_${u}_${l.error_type}_${l.message?.slice(0,20)}`,m=o===p;return!m&&!r?null:h.map((_,g)=>{let x={x:0,y:0};if(_.type==="pcb_component")x=_.center||{x:0,y:0};else if(_.type==="source_component"){const I=t?.find(C=>C.type==="pcb_component"&&C.source_component_id===_.source_component_id);I&&I.type==="pcb_component"&&(x=I.center||{x:0,y:0})}const b=Dt(e,x);if(isNaN(b.x)||isNaN(b.y))return null;const w=Math.abs(e.a),R=Math.max(8,Math.min(30,.5*w)),M=uve(b,i);return re.jsxs(ce.Fragment,{children:[re.jsx("svg",{style:{position:"absolute",left:0,top:0,pointerEvents:"none",mixBlendMode:"difference",zIndex:u_.errorOverlay},width:"100%",height:"100%",children:m?re.jsx("polygon",{points:`${b.x},${b.y-R*1.25} ${b.x+R},${b.y} ${b.x},${b.y+R*1.25} ${b.x-R},${b.y}`,fill:"#ff4444"}):re.jsx("circle",{cx:b.x,cy:b.y,r:R,fill:"none",stroke:m?"#ff4444":"red",strokeWidth:m?Math.max(2,R*.15):Math.max(1,R*.1),opacity:1})}),re.jsx("div",{style:{position:"absolute",left:b.x-(R+10),top:b.y-(R+10),width:(R+10)*2,height:(R+10)*2,zIndex:u_.errorOverlay+5,cursor:"pointer",borderRadius:"50%"},onMouseEnter:I=>{const C=I.currentTarget.nextElementSibling;if(C){const U=C.querySelector(".error-message");U&&(U.style.opacity="1")}},onMouseLeave:I=>{if(!m){const C=I.currentTarget.nextElementSibling;if(C){const U=C.querySelector(".error-message");U&&(U.style.opacity="0")}}}}),re.jsx("div",{style:{position:"absolute",zIndex:m?u_.errorOverlay+20:u_.errorOverlay+10,left:M.left,top:M.top,color:m?"#ff4444":"red",textAlign:"center",fontFamily:"sans-serif",fontSize:12,display:r||m?"flex":"none",flexDirection:"column",alignItems:"center",pointerEvents:"none",transform:M.transform},children:re.jsx("div",{className:`error-message ${dve}`,style:{opacity:m?1:0,border:`1px solid ${m?"#ff4444":"red"}`},children:l.message})})]},`${p}_${g}`)})})]})};function BUn({primitiveElement:n,elements:e}){let t=n.trace_length?`${n.trace_length.toFixed(3)}`:"";const i=fC(e).source_trace.get(n?.source_trace_id);if(i?.display_name&&(i?.max_length?t+=` / ${i.max_length}mm `:t+=" mm ",t+=`(${i.display_name})`),!t)return null;const r=n.trace_length&&i?.max_length&&n.trace_length>i.max_length;return{text:t,isOverLength:r}}function jUn(n){const{primitives:e,is_showing_multiple_traces_length:t,elements:i}=n,r=e.filter(c=>c._element.type==="pcb_trace"),o=i.filter(c=>c.type==="source_trace"),s=e.filter(c=>c._element.type!=="pcb_trace"),a=r.filter(c=>o.some(l=>c._element.type==="pcb_trace"&&c._element.source_trace_id===l.source_trace_id&&l.max_length!==void 0));if(!t)return[...s,...a];if(r.length>1){const c=r.reduce((l,u)=>{const d=l._element.trace_length;return u._element.trace_length<d?u:l},r[0]);return[...s,c]}return e}var HUn={position:"absolute",left:0,top:0,pointerEvents:"none",color:"red",fontFamily:"sans-serif",fontSize:12,textShadow:"0 0 2px black"},VUn=n=>{const{_element:e,_parent_pcb_component:t,_parent_source_component:i,_source_port:r}=n;switch(e.type){case"pcb_trace":return e.trace_length?`${e.trace_length.toFixed(3)}`:"";case"pcb_smtpad":case"pcb_plated_hole":{const o=[],s=Array.from(new Set((e.port_hints??[]).concat(r?.port_hints??[]))).filter(c=>!/^[0-9]+$/.test(c)).filter(c=>!c.includes("unnamed_")).sort((c,l)=>l.localeCompare(c)),a=i&&"name"in i&&i.name&&!i.name.includes("unnamed_")?i.name:null;return s.length>0?a?o.push(...s.map(c=>`${a}.${c}`)):o.push(...s):a&&o.push(a),o.join(", ")}default:return""}},GUn={top:"red",bottom:"aqua"},YUn=({primitive:n,mousePos:e,elements:t})=>{const[i,r]=ce.useState(!1),o=n._element;ce.useEffect(()=>{setTimeout(()=>{r(!0)},100)},[]);const[s,a,c,l]=[n.screen_x,n.screen_y,n.screen_w,n.screen_h],u=n.same_space_index??0,d=26,h=GUn[n?._element?.layer]??"red";let p=0;if(o.type==="pcb_smtpad"&&o?.shape==="rotated_rect"?p=o?.ccw_rotation??0:(o.type==="pcb_smtpad"&&(o?.shape==="pill"||o?.shape==="rotated_pill")&&"ccw_rotation"in n||o.type==="pcb_plated_hole"&&(o?.shape==="pill"||o?.shape==="oval")&&"ccw_rotation"in n)&&(p=o.ccw_rotation??0),o.type==="pcb_trace"){const g=BUn({primitiveElement:o,elements:t});if(!g)return null;const x=e.y-35;return re.jsx("div",{style:{zIndex:u_.elementOverlay,position:"absolute",left:e.x,top:x,color:h,pointerEvents:"none",transform:"translateX(-50%)"},children:re.jsx("div",{style:{backgroundColor:"#f2efcc",color:g.isOverLength?"red":"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",minWidth:"45px",textAlign:"center",whiteSpace:"nowrap"},children:g.text})})}const m=VUn(n);return m.trim().length===0?null:re.jsx("div",{style:{zIndex:u_.elementOverlay,position:"absolute",left:s-c/2-8,top:a-l/2-8,width:c+16,height:l+16,color:h,transform:`rotate(${-p}deg)`,transformOrigin:"center center"},children:re.jsx("div",{style:{width:i?`calc(100% + ${d*2*u}px)`:"100%",height:i?`calc(100% + ${d*2*u}px)`:"100%",marginLeft:i?`${-d*u}px`:0,marginTop:i?`${-d*u}px`:0,border:`1px solid ${h}`,opacity:i||u===0?1:0,transition:"width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"},children:re.jsx("div",{style:{position:"absolute",bottom:l+20+d*u,marginRight:i?`${-d*u}px`:0,marginBottom:i?0:-d*u,transition:"margin-right 0.2s, margin-bottom 0.2s",backgroundColor:"#f2efcc",color:"black",textShadow:"none",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale",padding:"6px 6px",borderRadius:"6px",fontSize:"14px",transform:`rotate(${p}deg)`,minWidth:"45px",textAlign:"center"},children:m})})})},qUn=({highlightedPrimitives:n,mousePos:e,elements:t})=>{const[i,r]=iv(a=>[a.is_moving_component,a.is_showing_multiple_traces_length]),o=n.some(a=>a._element.type==="pcb_smtpad")&&n.some(a=>a._element.type==="pcb_trace");let s=n;return o&&(s=s.filter(a=>a._element.type==="pcb_smtpad")),s=jUn({primitives:s,is_showing_multiple_traces_length:r,elements:t}),re.jsx("div",{style:HUn,children:!i&&s.map((a,c)=>re.jsx(YUn,{primitive:a,mousePos:e,elements:t},c))})};function XUn(n,e){return n.size!==e.size?!1:Array.from(n).every(t=>e.has(t))}function WUn(n,e,t){const i=(t.x-e.x)**2+(t.y-e.y)**2;if(i===0)return Xht(n,e);let r=((n.x-e.x)*(t.x-e.x)+(n.y-e.y)*(t.y-e.y))/i;r=Math.max(0,Math.min(1,r));const o={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};return Xht(n,o)}function Xht(n,e){const t=n.x-e.x,i=n.y-e.y;return Math.sqrt(t*t+i*i)}var oq=n=>{if(n.length===0)return null;let e=n[0].x,t=n[0].y,i=n[0].x,r=n[0].y;for(const o of n)o.x<e&&(e=o.x),o.y<t&&(t=o.y),o.x>i&&(i=o.x),o.y>r&&(r=o.y);return{center:{x:(e+i)/2,y:(t+r)/2},width:i-e,height:r-t}},Wht=(n,e)=>{if(e.length<3)return!1;let t=!1;for(let i=0,r=e.length-1;i<e.length;r=i++){const o=e[i].x,s=e[i].y,a=e[r].x,c=e[r].y;s>n.y!=c>n.y&&n.x<(a-o)*(n.y-s)/(c-s||Number.EPSILON)+o&&(t=!t)}return t},KUn=(n,e,t)=>{const i=[];for(const r of n){if(!r._element)continue;if("x1"in r&&r._element?.type==="pcb_trace"){const a=WUn({x:e.x,y:e.y},{x:r.x1,y:r.y1},{x:r.x2,y:r.y2}),c=r.width||.5,l=Math.max(c*25,2)/t.a;a<l&&i.push(r);continue}if(r.pcb_drawing_type==="polygon"){const a=r.points.map(l=>({x:di.parse(l.x),y:di.parse(l.y)})),c=oq(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;Wht(e,a)&&i.push(r);continue}if(r.pcb_drawing_type==="polygon_with_arcs"){const a=r.brep_shape.outer_ring.vertices.map(l=>({x:di.parse(l.x),y:di.parse(l.y)})),c=oq(a);if(!c||e.x<c.center.x-c.width/2||e.x>c.center.x+c.width/2||e.y<c.center.y-c.height/2||e.y>c.center.y+c.height/2)continue;Wht(e,a)&&i.push(r);continue}if(!("x"in r&&"y"in r))continue;let o=0,s=0;if("w"in r&&"h"in r)o=r.w,s=r.h;else if("r"in r)o=r.r*2,s=r.r*2;else continue;Math.abs(r.x-e.x)<o/2&&Math.abs(r.y-e.y)<s/2&&i.push(r)}return i},ZUn=({elements:n,children:e,transform:t,primitives:i,onMouseHoverOverPrimitives:r})=>{const[o,s]=ce.useState([]),[a,c]=ce.useState({x:0,y:0}),l=ce.useMemo(()=>{const d=[];for(const h of o){if(h._element?.type==="pcb_via"||h._element?.type==="pcb_component"||h?.layer==="drill")continue;let p=null,m=0,_=0;if(h.pcb_drawing_type==="polygon"){const w=oq(h.points);if(!w)continue;p=w.center,m=w.width,_=w.height}else if(h.pcb_drawing_type==="polygon_with_arcs"){const w=h.brep_shape.outer_ring.vertices.map(k=>({x:k.x,y:k.y})),E=oq(w);if(!E)continue;p=E.center,m=E.width,_=E.height}else"x"in h&&"y"in h&&(p={x:h.x,y:h.y},m="w"in h?h.w:"r"in h?h.r*2:0,_="h"in h?h.h:"r"in h?h.r*2:0);if(!p)continue;const g=Dt(t,p),x={w:m*t.a,h:_*t.a},b=d.filter(w=>g.x===w.screen_x&&g.y===w.screen_y&&x.w===w.screen_w&&x.h===w.screen_h).length;d.push({...h,x:p.x,y:p.y,w:m,h:_,screen_x:g.x,screen_y:g.y,screen_w:x.w,screen_h:x.h,same_space_index:b})}return d},[o,t]),u=(d,h,p,m)=>{c({x:d,y:h});const _=Dt(F2(p),{x:d,y:h}),g=KUn(m,_,p);XUn(new Set(g.map(x=>x._pcb_drawing_object_id)),new Set(o.map(x=>x._pcb_drawing_object_id)))||(s(g),r(g))};return re.jsxs("div",{style:{position:"relative"},onMouseMove:d=>{if(t){const h=d.currentTarget.getBoundingClientRect(),p=d.clientX-h.left,m=d.clientY-h.top;u(p,m,t,i)}},onTouchStart:d=>{if(t){const h=d.touches[0],p=d.currentTarget.getBoundingClientRect(),m=h.clientX-p.left,_=h.clientY-p.top;u(m,_,t,i)}},children:[e,re.jsx(qUn,{elements:n,mousePos:a,highlightedPrimitives:l})]})},Kht=["rgb(255, 100, 100)","rgb(100, 255, 100)","rgb(100, 100, 255)","rgb(255, 255, 100)","rgb(255, 100, 255)","rgb(100, 255, 255)","rgb(255, 150, 100)","rgb(150, 100, 255)","rgb(100, 255, 150)","rgb(255, 100, 150)"],QUn=({children:n,transform:e=Bh(),elements:t=[]})=>{const[i,{width:r,height:o}]=tq(),s=ce.useRef(null),{is_showing_pcb_groups:a,pcb_group_view_mode:c}=iv(l=>({is_showing_pcb_groups:l.is_showing_pcb_groups,pcb_group_view_mode:l.pcb_group_view_mode}));return ce.useEffect(()=>{const l=s.current;if(!l||!r||!o)return;l.width=r,l.height=o;const u=l.getContext("2d");if(!u||(u.clearRect(0,0,r,o),!a))return;const d=t.filter(w=>w.type==="pcb_group"),h=t.filter(w=>w.type==="pcb_component"),p=t.filter(w=>w.type==="source_group"),m=new Map(p.map(w=>[w.source_group_id,w])),_=d.filter(w=>{if(c==="all")return!0;if(!w.source_group_id)return!1;const E=m.get(w.source_group_id);return E?E.was_automatically_named!==!0:!1}),g=new Map;p.forEach(w=>{const E=w;if(E.parent_source_group_id){const k=g.get(E.parent_source_group_id)||[];k.push(w.source_group_id),g.set(E.parent_source_group_id,k)}});const x=w=>{const E=[],k=g.get(w)||[];for(const A of k)E.push(A),E.push(...x(A));return E},b=w=>{const E=p.find(k=>k.source_group_id===w);return E?.parent_source_group_id?1+b(E.parent_source_group_id):0};_.forEach((w,E)=>{let k=h.filter(Qe=>Qe.pcb_group_id===w.pcb_group_id);if(w.source_group_id){const Qe=x(w.source_group_id),Xe=d.filter(Ge=>Ge.source_group_id&&Qe.includes(Ge.source_group_id));for(const Ge of Xe){const et=h.filter(De=>De.pcb_group_id===Ge.pcb_group_id);k=[...k,...et]}}if(k.length===0)return;let A=1/0,R=1/0,M=-1/0,I=-1/0;if(k.forEach(Qe=>{if(Qe.center&&typeof Qe.width=="number"&&typeof Qe.height=="number"){const Xe=Qe.center.x-Qe.width/2,Ge=Qe.center.x+Qe.width/2,et=Qe.center.y+Qe.height/2,De=Qe.center.y-Qe.height/2;A=Math.min(A,Xe),M=Math.max(M,Ge),R=Math.min(R,De),I=Math.max(I,et)}}),A===1/0||M===-1/0)return;const C=w.source_group_id?b(w.source_group_id):0,U=w.source_group_id?x(w.source_group_id).length>0:!1,Y=1+(U?.5:0);A-=Y,M+=Y,R-=Y,I+=Y;const X=Dt(e,{x:A,y:I}),K=Dt(e,{x:M,y:I}),J=Dt(e,{x:A,y:R}),le=Dt(e,{x:M,y:R}),pe=Kht[E%Kht.length];u.strokeStyle=pe,u.lineWidth=2;const ve=Math.max(4,Math.min(12,8*Math.abs(e.a))),oe=Math.max(2,Math.min(6,4*Math.abs(e.a))),de=ve*(U?1.3:1),Te=oe;u.setLineDash([de,Te]),u.beginPath(),u.moveTo(X.x,X.y),u.lineTo(K.x,K.y),u.lineTo(le.x,le.y),u.lineTo(J.x,J.y),u.closePath(),u.stroke();const Me=Math.max(8,Math.min(12,10*Math.abs(e.a))),Oe=C==0||C==1?0:C*.11,$e=Me*(1-Oe),Re=4,se=w.name||`Group ${E+1}`;u.font=`${$e}px sans-serif`,u.setLineDash([]);const xe=u.measureText(se).width+Re*2,Ve=$e+Re*2,tt=X.x-5,ct=X.y-5,Ce=3;if(u.fillStyle="rgba(0, 0, 0, 0.8)",u.beginPath(),u.roundRect(tt,ct-Ve,xe,Ve,Ce),u.fill(),u.fillStyle=pe,u.textAlign="left",u.textBaseline="middle",u.fillText(se,tt+Re,ct-Ve/2),w.anchor_position){const Qe=w.anchor_position,Xe=A,Ge=M,et=I,De=R;let ke={x:Qe.x,y:Qe.y};const qe=Math.abs(Qe.x-Xe),Le=Math.abs(Qe.x-Ge),We=Math.abs(Qe.y-et),nt=Math.abs(Qe.y-De),mt=Math.min(qe,Le,We,nt);mt===qe?ke={x:Xe,y:Qe.y}:mt===Le?ke={x:Ge,y:Qe.y}:mt===We?ke={x:Qe.x,y:et}:ke={x:Qe.x,y:De};const bt=Dt(e,ke);u.strokeStyle="white",u.lineWidth=1.5,u.setLineDash([]);const _t=Math.max(4,Math.min(8,6*Math.abs(e.a)));u.beginPath(),u.moveTo(bt.x-_t,bt.y),u.lineTo(bt.x+_t,bt.y),u.stroke(),u.beginPath(),u.moveTo(bt.x,bt.y-_t),u.lineTo(bt.x,bt.y+_t),u.stroke()}})},[t,e,r,o,a,c]),re.jsxs("div",{ref:i,style:{position:"relative",width:"100%",height:"100%"},children:[n,re.jsx("canvas",{ref:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:u_.pcbGroupOverlay,display:a?"block":"none"}})]})},JUn=({transform:n,soup:e,children:t})=>{const i=iv(a=>a.is_showing_rats_nest),{netMap:r,idToNetMap:o}=ce.useMemo(()=>jht(e||[]),[e]),s=ce.useMemo(()=>{if(!e||!i)return[];const a=h=>{const p=fC(e)[h.replace(/_\d+$/,"")].get(h);return p&&"x"in p&&"y"in p?{x:p.x,y:p.y}:null},c=(h,p)=>{const m=r[p]||[];let _=null,g=1/0;return m.forEach(x=>{const b=a(x);if(b){const w=Math.sqrt((h.x-b.x)**2+(h.y-b.y)**2);w<g&&w>0&&(g=w,_=b)}}),_},l=fC(e).pcb_port.list(),u=fC(e).source_trace.list(),d=[];return l.forEach((h,p)=>{const m=o[h.pcb_port_id];let _=!1;for(const b of u)b.connected_source_port_ids.includes(h.source_port_id)&&b.connected_source_net_ids.length>0&&(_=!0);if(!m)return;const g={x:h.x,y:h.y},x=c(g,m);x&&d.push({key:`${h.pcb_port_id}-${p}`,startPoint:g,endPoint:x,isInNet:_})}),d},[e,r,o,i]);return!e||!i?t:(n||(n=Bh()),re.jsxs("div",{style:{position:"relative"},children:[t,re.jsx("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",opacity:.5,zIndex:u_.ratsNestOverlay},children:s.map(({key:a,startPoint:c,endPoint:l,isInNet:u})=>{const d=Dt(n,c),h=Dt(n,l);return re.jsx("line",{x1:d.x,y1:d.y,x2:h.x,y2:h.y,stroke:"white",strokeWidth:"1",strokeDasharray:u?"6,6":void 0},a)})})]}))},eBn={version:"1.11.247"},mC=(n,e)=>{const t=iv(i=>i.is_mouse_over_container);ce.useEffect(()=>{if(!n||typeof e!="function")return;const i=r=>{const o=n.split("+"),s=o.includes("ctrl"),a=o.includes("shift"),c=o.includes("alt"),l=o.includes("meta"),u=o[o.length-1];t&&(!s||r.ctrlKey)&&(!a||r.shiftKey)&&(!c||r.altKey)&&(!l||r.metaKey)&&r.key.toLowerCase()===u.toLowerCase()&&(r.preventDefault(),e())};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[n,e])},tBn=()=>{const[n,e]=ce.useState(!1);return ce.useEffect(()=>{const t=()=>{e(window.innerWidth<=768)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),n},nBn=({name:n,selected:e,onClick:t})=>re.jsxs("div",{className:JI`
5607
5607
  margin-top: 2px;
5608
5608
  padding: 4px;
5609
5609
  padding-left: 8px;
@@ -5688,7 +5688,7 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}}});function kht(n,e,t){if(!e||!t)retu
5688
5688
  * Copyright (c) 2013-2015, 2017, Jon Schlinkert.
5689
5689
  * Released under the MIT License.
5690
5690
  *)
5691
- */const lBn=({containerClassName:n,...e})=>{const t=ce.useRef(null),[i,r]=ce.useState(620);return ce.useLayoutEffect(()=>{const o=()=>{if(t.current){const a=t.current.clientHeight,c=window.innerHeight;r(Math.min(Math.max(a,620),c))}};o();const s=new ResizeObserver(o);return t.current&&s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),re.jsx("div",{ref:t,className:n||"rf-w-full rf-h-full",children:re.jsx(cBn,{...e,height:i})})},uBn='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.18 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-1{right:.25rem}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.\\!rf-z-\\[200\\]{z-index:200!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-z-\\[101\\]{z-index:101}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-4{margin-left:1rem;margin-right:1rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mr-4{margin-right:1rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline-block{display:inline-block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-20{height:5rem}.rf-h-24{height:6rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-7{height:1.75rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[70vh\\]{max-height:70vh}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[100px\\]{min-height:100px}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-20{width:5rem}.rf-w-24{width:6rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-40{width:10rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-80{width:20rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-32{min-width:8rem}.rf-min-w-80{min-width:20rem}.rf-min-w-96{min-width:24rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[600px\\]{min-width:600px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-64{max-width:16rem}.rf-max-w-96{max-width:24rem}.rf-max-w-\\[1000px\\]{max-width:1000px}.rf-max-w-\\[150px\\]{max-width:150px}.rf-max-w-\\[200px\\]{max-width:200px}.rf-max-w-\\[40\\%\\]{max-width:40%}.rf-max-w-\\[600px\\]{max-width:600px}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-max-w-xs{max-width:20rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.rf-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf--translate-x-1\\/2{--tw-translate-x:-50%}.rf--translate-x-1\\/2,.rf--translate-y-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-items-stretch{align-items:stretch}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.\\!rf-overflow-hidden{overflow:hidden!important}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rf-whitespace-normal{white-space:normal}.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-break-all{word-break:break-all}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-2{border-width:2px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-none{border-style:none}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-300{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-green-400{--tw-border-opacity:1;border-color:rgb(74 222 128/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-amber-50{--tw-bg-opacity:1;background-color:rgb(255 251 235/var(--tw-bg-opacity,1))}.rf-bg-amber-50\\/30{background-color:rgba(255,251,235,.3)}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-50\\/30{background-color:rgba(239,246,255,.3)}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-amber-500{fill:#f59e0b}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-1{padding-bottom:.25rem}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-0{padding-top:0}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.\\!rf-font-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-amber-500{--tw-text-opacity:1;color:rgb(245 158 11/var(--tw-text-opacity,1))}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.rf-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.rf-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.rf-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-600{--tw-text-opacity:1;color:rgb(202 138 4/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-70{opacity:.7}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:rf-border-blue-500:hover{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-slate-200:hover{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-800:hover{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-900:hover{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group:hover .group-hover\\:rf-opacity-100,.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\=true\\]\\:rf-opacity-50[data-disabled=true],.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-gray-700:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\\:rf-bg-gray-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-gray-500:is(.rf-dark *){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-block{display:block}.sm\\:rf-inline{display:inline}.sm\\:rf-grid{display:grid}.sm\\:rf-hidden{display:none}.sm\\:rf-w-auto{width:auto}.sm\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\\:rf-grid-cols-\\[1fr_auto\\]{grid-template-columns:1fr auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-justify-self-end{justify-self:end}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-right{text-align:right}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',aq=()=>{ce.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=uBn,document.head.appendChild(e)},[])},dBn=n=>{ce.useEffect(()=>(n?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[n])},Qht=n=>`hsl(${cw.indexOf(n)*137.5%360}, 70%, 50%)`,hBn=({phaseTimings:n})=>{if(!n)return null;const e=Object.values(n).reduce((t,i)=>t+i,0);return re.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[re.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:cw.map(t=>{const i=n[t]||0,r=i/e*100;return re.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:Qht(t)},children:re.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",i.toFixed(1),"ms"]})},t)})}),re.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},pBn=n=>{if(n instanceof Blob)return n;if(n==null)return"";if(typeof n=="string")return n;if(typeof n=="object")try{return JSON.stringify(n,null,2)}catch{return String(n)}return String(n)},fBn=({renderLog:n,onRerunWithDebug:e})=>{const[t,i]=ce.useState("chronological"),[r,o]=ce.useState(""),s=[{value:"",label:"None"},{value:"DEBUG=Group_doInitialSchematicTraceRender",label:"DEBUG=Group_doInitialSchematicTraceRender"},{value:"DEBUG=Group_doInitialSchematicLayoutMatchpack",label:"DEBUG=Group_doInitialSchematicLayoutMatchpack"},{value:"DEBUG=Group_doInitialPcbLayoutPack",label:"DEBUG=Group_doInitialPcbLayoutPack"}];if(!n)return re.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[re.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),e&&re.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[re.jsx("select",{value:r,onChange:l=>o(l.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(l=>re.jsx("option",{value:l.value,children:l.label},l.value))}),re.jsx(R0,{onClick:()=>e(r),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]})]});const a=Object.entries(n?.phaseTimings??{});t==="chronological"?a.sort((l,u)=>cw.indexOf(l[0])-cw.indexOf(u[0])):a.sort((l,u)=>u[1]-l[1]);const c=a.reduce((l,[u,d])=>l+d,0);return re.jsxs("div",{className:"rf-bg-white",children:[re.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[re.jsx("div",{children:"Render Logs"}),re.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[e&&re.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[re.jsx("select",{value:r,onChange:l=>o(l.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(l=>re.jsx("option",{value:l.value,children:l.label},l.value))}),re.jsx(R0,{onClick:()=>e(r),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),re.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:re.jsxs("select",{onChange:l=>{if(l.target.value){const u=n?.debugOutputs?.find(d=>d.name===l.target.value);if(u){const d=pBn(u.content),h=d instanceof Blob?d:new Blob([d],{type:"text/plain"}),p=URL.createObjectURL(h),m=document.createElement("a");m.href=p,m.download=`debug-${u.name}.txt`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(p)}l.target.value=""}},disabled:!n?.debugOutputs||n.debugOutputs.length===0,className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white disabled:rf-opacity-50 disabled:rf-cursor-not-allowed",children:[re.jsx("option",{value:"",children:"Download Debug Output"}),n?.debugOutputs?.map(l=>re.jsx("option",{value:l.name,children:l.name},l.name))]})}),re.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[re.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),re.jsxs("select",{value:t,onChange:l=>i(l.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[re.jsx("option",{value:"chronological",children:"Phase Order"}),re.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),re.jsx(hBn,{phaseTimings:n.phaseTimings}),re.jsxs("table",{className:"rf-w-full rf-text-xs",children:[re.jsx("thead",{children:re.jsxs("tr",{children:[re.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),re.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),re.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),re.jsx("tbody",{children:a.map(([l,u])=>re.jsxs("tr",{children:[re.jsx("td",{className:"rf-p-2",children:cw.indexOf(l)}),re.jsx("td",{className:"rf-p-2",children:l}),re.jsx("td",{className:"rf-p-2",children:re.jsx("div",{className:"rf-w-8",children:re.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Qht(l),width:`${u/c*100}%`}})})}),re.jsx("td",{className:"rf-p-2",children:re.jsxs("div",{className:"rf-flex w-full",children:[re.jsxs("span",{className:"rf-flex-grow",children:[u,"ms"]}),re.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(u/c*100).toFixed(1),"%"]})]})})]},l))})]})]})},Jht=({errorMessage:n,errorStack:e,circuitJsonErrors:t})=>{ce.useEffect(()=>{if(n){const i=new Error(n);e&&(i.stack=e);try{Bj.captureException(i)}catch{}}},[n,e]),ce.useEffect(()=>{if(t&&t.length>0)for(const i of t){const r=new Error(i.message||"Circuit JSON Error");i.stack&&(r.stack=i.stack);try{Bj.captureException(r,{error_type:i.type})}catch{}}},[t])},ept="0.0.1185",mBn={version:ept};function j8(n,e){const[t,i]=ce.useState(()=>{try{const r=window.localStorage.getItem(n);return r?JSON.parse(r):e}catch(r){return console.error("Error reading from localStorage:",r),e}});return ce.useEffect(()=>{try{window.localStorage.setItem(n,JSON.stringify(t))}catch(r){console.error("Error writing to localStorage:",r)}},[n,t]),[t,i]}const cq=bze()(vze(n=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{n({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),_Bn=n=>{const[e,t]=ce.useState([]),[i,r]=ce.useState(null),[o,s]=ce.useState(""),[a,c]=j8("eval-version-selection",null),l=cq(p=>p.setLastRunEvalVersion),u=cq(p=>p.lastRunEvalVersion);return ce.useEffect(()=>{n&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(p=>p.json()).then(p=>{if(Array.isArray(p?.versions)){let m=[...p.versions];p.tags?.latest&&(r(p.tags.latest),m=m.filter(_=>_!==p.tags.latest)),t(m)}}).catch(()=>{})},[n]),ce.useEffect(()=>{n&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,l(i)))},[n,a,i]),{versions:ce.useMemo(()=>e.filter(p=>p.includes(o)).slice(0,50),[e,o]),latestVersion:i,lastRunEvalVersion:u,search:o,setSearch:s,selectVersion:p=>{c(p),s("")}}},yBn=({snippetNames:n,onSelect:e,onCancel:t,isOpen:i})=>{const[r,o]=ce.useState(""),[s,a]=ce.useState("");if(!i)return null;const c=n.filter(d=>d.toLowerCase().includes(s.toLowerCase())),l=s&&!n.includes(s),u=d=>{d.key==="Enter"&&(c.length===1?o(c[0]):l&&o(s))};return re.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:re.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[re.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),re.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:d=>a(d.target.value),onKeyDown:u}),re.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(d=>re.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===d?"bg-blue-50":""}`,onClick:()=>o(d),children:d},d)),l&&re.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),re.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[re.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:t,children:"Cancel"}),re.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},gBn=n=>{const e=ce.useRef(null),t=lb(i=>i.recentEvents);ce.useEffect(()=>{if(t.length===0)return;const i=t[0];i.event_id!==e.current&&(n(i),e.current=i.event_id)},[t,n])};var lq="Dialog",[tpt,npt]=JE(lq),[xBn,dE]=tpt(lq),ipt=n=>{const{__scopeDialog:e,children:t,open:i,defaultOpen:r,onOpenChange:o,modal:s=!0}=n,a=ce.useRef(null),c=ce.useRef(null),[l,u]=$A({prop:i,defaultProp:r??!1,onChange:o,caller:lq});return re.jsx(xBn,{scope:e,triggerRef:a,contentRef:c,contentId:Vb(),titleId:Vb(),descriptionId:Vb(),open:l,onOpenChange:u,onOpenToggle:ce.useCallback(()=>u(d=>!d),[u]),modal:s,children:t})};ipt.displayName=lq;var rpt="DialogTrigger",opt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=dE(rpt,t),o=H_(e,r.triggerRef);return re.jsx(au.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":fve(r.open),...i,ref:o,onClick:aa(n.onClick,r.onOpenToggle)})});opt.displayName=rpt;var hve="DialogPortal",[bBn,spt]=tpt(hve,{forceMount:void 0}),apt=n=>{const{__scopeDialog:e,forceMount:t,children:i,container:r}=n,o=dE(hve,e);return re.jsx(bBn,{scope:e,forceMount:t,children:ce.Children.map(i,s=>re.jsx(WS,{present:t||o.open,children:re.jsx(OG,{asChild:!0,container:r,children:s})}))})};apt.displayName=hve;var uq="DialogOverlay",cpt=ce.forwardRef((n,e)=>{const t=spt(uq,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=dE(uq,n.__scopeDialog);return o.modal?re.jsx(WS,{present:i||o.open,children:re.jsx(wBn,{...r,ref:e})}):null});cpt.displayName=uq;var vBn=zA("DialogOverlay.RemoveScroll"),wBn=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=dE(uq,t);return re.jsx(jG,{as:vBn,allowPinchZoom:!0,shards:[r.contentRef],children:re.jsx(au.div,{"data-state":fve(r.open),...i,ref:e,style:{pointerEvents:"auto",...i.style}})})}),q4="DialogContent",lpt=ce.forwardRef((n,e)=>{const t=spt(q4,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=dE(q4,n.__scopeDialog);return re.jsx(WS,{present:i||o.open,children:o.modal?re.jsx(SBn,{...r,ref:e}):re.jsx(EBn,{...r,ref:e})})});lpt.displayName=q4;var SBn=ce.forwardRef((n,e)=>{const t=dE(q4,n.__scopeDialog),i=ce.useRef(null),r=H_(e,t.contentRef,i);return ce.useEffect(()=>{const o=i.current;if(o)return n1e(o)},[]),re.jsx(upt,{...n,ref:r,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:aa(n.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:aa(n.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:aa(n.onFocusOutside,o=>o.preventDefault())})}),EBn=ce.forwardRef((n,e)=>{const t=dE(q4,n.__scopeDialog),i=ce.useRef(!1),r=ce.useRef(!1);return re.jsx(upt,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{n.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||t.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:o=>{n.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&r.current&&o.preventDefault()}})}),upt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:o,...s}=n,a=dE(q4,t),c=ce.useRef(null),l=H_(e,c);return zxe(),re.jsxs(re.Fragment,{children:[re.jsx(wG,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:o,children:re.jsx(vG,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":fve(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),re.jsxs(re.Fragment,{children:[re.jsx(MBn,{titleId:a.titleId}),re.jsx(ABn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),pve="DialogTitle",dpt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=dE(pve,t);return re.jsx(au.h2,{id:r.titleId,...i,ref:e})});dpt.displayName=pve;var hpt="DialogDescription",ppt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=dE(hpt,t);return re.jsx(au.p,{id:r.descriptionId,...i,ref:e})});ppt.displayName=hpt;var fpt="DialogClose",mpt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=dE(fpt,t);return re.jsx(au.button,{type:"button",...i,ref:e,onClick:aa(n.onClick,()=>r.onOpenChange(!1))})});mpt.displayName=fpt;function fve(n){return n?"open":"closed"}var _pt="DialogTitleWarning",[TBn,ypt]=cen(_pt,{contentName:q4,titleName:pve,docsSlug:"dialog"}),MBn=({titleId:n})=>{const e=ypt(_pt),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
5691
+ */const lBn=({containerClassName:n,...e})=>{const t=ce.useRef(null),[i,r]=ce.useState(620);return ce.useLayoutEffect(()=>{const o=()=>{if(t.current){const a=t.current.clientHeight,c=window.innerHeight;r(Math.min(Math.max(a,620),c))}};o();const s=new ResizeObserver(o);return t.current&&s.observe(t.current),window.addEventListener("resize",o),()=>{s.disconnect(),window.removeEventListener("resize",o)}},[]),re.jsx("div",{ref:t,className:n||"rf-w-full rf-h-full",children:re.jsx(cBn,{...e,height:i})})},uBn='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.18 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-1{right:.25rem}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.\\!rf-z-\\[200\\]{z-index:200!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-z-\\[101\\]{z-index:101}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-4{margin-left:1rem;margin-right:1rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mr-4{margin-right:1rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline-block{display:inline-block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-20{height:5rem}.rf-h-24{height:6rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-7{height:1.75rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[200px\\]{max-height:200px}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[70vh\\]{max-height:70vh}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[100px\\]{min-height:100px}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-20{width:5rem}.rf-w-24{width:6rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-40{width:10rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-80{width:20rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-32{min-width:8rem}.rf-min-w-80{min-width:20rem}.rf-min-w-96{min-width:24rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[600px\\]{min-width:600px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-64{max-width:16rem}.rf-max-w-96{max-width:24rem}.rf-max-w-\\[1000px\\]{max-width:1000px}.rf-max-w-\\[150px\\]{max-width:150px}.rf-max-w-\\[200px\\]{max-width:200px}.rf-max-w-\\[40\\%\\]{max-width:40%}.rf-max-w-\\[600px\\]{max-width:600px}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-max-w-xs{max-width:20rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.rf-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf--translate-x-1\\/2{--tw-translate-x:-50%}.rf--translate-x-1\\/2,.rf--translate-y-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-items-stretch{align-items:stretch}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.\\!rf-overflow-hidden{overflow:hidden!important}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rf-whitespace-normal{white-space:normal}.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-break-all{word-break:break-all}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-2{border-width:2px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-none{border-style:none}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-300{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-green-400{--tw-border-opacity:1;border-color:rgb(74 222 128/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-amber-50{--tw-bg-opacity:1;background-color:rgb(255 251 235/var(--tw-bg-opacity,1))}.rf-bg-amber-50\\/30{background-color:rgba(255,251,235,.3)}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-50\\/30{background-color:rgba(239,246,255,.3)}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-amber-500{fill:#f59e0b}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-1{padding-bottom:.25rem}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-0{padding-top:0}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.\\!rf-font-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-amber-500{--tw-text-opacity:1;color:rgb(245 158 11/var(--tw-text-opacity,1))}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity,1))}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.rf-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.rf-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.rf-text-slate-800{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-600{--tw-text-opacity:1;color:rgb(202 138 4/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-70{opacity:.7}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:rf-border-blue-500:hover{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-slate-200:hover{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-800:hover{--tw-text-opacity:1;color:rgb(30 41 59/var(--tw-text-opacity,1))}.hover\\:rf-text-slate-900:hover{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group:hover .group-hover\\:rf-opacity-100,.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\=true\\]\\:rf-opacity-50[data-disabled=true],.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-gray-700:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.dark\\:rf-bg-gray-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-gray-500:is(.rf-dark *){--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-block{display:block}.sm\\:rf-inline{display:inline}.sm\\:rf-grid{display:grid}.sm\\:rf-hidden{display:none}.sm\\:rf-w-auto{width:auto}.sm\\:rf-grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\\:rf-grid-cols-\\[1fr_auto\\]{grid-template-columns:1fr auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-justify-self-end{justify-self:end}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-right{text-align:right}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',aq=()=>{ce.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=uBn,document.head.appendChild(e)},[])},dBn=n=>{ce.useEffect(()=>(n?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[n])},Qht=n=>`hsl(${cw.indexOf(n)*137.5%360}, 70%, 50%)`,hBn=({phaseTimings:n})=>{if(!n)return null;const e=Object.values(n).reduce((t,i)=>t+i,0);return re.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[re.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:cw.map(t=>{const i=n[t]||0,r=i/e*100;return re.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${r}%`,backgroundColor:Qht(t)},children:re.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",i.toFixed(1),"ms"]})},t)})}),re.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},pBn=n=>{if(n instanceof Blob)return n;if(n==null)return"";if(typeof n=="string")return n;if(typeof n=="object")try{return JSON.stringify(n,null,2)}catch{return String(n)}return String(n)},fBn=({renderLog:n,onRerunWithDebug:e})=>{const[t,i]=ce.useState("chronological"),[r,o]=ce.useState(""),s=[{value:"",label:"None"},{value:"DEBUG=Group_doInitialSchematicTraceRender",label:"DEBUG=Group_doInitialSchematicTraceRender"},{value:"DEBUG=Group_doInitialSchematicLayoutMatchpack",label:"DEBUG=Group_doInitialSchematicLayoutMatchpack"},{value:"DEBUG=Group_doInitialPcbLayoutPack",label:"DEBUG=Group_doInitialPcbLayoutPack"}];if(!n)return re.jsxs("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:[re.jsx("div",{className:"rf-mb-4",children:"No render log, make sure this tab is open when you render"}),e&&re.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[re.jsx("select",{value:r,onChange:l=>o(l.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(l=>re.jsx("option",{value:l.value,children:l.label},l.value))}),re.jsx(R0,{onClick:()=>e(r),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]})]});const a=Object.entries(n?.phaseTimings??{});t==="chronological"?a.sort((l,u)=>cw.indexOf(l[0])-cw.indexOf(u[0])):a.sort((l,u)=>u[1]-l[1]);const c=a.reduce((l,[u,d])=>l+d,0);return re.jsxs("div",{className:"rf-bg-white",children:[re.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center rf-mb-4",children:[re.jsx("div",{children:"Render Logs"}),re.jsxs("div",{className:"rf-flex rf-gap-4 rf-items-center",children:[e&&re.jsxs("div",{className:"rf-flex rf-gap-2 rf-items-center",children:[re.jsx("select",{value:r,onChange:l=>o(l.target.value),className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white",children:s.map(l=>re.jsx("option",{value:l.value,children:l.label},l.value))}),re.jsx(R0,{onClick:()=>e(r),size:"sm",className:"rf-text-xs",children:"Rerun Render with Debug"})]}),re.jsx("div",{className:"rf-flex rf-gap-2 rf-items-center",children:re.jsxs("select",{onChange:l=>{if(l.target.value){const u=n?.debugOutputs?.find(d=>d.name===l.target.value);if(u){const d=pBn(u.content),h=d instanceof Blob?d:new Blob([d],{type:"text/plain"}),p=URL.createObjectURL(h),m=document.createElement("a");m.href=p,m.download=`debug-${u.name}.txt`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(p)}l.target.value=""}},disabled:!n?.debugOutputs||n.debugOutputs.length===0,className:"rf-px-3 rf-py-1 rf-border rf-rounded rf-text-xs rf-bg-white disabled:rf-opacity-50 disabled:rf-cursor-not-allowed",children:[re.jsx("option",{value:"",children:"Download Debug Output"}),n?.debugOutputs?.map(l=>re.jsx("option",{value:l.name,children:l.name},l.name))]})}),re.jsxs("div",{className:"rf-flex rf-text-xs rf-items-center",children:[re.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),re.jsxs("select",{value:t,onChange:l=>i(l.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[re.jsx("option",{value:"chronological",children:"Phase Order"}),re.jsx("option",{value:"longest",children:"Duration"})]})]})]})]}),re.jsx(hBn,{phaseTimings:n.phaseTimings}),re.jsxs("table",{className:"rf-w-full rf-text-xs",children:[re.jsx("thead",{children:re.jsxs("tr",{children:[re.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),re.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),re.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),re.jsx("tbody",{children:a.map(([l,u])=>re.jsxs("tr",{children:[re.jsx("td",{className:"rf-p-2",children:cw.indexOf(l)}),re.jsx("td",{className:"rf-p-2",children:l}),re.jsx("td",{className:"rf-p-2",children:re.jsx("div",{className:"rf-w-8",children:re.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:Qht(l),width:`${u/c*100}%`}})})}),re.jsx("td",{className:"rf-p-2",children:re.jsxs("div",{className:"rf-flex w-full",children:[re.jsxs("span",{className:"rf-flex-grow",children:[u,"ms"]}),re.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(u/c*100).toFixed(1),"%"]})]})})]},l))})]})]})},Jht=({errorMessage:n,errorStack:e,circuitJsonErrors:t})=>{ce.useEffect(()=>{if(n){const i=new Error(n);e&&(i.stack=e);try{Bj.captureException(i)}catch{}}},[n,e]),ce.useEffect(()=>{if(t&&t.length>0)for(const i of t){const r=new Error(i.message||"Circuit JSON Error");i.stack&&(r.stack=i.stack);try{Bj.captureException(r,{error_type:i.type})}catch{}}},[t])},ept="0.0.1186",mBn={version:ept};function j8(n,e){const[t,i]=ce.useState(()=>{try{const r=window.localStorage.getItem(n);return r?JSON.parse(r):e}catch(r){return console.error("Error reading from localStorage:",r),e}});return ce.useEffect(()=>{try{window.localStorage.setItem(n,JSON.stringify(t))}catch(r){console.error("Error writing to localStorage:",r)}},[n,t]),[t,i]}const cq=bze()(vze(n=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{n({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),_Bn=n=>{const[e,t]=ce.useState([]),[i,r]=ce.useState(null),[o,s]=ce.useState(""),[a,c]=j8("eval-version-selection",null),l=cq(p=>p.setLastRunEvalVersion),u=cq(p=>p.lastRunEvalVersion);return ce.useEffect(()=>{n&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(p=>p.json()).then(p=>{if(Array.isArray(p?.versions)){let m=[...p.versions];p.tags?.latest&&(r(p.tags.latest),m=m.filter(_=>_!==p.tags.latest)),t(m)}}).catch(()=>{})},[n]),ce.useEffect(()=>{n&&(a?(window.TSCIRCUIT_LATEST_EVAL_VERSION=a,l(a)):i&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=i,l(i)))},[n,a,i]),{versions:ce.useMemo(()=>e.filter(p=>p.includes(o)).slice(0,50),[e,o]),latestVersion:i,lastRunEvalVersion:u,search:o,setSearch:s,selectVersion:p=>{c(p),s("")}}},yBn=({snippetNames:n,onSelect:e,onCancel:t,isOpen:i})=>{const[r,o]=ce.useState(""),[s,a]=ce.useState("");if(!i)return null;const c=n.filter(d=>d.toLowerCase().includes(s.toLowerCase())),l=s&&!n.includes(s),u=d=>{d.key==="Enter"&&(c.length===1?o(c[0]):l&&o(s))};return re.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:re.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[re.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),re.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:s,onChange:d=>a(d.target.value),onKeyDown:u}),re.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[c.map(d=>re.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${r===d?"bg-blue-50":""}`,onClick:()=>o(d),children:d},d)),l&&re.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${r===s?"bg-blue-50":""}`,onClick:()=>o(s),children:['Create new "',s,'"']})]}),re.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[re.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:t,children:"Cancel"}),re.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>r&&e(r),disabled:!r,children:r===s?`Create "${r}"`:`Save to ${r}`})]})]})})},gBn=n=>{const e=ce.useRef(null),t=lb(i=>i.recentEvents);ce.useEffect(()=>{if(t.length===0)return;const i=t[0];i.event_id!==e.current&&(n(i),e.current=i.event_id)},[t,n])};var lq="Dialog",[tpt,npt]=JE(lq),[xBn,dE]=tpt(lq),ipt=n=>{const{__scopeDialog:e,children:t,open:i,defaultOpen:r,onOpenChange:o,modal:s=!0}=n,a=ce.useRef(null),c=ce.useRef(null),[l,u]=$A({prop:i,defaultProp:r??!1,onChange:o,caller:lq});return re.jsx(xBn,{scope:e,triggerRef:a,contentRef:c,contentId:Vb(),titleId:Vb(),descriptionId:Vb(),open:l,onOpenChange:u,onOpenToggle:ce.useCallback(()=>u(d=>!d),[u]),modal:s,children:t})};ipt.displayName=lq;var rpt="DialogTrigger",opt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=dE(rpt,t),o=H_(e,r.triggerRef);return re.jsx(au.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":fve(r.open),...i,ref:o,onClick:aa(n.onClick,r.onOpenToggle)})});opt.displayName=rpt;var hve="DialogPortal",[bBn,spt]=tpt(hve,{forceMount:void 0}),apt=n=>{const{__scopeDialog:e,forceMount:t,children:i,container:r}=n,o=dE(hve,e);return re.jsx(bBn,{scope:e,forceMount:t,children:ce.Children.map(i,s=>re.jsx(WS,{present:t||o.open,children:re.jsx(OG,{asChild:!0,container:r,children:s})}))})};apt.displayName=hve;var uq="DialogOverlay",cpt=ce.forwardRef((n,e)=>{const t=spt(uq,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=dE(uq,n.__scopeDialog);return o.modal?re.jsx(WS,{present:i||o.open,children:re.jsx(wBn,{...r,ref:e})}):null});cpt.displayName=uq;var vBn=zA("DialogOverlay.RemoveScroll"),wBn=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=dE(uq,t);return re.jsx(jG,{as:vBn,allowPinchZoom:!0,shards:[r.contentRef],children:re.jsx(au.div,{"data-state":fve(r.open),...i,ref:e,style:{pointerEvents:"auto",...i.style}})})}),q4="DialogContent",lpt=ce.forwardRef((n,e)=>{const t=spt(q4,n.__scopeDialog),{forceMount:i=t.forceMount,...r}=n,o=dE(q4,n.__scopeDialog);return re.jsx(WS,{present:i||o.open,children:o.modal?re.jsx(SBn,{...r,ref:e}):re.jsx(EBn,{...r,ref:e})})});lpt.displayName=q4;var SBn=ce.forwardRef((n,e)=>{const t=dE(q4,n.__scopeDialog),i=ce.useRef(null),r=H_(e,t.contentRef,i);return ce.useEffect(()=>{const o=i.current;if(o)return n1e(o)},[]),re.jsx(upt,{...n,ref:r,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:aa(n.onCloseAutoFocus,o=>{o.preventDefault(),t.triggerRef.current?.focus()}),onPointerDownOutside:aa(n.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:aa(n.onFocusOutside,o=>o.preventDefault())})}),EBn=ce.forwardRef((n,e)=>{const t=dE(q4,n.__scopeDialog),i=ce.useRef(!1),r=ce.useRef(!1);return re.jsx(upt,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{n.onCloseAutoFocus?.(o),o.defaultPrevented||(i.current||t.triggerRef.current?.focus(),o.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:o=>{n.onInteractOutside?.(o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=o.target;t.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&r.current&&o.preventDefault()}})}),upt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:o,...s}=n,a=dE(q4,t),c=ce.useRef(null),l=H_(e,c);return zxe(),re.jsxs(re.Fragment,{children:[re.jsx(wG,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:o,children:re.jsx(vG,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":fve(a.open),...s,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),re.jsxs(re.Fragment,{children:[re.jsx(MBn,{titleId:a.titleId}),re.jsx(ABn,{contentRef:c,descriptionId:a.descriptionId})]})]})}),pve="DialogTitle",dpt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=dE(pve,t);return re.jsx(au.h2,{id:r.titleId,...i,ref:e})});dpt.displayName=pve;var hpt="DialogDescription",ppt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=dE(hpt,t);return re.jsx(au.p,{id:r.descriptionId,...i,ref:e})});ppt.displayName=hpt;var fpt="DialogClose",mpt=ce.forwardRef((n,e)=>{const{__scopeDialog:t,...i}=n,r=dE(fpt,t);return re.jsx(au.button,{type:"button",...i,ref:e,onClick:aa(n.onClick,()=>r.onOpenChange(!1))})});mpt.displayName=fpt;function fve(n){return n?"open":"closed"}var _pt="DialogTitleWarning",[TBn,ypt]=cen(_pt,{contentName:q4,titleName:pve,docsSlug:"dialog"}),MBn=({titleId:n})=>{const e=ypt(_pt),t=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
5692
5692
 
5693
5693
  If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
5694
5694
 
package/package.json CHANGED
@@ -3,14 +3,13 @@
3
3
  "main": "dist/index.js",
4
4
  "types": "dist/index.d.ts",
5
5
  "type": "module",
6
- "version": "0.0.841",
6
+ "version": "0.0.842-libonly",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/tscircuit/tscircuit"
10
10
  },
11
11
  "files": [
12
12
  "dist",
13
- "cli.mjs",
14
13
  "globals.d.ts"
15
14
  ],
16
15
  "scripts": {
@@ -29,10 +28,6 @@
29
28
  },
30
29
  "./browser": "./dist/browser.min.js"
31
30
  },
32
- "bin": {
33
- "tsci": "cli.mjs",
34
- "tscircuit": "cli.mjs"
35
- },
36
31
  "devDependencies": {
37
32
  "@types/bun": "^1.2.16",
38
33
  "esbuild": "^0.20.2",
@@ -50,7 +45,6 @@
50
45
  "@tscircuit/checks": "^0.0.85",
51
46
  "@tscircuit/circuit-json-flex": "^0.0.3",
52
47
  "@tscircuit/circuit-json-util": "^0.0.72",
53
- "@tscircuit/cli": "^0.1.423",
54
48
  "@tscircuit/core": "^0.0.839",
55
49
  "@tscircuit/eval": "^0.0.444",
56
50
  "@tscircuit/footprinter": "^0.0.236",
@@ -60,7 +54,7 @@
60
54
  "@tscircuit/miniflex": "^0.0.4",
61
55
  "@tscircuit/ngspice-spice-engine": "^0.0.2",
62
56
  "@tscircuit/props": "^0.0.387",
63
- "@tscircuit/runframe": "^0.0.1186",
57
+ "@tscircuit/runframe": "^0.0.1187",
64
58
  "@tscircuit/schematic-match-adapt": "^0.0.16",
65
59
  "@tscircuit/schematic-trace-solver": "^0.0.41",
66
60
  "@tscircuit/simple-3d-svg": "^0.0.41",
@@ -72,7 +66,7 @@
72
66
  "circuit-json-to-connectivity-map": "^0.0.22",
73
67
  "circuit-json-to-gltf": "^0.0.31",
74
68
  "circuit-json-to-simple-3d": "^0.0.9",
75
- "circuit-json-to-spice": "^0.0.17",
69
+ "circuit-json-to-spice": "^0.0.16",
76
70
  "circuit-to-svg": "^0.0.260",
77
71
  "comlink": "^4.4.2",
78
72
  "connectivity-map": "^1.0.0",
@@ -95,4 +89,4 @@
95
89
  "transformation-matrix": "^2.16.1",
96
90
  "zod": "^3.25.67"
97
91
  }
98
- }
92
+ }
package/cli.mjs DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- import { createRequire } from "node:module";
4
- const require = createRequire(import.meta.url);
5
-
6
- // Use require to import package.json
7
- const packageJson = require("./package.json");
8
- global.TSCIRCUIT_VERSION = packageJson.version;
9
-
10
- async function main() {
11
- await import("@tscircuit/cli");
12
- }
13
-
14
- main();